Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-------------------------------------------------------+
- | PHP-Fusion Content Management System
- | Copyright (C) 2002 - 2012 Nick Jones
- | http://www.php-fusion.co.uk/
- +--------------------------------------------------------+
- | Filename: administrativo.php
- | Author: Ricz
- +--------------------------------------------------------+
- | This program is released as free software under the
- | Affero GPL license. You can redistribute it and/or
- | modify it under the terms of this license which you
- | can read by viewing the included agpl.txt or online
- | at www.gnu.org/licenses/agpl.html. Removal of this
- | copyright header is strictly prohibited without
- | written permission from the original author(s).
- +--------------------------------------------------------*/
- require_once "../maincore.php";
- require_once THEMES."templates/admin_header_mce.php";
- include LOCALE.LOCALESET."admin/admin_correct.php";
- if (!checkrights("ADC") || !defined("iAUTH") || $_GET['aid'] != iAUTH) { redirect("../index.php"); }
- if ($settings['tinymce_enabled'] == 1) {
- echo "<script language='javascript' type='text/javascript'>advanced();</script>\n";
- } else {
- require_once INCLUDES."html_buttons_include.php";
- }
- if (isset($_GET['status']) && !isset($message)) {
- if ($_GET['status'] == "su") {
- $message = $locale['411'];
- }
- if ($message) { echo "<div id='close-message'><div class='admin-message'>".$message."</div></div>\n"; }
- }
- $result = dbcount("(projects_id)", DB_PROJECTS);
- if (!empty($result)) {
- if (isset($_POST['save'])) {
- $project = stripinput($_POST['project']);
- $encyc = stripinput($_POST['encyc']);
- $forum = stripinput($_POST['forum']);
- $down = stripinput($_POST['down']);
- $download = stripinput($_POST['download']);
- $online = stripinput($_POST['online']);
- if (isset($_POST['projects_id']) && isnum($_POST['projects_id'])) {
- // old:
- //$result = dbquery("UPDATE ".DB_PROJECTS." SET projects_subject='$project' AND ".DB_ENCYCLOPEDIA." SET encyclopedia_subject='$encyc' && ".DB_THREADS." SET thread_subject='$forum' && ".DB_DOWN." SET down_subject='$down' && ".DB_DOWNLOAD_CATS." SET download_cat_name='$download' && ".DB_VIDEO_CAT." SET cat_name='$online WHERE projects_id='".$_POST['projects_id']."'");
- // new:
- $tempAr = array();
- // organize table names with their field name and field value in an array
- $tempAr[DB_PROJECTS] = array('field' => 'projects_subject', 'value' => $project);
- $tempAr[DB_ENCYCLOPEDIA] = array('field' => 'encyclopedia_subject', 'value' => $encyc);
- $tempAr[DB_THREADS] = array('field' => 'thread_subject', 'value' => $forum);
- $tempAr[DB_DOWN] = array('field' => 'down_subject', 'value' => $down);
- $tempAr[DB_DOWNLOAD_CATS] = array('field' => 'download_cat_name', 'value' => $download);
- $tempAr[DB_VIDEO_CAT] = array('field' => 'cat_name', 'value' => $online);
- // protect input from sql injection
- $primaryKey = (int) mysql_real_escape_string($_POST['projects_id']);
- foreach($tempAr as $tblName => $fieldValuePair)
- {
- dbquery("UPDATE ".$tblName." SET ".$fieldValuePair["field"]." = '".$fieldValuePair["value"]."' WHERE projects_id = '".$primaryKey."'");
- }
- redirect(FUSION_SELF.$aidlink."&status=su");
- }
- } else {
- $result = dbquery("SELECT ta.projects_id, ta.projects_subject,
- tab.encyclopedia_subject,
- tac.thread_subject,
- tad.down_subject,
- tae.download_cat_name,
- taf.cat_name
- FROM ".DB_PROJECTS." ta
- LEFT JOIN ".DB_ENCYCLOPEDIA." tab ON ta.projects_subject=tab.encyclopedia_subject
- LEFT JOIN ".DB_THREADS." tac ON ta.projects_subject=tac.thread_subject
- LEFT JOIN ".DB_DOWN." tad ON ta.projects_subject=tad.down_subject
- LEFT JOIN ".DB_DOWNLOAD_CATS." tae ON ta.projects_subject=tae.download_cat_name
- LEFT JOIN ".DB_VIDEO_CAT." taf ON ta.projects_subject=taf.cat_name ORDER BY ta.projects_subject ASC");
- if (dbrows($result)) {
- $editlist = ""; $sel = "";
- while ($data = dbarray($result)) {
- if ((isset($_POST['projects_id']) && isnum($_POST['projects_id'])) || (isset($_GET['projects_id']) && isnum($_GET['projects_id']))) {
- $projects_id = isset($_POST['projects_id']) ? $_POST['projects_id'] : $_GET['projects_id'];
- $sel = ($projects_id == $data['projects_id'] ? " selected='selected'" : "");
- } else {
- $sel = "";
- }
- $editlist .= "<option value='".$data['projects_id']."'".$sel.">".$data['projects_subject']."</option>\n";
- }
- opentable($locale['400']);
- echo "<div style='text-align:center'>\n<form name='selectform' method='post' action='".FUSION_SELF.$aidlink."&action=edit'>\n";
- echo "<select name='projects_id' class='textbox' style='width:250px;'>\n".$editlist."</select>\n";
- echo "<input type='submit' name='edit' value='".$locale['409']."' class='button' />\n";
- echo "</form>\n</div>\n";
- closetable();
- }
- if ((isset($_GET['action']) && $_GET['action'] == "edit") && (isset($_POST['projects_id']) && isnum($_POST['projects_id'])) || (isset($_GET['projects_id']) && isnum($_GET['projects_id']))) {
- $result = dbquery("SELECT ta.projects_id, ta.projects_subject,
- tab.encyclopedia_subject,
- tac.thread_subject,
- tad.down_subject,
- tae.download_cat_name,
- taf.cat_name
- FROM ".DB_PROJECTS." ta
- LEFT JOIN ".DB_ENCYCLOPEDIA." tab ON ta.projects_subject=tab.encyclopedia_subject
- LEFT JOIN ".DB_THREADS." tac ON ta.projects_subject=tac.thread_subject
- LEFT JOIN ".DB_DOWN." tad ON ta.projects_subject=tad.down_subject
- LEFT JOIN ".DB_DOWNLOAD_CATS." tae ON ta.projects_subject=tae.download_cat_name
- LEFT JOIN ".DB_VIDEO_CAT." taf ON ta.projects_subject=taf.cat_name WHERE projects_id='".(isset($_POST['projects_id']) ? $_POST['projects_id'] : $_GET['projects_id'])."'");
- if (dbrows($result)) {
- $data = dbarray($result);
- $project = $data['projects_subject'];
- $encyc = $data['encyclopedia_subject'];
- $forum = $data['thread_subject'];
- $down = $data['down_subject'];
- $download = $data['download_cat_name'];
- $online = $data['cat_name'];
- } else {
- redirect(FUSION_SELF.$aidlink);
- }
- }
- if ((isset($_POST['projects_id']) && isnum($_POST['projects_id'])) || (isset($_GET['projects_id']) && isnum($_GET['projects_id']))) {
- opentable($locale['400']);
- } else {
- if (!isset($_POST['preview'])) {
- $project = "";
- $encyc = "";
- $forum = "";
- $down = "";
- $download = "";
- $online = "";
- }
- opentable($locale['400']);
- }
- $result = dbquery("SELECT ta.projects_id, ta.projects_subject,
- tab.encyclopedia_subject,
- tac.thread_subject,
- tad.down_subject,
- tae.download_cat_name,
- taf.cat_name
- FROM ".DB_PROJECTS." ta
- LEFT JOIN ".DB_ENCYCLOPEDIA." tab ON ta.projects_subject=tab.encyclopedia_subject
- LEFT JOIN ".DB_THREADS." tac ON ta.projects_subject=tac.thread_subject
- LEFT JOIN ".DB_DOWN." tad ON ta.projects_subject=tad.down_subject
- LEFT JOIN ".DB_DOWNLOAD_CATS." tae ON ta.projects_subject=tae.download_cat_name
- LEFT JOIN ".DB_VIDEO_CAT." taf ON ta.projects_subject=taf.cat_name ORDER BY projects_subject DESC");
- $list = ""; $sel = "";
- while ($data = dbarray($result)) {
- if (isset($projects_subject)) $sel = ($projects_subject == $data['projects_subject'] ? " selected='selected'" : "");
- $list .= "<option value='".$data['projects_subject']."'$sel>".$data['projects_subject']."</option>\n";
- }
- echo "<form name='inputform' method='post' action='".FUSION_SELF.$aidlink."' onsubmit='return ValidateForm(this)'>\n";
- echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['401']."</td>\n";
- echo "<td class='tbl'><input type='text' name='project' value='".$project."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['402']."</td>\n";
- echo "<td class='tbl'><input type='text' name='encyc' value='".$encyc."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['403']."</td>\n";
- echo "<td class='tbl'><input type='text' name='forum' value='".$forum."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['404']."</td>\n";
- echo "<td class='tbl'><input type='text' name='down' value='".$down."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['405']."</td>\n";
- echo "<td class='tbl'><input type='text' name='download' value='".$download."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td width='100' class='tbl'>".$locale['406']."</td>\n";
- echo "<td class='tbl'><input type='text' name='online' value='".$online."' class='textbox' style='width:250px;' /></td>\n";
- echo "</tr>\n<tr>\n";
- echo "<td align='center' colspan='2' class='tbl'><br />\n";
- if ((isset($_POST['projects_id']) && isnum($_POST['projects_id'])) || (isset($_GET['projects_id']) && isnum($_GET['projects_id']))) {
- echo "<input type='hidden' name='projects_id' value='".(isset($_POST['projects_id']) ? $_POST['projects_id'] : $_GET['projects_id'])."' />\n";
- }
- echo "<input type='submit' name='preview' value='".$locale['407']."' class='button' />\n";
- echo "<input type='submit' name='save' value='".$locale['408']."' class='button' /></td>\n";
- echo "</tr>\n</table>\n</form>\n";
- closetable();
- echo "<script type='text/javascript'>"."\n"."function DeleteArticle() {\n";
- echo "return confirm('".$locale['451']."');\n}\n";
- echo "function ValidateForm(frm) {"."\n"."if(frm.subject.value=='') {\n";
- echo "alert('".$locale['450']."');"."\n"."return false;\n}\n}\n</script>\n";
- }
- } else {
- opentable($locale['403']);
- echo "<div style='text-align:center'>".$locale['452']."<br />\n".$locale['453']."<br />\n";
- echo "<a href='article_cats.php".$aidlink."'>".$locale['454']."</a>".$locale['455']."</div>\n";
- closetable();
- }
- require_once THEMES."templates/footer.php";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement