コード例 #1
0
function get_basic_user_details($uid)
{
    $uid = mysql_clean($uid);
    $fields = get_user_fields();
    $fields = tbl_fields($fields, 'users');
    $query = " SELECT " . $fields . " FROM " . tbl('users');
    $query .= " WHERE userid='" . $uid . "' ";
    $query .= " LIMIT 1";
    $results = db_select($query);
    if ($results) {
        return $results[0];
    }
}
コード例 #2
0
ファイル: video.class.php プロジェクト: yukisky/clipbucket
 /**
  * Function used to get videos
  * this function has all options
  * that you need to fetch videos
  * please see docs.clip-bucket.com for more details
  */
 function get_videos($params)
 {
     global $db;
     $limit = $params['limit'];
     $order = $params['order'];
     $cond = "";
     $superCond = "";
     if (!has_access('admin_access', TRUE)) {
         $params['admin_access'] = false;
         $superCond = $cond .= " " . "video.status" . "='Successful' AND \n\t\t\t" . "video.active" . "='yes' AND " . "video.broadcast" . " !='unlisted' ";
     } else {
         $params['admin_access'] = true;
         if ($params['active']) {
             $cond .= " " . "video.active" . "='" . $params['active'] . "'";
         }
         if ($params['status']) {
             if ($cond != '') {
                 $cond .= " AND ";
             }
             $cond .= " " . "video.status" . "='" . $params['status'] . "'";
         }
         if ($params['broadcast']) {
             if ($cond != '') {
                 $cond .= " AND ";
             }
             $cond .= " " . "video.broadcast" . "='" . $params['broadcast'] . "'";
         }
     }
     //Setting Category Condition
     $all = false;
     if (!is_array($params['category'])) {
         if (strtolower($params['category']) == 'all') {
             $all = true;
         }
     }
     if ($params['category'] && !$all) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " (";
         if (!is_array($params['category'])) {
             $cats = explode(',', $params['category']);
         } else {
             $cats = $params['category'];
         }
         $count = 0;
         foreach ($cats as $cat_params) {
             $count++;
             if ($count > 1) {
                 $cond .= " OR ";
             }
             $cond .= " " . "video.category" . " LIKE '%#{$cat_params}#%' ";
         }
         $cond .= ")";
     }
     //date span
     if ($params['date_span']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         if ($params['date_span_column']) {
             $column = $params['date_span_column'];
         } else {
             $column = 'date_added';
         }
         $cond .= " " . cbsearch::date_margin($column, $params['date_span']);
     }
     //uid
     if ($params['user'] || $params['userid']) {
         if ($params['userid']) {
             $params['user'] = $params['userid'];
         }
         if (!is_array($params['user'])) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= " " . "video.userid" . "='" . $params['user'] . "'";
         } else {
             if ($cond != '') {
                 $cond .= ' AND (';
             }
             $uQu = 0;
             foreach ($params['user'] as $user) {
                 if ($uQu > 0) {
                     $cond .= ' OR ';
                 }
                 $cond .= " " . "video.userid" . "='" . $user . "'";
                 $uQu++;
             }
             $cond .= " ) ";
         }
     }
     //non-uid to exclude user videos from related
     if ($params['nonuser']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . "video.userid" . " <> '" . $params['nonuser'] . "' ";
     }
     $tag_n_title = '';
     //Tags
     if ($params['tags']) {
         //checking for commas ;)
         $tags = explode(",", $params['tags']);
         if (count($tags) > 0) {
             if ($tag_n_title != '') {
                 $tag_n_title .= ' OR ';
             }
             $total = count($tags);
             $loop = 1;
             foreach ($tags as $tag) {
                 $tag_n_title .= " " . 'video.tags' . " LIKE '%" . $tag . "%'";
                 if ($loop < $total) {
                     $tag_n_title .= " OR ";
                 }
                 $loop++;
             }
         } else {
             if ($tag_n_title != '') {
                 $tag_n_title .= ' OR ';
             }
             $tag_n_title .= " " . 'video.tags' . " LIKE '%" . $params['tags'] . "%'";
         }
     }
     //TITLE
     if ($params['title']) {
         if ($tag_n_title != '') {
             $tag_n_title .= ' OR ';
         }
         $tag_n_title .= " " . 'video.title' . " LIKE '%" . $params['title'] . "%'";
     }
     if ($tag_n_title) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " ({$tag_n_title}) ";
     }
     //FEATURED
     if ($params['featured']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . "video.featured" . " = '" . $params['featured'] . "' ";
     }
     //VIDEO ID
     if ($params['videoid']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . "video.videoid" . " = '" . $params['videoid'] . "' ";
     }
     //VIDEO ID
     if ($params['videoids']) {
         if (is_array($params['videoids'])) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= ' ( ';
             $curVid = 0;
             foreach ($params['videoids'] as $vid) {
                 if (is_numeric($vid)) {
                     if ($curVid > 0) {
                         $cond .= " OR ";
                     }
                     $cond .= " " . "video.videoid" . " = '" . $vid . "' ";
                 }
                 $curVid++;
             }
             $cond .= ' ) ';
         }
     }
     //VIDEO KEY
     if ($params['videokey']) {
         if (!is_array($params['videokey'])) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= " " . "video.videokey" . " = '" . $params['videokey'] . "' ";
         } else {
             if ($cond != '') {
                 $cond .= ' AND (';
             }
             $vkeyQue = 0;
             foreach ($params['videokey'] as $videokey) {
                 if ($vkeyQue > 0) {
                     $cond .= ' OR ';
                 }
                 $cond .= " " . "video.videokey" . " = '" . $videokey . "' ";
                 $vkeyQue++;
             }
             $cond .= " ) ";
         }
     }
     //Exclude Vids
     if ($params['exclude']) {
         if (!is_array($params['exclude'])) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' ";
         } else {
             foreach ($params['exclude'] as $exclude) {
                 if ($cond != '') {
                     $cond .= ' AND ';
                 }
                 $cond .= " " . 'video.videoid' . " <> '" . $exclude . "' ";
             }
         }
     }
     //Duration
     if ($params['duration']) {
         $duration_op = $params['duration_op'];
         if (!$duration_op) {
             $duration_op = "=";
         }
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . 'video.duration' . " " . $duration_op . " '" . $params['duration'] . "' ";
     }
     if ($params['has_mobile']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . 'video.has_mobile' . "='" . $params['has_mobile'] . "'";
     }
     //Filename
     if ($params['filename']) {
         if (!is_array($params['filename'])) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= " " . 'video.file_name' . " <> '" . $params['filename'] . "' ";
         } else {
             if ($cond != '') {
                 $cond .= ' AND (';
             } else {
                 $cond .= " ( ";
             }
             $fileNameQue = 0;
             foreach ($params['filename'] as $filename) {
                 if ($fileNameQue > 0) {
                     $cond .= ' OR ';
                 }
                 $cond .= " " . "video.file_name" . " = '" . $filename . "' ";
                 $fileNameQue++;
             }
             $cond .= " ) ";
         }
     }
     if ($params['cond']) {
         if ($params['cond_and']) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
         }
         $cond .= " " . $params['cond'];
     }
     $functions = cb_get_functions('get_videos');
     if ($functions) {
         foreach ($functions as $func) {
             $array = array('params' => $params, 'cond' => $cond);
             if (function_exists($func['func'])) {
                 $returned = $func['func']($array);
                 if ($returned) {
                     $cond = $returned;
                 }
             }
         }
     }
     if (!$params['count_only'] && !$params['show_related']) {
         $userFields = array('userid', 'email', 'username');
         foreach ($userFields as $ufield) {
             $ufieldq .= ",users." . $ufield;
         }
         //$meta_query = $this->create_meta_query();
         $fields_arr = array('video' => get_video_fields(), 'users' => get_user_fields());
         $fields = tbl_fields($fields_arr);
         $query = " SELECT " . $fields . " FROM " . tbl('video') . " AS video ";
         $query .= " LEFT JOIN " . tbl('users') . " AS users ";
         $query .= " ON video.userid = users.userid ";
         $limit_query = "";
         $order_query = "";
         if ($limit) {
             $limit_query = " LIMIT " . $limit;
         }
         if ($order) {
             $order_query = " ORDER BY " . $order;
         }
         if ($cond) {
             $query .= " WHERE " . $cond;
         }
         $query .= $order_query;
         $query .= $limit_query;
         $start = microtime(true);
         $action_data = call_actions('get_videos', $query);
         if ($action_data) {
             $result = $action_data;
         } else {
             $result = db_select($query);
         }
         $end = microtime(true);
     }
     if ($params['show_related']) {
         $cond = "";
         if ($superCond) {
             $cond = $superCond . " AND ";
         }
         $cond .= "MATCH(" . "video.title,video.tags" . ") \n\t\t\tAGAINST ('" . cbsearch::set_the_key($params['title']) . "' IN BOOLEAN MODE) ";
         if ($params['exclude']) {
             if ($cond != '') {
                 $cond .= ' AND ';
             }
             $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' ";
         }
         $query = " SELECT " . $fields . " FROM " . tbl('video') . " AS video ";
         $query .= " LEFT JOIN " . tbl('users') . " AS users ";
         $query .= " ON video.userid = users.userid ";
         if ($cond) {
             $query .= " WHERE " . $cond;
         }
         if ($limit) {
             $limit_query = " LIMIT " . $limit;
         }
         if ($order) {
             $order_query = " ORDER BY " . $order;
         }
         $query .= $order_query;
         $query .= $limit_query;
         $action_data = call_actions('get_videos', $query);
         if ($action_data) {
             $result = $action_data;
         } else {
             $result = db_select($query);
         }
         if ($db->num_rows == 0) {
             $cond = "";
             if ($superCond) {
                 $cond = $superCond . " AND ";
             }
             //Try Finding videos via tags
             $cond .= "MATCH(" . "video.title,video.tags" . ") \n\t\t\t\tAGAINST ('" . cbsearch::set_the_key($params['tags']) . "' IN BOOLEAN MODE) ";
             if ($params['exclude']) {
                 if ($cond != '') {
                     $cond .= ' AND ';
                 }
                 $cond .= " " . 'video.videoid' . " <> '" . $params['exclude'] . "' ";
             }
             $query = " SELECT " . $fields . " FROM " . tbl('video') . " AS video ";
             $query .= " LEFT JOIN " . tbl('users') . " AS users ";
             $query .= " ON video.userid = users.userid ";
             if ($cond) {
                 $query .= " WHERE " . $cond;
             }
             if ($limit) {
                 $limit_query = " LIMIT " . $limit;
             }
             if ($order) {
                 $order_query = " ORDER BY " . $order;
             }
             $query .= $order_query;
             $query .= $limit_query;
             $action_data = call_actions('get_videos', $query);
             if ($action_data) {
                 $result = $action_data;
             } else {
                 $result = db_select($query);
             }
         }
     }
     $result = apply_filters($result, 'get_videos');
     if (!$action_data && $result) {
         call_actions('select_videos', array('query' => $query, 'results' => $result));
     }
     if ($params['pr']) {
         pr($result, true);
     }
     if ($params['count_only']) {
         return $result = $db->count(tbl('video') . " AS video ", 'videoid', $cond);
     }
     if ($params['assign']) {
         assign($params['assign'], $result);
     } else {
         return $result;
     }
 }
