Beispiel #1
0
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'cm.id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(cm.id IN (' . $condition . '))');
             break;
         case 'cm.article_id':
             $this->_query->add_where('(cm.article_id = \'' . $condition . '\')');
             break;
         case 'cm.user_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('cm.user_id IN (' . $condition . ')');
             break;
         case 'cm.description':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_where('(cm.description LIKE \'%' . $condition . '%\')');
             break;
         case 'cm.create_dt':
             $this->_query->add_where('(cm.create_dt = \'' . $condition . '\')');
             break;
         case 'cm.author':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_where('(cm.author LIKE \'%' . $condition . '%\')');
             break;
         case 'cm.author_name':
             $this->_query->add_where("cm.author = '{$condition}'");
             break;
         case 'cm.email':
             $condition = str_replace('%', '\\%', $condition);
             $condition = str_replace('*', '%', $condition);
             $condition = str_replace('?', '_', $condition);
             $this->_query->add_where('(cm.email LIKE \'' . $condition . '\')');
             break;
         case 'cm.email_exact':
             $this->_query->add_where('(cm.email = \'' . $condition . '\')');
             break;
         case 'cm.ip':
             $condition = str_replace('%', '\\%', $condition);
             $condition = str_replace('*', '%', $condition);
             $condition = str_replace('?', '_', $condition);
             $this->_query->add_where('(cm.ip LIKE \'' . $condition . '\')');
             break;
         case 'cm.status':
             $this->_query->add_where('(cm.status = \'' . $condition . '\')');
             break;
         case 'cm.created_before':
             $this->_query->add_where('(cm.create_dt < (DATE_SUB(NOW(), INTERVAL ' . $condition . '  DAY)))');
             break;
         case 'cm.created_after':
             $this->_query->add_where('(cm.create_dt > (DATE_SUB(NOW(), INTERVAL ' . $condition . '  DAY)))');
             break;
         case 'cm.vote':
             $this->_query->add_where('(cm.vote = \'' . $condition . '\')');
             break;
         case 'cm.reply_to':
             if ($condition == 0) {
                 $this->_query->add_where('cm.reply_to IS NULL');
             } else {
                 $condition = secure_sql_in($condition);
                 $this->_query->add_where("cm.reply_to IN ({$condition})");
             }
             break;
         case 'cm.not_reply_to':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("cm.reply_to NOT IN ({$condition})");
             break;
         case 'cm.root_comment':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("cm.root_comment IN ({$condition})");
             break;
     }
 }
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'name':
         case 'url':
         case 'template':
         case 'tag_template':
             $this->_query->add_where("(tg.{$type} = '{$condition}')");
             break;
         case 'not_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(tg.id NOT IN ({$condition}))");
             break;
         case 'starting_with':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_where("(tg.name LIKE '{$condition}%')");
             break;
         case 'tag_id':
             $condition = secure_sql_in($condition);
             $this->_query->set_from(VIVVO_DB_PREFIX . $this->_sql_table . ' AS tg, ' . VIVVO_DB_PREFIX . 'tags_to_tags_groups AS ttg');
             $this->_query->add_where("ttg.tag_id IN ({$condition}) AND ttg.tags_group_id = tg.id");
             break;
         case 'category_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tags_group_id = tg.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles AS a ON a.id = at.article_id ', 'a');
             $this->_query->add_where("a.category_id IN ({$condition})");
             break;
         case 'article_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tags_group_id = tg.id ', 'at');
             $this->_query->add_where("at.article_id IN ({$condition})");
             break;
         case 'id':
         default:
             $condition = secure_sql_in($condition);
             $this->_query->add_where("tg.id IN ({$condition})");
             break;
     }
 }
 function get_hrefs($ids)
 {
     $hrefs = array();
     if (is_array($ids)) {
         $ids = implode(',', $ids);
     }
     $sm = vivvo_lite_site::get_instance();
     $sql = 'SELECT id, category_name FROM ' . VIVVO_DB_PREFIX . $this->_sql_table . ' WHERE id IN (' . secure_sql_in($ids) . ')';
     $res = $sm->get_db()->query($sql);
     if (!PEAR::isError($res)) {
         while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $hrefs[$row['id']] = array();
             $hrefs[$row['id']]['title'] = $row['category_name'];
             $hrefs[$row['id']]['href'] = Categories::format_href($sm, $row['id']);
         }
     }
     return $hrefs;
 }
 /**
  * adds filter to sql query
  *
  * @param	string	$type
  * @param	string	$condition
  */
 public function add_filter($type, $condition = '')
 {
     switch ($type) {
         case 'id':
         case 'article_id':
         case 'duration':
         case 'year':
             $condition = (int) $condition;
             $this->_query->add_where("{$type} = {$condition}");
             break;
         case 'minute':
         case 'hour':
         case 'dom':
         case 'month':
         case 'dow':
             $condition = ArticlesSchedule::getHexMask($condition, $type);
             $this->_query->add_where("{$type} & {$condition}");
             break;
         case 'id_in':
         case 'article_id_in':
         case 'duration_in':
         case 'year_in':
             $condition = secure_sql_in($condition);
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} IN ({$condition})");
             break;
         case 'id_not_in':
         case 'article_id_not_in':
         case 'duration_not_in':
         case 'year_not_in':
             $condition = secure_sql_in($condition);
             $type = substr($type, 0, -7);
             $this->_query->add_where("{$type} NOT IN ({$condition})");
             break;
         case 'duration_lt':
         case 'year_lt':
             $condition = (int) $condition;
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} < {$condition}");
             break;
         case 'duration_lte':
         case 'year_lte':
             $condition = (int) $condition;
             $type = substr($type, 0, -4);
             $this->_query->add_where("{$type} <= {$condition}");
             break;
         case 'duration_gt':
         case 'year_gt':
             $condition = (int) $condition;
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} > {$condition}");
             break;
         case 'duration_gte':
         case 'year_gte':
             $condition = (int) $condition;
             $type = substr($type, 0, -4);
             $this->_query->add_where("{$type} >= {$condition}");
             break;
     }
 }
