コード例 #1
0
ファイル: rss2.php プロジェクト: brainsqueezer/fffff
     $from_where = "FROM links WHERE link_status in  ('published', 'queued') AND link_date > date_sub(now(), interval 7 day) ";
 } else {
     $from_where = "FROM links WHERE link_status='{$status}' AND link_date > date_sub(now(), interval 7 day) ";
 }
 // Check if it's search
 if ($_REQUEST['q']) {
     if ($search) {
         $from_where = "FROM links WHERE {$search} ";
     } else {
         $from_where .= "AND false";
         // Force to return empty set
     }
     $title = _('Menéame') . ": " . htmlspecialchars(strip_tags($_REQUEST['q']));
 }
 if ($meta = check_integer('meta')) {
     $cat_list = meta_get_categories_list($meta);
     if (!$cat_list) {
         not_found();
     }
     $from_where .= " AND link_category in ({$cat_list})";
     $meta_name = $db->get_var("SELECT category_name FROM categories WHERE category_id = {$meta} AND category_parent=0");
     $title .= " -{$meta_name}-";
 } elseif ($cat = check_integer('category')) {
     $from_where .= " AND link_category={$cat} ";
     $category_name = $db->get_var("SELECT category_name FROM categories WHERE category_id = {$cat} AND category_lang='{$dblang}'");
     $title .= " -{$category_name}-";
 } elseif ($uid = check_integer('personal')) {
     $categories = $db->get_col("SELECT pref_value FROM prefs WHERE pref_user_id = {$uid} and pref_key = 'category' ");
     $user_login = $db->get_var("select user_login from users where user_id={$uid}");
     $title .= " -{$user_login}-";
     if ($categories) {
コード例 #2
0
ファイル: utils.php プロジェクト: brainsqueezer/fffff
function meta_get_current()
{
    global $globals, $db, $current_user;
    $globals['meta_current'] = 0;
    $globals['meta'] = clean_input_string($_REQUEST['meta']);
    //Check for personalisation
    // Authenticated users
    if ($current_user->user_id > 0) {
        $categories = $db->get_col("SELECT pref_value FROM prefs WHERE pref_user_id = {$current_user->user_id} and pref_key = 'category' order by pref_value");
        if ($categories) {
            $current_user->has_personal = true;
            $globals['meta_skip'] = '?meta=_all';
            if (!$globals['meta']) {
                $globals['meta_categories'] = implode(',', $categories);
                $globals['meta'] = '_personal';
            }
        } else {
            $globals['meta_categories'] = false;
        }
    } elseif ($_COOKIE['mnm_user_meta']) {
        // anonymous users
        $meta = $db->escape(clean_input_string($_COOKIE['mnm_user_meta']));
        $globals['meta_skip'] = '?meta=_all';
        $globals['meta_user_default'] = $db->get_var("select category_id from categories where category_uri = '{$meta}' and category_parent = 0");
        // Anonymous can select metas by cookie
        // Select user default only if no category has been selected
        if (!$_REQUEST['category'] && !$globals['meta']) {
            $globals['meta_current'] = $globals['meta_user_default'];
        }
    }
    if ($_REQUEST['category']) {
        $_REQUEST['category'] = $cat = (int) $_REQUEST['category'];
        if ($globals['meta'][0] == '_') {
            $globals['meta_current'] = $globals['meta'];
        } else {
            $globals['meta_current'] = (int) $db->get_var("select category_parent from categories where category_id = {$cat} and category_parent > 0");
            $globals['meta'] = '';
        }
    } elseif ($globals['meta']) {
        // Special metas begin with _
        if ($globals['meta'][0] == '_') {
            return 0;
        }
        $meta = $db->escape($globals['meta']);
        $globals['meta_current'] = $db->get_var("select category_id from categories where category_uri = '{$meta}' and category_parent = 0");
        if ($globals['meta_current']) {
            $globals['meta'] = '';
            // Security measure
        }
    }
    if ($globals['meta_current'] > 0) {
        $globals['meta_categories'] = meta_get_categories_list($globals['meta_current']);
        if (!$globals['meta_categories']) {
            $globals['meta_current'] = 0;
        }
    }
    //echo "meta_current: " . $globals['meta_current'] . "<br/>\n";
    return $globals['meta_current'];
}