Archive for the 'PHP' Category
PHP function to look for images
The function below will look for numerically numbered images (or any other type of file) on any giving website. The function will echo weather or not it found anything, if it found something it will return the html image code(s) for it.
/*When calling the function $istop should equal 1. $name should equal the name you want to echo. $imgurl should equal the image url until the number (if you had http://naterocks.com/image1.gif then the url would be http://naterocks.com/image), $ext should equal the file extension (you do not have the put a “.”, in the example above this would mean that $ext=”gif”), $number equals the number that you want to start searching from, $nwe is how many images you want per line, and $nwt should equal 1 when being called.*/
//to call use $variable=look_image(1,$name,$imgurl,$ext,$number,$nwe,1);Â
 function look_image($istop,$name,$imgurl,$ext,$number,$nwe,$nwt)
{
$url=$imgurl.$number.”.”.$ext;
if( !fopen($url, “r”) )
   {
     if ($istop==1)
      {$nwf=0;}
     echo ($name.” searching ended on number:”.$number.”<br>”);
   }
   else {
   if ($istop==1)
    { echo (”<b>New “.$name.”(s) found!</b>”);
    $post=”\n\n[b]New “.$name.”(s):[/b] \n”;
     }
   echo(”<br><img src=’”.$url.”‘><br>”);
   if ($nwe!=$nwt)
   { $post=$post.”<img src=’”.$url.”‘>”; }
   else
   { $post=$post.”<img src=’”.$url.”‘> \n”;
   $nwt=0; }
        //some math
   $number++;
   $nwt++;
   //keep looking
   $nwf=$post.look_image(0,$name,$imgurl,$ext,$number,$fname,$nwe,$nwt);
   }
 return $nwf;
}
Shop Moved
Yes, it’s ture. The NateRocks.com store have moved. It is now at http://www.printfection.com/naterocks .
Happy shopping….
No commentsNew PHP script
I just finished a new PHP script, it is called Site Moved Script. It will be useful to you if you have changed the url of your site. What it does is it redirects users to your new url and gives them a message about your move.
You find out more about this script on its webpage. (here)
No comments