コード例 #3
0
ファイル: video.class.php プロジェクト: Coding110/cbvideo
 /**
  * Function used to get video data
  */
 function get_video($vid, $file = false, $basic = false)
 {
     global $db, $cb_columns;
     $userFields = get_user_fields();
     $videoFields = array('video' => '*');
     if ($basic === true) {
         $videoFields = get_video_fields();
     }
     $fields = array('video' => $videoFields, 'users' => $userFields);
     $cond = ($file ? 'video.file_name' : (is_numeric($vid) ? 'video.videoid' : 'video.videokey')) . " = '%s' ";
     $query = "SELECT " . tbl_fields($fields) . " FROM " . cb_sql_table('video');
     $query .= " LEFT JOIN " . cb_sql_table('users') . " ON video.userid = users.userid";
     if ($cond) {
         $query .= " WHERE " . sprintf($cond, $vid);
     }
     $query .= 'LIMIT 1';
     $query_id = cb_query_id($query);
     $data = cb_do_action('select_video', array('query_id' => $query_id, 'videoid' => $vid));
     if ($data) {
         return $data;
     }
     $result = select($query);
     if ($result) {
         $result = apply_filters($result[0], 'get_video');
         cb_do_action('return_video', array('query_id' => $query_id, 'results' => $result, 'object_id' => $vid, 'videoid' => $vid));
         return $result;
     } else {
         return false;
     }
 }