Beispiel #5
0
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'id':
         case 'name':
         case 'sefriendly':
             $this->_query->add_where("t.{$type} = '{$condition}'");
             break;
         case 'name_like':
             $condition = str_replace(array('%', '_'), array('\\%', '\\_'), $condition);
             $this->_query->add_where("t.name LIKE '%{$condition}%'");
             break;
         case 'article_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_where("at.article_id IN ({$condition})");
             break;
         case 'tags_group_id':
         case 'topic_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'tags_to_tags_groups AS ttg ON ttg.tag_id = t.id ', 'ttg');
             $this->_query->add_where("ttg.tags_group_id IN ({$condition})");
             break;
         case 'not_tags_group_id':
         case 'not_topic_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'tags_to_tags_groups AS ttg ON ttg.tag_id = t.id ', 'ttg');
             $this->_query->add_where("ttg.tags_group_id NOT IN ({$condition})");
             break;
         case 'user_tag_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_where("at.tags_group_id IN ({$condition})");
             break;
         case 'not_user_tag_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_where("at.tags_group_id NOT IN ({$condition})");
             break;
         case 'id_in':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("t.id IN ({$condition})");
             break;
         case 'name_array':
         case 'sefriendly_array':
             foreach ($condition as &$item) {
                 $item = "'{$item}'";
             }
             unset($item);
             $condition = implode(',', $condition);
             $type = str_replace('_array', '', $type);
             $this->_query->add_where("t.{$type} IN ({$condition})");
             break;
         case 'search_starting_with':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_where("t.name LIKE '%{$condition}%'");
             break;
         case 'search_label_starting_with':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'tags_to_tags_groups AS tg ON tg.tag_id = t.id ', 'tg');
             $this->_query->add_where("t.name LIKE '%{$condition}%'");
             break;
         case 'user_group_id':
             $condition = secure_sql_in(explode(',', $condition));
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'group_user AS gu ON gu.user_id = at.user_id', 'gu');
             $this->_query->add_where("gu.group_id IN ({$condition})");
             break;
         case 'not_user_group_id':
             $condition = secure_sql_in(explode(',', $condition));
             $this->_query->add_fields('at.tags_group_id AS topic_id');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'group_user AS gu ON gu.user_id = at.user_id', 'gu');
             $this->_query->add_where("gu.group_id NOT IN ({$condition})");
             break;
         case 'article_status':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.tag_id = t.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles AS a ON at.article_id = a.id ', 'a');
             $this->_query->add_where("a.status IN ({$condition})");
             break;
         default:
     }
 }
