ranks are converted. on the home stretch.

This commit is contained in:
Ryan Walberg 2012-11-17 03:48:06 +00:00
parent de147ad95a
commit e9530173d3
3 changed files with 151 additions and 112 deletions

View file

@ -81,11 +81,11 @@ else if ($action == "demote") {
exit;
}
else if ($action == "edit") {
$query = "SELECT title, rendered FROM {$OPT["table_prefix"]}ranks WHERE ranking = " . $_GET["ranking"];
$query = "SELECT title, rendered FROM {$OPT["table_prefix"]}ranks WHERE ranking = " . addslashes($_GET["ranking"]);
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
if ($row = mysql_fetch_array($rs,MYSQL_ASSOC)) {
$title = htmlspecialchars($row["title"]);
$rendered = htmlspecialchars($row["rendered"]);
$title = $row["title"];
$rendered = $row["rendered"];
}
mysql_free_result($rs);
}
@ -123,113 +123,35 @@ else {
exit;
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Gift Registry - Manage Ranks</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body>
<?php
if (isset($message)) {
echo "<span class=\"message\">" . $message . "</span>";
}
$query = "SELECT ranking, title, rendered, rankorder " .
"FROM {$OPT["table_prefix"]}ranks ";
$query .= " ORDER BY rankorder";
$ranks = mysql_query($query) or die("Could not query: " . mysql_error());
"FROM {$OPT["table_prefix"]}ranks " .
"ORDER BY rankorder";
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
$ranks = array();
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
$ranks[] = $row;
}
mysql_free_result($rs);
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty-3.1.12/libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
$smarty->assign('action', $action);
$smarty->assign('ranks', $ranks);
if (isset($message)) {
$smarty->assign('message', $message);
}
$smarty->assign('title', $title);
if (isset($title_error)) {
$smarty->assign('title_error', $title_error);
}
$smarty->assign('rendered', $rendered);
if (isset($rendered_error)) {
$smarty->assign('rendered_error', $rendered_error);
}
$smarty->assign('ranking', $_GET["ranking"]);
$smarty->assign('haserror', $haserror);
$smarty->assign('isadmin', $_SESSION["admin"]);
$smarty->assign('opt', $OPT);
$smarty->display('ranks.tpl');
?>
<p>
<table class="partbox" cellspacing="0" cellpadding="2">
<tr class="partboxtitle">
<td colspan="4" align="center">Ranks</td>
</tr>
<tr>
<th class="colheader">Title</th>
<th class="colheader">Rendered HTML</th>
<th class="colheader">Rank Order</th>
</tr>
<?php
$i = 0;
while ($row = mysql_fetch_array($ranks,MYSQL_ASSOC)) {
?>
<tr class="<?php echo (!($i++ % 2)) ? "evenrow" : "oddrow" ?>">
<td><?php echo htmlspecialchars($row["title"]); ?></td>
<td><?php echo $row["rendered"]; ?></td>
<td><?php echo $row["rankorder"]; ?></td>
<td align="right">
<a href="ranks.php?action=edit&ranking=<?php echo $row["ranking"]; ?>">Edit</a>
/
<a href="ranks.php?action=delete&ranking=<?php echo $row["ranking"]; ?>">Delete</a>
/
<a href="ranks.php?action=promote&ranking=<?php echo $row["ranking"]; ?>&rankorder=<?php echo $row["rankorder"]; ?>">Promote</a>
/
<a href="ranks.php?action=demote&ranking=<?php echo $row["ranking"]; ?>&rankorder=<?php echo $row["rankorder"]; ?>">Demote</a>
</td>
</tr>
<?php
}
mysql_free_result($ranks);
?>
</table>
</p>
<p>
<a href="ranks.php">Add a new rank</a> / <a href="index.php">Back to main</a>
</p>
<form name="rank" method="get" action="ranks.php">
<?php
if ($action == "edit" || (isset($haserror) && $action == "update")) {
?>
<input type="hidden" name="ranking" value="<?php echo $_GET["ranking"]; ?>">
<input type="hidden" name="action" value="update">
<?php
}
else if ($action == "" || (isset($haserror) && $action == "insert")) {
?>
<input type="hidden" name="action" value="insert">
<?php
}
?>
<div align="center">
<TABLE class="partbox">
<tr class="partboxtitle">
<td align="center" colspan="2"><?php echo ($action == "edit" ? "Edit Rank '" . $title . "'" : "Add New Rank"); ?></td>
</tr>
<TR valign="top">
<TD>Title</TD>
<TD>
<input name="title" type="text" value="<?php echo $title; ?>" maxlength="255" size="50"/>
<?php
if (isset($title_error)) {
?><br /><font color="red"><?php echo $title_error; ?></font><?php
}
?>
</TD>
</TR>
<TR valign="top">
<TD>HTML</TD>
<TD>
<textarea name="rendered" rows="4" cols="40"><?php echo $rendered; ?></textarea>
<?php
if (isset($rendered_error)) {
?><br /><font color="red"><?php echo $rendered_error; ?></font><?php
}
?>
</TD>
</TR>
</TABLE>
</div>
<P>
<div align="center">
<input type="submit" value="<?php if ($action == "" || $action == "insert") echo "Add"; else echo "Update"; ?>"/>
<input type="button" value="Cancel" onClick="document.location.href='ranks.php';">
</div>
</P>
</form>
<table border="1">
</table>
</body>
</html>