コード例 #4
0
/**
 * myaccount dashboard, recent video comments widget
 * 
 * @global object $userquery
 * @param array $widget
 * @return string
 */
function account_dashboard_recent_video_comments($widget)
{
    global $userquery;
    if (!userid()) {
        return false;
    }
    $configs = get_dashboard_widget_configs($widget['id']);
    $no_of_comments = $configs['number_of_comments'] ? $configs['number_of_comments'] : 15;
    $no_of_days = $configs['number_of_days'] ? $configs['number_of_days'] : 8;
    if ($userquery->udetails['total_videos'] > 0) {
        $fields = array('video' => array('videoid', 'videokey', 'title', 'description', 'views'), 'users' => get_user_fields(), 'comments' => array('comment_id', 'type', 'comment', 'userid', 'type_id', 'type_owner_id', 'date_added'));
        $fields = tbl_fields($fields);
        $query = "SELECT {$fields}  FROM " . tbl('comments') . " AS comments ";
        $query .= "LEFT JOIN " . tbl('video') . " AS video ON " . 'comments.type_id' . " = " . 'video.videoid' . " ";
        $query .= "LEFT JOIN " . tbl('users') . " AS users ON " . 'comments.userid' . " = " . 'users.userid' . " ";
        start_where();
        add_where(" " . 'comments.type_owner_id' . " = " . userid());
        add_where(" " . 'comments.type' . " = 'v' ");
        add_where(" " . 'comments.userid' . " <> " . userid());
        add_where(" " . 'comments.date_added' . " BETWEEN SYSDATE() - INTERVAL {$no_of_days} DAY AND SYSDATE() ");
        if (get_where()) {
            $query .= " WHERE " . get_where();
        }
        end_where();
        $query .= " ORDER BY " . 'comments.date_added' . " DESC LIMIT {$no_of_comments}";
        $comments = db_select($query);
    }
    // Comment Template
    $params['file'] = 'blocks/account/dashboard_comments.html';
    $params['widget'] = $widget;
    $params['comments'] = $comments;
    $params['configs'] = $configs;
    return fetch_template_file($params);
}
コード例 #5
0
ファイル: user.class.php プロジェクト: yukisky/clipbucket
 /**
  * Get user friend requests
  * 
  * @param INT userid
  * 
  */
 function get_friend_requests($uid, $params = NULL)
 {
     $uid = mysql_clean($uid);
     if (isset($params['ignored'])) {
         $ignored = mysql_clean($params['ignored']);
     }
     if (isset($params['seen'])) {
         $seen = mysql_clean($params['seen']);
     }
     if (isset($params['count_only'])) {
         $count_only = $params['count_only'];
     }
     $fields_arr = array('r' => array('friend_id', 'message', 'seen', 'ignored', 'time_added', 'req_id'), 'u' => get_user_fields());
     $fields = tbl_fields($fields_arr);
     $query = "SELECT " . $fields . " FROM " . tbl('friend_requests') . " AS r";
     $query .= " LEFT JOIN " . tbl('users') . " AS u";
     $query .= " ON u.userid=r.userid ";
     $query .= " WHERE r.friend_id='{$uid}' ";
     if ($ignored) {
         $query .= " AND r.ignored='{$ignored}' ";
     }
     if ($seen) {
         $query .= " AND r.seen='{$seen}' ";
     }
     if (!$count_only) {
         $results = db_select($query);
     } else {
         //Return total friend requests...
         $query = " SELECT count(req_id) as total_requests ";
         $query .= " FROM " . tbl('friend_requests') . " WHERE ";
         $query .= " friend_id='{$uid}' ";
         if ($ignored) {
             $query .= " AND ignored='{$ignored}' ";
         }
         if ($seen) {
             $query .= " AND seen='{$seen}' ";
         }
         $results = db_select($query);
         if ($results) {
             return $results[0]['total_requests'];
         } else {
             return 0;
         }
     }
     if ($results) {
         return $results;
     } else {
         return false;
     }
 }
