我有一个旧的CMS,我需要编辑代码,以便它首先显示最新的项目作为最早的第一项。下面的代码来自我相信需要编辑的文件。任何帮助最受赞赏...
<?
require("inc/config.php");
if ($cms->mrow['usrlvl'] < $cms->ulid) {
header("Location: " . $cms->folder . "/home");
exit();
}
if (isset($_GET['dm'])) {
if ($_GET['dm'] == "a") {
$cms->dmsg = $cms->mrow['singular_title'] . " Added Successfully";
} else if ($_GET['dm'] == "u") {
$cms->dmsg = $cms->mrow['singular_title'] . " Updated Successfully";
} else if ($_GET['dm'] == "d") {
$cms->dmsg = $cms->mrow['singular_title'] . " Deleted Successfully";
} else if ($_GET['dm'] == "bd") {
$cms->dmsg = $_GET['t'] . " "; if ($_GET['t'] > 1) { $cms->dmsg .= $cms->mrow['title']; } else { $cms->dmsg .= $cms->mrow['singular_title']; } $cms->dmsg .= " deleted Successfully";
}
}
require("inc/header.php");
echo "<h1>" . $cms->mrow['title'] . "</h1>";
// Add button
if ($cms->user['ulid'] <= $cms->mrow['usrlvladd'] && ($cms->mrow['allowadd'] || $cms->user['ulid'] == 1)) echo "<a href=\"" . $cms->folder . "/" . $cms->mrow['tablename'] . "/add\" id=\"add\"><span>Add " . $cms->mrow['singular_title'] . "</span></a>";
// Bulk button
if ($cms->user['ulid'] <= $cms->mrow['usrlvladd'] && $cms->mrow['allowbulkadd']) echo "<a href=\"" . $cms->folder . "/" . $cms->mrow['tablename'] . "/bulkadd\" id=\"add\"><span>Add Multiple " . $cms->mrow['title'] . "</span></a>";
if (!empty($cms->dmsg)) echo "\n<div id=\"dmsg\"><h3><span>" . $cms->dmsg . "</span></h3></div>";
// Set Order BY based on previously saved session or Module Default
if (isset($_SESSION['module' . $cms->mid]['orderby'])) {
$cms->orderby = $_SESSION['module' . $cms->mid]['orderby'];
} else if ($cms->mrow['orderby'] > 0) { // Get order based on field in module table (default)
$fres = mysql_query("SELECT name FROM `" . $cms->prefix . "field_" . $cms->tbl . " WHERE fid=" . $cms->mrow['orderby']);
$cms->orderby = mysql_result($fres,0);
} else if ($cms->mrow['allowposition']) { // Order by ID otherwise
$cms->orderby = "position";
} else { // Order by ID otherwise
$cms->orderby = $cms->idname;
}
// Set Order By Direction based on previously saved session or Module Default
if (!empty($_SESSION['module' . $cms->mid]['direction'])) { // Set Order By first based on session if set
$cms->direction = $_SESSION['module' . $cms->mid]['direction'];
} else { // Order by ID otherwise
$cms->direction = $cms->mrow['direction'];
}
// List Filter Bar
if ($cms->mrow['allowsearch'] == 1 || $cms->mrow['allownpp'] == 1) $cms->listSearch();
// Set Current page based on previously saved session
if (isset($_SESSION['module' . $cms->mid]['pg']) && is_numeric($_SESSION['module' . $cms->mid]['pg'])) {
$cms->pg = $_SESSION['module' . $cms->mid]['pg'];
} else {
$cms->pg = 1;
}
// Generate ajax request to load content into div
echo "<script type=\"text/javascript\">\n";
echo "$(document).ready(function(){\n";
if (isset($_GET['upid'])) { $upid = $_GET['upid']; } else { $upid = 0; } // Update Record ID
echo "
document.pg = " . $cms->pg . ";
document.order = '" . $cms->orderby . "';
document.direction = '" . $cms->direction . "';
showModuleList('" . $cms->mrow['tablename'] . "',document.pg,document.order,document.direction,false," . $upid . ");
});
</script>\n";
// Ajax target div
echo "<div id=\"list\"></div>";
require("inc/footer.php");
?>