Beispiel #6
0
 /**
  * Adds filter to the WHERE clause of the query
  *
  * @param	string	$type
  * @param	mixed	$condition
  */
 public function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'not_id':
         case 'not_category':
         case 'not_count':
             $flag = true;
             $type = substr($type, 4);
         case 'id':
         case 'category_id':
         case 'count':
             $condition = secure_sql_in($condition);
             $operator = ($flag ? 'NOT ' : '') . 'IN';
             $this->_query->add_where("fd.{$type} {$operator} ({$condition})");
             break;
         case 'not_feed':
         case 'not_author':
             $flag = true;
             $type = substr($type, 4);
         case 'feed':
         case 'author':
             $condition = secure_sql_in($condition, true);
             $operator = ($flag ? 'NOT ' : '') . 'IN';
             $this->_query->add_where("fd.{$type} {$operator} ({$condition})");
             break;
         default:
             // ignore
     }
 }
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'id':
         case 'article_id':
         case 'user_id':
         case 'tag_id':
         case 'tags_group_id':
             $this->_query->add_where("(at.{$type} = '{$condition}')");
             break;
         case 'not_in_groups':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(at.tags_group_id NOT IN ({$condition}))");
             break;
         case 'not_in_tags':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(at.tag_id NOT IN ({$condition}))");
             break;
         default:
             $this->_query->add_where("(at.id = '{$condition}')");
             break;
     }
 }
