Location: PHPKode > projects > phpBannerEx > adm_conf.php
<?
#################################################################################################
#
#  project              : phpBannerEx
#  filename             : .php
#  last modified by     : 
#  e-mail               : hide@address.com
#  purpose              :
#
#################################################################################################

#  Include Configs & Variables
#################################################################################################
require("admin/config.php");
require("library.php");

db_connect();
ReadConfig();

$user = authorize();

if($user[ur_id] != 1) {
  unauthorize();
  print "<script> document.location=document.location; </script>";
  exit;
}


function main_list() {
  global $default_language;

  echo "<center>\n";

  echo "<form name=\"frmCat\" method=post>\n";
  echo "<h1>Categories</h1>\n";
  echo "<table class=list width=50%>\n";
  echo "  <tr>\n";
  echo "    <th class=list>Category name</th>\n";
  echo "    <th width=60 class=list>Delete</th>\n";
  echo "  </tr>\n";
  $sql = "SELECT * FROM cat ORDER BY ct_name"; $res = db_query($sql);
  while($row = mysql_fetch_array($res)) {
    echo "  <tr>\n";
    echo "    <td class=list><a href=\"adm_conf.php?act=cat_mod_form&cid=$row[ct_id]\"> $row[ct_name] </a></td>\n";
    echo "    <td class=list><a href=\"adm_conf.php?act=cat_del&cid=$row[ct_id]\">Delete</a></td>\n";
    echo "   </tr>\n";
  }
  echo "</table>\n";
  echo "<p>\n";
  echo "<a href=\"adm_conf.php?act=cat_add_form\"> New Category </a>\n";
  echo "</form>\n";

  echo "<form name=\"frmLng\" method=post>\n";
  echo "<h1>Languages</h1>\n";
  echo "<table class=list width=50%>\n";
  echo "  <tr>\n";
  echo "    <th class=list>Language</th>\n";
  echo "    <th class=list>Charset</th>\n";
  echo "    <th width=60 class=list>Delete</th>\n";
  echo "  </tr>\n";
  $sql = "SELECT * FROM lang"; $res = db_query($sql);
  while($row = mysql_fetch_array($res)) {
    echo "  <tr>\n";
    echo "    <td class=list><a href=\"adm_conf.php?act=lang_mod_form&lid=$row[ln_id]\"> $row[ln_name]</a></td>\n";
    echo "    <td class=list>$row[ln_charset]</td>\n";
    echo "    <td class=list><a href=\"adm_conf.php?act=lang_del&lid=$row[ln_id]\">Delete</a></td>\n";
    echo "   </tr>\n";
  }
  echo "</table>\n";
  echo "<p>\n";
  echo "<a href=\"adm_conf.php?act=lang_add_form\"> New Language</a>\n";
  echo "</form>\n";

  echo "<p>\n";
}

# Category Administration ===========================================

function cat_add_form() {
  echo "<center>\n";
  echo "<form name=\"frmCat\" method=post>\n";

  echo "<h1>New Category</h1>\n";
  echo "<table class=standard>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Category</td>\n";
  echo "    <td class=standard><input type=text name=\"ct_name\"></td>\n";
  echo "  </tr>\n";
  echo "</table>\n";

  echo "<p>\n";
  echo "<input type=hidden name=act value=cat_add>\n";
  echo "<input type=submit value=\"Add Category\">\n";
  echo "</form>";
}

function cat_add() {
  global $ct_code, $ct_lang_ref, $ct_name;

  if(!$ct_name)  { echo "Category Name cannot be empty!<br>\n"; }

  if(!$ct_name) {
    echo "<br>\n";
    echo "Go <a href=\"javascript:history.back();\">back</a> and correct all errors.<br>\n";
    exit;
  }

  $sql = "INSERT INTO cat (ct_name) VALUES ('$ct_name')";
  $res = db_query($sql);

  main_list();
}

function cat_mod_form() {
  global $cid;

  echo "<center>\n";
  echo "<form name=\"frmCat\" method=post>\n";

  $cat = mysql_fetch_array(db_query("SELECT * FROM cat WHERE ct_id = '$cid'"));

  echo "<h1>Modify Category</h1>\n";
  echo "<table class=standard>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Category</td>\n";
  echo "    <td class=standard><input type=text name=\"ct_name\" value=\"$cat[ct_name]\"></td>\n";
  echo "  </tr>\n";
  echo "</table>\n";

  echo "<p>\n";
  echo "<input type=hidden name=act value=cat_mod>\n";
  echo "<input type=submit value=\"Modify Category\">\n";
  echo "</form>";
}

