Contributions by Keith Gable This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to being restricted by the GNU General Public License, Essence Engine may not be sold, rented, sublicensed, or leased; you are not permitted to generate revenue with the Essence Engine source code. You may, however, use Essence Engine to run a website that generates revenue via other means. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $Id$ */ // Links Manager // Add/edit/delete links $pagetitle = "Links Manager"; include("mainheader.php"); include("themeheader.php"); if ($userinfo["editlinks"]) { // Add links if (($_GET["action"] == "add") || ($_GET["action"] == "edit")) { // Links form has been submitted if ($_POST["submitted"]) { $modlink = $_POST; if ($_POST["name"] && $_POST["img"] && $_POST["url"]) { $doquery = "name='" . mysql_escape_string($_POST["name"]) . "', "; $doquery .= "description='" . mysql_escape_string($_POST["description"]) . "', "; $doquery .= "img='" . mysql_escape_string($_POST["img"]) . "', "; $doquery .= "url='" . mysql_escape_string($_POST["url"]) . "', "; if ($_POST["hide"]) $doquery .= "hide=1, "; else $doquery .= "hide=0, "; if ($_POST["affiliate"]) $doquery .= "affiliate=1"; else $doquery .= "affiliate=0"; if ($_GET["action"] == "add") $doquery = "INSERT INTO links SET " . $doquery; elseif ($_GET["action"] == "edit") $doquery = "UPDATE links SET " . $doquery . " WHERE id='" . mysql_escape_string($_POST["linkid"]) . "' LIMIT 1"; $added = mysql_query($doquery, $db); if (mysql_errno() != 0) $errmsg = "MySQL Error " . mysql_errno() . ": " . mysql_error() . "."; else { if ($_GET["action"] == "add") sysmsg('Successfully added the link named "' . safetext($_POST["name"]) . '".'); elseif ($_GET["action"] == "edit") sysmsg('Successfully edited the link named "' . safetext($_POST["name"]) . '".'); sendlocation("adminlinks.php?action=edit"); } } else $errmsg = "You must supply all of the information for the link."; } elseif ($_GET["linkid"]) { $linkid = mysql_escape_string($_GET["linkid"]); $result = mysql_query("SELECT * FROM links WHERE id='" . $linkid . "'", $db); $modlink = mysql_fetch_array($result); if (!isset($modlink["name"])) { $_SESSION["sysmsg"] = 'The link id ' . safetext($linkid) . ' does not exist.'; sendlocation("adminlinks.php?action=edit"); } } if (($_GET["action"] == "add") || (($_GET["action"] == "edit") && (isset($modlink)))) { if ($errmsg) echo '
' . $errmsg . "
\n"; ?>
">
" />
" />
" />
" />
/>
/>
\n"; echo ' ' . "\n"; } else echo ' ' . "\n"; ?>
Add a new link\n"; // Show the link data echo "\n \n \n \n"; while ($links = mysql_fetch_array($result)) { echo " \n \n \n"; echo ' \n"; echo ' \n"; echo ' \n"; echo ' \n \n"; } echo "
NameImageHideAffiliateAction
" . safetext($links["name"]) . ""; if (strpos($links["img"],".swf") === false) //img link echo "\"""; else { // Doesn't work with Mozilla (grr), so show filename as link for now /* " class="link"> " /> */ echo '' . $links["img"] . ''; } echo "'; if ($links["hide"]) echo "yes"; else echo "no"; echo "'; if ($links["affiliate"]) echo "yes"; else echo "no"; echo "EditDelete
\n"; // Page count generator $result = mysql_query("SELECT count(*) FROM links", $db); $totallinks = mysql_fetch_array($result); $totallinks = $totallinks["count(*)"]; if ($totallinks > $perpage) { $totalpages = ceil($totallinks / $perpage); echo "
Go to page: \n"; for ($curpage = 1; $curpage <= $totalpages; ++$curpage) { if ($curpage == $pagenum) echo $curpage; else echo '' . $curpage . "\n"; if ($curpage != $totalpages) echo " - "; } echo "
\n"; } } } // Delete links elseif ($_GET["action"] == "delete") { if (($_GET["dodelete"]) && ($_GET["linkid"])) { $linkid = mysql_escape_string($_GET["linkid"]); // Is the user an admin? if ($userinfo["usertype"] >= 3) { $deletelink = mysql_query("DELETE FROM links WHERE id='" . $linkid . "' LIMIT 1", $db); if (mysql_errno() != 0) $_SESSION["sysmsg"] = "MySQL Error " . mysql_errno() . ": " . mysql_error() . "."; else $_SESSION["sysmsg"] = "Link " . $linkid . " was deleted successfully."; sendlocation("adminlinks.php?action=edit"); } } elseif ($_GET["linkid"]) { $linkid = mysql_escape_string($_GET["linkid"]); echo "
Do you really want to delete this link?
\n"; echo "Yes, delete this link.
\n"; echo "No, do not delete it.
\n"; $result = mysql_query("SELECT * FROM links WHERE id=" . $linkid, $db); $link = mysql_fetch_array($result); ?>
Name:
Description:
Image:" />
URL:">
Access denied: You do not have permission to edit links.\n"; include("themefooter.php"); ?>