Beispiel #8
0
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(id IN (' . $condition . '))');
             break;
         case 'notid':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(id NOT IN (' . $condition . '))');
             break;
         case 'title':
             $this->_query->add_where('(title = \'' . $condition . '\')');
             break;
         case 'body':
             $this->_query->add_where('(body = \'' . $condition . '\')');
             break;
         case 'hide':
             $this->_query->add_where('(hide = \'' . $condition . '\')');
             break;
         case 'sefriendly':
             $this->_query->add_where('(sefriendly = \'' . $condition . '\')');
             break;
         case 'template':
             $this->_query->add_where('(template = \'' . $condition . '\')');
             break;
         case 'order_number':
             $this->_query->add_where('(order_number = \'' . $condition . '\')');
             break;
     }
 }
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'id':
             $this->_query->add_where('(id = \'' . $condition . '\')');
             break;
         case 'group_id':
             $this->_query->add_where('(group_id = \'' . $condition . '\')');
             break;
         case 'group_id_in':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(group_id IN (' . $condition . '))');
             break;
         case 'user_source':
             $this->_query->add_where('(user_source = \'' . $condition . '\')');
             break;
         case 'privileges':
             $this->_query->add_where('(privileges = \'' . $condition . '\')');
             break;
     }
 }
 function generic_add_filter($params, $prefix = '')
 {
     if (is_array($params) && !empty($params)) {
         $keys = array_keys($params);
         foreach ($keys as $k) {
             if (preg_match('/^search_field_(.*)_(lt|gt|eq|neq|in|notin|between|notnull|isnull)$/', $k, $arr)) {
                 $condition = secure_sql($params[$k]);
                 switch ($arr[2]) {
                     case 'lt':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' < \'' . $condition . '\')');
                         break;
                     case 'gt':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' > \'' . $condition . '\')');
                         break;
                     case 'eq':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' = \'' . $condition . '\')');
                         break;
                     case 'neq':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' != \'' . $condition . '\')');
                         break;
                     case 'in':
                         $condition = secure_sql_in($condition);
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' IN ' . $condition . ')');
                         break;
                     case 'notin':
                         $condition = secure_sql_in($condition);
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' NOT IN ' . $condition . ')');
                         break;
                     case 'notnull':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' IS NOT NULL )');
                         break;
                     case 'isnull':
                         $this->_query->add_where('(' . $prefix . $arr[1] . ' IS NULL )');
                         break;
                     case 'between':
                         $between = explode(',', $condition);
                         if (is_array($between) && count($between) == 2) {
                             $this->_query->add_where('(' . $prefix . $arr[1] . ' BETWEEN \'' . $between[0] . '\' AND \'' . $between[1] . '\')');
                         }
                         break;
                 }
             }
         }
     }
 }
 function add_filter($type, $cond = '')
 {
     $condition = secure_sql($cond);
     switch ($type) {
         case 'id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(t.id IN (' . $condition . '))');
             break;
         case 'notid':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(t.id NOT IN (' . $condition . '))');
             break;
         case 'type':
             $this->_query->add_where("(t.type='{$condition}')");
             break;
         case 'ext':
             $this->_query->add_where("(t.extensions LIKE '%{$condition}%')");
             break;
     }
 }
 /**
  * Adds filter to the WHERE clause of the query
  *
  * @param	string	$type
  * @param	mixed	$condition
  */
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     $flag = false;
     switch ($type) {
         case 'not_id':
         case 'not_article_id':
         case 'not_version':
         case 'not_creator_id':
         case 'not_type':
             $flag = true;
             $type = substr($type, 4);
         case 'id':
         case 'article_id':
         case 'version':
         case 'creator_id':
         case 'type':
             $condition = secure_sql_in($condition);
             $operator = ($flag ? 'NOT ' : '') . 'IN';
             $this->_query->add_where("ar.{$type} {$operator} ({$condition})");
             break;
         case 'title_matches':
             $this->_query->add_where("ar.title LIKE '%{$condition}%'");
             break;
         case 'title':
             $this->_query->add_where("ar.title = '{$condition}'");
             break;
         case 'not_created_time':
             $flag = true;
         case 'created_time':
             $condition = (int) $condition;
             $operator = $flag ? '!=' : '=';
             $this->_query->add_where("ar.created_time {$operator} {$condition}");
             break;
         case 'created_time_lte':
         case 'created_time_gte':
             $flag = true;
         case 'created_time_lt':
         case 'created_time_gt':
             $condition = (int) $condition;
             $operator = ($type[13] == 'g' ? '>' : '<') . ($flag ? '=' : '');
             $this->_query->add_where("ar.created_time {$operator} {$condition}");
             break;
         default:
             // ignore
     }
 }
