Beispiel #1
0
             foreach ($ps as $orphan) {
                 $markers[] = '?';
                 $data[] = $orphan;
             }
             $db->run('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . implode(',', $markers) . ')', $data);
         }
         $data = array(':id' => $cat_to_delete);
         // Delete the category
         $db->delete('categories', 'id=:id', $data);
         // Regenerate the quick jump cache
         if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
             require PANTHER_ROOT . 'include/cache.php';
         }
         generate_forums_cache();
         generate_quickjump_cache();
         generate_perms_cache();
         redirect(panther_link($panther_url['admin_categories']), $lang_admin_categories['Category deleted redirect']);
     } else {
         $data = array(':id' => $cat_to_delete);
         $ps = $db->select('categories', 'cat_name', $data, 'id=:id');
         $cat_name = $ps->fetchColumn();
         $page_title = array($panther_config['o_board_title'], $lang_admin_common['Admin'], $lang_admin_common['Categories']);
         define('PANTHER_ACTIVE_PAGE', 'admin');
         require PANTHER_ROOT . 'header.php';
         generate_admin_menu('categories');
         $tpl = load_template('delete_category.tpl');
         echo $tpl->render(array('lang_admin_categories' => $lang_admin_categories, 'lang_admin_common' => $lang_admin_common, 'form_action' => panther_link($panther_url['admin_categories']), 'csrf_token' => generate_csrf_token(PANTHER_ADMIN_DIR . '/categories.php'), 'cat_name' => $cat_name, 'cat_to_delete' => $cat_to_delete));
         require PANTHER_ROOT . 'footer.php';
     }
 } else {
     if (isset($_POST['update'])) {
Beispiel #2
0
function generate_user_location($url)
{
    global $db, $panther_user, $lang_online, $panther_url;
    static $perms;
    if (!defined('PANTHER_FP_LOADED')) {
        $perms = array();
        if (file_exists(FORUM_CACHE_DIR . 'cache_perms.php')) {
            require FORUM_CACHE_DIR . 'cache_perms.php';
        } else {
            if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
                require PANTHER_ROOT . 'include/cache.php';
            }
            generate_perms_cache();
            require FORUM_CACHE_DIR . 'cache_perms.php';
        }
    }
    switch ($url) {
        case null:
            $location = $lang_online['bot'];
            break;
        case 'index.php':
            $location = $lang_online['viewing index'];
            break;
        case stristr($url, 'userlist.php'):
            $location = $lang_online['viewing userlist'];
            break;
        case 'online.php':
            $location = $lang_online['viewing online'];
            break;
        case 'misc.php?action=rules':
            $location = $lang_online['viewing rules'];
            break;
        case stristr($url, 'search'):
            $location = $lang_online['searching'];
            break;
        case stristr($url, 'help'):
            $location = $lang_online['bbcode help'];
            break;
        case stristr($url, 'profile'):
            $id = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $id);
            $ps = $db->select('users', 'username, group_id', $data, 'id=:id');
            $user = $ps->fetch();
            $username = colourize_group($user['username'], $user['group_id'], $id);
            $location = sprintf($lang_online['viewing profile'], $username);
            break;
        case stristr($url, 'pms_'):
            $location = $lang_online['private messaging'];
            break;
        case stristr($url, 'admin'):
            $location = $lang_online['administration'];
            break;
        case stristr($url, 'login'):
            $location = $lang_online['login'];
            break;
        case stristr($url, 'viewforum.php'):
            if (strpos($url, '&p=') !== false) {
                preg_match('~&p=(.*)~', $url, $replace);
                $url = str_replace($replace[0], '', $url);
            }
            $id = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $id);
            $ps = $db->select('forums', 'forum_name', $data, 'id=:id');
            $forum_name = $ps->fetchColumn();
            if (!isset($perms[$panther_user['g_id'] . '_' . $id])) {
                $perms[$panther_user['g_id'] . '_' . $id] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $id]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $id]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['forum'], array($id, url_friendly($forum_name))), 'name' => $forum_name, 'lang' => $lang_online['viewing forum']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'viewtopic.php?pid'):
            //Now for the nasty part =)
            $pid = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $pid);
            $ps = $db->run('SELECT t.subject, t.forum_id AS fid FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON p.topic_id=t.id WHERE p.id=:id', $data);
            $info = $ps->fetch();
            if (!isset($perms[$panther_user['g_id'] . '_' . $info['fid']])) {
                $perms[$panther_user['g_id'] . '_' . $info['fid']] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['post'], array($pid)), 'name' => $info['subject'], 'lang' => $lang_online['viewing topic']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'viewtopic.php?id'):
            if (strpos($url, '&p=') !== false) {
                preg_match('~&p=(.*)~', $url, $replace);
                $url = str_replace($replace[0], '', $url);
            }
            $id = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $id);
            $ps = $db->select('topics', 'subject, forum_id AS fid', $data, 'id=:id');
            $info = $ps->fetch();
            if (!isset($perms[$panther_user['g_id'] . '_' . $info['fid']])) {
                $perms[$panther_user['g_id'] . '_' . $info['fid']] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['topic'], array($id, url_friendly($info['subject']))), 'name' => $info['subject'], 'lang' => $lang_online['viewing topic']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'post.php?action=post'):
            $location = $lang_online['posting'];
            break;
        case stristr($url, 'post.php?fid'):
            $fid = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $fid);
            $ps = $db->select('forums', 'forum_name', $data, 'id=:id');
            $forum_name = $ps->fetchColumn();
            if (!isset($perms[$panther_user['g_id'] . '_' . $fid])) {
                $perms[$panther_user['g_id'] . '_' . $fid] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $fid]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $fid]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['forum'], array($fid, url_friendly($forum_name))), 'lang' => $forum_name, 'lang' => $lang_online['posting topic']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'post.php?tid'):
            $tid = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $tid);
            $ps = $db->select('topics', 'subject, forum_id AS fid', $data, 'id=:id');
            $info = $ps->fetch();
            if (!isset($perms[$panther_user['g_id'] . '_' . $info['fid']])) {
                $perms[$panther_user['g_id'] . '_' . $info['fid']] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['topic'], array($tid, url_friendly($info['subject']))), 'name' => $info['subject'], 'lang' => $lang_online['replying to topic']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'edit.php?id'):
            $id = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $id);
            $ps = $db->run('SELECT t.subject, t.forum_id AS fid FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON p.topic_id=t.id WHERE p.id=:id', $data);
            $info = $ps->fetch();
            if (!isset($perms[$panther_user['g_id'] . '_' . $info['fid']])) {
                $perms[$panther_user['g_id'] . '_' . $info['fid']] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['post'], array($id)), 'name' => $info['subject'], 'lang' => $lang_online['editing topic']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'delete.php?id'):
            $id = filter_var($url, FILTER_SANITIZE_NUMBER_INT);
            $data = array(':id' => $id);
            $ps = $db->run('SELECT t.subject, t.forum_id AS fid FROM ' . $db->prefix . 'posts AS p INNER JOIN ' . $db->prefix . 'topics AS t ON p.topic_id=t.id WHERE p.id=:id', $data);
            $info = $ps->fetch();
            if (!isset($perms[$panther_user['g_id'] . '_' . $info['fid']])) {
                $perms[$panther_user['g_id'] . '_' . $info['fid']] = $perms['_'];
            }
            if ($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'] == '1' || is_null($perms[$panther_user['g_id'] . '_' . $info['fid']]['read_forum'])) {
                $location = array('href' => panther_link($panther_url['post'], array($id)), 'name' => $info['subject'], 'lang' => $lang_online['deleting post']);
            } else {
                $location = $lang_online['in hidden forum'];
            }
            break;
        case stristr($url, 'moderate.php'):
            $location = $lang_online['moderating'];
            break;
        case stristr($url, 'register.php'):
            $location = $lang_online['register'];
            break;
        case stristr($url, 'misc.php?action=leaders'):
            $location = $lang_online['viewing team'];
            break;
        case '-':
            $location = $lang_online['not online'];
            break;
        default:
            $location = $url;
            break;
    }
    return $location;
}