Jump to content

papaface

Members
  • Posts

    1,437
  • Joined

  • Last visited

    Never

Posts posted by papaface

  1. Hey

     

    I am trying to find a way of retrieving the href value in a link on a specific webpage. However I only want to retrieve the href values for <a> elements that have the text "Click here to find out more".

    e.g.

    <a href="link.com/fdhh.php">Click here to find out more</a>

    Is there any specific PHP function that'll allow me to do that?

     

    Any help would be appreciated :)

  2. Ok I worked out how to do it:

    htmlspecialchars_decode(htmlspecialchars_decode($conv_current['Title'], ENT_QUOTES ) , ENT_QUOTES);

    In the browser it now displays correctly as:

    ADELE 'Cold Shoulder'

    But in text boxes it displays as:

    <input type="hidden" id="conv_Title" value="ADELE &#039;Cold Shoulder&#039;" />

    Again :(
  3. Hey,

     

    I am some text in a script that is converted as follows:

    	function get_htmlspecialchars( $given, $quote_style = ENT_QUOTES, $double_quotes = false )
    
    {
    
    	if($double_quotes)
    
    		return htmlspecialchars(htmlspecialchars( $given, $quote_style ) , $quote_style);
    
    	else
    
       			return htmlspecialchars( html_entity_decode( $given, $quote_style ), $quote_style );
    
    }

    Example:

    get_htmlspecialchars($results['title'],ENT_QUOTES,true);

     

    How can I get it back to regular text instead of things like:

    ADELE &#039;Cold Shoulder&#039;
    Lettering :(

     

    I can't for the life of me work out how to do it and its driving me insane lol

  4. echo <<<CODE
    <form action="<?php echo __FILE__; ?>" name="test">
    Name : <input type="text" name="name" /><br />
    E-Mail : <input type="text" name="email" /><br />
    </form>
    CODE;

  5. Not sure how you'd want that implemented in the code but it would be

    if (in_multiarray($_GET['input'],$ranges)) { header('Location: banned.php'); } else { //done something }

    Is that what you want?

  6. Not saying my way is the best possible way to do it, but it works.

    <?php
        function in_multiarray($elem, $array)
        {
            $top = sizeof($array) - 1;
            $bottom = 0;
            while($bottom <= $top)
            {
                if($array[$bottom] == $elem)
                    return true;
                else
                    if(is_array($array[$bottom]))
                        if(in_multiarray($elem, ($array[$bottom])))
                            return true;
                       
                $bottom++;
            }       
            return false;
        }
       
    $ranges = range(4600,5000);
    $ranges[] = range(400,800);
    $ranges[] = array(46, 207, 336, 982);
    $rand = rand(1,7000);
    while   (in_multiarray($rand,$ranges))
    $rand = rand(1,7000);
    echo "yay:".$rand;
    ?>

  7. Try:

    <?php
        function in_multiarray($elem, $array)
        {
            $top = sizeof($array) - 1;
            $bottom = 0;
            while($bottom <= $top)
            {
                if($array[$bottom] == $elem)
                    return true;
                else
                    if(is_array($array[$bottom]))
                        if(in_multiarray($elem, ($array[$bottom])))
                            return true;
                       
                $bottom++;
            }       
            return false;
        }
    
    $ranges = range(4600,5000);
    $ranges[] = range(400,800);
    $rand = rand(1,7000);
    while	(in_multiarray($rand,$ranges))
    $rand = rand(1,7000);
    echo "yay:".$rand;
    ?>
    

  8. Hey,

     

    I am trying to work out the difference between two times that are entered into a form like this:

    00:00:10 and 00:00:13

     

    I want to work out the time difference between the two times. Can anyone point me in the direction of how to do this? I have tried looking at the strftime function but I just can't work out how to do it.

     

    I know how to do it with mktime:

    $start = mktime(0, 0, 3, 0, 0, 0);//hour,minute,seconds
    $end = mktime(0, 0, 10, 0, 0, 0);;
    
    echo "start: ". $start . " end: ".$end."<br />";
    
    echo $end-$start; //7 seconds difference

    But I'm not able to receive the data in a way to put it into the mktime function without causing problems.

     

    Any help would be appreciated :)

  9. if your using the file_exists function you won't really need the switch

     

    $choice= $_GET['act'];
    
    include (file_exists("includes/$choice.php")  ? "includes/$choice.php" : "includes/about.php");
    

    Couldn't that cause possible security issues as you can potentially include any file in the includes directory as long as it exists....

  10. Hey,

     

    Please can someone help me with this.

    I have a page that refuses to load when I have session_start(); in the code.

     

    This is the top of the page:

    <?php
    session_start();
    error_reporting(1);
    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    The page just loads constantly displaying nothing when session_start(); is in there, but when I take it out, its fine.

     

    Any ideas as to what is causing this?

  11. Hey,

     

    I am about to go insane so please can someone come to my aid lol.

     

    My code:

    function download($url)
    {
    $curl = curl_init();
    
    if($curl)
    {
         if( !curl_setopt($curl, CURLOPT_URL, $url) ) return "FAIL: curl_setopt(CURLOPT_URL)";
         if( !curl_setopt($curl, CURLOPT_HEADER, array("Accept: text/xml,application/xml,application/xhtml+xml,text/html,;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept-Language: en-us,en;q=0.5", "Connection: keep-alive", "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.4) Gecko/20070625 Ubuntu/7.10 (gutsy) Firefox/3.0.0.7", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300")) ) return "FAIL: curl_setopt(CURLOPT_HEADER)";
     $ret = curl_exec($curl);
         if( !$ret ) return "FAIL: curl_exec()";
         curl_close($curl);
    
    if	(strpos($ret, "Payment Required") > 0)
    	{ 
    	return "Payment is required <br />";
    	}
    else
    	{
    	return $ret;
    	}
    }
    else return "FAIL: curl_init()";
    }

    Sample of cURL output:

    HTTP/1.1 402 Payment Required Date: Thu, 10 Dec 2009

    Why would that show when I am asking it to return "Payment is required <br />" if the $ret var contains the string "Payment Required"?

     

    Any help would be appreciated :)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.