Example #1
0
 function cms_block_tags()
 {
     global $db, $cache, $config, $template, $lang, $block_id, $cms_config_vars;
     $template->_tpldata['tags_loop.'] = array();
     // This block requires jquery_ui
     $config['jquery_ui'] = true;
     $sql_sort = empty($cms_config_vars['md_tags_words'][$block_id]) ? "l.tag_count DESC, l.tag_text ASC" : "RAND()";
     $sql_limit = (int) $cms_config_vars['md_tags_words'][$block_id];
     $sql_limit = $sql_limit < 0 || $sql_limit > 500 ? 50 : $sql_limit;
     $tags = array();
     $sql = "SELECT l.*\n\t\t\t\t\t\tFROM " . TOPICS_TAGS_LIST_TABLE . " l\n\t\t\t\t\t\tORDER BY " . $sql_sort . "\n\t\t\t\t\t\tLIMIT 0, " . $sql_limit;
     // Cache results for one our!
     $result = $db->sql_query($sql, 3600, 'tags_');
     $tags = $db->sql_fetchrowset($result);
     $db->sql_freeresult($result);
     $row_class = '';
     $i = 0;
     foreach ($tags as $tag) {
         $row_class = ip_zebra_rows($row_class);
         $tag_font_size = intval(mt_rand(8, 12));
         $template->assign_block_vars('tags_loop', array('CLASS' => $row_class, 'ROW_NUMBER' => $i + 1, 'U_TAG_TEXT' => append_sid(CMS_PAGE_TAGS . '?mode=view&amp;tag_text=' . htmlspecialchars(urlencode($tag['tag_text']))), 'TAG_TEXT' => htmlspecialchars($tag['tag_text']), 'TAG_FONT_SIZE' => $tag_font_size, 'TAG_COUNT' => $tag['tag_count']));
         $i++;
     }
     $template->assign_vars(array('U_TAGS_SEARCH_PAGE' => append_sid(CMS_PAGE_TAGS), 'U_TAGS' => append_sid(CMS_PAGE_TAGS), 'S_TAGS_BLOCK_ID' => $block_id, 'S_TAGS_SEARCH' => !empty($cms_config_vars['md_tags_search'][$block_id]) ? true : false, 'S_TAGS_COUNT' => !empty($cms_config_vars['md_tags_count'][$block_id]) ? true : false));
 }
Example #2
0
 function cms_block_top_likes()
 {
     global $db, $cache, $config, $template, $lang, $block_id, $cms_config_vars;
     $template->_tpldata['likes_row.'] = array();
     $topic_likes_hours = (int) $cms_config_vars['md_top_likes_hours'][$block_id];
     $topic_likes_hours = !empty($topic_likes_hours) ? $topic_likes_hours : 24;
     $topic_likes_timeframe = $topic_likes_hours * 60 * 60;
     $topic_likes_topics = (int) $cms_config_vars['md_top_likes_topics'][$block_id];
     $topic_likes_topics = !empty($topic_likes_topics) ? $topic_likes_topics : 10;
     $current_time = time();
     $delta_time = $current_time - $topic_likes_timeframe;
     $cache_expiry = 1 * 1 * 60 * 60;
     $topics_likes = $cache->get('_topics_likes_' . $cache_expiry);
     if ($topics_likes === false) {
         $topics_likes = array();
         $sql = "SELECT COUNT(tl.topic_id) AS likes_count, t.topic_id, t.topic_title\n\t\t\t\tFROM " . POSTS_LIKES_TABLE . " AS tl, " . TOPICS_TABLE . " AS t\n\t\t\t\tWHERE tl.like_time > " . (int) $delta_time . "\n\t\t\t\t\tAND t.topic_id = tl.topic_id\n\t\t\t\tGROUP BY tl.topic_id\n\t\t\t\tORDER BY likes_count DESC\n\t\t\t\tLIMIT 0, " . (int) $topic_likes_topics;
         $result = $db->sql_query($sql);
         $topics_likes = $db->sql_fetchrowset($result);
         $db->sql_freeresult($result);
         $cache->put('_topics_likes_' . $cache_expiry, $topics_likes, $cache_expiry);
     }
     $switch_topics_likes = false;
     if (!empty($topics_likes)) {
         $switch_topics_likes = true;
         $row_class = '';
         $i = 0;
         foreach ($topics_likes as $topic) {
             $topic_title = censor_text($topic['topic_title']);
             $topic_title = htmlspecialchars_clean($topic_title);
             $row_class = ip_zebra_rows($row_class);
             $template->assign_block_vars('likes_row', array('CLASS' => $row_class, 'ROW_NUMBER' => $i + 1, 'TOPIC_TITLE' => $topic_title, 'TOPIC_TITLE_SHORT' => strlen($topic_title) > 24 ? substr($topic_title, 0, 18) . '...' : $topic_title, 'U_TOPIC' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_TOPIC_URL . '=' . $topic['topic_id']), 'LIKES_COUNT' => $topic['likes_count']));
             $i++;
         }
     }
     $template->assign_vars(array('L_TOP_LIKES_NO_TOPICS_T' => sprintf($lang['TOP_LIKES_NO_TOPICS'], $topic_likes_hours), 'L_TOP_LIKES_DESC_T' => sprintf($lang['TOP_LIKES_DESC'], $topic_likes_hours), 'S_TOPICS_LIKES' => $switch_topics_likes, 'S_TOPICS_LIKES_COUNTER' => !empty($cms_config_vars['md_top_likes_counter'][$block_id]) ? true : false, 'S_TOPICS_LIKES_BLOCK_ID' => $block_id));
 }
Example #3
0
 if ($group_info['group_type'] == GROUP_HIDDEN && !$is_group_member && !$is_moderator) {
     // No group members
     $template->assign_block_vars('switch_hidden_group', array());
     $template->assign_vars(array('PAGINATION' => '&nbsp;', 'PAGE_NUMBER' => '&nbsp;', 'L_HIDDEN_MEMBERS' => $lang['Group_hidden_members']));
 }
 // We've displayed the members who belong to the group, now we do that pending memebers...
 if ($is_moderator) {
     // Users pending in ONLY THIS GROUP (which is moderated by this user)
     if ($modgroup_pending_count) {
         $row_class = '';
         for ($i = 0; $i < $modgroup_pending_count; $i++) {
             $username = $modgroup_pending_list[$i]['username'];
             $user_id = $modgroup_pending_list[$i]['user_id'];
             $user_info = array();
             $user_info = generate_user_info($modgroup_pending_list[$i], $config['default_dateformat'], $is_moderator);
             $row_class = ip_zebra_rows($row_class);
             $user_select = '<input type="checkbox" name="member[]" value="' . $user_id . '">';
             $template->assign_block_vars('pending_members_row', array('ROW_CLASS' => $row_class, 'USER_ID' => $user_id, 'USERNAME' => colorize_username($modgroup_pending_list[$i]['user_id'], $modgroup_pending_list[$i]['username'], $modgroup_pending_list[$i]['user_color'], $modgroup_pending_list[$i]['user_active']), 'FROM' => $user_info['from'], 'JOINED' => $user_info['joined'], 'POSTS' => $user_info['posts'], 'AVATAR_IMG' => $user_info['avatar'], 'AGE' => $user_info['age'], 'GENDER' => $user_info['gender'], 'STYLE' => $user_info['style'], 'PROFILE_IMG' => $user_info['profile_img'], 'PROFILE_URL' => $user_info['profile_url'], 'PROFILE' => $user_info['profile'], 'SEARCH_IMG' => $user_info['search_img'], 'SEARCH_URL' => $user_info['search_url'], 'SEARCH' => $user_info['search'], 'PM_IMG' => $user_info['pm_img'], 'PM_URL' => $user_info['pm_url'], 'PM' => $user_info['pm'], 'EMAIL_IMG' => $user_info['email_img'], 'EMAIL_URL' => $user_info['email_url'], 'EMAIL' => $user_info['email'], 'WWW_IMG' => $user_info['www_img'], 'WWW_URL' => $user_info['www_url'], 'WWW' => $user_info['www'], 'AIM_IMG' => $user_info['aim_img'], 'AIM_URL' => $user_info['aim_url'], 'AIM' => $user_info['aim'], 'ICQ_STATUS_IMG' => $user_info['icq_status_img'], 'ICQ_IMG' => $user_info['icq_img'], 'ICQ_URL' => $user_info['icq_url'], 'ICQ' => $user_info['icq'], 'MSN_IMG' => $user_info['msn_img'], 'MSN_URL' => $user_info['msn_url'], 'MSN' => $user_info['msn'], 'SKYPE_IMG' => $user_info['skype_img'], 'SKYPE_URL' => $user_info['skype_url'], 'SKYPE' => $user_info['skype'], 'YIM_IMG' => $user_info['yahoo_img'], 'YIM_URL' => $user_info['yahoo_url'], 'YIM' => $user_info['yahoo'], 'ONLINE_STATUS_IMG' => $user_info['online_status_img'], 'ONLINE_STATUS_CLASS' => $user_info['online_status_class'], 'ONLINE_STATUS_URL' => $user_info['online_status_url'], 'ONLINE_STATUS' => $user_info['online_status'], 'L_ONLINE_STATUS' => $user_info['online_status_lang'], 'U_VIEWPROFILE' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $user_id)));
         }
         $template->assign_block_vars('switch_pending_members', array());
         $template->assign_vars(array('L_SELECT' => $lang['Select'], 'L_APPROVE_SELECTED' => $lang['Approve_selected'], 'L_DENY_SELECTED' => $lang['Deny_selected']));
         $template->assign_var_from_handle('PENDING_USER_BOX', 'pendinginfo');
     }
 }
 if ($is_moderator) {
     $template->assign_block_vars('switch_mod_option', array());
     $template->assign_block_vars('switch_add_member', array());
 }
 if ($user->data['user_level'] == ADMIN) {
     $template->assign_block_vars('switch_mod_option.switch_admin', array());
 }
Example #4
0
 function show_layouts_list($is_layout_special)
 {
     global $db, $class_form, $template, $theme, $lang;
     $template->assign_block_vars('layout', array());
     $l_rows = $this->get_layouts_list();
     $l_count = sizeof($l_rows);
     $default_portal_id = 0;
     if (!$is_layout_special) {
         $sql = "SELECT config_value FROM " . $this->tables['block_config_table'] . " WHERE bid = '0' AND config_name = 'default_portal'";
         $result = $db->sql_query($sql);
         $c_row = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
         $default_portal_id = $c_row['config_value'];
     }
     $row_class = '';
     for ($i = 0; $i < $l_count; $i++) {
         $row_class = ip_zebra_rows($row_class);
         $layout_id = $l_rows[$i][$this->field_name];
         $layout_name = $is_layout_special ? isset($lang['auth_view_' . $l_rows[$i]['name']]) ? $lang['auth_view_' . $l_rows[$i]['name']] : (isset($lang['cms_page_name_' . strtolower($l_rows[$i]['name'])]) ? $lang['cms_page_name_' . strtolower($l_rows[$i]['name'])] : ucfirst($l_rows[$i]['name'])) : ucfirst($l_rows[$i]['name']);
         //$layout_name = htmlspecialchars($layout_name);
         $layout_filename = $l_rows[$i]['filename'];
         $layout_preview = $is_layout_special ? empty($layout_filename) ? '#' : append_sid($layout_filename) : (empty($layout_filename) ? CMS_PAGE_HOME . '?page=' . $layout_id : append_sid($layout_filename));
         $layout_locked = false;
         $select_name = 'auth_view_' . $layout_id;
         $default = $l_rows[$i]['view'];
         $select_js = '';
         if ($is_layout_special) {
             $layout_locked = !empty($l_rows[$i]['locked']) ? true : false;
             $options_array = array(AUTH_ALL, AUTH_REG, AUTH_MOD, AUTH_ADMIN);
             $options_langs_array = array($lang['B_ALL'], $lang['B_REG'], $lang['B_MOD'], $lang['B_ADMIN']);
         } else {
             $options_array = array(0, 1, 2, 3, 4);
             $options_langs_array = array($lang['B_ALL'], $lang['B_GUESTS'], $lang['B_REG'], $lang['B_MOD'], $lang['B_ADMIN']);
         }
         $auth_view_select_box = $class_form->build_select_box($select_name, $default, $options_array, $options_langs_array, $select_js);
         $template->assign_block_vars('layout.l_row', array('ROW_CLASS' => $row_class, 'ROW_DEFAULT_STYLE' => $layout_id == $default_portal_id ? 'font-weight: bold;' : '', 'LAYOUT_ID' => $layout_id, 'LAYOUT_NAME' => $layout_name, 'LAYOUT_FILENAME' => empty($layout_filename) ? $lang['None'] : htmlspecialchars($layout_filename), 'LAYOUT_BLOCKS' => $this->count_blocks_in_layout('\'' . $layout_id . '\'', $is_layout_special, true) . '/' . $this->count_blocks_in_layout('\'' . $layout_id . '\'', $is_layout_special, false), 'LAYOUT_TEMPLATE' => $l_rows[$i]['template'], 'LOCKED' => $layout_locked, 'PAGE_AUTH' => $auth_view_select_box, 'GB_CHECKED' => $l_rows[$i]['global_blocks'] ? ' checked="checked"' : '', 'BC_CHECKED' => $l_rows[$i]['page_nav'] ? ' checked="checked"' : '', 'U_PREVIEW_LAYOUT' => $layout_preview, 'U_EDIT_LAYOUT' => append_sid($this->root . '?mode=' . $this->mode . '&amp;' . $this->id_var_name . '=' . $layout_id . '&amp;action=edit'), 'U_EDIT_AUTH' => append_sid($this->root . '?mode=auth&amp;pmode=setting_cms_user_local&amp;id_type=' . ($is_layout_special ? 'layout_special' : 'layout') . '&amp;forum_id[]=' . $layout_id), 'U_DELETE_LAYOUT' => append_sid($this->root . '?mode=' . $this->mode . '&amp;' . $this->id_var_name . '=' . $layout_id . '&amp;action=delete'), 'U_LAYOUT' => append_sid($this->root . '?mode=' . $this->mode_blocks_name . '&amp;' . $this->id_var_name . '=' . $layout_id), 'U_COPY' => $is_layout_special ? '' : append_sid($this->root . '?mode=' . $this->mode . '&amp;' . $this->id_var_name . '=' . $layout_id . '&amp;action=clone')));
     }
     return true;
 }
Example #5
0
 function create_view_page(&$table_fields, &$inputs_array, $items_row, $template_row = 'field')
 {
     global $config, $template, $theme, $lang, $bbcode;
     $row_class = '';
     foreach ($table_fields as $k => $v) {
         $inputs_array[$k] = isset($items_row[$k]) ? $items_row[$k] : $v['default'];
         // We convert HTML entities only if we do not need to parse HTML...
         if (is_string($inputs_array[$k]) && !empty($v['html_parse'])) {
             $value = htmlspecialchars_decode($inputs_array[$k], ENT_COMPAT);
         }
         $auth_level = $v['view_level'];
         $is_auth = check_auth_level($auth_level);
         if ($is_auth) {
             $value = $inputs_array[$k];
             $s_bbcb = !empty($v['bbcode_box']) ? true : false;
             // SPECIAL PROCESSING - BEGIN
             // Convert back values from RADIO, SELECT or CHECKBOX
             if (in_array($v['type'], array('LIST_CHECKBOX', 'LIST_DROP', 'LIST_FLAGS', 'LIST_RADIO', 'LIST_RADIO_BR'))) {
                 $tmp_value = $this->get_lang_from_value($inputs_array[$k], $v['values']);
                 $value = $tmp_value != '' ? $tmp_value : $value;
             }
             // Convert empty numbers fields to 0
             if (!empty($v['is_number']) && empty($value)) {
                 $value = (int) 0;
             }
             // Apply number format if needed
             if (!empty($v['number_format'])) {
                 $v['number_format']['decimals'] = isset($v['number_format']['decimals']) ? $v['number_format']['decimals'] : (isset($lang['NUMBER_FORMAT_DECIMALS']) ? $lang['NUMBER_FORMAT_DECIMALS'] : 0);
                 $v['number_format']['decimals_sep'] = !empty($v['number_format']['decimals_sep']) ? $v['number_format']['decimals_sep'] : (isset($lang['NUMBER_FORMAT_DECIMALS_SEP']) ? $lang['NUMBER_FORMAT_DECIMALS_SEP'] : ',');
                 $v['number_format']['thousands_sep'] = !empty($v['number_format']['thousands_sep']) ? $v['number_format']['thousands_sep'] : (isset($lang['NUMBER_FORMAT_THOUSANDS_SEP']) ? $lang['NUMBER_FORMAT_THOUSANDS_SEP'] : '.');
                 $value = number_format($inputs_array[$k], $v['number_format']['decimals'], $v['number_format']['decimals_sep'], $v['number_format']['thousands_sep']);
             }
             // Create rating image
             if (!empty($v['is_rating'])) {
                 $rating = $value;
                 $rating_path = !empty($v['rating_path']) ? $v['rating_path'] : IP_ROOT_PATH . 'images/rates/';
                 $rating_min = !empty($v['rating_min']) ? $v['rating_min'] : 0;
                 $rating_max = !empty($v['rating_max']) ? $v['rating_max'] : 10;
                 $rating_extension = !empty($v['rating_extension']) ? $v['rating_extension'] : 'png';
                 $value = '<img src="' . $this->build_rating_image($rating, $rating_path, $rating_min, $rating_max, $rating_extension) . '" alt="' . $rating . '" title="' . $rating . '" />';
             }
             // Text processing... BBCode, HTML or plain text
             if ($s_bbcb || !empty($v['bbcode_parse'])) {
                 $value = $bbcode->parse($inputs_array[$k]);
             } else {
                 if (empty($v['html_parse']) && in_array($v['type'], array('TEXT', 'HTMLTEXT'))) {
                     $value = nl2br($inputs_array[$k]);
                 }
             }
             // Convert dates and times
             $v['datetime_format'] = !empty($v['datetime_format']) ? $v['datetime_format'] : 'unix';
             switch ($v['datetime_format']) {
                 case 'mysql':
                     $output = !empty($v['is_date']) ? 'date' : (!empty($v['is_time']) ? 'time' : 'datetime');
                     $value = format_date_mysql_php($inputs_array[$k], $output, 'php');
                     break;
                 default:
                     if (!empty($v['is_time'])) {
                         $value = create_date_ip($config['default_dateformat'], $inputs_array[$k], $config['board_timezone']);
                     }
                     if (!empty($v['is_date'])) {
                         $value = create_date($this->date_format_php, $inputs_array[$k], $config['board_timezone']);
                     }
                     break;
             }
             // Create user link (with user_id)
             if ($v['is_user_id']) {
                 $value = colorize_username($inputs_array[$k]);
             }
             // Create user link (with username)
             if ($v['is_username']) {
                 $target_userid = $this->get_user_id($inputs_array[$k]);
                 $value = colorize_username($target_userid);
             }
             // Create user link (with username)
             if ($v['type'] == 'PASSWORD') {
                 $value = '********';
             }
             // Create thumbnails for images
             if ($v['is_image']) {
                 $value = '<a href="' . append_sid($inputs_array[$k]) . '"><img src="' . append_sid(CMS_PAGE_IMAGE_THUMBNAIL . '?pic_id=' . urlencode($inputs_array[$k]) . (isset($v['thumbnail_size']) ? '&amp;thumbnail_size=' . intval($v['thumbnail_size']) : '')) . '" alt="" /></a>';
             }
             if (!empty($v['display_func']) && function_exists($v['display_func'])) {
                 $value = $v['display_func']($inputs_array[$k]);
             }
             // SPECIAL PROCESSING - END
             $row_class = ip_zebra_rows($row_class);
             $template_row = empty($template_row) ? 'field' : (string) $template_row;
             $template->assign_block_vars($template_row, array('CLASS' => $row_class, 'L_NAME' => $this->get_lang($v['lang_key']), 'L_EXPLAIN' => !empty($v['explain']) ? $this->get_lang($v['explain']) : '', 'S_BBCB' => $s_bbcb ? true : false, 'VALUE' => !empty($value) || $value === 0 ? $value : '&nbsp;'));
         }
     }
 }