Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 18th, 2012  |  syntax: PHP  |  size: 3.78 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         function faq() {
  2.                 global $tc_db, $tpl_page;
  3.                 $this->AdministratorsOnly();
  4.                 $disptable = true; $formval = 'add'; $title = _gettext('FAQ Management');
  5.                 if(isset($_GET['act'])) {
  6.                         if ($_GET['act'] == 'edit') {
  7.                                 if (isset($_POST['faq'])) {
  8.                                         $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "front` SET `subject` = " . $tc_db->qstr($_POST['heading']) . ", `message` = " . $tc_db->qstr($_POST['faq']) . ", `order` = " . intval($_POST['order']) . " WHERE `id` = " . $tc_db->qstr($_GET['id']) . "");
  9.                                         $tpl_page .= '<hr /><h3>'. _gettext('FAQ entry edited') .'</h3><hr />';
  10.                                         management_addlogentry(_gettext('Edited a FAQ entry'), 9);
  11.                                 }
  12.                                 $formval = 'edit&amp;id='. $_GET['id']; $title .= ' - Edit';
  13.                                 $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "front` WHERE `id` = " . $tc_db->qstr($_GET['id']));
  14.                                 $values = $results[0];
  15.                                 $disptable = false;
  16.                         } elseif ($_GET['act'] == 'del') {
  17.                                 $results = $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "front` WHERE `id` = " . $tc_db->qstr($_GET['id']));
  18.                                 $tpl_page .= '<hr /><h3>'. _gettext('FAQ entry deleted') .'</h3><hr />';
  19.                                 management_addlogentry(_gettext('Deleted a FAQ entry'), 9);
  20.                         } elseif ($_GET['act'] == 'add') {
  21.                                 if (isset($_POST['faq']) && isset($_POST['heading']) && isset($_POST['order'])) {
  22.                                         if (!empty($_POST['faq']) || !empty($_POST['heading'])) {
  23.                                                 $tpl_page .= '<hr />';
  24.                                                 $tc_db->Execute("INSERT HIGH_PRIORITY INTO `" . KU_DBPREFIX . "front` ( `page`, `subject` , `message` , `order` ) VALUES ( '1', " . $tc_db->qstr($_POST['heading']) . " , " . intval($_POST['faq']) . " , " . intval($_POST['order']) . " )");
  25.                                                 $tpl_page .= '<h3>'. _gettext('FAQ entry successfully added.') . '</h3>';
  26.                                                 management_addlogentry(_gettext('Added a FAQ entry'), 9);
  27.                                                 $tpl_page .= '<hr />';
  28.                                         } else {
  29.                                                 $tpl_page .= '<hr />'. _gettext('You must enter a heading as well as a post.') .'<hr />';
  30.                                         }
  31.                                 }
  32.                         }
  33.                 }
  34.                 $tpl_page .= '<h2>'. $title . '</h2><br />
  35.                         <form method="post" action="?action=faq&amp;act='. $formval . '">
  36.                         <label for="heading">'. _gettext('Heading') . ':</label>
  37.                         <input type="text" id="heading" name="heading" value="'. (isset($values['subject']) ? $values['subject'] : '') . '" />
  38.                         <div class="desc">'. _gettext('Can not be left blank.') . '</div><br />
  39.                         <label for="faq"> '. _gettext('Post') . ':</label>
  40.                         <textarea id="faq" name="faq" rows="25" cols="80">' . (isset($values['message']) ? htmlspecialchars($values['message']) : '') . '</textarea><br /><br />
  41.                         <label for="order">'. _gettext('Order') . ':</label>
  42.                         <input type="text" id="order" name="order" value="'     . (isset($values['order']) ? $values['order'] : '') . '" />
  43.                         <div class="desc">'. _gettext('This can be left blank, however it will appear at the very top of the list') . '</div><br />
  44.                         <input type="submit" value="'. _gettext('Add') . '" />
  45.                         </form>';
  46.                 if ($disptable) {
  47.                         $tpl_page .= '<br /><hr /><h1>'. _gettext('Edit/Delete FAQ Entries') .'</h1>';
  48.                         $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "front` WHERE `page` = 1 ORDER BY `order` ASC");
  49.                         if (count($results) > 0) {
  50.                                 $tpl_page .= '<table border="1" width="100%"><tr><th>'. _gettext('Order') .'</th><th>'. _gettext('Heading') .'</th><th>'. _gettext('Message') .'</th><th>'. _gettext('Edit/Delete') .'</th></tr>';
  51.                                 foreach ($results as $line) {
  52.                                         $tpl_page .= '<tr><td>'. $line['order'] . '</td><td>'. $line['subject'] . '</td><td>'. $line['message'] . '</td><td>[<a href="?action=faq&amp;act=edit&amp;id='. $line['id'] . '">'. _gettext('Edit') .'</a>] [<a href="?action=faq&amp;act=del&id='. $line['id'] . '">'. _gettext('Delete') .'</a>]</td></tr>';
  53.                                 }
  54.                                 $tpl_page .= '</table>';
  55.                         } else {
  56.                                 $tpl_page .= _gettext('No FAQ entries yet.');
  57.                         }
  58.                 }
  59.         }