本文整理汇总了PHP中colorize_username函数的典型用法代码示例。如果您正苦于以下问题:PHP colorize_username函数的具体用法?PHP colorize_username怎么用?PHP colorize_username使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了colorize_username函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cms_block_statistics
function cms_block_statistics()
{
global $config, $template, $lang;
$total_topics = $config['max_topics'];
$total_posts = $config['max_posts'];
$total_topics = $config['max_topics'];
$total_posts = $config['max_posts'];
$total_users = $config['max_users'];
$newest_userdata['user_id'] = $config['last_user_id'];
$newest_user = colorize_username($newest_userdata['user_id']);
$newest_uid = $newest_userdata['user_id'];
if ($total_posts == 0) {
$l_total_post_s = $lang['Posted_articles_zero_total'];
} elseif ($total_posts == 1) {
$l_total_post_s = $lang['Posted_article_total'];
} else {
$l_total_post_s = $lang['Posted_articles_total'];
}
if ($total_users == 0) {
$l_total_user_s = $lang['Registered_users_zero_total'];
} elseif ($total_users == 1) {
$l_total_user_s = $lang['Registered_user_total'];
} else {
$l_total_user_s = $lang['Registered_users_total'];
}
$template->assign_vars(array('TOTAL_USERS' => sprintf($l_total_user_s, $total_users), 'NEWEST_USER' => sprintf($lang['Newest_user'], '', $newest_user, ''), 'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts), 'TOTAL_TOPICS' => sprintf($lang['total_topics'], $total_topics)));
}
示例2: cms_block_user_block
function cms_block_user_block()
{
global $db, $cache, $config, $template, $user, $lang;
/*
if($user->data['session_logged_in'])
{
$sql = "SELECT COUNT(post_id) as total
FROM " . POSTS_TABLE . "
WHERE post_time >= " . $user->data['user_lastvisit'] . " AND poster_id <> " . $user->data['user_id'] . " AND post_time < " . time();
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
$db->sql_return_on_error(false);
if($result)
{
$row = $db->sql_fetchrow($result);
$lang['Search_new'] = $lang['Search_new'] . " (" . $row['total'] . ")";
$db->sql_freeresult($result);
}
}
*/
// Check For Anonymous User
if ($user->data['user_id'] != ANONYMOUS) {
$name_link = colorize_username($user->data['user_id'], $user->data['username'], $user->data['user_color'], $user->data['user_active']);
$avatar_img = user_get_avatar($user->data['user_id'], $user->data['user_level'], $user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_allowavatar']);
} else {
$name_link = $lang['Guest'];
$avatar_img = '<img src="' . $config['default_avatar_guests_url'] . '" alt="" />';
}
$s_last_visit = create_date($config['default_dateformat'], $user->data['user_lastvisit'], $config['board_timezone']);
$template->assign_vars(array('U_PORTAL_NOSID' => CMS_PAGE_HOME, 'AVATAR_IMG' => $avatar_img, 'U_NAME_LINK' => $name_link, 'LAST_VISIT_DATE' => sprintf($lang['You_last_visit'], $s_last_visit), 'L_REMEMBER_ME' => $lang['Remember_me'], 'L_SEND_PASSWORD' => $lang['Forgotten_password'], 'U_SEND_PASSWORD' => append_sid(CMS_PAGE_PROFILE . '?mode=sendpassword'), 'L_REGISTER_NEW_ACCOUNT' => sprintf($lang['Register_new_account'], '<a href="' . append_sid(CMS_PAGE_PROFILE . '?mode=register') . '">', '</a>'), 'L_NEW_SEARCH' => $lang['Search_new']));
}
示例3: ts_id_2_name
function ts_id_2_name($id, $mode = 'user')
{
global $db;
if ($id == '') {
return '?';
}
switch ($mode) {
case 'user_formatted':
$sql = "SELECT user_id, username, user_active, user_color FROM " . USERS_TABLE . " WHERE user_id = " . $id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$formatted_username = colorize_username($row['user_id'], $row['username'], $row['user_color'], $row['user_active']);
return $formatted_username;
break;
case 'user':
$sql = "SELECT username FROM " . USERS_TABLE . " WHERE user_id = " . $id;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
return $row['username'];
break;
case 'forum':
$sql = "SELECT f.forum_name\n\t\t\t\tFROM " . FORUMS_TABLE . " f, " . TOPICS_TABLE . " t\n\t\t\t\tWHERE t.topic_id = " . $id . "\n\t\t\t\t\tAND t.forum_id = f.forum_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
return $row['forum_name'];
break;
}
}
示例4: cms_block_recent_articles
function cms_block_recent_articles()
{
// if article approved in the table is equal to 1 the article has been approved, else it is not approved, so don't show it.
global $db, $cache, $config, $template, $user, $lang, $table_prefix, $style_row, $block_id, $cms_config_vars;
$template->_tpldata['recent_articles.'] = array();
@(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
$sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " ORDER BY article_id DESC LIMIT " . $cms_config_vars['md_total_articles'][$block_id];
$result = $db->sql_query($sql);
//now lets get our info
if ($row = $db->sql_fetchrow($result)) {
$i = 0;
do {
if ($row['approved'] == 1) {
$title = $row['article_title'];
$author_id = $row['article_author_id'];
$author = colorize_username($author_id);
$article_category_id = $row['article_id'];
$url = append_sid(IP_ROOT_PATH . 'kb.' . PHP_EXT . '?mode=article&k=' . $article_category_id);
if ($cms_config_vars['md_recent_articles_style'][$block_id] == '1') {
$style_row = 'articles_scroll';
} else {
$style_row = 'articles_static';
}
$template->assign_block_vars($style_row, '');
// Convert and clean special chars!
$title = htmlspecialchars_clean($title);
$template->assign_block_vars($style_row . '.recent_articles', array('TITLE' => $title, 'U_ARTICLE' => $url, 'AUTHOR' => $author, 'DATE' => create_date_ip($config['default_dateformat'], $row['article_date'], $config['board_timezone'])));
}
$i++;
} while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
}
}
示例5: cms_block_forum
function cms_block_forum()
{
global $db, $cache, $config, $template, $images, $lang, $bbcode, $block_id, $cms_config_vars;
$template->_tpldata['fetchpost_row.'] = array();
if (!class_exists('class_topics')) {
include IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT;
}
$class_topics = new class_topics();
$template->assign_vars(array('L_COMMENTS' => $lang['Comments'], 'L_VIEW_COMMENTS' => $lang['View_comments'], 'L_POST_COMMENT' => $lang['Post_your_comment'], 'L_POSTED' => $lang['Posted'], 'L_ANNOUNCEMENT' => $lang['Post_Announcement'], 'L_REPLIES' => $lang['Replies'], 'L_REPLY_NEWS' => $lang['News_Reply'], 'L_PRINT_NEWS' => $lang['News_Print'], 'L_EMAIL_NEWS' => $lang['News_Email'], 'MINIPOST_IMG' => $images['icon_minipost'], 'NEWS_REPLY_IMG' => $images['news_reply'], 'NEWS_PRINT_IMG' => $images['news_print'], 'NEWS_EMAIL_IMG' => $images['news_email'], 'IMG_CLOCK' => $images['news_clock']));
$article = request_var('article', 0);
if (!empty($article)) {
$cms_config_vars['md_news_length'][$block_id] = 0;
}
// Mighty Gorgon: edited by JHL, I still need to check the impacts on the auth system
//$fetchposts = $class_topics->fetch_posts($cms_config_vars['md_news_forum_id'][$block_id], $cms_config_vars['md_num_news'][$block_id], $cms_config_vars['md_news_length'][$block_id], false, false, false, false);
$fetchposts = $class_topics->fetch_posts($cms_config_vars['md_news_forum_id'][$block_id], $cms_config_vars['md_num_news'][$block_id], $cms_config_vars['md_news_length'][$block_id]);
for ($i = 0; $i < sizeof($fetchposts); $i++) {
$open_bracket = '';
$close_bracket = '';
$read_full = '';
if (empty($article) && $fetchposts[$i]['striped'] == 1) {
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $lang['Read_Full'];
}
// Convert and clean special chars!
$topic_title = htmlspecialchars_clean($fetchposts[$i]['topic_title']);
$template->assign_block_vars('fetchpost_row', array('TOPIC_ID' => $fetchposts[$i]['topic_id'], 'TITLE' => $topic_title, 'POSTER' => $fetchposts[$i]['username'], 'POSTER_CG' => colorize_username($fetchposts[$i]['user_id'], $fetchposts[$i]['username'], $fetchposts[$i]['user_color'], $fetchposts[$i]['user_active']), 'TIME' => $fetchposts[$i]['topic_time'], 'TEXT' => $fetchposts[$i]['post_text'], 'REPLIES' => $fetchposts[$i]['topic_replies'], 'U_VIEW_COMMENTS' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $fetchposts[$i]['post_id'] . '#p' . $fetchposts[$i]['post_id'], true), 'U_POST_COMMENT' => append_sid('posting.' . PHP_EXT . '?mode=reply&' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id']), 'U_PRINT_TOPIC' => append_sid('printview.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id'] . '&start=0'), 'U_EMAIL_TOPIC' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . urlencode(ip_utf8_decode($fetchposts[$i]['topic_title'])) . '&topic_id=' . $fetchposts[$i]['topic_id']), 'U_READ_FULL' => append_sid($index_file . '?article=' . $i), 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket));
}
}
示例6: cms_block_recent_topics
function cms_block_recent_topics()
{
global $db, $cache, $config, $template, $user, $lang, $block_id, $cms_config_vars;
$template->_tpldata['recent_topic_row.'] = array();
$except_forums = build_exclusion_forums_list();
$current_time = time();
$extra = "AND t.topic_time <= {$current_time}";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username, u.user_active, u.user_color\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u\n\t\t\tWHERE t.forum_id NOT IN (" . $except_forums . ")\n\t\t\t\tAND t.topic_status <> 2\n\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\tAND p.poster_id = u.user_id\n\t\t\t\t{$extra}\n\t\t\tORDER BY p.post_time DESC\n\t\t\tLIMIT " . $cms_config_vars['md_num_recent_topics'][$block_id];
$result = $db->sql_query($sql);
$number_recent_topics = $db->sql_numrows($result);
$recent_topic_row = array();
while ($row1 = $db->sql_fetchrow($result)) {
$recent_topic_row[] = $row1;
}
$db->sql_freeresult($result);
if ($cms_config_vars['md_recent_topics_style'][$block_id]) {
$style_row = 'scroll';
} else {
$style_row = 'static';
}
$template->assign_block_vars($style_row, '');
for ($i = 0; $i < $number_recent_topics; $i++) {
$recent_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']);
// Convert and clean special chars!
$topic_title = htmlspecialchars_clean($recent_topic_row[$i]['topic_title']);
$template->assign_block_vars($style_row . '.recent_topic_row', array('U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $recent_topic_row[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $recent_topic_row[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#p' . $recent_topic_row[$i]['post_id'], 'L_TITLE' => $topic_title, 'L_BY' => $lang['By'], 'L_ON' => $lang['POSTED_ON'], 'S_POSTER' => colorize_username($recent_topic_row[$i]['user_id'], $recent_topic_row[$i]['username'], $recent_topic_row[$i]['user_color'], $recent_topic_row[$i]['user_active']), 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $recent_topic_row[$i]['post_time'], $config['board_timezone'])));
}
}
示例7: cms_block_random_topics
function cms_block_random_topics()
{
global $db, $cache, $config, $template, $user, $lang, $bbcode, $block_id, $cms_config_vars;
@(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
$template->_tpldata['random_topic_row.'] = array();
$bbcode->allow_html = $user->data['user_allowhtml'] && $config['allow_html'] ? true : false;
$bbcode->allow_bbcode = $user->data['user_allowbbcode'] && $config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $user->data['user_allowsmile'] && $config['allow_smilies'] ? true : false;
$allowed_forum_id = build_allowed_forums_list();
if ($allowed_forum_id != '') {
$allow_forum_id = $cms_config_vars['md_random_topics_forums'][$block_id];
if ($allow_forum_id == '0') {
$allowed_forums_sql = 'AND t.forum_id IN (' . $allowed_forum_id . ')';
} else {
$allowed_forums = explode(',', $allow_forum_id);
$allowed_forums_tmp = explode(',', $allowed_forum_id);
$allowed_forum_id = '';
for ($i = 0; $i < sizeof($allowed_forums); $i++) {
for ($j = 0; $j < sizeof($allowed_forums_tmp); $j++) {
if ($allowed_forums[$i] == $allowed_forums_tmp[$j]) {
$allowed_forum_id .= $allowed_forums[$i] . ',';
break;
}
}
}
if ($allowed_forum_id != '') {
$allowed_forum_id = substr($allowed_forum_id, -1, 1) == ',' ? substr($allowed_forum_id, 0, -1) : $allowed_forum_id;
$allowed_forums_sql = 'AND t.forum_id IN (' . $allowed_forum_id . ')';
} else {
$no_topics_found = true;
}
}
} else {
$allowed_forums_sql = '';
}
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username, u.user_active, u.user_color, f.forum_name\n\t\t\tFROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . FORUMS_TABLE . " AS f\n\t\t\tWHERE t.topic_status <> 2\n\t\t\t\t" . $allowed_forums_sql . "\n\t\t\t\tAND f.forum_id = t.forum_id\n\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\tAND p.poster_id = u.user_id\n\t\t\tORDER BY RAND()\n\t\t\tLIMIT " . $cms_config_vars['md_num_random_topics'][$block_id];
$result = $db->sql_query($sql);
$number_random_topics = $db->sql_numrows($result);
$random_topic_row = array();
while ($row1 = $db->sql_fetchrow($result)) {
$random_topic_row[] = $row1;
}
$db->sql_freeresult($result);
if ($number_random_topics == 0 || $no_topics_found == true) {
$template->assign_block_vars('no_topics', array('L_NO_TOPICS' => $lang['No_topics_found']));
} else {
if ($cms_config_vars['md_random_topics_style'][$block_id]) {
$style_row = 'scroll';
} else {
$style_row = 'static';
}
$template->assign_block_vars($style_row, '');
for ($i = 0; $i < $number_random_topics; $i++) {
$random_topic_row[$i]['topic_title'] = censor_text($recent_topic_row[$i]['topic_title']);
$template->assign_block_vars($style_row . '.random_topic_row', array('U_FORUM' => append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $random_topic_row[$i]['forum_id']), 'L_FORUM' => $random_topic_row[$i]['forum_name'], 'U_TITLE' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $random_topic_row[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $random_topic_row[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $random_topic_row[$i]['post_id']) . '#p' . $random_topic_row[$i]['post_id'], 'L_TITLE' => $bbcode->parse(htmlspecialchars($random_topic_row[$i]['topic_title'])), 'L_BY' => $lang['By'], 'L_ON' => $lang['POSTED_ON'], 'S_POSTER' => colorize_username($random_topic_row[$i]['user_id'], $random_topic_row[$i]['username'], $random_topic_row[$i]['user_color'], $random_topic_row[$i]['user_active']), 'S_POSTTIME' => create_date_ip($config['default_dateformat'], $random_topic_row[$i]['post_time'], $config['board_timezone'])));
}
}
}
示例8: cms_block_online_users_chat
function cms_block_online_users_chat()
{
global $db, $cache, $config, $template, $theme, $images, $user, $lang, $table_prefix;
$ajax_chat_page = !empty($config['ajax_chat_link_type']) ? CMS_PAGE_AJAX_CHAT : CMS_PAGE_AJAX_SHOUTBOX;
$ajax_chat_link = !empty($config['ajax_chat_link_type']) ? append_sid($ajax_chat_page) . '" target="_chat' : '#" onclick="window.open(\'' . append_sid($ajax_chat_page) . '\', \'_chat\', \'width=720,height=600,resizable=yes\'); return false;';
$online_time = 300;
$cache_time = 600;
// Initialize data
$online_users_array = array('reg' => 0, 'guests' => 0, 'tot' => 0, 'list' => '', 'text' => '', 'users' => array(), 'user_ids' => array());
if (!function_exists('get_online_users')) {
@(include_once IP_ROOT_PATH . 'includes/functions_online.' . PHP_EXT);
}
$online_users_chat = get_online_users('chat', true, false, '', $online_time, $cache_time);
foreach ($online_users_chat as $online_user_chat_data) {
$uid = $online_user_chat_data['user_id'];
if (!in_array($uid, $online_users_array['user_ids'])) {
$online_users_array['user_ids'][] = $uid;
$online_users_array['users'][$uid] = array('user_id' => $online_user_chat_data['user_id'], 'username' => $online_user_chat_data['username'], 'username_clean' => $online_user_chat_data['username_clean'], 'user_color' => $online_user_chat_data['user_color'], 'user_active' => $online_user_chat_data['user_active'], 'user_allow_viewonline' => 1);
}
}
$online_users = get_online_users('site', true, false, '', $online_time, $cache_time);
foreach ($online_users as $online_user_data) {
$uid = $online_user_data['user_id'];
if (!in_array($uid, $online_users_array['user_ids'])) {
if ($online_user_data['user_allow_viewonline'] || $user->data['user_level'] == ADMIN || $user->data['user_id'] == $online_user_data['user_id']) {
$online_users_array['user_ids'][] = $uid;
$io = $online_user_data['user_allow_viewonline'] ? true : false;
$online_users_array['users'][$uid] = array('user_id' => $online_user_data['user_id'], 'username' => $online_user_data['username'], 'username_clean' => $online_user_data['username_clean'], 'user_color' => $online_user_data['user_color'], 'user_active' => $online_user_data['user_active'], 'user_allow_viewonline' => $online_user_data['user_allow_viewonline']);
}
}
}
$online_users_array['tot'] = sizeof($online_users_array['users']);
$online_users_array['text'] = empty($online_users_array['tot']) ? $lang['Reg_users_zero_total'] : ($online_users_array['tot'] == 1 ? $lang['Reg_user_total'] : sprintf($lang['Reg_users_total'], $online_users_array['tot']));
$online_users_text = '';
$switch_users_online = false;
if (empty($online_users_array['tot'])) {
$online_users_text = $lang['CHAT_NO_USERS'];
} else {
foreach ($online_users_array['users'] as $k => $online_user_data) {
$online_users_sort[$k] = $online_user_data['username_clean'];
}
asort($online_users_sort);
foreach ($online_users_sort as $k => $v) {
$cu = $online_users_array['users'][$k];
$io = $cu['user_allow_viewonline'] ? true : false;
$user_link = '';
if ($user->data['session_logged_in'] && $user->data['user_id'] != $cu['user_id']) {
$chat_room = 'chat_room=' . (min($user->data['user_id'], $cu['user_id']) . '|' . max($user->data['user_id'], $cu['user_id']));
$chat_link = append_sid($ajax_chat_page . '?' . $ajax_chat_room);
$user_link = !empty($config['ajax_chat_link_type']) ? $chat_link . '" target="_chat' : '#" onclick="window.open(\'' . $chat_link . '\', \'_chat\', \'width=720,height=600,resizable=yes\'); return false;';
}
$online_users_text .= (empty($online_users_text) ? '' : ', ') . ($io ? '' : '<em>') . colorize_username($cu['user_id'], $cu['username'], $cu['user_color'], $cu['user_active'], false, false, false, false, $user_link) . ($io ? '' : '</em>');
}
$switch_users_online = !empty($online_users_text) ? true : false;
}
$template->assign_vars(array('S_USERS_ONLINE' => $switch_users_online, 'B_ONLINE_USERS_TEXT' => $online_users_text, 'B_U_CHAT' => $ajax_chat_link));
}
示例9: cms_block_forum_attach
function cms_block_forum_attach()
{
global $db, $cache, $config, $template, $images, $lang, $bbcode, $block_id, $cms_config_vars;
if (!class_exists('class_topics')) {
include IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT;
}
$class_topics = new class_topics();
@(include_once IP_ROOT_PATH . ATTACH_MOD_PATH . 'displaying.' . PHP_EXT);
$template->_tpldata['articles_fp.'] = array();
$index_file = !empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : getenv('SCRIPT_NAME');
$index_file = htmlspecialchars(urldecode($index_file));
$template->set_filenames(array('forum_attach_block' => 'blocks/forum_attach_block.tpl'));
$template->assign_vars(array('L_COMMENTS' => $lang['Comments'], 'L_VIEW_COMMENTS' => $lang['View_comments'], 'L_POST_COMMENT' => $lang['Post_your_comment'], 'L_POSTED' => $lang['Posted'], 'L_ANNOUNCEMENT' => $lang['Post_Announcement'], 'L_REPLIES' => $lang['Replies'], 'L_REPLY_NEWS' => $lang['News_Reply'], 'L_PRINT_NEWS' => $lang['News_Print'], 'L_EMAIL_NEWS' => $lang['News_Email'], 'MINIPOST_IMG' => $images['icon_minipost'], 'NEWS_REPLY_IMG' => $images['news_reply'], 'NEWS_PRINT_IMG' => $images['news_print'], 'NEWS_EMAIL_IMG' => $images['news_email'], 'IMG_CLOCK' => $images['news_clock']));
// $only_auth_view must have the opposite value of $cms_config_vars['md_ignore_auth_view'][$block_id]
// Suggested by JHL - To Be Verified!
//$only_auth_view = (!empty($cms_config_vars['md_ignore_auth_view'][$block_id]) ? true : false);
$only_auth_view = !empty($cms_config_vars['md_ignore_auth_view'][$block_id]) || $cms_config_vars['md_ignore_auth_view'][$block_id] == true ? false : true;
if ($cms_config_vars['md_single_post_retrieve'][$block_id]) {
$single_post_id = request_var('post_id', 0);
if ($cms_config_vars['md_single_post_auto_id'][$block_id]) {
$single_post_id = !empty($single_post_id) ? $single_post_id : $cms_config_vars['md_single_post_id'][$block_id];
} else {
$single_post_id = $cms_config_vars['md_single_post_id'][$block_id];
}
// Mighty Gorgon: edited by JHL, I still need to check the impacts of this amendment
//$fetchposts = $class_topics->fetch_posts($single_post_id, 1, $cms_config_vars['md_single_post_length'][$block_id], false, false, true, $only_auth_view);
$fetchposts = $class_topics->fetch_posts($single_post_id, 1, $cms_config_vars['md_single_post_length'][$block_id], false, 0, true, $only_auth_view);
} else {
$fetchposts = $class_topics->fetch_posts($cms_config_vars['md_posts_forum_id'][$block_id], $cms_config_vars['md_num_posts'][$block_id], $cms_config_vars['md_posts_length'][$block_id], $cms_config_vars['md_posts_show_portal'][$block_id], $cms_config_vars['md_posts_random'][$block_id], false, $only_auth_view);
}
for ($i = 0; $i < sizeof($fetchposts); $i++) {
init_display_post_attachments($fetchposts[$i]['topic_attachment'], $fetchposts[$i], true, $block_id);
$open_bracket = '';
$close_bracket = '';
$read_full = '';
if ($fetchposts[$i]['striped'] == 1) {
$open_bracket = '[ ';
$close_bracket = ' ]';
$read_full = $lang['Read_Full'];
}
// Convert and clean special chars!
$topic_title = htmlspecialchars_clean($fetchposts[$i]['topic_title']);
$template->assign_block_vars('articles_fp', array('TOPIC_ID' => $fetchposts[$i]['topic_id'], 'FORUM_ID' => $fetchposts[$i]['forum_id'], 'TITLE' => $topic_title, 'POSTER' => $fetchposts[$i]['username'], 'POSTER_CG' => colorize_username($fetchposts[$i]['user_id'], $fetchposts[$i]['username'], $fetchposts[$i]['user_color'], $fetchposts[$i]['user_active']), 'TIME' => $fetchposts[$i]['topic_time'], 'TEXT' => $fetchposts[$i]['post_text'], 'REPLIES' => $fetchposts[$i]['topic_replies'], 'U_VIEW_COMMENTS' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id'] . '&' . POST_POST_URL . '=' . $fetchposts[$i]['post_id'] . '#p' . $fetchposts[$i]['post_id'], true), 'U_POST_COMMENT' => append_sid('posting.' . PHP_EXT . '?mode=reply&' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id']), 'U_PRINT_TOPIC' => append_sid('printview.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $fetchposts[$i]['forum_id'] . '&' . POST_TOPIC_URL . '=' . $fetchposts[$i]['topic_id'] . '&start=0'), 'U_EMAIL_TOPIC' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . urlencode(ip_utf8_decode($fetchposts[$i]['topic_title'])) . '&topic_id=' . $fetchposts[$i]['topic_id']), 'U_READ_FULL' => append_sid($index_file . '?article=' . $i), 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket));
display_attachments($fetchposts[$i]['post_id'], 'articles_fp');
}
}
示例10: display_comments
/**
*
* @Extra credits for this file
* Mohd - (mohdalbasri@hotmail.com)
*
*/
function display_comments(&$file_data)
{
global $pafiledb, $pafiledb_config, $pafiledb_functions;
global $db, $cache, $config, $template, $images, $user, $lang, $bbcode;
@(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
@(include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT);
$template->assign_vars(array('L_COMMENTS' => $lang['Comments']));
$sql = 'SELECT c.*, u.username, u.user_id, u.user_active, u.user_color, u.user_level, u.user_allow_viewemail, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm, u.user_skype, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_from, u.user_from_flag, u.user_rank, u.user_rank2, u.user_rank3, u.user_rank4, u.user_rank5, u.user_birthday, u.user_gender, u.user_allow_viewonline, u.user_lastvisit, u.user_session_time, u.user_style, u.user_lang
FROM ' . PA_COMMENTS_TABLE . ' AS c
LEFT JOIN ' . USERS_TABLE . " AS u ON c.poster_id = u.user_id\n\t\tWHERE c.file_id = '" . $file_data['file_id'] . "'\n\t\tORDER BY c.comments_time ASC";
$result = $db->sql_query($sql);
if (!($comment_number = $db->sql_numrows($result))) {
$template->assign_vars(array('L_NO_COMMENTS' => $lang['No_comments'], 'NO_COMMENTS' => true));
}
$ranks_array = $cache->obtain_ranks(false);
while ($comments_row = $db->sql_fetchrow($result)) {
$time = create_date_ip($config['default_dateformat'], $comments_row['comments_time'], $config['board_timezone']);
$comments_text = $comments_row['comments_text'];
$comments_text = comment_suite($comments_text);
$comments_text = censor_text($comments_text);
//bbcode parser Start
$bbcode->allow_html = $pafiledb_config['allow_html'] ? true : false;
$bbcode->allow_bbcode = $pafiledb_config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $pafiledb_config['allow_smilies'] ? true : false;
$comments_text = $bbcode->parse($comments_text);
//bbcode parser End
$poster = $comments_row['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($comments_row['user_id'], $comments_row['username'], $comments_row['user_color'], $comments_row['user_active']);
$user_info = array();
$user_info = generate_user_info($comments_row);
foreach ($user_info as $k => $v) {
${$k} = $v;
}
$poster_posts = $comments_row['user_id'] != ANONYMOUS ? $lang['Posts'] . ': ' . $comments_row['user_posts'] : '';
$poster_from = $user_info['from'];
$poster_joined = $user_info['joined'];
$poster_avatar = $user_info['avatar'];
// Mighty Gorgon - Multiple Ranks - BEGIN
$user_ranks = generate_ranks($comments_row, $ranks_array);
// Mighty Gorgon - Multiple Ranks - END
$comments_text = str_replace("\n", "\n<br />\n", $comments_text);
$template->assign_block_vars('text', array('POSTER' => $poster, 'U_COMMENT_DELETE' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? append_sid('dload.' . PHP_EXT . "?action=post_comment&cid={$comments_row['comments_id']}&delete=do&file_id={$file_data['file_id']}") : '', 'AUTH_COMMENT_DELETE' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'DELETE_IMG' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_delete_comment'] && $file_info['user_id'] == $user->data['user_id'] || $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_mod'] ? $images['icon_delpost'] : '', 'ICON_MINIPOST_IMG' => IP_ROOT_PATH . $images['icon_minipost'], 'ICON_SPACER' => IP_ROOT_PATH . $images['spacer'], 'GENDER' => $user_info['gender'], 'USER_RANK_01' => $user_ranks['rank_01_html'], 'USER_RANK_01_IMG' => $user_ranks['rank_01_img_html'], 'USER_RANK_02' => $user_ranks['rank_02_html'], 'USER_RANK_02_IMG' => $user_ranks['rank_02_img_html'], 'USER_RANK_03' => $user_ranks['rank_03_html'], 'USER_RANK_03_IMG' => $user_ranks['rank_03_img_html'], 'USER_RANK_04' => $user_ranks['rank_04_html'], 'USER_RANK_04_IMG' => $user_ranks['rank_04_img_html'], 'USER_RANK_05' => $user_ranks['rank_05_html'], 'USER_RANK_05_IMG' => $user_ranks['rank_05_img_html'], 'POSTER_JOINED' => $poster_joined, 'POSTER_POSTS' => $poster_posts, 'POSTER_FROM' => $poster_from, 'POSTER_AVATAR' => $poster_avatar, 'TITLE' => $comments_row['comments_title'], 'TIME' => $time, 'TEXT' => $comments_text));
}
$db->sql_freeresult($result);
$template->assign_vars(array('REPLY_IMG' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? $images['pa_comment_post'] : '', 'AUTH_POST' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? true : false, 'L_COMMENT_DO' => $pafiledb->modules[$pafiledb->module_name]->auth[$file_data['file_catid']]['auth_post_comment'] ? $lang['Comment_do'] : '', 'L_COMMENTS' => $lang['Comments'], 'L_AUTHOR' => $lang['Author'], 'L_POSTED' => $lang['Posted'], 'L_COMMENT_SUBJECT' => $lang['Comment_subject'], 'L_COMMENT_ADD' => $lang['Comment_add'], 'L_COMMENT_DELETE' => $lang['Comment_delete'], 'L_COMMENTS_NAME' => $lang['Name'], 'L_BACK_TO_TOP' => $lang['Back_to_top'], 'SPACER' => $images['spacer'], 'U_COMMENT_DO' => append_sid('dload.' . PHP_EXT . '?action=post_comment&file_id=' . $file_data['file_id'])));
}
示例11: cms_block_staff
function cms_block_staff()
{
global $db, $cache, $config, $template, $theme, $images, $user, $lang, $table_prefix;
$sql = "SELECT * FROM " . USERS_TABLE . "\n\t\t\tWHERE user_level <> 0\n\t\t\tORDER BY user_level";
$result = $db->sql_query($sql);
while ($db_select = $db->sql_fetchrow($result)) {
if ($db_select['user_level'] == JUNIOR_ADMIN || $db_select['user_level'] == ADMIN) {
$user_level = $lang['Memberlist_Administrator'];
} elseif ($db_select['user_level'] == MOD) {
$user_level = $lang['Memberlist_Moderator'];
}
$u_name = colorize_username($db_select['user_id'], $db_select['username'], $db_select['user_color'], $db_select['user_active']);
$l_name = $db_select[username];
$template->assign_block_vars('staff', array('USER_LEVEL' => $user_level, 'L_NAME' => $l_name, 'U_NAME' => $u_name));
}
$db->sql_freeresult($result);
$template->assign_vars(array('STAFF_NAME' => $lang['Staff'], 'STAFF_ADMIN' => $lang['Memberlist_Administrator'], 'STAFF_MOD' => $lang['Memberlist_Moderator']));
}
示例12: cms_block_top_posters
function cms_block_top_posters()
{
global $db, $cache, $config, $template, $lang, $block_id, $cms_config_vars;
include_once IP_ROOT_PATH . 'includes/functions_users.' . PHP_EXT;
$top_posters_n = intval($cms_config_vars['md_total_poster'][$block_id]) ? $cms_config_vars['md_total_poster'][$block_id] : 10;
$show_admins = true;
$show_mods = true;
$top_posters_array = top_posters($top_posters_n, $show_admins, $show_mods, true);
$show_avatars = $cms_config_vars['md_show_avatars'][$block_id] == true ? true : false;
$template->assign_var('S_SHOW_AVATARS', $show_avatars);
for ($i = 0; $i < sizeof($top_posters_array); $i++) {
$username2 = $top_posters_array[$i]['username'];
$username = colorize_username($top_posters_array[$i]['user_id'], $top_posters_array[$i]['username'], $top_posters_array[$i]['user_color'], $top_posters_array[$i]['user_active']);
$user_id = $top_posters_array[$i]['user_id'];
$posts = $top_posters_array[$i]['user_posts'] ? $top_posters_array[$i]['user_posts'] : 0;
$poster_avatar = user_get_avatar($top_posters_array[$i]['user_id'], $top_posters_array[$i]['user_level'], $top_posters_array[$i]['user_avatar'], $top_posters_array[$i]['user_avatar_type'], $top_posters_array[$i]['user_allowavatar']);
$template->assign_block_vars('topposter', array('USERNAME' => $username, 'POSTS' => $posts, 'AVATAR_IMG' => $poster_avatar, 'U_VIEWPOSTER' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&' . POST_USERS_URL . '=' . $user_id), 'U_VIEWPOSTS' => append_sid(CMS_PAGE_SEARCH . '?search_author=' . urlencode(ip_utf8_decode($username2)) . '&showresults=posts')));
}
}
示例13: while
{
$sql = "SELECT u.username, u.user_id, u.user_active, u.user_color, u.user_level, u.user_allow_viewemail, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_msnm, u.user_skype, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_from, u.user_from_flag, u.user_rank, u.user_rank2, u.user_rank3, u.user_rank4, u.user_rank5, u.user_birthday, u.user_gender, u.user_allow_viewonline, u.user_lastvisit, u.user_session_time, u.user_style, u.user_lang, tv.view_time, tv.view_count
FROM " . USERS_TABLE . " u, " . TOPIC_VIEW_TABLE . " tv
WHERE u.user_id = tv.user_id
AND tv.topic_id = " . $topic_id . "
" . $sql_hidden . "
GROUP BY tv.user_id
ORDER BY $order_by";
}
$result = $db->sql_query($sql);
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$user_id = $row['user_id'];
$username = colorize_username($row['user_id'], $row['username'], $row['user_color'], $row['user_active']);
$user_info = array();
$user_info = generate_user_info($row);
foreach ($user_info as $k => $v)
{
$$k = $v;
}
if (!empty($like))
{
$topic_time = ($row['like_time']) ? create_date($config['default_dateformat'], $row['like_time'], $config['board_timezone']) : $lang['Never_last_logon'];
$view_count = ' ';
}
else
{
示例14: main
//.........这里部分代码省略.........
$delete_search_ids = array();
while ($row = $db->sql_fetchrow($result)) {
$delete_search_ids[] = "'" . $row['session_id'] . "'";
}
if (sizeof($delete_search_ids)) {
$sql = "DELETE FROM " . SEARCH_TABLE . "\n\t\t\t\t\t\t\tWHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")";
$result = $db->sql_query($sql);
}
}
// Store new result data
$search_results = implode(', ', $search_ids);
$store_search_data = array();
for ($i = 0; $i < sizeof($store_vars); $i++) {
$store_search_data[$store_vars[$i]] = ${$store_vars}[$i];
}
$result_array = serialize($store_search_data);
unset($store_search_data);
mt_srand((double) microtime() * 1000000);
$search_id = mt_rand();
$sql = "UPDATE " . SEARCH_TABLE . "\n\t\t\t\t\tSET search_id = {$search_id}, search_array = '" . $db->sql_escape($result_array) . "'\n\t\t\t\t\tWHERE session_id = '" . $user->data['session_id'] . "'";
$db->sql_return_on_error(true);
$result = $db->sql_query($sql);
$db->sql_return_on_error(false);
if (!$result || !$db->sql_affectedrows()) {
$sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)\n\t\t\t\t\t\tVALUES({$search_id}, '" . $user->data['session_id'] . "', '" . $db->sql_escape($result_array) . "')";
$result = $db->sql_query($sql);
}
} else {
$search_id = intval($search_id);
if ($search_id) {
$sql = "SELECT search_array\n\t\t\t\t\t\tFROM " . SEARCH_TABLE . "\n\t\t\t\t\t\tWHERE search_id = {$search_id}\n\t\t\t\t\t\tAND session_id = '" . $user->data['session_id'] . "'";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
$search_data = unserialize($row['search_array']);
for ($i = 0; $i < sizeof($store_vars); $i++) {
${$store_vars}[$i] = $search_data[$store_vars[$i]];
}
}
}
}
if ($search_results != '') {
$sql = "SELECT f1.*, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, u.user_active, u.user_color, c.cat_id, c.cat_name, COUNT(cm.comments_id) AS total_comments\n\t\t\t\t\tFROM (" . PA_FILES_TABLE . " AS f1, " . PA_CATEGORY_TABLE . " AS c)\n\t\t\t\t\t\tLEFT JOIN " . PA_VOTES_TABLE . " AS r ON f1.file_id = r.votes_file\n\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id\n\t\t\t\t\t\tLEFT JOIN " . PA_COMMENTS_TABLE . " AS cm ON f1.file_id = cm.file_id\n\t\t\t\t\tWHERE f1.file_id IN ({$search_results})\n\t\t\t\t\tAND c.cat_id = f1.file_catid\n\t\t\t\t\tAND f1.file_approved = '1'\n\t\t\t\t\tGROUP BY f1.file_id\n\t\t\t\t\tORDER BY {$sort_method} {$sort_order}\n\t\t\t\t\tLIMIT {$limit_sql}";
$result = $db->sql_query($sql);
$searchset = array();
while ($row = $db->sql_fetchrow($result)) {
$searchset[] = $row;
}
$db->sql_freeresult($result);
$l_search_matches = $total_match_count == 1 ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count);
$template->assign_vars(array('L_SEARCH_MATCHES' => $l_search_matches));
for ($i = 0; $i < sizeof($searchset); $i++) {
$cat_url = append_sid('dload.' . PHP_EXT . '?action=category&cat_id=' . $searchset[$i]['cat_id']);
$file_url = append_sid('dload.' . PHP_EXT . '?action=file&file_id=' . $searchset[$i]['file_id']);
//===================================================
// Format the date for the given file
//===================================================
$date = create_date_ip($config['default_dateformat'], $searchset[$i]['file_time'], $config['board_timezone']);
//===================================================
// Get rating for the file and format it
//===================================================
//$rating = ($searchset[$i]['rating'] != 0) ? round($searchset[$i]['rating'], 2) . ' / 10' : $lang['Not_rated'];
//$rating2 = ($searchset[$i]['rating'] != 0) ? sprintf("%.1f", round(($searchset[$i]['rating']), 2) / 2) : '0.0';
$rating2 = $searchset[$i]['rating'] != 0 ? sprintf("%.1f", round($searchset[$i]['rating'], 0) / 2) : '0.0';
//===================================================
// If the file is new then put a new image in front of it
//===================================================
$is_new = false;
if (time() - $pafiledb_config['settings_newdays'] * 24 * 60 * 60 < $searchset[$i]['file_time']) {
$is_new = true;
}
$xs_new = $is_new ? '-new' : '';
//===================================================
// Get the post icon fot this file
//===================================================
if ($searchset[$i]['file_pin'] != FILE_PINNED) {
if ($searchset[$i]['file_posticon'] == 'none' || $searchset[$i]['file_posticon'] == 'none.gif') {
$posticon = '<img src="' . IP_ROOT_PATH . FILES_ICONS_DIR . 'default.png" alt="" />';
//$posticon = ' ';
} else {
$posticon = '<img src="' . FILES_ICONS_DIR . $searchset[$i]['file_posticon'] . '" alt="" />';
}
} else {
$posticon = '<img src="' . $images['forum_link'] . '" alt="" />';
}
$poster = $searchset[$i]['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($searchset[$i]['user_id'], $searchset[$i]['username'], $searchset[$i]['user_color'], $searchset[$i]['user_active']);
$template->assign_block_vars('searchresults', array('CAT_NAME' => $searchset[$i]['cat_name'], 'FILE_NEW_IMAGE' => $images['pa_file_new'], 'PIN_IMAGE' => $posticon, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'IS_NEW_FILE' => $is_new, 'FILE_NAME' => $searchset[$i]['file_name'], 'FILE_DESC' => $searchset[$i]['file_desc'], 'FILE_SUBMITER' => $poster, 'DATE' => $date, 'RATING' => $rating2, 'DOWNLOADS' => $searchset[$i]['file_dls'], 'U_FILE' => $file_url, 'U_CAT' => $cat_url));
}
$base_url = append_sid('dload.' . PHP_EXT . '?action=search&search_id=' . $search_id);
$template->assign_vars(array('PAGINATION' => generate_pagination($base_url, $total_match_count, $pafiledb_config['settings_file_page'], $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $pafiledb_config['settings_file_page']) + 1, ceil($total_match_count / $pafiledb_config['settings_file_page'])), 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'L_HOME' => $lang['Home'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATE' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_FILE' => $lang['File'], 'L_SUBMITER' => $lang['Submiter'], 'L_CATEGORY' => $lang['Category'], 'L_NEW_FILE' => $lang['New_file']));
$this->display($lang['Download'], 'pa_search_result.tpl');
} else {
message_die(GENERAL_MESSAGE, $lang['No_search_match']);
}
}
if (!isset($_POST['submit']) || $search_author == '' && $search_keywords == '' && !$search_id) {
$dropmenu = $this->jumpmenu_option();
$template->assign_vars(array('S_SEARCH_ACTION' => append_sid('dload.php'), 'S_CAT_MENU' => $dropmenu, 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SEARCH_OPTIONS' => $lang['Search_options'], 'L_SEARCH_KEYWORDS' => $lang['Search_keywords'], 'L_SEARCH_KEYWORDS_EXPLAIN' => $lang['Search_keywords_explain'], 'L_SEARCH_AUTHOR' => $lang['Search_author'], 'L_SEARCH_AUTHOR_EXPLAIN' => $lang['Search_author_explain'], 'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'], 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], 'L_INCLUDE_COMMENTS' => $lang['Include_comments'], 'L_SORT_BY' => $lang['Select_sort_method'], 'L_SORT_DIR' => $lang['Order'], 'L_SORT_ASCENDING' => $lang['Sort_Ascending'], 'L_SORT_DESCENDING' => $lang['Sort_Descending'], 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATING' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_UPDATE_TIME' => $lang['Update_time'], 'L_SEARCH' => $lang['Search'], 'L_SEARCH_FOR' => $lang['Search_for'], 'L_ALL' => $lang['All'], 'L_CHOOSE_CAT' => $lang['Choose_cat']));
$this->display($lang['Download'], 'pa_search_body.tpl');
}
}
示例15: main
function main($action)
{
global $db, $cache, $config, $images, $user, $lang, $bbcode, $pafiledb_config, $template, $pafiledb_functions;
@(include_once IP_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
$cat_id = request_var('cat_id', 0);
$file_id = request_var('file_id', 0);
$action = request_var('action', '');
if ($file_id == 0 && $action != '') {
$file_id_array = array();
$file_id_array = explode('=', $action);
$file_id = $file_id_array[1];
}
if (empty($file_id)) {
message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
}
// =======================================================
// file id is not set, give him/her a nice error message
// =======================================================
$sql = "SELECT f.*, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, u.user_active, u.user_color, COUNT(c.comments_id) as total_comments\n\t\t\tFROM " . PA_FILES_TABLE . " AS f\n\t\t\t\tLEFT JOIN " . PA_VOTES_TABLE . " AS r ON f.file_id = r.votes_file\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON f.user_id = u.user_id\n\t\t\t\tLEFT JOIN " . PA_COMMENTS_TABLE . " AS c ON f.file_id = c.file_id\n\t\t\tWHERE f.file_id = " . (int) $file_id . "\n\t\t\tAND f.file_approved = 1\n\t\t\tGROUP BY f.file_id ";
$result = $db->sql_query($sql);
//===================================================
// file doesn't exist'
//===================================================
if (!($file_data = $db->sql_fetchrow($result))) {
message_die(GENERAL_MESSAGE, $lang['File_not_exist']);
}
$db->sql_freeresult($result);
//===================================================
// Pafiledb auth for viewing file
//===================================================
if (!$this->auth[$file_data['file_catid']]['auth_view_file']) {
if (!$user->data['session_logged_in']) {
redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=file&file_id=' . $file_id, true));
}
$message = sprintf($lang['Sorry_auth_view'], $this->auth[$file_data['file_catid']]['auth_view_file_type']);
message_die(GENERAL_MESSAGE, $message);
}
$this->generate_category_nav($file_data['file_catid']);
$template->assign_vars(array('L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD_HOME' => append_sid('dload.' . PHP_EXT), 'FILE_NAME' => $file_data['file_name'], 'DOWNLOAD' => $pafiledb_config['settings_dbname']));
//===================================================
// Prepare file info to display them
//===================================================
$file_time = create_date_ip($config['default_dateformat'], $file_data['file_time'], $config['board_timezone']);
$file_last_download = $file_data['file_last'] ? create_date_ip($config['default_dateformat'], $file_data['file_last'], $config['board_timezone']) : $lang['never'];
$file_update_time = $file_data['file_update_time'] ? create_date_ip($config['default_dateformat'], $file_data['file_update_time'], $config['board_timezone']) : $lang['never'];
$file_author = trim($file_data['file_creator']);
$file_version = trim($file_data['file_version']);
$file_screenshot_url = trim($file_data['file_ssurl']);
$file_website_url = trim($file_data['file_docsurl']);
//$file_rating = ($file_data['rating'] != 0) ? round($file_data['rating'], 2) . ' / 10' : $lang['Not_rated'];
//$file_rating2 = ($file_data['rating'] != 0) ? sprintf("%.1f", round(($file_data['rating']), 2)/2) : '0.0';
$file_rating2 = $file_data['rating'] != 0 ? sprintf("%.1f", round($file_data['rating'], 0) / 2) : '0.0';
$file_download_link = $file_data['file_license'] > 0 ? append_sid('dload.' . PHP_EXT . '?action=license&license_id=' . $file_data['file_license'] . '&file_id=' . $file_id) : append_sid('dload.' . PHP_EXT . '?action=download&file_id=' . $file_id);
$file_size = $pafiledb_functions->get_file_size($file_id, $file_data);
/*
$file_poster = ($file_data['user_id'] != ANONYMOUS) ? '<a href="' . append_sid(CMS_PAGE_PROFILE.'?mode=viewprofile&' . POST_USERS_URL . '=' . $file_data['user_id']) . '">' : '';
$file_poster .= ($file_data['user_id'] != ANONYMOUS) ? $file_data['username'] : $lang['Guest'];
$file_poster .= ($file_data['user_id'] != ANONYMOUS) ? '</a>' : '';
*/
$file_poster = $file_data['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($file_data['user_id'], $file_data['username'], $file_data['user_color'], $file_data['user_active']);
$bbcode->allow_html = $config['allow_html'] ? true : false;
$bbcode->allow_bbcode = $config['allow_bbcode'] ? true : false;
$bbcode->allow_smilies = $config['allow_smilies'] ? true : false;
$file_long_desc = $bbcode->parse($file_data['file_longdesc']);
$template->assign_vars(array('L_CLICK_HERE' => $lang['Click_here'], 'L_AUTHOR' => $lang['Creator'], 'L_VERSION' => $lang['Version'], 'L_SCREENSHOT' => $lang['Scrsht'], 'L_WEBSITE' => $lang['Docs'], 'L_FILE' => $lang['File'], 'L_EDIT' => $lang['Editfile'], 'L_DELETE' => $lang['Deletefile'], 'L_DESC' => $lang['Desc'], 'L_VOTES' => $lang['Votes'], 'L_DATE' => $lang['Date'], 'L_UPDATE_TIME' => $lang['Update_time'], 'L_LASTTDL' => $lang['Lastdl'], 'L_DLS' => $lang['Dls'], 'L_RATING' => $lang['DlRating'], 'L_SIZE' => $lang['File_size'], 'L_DOWNLOAD' => $lang['Downloadfile'], 'L_RATE' => $lang['Rate'], 'L_EMAIL' => $lang['Emailfile'], 'L_SUBMITED_BY' => $lang['Submiter'], 'SHOW_AUTHOR' => !empty($file_author) ? true : false, 'SHOW_VERSION' => !empty($file_version) ? true : false, 'SHOW_SCREENSHOT' => !empty($file_screenshot_url) ? true : false, 'SHOW_WEBSITE' => !empty($file_website_url) ? true : false, 'SS_AS_LINK' => $file_data['file_sshot_link'] ? true : false, 'FILE_NAME' => $file_data['file_name'], 'FILE_LONGDESC' => $file_long_desc, 'FILE_SUBMITED_BY' => $file_poster, 'FILE_AUTHOR' => $file_author, 'FILE_VERSION' => $file_version, 'FILE_SCREENSHOT' => $file_screenshot_url, 'FILE_WEBSITE' => $file_website_url, 'AUTH_EDIT' => $this->auth[$file_data['file_catid']]['auth_edit_file'] && $file_data['user_id'] == $user->data['user_id'] || $this->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'AUTH_DELETE' => $this->auth[$file_data['file_catid']]['auth_delete_file'] && $file_data['user_id'] == $user->data['user_id'] || $this->auth[$file_data['file_catid']]['auth_mod'] ? true : false, 'AUTH_DOWNLOAD' => $this->auth[$file_data['file_catid']]['auth_download'] ? true : false, 'AUTH_RATE' => $this->auth[$file_data['file_catid']]['auth_rate'] ? true : false, 'AUTH_EMAIL' => $this->auth[$file_data['file_catid']]['auth_email'] ? true : false, 'INCLUDE_COMMENTS' => $this->auth[$file_data['file_catid']]['auth_view_comment'] ? true : false, 'DELETE_IMG' => $images['icon_delpost'], 'EDIT_IMG' => $images['icon_edit'], 'DOWNLOAD_IMG' => $images['pa_download'], 'RATE_IMG' => $images['pa_rate'], 'EMAIL_IMG' => $images['pa_email'], 'FILE_VOTES' => $file_data['total_votes'], 'TIME' => $file_time, 'UPDATE_TIME' => $file_data['file_update_time'] != $file_data['file_time'] ? $file_update_time : $lang['never'], 'RATING' => $file_rating2, 'FILE_DLS' => intval($file_data['file_dls']), 'FILE_SIZE' => $file_size, 'LAST' => $file_last_download, 'U_DELETE' => append_sid('dload.' . PHP_EXT . '?action=user_upload&do=delete&file_id=' . $file_id), 'U_EDIT' => append_sid('dload.' . PHP_EXT . '?action=user_upload&file_id=' . $file_id), 'U_DOWNLOAD' => $file_download_link, 'U_RATE' => append_sid('dload.' . PHP_EXT . '?action=rate&file_id=' . $file_id), 'U_EMAIL' => append_sid('dload.' . PHP_EXT . '?action=email&file_id=' . $file_id)));
$custom_fields = new custom_fields();
$custom_fields->custom_table = PA_CUSTOM_TABLE;
$custom_fields->custom_data_table = PA_CUSTOM_DATA_TABLE;
$custom_fields->init();
$custom_fields->display_data($file_id);
if ($this->auth[$file_data['file_catid']]['auth_view_comment']) {
include IP_ROOT_PATH . PA_FILE_DB_PATH . 'functions_comment.' . PHP_EXT;
display_comments($file_data);
}
$this->display($lang['Download'], 'pa_file_body.tpl');
}