Beispiel #13
0
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'userid':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(u.userid IN (' . $condition . '))');
             break;
         case 'first_name':
             $this->_query->add_where('(u.first_name = \'' . $condition . '\')');
             break;
         case 'last_name':
             $this->_query->add_where('(u.last_name = \'' . $condition . '\')');
             break;
         case 'name':
             $condition = str_replace('%', '\\%', $condition);
             $this->_query->add_where('(u.last_name LIKE \'%' . $condition . '%\') OR (u.first_name LIKE \'%' . $condition . '%\') OR (u.username LIKE \'%' . $condition . '%\')');
             break;
         case 'email_address':
             $this->_query->add_where('(u.email_address = \'' . $condition . '\')');
             break;
         case 'username':
             $this->_query->add_where('(u.username = \'' . $condition . '\')');
             break;
         case 'password':
             $this->_query->add_where('(u.password = \'' . $condition . '\')');
             break;
         case 'session_id':
             $this->_query->add_where("u.session_id = '{$condition}'");
             break;
         case 'user_hash':
             $this->_query->add_where("MD5(u.session_id) = '{$condition}'");
             break;
         case 'activated':
             $this->_query->add_where('(u.activated = \'' . $condition . '\')');
             break;
         case 'group':
             $condition = secure_sql_in($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'group_user AS gu ON gu.user_id = u.userid ', 'gu');
             $this->_query->add_where('(gu.group_id IN (' . $condition . '))');
             $this->_query->add_group_by('u.userid');
             break;
         case 'concat_first_last':
             $this->_query->add_where('CONCAT(u.first_name, "-", u.last_name ) = \'' . $condition . '\'');
             break;
         case 'created_before':
             $this->_query->add_where('(u.created < (DATE_SUB(NOW(), INTERVAL ' . $condition . '  DAY)))');
             break;
         case 'created_after':
             $this->_query->add_where('(u.created > (DATE_SUB(NOW(), INTERVAL ' . $condition . '  DAY)))');
             break;
         case 'md5':
             $this->_query->add_where("md5(concat( u.`email_address` , u.`username` , u.`created` ) ) = '{$condition}'");
             break;
         case 'forgot':
             $this->_query->add_where("md5( concat( u.`username` , u.`email_address`, u.`password` ) ) = '{$condition}'");
             break;
     }
 }
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'id':
         case 'tag_id':
         case 'tags_group_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("({$type} IN ({$condition}))");
             break;
         case 'not_id':
             $this->_query->add_where("(id<>'{$condition}')");
             break;
         default:
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(id IN ({$condition}))");
             break;
     }
 }
 function _list_output()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $content_template = $this->load_template($this->_template_root . 'list.xml');
     if (!$sm->user->is_admin()) {
         $editor_restriction = $sm->user->get_privilege_object_ids('WRITE', 'Categories');
         if (!in_array('0', $editor_restriction)) {
             if (isset($sm->article_list_params['search_options']['search_cid'])) {
                 if (!is_array($sm->article_list_params['search_options']['search_cid'])) {
                     $sm->article_list_params['search_options']['search_cid'] = explode(',', $sm->article_list_params['search_options']['search_cid']);
                 }
                 $sm->article_list_params['search_options']['search_cid'] = array_intersect($editor_restriction, $sm->article_list_params['search_options']['search_cid']);
             }
             if (empty($sm->article_list_params['search_options']['search_cid'])) {
                 $sm->article_list_params['search_options']['search_cid'] = $editor_restriction;
             }
             if ($um->isset_param('search_category_id')) {
                 $search_cid = array_intersect(explode(',', $um->get_param('search_category_id')), $sm->article_list_params['search_options']['search_cid']);
             }
         }
     }
     if (!$search_cid and $um->isset_param('search_category_id')) {
         $search_cid = explode(',', $um->get_param('search_category_id'));
     }
     if ($search_cid) {
         $sm->article_list_params['search_options']['search_cid'] = $search_cid;
         $content_template->assign('search_category_id', secure_sql_in($search_cid));
     }
     foreach (array('search_tag_id', 'search_topic_id', 'search_author', 'search_user_id') as $filter) {
         if ($um->isset_param($filter)) {
             $sm->article_list_params[$filter] = $um->get_param($filter);
             $content_template->assign($filter, $um->get_param($filter));
         }
     }
     $content_template->assign('search_limit', $sm->article_list_params['search_limit']);
     $content_template->assign('search_sort_by', strval($sm->article_list_params['search_sort_by'] . '.' . $sm->article_list_params['search_order']));
     if ($sm->article_list_params['search_options']['search_tag'] != '') {
         $content_template->assign('disable_all', intval(1));
     }
     $content_template->assign('list_output', intval(1));
     $content_template->assign('content_params', $sm->article_list_params);
     class_exists('TagsGroups') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php');
     $topic = TagsGroups_list::factory()->get_group_by_id(0);
     $content_template->assign('default_topic', $topic);
     return $content_template;
 }
 function add_filter($type, $cond = '')
 {
     $condition = secure_sql($cond);
     switch ($type) {
         case 'id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(f.id IN (' . $condition . '))');
             break;
         case 'notid':
             $condition = secure_sql_in($condition);
             $this->_query->add_where('(f.id NOT IN (' . $condition . '))');
             break;
         case 'name':
             $this->_query->add_where("(f.name='{$condition}')");
             break;
         case 'name_starts_with':
             $this->_query->add_where("(f.name LIKE '{$condition}%')");
             break;
         case 'name_wildcard':
             $this->_query->add_where("(f.name LIKE '%{$condition}%')");
             break;
         case 'ext':
             $ext = join("','", explode(',', $condition));
             $this->_query->add_where("(f.extension IN ('{$ext}'))");
             break;
         case 'path':
             $cond = rtrim($cond, '/') . '/';
             //make sure one and just one / at the end
             $this->_query->add_where("(f.path_md5='" . md5($cond) . "')");
             break;
         case 'under_path':
             $this->_query->add_where("(f.path LIKE '{$condition}%')");
             break;
         case 'type_id':
             $this->_query->add_where("(f.filetype_id='{$condition}')");
             break;
         case 'not_type_id':
             $condition = (int) $condition;
             $this->_query->add_where("(f.filetype_id != {$condition})");
             break;
         case 'type':
             $this->_query->add_where("(t.type='{$condition}')");
             break;
         case 'date_after':
             $this->_query->add_where("(f.mtime > '{$condition}')");
             break;
         case 'info':
             $this->_query->add_where("(MATCH (f.info) AGAINST ('{$condition}' IN BOOLEAN MODE))");
             break;
     }
 }
