Go Back   Webmaster Desk Forum | Voice of webmasters > Development Desk > Programming > PHP

Reply

 

LinkBack Thread Tools Display Modes

need some help with php code
  #1  
Old 11-02-2008, 11:36 AM
shadav's Avatar
shadav shadav is offline
The Forgotten One
 
Join Date: Jul 2007
Posts: 162
shadav will become famous soon enoughshadav will become famous soon enough
Send a message via Yahoo to shadav
Default need some help with php code

ok i donno why i get asked these questions, even though I tell people i've no idea wtf i'm doing

so can anyone help me to answer this?
Quote:
Here’s one for you:

I want to put a random screen shot up on the page as a thumbnail that changes with each page load/reload. What I’m hoping to do is just upload the pictures into a directory on the server and have a script just pull it. I’ve made some headway, but what is happening is when you click the thumbnail it just executes the script and the picture that gets enlarged is not the one that’s showing on the page.

Here is the PHP:

PHP Code:
<?php

$image_directory 
'.';

$image_extension = array();

$image_extension['gif'] = 'image/gif';

$image_extension['jpg'] = 'image/jpeg';

$image_extension['jpeg'] = 'image/jpeg';

$image_extension['png'] = 'image/png';

 

$image null;

if (
substr($image_directory,-1) != '/') {

$image_directory $image_directory.'/';

}

 

if (isset(
$_GET['image'])) {

$img_info pathinfo($_GET['image']);

if (

isset( 
$image_extensionstrtolower$img_info['extension'] ) ] ) &&

file_exists$image_directory.$img_info['basename'] )

) {

$image $image_directory.$img_info['basename'];

}

} else {

$fileList = array();

$handle opendir($image_directory);

while ( 
false !== ( $file readdir($handle) ) ) {

$file_info pathinfo($file);

if (

isset( 
$image_extensionstrtolower$file_info['extension'] ) ] )

) {

$fileList[] = $file;

}

}

closedir($handle);

 

if (
count($fileList) > 0) {

$imageNumber time() % count($fileList);

$image $image_directory.$fileList[$imageNumber];

}

}

 

if (
$image!=null) {

$img_info pathinfo($image);

$contents 'Content-type: '.$image_extension$img_info['extension'] ];

header ($contents);

readfile($image);

} else {

if ( 
function_exists('imagecreate') ) {

header ("Content-type: image/png");

$picture = @imagecreate (100100)

or die (
"Cannot initialize new GD image stream");

$bgcolor imagecolorallocate ($picture255255255);

$font_color imagecolorallocate ($picture0,0,0);

imagestring ($picture255"IMAGE ERROR"$font_color);

imagepng ($picture);

imagedestroy($picture);

}

}

?>
This is what calls it on the page:

<img src="http://www.kinprecision.com/rimg/wallpaperama-generator.php" width = "175" height = "131"

This is what I tried to make it a thumbnail:

<a href="http://www.kinprecision.com/rimg/wallpaperama-generator.php" target="_blank"><img

src="http://www.kinprecision.com/rimg/wallpaperama-generator.php" width="175" height="131" border="0">

Thanks

Alan
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 13-02-2008, 01:29 PM
Shabu's Avatar
Shabu Shabu is offline
Marks and Marker
 
Join Date: Jul 2007
Location: Dhaka, Bangladesh
Posts: 412
Shabu will become famous soon enoughShabu will become famous soon enough
Default

I'm a PHP GURU (fake )

Sending this thread to a PHP coder, might be he can help you
__________________
Brandable Domains ~ Bloggers Eye ~ My Photo Gallery ~ Lemon Shadow 2 - New free phpLD templates
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3  
Old 15-02-2008, 05:53 PM
shadav's Avatar
shadav shadav is offline
The Forgotten One
 
Join Date: Jul 2007
Posts: 162
shadav will become famous soon enoughshadav will become famous soon enough
Send a message via Yahoo to shadav
Default

thanks hun cuz i've no idea lol and a few friends gave me advice which made no sense to me that i then told my friend and he's clueless to lmfao so any help at all would be great
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:24 PM.




Webmaster Desk forum is a concern of Graffias Web service network

Skin by: eXtremepixels Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.