Location: PHPKode > projects > phpBannerEx > adm_lang.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 $lang, $show_languages;

  if($lang) {
    echo "<center>\n";
    echo "<form name=\"frmCatAdm\" method=post>\n";

    echo "<h1>".get_msg("categories",$lang)."</h1>\n";
    echo "<table class=list>\n";
    echo "  <tr>\n";
    echo "    <th class=list>".get_msg('category', $lang)."</th>\n";
    echo "    <th class=list>".get_msg("translation",$lang)."</th>\n";
    echo "  </tr>\n";
    $sql = "SELECT * FROM cat LEFT JOIN cat_l ON (ct_id = cl_cat_ref AND cl_lang_ref = '$lang') ORDER BY ct_name"; $res = db_query($sql);
    while($row = mysql_fetch_array($res)) {
      echo "  <tr>\n";
      echo "    <td class=list>$row[ct_name]</td>\n";
      echo "    <td class=list><input type=text name=\"cat[$row[ct_id]]\" value=\"$row[cl_name]\" size=60></td>\n";
      echo "   </tr>\n";
    }
    echo "</table>\n";
    echo "<input type=hidden name=lang value=\"$lang\">";
    echo "<input type=hidden name=act value=cat_change>";
    echo "<input type=submit value=\"".get_msg(save,$lang)." ".get_msg(categories,$lang)."\">\n";
    echo "<input type=reset value=\"".get_msg(reset,$lang)." ".get_msg(categories,$lang)."\">\n";
    echo "<input type=button value=\"".get_msg(goback,$lang)."\" onClick=\"javascript:document.location='adm.php';\">\n";
    echo "</form>\n";
  }

  echo "<form name=\"frmMsgAdm\" method=post>\n";
  echo "<h1>".get_msg(messages,$lang)."</h1>\n";
  echo "<table class=list>\n";
  echo "  <tr>\n";
  echo "    <th class=list>".get_msg(keyword,$lang)."</th>\n";
  echo "    <th class=list>".get_msg(message,$lang)."</th>\n";
  echo "    <th class=list>".get_msg(translation,$lang)."</th>\n";
  echo "  </tr>\n";
  $sql = "SELECT msg.ms_kw,msg.ms_text as text1,m1.ms_text as text2 FROM msg LEFT JOIN msg as m1 ON (m1.ms_kw = msg.ms_kw AND m1.ms_lang_ref = '$lang') WHERE msg.ms_lang_ref=0 ORDER BY msg.ms_kw";
  $res = db_query($sql);
  while($row = mysql_fetch_array($res)) {
    echo "  <tr>\n";
    echo "    <td class=list>$row[ms_kw]</td>\n";
    echo "    <td class=list><textarea readonly cols=40 rows=10>$row[text1]</textarea></td>\n";
    echo "    <td class=list><textarea name=\"msg[$row[ms_kw]]\" cols=40 rows=10>$row[text2]</textarea></td>\n";
    echo "   </tr>\n";
  }
  echo "</table>\n";
  echo "<input type=hidden name=lang value=\"$lang\">";
  echo "<input type=hidden name=act value=msg_change>";
  echo "<input type=submit value=\"".get_msg(save,$lang)." ".get_msg(messages,$lang)."\">\n";
  echo "<input type=reset value=\"".get_msg(reset,$lang)." ".get_msg(messages,$lang)."\">\n";
  echo "<input type=button value=\"".get_msg(goback,$lang)."\" onClick=\"javascript:document.location='adm.php';\">\n";
  echo "</form>\n";

}

function cat_change() {
  global $lang, $cat;

  db_query("DELETE FROM cat_l WHERE cl_lang_ref = '$lang'");
  while(list($key, $val) = each($cat)) {
    db_query("INSERT INTO cat_l (cl_name, cl_cat_ref, cl_lang_ref) VALUES ('$val','$key','$lang')");
  }

  main_list();
}

function msg_change() {
  global $lang, $msg;

  db_query("DELETE FROM msg WHERE ms_lang_ref = '$lang'");
  while(list($key, $val) = each($msg)) {
    if ($val) {
      db_query("INSERT INTO msg (ms_kw, ms_text, ms_lang_ref) VALUES ('$key','$val','$lang')");
    }
  }

  main_list();
}

include($addheader);

include("adm_menu.inc");

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

if($act == "cat_change") { cat_change(); }
if($act == "msg_change") { msg_change(); }

include("$addfooter");

?>
Return current item: phpBannerEx