function cat_mod() {
  global $cid, $ct_name;

  if(!$ct_name)  { echo "Category Name cannot be empty!<br>\n"; }

  if(!$ct_name) {
    echo "<br>\n";
    echo "Go <a href=\"javascript:history.back();\">back</a> and correct all errors.<br>\n";
    exit;
  }

  $sql = "UPDATE cat SET ct_name='$ct_name' WHERE ct_id='$cid'";
  $res = db_query($sql);

  main_list();
}

function cat_del() {
  global $cid;

  $sql = "DELETE FROM cat WHERE ct_id = '$cid'";
  $res = db_query($sql);

  main_list();
}

# Language Administration

function lang_add_form() {
  echo "<center>\n";
  echo "<form name=\"frmLang\" method=post>\n";

  echo "<h1>New Language</h1>\n";
  echo "<table class=standard>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Language</td>\n";
  echo "    <td class=standard><input type=text name=\"ln_name\"</td>\n";
  echo "  </tr>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Charset</td>\n";
  echo "    <td class=standard><input type=text name=\"ln_charset\"</td>\n";
  echo "  </tr>\n";
  echo "</table>\n";

  echo "<p>\n";
  echo "<input type=hidden name=act value=lang_add>\n";
  echo "<input type=submit value=\"Add Language\">\n";
  echo "</form>";
}

function lang_add() {
  global $ln_name, $ln_charset;

  if(!$ln_name)     { echo "Language Name cannot be empty!<br>\n"; }
  if(!$ln_charset)  { echo "Charset cannot be empty!<br>\n"; }

  if(!$ln_name || !$ln_charset) {
    echo "<br>\n";
    echo "Go <a href=\"javascript:history.back();\">back</a> and correct all errors.<br>\n";
    exit;
  }

  $sql = "INSERT INTO lang (ln_name, ln_charset) VALUES ('$ln_name','$ln_charset')";
  $res = db_query($sql);

  main_list();
}

function lang_mod_form() {
  global $lid;

  $lng = mysql_fetch_array(db_query("SELECT * FROM lang WHERE ln_id='$lid'"));

  echo "<center>\n";
  echo "<form name=\"frmLang\" method=post>\n";

  echo "<h1>Modify Language</h1>\n";
  echo "<table class=standard>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Language</td>\n";
  echo "    <td class=standard><input type=text name=\"ln_name\" value=\"$lng[ln_name]\"></td>\n";
  echo "  </tr>\n";
  echo "  <tr>\n";
  echo "    <td class=standard>Charset</td>\n";
  echo "    <td class=standard><input type=text name=\"ln_charset\" value=\"$lng[ln_charset]\"></td>\n";
  echo "  </tr>\n";
  echo "</table>\n";

  echo "<p>\n";
  echo "<input type=hidden name=act value=lang_mod>\n";
  echo "<input type=submit value=\"Modify Language\">\n";
  echo "</form>";
}

function lang_mod() {
  global $lid, $ln_name, $ln_charset;

  if(!$ln_name)    { echo "Language Name cannot be empty!<br>\n"; }
  if(!$ln_charset) { echo "Charset cannot be empty!<br>\n"; }

  if(!$ln_name) {
    echo "<br>\n";
    echo "Go <a href=\"javascript:history.back();\">back</a> and correct all errors.<br>\n";
    exit;
  }

  $sql = "UPDATE lang SET ln_name='$ln_name', ln_charset='$ln_charset' WHERE ln_id='$lid'";
  $res = db_query($sql);

  main_list();
}

function lang_del() {
  global $lid;

  $sql = "DELETE FROM lang WHERE ln_id = '$lid'";
  $res = db_query($sql);

  main_list();
}

include($addheader);

include("adm_menu.inc");

if(!$act) { main_list(); }

if($act == "cat_add_form") { cat_add_form(); }
if($act == "cat_add")      { cat_add(); }
if($act == "cat_mod_form") { cat_mod_form(); }
if($act == "cat_mod")      { cat_mod(); }
if($act == "cat_del")      { cat_del(); }

if($act == "lang_add_form") { lang_add_form(); }
if($act == "lang_add")      { lang_add(); }
if($act == "lang_mod_form") { lang_mod_form(); }
if($act == "lang_mod")      { lang_mod(); }
if($act == "lang_del")      { lang_del(); }

include("$addfooter");

?>
Return current item: phpBannerEx