本文整理汇总了PHP中collapse_2d_complexity函数的典型用法代码示例。如果您正苦于以下问题:PHP collapse_2d_complexity函数的具体用法?PHP collapse_2d_complexity怎么用?PHP collapse_2d_complexity使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了collapse_2d_complexity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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'));
}
示例2: run
/**
* Standard modular run function.
*
* @return tempcode The result of execution.
*/
function run()
{
require_lang('leader_board');
require_code('points');
require_css('points');
$title = get_page_title('POINT_LEADERBOARD');
$start_date = intval(get_option('leaderboard_start_date'));
$weeks = $GLOBALS['SITE_DB']->query('SELECT DISTINCT date_and_time FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'leader_board WHERE date_and_time>=' . strval($start_date) . ' ORDER BY date_and_time DESC');
if (count($weeks) == 0) {
warn_exit(do_lang_tempcode('NO_ENTRIES'));
}
$first_week = $weeks[count($weeks) - 1]['date_and_time'];
$weeks = collapse_1d_complexity('date_and_time', $weeks);
$out = new ocp_tempcode();
foreach ($weeks as $week) {
$rows = collapse_2d_complexity('lb_member', 'lb_points', $GLOBALS['SITE_DB']->query_select('leader_board', array('lb_member', 'lb_points'), array('date_and_time' => $week)));
$week_tpl = new ocp_tempcode();
foreach ($rows as $member => $points) {
$points_url = build_url(array('page' => 'points', 'type' => 'member', 'id' => $member), get_module_zone('points'));
$profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member, false, true);
$name = $GLOBALS['FORUM_DRIVER']->get_username($member);
if (is_null($name)) {
$name = do_lang('UNKNOWN');
}
$week_tpl->attach(do_template('POINTS_LEADERBOARD_ROW', array('_GUID' => '6d323b4b5abea0e82a14cb4745c4af4f', 'POINTS_URL' => $points_url, 'PROFILE_URL' => $profile_url, 'POINTS' => integer_format($points), 'NAME' => $name, 'ID' => strval($member))));
}
$nice_week = intval(($week - $first_week) / (7 * 24 * 60 * 60) + 1);
$out->attach(do_template('POINTS_LEADERBOARD_WEEK', array('_GUID' => '3a0f71bf20f9098e5711e85cf25f6549', 'WEEK' => integer_format($nice_week), 'ROWS' => $week_tpl)));
}
return do_template('POINTS_LEADERBOARD_SCREEN', array('_GUID' => 'bab5f7b661435b83800532d3eebd0d54', 'TITLE' => $title, 'WEEKS' => $out));
}
示例3: run
/**
* 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'));
}
示例4: run
/**
* Standard modular run function for ajax-tree hooks. Generates XML for a tree list, which is interpreted by Javascript and expanded on-demand (via new calls).
*
* @param ?ID_TEXT The ID to do under (NULL: root)
* @param array Options being passed through
* @param ?ID_TEXT The ID to select by default (NULL: none)
* @return string XML in the special category,entry format
*/
function run($id, $options, $default = NULL)
{
require_code('ocf_forums');
require_code('ocf_forums2');
$compound_list = array_key_exists('compound_list', $options) ? $options['compound_list'] : false;
$addable_filter = array_key_exists('addable_filter', $options) ? $options['addable_filter'] : false;
$stripped_id = $compound_list ? preg_replace('#,.*$#', '', $id) : $id;
$tree = ocf_get_forum_tree_secure(NULL, is_null($id) ? NULL : intval($id), false, NULL, '', NULL, NULL, $compound_list, 1, true);
$out = '';
if (!has_actual_page_access(NULL, 'forumview')) {
$tree = $compound_list ? array(array(), '') : array();
}
$categories = collapse_2d_complexity('id', 'c_title', $GLOBALS['FORUM_DB']->query_select('f_categories', array('id', 'c_title')));
if ($compound_list) {
list($tree, ) = $tree;
}
foreach ($tree as $t) {
if ($compound_list) {
$_id = $t['compound_list'];
} else {
$_id = strval($t['id']);
}
if ($stripped_id === strval($t['id'])) {
continue;
}
// Possible when we look under as a root
$title = $t['title'];
$description = array_key_exists($t['group'], $categories) ? $categories[$t['group']] : '';
$has_children = $t['child_count'] != 0;
$selectable = !$addable_filter || ocf_may_post_topic($t['id']);
$tag = 'category';
// category
$out .= '<' . $tag . ' id="' . $_id . '" title="' . xmlentities($title) . '" description="' . xmlentities($description) . '" has_children="' . ($has_children ? 'true' : 'false') . '" selectable="' . ($selectable ? 'true' : 'false') . '"></' . $tag . '>';
}
// Mark parent cats for pre-expansion
if (!is_null($default) && $default != '') {
$cat = intval($default);
while (!is_null($cat)) {
$out .= '<expand>' . strval($cat) . '</expand>';
$cat = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_parent_forum', array('id' => $cat));
}
}
$tag = 'result';
// result
return '<' . $tag . '>' . $out . '</' . $tag . '>';
}
示例5: run
/**
* 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 (get_forum_type() != 'ocf') {
return NULL;
}
if (!has_actual_page_access(get_member(), 'forumview')) {
return NULL;
}
if (is_guest()) {
return NULL;
}
$condition = 'l_time<t_cache_last_time OR (l_time IS NULL AND t_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days'))) . ')';
$query = ' FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics top LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (top.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND top.t_cache_first_post=t.id WHERE (' . $condition . ') AND t_forum_id IS NOT NULL ' . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' ORDER BY t_cache_last_time DESC';
$rows = $GLOBALS['FORUM_DB']->query('SELECT *,top.id AS t_id ' . $query, $max);
$categories = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'));
$content = new ocp_tempcode();
foreach ($rows as $row) {
if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
$id = strval($row['id']);
$author = $row['t_cache_first_username'];
$news_date = date($date_string, $row['t_cache_first_time']);
$edit_date = date($date_string, $row['t_cache_last_time']);
if ($edit_date == $news_date) {
$edit_date = '';
}
$news_title = xmlentities($row['t_cache_first_title']);
$_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
$category_raw = strval($row['t_forum_id']);
$view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('topicview'));
if ($prefix == 'RSS_') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['t_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)));
}
}
require_lang('ocf');
return array($content, do_lang('TOPICS_UNREAD'));
}
示例6: run
/**
* 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)
{
if (!addon_installed('galleries')) {
return array();
}
require_lang('galleries');
$new = new ocp_tempcode();
$count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('download\\_%') . '\'');
if ($count < 500) {
$_galleries = $GLOBALS['SITE_DB']->query('SELECT name,fullname FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries WHERE name NOT LIKE \'' . db_encode_like('download\\_%') . '\'', 300);
if (count($_galleries) == 300) {
return array();
}
foreach ($_galleries as $i => $_gallery) {
$_galleries[$i]['text_original'] = get_translated_text($_gallery['fullname']);
}
$galleries = collapse_2d_complexity('name', 'text_original', $_galleries);
} else {
$galleries = array();
}
require_code('ocfiltering');
$or_list = ocfilter_to_sqlfragment($filter, 'cat', NULL, NULL, NULL, NULL, false);
$rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos WHERE add_date>' . strval((int) $cutoff_time) . ' AND validated=1 AND (' . $or_list . ') ORDER BY add_date DESC', 300);
if (count($rows) == 300) {
return array();
}
foreach ($rows as $row) {
$_url = build_url(array('page' => 'galleries', 'type' => 'video', 'id' => $row['id']), get_module_zone('galleries'), NULL, false, false, true);
$url = $_url->evaluate();
if (!array_key_exists($row['cat'], $galleries)) {
$galleries[$row['cat']] = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $row['cat'])));
}
$name = $galleries[$row['cat']];
$_name = get_translated_text($row['title']);
if ($_name != '') {
$name = $_name;
}
$description = get_translated_text($row['comments'], NULL, $lang);
$member_id = is_guest($row['submitter']) ? NULL : strval($row['submitter']);
$new->attach(do_template('NEWSLETTER_NEW_RESOURCE_FCOMCODE', array('_GUID' => 'dfe5850aa67c0cd00ff7d465248b87a5', 'MEMBER_ID' => $member_id, 'URL' => $url, 'NAME' => $name, 'DESCRIPTION' => $description)));
}
return array($new, do_lang('GALLERIES', '', '', '', $lang));
}
示例7: run
/**
* 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('ocf_forum')) {
return NULL;
}
if (get_forum_type() != 'ocf') {
return NULL;
}
if (!has_actual_page_access(get_member(), 'forumview')) {
return NULL;
}
$filters = ocfilter_to_sqlfragment($_filters, 't_forum_id', 'f_forums', 'f_parent_forum', 't_forum_id', 'id', true, true, $GLOBALS['FORUM_DB']);
// 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['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE t_cache_last_time>' . strval($cutoff) . (!has_specific_permission(get_member(), 'see_unvalidated') ? ' AND t_validated=1 ' : '') . ' AND ' . $filters . ' ORDER BY t_cache_last_time DESC', $max);
$categories = collapse_2d_complexity('id', 'f_name', $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0'));
$content = new ocp_tempcode();
foreach ($rows as $row) {
if ((!is_null($row['t_forum_id']) || $row['t_pt_to'] == get_member()) && has_category_access(get_member(), 'forums', strval($row['t_forum_id']))) {
$id = strval($row['id']);
$author = $row['t_cache_first_username'];
$news_date = date($date_string, $row['t_cache_first_time']);
$edit_date = date($date_string, $row['t_cache_last_time']);
if ($edit_date == $news_date) {
$edit_date = '';
}
$news_title = xmlentities($row['t_cache_first_title']);
$_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
$summary = xmlentities($_summary->evaluate());
$news = '';
$category = array_key_exists($row['t_forum_id'], $categories) ? $categories[$row['t_forum_id']] : do_lang('NA');
$category_raw = strval($row['t_forum_id']);
$view_url = build_url(array('page' => 'topicview', 'id' => $row['id']), get_module_zone('forumview'), NULL, false, false, true);
if ($prefix == 'RSS_') {
$if_comments = do_template('RSS_ENTRY_COMMENTS', array('_GUID' => 'f5dd7ba612b989bba5e2d496da5bf161', '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)));
}
}
require_lang('ocf');
return array($content, do_lang('SECTION_FORUMS'));
}
示例8: ocf_list_multi_moderations
/**
* List all the multi moderations that may be used in a certain forum.
*
* @param ?AUTO_LINK The forum we are listing for (NULL: private topics).
* @return array List of multi moderations.
*/
function ocf_list_multi_moderations($forum_id)
{
if (!addon_installed('ocf_multi_moderations')) {
return array();
}
if (is_null($forum_id)) {
return array();
}
$rows = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations m LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND m.mm_name=t.id', array('mm_forum_multi_code', 'm.id', 'm.mm_name', 'text_original AS _mm_name'), NULL, 'ORDER BY text_original');
$out = array();
if (count($rows) == 0) {
return $out;
}
$lots_of_forums = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)') > 200;
if (!$lots_of_forums) {
$all_forums = collapse_2d_complexity('id', 'f_parent_forum', $GLOBALS['FORUM_DB']->query_select('f_forums', array('id', 'f_parent_forum')));
}
foreach ($rows as $row) {
if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($row['_mm_name'])) {
$row['_mm_name'] = get_translated_text($row['mm_name'], $GLOBALS['FORUM_DB']);
}
require_code('ocfiltering');
if ($lots_of_forums) {
$sql = ocfilter_to_sqlfragment($row['mm_forum_multi_code'], 'id', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']);
if (!is_null($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval($forum_id) . ' AND (' . $sql . ')'))) {
$out[$row['id']] = $row['_mm_name'];
}
} else {
$idlist = ocfilter_to_idlist_using_memory($row['mm_forum_multi_code'], $all_forums, 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']);
if (in_array($forum_id, $idlist)) {
$out[$row['id']] = $row['_mm_name'];
}
}
}
return $out;
}
示例9: run
/**
* Standard modular run function.
*
* @param array A map of parameters.
* @return tempcode The result of execution.
*/
function run($map)
{
require_code('galleries');
require_lang('galleries');
$number = array_key_exists('param', $map) ? intval($map['param']) : 10;
$zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('galleries');
$out = new ocp_tempcode();
$rows1 = $GLOBALS['SITE_DB']->query('SELECT DISTINCT g.name,g.add_date FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries g JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'images i ON g.name=i.cat WHERE i.add_date IS NOT NULL AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\' ORDER BY g.add_date DESC', $number);
$rows2 = $GLOBALS['SITE_DB']->query('SELECT DISTINCT g.name,g.add_date FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'galleries g JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'videos i ON g.name=i.cat WHERE i.add_date IS NOT NULL AND name NOT LIKE \'' . db_encode_like('download\\_%') . '\' ORDER BY g.add_date DESC', $number);
$galleries = array_unique(collapse_2d_complexity('name', 'add_date', array_merge($rows1, $rows2)));
arsort($galleries);
if (count($galleries) == 0) {
return do_template('BLOCK_NO_ENTRIES', array('_GUID' => 'e6d16782037d35949646f95656382783', 'HIGH' => false, 'TITLE' => do_lang_tempcode('RECENT', make_string_tempcode(integer_format($number)), do_lang_tempcode('GALLERIES')), 'MESSAGE' => do_lang_tempcode('NO_CATEGORIES'), 'ADD_NAME' => '', 'SUBMIT_URL' => ''));
} else {
foreach (array_keys($galleries) as $i => $gallery) {
if ($i == $number) {
break;
}
$row = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $gallery), '', 1);
$out->attach(do_template('GALLERY_SUBGALLERY_WRAP', array('CONTENT' => show_gallery_box($row[0], 'root', true, $zone, false, true))));
}
}
return do_template('BLOCK_MAIN_RECENT_GALLERIES', array('_GUID' => 'a7fca7d625a3d3af362735dad670f6eb', 'CONTENT' => $out, 'NUMBER' => integer_format($number)));
}
示例10: ocf_make_member
//.........这里部分代码省略.........
if ($g_id == $primary_group) {
unset($secondary_groups[$_g_id]);
}
}
if (is_null($ip_address)) {
$ip_address = get_ip_address();
}
if ($password_compatibility_scheme == '' && get_value('no_password_hashing') === '1') {
$password_compatibility_scheme = 'plain';
$salt = '';
}
if ($salt == '' && $password_compatibility_scheme == '') {
$salt = produce_salt();
$password_salted = md5($salt . md5($password));
} else {
$password_salted = $password;
}
// Supplement custom field values given with defaults, and check constraints
$all_fields = list_to_map('id', ocf_get_all_custom_fields_match($secondary_groups));
require_code('fields');
foreach ($all_fields as $field) {
$field_id = $field['id'];
if (array_key_exists($field_id, $custom_fields)) {
if ($check_correctness && $field[array_key_exists('cf_show_on_join_form', $field) ? 'cf_show_on_join_form' : 'cf_required'] == 0 && $field['cf_owner_set'] == 0 && !has_actual_page_access(get_member(), 'admin_ocf_join')) {
access_denied('I_ERROR');
}
} else {
$custom_fields[$field_id] = '';
}
}
if (!addon_installed('unvalidated')) {
$validated = 1;
}
$map = array('m_username' => $username, 'm_pass_hash_salted' => $password_salted, 'm_pass_salt' => $salt, 'm_theme' => $theme, 'm_avatar_url' => $avatar_url, 'm_validated' => $validated, 'm_validated_email_confirm_code' => $validated_email_confirm_code, 'm_cache_num_posts' => 0, 'm_cache_warnings' => 0, 'm_max_email_attach_size_mb' => 5, 'm_join_time' => $join_time, 'm_timezone_offset' => $timezone, 'm_primary_group' => $primary_group, 'm_last_visit_time' => $last_visit_time, 'm_last_submit_time' => $last_submit_time, 'm_signature' => insert_lang_comcode($signature, 4, $GLOBALS['FORUM_DB']), 'm_is_perm_banned' => $is_perm_banned, 'm_preview_posts' => $preview_posts, 'm_notes' => $personal_notes, 'm_dob_day' => $dob_day, 'm_dob_month' => $dob_month, 'm_dob_year' => $dob_year, 'm_reveal_age' => $reveal_age, 'm_email_address' => $email_address, 'm_title' => $title, 'm_photo_url' => $photo_url, 'm_photo_thumb_url' => $photo_thumb_url, 'm_views_signatures' => $views_signatures, 'm_auto_monitor_contrib_content' => $auto_monitor_contrib_content, 'm_highlighted_name' => $highlighted_name, 'm_pt_allow' => $pt_allow, 'm_pt_rules_text' => insert_lang_comcode($pt_rules_text, 4, $GLOBALS['FORUM_DB']), 'm_language' => $language, 'm_ip_address' => $ip_address, 'm_zone_wide' => $zone_wide, 'm_allow_emails' => $allow_emails, 'm_allow_emails_from_staff' => $allow_emails_from_staff, 'm_password_change_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_on_probation_until' => NULL);
if (!is_null($id)) {
$map['id'] = $id;
}
$member_id = $GLOBALS['FORUM_DB']->query_insert('f_members', $map, true);
if ($check_correctness) {
// If it was an invite/recommendation, award the referrer
if (addon_installed('recommend')) {
$inviter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_invites', 'i_inviter', array('i_email_address' => $email_address), 'ORDER BY i_time');
if (!is_null($inviter)) {
if (addon_installed('points')) {
require_code('points2');
require_lang('recommend');
system_gift_transfer(do_lang('RECOMMEND_SITE_TO', $username, get_site_name()), intval(get_option('points_RECOMMEND_SITE')), $inviter);
}
if (addon_installed('chat')) {
require_code('chat2');
buddy_add($inviter, $member_id);
buddy_add($member_id, $inviter);
}
}
}
}
$value = mixed();
// Store custom fields
$row = array('mf_member_id' => $member_id);
$all_fields_types = collapse_2d_complexity('id', 'cf_type', $all_fields);
foreach ($custom_fields as $field_num => $value) {
if (!array_key_exists($field_num, $all_fields_types)) {
continue;
}
// Trying to set a field we're not allowed to (doesn't apply to our group)
$ob = get_fields_hook($all_fields_types[$field_num]);
list(, , $storage_type) = $ob->get_field_value_row_bits($all_fields[$field_num]);
if (strpos($storage_type, '_trans') !== false) {
$value = insert_lang($value, 3, $GLOBALS['FORUM_DB']);
}
$row['field_' . strval($field_num)] = $value;
}
// Set custom field row
$all_fields_regardless = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_type'));
foreach ($all_fields_regardless as $field) {
if (!array_key_exists('field_' . strval($field['id']), $row)) {
$ob = get_fields_hook($field['cf_type']);
list(, , $storage_type) = $ob->get_field_value_row_bits($field);
$value = '';
if (strpos($storage_type, '_trans') !== false) {
$value = insert_lang($value, 3, $GLOBALS['FORUM_DB']);
}
$row['field_' . strval($field['id'])] = $value;
}
}
$GLOBALS['FORUM_DB']->query_insert('f_member_custom_fields', $row);
// Any secondary work
foreach ($secondary_groups as $g) {
if ($g != $primary_group) {
$GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id, 'gm_group_id' => $g), '', 1);
$GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $g, 'gm_member_id' => $member_id, 'gm_validated' => 1));
}
}
if ($check_correctness) {
if (function_exists('decache')) {
decache('side_stats');
}
}
return $member_id;
}
示例11: interface_content
/**
* The UI to translate content.
*
* @return tempcode The UI
*/
function interface_content()
{
$title = get_page_title('TRANSLATE_CONTENT');
if (!multi_lang()) {
warn_exit(do_lang_tempcode('MULTILANG_OFF'));
}
$max = get_param_integer('max', 100);
$lang = choose_language($title);
if (is_object($lang)) {
return $lang;
}
// Fiddle around in order to find what we haven't translated. Subqueries and self joins don't work well enough across different db's
if (!db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
$_done_id_list = collapse_2d_complexity('id', 'text_original', $GLOBALS['SITE_DB']->query_select('translate', array('id', 'text_original'), array('language' => $lang, 'broken' => 0)));
$done_id_list = '';
foreach (array_keys($_done_id_list) as $done_id) {
if ($done_id_list != '') {
$done_id_list .= ',';
}
$done_id_list .= strval($done_id);
}
$and_clause = $done_id_list == '' ? '' : 'AND id NOT IN (' . $done_id_list . ')';
$query = 'FROM ' . get_table_prefix() . 'translate WHERE ' . db_string_not_equal_to('language', $lang) . ' ' . $and_clause . ' AND ' . db_string_not_equal_to('text_original', '') . ' ORDER BY importance_level';
$to_translate = $GLOBALS['SITE_DB']->query('SELECT * ' . $query, $max);
} else {
$query = 'FROM ' . get_table_prefix() . 'translate a LEFT JOIN ' . get_table_prefix() . 'translate b ON a.id=b.id AND b.broken=0 AND ' . db_string_equal_to('b.language', $lang) . ' WHERE b.id IS NULL AND ' . db_string_not_equal_to('a.language', $lang) . ' AND ' . db_string_not_equal_to('a.text_original', '');
$to_translate = $GLOBALS['SITE_DB']->query('SELECT a.* ' . $query . (can_arbitrary_groupby() ? ' GROUP BY a.id' : '') . ' ORDER BY a.importance_level', $max);
}
$total = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
if (count($to_translate) == 0) {
inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
}
require_all_lang($lang, true);
require_all_open_lang_files($lang);
// Make our translation page
require_code('lang2');
$lines = '';
$intertrans = $this->get_intertran_conv($lang);
$actions = make_string_tempcode(' ');
$last_level = NULL;
$too_many = count($to_translate) == $max;
$ids_to_lookup = array();
foreach ($to_translate as $it) {
$ids_to_lookup[] = $it['id'];
}
$names = find_lang_content_names($ids_to_lookup);
foreach ($to_translate as $i => $it) {
if ($it['importance_level'] == 0) {
continue;
}
// Corrupt data
$id = $it['id'];
$old = $it['text_original'];
$current = $this->find_lang_matches($old, $lang);
$priority = $last_level === $it['importance_level'] ? NULL : do_lang('PRIORITY_' . strval($it['importance_level']));
$name = $names[$id];
if (is_null($name)) {
continue;
}
// Orphaned string
if ($intertrans != '') {
$actions = do_template('TRANSLATE_ACTION', array('_GUID' => 'f625cf15c9db5e5af30fc772a7f0d5ff', 'LANG_FROM' => $it['language'], 'LANG_TO' => $lang, 'NAME' => 'trans_' . strval($id), 'OLD' => $old));
}
$line = do_template('TRANSLATE_LINE_CONTENT', array('_GUID' => '87a0f5298ce9532839f3206cd0e06051', 'NAME' => $name, 'ID' => strval($id), 'OLD' => $old, 'CURRENT' => $current, 'ACTIONS' => $actions, 'PRIORITY' => $priority));
$lines .= $line->evaluate();
/*XHTMLXHTML*/
$last_level = $it['importance_level'];
}
$url = build_url(array('page' => '_SELF', 'type' => '_content', 'lang' => $lang), '_SELF');
require_code('lang2');
return do_template('TRANSLATE_SCREEN_CONTENT_SCREEN', array('_GUID' => 'af732c5e595816db1c6f025c4b8fa6a2', 'MAX' => integer_format($max), 'TOTAL' => integer_format($total - $max), 'LANG_ORIGINAL_NAME' => get_site_default_lang(), 'LANG_NICE_ORIGINAL_NAME' => lookup_language_full_name(get_site_default_lang()), 'LANG_NICE_NAME' => lookup_language_full_name($lang), 'TOO_MANY' => $too_many, 'INTERTRANS' => $intertrans, 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url));
}
示例12: bounce_filter_c
/**
* The UI to confirm which subscribers to prune.
*
* @return tempcode The UI
*/
function bounce_filter_c()
{
$title = get_page_title('BOUNCE_FILTER');
disable_php_memory_limit();
// In case of a huge number
$username = post_param('username');
$password = post_param('password');
$server = post_param('server');
$port = post_param_integer('port');
$box = post_param('box');
$mbox = @imap_open($box, $username, $password);
if ($mbox === false) {
warn_exit(do_lang_tempcode('IMAP_ERROR', imap_last_error()));
}
$fields = '';
//new ocp_tempcode();
require_code('form_templates');
$all_subscribers = array();
$all_subscribers += collapse_2d_complexity('email', 'id', $GLOBALS['SITE_DB']->query_select('newsletter', array('email', 'id')));
if (get_forum_type() == 'ocf') {
$all_subscribers += collapse_2d_complexity('m_email_address', 'id', $GLOBALS['FORUM_DB']->query_select('f_members', array('m_email_address', 'id'), array('m_allow_emails_from_staff' => 1)));
}
$headers = imap_search($mbox, 'UNDELETED');
if ($headers === false) {
$headers = array();
}
$num = 0;
foreach ($headers as $val) {
$msg = imap_body($mbox, $val);
$matches = array();
$num_matches = preg_match_all("#<([^\n<>@]+@[^\n<>@]+)>#", $msg, $matches);
if ($num_matches != 0) {
$overview = imap_headerinfo($mbox, $val);
$body = imap_body($mbox, $val);
$checked = strpos($body, 'X-Failed-Recipients') !== false || strpos($body, '5.1.1') !== false || strpos($body, '5.1.6') !== false || strpos($body, '5.7.1') !== false;
for ($i = 0; $i < $num_matches; $i++) {
$m = $matches[1][$i];
$m = str_replace('@localhost.localdomain', '', $m);
if ($m != get_option('staff_address') && array_key_exists($m, $all_subscribers)) {
$tick = form_input_tick($m, $overview->subject . '.', 'email_' . strval($num), $checked, NULL, $m);
$fields .= $tick->evaluate();
// HTMLHTML
//$fields->attach($tick);
$num++;
unset($all_subscribers[$m]);
// So as to make the list no longer than needed; each subscriber only considered once
}
}
}
}
imap_close($mbox);
if ($num == 0) {
warn_exit(do_lang_tempcode('NO_ENTRIES'));
}
$submit_name = do_lang_tempcode('PROCEED');
$post_url = get_self_url();
$post_url = build_url(array('page' => '_SELF', 'type' => 'bounce_filter_d'), '_SELF');
return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => build_keep_post_fields(), 'TITLE' => $title, 'TEXT' => do_lang_tempcode('BOUNCE_WHICH'), 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
}
示例13: _get_usergroup_list
/**
* Get the forum usergroup list.
*
* @return array The usergroup list
*/
function _get_usergroup_list()
{
$results = $this->connection->query('SELECT group_id,group_name FROM ' . $this->connection->get_table_prefix() . 'groups');
$results2 = collapse_2d_complexity('group_id', 'group_name', $results);
return $results2;
}
示例14: ocf_get_forum_tree_secure
/**
* Generate a tempcode tree based selection list (ala nice_get_*) for choosing a forum OR a map of details. Also capable of getting comma-separated ancester forum lists. Also capable of displaying topic lists in the tree. In other words... this function is incredibly powerful, and complex.
*
* @param ?MEMBER The member that the view privileges are done for (NULL: current member).
* @param ?AUTO_LINK The forum we are starting from (NULL: capture the whole tree).
* @param boolean Whether to get a tempcode list (as opposed to a list of maps).
* @param ?array The forum(s) to select by default (NULL: no preference). Only applies if !$topics_too. An array of AUTO_LINK's (for IDs) or strings (for names).
* @param string The ancester list at this point of the recursion (blank for the start).
* @param ?AUTO_LINK ID of a forum to skip display/recursion for (NULL: none).
* @param ?boolean Whether the child forums are ordered alphabetically (NULL: find from DB).
* @param boolean Whether to generate a compound list (a list of all the ancesters, for each point in the forum tree) as well as the tree.
* @param ?integer The number of recursive levels to search (NULL: all)
* @param boolean Whether to generate tree statistics.
* @return mixed Each tempcode of the tree if $field_format or else a list of maps, OR (if $use_compound_list) a pair of the tempcode and the compound list.
*/
function ocf_get_forum_tree_secure($member_id = NULL, $base_forum = NULL, $field_format = false, $selected_forum = NULL, $tree = '', $skip = NULL, $order_sub_alpha = NULL, $use_compound_list = false, $levels = NULL, $do_stats = false)
{
if ($levels == -1 && !$use_compound_list) {
return $use_compound_list ? array(array(), '') : array();
}
global $FORUM_TREE_SECURE_CACHE;
if (is_null($member_id)) {
$member_id = get_member();
}
if (is_null($order_sub_alpha)) {
if (is_null($base_forum)) {
$order_sub_alpha = false;
} else {
$order_sub_alpha = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_order_sub_alpha', array('id' => $base_forum));
}
}
$out = array();
$order = $order_sub_alpha ? 'f_name' : 'f_position,id';
$forums = array();
if (is_null($FORUM_TREE_SECURE_CACHE)) {
$FORUM_TREE_SECURE_CACHE = mixed();
$num_forums = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)');
$FORUM_TREE_SECURE_CACHE = $num_forums >= 300;
// Mark it as 'huge'
}
if ($FORUM_TREE_SECURE_CACHE === true) {
$forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_order_sub_alpha,f_name,f_category_id,f_parent_forum,f_position FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id IS NOT NULL AND ' . db_string_equal_to('f_redirection', '') . ' AND ' . (is_null($base_forum) ? 'f_parent_forum IS NULL' : 'f_parent_forum=' . strval($base_forum)) . ' ORDER BY f_position', 200);
} else {
if (is_null($FORUM_TREE_SECURE_CACHE) || $FORUM_TREE_SECURE_CACHE === false) {
$FORUM_TREE_SECURE_CACHE = $GLOBALS['FORUM_DB']->query('SELECT id,f_order_sub_alpha,f_name,f_category_id,f_parent_forum,f_position FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id IS NOT NULL AND ' . db_string_equal_to('f_redirection', '') . ' ORDER BY f_position');
}
foreach ($FORUM_TREE_SECURE_CACHE as $x) {
if ($x['f_parent_forum'] === $base_forum) {
$forums[] = $x;
}
}
}
global $M_SORT_KEY;
$M_SORT_KEY = $order;
uasort($forums, 'multi_sort');
$compound_list = '';
foreach ($forums as $forum) {
$access = has_category_access($member_id, 'forums', strval($forum['id']));
$cat_sort_key = '!' . (is_null($forum['f_category_id']) ? '' : strval($forum['f_category_id']));
if ($access && $skip !== $forum['id'] && $levels !== 0) {
$cat_bit = '';
if (!is_null($forum['f_category_id'])) {
global $CATEGORY_TITLES;
if (is_null($CATEGORY_TITLES)) {
$CATEGORY_TITLES = collapse_2d_complexity('id', 'c_title', $GLOBALS['FORUM_DB']->query_select('f_categories', array('id', 'c_title')));
}
$cat_bit = array_key_exists($forum['f_category_id'], $CATEGORY_TITLES) ? $CATEGORY_TITLES[$forum['f_category_id']] : do_lang('NA');
//if (strlen($pre.$cat_bit)>26) $cat_bit='...';
}
if ($field_format) {
$pre = $tree == '' ? '' : $tree . ' > ';
$below = ocf_get_forum_tree_secure($member_id, $forum['id'], true, $selected_forum, $pre . $forum['f_name'], $skip, $forum['f_order_sub_alpha'], $use_compound_list, NULL, $do_stats);
if ($use_compound_list) {
list($below, $_compound_list) = $below;
$compound_list .= strval($forum['id']) . ',' . $_compound_list;
}
$selected = false;
if (!is_null($selected_forum)) {
foreach ($selected_forum as $s) {
if (is_integer($s) && $s == $forum['id']) {
$selected = true;
}
if (is_string($s) && $s == $forum['f_name']) {
$selected = true;
}
}
}
$line = do_template('OCF_FORUM_LIST_LINE', array('_GUID' => '2fb4bd9ed5c875de6155bef588c877f9', 'PRE' => $pre, 'NAME' => $forum['f_name'], 'CAT_BIT' => $cat_bit));
if (!array_key_exists($cat_sort_key, $out)) {
$out[$cat_sort_key] = '';
}
$out[$cat_sort_key] .= '<option value="' . (!$use_compound_list ? strval($forum['id']) : strval($forum['id']) . ',' . $_compound_list) . '"' . ($selected ? ' selected="selected"' : '') . '>' . $line->evaluate() . '</option>';
//$out.=$below;
if ($levels !== 0) {
$out[$cat_sort_key] .= $below->evaluate();
}
} else {
if ($use_compound_list) {
$below = ocf_get_forum_tree_secure($member_id, $forum['id'], true, $selected_forum, $forum['f_name'], $skip, $forum['f_order_sub_alpha'], $use_compound_list, NULL, $do_stats);
list($below, $_compound_list) = $below;
//.........这里部分代码省略.........
示例15: do_import
/**
* The actualiser to do an import.
*
* @return tempcode The UI
*/
function do_import()
{
$refresh_url = get_self_url(true, false, array('type' => 'import'), true);
$refresh_time = either_param_integer('refresh_time', 15);
// Shouldn't default, but reported on some systems to do so
if (function_exists('set_time_limit')) {
@set_time_limit($refresh_time);
}
header('Content-type: text/html; charset=' . get_charset());
@ini_set('log_errors', '0');
global $I_REFRESH_URL;
$I_REFRESH_URL = $refresh_url;
require_code('database_action');
$title = get_page_title('IMPORT');
$importer = get_param('importer');
require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer));
$object = object_factory('Hook_' . filter_naughty_harsh($importer));
// Get data
$old_base_dir = either_param('old_base_dir');
if (method_exists($object, 'verify_base_path') && !$object->verify_base_path($old_base_dir)) {
warn_exit(do_lang_tempcode('BAD_IMPORT_PATH', escape_html($old_base_dir)));
}
if (method_exists($object, 'probe_db_access')) {
list($db_name, $db_user, $db_password, $db_table_prefix) = $object->probe_db_access(either_param('old_base_dir'));
} else {
$db_name = either_param('db_name');
$db_user = either_param('db_user');
$db_password = either_param('db_password');
$db_table_prefix = either_param('db_table_prefix');
}
if ($db_name == get_db_site() && $importer == 'ocp_merge' && $db_table_prefix == $GLOBALS['SITE_DB']->get_table_prefix()) {
warn_exit(do_lang_tempcode('IMPORT_SELF_NO'));
}
$import_source = is_null($db_name) ? NULL : new database_driver($db_name, get_db_site_host(), $db_user, $db_password, $db_table_prefix);
// Some preliminary tests
$happy = get_param_integer('happy', 0);
if (method_exists($object, 'pre_import_tests') && $happy == 0) {
$ui = $object->pre_import_tests($import_source, $db_table_prefix, $old_base_dir);
if (!is_null($ui)) {
return $ui;
}
}
// Save data
$GLOBALS['SITE_DB']->query_delete('import_session', array('imp_session' => get_session_id()), '', 1);
$GLOBALS['SITE_DB']->query_insert('import_session', array('imp_hook' => '', 'imp_old_base_dir' => $old_base_dir, 'imp_db_name' => is_null($db_name) ? '' : $db_name, 'imp_db_user' => is_null($db_user) ? '' : $db_user, 'imp_db_table_prefix' => is_null($db_table_prefix) ? '' : $db_table_prefix, 'imp_refresh_time' => $refresh_time, 'imp_session' => get_session_id()));
$info = $object->info();
$_import_list = $info['import'];
$out = new ocp_tempcode();
$parts_done = collapse_2d_complexity('imp_id', 'imp_session', $GLOBALS['SITE_DB']->query_select('import_parts_done', array('imp_id', 'imp_session'), array('imp_session' => get_session_id())));
$import_last = '-1';
if (get_forum_type() != 'ocf') {
require_code('forum/ocf');
$GLOBALS['OCF_DRIVER'] = new forum_driver_ocf();
$GLOBALS['OCF_DRIVER']->connection = $GLOBALS['SITE_DB'];
$GLOBALS['OCF_DRIVER']->MEMBER_ROWS_CACHED = array();
}
$_import_list[] = 'ocf_switch';
$all_skipped = true;
$lang_array = array();
$hooks = find_all_hooks('modules', 'admin_import_types');
foreach (array_keys($hooks) as $hook) {
require_code('hooks/modules/admin_import_types/' . filter_naughty_harsh($hook));
$_hook = object_factory('Hook_admin_import_types_' . filter_naughty_harsh($hook));
$lang_array += $_hook->run();
}
foreach ($_import_list as $import) {
$import_this = either_param_integer('import_' . $import, 0);
if ($import_this == 1) {
$dependency = NULL;
if (array_key_exists('dependencies', $info) && array_key_exists($import, $info['dependencies'])) {
foreach ($info['dependencies'][$import] as $_dependency) {
if (!array_key_exists($_dependency, $parts_done) && isset($lang_array[$_dependency])) {
$dependency = $_dependency;
}
}
}
if (is_null($dependency)) {
if ($import == 'ocf_switch') {
$out->attach($this->ocf_switch());
} else {
$function_name = 'import_' . $import;
ocf_over_local();
$func_output = call_user_func_array(array($object, $function_name), array($import_source, $db_table_prefix, $old_base_dir));
if (!is_null($func_output)) {
$out->attach($func_output);
}
ocf_over_msn();
}
$parts_done[$import] = get_session_id();
$import_last = $import;
$all_skipped = false;
$GLOBALS['SITE_DB']->query_delete('import_parts_done', array('imp_id' => $import, 'imp_session' => get_session_id()), '', 1);
$GLOBALS['SITE_DB']->query_insert('import_parts_done', array('imp_id' => $import, 'imp_session' => get_session_id()));
} else {
$out->attach(do_template('IMPORT_MESSAGE', array('_GUID' => 'b2a853f5fb93beada51a3eb8fbd1575f', 'MESSAGE' => do_lang_tempcode('IMPORT_OF_SKIPPED', escape_html($import), escape_html($dependency)))));
//.........这里部分代码省略.........