[ Index ]
 

Code source de PHP NUKE 7.9

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/FAQ/admin/ -> index.php (source)

   1  <?php
   2  
   3  /************************************************************************/

   4  /* PHP-NUKE: Web Portal System                                          */

   5  /* ===========================                                          */

   6  /*                                                                      */

   7  /* Copyright (c) 2005 by Francisco Burzi                                */

   8  /* http://phpnuke.org                                                   */

   9  /*                                                                      */

  10  /* Based on PHP-Nuke Add-On                                             */

  11  /* Copyright (c) 2001 by Richard Tirtadji AKA King Richard              */

  12  /*                       (rtirtadji@hotmail.com)                        */

  13  /*                       Hutdik Hermawan AKA hotFix                     */

  14  /*                       (hutdik76@hotmail.com)                         */

  15  /* http://www.nukeaddon.com                                             */

  16  /*                                                                      */

  17  /* This program is free software. You can redistribute it and/or modify */

  18  /* it under the terms of the GNU General Public License as published by */

  19  /* the Free Software Foundation; either version 2 of the License.       */

  20  /************************************************************************/

  21  
  22  if (!defined('ADMIN_FILE')) {
  23      die ("Access Denied");
  24  }
  25  
  26  global $prefix, $db, $admin_file;
  27  $aid = substr("$aid", 0,25);
  28  $row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='FAQ'"));
  29  $row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
  30  $admins = explode(",", $row['admins']);
  31  $auth_user = 0;
  32  for ($i=0; $i < sizeof($admins); $i++) {
  33      if ($row2['name'] == "$admins[$i]" AND !empty($row['admins'])) {
  34          $auth_user = 1;
  35      }
  36  }
  37  
  38  if ($row2['radminsuper'] == 1 || $auth_user == 1) {
  39  
  40      /*********************************************************/

  41      /* Faq Admin Function                                    */

  42      /*********************************************************/

  43  
  44  	function FaqAdmin() {
  45          global $admin, $bgcolor2, $prefix, $db, $currentlang, $multilingual, $admin_file, $language;
  46          include  ("header.php");
  47          GraphicAdmin();
  48          OpenTable();
  49          echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
  50          CloseTable();
  51          echo "<br>";
  52          OpenTable();
  53          echo "<center><font class=\"option\"><b>" . _ACTIVEFAQS . "</b></font></center><br>"
  54          ."<table border=\"1\" width=\"100%\" align=\"center\"><tr>"
  55          ."<td bgcolor=\"$bgcolor2\" align=\"left\" nowrap>&nbsp;<b>" . _CATEGORIES . "</b>&nbsp;</td>"
  56          ."<td bgcolor=\"$bgcolor2\" align=\"center\" nowrap>&nbsp;<b>" . _LANGUAGE . "</b>&nbsp;</td>"
  57          ."<td bgcolor=\"$bgcolor2\" align=\"center\" nowrap>&nbsp;<b>" . _FUNCTIONS . "</b>&nbsp;</td></tr><tr>";
  58          $result = $db->sql_query("select id_cat, categories, flanguage from ".$prefix."_faqcategories order by id_cat");
  59          while ($row = $db->sql_fetchrow($result)) {
  60              $id_cat = $row['id_cat'];
  61              $categories = filter($row['categories'], "nohtml");
  62              $flanguage = $row['flanguage'];
  63              if (empty($flanguage)) {
  64                  $flanguage = _ALL;
  65              }
  66              echo "<td align=\"left\" width=\"100%\">&nbsp;$categories</td>"
  67              ."<td align=\"center\">$flanguage</td>"
  68              ."<td align=\"center\" nowrap>&nbsp;<a href=\"".$admin_file.".php?op=FaqCatGo&amp;id_cat=$id_cat\"><img src=\"images/add.gif\" alt=\""._CONTENT."\" title=\""._CONTENT."\" border=\"0\" width=\"17\" height=\"17\"></a>  <a href=\"".$admin_file.".php?op=FaqCatEdit&amp;id_cat=$id_cat\"><img src=\"images/edit.gif\" alt=\""._EDIT."\" title=\""._EDIT."\" border=\"0\" width=\"17\" height=\"17\"></a>  <a href=\"".$admin_file.".php?op=FaqCatDel&amp;id_cat=$id_cat&amp;ok=0\"><img src=\"images/delete.gif\" alt=\""._DELETE."\" title=\""._DELETE."\" border=\"0\" width=\"17\" height=\"17\"></a>&nbsp;</td><tr>";
  69          }
  70          echo "</td></tr></table>";
  71          CloseTable();
  72          echo "<br>";
  73          OpenTable();
  74          echo "<center><font class=\"option\"><b>" . _ADDCATEGORY . "</b></font></center><br>"
  75          ."<form action=\"".$admin_file.".php\" method=\"post\">"
  76          ."<table border=\"0\" width=\"100%\"><tr><td>"
  77          ."" . _CATEGORIES . ":</td><td><input type=\"text\" name=\"categories\" size=\"30\"></td>";
  78          if ($multilingual == 1) {
  79              echo "<tr><td>" . _LANGUAGE . ":</td><td>"
  80              ."<select name=\"flanguage\">";
  81              $handle=opendir('language');
  82              while ($file = readdir($handle)) {
  83                  if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  84                      $langFound = $matches[1];
  85                      $languageslist .= "$langFound ";
  86                  }
  87              }
  88              closedir($handle);
  89              $languageslist = explode(" ", $languageslist);
  90              sort($languageslist);
  91              for ($i=0; $i < sizeof($languageslist); $i++) {
  92                  if(!empty($languageslist[$i])) {
  93                      echo "<option value=\"$languageslist[$i]\" ";
  94                      if($languageslist[$i]==$currentlang) echo "selected";
  95                      echo ">".ucfirst($languageslist[$i])."</option>\n";
  96                  }
  97              }
  98              echo "</select></td>";
  99          } else {
 100              echo "<input type=\"hidden\" name=\"flanguage\" value=\"$language\">";
 101          }
 102          echo "</tr></table>"
 103          ."<input type=\"hidden\" name=\"op\" value=\"FaqCatAdd\">"
 104          ."<input type=\"submit\" value=" . _SAVE . ">"
 105          ."</form>";
 106          CloseTable();
 107          include ("footer.php");
 108      }
 109  
 110  	function FaqCatGo($id_cat) {
 111          global $admin, $bgcolor2, $prefix, $db, $admin_file;
 112          include  ("header.php");
 113          GraphicAdmin();
 114          OpenTable();
 115          echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
 116          CloseTable();
 117          echo "<br>";
 118          OpenTable();
 119          echo "<center><font class=\"option\"><b>" . _QUESTIONS . "</b></font></center><br>"
 120          ."<table border=1 width=100% align=\"center\"><tr>"
 121          ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>" . _CONTENT . "</b></td>"
 122          ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>" . _FUNCTIONS . "</b></td></tr>";
 123          $id_cat = intval($id_cat);
 124          $result = $db->sql_query("select id, question, answer from ".$prefix."_faqanswer where id_cat='$id_cat' order by id");
 125          while ($row = $db->sql_fetchrow($result)) {
 126              $id = intval($row['id']);
 127              $question = filter($row['question'], "nohtml");
 128              $answer = filter($row['answer']);
 129              echo "<tr><td><i>$question</i><br><br>$answer"
 130              ."</td><td align=\"center\">&nbsp;<a href=\"".$admin_file.".php?op=FaqCatGoEdit&amp;id=$id\"><img src=\"images/edit.gif\" alt=\""._EDIT."\" title=\""._EDIT."\" border=\"0\" width=\"17\" height=\"17\"></a>  <a href=\"".$admin_file.".php?op=FaqCatGoDel&amp;id=$id&amp;ok=0\"><img src=\"images/delete.gif\" alt=\""._DELETE."\" title=\""._DELETE."\" border=\"0\" width=\"17\" height=\"17\"></a>&nbsp;</td></tr>"
 131              ."</td></tr>";
 132          }
 133          echo "</table>";
 134          CloseTable();
 135          echo "<br>";
 136          OpenTable();
 137          echo "<center><font class=\"option\"><b>" . _ADDQUESTION . "</b></center><br>"
 138          ."<form action=\"".$admin_file.".php\" method=\"post\">"
 139          ."<table border=\"0\" width=\"100%\"><tr><td>"
 140          ."" . _QUESTION . ":</td><td><input type=\"text\" name=\"question\" size=\"40\"></td></tr><tr><td>"
 141          ."" . _ANSWER . " </td><td><textarea name=\"answer\" cols=\"70\" rows=\"15\"></textarea>"
 142          ."</td></tr></table>"
 143          ."<input type=\"hidden\" name=\"id_cat\" value=\"$id_cat\">"
 144          ."<input type=\"hidden\" name=\"op\" value=\"FaqCatGoAdd\">"
 145          ."<input type=\"submit\" value=" . _SAVE . "> " . _GOBACK . ""
 146          ."</form>";
 147          CloseTable();
 148          include ("footer.php");
 149      }
 150  
 151  	function FaqCatEdit($id_cat) {
 152          global $admin, $db, $multilingual, $admin_file;
 153          include  ("config.php");
 154          include  ("header.php");
 155          GraphicAdmin();
 156          OpenTable();
 157          echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
 158          CloseTable();
 159          echo "<br>";
 160          $id_cat = intval($id_cat);
 161          $row = $db->sql_fetchrow($db->sql_query("SELECT categories, flanguage from " . $prefix . "_faqcategories where id_cat='$id_cat'"));
 162          $categories = filter($row['categories'], "nohtml");
 163          $flanguage = $row['flanguage'];
 164          OpenTable();
 165          echo "<center><font class=\"option\"><b>" . _EDITCATEGORY . "</b></font></center>"
 166          ."<form action=\"".$admin_file.".php\" method=\"post\">"
 167          ."<input type=\"hidden\" name=\"id_cat\" value=\"$id_cat\">"
 168          ."<table border=\"0\" width=\"100%\"><tr><td>"
 169          ."" . _CATEGORIES . ":</td><td><input type=\"text\" name=\"categories\" size=\"31\" value='$categories'></td>";
 170          if ($multilingual == 1) {
 171              echo "<tr><td>" . _LANGUAGE . ":</td><td>"
 172              ."<select name=\"flanguage\">";
 173              $handle=opendir('language');
 174              while ($file = readdir($handle)) {
 175                  if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
 176                      $langFound = $matches[1];
 177                      $languageslist .= "$langFound ";
 178                  }
 179              }
 180              closedir($handle);
 181              $languageslist = explode(" ", $languageslist);
 182              sort($languageslist);
 183              for ($i=0; $i < sizeof($languageslist); $i++) {
 184                  if(!empty($languageslist[$i])) {
 185                      echo "<option name=\"flanguage\" value=\"$languageslist[$i]\" ";
 186                      if($languageslist[$i]==$flanguage) echo "selected";
 187                      echo ">".ucfirst($languageslist[$i])."</option>\n";
 188                  }
 189              }
 190              echo "</select></td>";
 191          } else {
 192              echo "<input type=\"hidden\" name=\"flanguage\" value=\"$language\">";
 193          }
 194          echo "</tr></table>"
 195          ."<input type=\"hidden\" name=\"op\" value=\"FaqCatSave\">"
 196          ."<input type=\"submit\" value=\""._SAVE."\"> "._GOBACK.""
 197          ."</form>";
 198          CloseTable();
 199          include ("footer.php");
 200      }
 201  
 202  	function FaqCatGoEdit($id) {
 203          global $admin, $bgcolor2, $prefix, $db, $admin_file;
 204          include  ("header.php");
 205          GraphicAdmin();
 206          OpenTable();
 207          echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
 208          CloseTable();
 209          echo "<br>";
 210          $id = intval($id);
 211          $row = $db->sql_fetchrow($db->sql_query("SELECT question, answer from " . $prefix . "_faqanswer where id='$id'"));
 212          $question = filter($row['question'], "nohtml");
 213          $answer = filter($row['answer']);
 214          OpenTable();
 215          echo "<center><font class=\"option\"><b>" . _EDITQUESTIONS . "</b></font></center>"
 216          ."<form action=\"".$admin_file.".php\" method=\"post\">"
 217          ."<input type=\"hidden\" name=\"id\" value=\"$id\">"
 218          ."<table border=\"0\" width=\"100%\"><tr><td>"
 219          ."" . _QUESTION . ":</td><td><input type=\"text\" name=\"question\" size=\"31\" value=\"$question\"></td></tr><tr><td>"
 220          ."" . _ANSWER . ":</td><td><textarea name=\"answer\" cols=70 rows=15>$answer</textarea>"
 221          ."</td></tr></table>"
 222          ."<input type=\"hidden\" name=\"op\" value=\"FaqCatGoSave\">"
 223          ."<input type=\"submit\" value=" . _SAVE . "> " . _GOBACK . ""
 224          ."</form>";
 225          CloseTable();
 226          include ("footer.php");
 227      }
 228  
 229  
 230  	function FaqCatSave($id_cat, $categories, $flanguage) {
 231          global $prefix, $db, $admin_file;
 232          $categories = filter($categories, "nohtml", 1);
 233          $id_cat = intval($id_cat);
 234          $db->sql_query("update ".$prefix."_faqcategories set categories='$categories', flanguage='$flanguage' where id_cat='$id_cat'");
 235          Header("Location: ".$admin_file.".php?op=FaqAdmin");
 236      }
 237  
 238  	function FaqCatGoSave($id, $question, $answer) {
 239          global $prefix, $db, $admin_file;
 240          $question = filter($question, "nohtml", 1);
 241          $answer = filter($answer, "", 1);
 242          $id = intval($id);
 243          $db->sql_query("update ".$prefix."_faqanswer set question='$question', answer='$answer' where id='$id'");
 244          Header("Location: ".$admin_file.".php?op=FaqAdmin");
 245      }
 246  
 247  	function FaqCatAdd($categories, $flanguage) {
 248          global $prefix, $db, $admin_file;
 249          $categories = filter($categories, "nohtml", 1);
 250          $db->sql_query("insert into ".$prefix."_faqcategories values (NULL, '$categories', '$flanguage')");
 251          Header("Location: ".$admin_file.".php?op=FaqAdmin");
 252      }
 253  
 254  	function FaqCatGoAdd($id_cat, $question, $answer) {
 255          global $prefix, $db, $admin_file;
 256          $question = filter($question, "nohtml", 1);
 257          $answer = filter($answer, "", 1);
 258          $db->sql_query("insert into ".$prefix."_faqanswer values (NULL, '$id_cat', '$question', '$answer')");
 259          Header("Location: ".$admin_file.".php?op=FaqCatGo&id_cat=$id_cat");
 260      }
 261  
 262  	function FaqCatDel($id_cat, $ok=0) {
 263          global $prefix, $db, $admin_file;
 264          if($ok==1) {
 265              $id_cat = intval($id_cat);
 266              $db->sql_query("delete from ".$prefix."_faqcategories where id_cat='$id_cat'");
 267              $db->sql_query("delete from ".$prefix."_faqanswer where id_cat='$id_cat'");
 268              Header("Location: ".$admin_file.".php?op=FaqAdmin");
 269          } else {
 270              include ("header.php");
 271              GraphicAdmin();
 272              OpenTable();
 273              echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
 274              CloseTable();
 275              echo "<br>";
 276              OpenTable();
 277              echo "<br><center><b>" . _FAQDELWARNING . "</b><br><br>";
 278          }
 279          echo "[ <a href=\"".$admin_file.".php?op=FaqCatDel&amp;id_cat=$id_cat&amp;ok=1\">" . _YES . "</a> | <a href=\"".$admin_file.".php?op=FaqAdmin\">" . _NO . "</a> ]</center><br><br>";
 280          CloseTable();
 281          include ("footer.php");
 282      }
 283  
 284  	function FaqCatGoDel($id, $ok=0) {
 285          global $prefix, $db, $admin_file;
 286          if($ok==1) {
 287              $id = intval($id);
 288              $db->sql_query("delete from ".$prefix."_faqanswer where id='$id'");
 289              Header("Location: ".$admin_file.".php?op=FaqAdmin");
 290          } else {
 291              include ("header.php");
 292              GraphicAdmin();
 293              OpenTable();
 294              echo "<center><font class=\"title\"><b>" . _FAQADMIN . "</b></font></center>";
 295              CloseTable();
 296              echo "<br>";
 297              OpenTable();
 298              echo "<br><center><b>" . _QUESTIONDEL . "</b><br><br>";
 299          }
 300          echo "[ <a href=\"".$admin_file.".php?op=FaqCatGoDel&amp;id=$id&amp;ok=1\">" . _YES . "</a> | <a href=\"".$admin_file.".php?op=FaqAdmin\">" . _NO . "</a> ]</center><br><br>";
 301          CloseTable();
 302          include ("footer.php");
 303      }
 304  
 305      switch($op) {
 306  
 307          case "FaqCatSave":
 308          FaqCatSave($id_cat, $categories, $flanguage); /* Multilingual Code : added variable */
 309          break;
 310  
 311          case "FaqCatGoSave":
 312          FaqCatGoSave($id, $question, $answer);
 313          break;
 314  
 315          case "FaqCatAdd":
 316          FaqCatAdd($categories, $flanguage); /* Multilingual Code : added variable */
 317          break;
 318  
 319          case "FaqCatGoAdd":
 320          FaqCatGoAdd($id_cat, $question, $answer);
 321          break;
 322  
 323          case "FaqCatEdit":
 324          FaqCatEdit($id_cat);
 325          break;
 326  
 327          case "FaqCatGoEdit":
 328          FaqCatGoEdit($id);
 329          break;
 330  
 331          case "FaqCatDel":
 332          FaqCatDel($id_cat, $ok);
 333          break;
 334  
 335          case "FaqCatGoDel":
 336          FaqCatGoDel($id, $ok);
 337          break;
 338  
 339          case "FaqAdmin":
 340          FaqAdmin();
 341          break;
 342  
 343          case "FaqCatGo":
 344          FaqCatGo($id_cat);
 345          break;
 346      }
 347  
 348  } else {
 349      include ("header.php");
 350      GraphicAdmin();
 351      OpenTable();
 352      echo "<center><b>"._ERROR."</b><br><br>You do not have administration permission for module \"$module_name\"</center>";
 353      CloseTable();
 354      include ("footer.php");
 355  }
 356  
 357  ?>


Généré le : Sun Apr 1 11:11:59 2007 par Balluche grâce à PHPXref 0.7