コード例 #6
0
ファイル: photos.class.php プロジェクト: Coding110/cbvideo
 /**
  * Get Photos 
  */
 function get_photos($p)
 {
     global $db, $cb_columns;
     $tables = "photos,users";
     $order = $p['order'];
     $limit = $p['limit'];
     $cond = "";
     if (!has_access('admin_access', TRUE)) {
         $cond = " " . 'photos.broadcast' . " = 'public' AND " . 'photos.active' . " = 'yes'";
     } else {
         if ($p['active']) {
             $cond .= " " . 'photos.active' . " = '" . $p['active'] . "'";
         }
         if ($p['broadcast']) {
             if ($cond != "") {
                 $cond .= " AND ";
             }
             $cond .= " " . 'photos.broadcast' . " = '" . $p['broadcast'] . "'";
         }
     }
     if ($p['pid']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $this->constructMultipleQuery(array("ids" => $p['pid'], "sign" => "=", "operator" => "OR"));
     }
     if ($p['key']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= " " . 'photos.photo_key' . " = '" . $p['key'] . "'";
     }
     if ($p['filename']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= " " . 'photos.filename' . " = '" . $p['filename'] . "'";
     }
     if ($p['extension']) {
         foreach ($this->exts as $ext) {
             if (in_array($ext, $this->exts)) {
                 if ($cond != "") {
                     $cond .= " AND ";
                 }
                 $cond .= " " . 'photos.ext' . " = '" . $p['extension'] . "'";
             }
         }
     }
     if ($p['date_span']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= " " . cbsearch::date_margin("photos.date_added", $p['date_span']);
     }
     if ($p['featured']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= " " . 'photos.featured' . " = '" . $p['featured'] . "'";
     }
     if ($p['user']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $this->constructMultipleQuery(array("ids" => $p['user'], "sign" => "=", "operator" => "AND", "column" => "userid"));
     }
     if ($p['exclude']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>"));
     }
     $title_tag = '';
     if ($p['title']) {
         $title_tag = " " . 'photos.photo_title' . " LIKE '%" . $p['title'] . "%'";
     }
     if ($p['tags']) {
         $tags = explode(",", $p['tags']);
         if (count($tags) > 0) {
             if ($title_tag != '') {
                 $title_tag .= " OR ";
             }
             $total = count($tags);
             $loop = 1;
             foreach ($tags as $tag) {
                 $title_tag .= " " . 'photos.photo_tags' . " LIKE '%{$tag}%'";
                 if ($loop < $total) {
                     $title_tag .= " OR ";
                 }
                 $loop++;
             }
         } else {
             if ($title_tag != '') {
                 $title_tag .= " OR ";
             }
             $title_tag .= " " . 'photos.photo_tags' . " LIKE '%" . $p['tags'] . "%'";
         }
     }
     if ($title_tag != "") {
         if ($cond != '') {
             $cond .= " AND ";
         }
         $cond .= " ({$title_tag}) ";
     }
     if ($p['ex_user']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $this->constructMultipleQuery(array("ids" => $p['ex_user'], "sign" => "<>", "operator" => "AND", "column" => "userid"));
     }
     if ($p['extra_cond']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $p['extra_cond'];
     }
     if ($p['get_orphans']) {
         $p['collection'] = (string) "0";
     }
     if ($p['collection'] || $p['get_orphans']) {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "=", "operator" => "OR", "column" => "collection_id"));
     } else {
         if ($cond != "") {
             $cond .= " AND ";
         }
         $cond .= " " . 'photos.collection_id' . " <> '0'";
     }
     $fields = array('photos' => get_photo_fields(), 'users' => get_user_fields(), 'collections' => array('collection_name', 'type', 'category', 'views as collection_views', 'date_added as collection_added'));
     $string = tbl_fields($fields);
     $main_query = "SELECT {$string} FROM " . table('photos');
     $main_query .= " LEFT JOIN " . table('collections') . " ON photos.collection_id = collections.collection_id";
     $main_query .= " LEFT JOIN " . table('users') . " ON collections.userid = users.userid";
     $order = $order ? " ORDER BY " . $order : false;
     $limit = $limit ? " LIMIT " . $limit : false;
     if (!$p['count_only'] && !$p['show_related']) {
         $query = $main_query;
         if ($cond) {
             $query .= " WHERE " . $cond;
         }
         $query .= $order;
         $query .= $limit;
         $result = select($query);
     }
     if ($p['show_related']) {
         $query = $main_query;
         $cond = "MATCH(" . 'photos.photo_title,photos.photo_tags' . ")";
         $cond .= " AGAINST ('" . cbsearch::set_the_key($p['title']) . "' IN BOOLEAN MODE)";
         if ($p['exclude']) {
             if ($cond != "") {
                 $cond .= " AND ";
             }
             $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>"));
         }
         if ($p['collection']) {
             if ($cond != "") {
                 $cond .= " AND ";
             }
             $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "<>", "column" => "collection_id"));
         }
         if ($p['extra_cond']) {
             if ($cond != "") {
                 $cond .= " AND ";
             }
             $cond .= $p['extra_cond'];
         }
         $where = " WHERE " . $cond . " AND photos.collection_id <> 0";
         $query .= $where;
         $query .= $order;
         $query .= $limit;
         $result = select($query);
         // We found nothing from TITLE of Photos, let's try TAGS
         if ($db->num_rows == 0) {
             $query = $main_query;
             $tags = cbsearch::set_the_key($p['tags']);
             $tags = str_replace('+', '', $tags);
             $cond = "MATCH(" . 'photos.photo_title,photos.photo_tags' . ")";
             $cond .= " AGAINST ('" . $tags . "' IN BOOLEAN MODE)";
             if ($p['exclude']) {
                 if ($cond != "") {
                     $cond .= " AND ";
                 }
                 $cond .= $this->constructMultipleQuery(array("ids" => $p['exclude'], "sign" => "<>"));
             }
             if ($p['collection']) {
                 if ($cond != "") {
                     $cond .= " AND ";
                 }
                 $cond .= $this->constructMultipleQuery(array("ids" => $p['collection'], "sign" => "<>", "column" => "collection_id"));
             }
             if ($p['extra_cond']) {
                 if ($cond != "") {
                     $cond .= " AND ";
                 }
                 $cond .= $p['extra_cond'];
             }
             $where = " WHERE " . $cond . " AND photos.collection_id <> 0";
             $query .= $where;
             $query .= $order;
             $query .= $limit;
             $result = select($query);
         }
     }
     if ($p['count_only']) {
         if ($p['extra_cond']) {
             if ($cond != "") {
                 $cond .= " AND ";
             }
             $cond .= $p['extra_cond'];
         }
         $result = $db->count(table("photos"), "photo_id", $cond);
     }
     ##pr( $query, true );
     if ($p['assign']) {
         assign($p['assign'], $result);
     } else {
         return $result;
     }
 }
