$strlen) return false; return substr_compare($string, $test, -$testlen) === 0; } $folderID = 0; $rootPath = "files/"; $thisPath = ""; if (isset($_GET['p'])) { $p = $rootPath.$_GET['p']; if (!endsWith($p, "/")) { $p .= "/"; } $SQL = sprintf("SELECT id, path, name, template FROM files where path = '%s'", mysql_real_escape_string($p)); $retid = mysql_db_query($db, $SQL, $cid); if (!$retid) { echo( mysql_error()); } // failure $row = mysql_fetch_array($retid); $thisPath = $row['path']; $rootPath = ""; $folderID = $row['id']; $template = loadTemplate($row['template']); if (empty($folderID) && !is_numeric($folderID)) { echo "Unfortunately the folder you have requested cannot be displayed!"; exit; } else { echo $thisPath."
"; } } else { echo "files/
"; } if ($folderID) { echo " ..
"; } $bFirstFile = false; $SQL = "SELECT id, name, description, size, author, image, is_folder, parent_id FROM files where parent_id = ".$folderID." order by is_folder desc, isnull(image) desc, name"; $retid = mysql_db_query($db, $SQL, $cid); if (!$retid) { echo( mysql_error()); } // failure while ($row = mysql_fetch_array($retid)) { if ($row['is_folder']) { echo " ".$row['name']."
"; } else { if (($template != null || !empty($row['image'])) && !$bFirstFile) { echo "
"; $bFirstFile = true; } if ($template != null) { $t = $template; $t = str_replace("[image]", $row['image'], $t); $t = str_replace("[name]", $row['name'], $t); $t = str_replace("[size]", $row['size'], $t); $t = str_replace("[description]", $row['description'], $t); $t = str_replace("[author]", $row['author'], $t); echo $t; } else if (!empty($row['image'])) { echo "\"".$row['description']."\""; } else { echo " ".$row['name']."
"; } } } if ($bFirstFile) { echo "
"; } ?>