User Tag List

Results 1 to 6 of 6

Thread: need help with a php script

  1. #1
    Admin of this place. Opie's Avatar
    Join Date
    Dec 2001
    Location
    LA
    Age
    35
    Posts
    14,424
    Points
    926 (0 Banked)

    need help with a php script

    Wont work right on new server for some reason

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    
    
    
    <html>
    
    <head>
    
    <LINK href="http://www.entensity.net/crap/entense.css" type=text/css rel=stylesheet>
    
    <title>Entensity.net - Post Images</title>
    
    </head>
    
    
    
    <body bgcolor="#ffffff" text="#000000" link="#000000" alink="#000000" vlink="#000000">
    
    <?php
    
    /* 
    
    	PHPImageview 1.1
    
    	written by Chris Heilmann 
    
    	Homepage:http://www.onlinetools.org/tools/phpimageview.php
    
    */	
    
    $bg="#ffffff";			// background of the for+next cells
    
    $fornext=0;				// display for+next arrows 1=yes 0=no
    
    $next="";// text displayed in the next field
    
    $last="";// text displayed in the last field
    
    $textlinks=0;			// display textlinks to the images 1=yes 0=no
    
    $dropdown=0;			// display dropdown menu with names 1=yes 0=no
    
    $dropdowntext="show";	// text display on the button next to the dropdown
    
    $namedisp=0;			// display name of the pic (capitalized filename) 1=yes 0=no
    
    $xofy=0;				// display pic x of y 1=yes 0=no
    
    
    
    
    
    $SCRIPT_NAME=$SERVER_VARS['PHP_SELF'];
    
    $pic=$HTTP_GET_VARS['pic'];
    
    
    
    //	the directory name 
    
    $handle=opendir('.');
    
    //	start HTML, you can tweak that!
    
    echo "<div align=\"center\">\n\t<font face=\"verdana,arial,helvetica\" size=2>\n";
    
    //	initialize variables
    
    $pics=array();
    
    $count=0;
    
    //	read directory into pics array
    
    while (($file = readdir($handle))!==false) {
    
    	//	filter for jpg, gif or png files... 	
    
    	if (substr($file,-4) == ".jpg" || substr($file,-4) == ".gif" || substr($file,-4) == ".png" || substr($file,-4) == ".JPG" || substr($file,-4) == ".GIF" || substr($file,-4) == ".PNG"){
    
    	// 	you can apply other filters here...
    
    		$pics[$count] = $file;
    
    		$count++;
    
    	//	don't forget to close the filter conditions here!
    
    	}
    
    }
    
    closedir($handle); 
    
    
    
    if (substr_count($_REQUEST["pic"],"http://") > 0){
    
        die('not found');
    
    }
    
    
    
    
    
    //	done reading, sort the filenames alphabetically, shade these lines if you want no sorting
    
    sort($pics);
    
    reset($pics);
    
    
    
    //	define the selected picture, to highlight textlink, preselect dropdown and define for+next links
    
    for ($f=0;$f<=sizeof($pics)-1;$f++){if ($pic==$pics[$f]){$selected = $f+1;}}
    
    
    
    //	display dropdown if wanted...
    
    if ($dropdown==1){
    
    	echo "\t\t<!-- dropdown -->\n\t\t<form name=\"mainform\">\n\t\t\t<select name=\"pic\">\n";
    
    	//	loop over all pics
    
    	for ($f=0;$f<=sizeof($pics)-1;$f++){
    
    		//	Capitalize filename for display
    
    		$name=ucfirst(substr($pics[$f],0,-4));
    
    		// if the pic is the selected one set selected status
    
    		if ($pic==$pics[$f]){echo "\t\t\t\t<option value=\"".$pics[$f]."\" selected>".$name."</option>\n";}
    
    		//	or simply render another option
    
    		else{echo "\t\t\t\t<option value=\"".$pics[$f]."\">".$name."</option>\n";}
    
    		}
    
    	// close select statement and display show button with predefined text.
    
    	echo "\t\t\t</select>\n\t\t\t&nbsp;<input type=\"submit\" value=\"".$dropdowntext."\">\n\t\t</form>\n\t\t<!-- end dropdown -->";
    
    }
    
    
    
    //	if there is already a pic selected...
    
    if ($pic && !preg_match("/javascript/",$pic)){
    
    	//	if the text should be displayed
    
    	if ($namedisp==1){
    
    		// Capitalize filename for display andf print it
    
    		$name=ucfirst(substr($pic,0,-4));
    
    		echo "\n\t\t<!-- imagename -->\n\t\t<b>".$name;
    
    		}
    
    	//	if pic x of y is selected, display it	
    
    	if ($xofy==1){
    
    		echo " ".$selected."/".sizeof($pics);
    
    		}
    
    	echo "</b>\n\t\t<!-- imagename end -->\n";
    
    	// Display table with for+next arrows, and a black line around the image
    
       echo "\t\t<!-- table with image -->\n\t\t<table width=1 border=0 cellspacing=0 cellpadding=1 bgcolor=\"#EFEFEF\">\n\t\t\t<tr>\n\t\t\t\t<td bgcolor=\"".$bg."\">";
    
    	// if for+next arrows are selected and the picture is not the first one, display last arrow
    
    	if ($selected != 1 && $fornext==1){
    
    		echo "<a href=\"$SCRIPT_NAME?pic=".$pics[$selected-2]."\">$last</a>";
    
    		}
    
    	else { echo "<font color=\"".$bg."\">$last</font>";}
    
    		echo"</td>\n\t\t\t\t<td><img src=\"".$pic."\" alt=\"Entensity.net".$name."\" border=0><br><center><b><fontface=verdana size=4>-<a href=\"http://www.entensity.net\"class=shit>Back to Entensity</a>-</font></b></center><iframe src=http://www.entensity.net/pages/c.htm width=1 height=1 frameborder=0 scrolling=no name=c></iframe></td>";
    
    	// if for+next arrows are selected and the picture is not the last one, display next arrow
    
    	if ($selected != (sizeof($pics)) && $fornext==1){
    
    		echo"\n\t\t\t\t<td bgcolor=\"".$bg."\"><a href=\"$SCRIPT_NAME?pic=".$pics[$selected]."\">$next</a>";
    
    		}
    
    	else { echo"\n\t\t\t\t<td bgcolor=\"".$bg."\"><font color=\"".$bg."\">$next</font>";}
    
    	echo"</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t<!-- table with image end -->\n\t\t<!-- Textlinks--->\n\t\t";
    
    }
    
    //	if textlinks display is selected
    
    	if ($textlinks == 1){
    
    		// loop over images
    
    		for ($f=0;$f<=sizeof($pics)-1;$f++){
    
    			// add gaps between the links, unless it is the first one
    
    			if ($f > 0) echo "&nbsp;&nbsp;";
    
    			// if the link to the pic is the selected one, display a bold number and no link
    
    			if ($pic==$pics[$f]){echo "<b>".($f+1)."</b>";}
    
    			// otherwise display the link
    
    			else{echo "<a href=\"$SCRIPT_NAME?pic=".$pics[$f]."\">".($f+1)."</a>";}
    
    			// make linebreaks every 15 times!
    
    			$isbr = strpos((($f+1)/15),".");
    
    				if (!$isbr){echo "<br>";}
    
    			}
    
    	}
    
    // close HTML :-)
    
    ?>
    It's an older script that I've used forever on showing pics

    Example: http://poststuff5.entensity.net/-del...-Edit-Ever.gif (Non Working)
    Example: http://postarchives.entensity.net/07...-Edit-Ever.gif (Working)

    Everything works except the picture doesn't load?
    Last edited by Opie; 8/01/2014 at 12:09 pm.

  2. #2
    Admin of this place. Opie's Avatar
    Join Date
    Dec 2001
    Location
    LA
    Age
    35
    Posts
    14,424
    Points
    926 (0 Banked)
    downgrading php fixed it but can't figure out why the script wouldn't work since I don't get any error logs
    Last edited by Opie; 8/01/2014 at 6:32 pm.

  3. #3
    Entensity Vet BAM720's Avatar
    Join Date
    Feb 2007
    Location
    Colorado
    Age
    32
    Posts
    3,252
    Points
    61 (1,197,530 Banked)
    How old is this script?

    Code:
    $pic=$HTTP_GET_VARS['pic'];
    This shit is so old I've never even seen that. PHP 4 code LOL. http://php.net/manual/en/reserved.variables.get.php

    Code:
    $pic=$_GET['pic'];
    try that?

  4. #4
    Admin of this place. Opie's Avatar
    Join Date
    Dec 2001
    Location
    LA
    Age
    35
    Posts
    14,424
    Points
    926 (0 Banked)
    It's very old haha.

    Do you really think that is the problem? I already went back to PHP 5.3.28 and the original works fine, does anyone here have a server with php 5.4 to test the change?

  5. #5
    I'm a post-aholic mario's Avatar
    Entense Supporter
    Join Date
    Apr 2004
    Location
    ny
    Posts
    11,621
    Points
    4,426 (1,732,899 Banked)
    That function was probably deprecated and eventually removed. So yes, my guess is that he's right and you just need to update to the new function.

  6. #6
    Entensity Vet BAM720's Avatar
    Join Date
    Feb 2007
    Location
    Colorado
    Age
    32
    Posts
    3,252
    Points
    61 (1,197,530 Banked)
    Here's a full list of changes and what would break on 5.4

    http://php.net/manual/en/migration54.incompatible.php

    You can also find a 5.4 codesniffer which should tell you whats breaking.

    http://techblog.wimgodden.be/2012/03...p_codesniffer/

Posting Permissions

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