コード例 #7
0
/**
 * Gets subscribed content from subscriptions_content table
 * of provided userid.
 * 
 * @author Fawaz Tahir <*****@*****.**>
 * @global int $cb_subscriptions_content_limit
 * @param type $userid
 * @return boolean
 */
function get_user_subscriptions_content($userid = null)
{
    global $cb_subscriptions_content_limit;
    if (is_null($userid)) {
        $userid = userid();
    }
    if (!$userid) {
        return false;
    }
    $fields = tbl_fields(array('subscriptions' => array('subscription_id', 'userid as subscriber_id', 'subscribed_to', 'subscribed_content'), 'subscriptions_content' => get_subscription_content_fields(), 'users' => get_user_fields(), 'objects_cache' => array('content', 'last_updated')));
    $query = "SELECT " . $fields . " FROM " . cb_sql_table('subscriptions_content');
    $query .= " LEFT JOIN " . cb_sql_table('subscriptions') . " ON subscriptions_content.subscription_id = subscriptions.subscription_id";
    $query .= " LEFT JOIN " . cb_sql_table('objects_cache') . " ON subscriptions_content.content_cache_id = objects_cache.object_id ";
    $query .= " LEFT JOIN " . cb_sql_table('users') . " ON subscriptions.userid = users.userid ";
    $subscriptions = get_user_subscriptions();
    $subs_query = build_user_subscriptions_query_string($subscriptions);
    start_where();
    add_where(" subscriptions.userid = '" . $userid . "' ");
    add_where(" subscriptions_content.is_content_hidden = 'no' ");
    if ($subs_query) {
        add_where($subs_query);
    }
    $query .= " WHERE " . get_where();
    end_where();
    $query .= " ORDER BY subscriptions_content.date_added DESC";
    $query .= " LIMIT " . $cb_subscriptions_content_limit;
    $results = db_select($query);
    if ($results) {
        return $results;
    } else {
        return false;
    }
}
コード例 #8
0
ファイル: groups.class.php プロジェクト: yukisky/clipbucket
 /**
  * Function used to get group admins
  * 
  * @param $gid
  */
 function get_group_admins($gid)
 {
     global $db;
     $gid = mysql_clean($gid);
     $app_query = "";
     $app_query = " AND " . tbl($this->gp_mem_tbl) . ".active='{$approved}'";
     //List of fields we need from a user table
     $user_fields = get_user_fields();
     $user_fields = apply_filters($user_fields, 'get_group_members');
     $fields_arr = array('users' => $user_fields, 'members' => array('is_admin', 'ban', 'active'));
     $fields = tbl_fields($fields_arr);
     $query = " SELECT " . $fields . " FROM " . tbl('group_members') . " AS members ";
     $query .= " LEFT JOIN " . tbl('users') . " AS users ON ";
     $query .= " users.userid = members.userid ";
     $query .= " WHERE members.group_id='{$gid}' AND members.is_admin='yes' ";
     $result = db_select($query);
     if ($db->num_rows > 0) {
         return $result;
     } else {
         return false;
     }
 }
