jags2ooo
asked on
Simple display image Code won't work in PHP5
This script works fine in php4 but when i put it on my Main server which is php5 it doesn't work. IS there any reason why it wouldn't work in php5?
I attempted to remove the c_scandir function and use scandir instead for php5 but it still fails.
Example: working (php4) - http://bleach-network.com/manga-reader/image.php?id=1&what=1
example2: not working (php5) - http://bleachnet.mine.nu/Downloads/manga-reader/image.php?id=1&what=1
PHP5 php.ini file ::: http://bleachnet.mine.nu/Downloads/php.txt
<?php
// Custom scandir function
function c_scandir($dir)
{ if (function_exists('scandir' ))
{
return scandir($dir);
}
$fileps = array();
if ($handle = opendir($dir)) {
while (false !== ($filep = readdir($handle))) {
$fileps[] = $filep;
}
closedir($handle);
}
return $fileps;
}
$komiks = (int) $_GET['id'];
if ($komiks > 0) {
$what = (int) $_GET['what'];
if ($what>0) {
$nrkat = 0;
$katalog = c_scandir('.');
foreach ($katalog as $file) {
if ((filetype($file)=='dir')& &($file!=' .')&&($fil e!='..')) {
$nrkat++;
if ($nrkat == $komiks) {
$komi = c_scandir($file);
$nrko = 0;
foreach ($komi as $file2) {
if ((filetype($file.'/'.$file 2)=='file' )&&($file2 !='.')&&($ file2!='.. ')) {
$nrko++;
if ($nrko==$what) {
//ok, to jest ten plik, wyswietlamy go.
$img = null;
$img = @imagecreatefromgif($file. '/'.$file2 );
if (!$img) $img = @imagecreatefromjpeg($file .'/'.$file 2);
if (!$img) $img = @imagecreatefrompng($file. '/'.$file2 );
header("Content-type: image/jpeg");
imagejpeg($img);
}
}
}
}
}
}
}
}
?>
I attempted to remove the c_scandir function and use scandir instead for php5 but it still fails.
Example: working (php4) - http://bleach-network.com/manga-reader/image.php?id=1&what=1
example2: not working (php5) - http://bleachnet.mine.nu/Downloads/manga-reader/image.php?id=1&what=1
PHP5 php.ini file ::: http://bleachnet.mine.nu/Downloads/php.txt
<?php
// Custom scandir function
function c_scandir($dir)
{ if (function_exists('scandir'
{
return scandir($dir);
}
$fileps = array();
if ($handle = opendir($dir)) {
while (false !== ($filep = readdir($handle))) {
$fileps[] = $filep;
}
closedir($handle);
}
return $fileps;
}
$komiks = (int) $_GET['id'];
if ($komiks > 0) {
$what = (int) $_GET['what'];
if ($what>0) {
$nrkat = 0;
$katalog = c_scandir('.');
foreach ($katalog as $file) {
if ((filetype($file)=='dir')&
$nrkat++;
if ($nrkat == $komiks) {
$komi = c_scandir($file);
$nrko = 0;
foreach ($komi as $file2) {
if ((filetype($file.'/'.$file
$nrko++;
if ($nrko==$what) {
//ok, to jest ten plik, wyswietlamy go.
$img = null;
$img = @imagecreatefromgif($file.
if (!$img) $img = @imagecreatefromjpeg($file
if (!$img) $img = @imagecreatefrompng($file.
header("Content-type: image/jpeg");
imagejpeg($img);
}
}
}
}
}
}
}
}
?>
i guess it will not work. coz the variable 'what' is repeated
ASKER
Doesn't work gawai :(
did you try changing the variable name ?
ASKER
Yes i tried doesn't work i had changed it to scan
make sure images and the directory are exist in server
ASKER
Yes of course they are all there. If i run a scandir + print_r the images in the directory are all listed.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
or this one
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgn ame); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
header("Content-Type: image/jpeg");
$img = LoadJpeg("12.jpg");
imagejpeg($img);
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgn
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
header("Content-Type: image/jpeg");
$img = LoadJpeg("12.jpg");
imagejpeg($img);
ASKER
gawai Thank you Very much my friend! AMAZING i spent so many hour modifying code trying to figure out what was wrong >< THANK YOU!
u r most welcome my dear :)
$komiks = (int) $_GET['id'];
if ($komiks > 0) {
$what = (int) $_GET['what'];
with
$komiks = (int) $id;
if ($komiks > 0) {
$what = (int) $what;
and see wat happen