/** * Get the full URL to the needed thumbnail * * @param numeric $pTopicId Topic ID of topic in question * @access public * @return Path to thumbnail, FALSE on failure */ public function getTopicImageThumbUrl($pTopicId = NULL) { global $gBitSystem; $ret = FALSE; if (!@BitBase::verifyId($pTopicId) && $this->isValid()) { $pTopicId = $this->mTopicId; } if (@BitBase::verifyId($pTopicId)) { $ret = liberty_fetch_thumbnail_url(array('source_file' => BitArticleTopic::getTopicImageBaseUrl($pTopicId), 'default_image' => $gBitSystem->getConfig('articles_image_size', 'small'))); } return $ret; }
/** * getList get a list of users * * @param array $pParamHash * @access public * @return array of users */ function getList(&$pParamHash) { global $gBitSystem, $gBitUser; if (empty($pParamHash['sort_mode'])) { $pParamHash['sort_mode'] = 'registration_date_desc'; } LibertyContent::prepGetList($pParamHash); $selectSql = $joinSql = $whereSql = ''; $bindVars = array(); array_push($bindVars, 'bituser'); $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash); // limit search to users with a specific language if (!empty($pParamHash['lang_code'])) { $joinSql .= " INNER JOIN `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp ON ( lcp.`content_id`=uu.`content_id` AND lcp.`pref_name`='bitlanguage' )"; $whereSql .= " AND lcp.`pref_value`=? "; $bindVars[] = $pParamHash['lang_code']; } if (!$gBitUser->hasPermission('p_users_admin')) { $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp2 ON ( lcp2.`content_id`=uu.`content_id` AND lcp2.`pref_name`='users_information' )"; $whereSql .= " AND (lcp2.`pref_value` IS NULL OR lcp2.`pref_value`='public')"; } // limit search to users with a specific IP if (!empty($pParamHash['ip'])) { $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_cnxn` uc ON ( uu.`user_id`=uc.`user_id`) "; $ips = explode(',', $pParamHash['ip']); $whereSql .= ' AND ( '; do { $ip = array_pop($ips); if (strpos($ip, '%')) { $whereSql .= " uc.`ip` LIKE ? "; } else { $whereSql .= " uc.`ip`=? "; } $bindVars[] = $ip; if (!empty($ips)) { $whereSql .= ' OR '; } } while ($ips); $whereSql .= ' ) '; } // limit to registrations over a time period like 'YYYY-MM-DD' or 'Y \Week W' or anything convertible by SQLDate if (!empty($pParamHash['period'])) { $sqlPeriod = $this->mDb->SQLDate($this->mDb->getPeriodFormat($pParamHash['period']), $this->mDb->SQLIntToTimestamp('registration_date')); $whereSql .= ' AND ' . $sqlPeriod . '=?'; $bindVars[] = $pParamHash['timeframe']; } // lets search for a user if ($pParamHash['find']) { $whereSql .= " AND ( UPPER( uu.`login` ) LIKE ? OR UPPER( uu.`real_name` ) LIKE ? OR UPPER( uu.`email` ) LIKE ? ) "; $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%'; $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%'; $bindVars[] = '%' . strtoupper($pParamHash['find']) . '%'; } if ($gBitSystem->isPackageActive('stats')) { $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "stats_referer_users_map` srum ON (srum.`user_id`=uu.`user_id`)\n\t\t\t\t\t\t LEFT OUTER JOIN `" . BIT_DB_PREFIX . "stats_referer_urls` sru ON (srum.`referer_url_id`=sru.`referer_url_id`)"; $selectSql .= ", sru.`referer_url`"; if (!empty($pParamHash['referer'])) { if ($pParamHash['referer'] == 'none') { $whereSql .= " AND `referer_url` IS NULL"; } else { $whereSql .= " AND `referer_url` LIKE ?"; $bindVars[] = '%' . strtolower($pParamHash['find']) . '%'; } } } // Return an array of users indicating name, email, last changed pages, versions, last_login $query = "\n\t\t\tSELECT uu.*, lc.`content_status_id`, lf_ava.`file_name` AS `avatar_file_name`, lf_ava.`mime_type` AS `avatar_mime_type`, la_ava.`attachment_id` AS `avatar_attachment_id` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "users_users` uu\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (uu.`content_id`=lc.`content_id`)\n\t\t\t\t{$joinSql}\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la_ava ON ( uu.`avatar_attachment_id`=la_ava.`attachment_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf_ava ON ( lf_ava.`file_id`=la_ava.`foreign_id` )\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql} ORDER BY " . $this->mDb->convertSortmode($pParamHash['sort_mode']); $result = $this->mDb->query($query, $bindVars, $pParamHash['max_records'], $pParamHash['offset']); $ret = array(); while ($res = $result->fetchRow()) { // Used for pulling out dead/empty/spam accounts if (isset($pParamHash['max_content_count']) && is_numeric($pParamHash['max_content_count'])) { $contentCount = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "liberty_content` lc INNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( lc.`user_id`=uu.`user_id` ) WHERE uu.`user_id`=? AND `content_type_guid` != 'bituser'", array($res['user_id'])); if ($contentCount > $pParamHash['max_content_count']) { continue; } } // Used for pulling out non-idle accounts or pigs if (isset($pParamHash['min_content_count']) && is_numeric($pParamHash['min_content_count'])) { $contentCount = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "liberty_content` lc INNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( lc.`user_id`=uu.`user_id` ) WHERE uu.`user_id`=? AND `content_type_guid` != 'bituser'", array($res['user_id'])); if ($contentCount < $pParamHash['min_content_count']) { continue; } } if (!empty($res['referer_url'])) { if ($gBitSystem->isPackageActive('stats')) { $res['short_referer_url'] = stats_referer_display_short($res['referer_url']); } } if (!empty($res['avatar_file_name'])) { $res['avatar_url'] = $this->getSourceUrl(array('attachment_id' => $res['avatar_attachment_id'], 'mime_type' => $res['avatar_mime_type'], 'file_name' => $res['avatar_file_name'])); $res['thumbnail_url'] = liberty_fetch_thumbnail_url(array('source_file' => $this->getSourceFile(array('sub_dir' => $res['avatar_attachment_id'], 'user_id' => $res['user_id'], 'file_name' => $res['avatar_file_name'], 'mime_type' => $res['avatar_mime_type'], 'package' => liberty_mime_get_storage_sub_dir_name(array('mime_type' => $res['avatar_mime_type'], 'name' => $res['avatar_file_name'])))), 'file_name' => $res['avatar_url'], 'size' => 'avatar')); } $res["roles"] = $this->getRoles($res['user_id']); $ret[$res['user_id']] = $res; } $retval = array(); $query = "\n\t\t\tSELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "users_users` uu\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (uu.`content_id`=lc.`content_id`) {$joinSql}\n\t\t\tWHERE lc.`content_type_guid` = ? {$whereSql}"; $pParamHash["cant"] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pParamHash); return $ret; }
/** * This function gets a list of posts */ function getList(&$pListHash) { global $gBitUser, $gBitSystem; $this->prepGetList($pListHash); $joinSql = $selectSql = $whereSql = ''; $ret = array(); $contentId = $this->mCommentId; // $mid = 'ORDER BY `thread_forward_sequence` ASC'; $bindVars = array(); if (!empty($pListHash['content_id'])) { if (is_array($contentId)) { $mid2 = 'in (' . implode(',', array_fill(0, count($pListHash['content_id']), '?')) . ')'; $bindVars = $contentId; $selectSql = ', lcp.content_type_guid as parent_content_type_guid, lcp.title as parent_title '; $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content` lcp ON (lcp.content_id = lcom.parent_id) "; } elseif (is_numeric($contentId)) { $whereSql .= " AND `thread_forward_sequence` LIKE '" . sprintf("%09d.", $contentId) . "%'"; } } if ($gBitSystem->isFeatureActive('boards_posts_anon_moderation') && !($gBitUser->hasPermission('p_boards_update') || $gBitUser->hasPermission('p_boards_post_update'))) { $whereSql .= " AND ((post.`is_approved` = 1) OR (lc.`user_id` >= 0))"; } $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, $this); if (!empty($pListHash['board_id'])) { $joinSql .= "INNER JOIN `" . BIT_DB_PREFIX . "boards` b ON (b.`content_id` = bm.`board_content_id`)"; $whereSql .= ' AND b.`board_id`=? '; array_push($bindVars, (int) $pListHash['board_id']); } if (BitBase::verifyId($pListHash['user_id'])) { $whereSql .= ' AND lc.`user_id`=? '; array_push($bindVars, $pListHash['user_id']); } if (!empty($whereSql)) { $whereSql = preg_replace('/^[\\s]*AND\\b/i', 'WHERE ', $whereSql); } $sql = "SELECT lcom.`comment_id`, lcom.`parent_id`, lcom.`root_id`, lcom.`thread_forward_sequence`, lcom.`thread_reverse_sequence`, lcom.`anon_name`, lc.*, uu.`email`, uu.`real_name`, uu.`login`, post.is_approved, post.is_warned, post.warned_message, uu.registration_date AS registration_date,\n\t\t\t\t\ttf_ava.`file_name` AS `avatar_file_name`, tf_ava.`mime_type` AS `avatar_mime_type`, tf_ava.`user_id` AS `avatar_user_id`, ta_ava.`attachment_id` AS `avatar_attachment_id`\n\t\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_comments` lcom\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "boards_map` bm ON (lcom.`root_id` = bm.`topic_content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lcom.`content_id` = lc.`content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON (lc.`user_id` = uu.`user_id`)\n\t\t\t\t\t {$joinSql}\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` ta_ava ON ( uu.`avatar_attachment_id`=ta_ava.`attachment_id` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` tf_ava ON ( tf_ava.`file_id`=ta_ava.`foreign_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "boards_posts` post ON (post.`comment_id` = lcom.`comment_id`)\n\t\t\t\t{$whereSql} ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $ret = array(); if ($result = $this->mDb->query($sql, $bindVars, $pListHash['max_records'], $pListHash['offset'])) { while ($row = $result->FetchRow()) { if (empty($row['anon_name'])) { $row['anon_name'] = "Anonymous"; } if (!empty($row['avatar_file_name'])) { $row['user_avatar_url'] = liberty_fetch_thumbnail_url(array('source_file' => liberty_mime_get_source_file(array('user_id' => $row['avatar_user_id'], 'file_name' => $row['avatar_file_name'], 'mime_type' => $row['avatar_mime_type'], 'attachment_id' => $row['avatar_attachment_id'])), 'size' => 'avatar')); } else { $row['user_avatar_url'] = FALSE; } unset($row['avatar_file_name']); if (!empty($row['warned_message'])) { $row['warned_message'] = str_replace("\n", "<br />\n", $row['warned_message']); } $row['data'] = trim($row['data']); $row['user_url'] = BitUser::getDisplayUrlFromHash($row); $row['parsed_data'] = $this->parseData($row); $row['level'] = substr_count($row['thread_forward_sequence'], '.') - 1; $row['topic_id'] = boards_get_topic_comment($row['thread_forward_sequence']); $row['display_url'] = static::getDisplayUrlFromHash($row); $c = new LibertyComment(); $c->mInfo = $row; $row['is_editable'] = $c->userCanEdit(); $ret[] = $row; //va($row); } } return $ret; }
function loadCurrentImage($pCurrentImageId) { if ($this->isValid() && @$this->verifyId($pCurrentImageId)) { // this code sucks but works - XOXO spiderr $query = "SELECT fgim.*, fi.`image_id`, lf.`file_name`, lf.`user_id`, lf.`mime_type`, la.`attachment_id`\n\t\t\t\t\tFROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` fgim\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "fisheye_image` fi ON ( fi.`content_id`=fgim.`item_content_id` )\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON ( fi.`content_id`=la.`content_id` )\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON ( lf.`file_id`=la.`foreign_id` )\n\t\t\t\t\tWHERE fgim.`gallery_content_id` = ?\n\t\t\t\t\tORDER BY fgim.`item_position`, fi.`content_id` "; if ($rs = $this->mDb->query($query, array($this->mContentId))) { $tempImage = new FisheyeImage(); $rows = $rs->getRows(); for ($i = 0; $i < count($rows); $i++) { if ($rows[$i]['image_id'] == $pCurrentImageId) { if ($i > 0) { $this->mInfo['previous_image_id'] = $rows[$i - 1]['image_id']; $this->mInfo['previous_image_avatar'] = liberty_fetch_thumbnail_url(array('file_name' => $rows[$i - 1]['file_name'], 'source_file' => $tempImage->getSourceFile($rows[$i - 1]), 'mime_image' => TRUE, 'size' => 'avatar')); } if ($i + 1 < count($rows)) { $this->mInfo['next_image_id'] = $rows[$i + 1]['image_id']; $this->mInfo['next_image_avatar'] = liberty_fetch_thumbnail_url(array('file_name' => $rows[$i + 1]['file_name'], 'source_file' => $tempImage->getSourceFile($rows[$i + 1]), 'mime_image' => TRUE, 'size' => 'avatar')); } } } } } }
function getList(&$pListHash) { global $gBitUser, $gBitSystem; LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $distinct = ''; $select = ''; $whereSql = ''; $joinSql = ''; if (@$this->verifyId($pListHash['user_id'])) { $whereSql .= " AND lc.`user_id` = ? "; $bindVars[] = $pListHash['user_id']; } elseif (!empty($pListHash['recent_users'])) { $distinct = " DISTINCT ON ( lc.created/86400, uu.`user_id` ) "; $pListHash['sort_mode'] = 'uu.user_id_desc'; } if (@$this->verifyId($pListHash['gallery_id'])) { $whereSql .= " AND fg.`gallery_id` = ? "; $bindVars[] = $pListHash['gallery_id']; } if (!empty($pListHash['search'])) { $whereSql .= " AND UPPER(lc.`title`) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['search']) . '%'; } if (!empty($pListHash['max_age']) && is_numeric($pListHash['max_age'])) { $whereSql .= " AND lc.`created` > ? "; $bindVars[] = $pListHash['max_age']; } $this->getServicesSql('content_user_collection_function', $selectSql, $joinSql, $whereSql, $bindVars, $this, $pListHash); $orderby = ''; if (!empty($pListHash['recent_images'])) { // get images from recent user truncated by day. This is necessary because DISTINCT ON expressions must match initial ORDER BY expressions $distinct = " DISTINCT ON ( lc.`created`/86400, uu.`user_id` ) "; $orderby = " ORDER BY lc.`created`/86400 DESC, uu.`user_id`"; } elseif (!empty($pListHash['sort_mode'])) { //converted in prepGetList() $orderby = " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); if (!empty($whereSql)) { $whereSql = substr_replace($whereSql, ' WHERE ', 0, 4); } $thumbSize = !empty($pListHash['size']) ? $pListHash['size'] : 'avatar'; $query = "SELECT {$distinct} fi.`image_id` AS `hash_key`, fi.*, lf.*, la.attachment_id, lc.*, fg.`gallery_id`, uu.`login`, uu.`real_name` {$select} {$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "fisheye_image` fi\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON(la.`content_id`=fi.`content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON(la.`foreign_id`=lf.`file_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON(fi.`content_id` = lc.`content_id`)\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON(uu.`user_id` = lc.`user_id`) {$joinSql}\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` tfgim2 ON(tfgim2.`item_content_id`=lc.`content_id`)\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "fisheye_gallery` fg ON(fg.`content_id`=tfgim2.`gallery_content_id`)\n\t\t\t\t{$whereSql} {$orderby}"; if ($rs = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset'], $pListHash['query_cache_time'])) { while ($row = $rs->fetchRow()) { // legacy table data was named storage_path and included a partial path. strip out any path just in case $row['file_name'] = basename($row['file_name']); $ret[$row['hash_key']] = $row; $imageId = $row['image_id']; if (empty($pListHash['no_thumbnails'])) { $ret[$imageId]['display_url'] = static::getDisplayUrlFromHash($row); $ret[$imageId]['has_machine_name'] = $this->isMachineName($ret[$imageId]['title']); $ret[$imageId]['source_url'] = $this->getStorageUrl($row) . $row['file_name']; $ret[$imageId]['thumbnail_url'] = liberty_fetch_thumbnail_url(array('source_file' => $this->getSourceFile($row), 'default_image' => FISHEYE_PKG_URL . 'image/generating_thumbnails.png', 'size' => $thumbSize, 'type' => $row['mime_type'])); } } } return $ret; }