Jump to content

jeffshead

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jeffshead's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So this is the PHP code that is used to display the file tree on the web page: <?php echo php_file_tree($FileLocations["tracy"], array("gif", "jpg", "jpeg", "png","pdf", "zip", "xlsx")); ?> Looks like I need to add something for the $return_link parameter, for the php_file_tree() function. Sorry, I don't even know what $return_link is supposed to be or what it is used for. If I change that line to: <?php echo php_file_tree($FileLocations["tracy"], test, array("gif", "jpg", "jpeg", "png","pdf", "zip", "xlsx")); ?> I get this error: If I change that line to: <?php echo php_file_tree($FileLocations["tracy"], $return_link, array("gif", "jpg", "jpeg", "png","pdf", "zip", "xlsx")); ?> It seems to work without any errors in PHP 8.1.
  2. This is output of echo and of print_r for PHP 7.3: echo $return_link; Array print_r($return_link); ArrayArrayArrayArrayArrayArrayArrayArray
  3. I did not write the script. It is old so that's why the author had concern for PHP4. This is output of echo and of print_r : echo $return_link; Array print_r($return_link); Array ( [0] => gif [1] => jpg [2] => jpeg [3] => png [4] => pdf [5] => zip [6] => xlsx ) Looks like $return_link is somehow getting mixed up with $extensions since updating server from PHP 7 to PHP 8. If I revert back to PHP 7.3, the script works without error.
  4. Thank for taking the time! Below is all of the code in that PHP file: <?php /* == PHP FILE TREE == Let's call it...oh, say...version 1? == AUTHOR == Cory S.N. LaViska http://abeautifulsite.net/ == DOCUMENTATION == For documentation and updates, visit http://abeautifulsite.net/notebook.php?article=21 */ function php_file_tree($directory, $return_link, $extensions = array()) { // Generates a valid XHTML list of all directories, sub-directories, and files in $directory // Remove trailing slash if( substr($directory, -1) == "/" ) $directory = substr($directory, 0, strlen($directory) - 1); $code .= php_file_tree_dir($directory, $return_link, $extensions); return $code; } function php_file_tree_dir($directory, $return_link, $extensions = array(), $first_call = true) { // Mod for Sitelok global $FileLocation,$FileLocations; // End of mod // Recursive function called by php_file_tree() to list directories/files // Get and sort directories/files if( function_exists("scandir") ) $file = scandir($directory); else $file = php4_scandir($directory); natcasesort($file); // Make directories first $files = $dirs = array(); foreach($file as $this_file) { if( is_dir("$directory/$this_file" ) ) $dirs[] = $this_file; else $files[] = $this_file; } $file = array_merge($dirs, $files); // Filter unwanted extensions if( !empty($extensions) ) { foreach( array_keys($file) as $key ) { if( !is_dir("$directory/$file[$key]") ) { $ext = substr($file[$key], strrpos($file[$key], ".") + 1); if( !in_array($ext, $extensions) ) unset($file[$key]); } } } if( count($file) > 2 ) { // Use 2 instead of 0 to account for . and .. "directories" $php_file_tree = "<ul"; if( $first_call ) { $php_file_tree .= " class=\"php-file-tree\""; $first_call = false; } $php_file_tree .= ">"; foreach( $file as $this_file ) { if( $this_file != "." && $this_file != ".." ) { if( is_dir("$directory/$this_file") ) { // Directory $php_file_tree .= "<li class=\"pft-directory\"><a href=\"#\">" . htmlspecialchars($this_file) . "</a>"; $php_file_tree .= php_file_tree_dir("$directory/$this_file", $return_link ,$extensions, false); $php_file_tree .= "</li>"; } else { // File // Get extension (prepend 'ext-' to prevent invalid classes from extensions that begin with numbers) $ext = "ext-" . substr($this_file, strrpos($this_file, ".") + 1); // Mod for Sitelok if ($return_link!="") { $slfile=str_replace($FileLocations[$return_link],"",$directory."/".$this_file); $link = sl_siteloklink($slfile.":".$return_link,1); } else { $slfile=str_replace($FileLocation,"",$directory."/".$this_file); $link = sl_siteloklink($slfile,1); } // End of mod $php_file_tree .= "<li class=\"pft-file " . strtolower($ext) . "\"><a href=\"$link\">" . htmlspecialchars($this_file) . "</a></li>"; } } } $php_file_tree .= "</ul>"; } return $php_file_tree; } // For PHP4 compatibility function php4_scandir($dir) { $dh = opendir($dir); while( false !== ($filename = readdir($dh)) ) { $files[] = $filename; } sort($files); return($files); }
  5. I have the following code which throws an error since updating to PHP 8.x: Code: if ($return_link!="") { $slfile=str_replace($FileLocations[$return_link],"",$directory."/".$this_file); $link = sl_siteloklink($slfile.":".$return_link,1); } else { $slfile=str_replace($FileLocation,"",$directory."/".$this_file); $link = sl_siteloklink($slfile,1); } Error: Line 71 referenced in the error is: // This is the second line in the code block above $slfile=str_replace($FileLocations[$return_link],"",$directory."/".$this_file); I have tried rewriting line 71 but I don't know what the heck I'm doing. Can someone suggest the correct code?
  6. After more testing, I don't think the problem is related to the PHP version. I created a new test environment with both versions of PHP and I cannot re-create the issue on my server. The issue must be related to the host provider's server and/or settings. I think it must have something to do with sessions. Any ideas on what settings to look for?
  7. From previous code: tstamp = $_SESSION['tstamp']; $hash = $_SESSION['thash'];
  8. The code snippet below works fine with PHP 5.3 (register_globals = Off) but does NOT give the same results with PHP 5.5: $verhash = md5($tstamp."salt"); if ($hash != $verhash) { $_SESSION['direct'] = 1; if(isset($_SESSION['ntrd'])) { unset($_SESSION['ntrd']); } if(isset($_SESSION['rntr'])) { unset($_SESSION['rntr']); } header('refresh: 0; url=/accessDenied.php'); exit; } I'm not sure if there is a problem with the above snippet or with some other part of the code but I always get redirected to the 'accessDenied.php' page with PHP 5.5. Can someone tell me if the snippet above would output differently on PHP 5.5? Thanks, Jeff
  9. Thanks for the explanation Barand, that seems to have fixed it!
  10. Googled for hours and can't find an answer ??? I get a "Notice: Undefined offset: 1" warning referring to line 2 in the the code below: /* add domain name to username if whatnot and soforth */ if (!list($login_host, $other) = split(':', $_SERVER['HTTP_HOST'])) { $login_host = $_SERVER['HTTP_HOST']; } if (!strstr($login_username, '@')) { /* strip any leading 'www.' so that only a username is required */ $login_host = preg_replace('/^www\./i', '', $login_host); $login_host = preg_replace('/^webmail\./i', '', $login_host); $login_host = preg_replace('/^mail\./i', '', $login_host); $login_username .= '@' . $login_host; } I did not write the code, just trying to stop the warning. This code snippet is from a webmail redirect page which prevents users from reposting their form data after a successful logout. I'm sure the fix is is to add "isset" somewhere, but I can't figure it out. Can someone help?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.