помощь в настройке скрипта ImgRandom 1.0

hamveeas

Новичок
помощь в настройке скрипта ImgRandom 1.0

нужна небольшая помощь.дело в том что я уже целый день бьюсь над этим скриптом я перечитал все что только можно и теперь в голаве получилась такая каша поэтому и решил обратится за по мощью сам скрипт состоит из одного файла вот код
PHP:
<?php    #This script has been developped by Francesco D'Alesio [[email protected]]  #Please feel free to contact me for any reason    #All you have to do is to change this two variables. Remember to use the absolute path for the first variable, starting with a slash    $absolute = "/home/httpdocs/images/imgrandom";  $url = "http://www.yourdomain.com/images/imgrandom";    #You my now add in the img html tag the url of this script  #<IMG SRC="http://yourdomain.com/whatever/imgrandom.php3">    # DO NOT CHANGE ANYTHING BELOW THIS LINE    $randir = dir("$absolute");    $num = 0;    while($read = readdir($randir))    {    $tmp = split("\.", $read, 2);    if ($tmp[1] == "jpg" || $tmp[1] == "JPG")    {    $imgsrc[] = $read;    $num++;    }    if ($tmp[1] == "gif" || $tmp[1] == "GIF")    {    $imgsrc[] = $read;    $num++;    }  }    srand((double)microtime()*1000000);    $imgrandom = rand(0,($num-1));        header("location: $url/$imgsrc[$imgrandom]");    ?>
а это readme
Please open imgrandom.php3 and change the 2 variables needed.

Then you can point your html img src tag to the script like this
<IMG SRC="http://www.yourdomain.com/whatever/imgrandom.php3">

я прописал все
PHP:
<?php    #This script has been developped by Francesco D'Alesio [[email protected]]  #Please feel free to contact me for any reason    #All you have to do is to change this two variables. Remember to use the absolute path for the first variable, starting with a slash    $absolute = "/home/hamveeas/public_html/images/imgrandom";  $url = "http://news-inet.ru/whatever/imgrandom.php3";    #You my now add in the img html tag the url of this script  #<IMG SRC="http://yourdomain.com/whatever/imgrandom.php3">    # DO NOT CHANGE ANYTHING BELOW THIS LINE    $randir = dir("$absolute");    $num = 0;    while($read = readdir($randir))    {    $tmp = split("\.", $read, 2);    if ($tmp[1] == "jpg" || $tmp[1] == "JPG")    {    $imgsrc[] = $read;    $num++;    }    if ($tmp[1] == "gif" || $tmp[1] == "GIF")    {    $imgsrc[] = $read;    $num++;    }  }    srand((double)microtime()*1000000);    $imgrandom = rand(0,($num-1));        header("location: $url/$imgsrc[$imgrandom]");    ?>
но у меня он выдает вот такую ошибку
Warning: readdir(): supplied argument is not a valid Directory resource in /home/hamveeas/public_html/whatever/imgrandom.php3 on line 20

Warning: Cannot modify header information - headers already sent by (output started at /home/hamveeas/public_html/whatever/imgrandom.php3:20) in /home/hamveeas/public_html/whatever/imgrandom.php3 on line 58

Версия PHP 5.2.6
register_globals on
Версия Apache 1.3.41 (Unix)
прошу мне объяснить что я делаю не так
заранее спасибо
 

Ярослав

Новичок
1. Оформи код в нормальный вид
2. http://ua.php.net/manual/en/class.dir.php
3. http://ua.php.net/manual/en/function.readdir.php
 

dimagolov

Новичок
расширение php3 наводит на мысль, что скрипт писался под 3-ю версию, то есть его надо адаптировать к 5-й
 
Сверху