Beispiel #17
0
 function add_filter($type, $condition = '')
 {
     $condition = secure_sql($condition);
     switch ($type) {
         case 'a.id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("a.id IN ({$condition})");
             break;
         case '!a.id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("a.id NOT IN ({$condition})");
             break;
         case 'a.category_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("a.category_id IN ({$condition})");
             break;
         case '!a.category_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("a.category_id NOT IN ({$condition})");
             break;
         case 'a.user_id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("a.user_id IN ({$condition})");
             $this->_query->add_where("a.user_domain = '" . VIVVO_USER_SOURCE . "'");
             break;
         case 'a.user_domain':
             $this->_query->add_where("a.user_domain = '{$condition}'");
             break;
         case 'a.author_exact_name':
             $this->_query->add_where("a.author = '{$condition}'");
             break;
         case 'a.author':
             $condition = escape_sql_like($condition);
             $this->_query->add_where("a.author LIKE '%{$condition}%'");
             break;
         case 'a.title':
             $condition = escape_sql_like($condition);
             $this->_query->add_where("a.title LIKE '%{$condition}%'");
             break;
         case 'a.image':
             $this->_query->add_where("a.image = '{$condition}'");
             break;
         case 'a.created_month':
             $this->_query->add_where("MONTH(a.created) = '{$condition}'");
             break;
         case 'a.created_year':
             $this->_query->add_where("YEAR(a.created) = '{$condition}'");
             break;
         case 'a.created_day':
             $this->_query->add_where("DAY(a.created) = '{$condition}'");
             break;
         case 'a.created_before':
             $current_time = date('Y-m-d H:i:00', VIVVO_START_TIME);
             $this->_query->add_where("a.created < (DATE_SUB('{$current_time}', INTERVAL {$condition}  DAY))");
             break;
         case 'a.created_after':
             $current_time = date('Y-m-d H:i:00', VIVVO_START_TIME);
             $this->_query->add_where("a.created > (DATE_SUB('{$current_time}', INTERVAL {$condition} DAY))");
             break;
         case 'a.created_filter':
             $current_time = date('Y-m-d H:i:00', VIVVO_START_TIME);
             $this->_query->add_where("a.created < '{$current_time}'");
             break;
         case 'a.body':
             $this->_query->add_where("MATCH (title,body,abstract) AGAINST ('{$condition}' IN BOOLEAN MODE)");
             break;
         case 'a.last_read':
             $this->_query->add_where("a.last_read = '{$condition}'");
             break;
         case 'a.times_read':
             $this->_query->add_where("a.times_read = '{$condition}'");
             break;
         case 'a.today_read':
             $this->_query->add_where("a.today_read = '{$condition}'");
             break;
         case 'a.status':
             $this->_query->add_where("a.status = '{$condition}'");
             break;
         case 'a.not_status':
             $this->_query->add_where("a.status != '{$condition}'");
             break;
         case 'a.status_limit':
             $this->_query->add_where('a.status > 0');
             break;
         case 'a.sefriendly':
             $this->_query->add_where("a.sefriendly = '{$condition}'");
             break;
         case 'a.link':
             $this->_query->add_where("a.link = '{$condition}'");
             break;
         case 'a.order_num':
             $this->_query->add_where("a.order_num = '{$condition}'");
             break;
         case 'a.show_poll':
             $this->_query->add_where("a.show_poll = '{$condition}'");
             break;
         case 'a.rss_feed':
             $this->_query->add_where("a.rss_feed = '{$condition}'");
             break;
         case 'a.show_comment':
             $this->_query->add_where("a.show_comment = '{$condition}'");
             break;
         case 'a.keywords':
             $this->_query->add_where("a.keywords = '{$condition}'");
             break;
         case 'a.description':
             $this->_query->add_where("a.description = '{$condition}'");
             break;
         case 'a.emailed':
             $this->_query->add_where("a.emailed = '{$condition}'");
             break;
         case 'a.vote_num':
             $this->_query->add_where("a.vote_num = '{$condition}'");
             break;
         case 'a.vote_sum':
             $this->_query->add_where("a.vote_sum = '{$condition}'");
             break;
         case 'a.abstract':
             $this->_query->add_where("a.abstract = '{$condition}'");
             break;
         case 'related':
             $this->_query->add_join(' INNER JOIN ' . VIVVO_DB_PREFIX . 'related AS r ON r.related_article_id = a.id ', 'r');
             $this->_query->add_order('r.relevance DESC');
             $this->_query->add_where('r.article_id = ' . (int) $condition);
             break;
         case 'tag':
             $condition = secure_sql_in($condition, false);
             $this->_query->add_join(' INNER JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $this->_query->add_join(' INNER JOIN ' . VIVVO_DB_PREFIX . 'tags as t ON t.id = at.tag_id ', 't');
             $this->_query->add_where("t.name IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'tag_matches':
             $condition = escape_sql_like($condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'tags as t ON t.id = at.tag_id ', 't');
             $this->_query->add_where("t.name LIKE '%{$condition}%'");
             $this->_query->add_group_by('a.id');
             break;
         case 'tag_id':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $condition = secure_sql_in($condition);
             $this->_query->add_where("at.tag_id IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'all_tag_ids':
             is_array($condition) or $condition = explode(',', $condition);
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $value = (int) array_shift($condition);
             $this->_query->add_where("at.tag_id = {$value}");
             $this->_query->add_group_by('a.id');
             $tag_ids = array();
             foreach ($condition as $value) {
                 $tag_ids[] = (int) $value;
             }
             if (!empty($tag_ids)) {
                 $tag_ids = implode(',', $tag_ids);
                 $this->_query->add_where('a.id IN (SELECT article_id FROM ' . VIVVO_DB_PREFIX . "articles_tags WHERE tag_id IN ({$tag_ids}))");
             }
             break;
         case 'tags_group_id':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $condition = secure_sql_in($condition);
             $this->_query->add_where("at.tags_group_id IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'user_group_id':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'group_user AS gu ON at.user_id = gu.user_id ', 'gu');
             $condition = secure_sql_in($condition);
             $this->_query->add_where("gu.group_id IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'not_user_group_id':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'group_user AS gu ON at.user_id = gu.user_id ', 'gu');
             $condition = secure_sql_in($condition);
             $this->_query->add_where("gu.group_id NOT IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'tags_group_name':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_tags AS at ON at.article_id = a.id ', 'at');
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'tags_groups as tg ON at.tags_group_id = tg.id ', 'tg');
             $condition = explode(',', $condition);
             foreach ($condition as &$topic) {
                 $topic = "'" . secure_sql($topic) . "'";
             }
             unset($topic);
             $condition = implode(',', $condition);
             $this->_query->add_where("tg.name IN ({$condition})");
             $this->_query->add_group_by('a.id');
             break;
         case 'sc.id':
         case 'sc.duration':
         case 'sc.status':
         case 'sc.year':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = (int) $condition;
             $this->_query->add_where("{$type} = {$condition}");
             break;
         case 'sc.minute':
         case 'sc.hour':
         case 'sc.dom':
         case 'sc.month':
         case 'sc.dow':
             require_once VIVVO_FS_ROOT . 'lib/vivvo/core/ArticlesSchedule.class.php';
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = ArticlesSchedule::getHexMask($condition, substr($type, 3));
             $this->_query->add_where("{$type} & {$condition}");
             break;
         case 'sc.date':
             if (!is_array($condition)) {
                 $parts = explode(',', date('i,G,j,n,w,Y', $condition));
                 $condition = array('minute' => (int) $parts[0], 'hour' => $parts[1], 'dom' => $parts[2], 'month' => $parts[3], 'dow' => $parts[4] + 1, 'year' => $parts[5]);
             }
             require_once VIVVO_FS_ROOT . 'lib/vivvo/core/ArticlesSchedule.class.php';
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = ArticlesSchedule::getHexMask($condition);
             foreach ($condition as $name => $value) {
                 if ($name == 'year') {
                     $value = (int) $value;
                     $this->_query->add_where("sc.year = {$value}");
                 } else {
                     $this->_query->add_where("sc.{$name} & {$value}");
                 }
             }
             break;
         case 'sc.id_in':
         case 'sc.duration_in':
         case 'sc.year_in':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = secure_sql_in($condition);
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} IN ({$condition})");
             break;
         case 'sc.id_not_in':
         case 'sc.duration_not_in':
         case 'sc.year_not_in':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = secure_sql_in($condition);
             $type = substr($type, 0, -7);
             $this->_query->add_where("{$type} NOT IN ({$condition})");
             break;
         case 'sc.duration_lt':
         case 'sc.year_lt':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = (int) $condition;
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} < {$condition}");
             break;
         case 'sc.duration_lte':
         case 'sc.year_lte':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = (int) $condition;
             $type = substr($type, 0, -4);
             $this->_query->add_where("{$type} <= {$condition}");
             break;
         case 'sc.duration_gt':
         case 'sc.year_lg':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = (int) $condition;
             $type = substr($type, 0, -3);
             $this->_query->add_where("{$type} > {$condition}");
             break;
         case 'sc.duration_gte':
         case 'sc.year_gte':
             $this->_query->add_join(' LEFT JOIN ' . VIVVO_DB_PREFIX . 'articles_schedule AS sc ON sc.article_id = a.id ', 'sc');
             $condition = (int) $condition;
             $type = substr($type, 0, -4);
             $this->_query->add_where("{$type} >= {$condition}");
             break;
     }
 }
 function add_filter($type, $cond = '')
 {
     $condition = secure_sql($cond);
     switch ($type) {
         case 'id':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(k.id IN ({$condition}))");
             break;
         case 'notid':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(k.id NOT IN ({$condition}))");
             break;
         case 'asset_id':
             $this->_query->add_where("(k.asset_id='{$condition}')");
             break;
         case 'asset_id_list':
             $condition = secure_sql_in($condition);
             $this->_query->add_where("(k.asset_id IN ({$condition}))");
             break;
         case 'keyword':
             $this->_query->add_where("(k.keyword='{$condition}')");
             break;
         case 'keyword_starts_with':
             $this->_query->add_where("(k.keyword LIKE '{$condition}%')");
             break;
         case 'fulltext':
             $this->_query->add_where("MATCH (k.keyword) AGAINST ('{$condition}' IN BOOLEAN MODE)");
             break;
         case 'like':
             $condition = escape_sql_like($condition);
             $this->_query->add_where("k.keyword LIKE '%{$condition}%'");
     }
 }