コード例 #9
0
ファイル: user.class.php プロジェクト: reactvideos/Website
 /**
  * Function used to get users
  */
 function get_users($params = NULL, $force_admin = FALSE)
 {
     global $db;
     $limit = $params['limit'];
     $order = $params['order'];
     $cond = "";
     if (!has_access('admin_access', TRUE) && !$force_admin) {
         $cond .= " \tusers.usr_status='Ok' AND users.ban_status ='no' ";
     } else {
         if ($params['ban']) {
             $cond .= " users.ban_status ='" . $params['ban'] . "'";
         }
         if ($params['status']) {
             if ($cond != '') {
                 $cond .= " AND ";
             }
             $cond .= " \tusers.usr_status='" . $params['status'] . "'";
         }
     }
     //Setting Category Condition
     if (!is_array($params['category'])) {
         $is_all = strtolower($params['category']);
     }
     if ($params['category'] && $is_all != 'all') {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " (";
         if (!is_array($params['category'])) {
             $cats = explode(',', $params['category']);
         } else {
             $cats = $params['category'];
         }
         $count = 0;
         foreach ($cats as $cat_params) {
             $count++;
             if ($count > 1) {
                 $cond .= " OR ";
             }
             $cond .= " users.category LIKE '%{$cat_params}%' ";
         }
         $cond .= ")";
     }
     //date span
     if ($params['date_span']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . cbsearch::date_margin("users.doj", $params['date_span']);
     }
     /*//uid 
     		if($params['user'])
     		{
     			if($cond!='')
     				$cond .= ' AND ';
     			$cond .= " userid='".$params['user']."'";
     		}
     		
     		$tag_n_title='';
     		//Tags
     		if($params['tags'])
     		{
     			//checking for commas ;)
     			$tags = explode(",",$params['tags']);
     			if(count($tags)>0)
     			{
     				if($tag_n_title!='')
     					$tag_n_title .= ' OR ';
     				$total = count($tags);
     				$loop = 1;
     				foreach($tags as $tag)
     				{
     					$tag_n_title .= " tags LIKE '%".$tag."%'";
     					if($loop<$total)
     					$tag_n_title .= " OR ";
     					$loop++;
     					
     				}
     			}else
     			{
     				if($tag_n_title!='')
     					$tag_n_title .= ' OR ';
     				$tag_n_title .= " tags LIKE '%".$params['tags']."%'";
     			}
     		}
     		//TITLE
     		if($params['title'])
     		{
     			if($tag_n_title!='')
     				$tag_n_title .= ' OR ';
     			$tag_n_title .= " title LIKE '%".$params['tags']."%'";
     		}
     		
     		if($tag_n_title)
     		{
     			if($cond!='')
     				$cond .= ' AND ';
     			$cond .= " ($tag_n_title) ";
     		}*/
     //FEATURED
     if ($params['featured']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.featured = '" . $params['featured'] . "' ";
     }
     //Email
     if ($params['username']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.username = '******'username'] . "' ";
     }
     //Email
     if ($params['email']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.email = '" . $params['email'] . "' ";
     }
     //Exclude Users
     if ($params['exclude']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.userid <> '" . $params['exclude'] . "' ";
     }
     //Getting specific User
     if ($params['userid']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.userid = '" . $params['userid'] . "' ";
     }
     //Sex
     if ($params['gender']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.sex = '" . $params['gender'] . "' ";
     }
     //Level
     if ($params['level']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " users.level = '" . $params['level'] . "' ";
     }
     if ($params['cond']) {
         if ($cond != '') {
             $cond .= ' AND ';
         }
         $cond .= " " . $params['cond'] . " ";
     }
     if (!$params['count_only']) {
         $fields = array('users' => get_user_fields(), 'profile' => array('rating', 'rated_by', 'voters', 'first_name', 'last_name'));
         $fields['users'][] = 'last_active';
         $query = " SELECT " . tbl_fields($fields) . " FROM " . tbl('users') . " AS users ";
         $query .= " LEFT JOIN " . table('user_profile', 'profile ') . " ON users.userid = profile.userid ";
         if ($cond) {
             $query .= " WHERE " . $cond;
         }
         if ($order) {
             $query .= " ORDER BY " . $order;
         }
         if ($limit) {
             $query .= " LIMIT  " . $limit;
         }
         //$result = $db->select(tbl('users'),'*',$cond,$limit,$order);
         $result = select($query);
     }
     if ($params['count_only']) {
         //$cond= substr($cond,8);
         $result = $db->count(tbl('users') . " AS users ", 'userid', $cond);
         //echo $cond;
         //return $result;
     }
     if ($params['assign']) {
         assign($params['assign'], $result);
     } else {
         return $result;
     }
 }