/module/forum/admin/index.php
PHP | 199 lines | 154 code | 30 blank | 15 comment | 17 complexity | 6b1b8b4507c07904e61de3f580d98428 MD5 | raw file
Possible License(s): AGPL-3.0
- <?php
- /**
- * Module Forum
- *
- * @link http://www.cms.woli.pl/ CMS WOLI
- * @author Rafal Wolak <rafal.wolak@woli.pl>
- * @license http://creativecommons.org/licenses/by/2.5/pl/
- Creative Commons Uznanie autorstwa 2.5
- * @package module
- */
-
- /**
- */
- define('IN_SITE', true);
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
-
-
- // Za?adowanie pliku konfiguracyjnego
- if (!defined('IS_INSTALLED'))
- {
- require_once '../../inc/config.' . $phpEx;
- }
- require_once ROOT_DIR . 'inc/common.' . $phpEx;
- require_once ROOT_DIR . 'inc/init.' . $phpEx;
-
-
- /**
- * Komentarze
- */
- if (!isset($_GET['o']))
- {
- if (request_var('go', 'false') == 'true')
- {
- $postid = $_POST['postid'];
- $rate = $_POST['rate'];
-
- for ($i = 0, $end = count($postid); $i < $end; $i++)
- {
- $sql = 'UPDATE ' . $prefix . '_forum_post
- SET post_active="' . request_var('active-' . $postid[$i], 0) . '",
- post_rate="' . $rate[$i]. '"
- WHERE post_id="' . (int) $postid[$i] . '"';
- $db->sql_query($sql);
- }
-
- header('Location: ' . request_url());
- exit;
- }
- else
- {
- $pag['onsite'] = 20;
- $userid = request_var('userid', 0);
-
- $sql = 'SELECT post_id
- FROM ' . $prefix . '_forum_post';
- $result = $db->sql_query($sql);
- $pag['num'] = $db->sql_numrows($result);
- $db->sql_freeresult($result);
-
- $smarty->assign('num', $pag['num']);
-
-
- $sql = 'SELECT *
- FROM ' . $prefix . '_forum_post
- ORDER BY post_adddate DESC
- LIMIT ' . (int) $pag['start'] . ', ' . (int) $pag['onsite'];
- $result = $db->sql_query($sql);
-
- $lp = $pag['start'] + 1;
- while ($row = $db->sql_fetchrow($result))
- {
- $value[] = array(
- 'id' => $row['post_id'],
- 'url' => $mod_forum->_url($row['post_id']),
- 'title' => $row['post_title'],
- 'text' => htmlspecialchars_decode($row['post_text'], ENT_QUOTES),
- 'userid' => $row['post_userid'],
- 'username' => ($row['post_userid'] > 0) ? $user->username($row['post_userid']) : $row['post_username'],
- 'email' => $row['post_useremail'],
- 'ip' => $row['post_userip'],
- 'host' => $row['post_userhost'],
- 'adddate' => $date->view($row['post_adddate'], '|d.m.Y \o H:i|', false),
- 'active' => $row['post_active'],
- 'rate' => $row['post_rate'],
- 'isbanuserid' => $core->is_ban($row['post_userid'], 'userid', 'text'),
- 'isbanip' => $core->is_ban($row['post_userip'], 'ip', 'text'),
- 'isbanemail' => $core->is_ban($row['post_useremail'], 'email', 'text'),
- 'baniduserid' => $core->is_ban($row['post_userid'], 'userid', 'id'),
- 'banidip' => $core->is_ban($row['post_userip'], 'ip', 'id'),
- 'banidemail' => $core->is_ban($row['post_useremail'], 'email', 'id'),
- 'lp' => $lp
- );
-
- $lp++;
- }
-
- $db->sql_freeresult($result);
-
- $smarty->assign('value', $value);
-
- if ($pag['num'] > 0)
- $smarty->assign('pagination', ($pag['num'] > 0) ? pag(append_sid(SITE_URL . 'admin/?q=' . request_var('q', '') . '&p=#')) : '');
- }
- }
- else
- {
- switch (request_var('w', 'error'))
- {
- case 'edit':
-
- if (request_var('go', 'false') == 'true')
- {
- $sql = 'UPDATE ' . $prefix . '_forum_post
- SET post_title="' . request_var('title', '') . '",
- post_text="' . request_var('text', '') . '",
- post_moddate="' . time() . '",
- post_active="' . request_var('active', 0) . '"
- WHERE ad_id="' . (int) request_var('id', 0) . '"';
-
- if ($db->sql_query($sql))
- {
- $msg = array(
- 'text' => '<strong>' . lang('GLOBAL: CONGRATULATIONS') . '</strong> ' . lang('GLOBAL: OPTIONS HAVE BEEN SAVED'),
- 'url' => SITE_URL . '?q=' . request_var('q', '') . '&o=ad',
- 'time' => 2
- );
- }
- else
- {
- $msg = array(
- 'text' => '<strong>' . lang('GLOBAL: ATTENTION') . '</strong> ' . lang('GLOBAL: FAILED TO SAVE OPTIONS'),
- 'url' => request_url(),
- 'time' => 5
- );
- }
-
- $smarty->assign('msg', $msg);
- }
- else
- {
- $sql = 'SELECT post_id, post_title, post_text, post_active
- FROM ' . $prefix . '_forum_post
- WHERE post_id="' . (int) request_var('id', 0) . '"';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $edit = array(
- 'id' => $row['post_id'],
- 'title' => $row['post_title'],
- 'text' => $row['post_text'],
- 'active' => $row['post_active']
- );
- }
-
- $db->sql_freeresult($result);
-
- $smarty->assign('edit', $edit);
- }
-
- break;
-
- case 'del':
-
- if (request_var('go', 'false') == 'true')
- {
- $sql = 'DELETE
- FROM ' . $prefix . '_forum_post
- WHERE post_id="' . (int) request_var('id', 0) . '"';
-
- if ($db->sql_query($sql))
- {
- $msg = array(
- 'text' => '<strong>Gratulacje!</strong> Dane zosta?y usuni?te.' . $msetext,
- 'url' => SITE_URL . '?q=' . request_var('q', ''),
- 'time' => 5
- );
- }
- else
- {
- $msg = array(
- 'text' => '<strong>Uwaga!</strong> Dane nie zosta3y usuni?te.',
- 'url' => request_url(),
- 'time' => 5
- );
- }
-
- $smarty->assign('msg', $msg);
- }
-
- break;
- }
- }
-
-
- $smarty->caching = 0;
- $cache_lifetime = 0;
- $smarty->display(template('admin/index', 'mod', 'forum'), $my_cache_id);
- ?>