Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    adding in br to extrnal text file

    bit of a silly one this (im re-writing it after ie decided to crash as soon as i hit post,.. man, must remeber ctrl+c next time. lol)

    I have a dynamic sig ( http://www.nick-web.co.uk/sig/button1.php ), and the code for that is
    PHP Code:
    <?

    // Begin Random Quote 1
        
    $delim "\n";
        
    $quotefile "random_insults.txt";
        
    // Begin. 
        
    $fp fopen($quotefile"r");
        
    $contents fread($fpfilesize($quotefile)); 
        
    $quote_arr explode($delim,$contents); 
        
    fclose($fp); 
        
    // initiate randomness
        
    srand((double)microtime()*1000000); 
        
    // generate random quote index 
        
    $quote_index = (rand(1sizeof($quote_arr)) - 1); 
        
    // get quote at $quote_index and return it 
        
    $herequote $quote_arr[$quote_index]; 
    // End Random Quote 

    // Begin Random Quote 2
        
    $delim "\n";
        
    $quotefile1 "random.txt";
        
    // Begin. 
        
    $fp fopen($quotefile1"r");
        
    $contents fread($fpfilesize($quotefile1)); 
        
    $quote_arr explode($delim,$contents); 
        
    fclose($fp); 
        
    // initiate randomness
        
    srand((double)microtime()*1000000); 
        
    // generate random quote index 
        
    $quote_index = (rand(1sizeof($quote_arr)) - 1); 
        
    // get quote at $quote_index and return it 
        
    $herequote1 $quote_arr[$quote_index]; 
    // End Random Quote 2

    //Begin Image
        
    header("Content-type: image/png"); //create png headers
        
    $string $_GET['text']; 
        
    $remote_addr $REMOTE_ADDR//assing the remote_addr variable
        
    $agent $HTTP_USER_AGENT;  //assing the user agent variable
        
    $host gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']); //asssing the host variable
        
    $im     imagecreatefrompng("images/button1.png"); //background image( images/button1.png)
        
    $black imagecolorallocate($im000); //assing colour black, 0, 0, 0, is the R, G, B values)
        
    $blue imagecolorallocate($im00255); //assing colour black, 0, 0, 0, is the R, G, B values)
        
    imagestring($im300"You Host: $host"$black); //Draw in $im(the image), 3(dunno), 0(width from edge of pic), 9(height frm top), "Host: $host"(Write that text), $black (using the colour black (Assigned earlier ;) )
        
    imagestring($im32500"Your IP address: $remote_addr"$black); //same as above
        
    imagestring($im3015$herequote$blue); //same again,
        
    imagestring($im3082$herequote1$black); //after nick-web.co.uk randquote
        
    imagepng($im,'',100);  //create the temp image
        
    imagedestroy($im); //destroy the temp image
    //End Image
    ?>
    as u can see, it reads 2 txt files, random_insults.txt and random.txt. If u refresh the sig a couple of times ul end up oming accross aquote that runs over the image.. i.e the text is to long. Is there any way to automatically add a br after it finds a space after, say the 80th character? (so after 80 characters, it looks for a space, and when it finds one, it adds a liane break).. is this possible?

    Next up, you can see it says host and then displays some weird thing about ur host.. Is there any way so that it check s for a normal hostname, i.e aol and then just displays that instead if ABAF0F0.itp.aol.com or stuff?

    Thanks in advance again.. (hopefully it wont crash this time )

    Nick

  • #2
    New to the CF scene
    Join Date
    Nov 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can anybody help with this? i have this code
    PHP Code:
    <? 
    // Begin Random Quote 1 
        
    $delim "\n"
        
    $quotefile "random_insults.txt"
        
    // Begin. 
        
    $fp fopen($quotefile"r"); 
        
    $contents fread($fpfilesize($quotefile)); 
        
    $quote_arr explode($delim,$contents); 
        
    fclose($fp); 
        
    // initiate randomness 
        
    srand((double)microtime()*1000000); 
        
    // generate random quote index 
        
    $quote_index = (rand(1sizeof($quote_arr)) - 1); 
        
    // get quote at $quote_index and return it 
        
    $herequote $quote_arr[$quote_index]; 
    // Begin break the string 
    if ( strlen($herequote) > "70" ) { 
       
    //begin search for a space 
       
    $thisstring explode(" ",$herequote); 
       for(
    $i 0$i $length$i++){ 
        
    $output[$i] = $temp_output substr($thisstring$i1); 
        
    $i++; 
       } 
       
    $i 70;  // set the break point 
       
    $test $output[$i]; //set up the first test 
       
    while ( $test <> " " ) { //look for a space 
        
    $i--; 
         
    $test $output[$i];   //get the previous character in the string 
       

       
    $test $i
       for (
    $i 0$i $test$i++) { 
          
    $herequote += $output[$i]; 
       } 
       
    $herequotf ""
       for (
    $i $test$i $length$i++) { 
          
    $herequotf += $output[$i]; 
       } 

    // End break the string 
    // End Random Quote 

    // Begin Random Quote 2 
        
    $delim "\n"
        
    $quotefile1 "random.txt"
        
    // Begin. 
        
    $fp fopen($quotefile1"r"); 
        
    $contents fread($fpfilesize($quotefile1)); 
        
    $quote_arr explode($delim,$contents); 
        
    fclose($fp); 
        
    // initiate randomness 
        
    srand((double)microtime()*1000000); 
        
    // generate random quote index 
        
    $quote_index = (rand(1sizeof($quote_arr)) - 1); 
        
    // get quote at $quote_index and return it 
        
    $herequote1 $quote_arr[$quote_index]; 
    // End Random Quote 2 

    //Begin Image 
        
    header("Content-type: image/png"); //create png headers 
        
    $string $_GET['text']; 
        
    $remote_addr $REMOTE_ADDR//assing the remote_addr variable 
        
    $agent $HTTP_USER_AGENT;  //assing the user agent variable 
        
    $host gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']); //asssing the host variable 
        
    $im     imagecreatefrompng("images/button1.png"); //background image( images/button1.png) 
        
    $black imagecolorallocate($im000); //assing colour black, 0, 0, 0, is the R, G, B values) 
        
    $blue imagecolorallocate($im00255); //assing colour black, 0, 0, 0, is the R, G, B values) 
        
    imagestring($im300"You Host: $host"$black); //Draw in $im(the image), 3(dunno), 0(width from edge of pic), 9(height frm top), "Host: $host"(Write that text), $black (using the colour black (Assigned earlier  ) 
        
    imagestring($im32500"Your IP address: $remote_addr"$black); //same as above 
        
    imagestring($im3015$herequote$blue); //same again, 
        
    if ( $herequotf ) { 
        
    imagestring($im3025$herequote$blue); //same again, 
        

        
    imagestring($im3082$herequote1$black); //after nick-web.co.uk randquote 
        
    imagepng($im,'',100);  //create the temp image 
        
    imagedestroy($im); //destroy the temp image 
    //End Image 
    ?>
    however, i keep gettin a max execution time error... any ideas whats causing this?


    Thanks again, Nick


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •