function word_filter_get($uid, &$word_filter_array) { if (!($db = db::get())) { return false; } if (!is_numeric($uid)) { return false; } if (!is_array($word_filter_array)) { $word_filter_array = array(); } if (!($table_prefix = get_table_prefix())) { return false; } $sql = "SELECT FID, MATCH_TEXT, REPLACE_TEXT, FILTER_TYPE "; $sql .= "FROM `{$table_prefix}WORD_FILTER` "; $sql .= "WHERE UID = '{$uid}' AND FILTER_ENABLED = 1 "; $sql .= "ORDER BY FID "; if ($uid != 0) { $sql .= "LIMIT 0, 20"; } if (!($result = $db->query($sql))) { return false; } if ($result->num_rows == 0) { return false; } while ($word_filter_data = $result->fetch_assoc()) { $word_filter_array[] = $word_filter_data; } return true; }
/** * Standard modular run function. * * @return tempcode Results */ function run() { $out = new ocp_tempcode(); $tables = $GLOBALS['SITE_DB']->query_select('db_meta', array('DISTINCT m_table')); if (count($GLOBALS['SITE_DB']->connection_write) > 4) { $GLOBALS['SITE_DB']->connection_write = call_user_func_array(array($GLOBALS['SITE_DB']->static_ob, 'db_get_connection'), $GLOBALS['SITE_DB']->connection_write); _general_db_init(); } list($db, $db_name) = $GLOBALS['SITE_DB']->connection_write; mysql_select_db($db_name, $db); foreach ($tables as $table) { if ($table['m_table'] == 'sessions') { continue; } // HEAP, so can't be repaired $table = get_table_prefix() . $table['m_table']; // Check/Repair $result = mysql_query('CHECK TABLE ' . $table . ' FAST', $db); echo mysql_error($db); mysql_data_seek($result, mysql_num_rows($result) - 1); $status_row = mysql_fetch_assoc($result); if ($status_row['Msg_type'] != 'status') { $out->attach(paragraph(do_lang_tempcode('TABLE_ERROR', escape_html($table), escape_html($status_row['Msg_type']), array(escape_html($status_row['Msg_text']))), 'dfsdgdsgfgd')); $result2 = mysql_query('REPAIR TABLE ' . $table, $db); mysql_data_seek($result2, mysql_num_rows($result2) - 1); $status_row_2 = mysql_fetch_assoc($result2); $out->attach(paragraph(do_lang_tempcode('TABLE_FIXED', escape_html($table), escape_html($status_row_2['Msg_type']), array(escape_html($status_row_2['Msg_text']))), 'dfsdfgdst4')); } // Optimise mysql_unbuffered_query('OPTIMIZE TABLE ' . $table, $db); } return $out; }
function mods_list_forum_leaders() { if (!($db = db::get())) { return false; } $mod_list_array = array(); if (!($table_prefix = get_table_prefix())) { return false; } if (!($forum_fid = get_forum_fid())) { return false; } $user_perm_admin_tools = USER_PERM_ADMIN_TOOLS; $sql = "SELECT USERS.UID, USERS.LOGON, COALESCE(USER_PEER.PEER_NICKNAME, USERS.NICKNAME) AS NICKNAME "; $sql .= "FROM ((SELECT DISTINCT USER.UID, USER.LOGON, USER.NICKNAME FROM USER INNER JOIN GROUP_USERS "; $sql .= "ON (GROUP_USERS.UID = USER.UID) INNER JOIN GROUP_PERMS ON (GROUP_PERMS.GID = GROUP_USERS.GID) "; $sql .= "INNER JOIN GROUPS ON (GROUPS.GID = GROUP_PERMS.GID) WHERE GROUPS.FORUM IN (0, {$forum_fid}) "; $sql .= "AND GROUP_PERMS.FID IN (0) AND GROUP_PERMS.PERM & {$user_perm_admin_tools}) UNION ALL "; $sql .= "(SELECT DISTINCT USER.UID, USER.LOGON, USER.NICKNAME FROM USER INNER JOIN USER_PERM "; $sql .= "ON (USER_PERM.UID = USER.UID) WHERE USER_PERM.FORUM IN (0, {$forum_fid}) AND USER_PERM.FID IN (0) "; $sql .= "AND USER_PERM.PERM & {$user_perm_admin_tools} > 0)) AS USERS LEFT JOIN `{$table_prefix}USER_PEER` USER_PEER "; $sql .= "ON (USER_PEER.PEER_UID = USERS.UID AND USER_PEER.UID = {$_SESSION['UID']})"; if (!($result = $db->query($sql))) { return false; } if ($result->num_rows == 0) { return false; } while (($mod_list_data = $result->fetch_assoc()) !== null) { $mod_list_array[$mod_list_data['UID']] = $mod_list_data; } return $mod_list_array; }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { require_lang('activities'); require_code('activities'); list(, $whereville) = find_activities(get_member(), $_filters == '' ? 'all' : 'some_members', $_filters == '' ? NULL : array_map('intval', explode(',', $_filters))); $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'activities WHERE (' . $whereville . ') AND a_time>' . strval($cutoff) . ' ORDER BY a_time DESC', $max, 0); $content = new ocp_tempcode(); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['a_member_id']); if (is_null($author)) { $author = do_lang('UNKNOWN'); } $news_date = date($date_string, $row['a_time']); $edit_date = ''; list($_title, ) = render_activity($row); $news_title = xmlentities($_title->evaluate()); $summary = xmlentities(''); $news = ''; $category = ''; $category_raw = ''; $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $row['a_member_id']), get_module_zone('members'), NULL, false, false, true); $if_comments = new ocp_tempcode(); $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } return array($content, do_lang('ACTIVITIES_TITLE')); }
function user_get_relationship($uid, $peer_uid) { if (!($db = db::get())) { return 0; } if (!is_numeric($uid)) { return 0; } if (!is_numeric($peer_uid)) { return 0; } if (!($table_prefix = get_table_prefix())) { return 0; } $sql = "SELECT RELATIONSHIP FROM `{$table_prefix}USER_PEER` "; $sql .= "WHERE UID = '{$uid}' AND PEER_UID = '{$peer_uid}'"; if (!($result = $db->query($sql))) { return 0; } if ($result->num_rows == 0) { return 0; } list($peer_relationship) = $result->fetch_row(); return $peer_relationship; }
/** * Standard modular run function for OcCLE notification hooks. * * @param ?integer The "current" time on which to base queries (NULL: now) * @return ~array Array of section, type and message responses (false: nothing) */ function run($timestamp = NULL) { if (!addon_installed('chat')) { return false; } if (!is_null(get_value('occle_watched_chatroom'))) { require_lang('chat'); if (is_null($timestamp)) { $timestamp = time(); } $room = intval(get_value('occle_watched_chatroom')); $room_messages = $GLOBALS['SITE_DB']->query('SELECT COUNT(*) AS cnt FROM ' . get_table_prefix() . 'chat_messages WHERE room_id=' . strval($room) . ' AND date_and_time>=' . strval((int) $timestamp)); if (!array_key_exists(0, $room_messages)) { return false; } if ($room_messages[0]['cnt'] > 0) { $rooms = array(); $messages = $room_messages[0]['cnt']; $room_data = $GLOBALS['SITE_DB']->query_value_null_ok('chat_rooms', 'room_name', array('id' => $room)); if (is_null($room_data)) { return false; } // Selected room deleted $rooms[$room_data] = build_url(array('page' => 'chat', 'type' => 'room', 'id' => $room), get_module_zone('chat')); return array(do_lang('SECTION_CHAT'), do_lang('NEW_MESSAGES'), do_template('OCCLE_CHAT_NOTIFICATION', array('MESSAGE_COUNT' => integer_format($messages), 'ROOMS' => $rooms))); } else { return false; } } else { return false; } }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!addon_installed('stats')) { return; } $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * intval(get_option('stats_store_time')))); }
/** * Standard modular run function for newsletter hooks. * * @param TIME The time that the entries found must be newer than * @param LANGUAGE_NAME The language the entries found must be in * @param string Category filter to apply * @param BINARY Whether to use full article instead of summary * @return array Tuple of result details */ function run($cutoff_time, $lang, $filter, $in_full = 1) { if (!addon_installed('news')) { return array(); } require_lang('news'); $new = new ocp_tempcode(); require_code('ocfiltering'); $or_list = ocfilter_to_sqlfragment($filter, 'news_category'); $or_list_2 = ocfilter_to_sqlfragment($filter, 'news_entry_category'); $rows = $GLOBALS['SITE_DB']->query('SELECT title,news,news_article,id,date_and_time,submitter FROM ' . get_table_prefix() . 'news LEFT JOIN ' . get_table_prefix() . 'news_category_entries ON news_entry=id WHERE validated=1 AND date_and_time>' . strval((int) $cutoff_time) . ' AND ((' . $or_list . ') OR (' . $or_list_2 . ')) ORDER BY date_and_time DESC', 300); if (count($rows) == 300) { return array(); } $rows = remove_duplicate_rows($rows, 'id'); foreach ($rows as $row) { $_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true); $url = $_url->evaluate(); $name = get_translated_text($row['title'], NULL, $lang); $description = get_translated_text($row[$in_full == 1 ? 'news_article' : 'news'], NULL, $lang); if ($description == '') { $description = get_translated_text($row[$in_full == 1 ? 'news' : 'news_article'], NULL, $lang); } $member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']); $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '4eaf5ec00db1f0b89cef5120c2486521', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description))); } return array($new, do_lang('NEWS', '', '', '', $lang)); }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $sup = get_param('block_map_sup', '', true); $_map = get_param('block_map', false, true); if ($sup != '') { $_map .= ',' . $sup; } require_code('blocks'); $map = block_params_str_to_arr($_map); if (!array_key_exists('block', $map)) { return new ocp_tempcode(); } $auth_key = get_param_integer('auth_key'); // Check permissions $test = $GLOBALS['SITE_DB']->query_value_null_ok('temp_block_permissions', 'p_block_constraints', array('p_session_id' => get_session_id(), 'id' => $auth_key)); if (is_null($test) || !block_signature_check(block_params_str_to_arr($test), $map)) { require_lang('permissions'); return paragraph(do_lang_tempcode('ACCESS_DENIED__ACCESS_DENIED', escape_html($map['block']))); } // Cleanup $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'temp_block_permissions WHERE p_time<' . strval(time() - 60 * 60 * intval(get_option('session_expiry_time')))); // Return block snippet global $CSSS, $JAVASCRIPTS; $CSSS = array(); $JAVASCRIPTS = array(); $out = new ocp_tempcode(); $out->attach(symbol_tempcode('CSS_TEMPCODE')); $out->attach(symbol_tempcode('JS_TEMPCODE')); $out->attach(do_block($map['block'], $map)); return $out; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('downloads'); require_css('downloads'); require_lang('downloads'); require_code('ocfiltering'); $number = array_key_exists('param', $map) ? intval($map['param']) : 10; $filter = array_key_exists('filter', $map) ? $map['filter'] : '*'; $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('downloads'); $sql_filter = ocfilter_to_sqlfragment($filter, 'p.category_id', 'download_categories', 'parent_id', 'p.category_id', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'download_downloads p WHERE validated=1 AND (' . $sql_filter . ') ORDER BY add_date DESC', $number); $title = do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('SECTION_DOWNLOADS')); if (array_key_exists('title', $map) && $map['title'] != '') { $title = protect_from_escaping(escape_html($map['title'])); } $out = new ocp_tempcode(); foreach ($rows as $i => $row) { if ($i != 0) { $out->attach(do_template('BLOCK_SEPARATOR')); } $out->attach(get_download_html($row, true, true, $zone)); } if ($out->is_empty()) { if (has_actual_page_access(NULL, 'cms_downloads', NULL, NULL) && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_downloads')) { $submit_url = build_url(array('page' => 'cms_downloads', 'type' => 'ad', 'redirect' => SELF_REDIRECT), get_module_zone('cms_downloads')); } else { $submit_url = new ocp_tempcode(); } return do_template('BLOCK_NO_ENTRIES', array('_GUID' => '74399763a51102bdd6e6d92c2c11354f', 'HIGH' => false, 'TITLE' => $title, 'MESSAGE' => do_lang_tempcode('NO_DOWNLOADS_YET'), 'ADD_NAME' => do_lang_tempcode('ADD_DOWNLOAD'), 'SUBMIT_URL' => $submit_url)); } return do_template('BLOCK_MAIN_RECENT_DOWNLOADS', array('_GUID' => '257fa1b83d1b6fe3acbceb2b618e6d7f', 'TITLE' => $title, 'CONTENT' => $out, 'NUMBER' => integer_format($number))); }
/** * Standard modular run function for newsletter hooks. * * @param TIME The time that the entries found must be newer than * @param LANGUAGE_NAME The language the entries found must be in * @param string Category filter to apply * @return array Tuple of result details */ function run($cutoff_time, $lang, $filter) { $new = new ocp_tempcode(); require_code('ocfiltering'); if ($filter == '') { $filter = ','; } // Just welcome zone $or_list = ocfilter_to_sqlfragment($filter, 'b.the_zone', NULL, NULL, NULL, NULL, false); $_rows = $GLOBALS['SITE_DB']->query('SELECT a.* FROM ' . get_table_prefix() . 'cached_comcode_pages a JOIN ' . get_table_prefix() . 'comcode_pages b ON a.the_page=b.the_page AND a.the_zone=b.the_zone WHERE p_add_date>' . strval($cutoff_time) . ' AND (' . $or_list . ')', 300); if (count($_rows) == 300) { return array(); } $rows = array(); foreach ($_rows as $row) { $rows[$row['the_zone'] . ':' . $row['the_page']] = $row; } $_rows2 = $GLOBALS['SITE_DB']->query_select('seo_meta', array('*'), array('meta_for_type' => 'comcode_page')); $rows2 = array(); foreach ($_rows2 as $row) { $rows2[$row['meta_for_id']] = $row; } $zones = explode(',', $filter); //find_all_zones(); foreach ($zones as $zone) { if ($zone == 'cms') { continue; } if ($zone == 'adminzone') { continue; } $pages = find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, $cutoff_time); foreach (array_keys($pages) as $page) { if (!is_string($page)) { $page = strval($page); } // PHP can be weird when things like '404' are put in arrays if (substr($page, 0, 6) == 'panel_') { continue; } $id = $zone . ':' . $page; $_url = build_url(array('page' => $page), $zone, NULL, false, false, true); $url = $_url->evaluate(); $name = ucfirst(str_replace('_', ' ', $page)); if (array_key_exists($id, $rows)) { $_name = get_translated_text($rows[$id]['cc_page_title'], NULL, NULL, true); if (!is_null($_name)) { $name = $_name; } } $description = ''; $member_id = NULL; if (array_key_exists($id, $rows2)) { $description = get_translated_text($rows2[$id]['meta_description']); } $new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => '67f165847dacd54d2965686d561b57ee', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description))); } } return array($new, do_lang('PAGES', '', '', '', $lang)); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!addon_installed('galleries')) { return NULL; } if (!has_actual_page_access(get_member(), 'galleries')) { return NULL; } $filters_1 = ocfilter_to_sqlfragment($_filters, 'name', 'galleries', 'parent_id', 'name', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters = ocfilter_to_sqlfragment($_filters, 'cat', 'galleries', 'parent_id', 'cat', 'name', false, false); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) require_lang('galleries'); $content = new ocp_tempcode(); $_galleries = array(); if ($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1) < 3000) { $_galleries = $GLOBALS['SITE_DB']->query('SELECT fullname,name FROM ' . get_table_prefix() . 'galleries WHERE ' . $filters_1); foreach ($_galleries as $i => $_gallery) { $_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']); } } $galleries = collapse_2d_complexity('name', 'text_original', $_galleries); $rows1 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows2 = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images WHERE add_date>' . strval((int) $cutoff) . ' AND ' . $filters . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' ORDER BY add_date DESC', $max); $rows = array_merge($rows1, $rows2); foreach ($rows as $row) { $id = strval($row['id']); $author = $GLOBALS['FORUM_DRIVER']->get_username($row['submitter']); if (is_null($author)) { $author = ''; } $news_date = date($date_string, $row['add_date']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $news_title = xmlentities(do_lang('THIS_WITH_SIMPLE', array_key_exists('video_views', $row) ? do_lang('VIDEO') : do_lang('IMAGE'), strval($row['id']))); $_summary = get_translated_tempcode($row['comments']); $summary = xmlentities($_summary->evaluate()); $news = ''; if (!array_key_exists($row['cat'], $galleries)) { $_fullname = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'fullname', array('name' => $row['cat'])); if (is_null($_fullname)) { continue; } $galleries[$row['cat']] = get_translated_text($_fullname); } $category = $galleries[$row['cat']]; $category_raw = $row['cat']; $view_url = build_url(array('page' => 'galleries', 'type' => array_key_exists('video_views', $row) ? 'video' : 'image', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= '1') { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => '65dc0cec8c75f565c58c95fa1667aa1e', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } require_code('images'); $enclosure_url = ensure_thumbnail($row['url'], $row['thumb_url'], 'galleries', array_key_exists('video_views', $row) ? 'videos' : 'images', $row['id']); list($enclosure_length, $enclosure_type) = get_enclosure_details($row['url'], $enclosure_url); $content->attach(do_template($prefix . 'ENTRY', array('ENCLOSURE_URL' => $enclosure_url, 'ENCLOSURE_LENGTH' => $enclosure_length, 'ENCLOSURE_TYPE' => $enclosure_type, 'VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } require_lang('galleries'); return array($content, do_lang('GALLERIES')); }
/** * Standard modular run function for RSS hooks. * * @param string A list of categories we accept from * @param TIME Cutoff time, before which we do not show results from * @param string Prefix that represents the template set we use * @set RSS_ ATOM_ * @param string The standard format of date to use for the syndication type represented in the prefix * @param integer The maximum number of entries to return, ordering by date * @return ?array A pair: The main syndication section, and a title (NULL: error) */ function run($_filters, $cutoff, $prefix, $date_string, $max) { if (!addon_installed('news')) { return NULL; } if (!has_actual_page_access(get_member(), 'news')) { return NULL; } $filters_1 = ocfilter_to_sqlfragment($_filters, 'p.news_category', 'news_categories', NULL, 'p.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters_2 = ocfilter_to_sqlfragment($_filters, 'd.news_entry_category', 'news_categories', NULL, 'd.news_category', 'id'); // Note that the parameters are fiddled here so that category-set and record-set are the same, yet SQL is returned to deal in an entirely different record-set (entries' record-set) $filters = '(' . $filters_1 . ' OR ' . $filters_2 . ')'; $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'news p LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id WHERE date_and_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND validated=1 ' : '') . ' AND ' . $filters . (can_arbitrary_groupby() ? ' GROUP BY p.id' : '') . ' ORDER BY date_and_time DESC', $max); $rows = remove_duplicate_rows($rows, 'id'); $_categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id', 'nc_title'), array('nc_owner' => NULL)); foreach ($_categories as $i => $_category) { $_categories[$i]['text_original'] = get_translated_text($_category['nc_title']); } $categories = collapse_2d_complexity('id', 'text_original', $_categories); $content = new ocp_tempcode(); foreach ($rows as $row) { if (has_category_access(get_member(), 'news', strval($row['news_category']))) { $id = strval($row['id']); $author = $row['author']; $news_date = date($date_string, $row['date_and_time']); $edit_date = is_null($row['edit_date']) ? '' : date($date_string, $row['edit_date']); $_title = get_translated_tempcode($row['title']); $news_title = xmlentities($_title->evaluate()); $_summary = get_translated_tempcode($row['news']); if ($_summary->is_empty()) { $_summary = get_translated_tempcode($row['news_article']); } $summary = xmlentities($_summary->evaluate()); if (!is_null($row['news_article'])) { $_news = get_translated_tempcode($row['news_article']); if ($_news->is_empty()) { $news = ''; } else { $news = xmlentities($_news->evaluate()); } } else { $news = ''; } if (!array_key_exists($row['news_category'], $categories)) { $categories[$row['news_category']] = get_translated_text($GLOBALS['SITE_DB']->query_value('news_categories', 'nc_title', array('id' => $row['news_category']))); } $category = $categories[$row['news_category']]; $category_raw = strval($row['news_category']); $view_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $row['id']), get_module_zone('news'), NULL, false, false, true); if ($prefix == 'RSS_' && get_option('is_on_comments') == '1' && $row['allow_comments'] >= 1) { $if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'b4f25f5cf68304f8d402bb06851489d6', 'COMMENT_URL' => $view_url, 'ID' => strval($row['id']))); } else { $if_comments = new ocp_tempcode(); } $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date))); } } return array($content, do_lang('NEWS')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { if (!array_key_exists('param', $map)) { $map['param'] = ''; } if (!array_key_exists('extra', $map)) { $map['extra'] = ''; } $max = array_key_exists('max', $map) ? intval($map['max']) : 100; require_code('banners'); $b_type = $map['param']; $myquery = 'SELECT * FROM ' . get_table_prefix() . 'banners WHERE ((((the_type<>1) OR ((campaign_remaining>0) AND ((expiry_date IS NULL) or (expiry_date>' . strval(time()) . ')))) AND ' . db_string_not_equal_to('name', '') . ')) AND validated=1 AND ' . db_string_equal_to('b_type', $b_type) . ' ORDER BY name'; $banners = $GLOBALS['SITE_DB']->query($myquery, 200); $assemble = new ocp_tempcode(); if (count($banners) > $max) { shuffle($banners); $banners = array_slice($banners, 0, $max); } foreach ($banners as $i => $banner) { $bd = show_banner($banner['name'], $banner['b_title_text'], get_translated_tempcode($banner['caption']), $banner['img_url'], '', $banner['site_url'], $banner['b_type']); $more_coming = $i < count($banners) - 1; $assemble->attach(do_template('BLOCK_MAIN_BANNER_WAVE_BWRAP', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'BANNER' => $bd, 'MORE_COMING' => $more_coming))); } return do_template('BLOCK_MAIN_BANNER_WAVE', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'ASSEMBLE' => $assemble)); }
/** * A page is not validated, so show a warning. * * @param ID_TEXT The zone the page is being loaded from * @param ID_TEXT The codename of the page * @param tempcode The edit URL (blank if no edit access) * @return tempcode The warning */ function get_page_warning_details($zone, $codename, $edit_url) { $warning_details = new ocp_tempcode(); if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated'); } $uv_warning = do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT'); // Wear sun cream if (!$edit_url->is_empty()) { $menu_links = $GLOBALS['SITE_DB']->query('SELECT DISTINCT i_menu FROM ' . get_table_prefix() . 'menu_items WHERE ' . db_string_equal_to('i_url', $zone . ':' . $codename) . ' OR ' . db_string_equal_to('i_url', '_SEARCH:' . $codename)); if (count($menu_links) != 0) { $menu_items_linking = new ocp_tempcode(); foreach ($menu_links as $menu_link) { if (!$menu_items_linking->is_empty()) { $menu_items_linking->attach(do_lang_tempcode('LIST_SEP')); } $menu_edit_url = build_url(array('page' => 'admin_menus', 'type' => 'edit', 'id' => $menu_link['i_menu']), get_module_zone('admin_menus')); $menu_items_linking->attach(hyperlink($menu_edit_url, $menu_link['i_menu'], false, true)); } $uv_warning = do_lang_tempcode('UNVALIDATED_TEXT_STAFF', $menu_items_linking); } } $warning_details->attach(do_template('WARNING_TABLE', array('WARNING' => $uv_warning))); return $warning_details; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('news'); $categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $content = new ocp_tempcode(); $categories2 = array(); foreach ($categories as $category) { if (has_category_access(get_member(), 'news', strval($category['id']))) { $join = ' LEFT JOIN ' . get_table_prefix() . 'news_category_entries d ON d.news_entry=p.id'; $count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'news p' . $join . ' WHERE validated=1 AND (news_entry_category=' . strval($category['id']) . ' OR news_category=' . strval($category['id']) . ') ORDER BY date_and_time DESC'); if ($count > 0) { $category['_nc_title'] = get_translated_text($category['nc_title']); $categories2[] = $category; } } } if (count($categories2) == 0) { global $M_SORT_KEY; $M_SORT_KEY = '_nc_title'; usort($categories2, 'multi_sort'); foreach ($categories as $category) { if (has_category_access(get_member(), 'news', strval($category['id']))) { $categories2[] = $category; } } } foreach ($categories2 as $category) { $url = build_url(array('page' => 'news', 'type' => 'misc', 'id' => $category['id']), get_module_zone('news')); $name = $category['_nc_title']; $content->attach(do_template('BLOCK_SIDE_NEWS_CATEGORIES_CATEGORY', array('_GUID' => 'fee49cac370ec00fc59d2e9c66b6255a', 'URL' => $url, 'NAME' => $name, 'COUNT' => integer_format($count)))); } return do_template('BLOCK_SIDE_NEWS_CATEGORIES', array('_GUID' => 'b47a0047247096373e5aa626348c4ebb', 'CONTENT' => $content, 'PRE' => '', 'POST' => '')); }
/** * Get the number of polls in the queue. * * @return integer Number in queue */ function get_num_poll_queue() { $c = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'poll WHERE votes1+votes2+votes3+votes4+votes5+votes6+votes7+votes8+votes9+votes10=0 AND is_current=0'); if (is_null($c)) { return 0; } return $c; }
/** * Get the number of people using the chat system at the moment. Note that this is intentionally different from 'users online' even if site wide IM is enabled- it has a 60 second timeout, so it really is active people. * * @return integer The number of people on the chat system */ function get_num_chatters() { // We need to get all the messages that were posted in the last x minutes, and count them if (!defined('CHAT_ACTIVITY_PRUNE')) { define('CHAT_ACTIVITY_PRUNE', 25); } return $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT member_id) FROM ' . get_table_prefix() . 'chat_active a LEFT JOIN ' . get_table_prefix() . 'sessions s ON s.the_user=a.member_id WHERE session_invisible=0 AND date_and_time>=' . strval((int) time() - CHAT_ACTIVITY_PRUNE)); }
/** * Get the number of flagrant text messages in the queue. * * @return integer Number in queue */ function get_num_flagrant_queue() { $c = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'text WHERE activation_time IS NULL'); if (is_null($c)) { return 0; } return $c; }
/** * Get a list of all the notification codes this hook can handle. * (Addons can define hooks that handle whole sets of codes, so hooks are written so they can take wide authority) * * @return array List of codes (mapping between code names, and a pair: section and labelling for those codes) */ function list_handled_codes() { $list = array(); $catalogues = $GLOBALS['SITE_DB']->query('SELECT c_name,c_title FROM ' . get_table_prefix() . 'catalogues WHERE ' . db_string_not_equal_to('c_send_view_reports', 'never')); foreach ($catalogues as $catalogue) { $list['catalogue_view_reports__' . $catalogue['c_name']] = array(do_lang('GENERAL'), do_lang('NOTIFICATION_TYPE_catalogue_view_reports', get_translated_text($catalogue['c_title']))); } return $list; }
/** * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system. * * @return array Array of links and where to show */ function run() { if (!addon_installed('news')) { return array(); } $cnt = $GLOBALS['SITE_DB']->query_value_null_ok('news', 'COUNT(*)', NULL, '', true); $cnt_blogs = $cnt - $GLOBALS['SITE_DB']->query_value_null_ok('news n LEFT JOIN ' . get_table_prefix() . 'news_categories c ON c.id=n.news_category', 'COUNT(*)', array('nc_owner' => NULL), '', true); return array(array('cms', 'news', array('cms_news', array('type' => 'misc'), get_module_zone('cms_news')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('NEWS'), make_string_tempcode(escape_html(integer_format($cnt)))), 'DOC_NEWS'), array('cms', 'news', array('cms_blogs', array('type' => 'misc'), get_module_zone('cms_blogs')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('BLOGS'), make_string_tempcode(escape_html(integer_format($cnt_blogs)))), 'DOC_BLOGS')); }
/** * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in. * * @param boolean Whether to simplify the banner interface (for the point-store buy process) * @param ID_TEXT The name of the banner * @param URLPATH The URL to the banner image * @param URLPATH The URL to the site the banner leads to * @param SHORT_TEXT The caption of the banner * @param LONG_TEXT Any notes associated with the banner * @param integer The banners "importance modulus" * @range 1 max * @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type) * @range 0 max * @param SHORT_INTEGER The type of banner (0=permanent, 1=campaign, 2=default) * @set 0 1 2 * @param ?TIME The banner expiry date (NULL: never expires) * @param ?ID_TEXT The username of the banners submitter (NULL: current member) * @param BINARY Whether the banner has been validated * @param ID_TEXT The banner type (can be anything, where blank means 'normal') * @param SHORT_TEXT The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline) * @return tempcode The input field tempcode */ function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '') { require_code('images'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true)); $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false)); // Blank implies iframe if (!$simplified) { $types = nice_get_banner_types($b_type); if ($types->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false)); } else { $fields->attach(form_input_hidden('b_type', $b_type)); } if (has_specific_permission(get_member(), 'full_banner_setup')) { $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false)); } if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) { if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA')))); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf'))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION')))); if (has_specific_permission(get_member(), 'full_banner_setup')) { $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT'))); $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios)); $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false)); $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name)); if (is_null($total_importance)) { $total_importance = 0; } $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true)); } $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2)); return $fields; }
/** * Get details of awards won for a content item. * * @param ID_TEXT The award content type * @param ID_TEXT The content ID * @return array List of awards won */ function find_awards_for($content_type, $id) { $awards = array(); $rows = $GLOBALS['SITE_DB']->query_select('award_archive a LEFT JOIN ' . get_table_prefix() . 'award_types t ON t.id=a.a_type_id', array('date_and_time', 'a_type_id'), array('a_content_type' => $content_type, 'content_id' => $id), 'ORDER BY date_and_time DESC'); foreach ($rows as $row) { require_lang('awards'); $awards[] = array('AWARD_TYPE' => get_translated_text($GLOBALS['SITE_DB']->query_value('award_types', 'a_title', array('id' => $row['a_type_id']))), 'AWARD_TIMESTAMP' => strval($row['date_and_time'])); } return $awards; }
/** * Get a tempcode list of the available mail domains. * * @param ID_TEXT The type of mail domain * @set pop3 forw * @param integer Description * @return tempcode The tempcode list of available domains */ function get_mail_domains($type, $points_left) { $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'prices WHERE name LIKE \'' . db_encode_like($type . '%') . '\''); $list = new ocp_tempcode(); foreach ($rows as $row) { $address = substr($row['name'], strlen($type)); //If we can't afford the mail, turn the text red $red = $points_left < $row['price']; $list->attach(form_input_list_entry($address, false, '@' . $address . ' ' . do_lang('PRICE_GIVE', integer_format($row['price'])), $red)); } return $list; }
/** * Find which special CPF's to enable. * * @return array A list of CPF's to enable */ function to_enable() { global $SITE_INFO; $cpf = array(); if ($SITE_INFO['forum_type'] != 'ocf' || get_db_forums() != get_db_site() || $GLOBALS['FORUM_DRIVER']->get_drivered_table_prefix() != get_table_prefix()) { $cpf['role'] = 1; if (get_option('signup_fullname') == '0') { $cpf['fullname'] = 1; } $cpf['sites'] = 1; } return $cpf; }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!addon_installed('catalogues')) { return; } $last = get_value('last_classified_refresh'); $time = time(); if (!is_null($last) && intval($last) > $time - 60 * 60) { return; } // Don't do more than once per hour if (function_exists('set_time_limit')) { @set_time_limit(0); } $start = 0; do { $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices p ON p.c_catalogue_name=e.c_name', array('e.*'), array('ce_validated' => 1), '', 1000, $start); foreach ($entries as $entry) { if ($entry['ce_last_moved'] == $entry['ce_add_date']) { require_code('classifieds'); initialise_classified_listing($entry); } // Expiring if ($entry['ce_last_moved'] < $time) { $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_validated' => 0), array('id' => $entry['id']), '', 1); decache('main_cc_embed'); decache('main_recent_cc_entries'); require_code('catalogues2'); calculate_category_child_count_cache($entry['cc_id']); } elseif ($entry['ce_last_moved'] < $time + 60 * 60 * 24 && $entry['ce_last_moved'] > $time + 60 * 60 * 23) { // Expiring in 24 hours require_code('notifications'); require_lang('classifieds'); $member_id = $entry['ce_submitter']; $renew_url = build_url(array('page' => 'classifieds', 'type' => 'adverts', 'id' => $member_id), get_module_zone('classifieds')); require_code('catalogues'); $data_map = get_catalogue_entry_map($entry, NULL, 'CATEGORY', 'DEFAULT', NULL, NULL, array(0)); $ad_title = $data_map['FIELD_0_PLAIN']; if (is_object($ad_title)) { $ad_title = $ad_title->evaluate(); } $subject_tag = do_lang('SUBJECT_CLASSIFIED_ADVERT_EXPIRING', $ad_title, get_site_name(), NULL, get_lang($member_id), false); $mail = do_lang('MAIL_CLASSIFIED_ADVERT_EXPIRING', $ad_title, comcode_escape(get_site_name()), comcode_escape($renew_url->evaluate()), get_lang($member_id), false); // Send actual notification dispatch_notification('classifieds__' . $entry['c_name'], '', $subject_tag, $mail, array($member_id), A_FROM_SYSTEM_PRIVILEGED); } } } while (count($entries) == 1000); set_value('last_classified_refresh', strval($time)); }
/** * Standard stage of pointstore item purchase. * * @return tempcode The UI */ function text() { if (get_option('is_on_flagrant_buy') == '0') { return new ocp_tempcode(); } $title = get_page_title('TITLE_NEWTEXT'); $results = $GLOBALS['SITE_DB']->query('SELECT SUM(days) As days FROM ' . get_table_prefix() . 'text WHERE activation_time IS NULL'); $queue = $results[0]['days']; if (is_null($queue)) { $queue = 0; } $text_link = build_url(array('page' => '_SELF', 'type' => '_text', 'id' => 'flagrant'), '_SELF'); $cost = intval(get_option('text')); return do_template('POINTSTORE_FLAGRANT_SCREEN', array('_GUID' => '92d51c5b87745c31397d9165595262d3', 'TITLE' => $title, 'TEXT_LINK' => $text_link, 'QUEUE' => integer_format($queue), 'COST' => integer_format($cost))); }
/** * Standard modular run function. * * @return tempcode Results */ function run() { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'theme_images WHERE path LIKE \'themes/%/images/%\''); persistant_cache_delete('THEME_IMAGES'); $paths = $GLOBALS['SITE_DB']->query_select('theme_images', array('path', 'id')); foreach ($paths as $path) { if ($path['path'] == '') { $GLOBALS['SITE_DB']->query_delete('theme_images', $path, '', 1); } elseif (preg_match('#^themes/[^/]+/images_custom/+' . str_replace('#', '\\#', preg_quote($path['id'])) . '\\.#', $path['path']) != 0) { if (!file_exists(get_custom_file_base() . '/' . $path['path']) && !file_exists(get_file_base() . '/' . $path['path'])) { $GLOBALS['SITE_DB']->query_delete('theme_images', $path, '', 1); } } } return new ocp_tempcode(); }
/** * Function for administrators to pick an identifier (only used by admins, usually the identifier would be picked via some other means in the wider ocPortal codebase). * * @param ID_TEXT Product type code. * @return ?tempcode Input field in standard Tempcode format for fields (NULL: no identifier). */ function get_identifier_manual_field_inputter($type_code) { require_code('catalogues'); require_lang('classifieds'); $list = new ocp_tempcode(); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_entries e JOIN ' . get_table_prefix() . 'classifieds_prices c ON c.c_catalogue_name=e.c_name', array('e.*'), NULL, 'GROUP BY e.id ORDER BY ce_add_date DESC'); foreach ($rows as $row) { $data_map = get_catalogue_entry_map($row, NULL, 'CATEGORY', 'DEFAULT', NULL, NULL, array(0)); $ad_title = $data_map['FIELD_0']; $username = $GLOBALS['FORUM_DRIVER']->get_username($row['ce_submitter']); if (is_null($username)) { $username = do_lang('UNKNOWN'); } $list->attach(form_input_list_entry(strval($row['id']), get_param_integer('id', NULL) === $row['id'], do_lang('CLASSIFIED_OF', strval($row['id']), $username, $ad_title))); } return form_input_list(do_lang_tempcode('ENTRY'), '', 'purchase_id', $list); }
/** * Standard pointstore item configuration function. * * @return ?array A tuple: list of [fields to shown, hidden fields], title for add form, add form (NULL: disabled) */ function config() { $rows = $GLOBALS['SITE_DB']->query('SELECT price,name FROM ' . get_table_prefix() . 'prices WHERE name LIKE \'' . db_encode_like('pop3_%') . '\''); $out = array(); foreach ($rows as $i => $row) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $domain = substr($row['name'], strlen('pop3_')); $hidden->attach(form_input_hidden('dpop3_' . strval($i), $domain)); $fields->attach(form_input_line(do_lang_tempcode('MAIL_DOMAIN'), do_lang_tempcode('DESCRIPTION_MAIL_DOMAIN'), 'ndpop3_' . strval($i), substr($row['name'], 5), true)); $fields->attach(form_input_integer(do_lang_tempcode('MAIL_COST'), do_lang_tempcode('DESCRIPTION_MAIL_COST', escape_html('pop3'), escape_html($domain)), 'pop3_' . strval($i), $row['price'], true)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete_pop3_' . strval($i), false)); $out[] = array($fields, $hidden, do_lang_tempcode('EDIT_POP3_DOMAIN')); } return array($out, do_lang_tempcode('ADD_NEW_POP3_DOMAIN'), $this->get_fields()); }