/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_forum_type() != 'ocf') { return; } $time = time(); $last_time = intval(get_value('last_confirm_reminder_time')); if ($last_time > time() - 24 * 60 * 60 * 2) { return; } set_value('last_confirm_reminder_time', strval($time)); require_code('mail'); require_lang('ocf'); $GLOBALS['NO_DB_SCOPE_CHECK'] = true; $rows = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_not_equal_to('m_validated_email_confirm_code', '') . ' AND m_join_time>' . strval($last_time)); $GLOBALS['NO_DB_SCOPE_CHECK'] = false; foreach ($rows as $row) { $coppa = get_option('is_on_coppa') == '1' && utctime_to_usertime(time() - mktime(0, 0, 0, $row['m_dob_month'], $row['m_dob_day'], $row['m_dob_year'])) / 31536000.0 < 13.0; if (!$coppa) { $zone = get_module_zone('join'); if ($zone != '') { $zone .= '/'; } $url = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4&email=' . rawurlencode($row['m_email_address']) . '&code=' . $row['m_validated_email_confirm_code']; $url_simple = get_base_url() . '/' . $zone . 'index.php?page=join&type=step4'; $message = do_lang('OCF_SIGNUP_TEXT', comcode_escape(get_site_name()), comcode_escape($url), array($url_simple, $row['m_email_address'], strval($row['m_validated_email_confirm_code'])), $row['m_language']); mail_wrap(do_lang('CONFIRM_EMAIL_SUBJECT', get_site_name(), NULL, NULL, $row['m_language']), $message, array($row['m_email_address']), $row['m_username']); } } }
/** * 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)); }
/** * Find whether a member of a certain username is bound to HTTP authentication (an exceptional situation, only for sites that use it). * * @param string The username. * @return ?integer The member ID, if it is (NULL: not bound). */ function ocf_authusername_is_bound_via_httpauth($authusername) { $ret = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_password_compat_scheme' => 'httpauth', 'm_pass_hash_salted' => $authusername)); if (is_null($ret)) { $ret = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_not_equal_to('m_password_compat_scheme', '') . ' AND ' . db_string_equal_to('m_username', $authusername)); } return $ret; }
/** * Helper function to generate an SQL "not equal to" fragment. * * @param string The field name * @param string The string value (may actually hold an integer, if $numeric) * @param boolean Whether the value is numeric * @return string SQL fragment */ function _ocfilter_neq($field_name, $var, $numeric) { if ($numeric) { return $field_name . '<>' . strval(intval($var)); } else { return db_string_not_equal_to($field_name, $var); } }
/** * 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; }
/** * 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; }
/** * Shows an HTML page of all authors clickably. */ function authors_script() { require_lang('authors'); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'max'; $start = get_param_integer('start', 0); $max = get_param_integer('max', 300); $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\''); $rows = array(); foreach ($author_fields as $field) { if ($field['m_table'] != 'addons' && $field['m_table'] != 'blocks' && $field['m_table'] != 'modules') { $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' AS author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name'], $max + $start); foreach ($rows_new as $a) { if (!array_key_exists($a['author'], $rows) || $field['m_table'] == 'authors') { $rows[$a['author']] = $field['m_table']; } } } } $rows = array_unique($rows); $field_name = get_param('field_name'); $content = new ocp_tempcode(); $i = 0; foreach ($rows as $author => $table) { if ($i >= $start && $i < $start + $max) { if ($table == 'authors') { $content->attach(do_template('AUTHOR_POPUP_WINDOW_DEFINED', array('_GUID' => 'cffa9926cebd3ec2920677266a3299ea', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author))); } else { $content->attach(do_template('AUTHOR_POPUP_WINDOW_UNDEFINED', array('_GUID' => '6210be6d1eef4bc2bda7f49947301f97', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author))); } } $i++; } if ($content->is_empty()) { $content = paragraph(do_lang_tempcode('NO_ENTRIES'), 'dfids09fi;lk;3'); } if ($i >= $start + $max) { $keep = symbol_tempcode('KEEP'); $next_link = find_script('authors') . '?field_name=' . urlencode($field_name) . '&start=' . strval($start + $max) . '&max=' . strval($max) . $keep->evaluate(); } else { $next_link = NULL; } $echo = do_template('STYLED_HTML_WRAP', array('_GUID' => 'ab8d8c9d276530d82ddd84202aacf32f', 'TITLE' => do_lang_tempcode('CHOOSE_AUTHOR'), 'NEXT_LINK' => $next_link, 'CONTENT' => $content)); $echo->evaluate_echo(); }
/** * 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() { return array(array('', 'zones', array('admin', array('type' => 'structure'), get_module_zone('admin')), do_lang_tempcode('STRUCTURE'), 'DOC_STRUCTURE'), array('', 'view_this', array('admin', array('type' => 'usage'), get_module_zone('admin')), do_lang_tempcode('USAGE'), 'DOC_USAGE'), array('', 'manage_themes', array('admin', array('type' => 'style'), get_module_zone('admin')), do_lang_tempcode('STYLE'), 'DOC_STYLE'), array('', 'config', array('admin', array('type' => 'setup'), get_module_zone('admin')), do_lang_tempcode('SETUP'), 'DOC_SETUP'), array('', 'cleanup', array('admin', array('type' => 'tools'), get_module_zone('admin')), do_lang_tempcode('TOOLS'), 'DOC_TOOLS'), array('', 'permissionstree', array('admin', array('type' => 'security'), get_module_zone('admin')), do_lang_tempcode('SECURITY_GROUP_SETUP'), 'DOC_SECURITY'), array('', 'cms_home', array('cms', array('type' => 'cms'), get_module_zone('cms')), do_lang_tempcode('CMS'), 'DOC_CMS'), has_specific_permission(get_member(), 'edit_highrange_content') || has_specific_permission(get_member(), 'edit_own_highrange_content') ? array('cms', 'comcode_page_edit', array('cms_comcode_pages', array('type' => 'misc'), get_module_zone('cms_comcode_pages')), do_lang_tempcode('ITEMS_HERE', do_lang_tempcode('_COMCODE_PAGES'), make_string_tempcode(escape_html(integer_format($GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(DISTINCT the_zone,the_page) FROM ' . get_table_prefix() . 'comcode_pages WHERE ' . db_string_not_equal_to('the_zone', '!')))))), 'DOC_COMCODE_PAGE_EDIT') : NULL, array('structure', 'zones', array('admin_zones', array('type' => 'misc'), get_module_zone('admin_zones')), do_lang_tempcode('ZONES'), 'DOC_ZONES'), array('structure', 'zone_editor', array('admin_zones', array('type' => 'editor'), get_module_zone('admin_zones')), do_lang_tempcode('ZONE_EDITOR'), 'DOC_ZONE_EDITOR'), array('structure', 'menus', array('admin_menus', array('type' => 'misc'), get_module_zone('admin_menus')), do_lang_tempcode('MENU_MANAGEMENT'), 'DOC_MENUS'), addon_installed('page_management') ? array('structure', 'sitetree', array('admin_sitetree', array('type' => 'site_tree'), get_module_zone('admin_sitetree')), do_lang_tempcode('SITE_TREE_EDITOR'), 'DOC_SITE_TREE_EDITOR') : NULL, addon_installed('redirects_editor') ? array('structure', 'redirect', array('admin_redirects', array('type' => 'misc'), get_module_zone('admin_redirects')), do_lang_tempcode('REDIRECTS'), 'DOC_REDIRECTS') : NULL, addon_installed('page_management') ? array('structure', 'pagewizard', array('admin_sitetree', array('type' => 'pagewizard'), get_module_zone('admin_sitetree')), do_lang_tempcode('PAGE_WIZARD'), 'DOC_PAGE_WIZARD') : NULL, addon_installed('breadcrumbs') ? array('structure', 'xml', array('admin_config', array('type' => 'xml_breadcrumbs'), get_module_zone('admin_config')), do_lang_tempcode('BREADCRUMB_OVERRIDES'), 'DOC_BREADCRUMB_OVERRIDES') : NULL, array('structure', 'addons', array('admin_addons', array('type' => 'misc'), get_module_zone('admin_addons')), do_lang_tempcode('ADDONS'), 'DOC_ADDONS'), get_forum_type() != 'ocf' || !addon_installed('ocf_cpfs') ? NULL : array('usage', 'customprofilefields', array('admin_ocf_customprofilefields', array('type' => 'stats'), get_module_zone('admin_ocf_customprofilefields')), do_lang_tempcode('CUSTOM_PROFILE_FIELD_STATS'), 'DOC_CUSTOM_PROFILE_FIELDS_STATS'), addon_installed('errorlog') ? array('usage', 'errorlog', array('admin_errorlog', array(), get_module_zone('admin_errorlog')), do_lang_tempcode('ERROR_LOG'), 'DOC_ERROR_LOG') : NULL, addon_installed('actionlog') ? array('usage', 'actionlog', array('admin_actionlog', array('type' => 'misc'), get_module_zone('admin_actionlog')), do_lang_tempcode('VIEW_ACTION_LOGS'), 'DOC_ACTION_LOG') : NULL, addon_installed('securitylogging') ? array('usage', 'securitylog', array('admin_security', array('type' => 'misc'), get_module_zone('admin_security')), do_lang_tempcode('SECURITY_LOGGING'), 'DOC_SECURITY_LOGGING') : NULL, get_option('mail_queue_debug') !== '1' ? NULL : array('usage', 'email', array('admin_emaillog', array('type' => 'misc'), get_module_zone('admin_emaillog')), do_lang_tempcode('EMAIL_QUEUE'), 'DOC_EMAIL_QUEUE'), array('style', 'manage_themes', array('admin_themes', array('type' => 'misc'), get_module_zone('admin_themes')), do_lang_tempcode('THEMES'), 'DOC_THEMES'), get_forum_type() != 'ocf' ? NULL : array('style', 'emoticons', array('admin_ocf_emoticons', array('type' => 'misc'), get_module_zone('admin_ocf_emoticons')), do_lang_tempcode('EMOTICONS'), 'DOC_EMOTICONS'), array('setup', 'config', array('admin_config', array('type' => 'misc'), get_module_zone('admin_config')), do_lang_tempcode('CONFIGURATION'), 'DOC_CONFIGURATION'), addon_installed('awards') ? array('setup', 'awards', array('admin_awards', array('type' => 'misc'), get_module_zone('admin_awards')), do_lang_tempcode('AWARDS'), 'DOC_AWARDS') : NULL, get_forum_type() == 'ocf' || !addon_installed('welcome_emails') ? NULL : array('setup', 'welcome_emails', array('admin_ocf_welcome_emails', array('type' => 'misc'), get_module_zone('admin_ocf_welcome_emails')), do_lang_tempcode('WELCOME_EMAILS'), 'DOC_WELCOME_EMAILS'), get_forum_type() == 'ocf' ? NULL : array('tools', 'investigateuser', array('admin_lookup', array(), get_module_zone('admin_lookup')), do_lang_tempcode('INVESTIGATE_USER'), 'DOC_INVESTIGATE_USER'), addon_installed('xml_fields') ? array('setup', 'xml', array('admin_config', array('type' => 'xml_fields'), get_module_zone('admin_config')), do_lang_tempcode('FIELD_FILTERS'), 'DOC_FIELD_FILTERS') : NULL, get_forum_type() != 'ocf' ? NULL : array('tools', 'editmember', array('admin_ocf_join', array('type' => 'menu'), get_module_zone('admin_ocf_join')), do_lang_tempcode('MEMBERS'), 'DOC_MEMBERS'), array('tools', 'cleanup', array('admin_cleanup', array('type' => 'misc'), get_module_zone('admin_cleanup')), do_lang_tempcode('CLEANUP_TOOLS'), 'DOC_CLEANUP_TOOLS'), array('security', 'permissionstree', array('admin_permissions', array('type' => 'misc'), get_module_zone('admin_permissions')), do_lang_tempcode('PERMISSIONS_TREE'), 'DOC_PERMISSIONS_TREE'), addon_installed('match_key_permissions') ? array('security', 'matchkeysecurity', array('admin_permissions', array('type' => 'keys'), get_module_zone('admin_permissions')), do_lang_tempcode('PAGE_MATCH_KEY_ACCESS'), 'DOC_PAGE_MATCH_KEY_ACCESS') : NULL, addon_installed('securitylogging') ? array('security', 'ipban', array('admin_ipban', array('type' => 'misc'), get_module_zone('admin_ipban')), do_lang_tempcode('BANNED_ADDRESSES'), 'DOC_IPBAN') : NULL, array('security', 'privileges', array('admin_permissions', array('type' => 'specific'), get_module_zone('admin_permissions')), do_lang_tempcode('GLOBAL_SPECIFIC_PERMISSIONS'), 'DOC_SPECIFIC_PERMISSIONS'), get_forum_type() != 'ocf' ? NULL : array('security', 'usergroups', array('admin_ocf_groups', array('type' => 'misc'), get_module_zone('admin_ocf_groups')), do_lang_tempcode('USERGROUPS'), 'DOC_GROUPS'), get_forum_type() == 'ocf' ? NULL : array('security', 'usergroups', array('admin_permissions', array('type' => 'absorb'), get_module_zone('admin_security')), do_lang_tempcode('ABSORB_PERMISSIONS'), 'DOC_ABSORB_PERMISSIONS'), is_null(get_value('brand_base_url')) ? array('tools', 'cleanup', array('admin_config', array('type' => 'upgrader'), get_module_zone('admin_config')), do_lang_tempcode('FU_UPGRADER_TITLE'), 'FU_UPGRADER_INTRO') : NULL, addon_installed('syndication') ? array('tools', 'cleanup', array('admin_config', array('type' => 'backend'), get_module_zone('admin_config')), do_lang_tempcode('FEEDS'), 'OPML_INDEX_DESCRIPTION') : NULL, addon_installed('code_editor') ? array('tools', 'cleanup', array('admin_config', array('type' => 'code_editor'), get_module_zone('admin_config')), do_lang_tempcode('CODE_EDITOR'), 'DOC_CODE_EDITOR') : NULL); }
/** * Create a pie chart of the ratios of the specified statistic for the specified page. The chart is saved as an SVG image in /data_custom/admin_stats/, and the tempcode for display of the graph and results table is returned * * @param PATH The page path * @param string The statistic to use * @param string Language identifier for the graph title * @param string Language identifier for the graph description * @param string Language identifier for the list title * @return array A linear array containing the graph and list tempcode objects, respectively */ function page_x_share($page, $type, $graph_title, $graph_description, $list_title) { //Return a pie chart with the $type used to view this page $start = get_param_integer('start_' . $type, 0); $max = get_param_integer('max_' . $type, 25); $sortables = array('views' => do_lang_tempcode('_VIEWS')); list($sortable, $sort_order) = explode(' ', get_param('sort', 'views DESC'), 2); if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) { log_hack_attack_and_exit('ORDERBY_HACK'); } global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'sort'; $where = db_string_equal_to('the_page', $page); if (substr($page, 0, 6) == 'pages/') { $where .= ' OR ' . db_string_equal_to('the_page', '/' . $page); } // Legacy compatibility $ip_filter = $GLOBALS['DEBUG_MODE'] ? '' : ' AND ' . db_string_not_equal_to('ip', get_ip_address()); $rows = $GLOBALS['SITE_DB']->query('SELECT id,' . $type . ' FROM ' . get_table_prefix() . 'stats WHERE (' . $where . ')' . $ip_filter, 5000); if (count($rows) < 1) { $list = new ocp_tempcode(); $graph = new ocp_tempcode(); return array($graph, $list); } $data1 = array(); $degrees = 360 / count($rows); foreach ($rows as $value) { //if($value[$type]==0) $value[$type]=do_lang('_UNKNOWN'); if (!array_key_exists($value[$type], $data1)) { $data1[$value[$type]] = $degrees; } else { $data1[$value[$type]] = ($data1[$value[$type]] / $degrees + 1) * $degrees; } } require_code('templates_results_table'); $fields_title = results_field_title(array(do_lang_tempcode($list_title), do_lang_tempcode('COUNT_VIEWS')), $sortables, 'sort', $sortable . ' ' . $sort_order); $fields = new ocp_tempcode(); $data = array(); $done_total = 0; //$done=0; $i = 0; foreach ($data1 as $key => $value) { if ($i < $start) { $i++; continue; } elseif ($i >= $start + $max) { break; } if ($key == '') { $link = do_lang('_UNKNOWN'); } else { $link = escape_html($key); } $fields->attach(results_entry(array($link, escape_html(integer_format($value))))); //if ($done<20) //{ $data[$key] = $value * $degrees; //$done++; $done_total += $value; //} $i++; } if (count($rows) > $done_total) { $data[do_lang('OTHER')] = 360.0 - $done_total * $degrees; $fields->attach(results_entry(array(do_lang('OTHER'), integer_format(count($rows) - $done_total)), true)); } if ($sortable == 'views') { asort($data1); if ($sort_order == 'DESC') { $data1 = array_reverse($data1); } } $list = results_table(do_lang_tempcode('PAGES_STATISTICS', escape_html($page)), $start, 'start_' . $type, $max, 'max_' . $type, $i, $fields_title, $fields, $sortables, $sortable, $sort_order, 'sort_' . $type); $output = create_pie_chart($data); $this->save_graph(strval($rows[0]['id']) . '-' . $type, $output); $graph = do_template('STATS_GRAPH', array('GRAPH' => get_custom_base_url() . '/data_custom/modules/admin_stats/' . strval($rows[0]['id']) . '-' . $type . '.xml', 'TITLE' => do_lang_tempcode($graph_title), 'TEXT' => do_lang_tempcode($graph_description))); return array($graph, $list); }
/** * See if a gallery has any watermarks to use, or all galleries. * * @param ?ID_TEXT The gallery (NULL: all the current user has access to) * @return boolean Whether watermarks are available */ function has_at_least_one_watermark($cat = NULL) { $where = ''; if (!is_null($cat)) { $where = db_string_equal_to('name', $cat) . ' AND '; } $where .= '(' . db_string_not_equal_to('watermark_top_left', ''); $where .= ' OR ' . db_string_not_equal_to('watermark_top_left', ''); $where .= ' OR ' . db_string_not_equal_to('watermark_top_right', ''); $where .= ' OR ' . db_string_not_equal_to('watermark_bottom_left', ''); $where .= ' OR ' . db_string_not_equal_to('watermark_bottom_right', '') . ')'; $gals = $GLOBALS['SITE_DB']->query('SELECT name FROM ' . get_table_prefix() . 'galleries WHERE ' . $where); foreach ($gals as $guy) { $cat = $guy['name']; if (has_category_access(get_member(), 'galleries', $cat)) { return true; } } return false; }
/** * Show a banner according to GET parameter specification. * * @param boolean Whether to return a result rather than outputting * @param ?string Whether we are displaying or click-processing (NULL: get from URL param) * @set "click" "" * @param ?string Specific banner to display (NULL: get from URL param) (blank: randomise) * @param ?string Banner type to display (NULL: get from URL param) * @param ?integer Whether we are only showing our own banners, rather than allowing external rotation ones (NULL: get from URL param) * @param ?string The banner advertisor who is actively displaying the banner (calling up this function) and hence is rewarded (NULL: get from URL param) (blank: our own site) * @return ?tempcode Result (NULL: we weren't asked to return the result) */ function banners_script($ret = false, $type = NULL, $dest = NULL, $b_type = NULL, $internal_only = NULL, $source = NULL) { require_code('images'); require_lang('banners'); // If this is being called for a click through if (is_null($type)) { $type = get_param('type', ''); } if ($type == 'click') { // Input parameters if (is_null($source)) { $source = get_param('source', ''); } if (is_null($dest)) { $dest = get_param('dest', ''); } // Has the banner been clicked before? $test = $GLOBALS['SITE_DB']->query_value('banner_clicks', 'MAX(c_date_and_time)', array('c_ip_address' => get_ip_address(), 'c_banner_id' => $dest)); $unique = is_null($test) || $test < time() - 60 * 60 * 24; // Find the information about the dest $rows = $GLOBALS['SITE_DB']->query_select('banners', array('site_url', 'hits_to', 'campaign_remaining'), array('name' => $dest)); if (!array_key_exists(0, $rows)) { fatal_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $url = $myrow['site_url']; $page_link = url_to_pagelink($url); if ($page_link != '') { $keep = symbol_tempcode('KEEP', array(strpos($url, '?') === false ? '1' : '0')); $url .= $keep->evaluate(); } if ($unique) { if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET hits_to=(hits_to+1) WHERE ' . db_string_equal_to('name', $dest), 1); } $campaignremaining = $myrow['campaign_remaining']; if (!is_null($campaignremaining)) { if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET campaign_remaining=(campaign_remaining-1) WHERE ' . db_string_equal_to('name', $dest), 1); } } } // Find the information about the source if ($source != '' && $unique) { $rows = $GLOBALS['SITE_DB']->query_select('banners', array('hits_from', 'campaign_remaining'), array('name' => $source)); if (!array_key_exists(0, $rows)) { fatal_exit(do_lang_tempcode('BANNER_MISSING_SOURCE')); } $myrow = $rows[0]; if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET hits_from=(hits_from+1) WHERE ' . db_string_equal_to('name', $source), 1); } $campaignremaining = $myrow['campaign_remaining']; if (!is_null($campaignremaining)) { if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET campaign_remaining=(campaign_remaining+1) WHERE ' . db_string_equal_to('name', $source), 1); } } } // Log the click load_user_stuff(); $GLOBALS['SITE_DB']->query_insert('banner_clicks', array('c_date_and_time' => time(), 'c_member_id' => get_member(), 'c_ip_address' => get_ip_address(), 'c_source' => $source, 'c_banner_id' => $dest)); if (strpos($url, chr(10)) !== false || strpos($url, chr(13)) !== false) { log_hack_attack_and_exit('HEADER_SPLIT_HACK'); } header('Location: ' . $url); } else { if (is_null($dest)) { $dest = get_param('dest', ''); } if (is_null($b_type)) { $b_type = get_param('b_type', ''); } if (is_null($internal_only)) { $internal_only = get_param_integer('internal_only', 0); } if ($internal_only == 0 && $dest == '' && $b_type == '') { $adcode = get_option('money_ad_code'); if ($adcode != '' && (0 == $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)', array('validated' => 1)) || mt_rand(0, 100) > intval(get_option('advert_chance')))) { if ($ret) { return make_string_tempcode($adcode); } $echo = do_template('BASIC_HTML_WRAP', array('_GUID' => 'fd6fc24384dd13e7931ceb369a500672', 'TITLE' => do_lang_tempcode('BANNER'), 'CONTENT' => $adcode)); $echo->evaluate_echo(); return NULL; } } // A community banner then... // ========================== // Input parameters (clicks-in from source site) if (is_null($source)) { $source = get_param('source', ''); } // To allow overriding to specify a specific banner if ($dest != '') { $myquery = 'SELECT * FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_equal_to('name', $dest); } else { $myquery = 'SELECT * FROM ' . get_table_prefix() . 'banners WHERE ((the_type<>' . strval(BANNER_CAMPAIGN) . ') OR (campaign_remaining>0)) AND ((expiry_date IS NULL) OR (expiry_date>' . strval(time()) . ')) AND ' . db_string_not_equal_to('name', $source) . ' AND validated=1 AND ' . db_string_equal_to('b_type', $b_type); } // Run Query $rows = $GLOBALS['SITE_DB']->query($myquery, 500, NULL, true); if (is_null($rows)) { $rows = array(); } // Error, but tolerate it as it could be on each page load // Filter out what we don't have permission for if (get_option('use_banner_permissions', true) === '1') { load_user_stuff(); require_code('permissions'); $groups = _get_where_clause_groups(get_member()); if (!is_null($groups)) { $perhaps = collapse_1d_complexity('category_name', $GLOBALS['SITE_DB']->query('SELECT category_name FROM ' . get_table_prefix() . 'group_category_access WHERE ' . db_string_equal_to('module_the_name', 'banners') . ' AND (' . $groups . ')')); $new_rows = array(); foreach ($rows as $row) { if (in_array($row['name'], $perhaps)) { $new_rows[] = $row; } } $rows = $new_rows; } } // Are we allowed to show default banners? $counter = 0; $show_defaults = true; while (array_key_exists($counter, $rows)) { $myrow = $rows[$counter]; if ($myrow['the_type'] == BANNER_CAMPAIGN) { $show_defaults = false; } $counter++; } // Count the total of all importance_modulus entries $tally = 0; $counter = 0; $bound = array(); while (array_key_exists($counter, $rows)) { $myrow = $rows[$counter]; if ($myrow['the_type'] == 2 && !$show_defaults) { $myrow['importance_modulus'] = 0; } $tally += $myrow['importance_modulus']; $bound[$counter] = $tally; $counter++; } if ($tally == 0) { load_user_stuff(); require_code('permissions'); if (has_actual_page_access(NULL, 'cms_banners') && has_submit_permission('mid', get_member(), get_ip_address(), 'cms_banners')) { $add_banner_url = build_url(array('page' => 'cms_banners', 'type' => 'ad'), get_module_zone('cms_banners')); } else { $add_banner_url = new ocp_tempcode(); } $content = do_template('BANNERS_NONE', array('_GUID' => 'b786ec327365d1ef38134ce401db9dd2', 'ADD_BANNER_URL' => $add_banner_url)); if ($ret) { return $content; } $echo = do_template('BASIC_HTML_WRAP', array('_GUID' => '00c8549b88dac8a1291450eb5b681d80', 'TARGET' => '_top', 'TITLE' => do_lang_tempcode('BANNER'), 'CONTENT' => $content)); $echo->evaluate_echo(); return NULL; } // Choose which banner to show from the results $rand = mt_rand(0, $tally); for ($i = 0; $i < $counter; $i++) { if ($rand <= $bound[$i]) { break; } } $name = $rows[$i]['name']; // Update the counts (ones done per-view) if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET views_to=(views_to+1) WHERE ' . db_string_equal_to('name', $name), 1, NULL, false, true); } if ($source != '') { if (get_db_type() != 'xml') { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'banners SET views_from=(views_from+1) WHERE ' . db_string_equal_to('name', $name), 1, NULL, false, true); } } // Display! $img = $rows[$i]['img_url']; $caption = get_translated_tempcode($rows[$i]['caption']); $content = show_banner($name, $rows[$i]['b_title_text'], $caption, $img, $source, $rows[$i]['site_url'], $rows[$i]['b_type']); if ($ret) { return $content; } $echo = do_template('BASIC_HTML_WRAP', array('_GUID' => 'd23424ded86c850f4ae0006241407ff9', 'TITLE' => do_lang_tempcode('BANNER'), 'CONTENT' => $content)); $echo->evaluate_echo(); } return NULL; }
/** * 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)); }
/** * Detect conflicts with an event in certain time periods. * * @param MEMBER The member to detect conflicts for * @param AUTO_LINK The event ID that we are detecting conflicts with (we need this so we don't think we conflict with ourself) * @param array List of pairs specifying our happening time (in time order) * @param boolean Whether to restrict only to viewable events for the current member * @param ?TIME The timestamp that found times must exceed. In user-time (NULL: use find_periods_recurrence default) * @param ?TIME The timestamp that found times must not exceed. In user-time (NULL: use find_periods_recurrence default) * @return array A list of events happening, with time details */ function detect_happening_at($member_id, $skip_id, $our_times, $restrict = true, $period_start = NULL, $period_end = NULL) { if (count($our_times) == 0) { return array(); } $conflicts = array(); $where = is_null($skip_id) ? '' : 'id<>' . strval($skip_id); if ($restrict) { if ($where != '') { $where .= ' AND '; } $where .= '(e_submitter=' . strval((int) $member_id) . ' OR e_is_public=1)'; } if ($where != '') { $where .= ' AND '; } $where .= '(validated=1 OR e_is_public=0)'; $where .= ' AND (((e_start_month>=' . strval(intval(date('m', $our_times[0][0])) - 1) . ' AND e_start_year=' . date('Y', $our_times[0][0]) . ') AND (e_start_month<=' . strval(intval(date('m', $our_times[0][1])) + 1) . ' AND e_start_year=' . date('Y', $our_times[0][1]) . ' OR e_start_year<' . date('Y', $our_times[0][1]) . ')) OR ' . db_string_not_equal_to('e_recurrence', 'none') . ')'; $where = ' WHERE ' . $where; $table = 'calendar_events e'; $events = $GLOBALS['SITE_DB']->query('SELECT *,e.id AS e_id FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $table . $where); foreach ($events as $event) { if (!has_category_access(get_member(), 'calendar', strval($event['e_type']))) { continue; } $their_times = find_periods_recurrence($event['e_timezone'], 1, $event['e_start_year'], $event['e_start_month'], $event['e_start_day'], is_null($event['e_start_hour']) ? find_timezone_start_hour_in_utc($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day']) : $event['e_start_hour'], is_null($event['e_start_minute']) ? find_timezone_start_minute_in_utc($event['e_timezone'], $event['e_start_year'], $event['e_start_month'], $event['e_start_day']) : $event['e_start_minute'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day'], is_null($event['e_end_hour']) ? find_timezone_end_hour_in_utc($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day']) : $event['e_end_hour'], is_null($event['e_end_minute']) ? find_timezone_end_minute_in_utc($event['e_timezone'], $event['e_end_year'], $event['e_end_month'], $event['e_end_day']) : $event['e_end_minute'], $event['e_recurrence'], $event['e_recurrences'], $period_start, $period_end); // Now search every combination to see if we can get a hit foreach ($our_times as $our) { foreach ($their_times as $their) { $conflict = false; if (is_null($our[3]) && is_null($their[3])) { if ($our[2] == $their[2]) { $conflict = true; } } elseif (is_null($our[3]) && !is_null($their[3])) { if ($our[2] >= $their[2] && $our[2] < $their[3]) { $conflict = true; } } elseif (!is_null($our[3]) && is_null($their[3])) { if ($their[2] >= $our[2] && $their[2] < $our[3]) { $conflict = true; } } elseif (!is_null($our[3]) && !is_null($their[3])) { if ($our[2] >= $their[2] && $our[2] < $their[3]) { $conflict = true; } if ($their[2] >= $our[2] && $their[2] < $our[3]) { $conflict = true; } } if ($conflict) { $conflicts[] = array($event['e_id'], $event, $their[2], $their[3]); break 2; } } } } return $conflicts; }
/** * Get all the image IDs (both already known, and those uncached) of a certain type (i.e. under a subdirectory). * * @param ID_TEXT The type of image (e.g. 'ocf_emoticons') * @param boolean Whether to search recursively; i.e. in subdirectories of the type subdirectory * @param ?object The database connection to work over (NULL: site db) * @param ?ID_TEXT The theme to search in, in addition to the default theme (NULL: current theme) * @param boolean Whether to only return directories (advanced option, rarely used) * @param boolean Whether to only return from the database (advanced option, rarely used) * @return array The list of image IDs */ function get_all_image_ids_type($type, $recurse = false, $db = NULL, $theme = NULL, $dirs_only = false, $db_only = false) { if (is_null($db)) { $db = $GLOBALS['SITE_DB']; } if (is_null($theme)) { $theme = $GLOBALS['FORUM_DRIVER']->get_theme(); } if (substr($type, 0, 4) == 'ocf_' && file_exists(get_file_base() . '/themes/default/images/avatars/index.html')) { $type = substr($type, 4); } if (substr($type, -1) == '/') { $type = substr($type, 0, strlen($type) - 1); } $ids = array(); if (!$db_only && ($db->connection_write == $GLOBALS['SITE_DB']->connection_write || $dirs_only || get_db_forums() == get_db_site())) { _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); if ($theme != 'default') { _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); } _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); _get_all_image_ids_type($ids, get_file_base() . '/themes/default/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); if ($theme != 'default') { _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); _get_all_image_ids_type($ids, get_custom_file_base() . '/themes/' . $theme . '/images_custom/' . get_site_default_lang() . '/' . ($type == '' ? '' : $type . '/'), $type, $recurse, $dirs_only); } } if (!$dirs_only) { $query = 'SELECT DISTINCT id,path FROM ' . $db->get_table_prefix() . 'theme_images WHERE '; if (!$db_only) { $query .= 'path NOT LIKE \'' . db_encode_like('themes/default/images/%') . '\' AND ' . db_string_not_equal_to('path', 'themes/default/images/blank.gif') . ' AND '; } $query .= '(' . db_string_equal_to('theme', $theme) . ' OR ' . db_string_equal_to('theme', 'default') . ') AND id LIKE \'' . db_encode_like($type . '%') . '\' ORDER BY path'; $rows = $db->query($query); foreach ($rows as $row) { if ($row['path'] == '') { continue; } if (url_is_local($row['path']) && !file_exists((substr($row['path'], 0, 15) == 'themes/default/' ? get_file_base() : get_custom_file_base()) . '/' . rawurldecode($row['path']))) { continue; } if ($row['path'] != 'themes/default/images/blank.gif') { $ids[] = $row['id']; } else { $key = array_search($row['id'], $ids); if (is_integer($key)) { unset($ids[$key]); } } } } sort($ids); return array_unique($ids); }
/** * The UI to choose session details. * * @return tempcode The UI */ function choose_session2() { $title = get_page_title('IMPORT'); /* Three cases: 1) We are continuing (therefore do nothing) 2) We are resuming a prior session, after our session changed (therefore remap old session-data to current session) 3) We are starting afresh (therefore delete all previous import sessions) 4) As per '3', except OCF imports are maintained as we're now importing a satellite site */ $session = either_param_integer('session', get_session_id()); if ($session == -1 || $session == -2) { // Delete all others $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_session'); if ($session == -1) { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_parts_done'); $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_id_remap'); } else { $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_parts_done WHERE imp_id NOT LIKE \'' . db_encode_like('ocf_%') . '\''); $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'import_id_remap WHERE (id_type NOT LIKE \'' . db_encode_like('ocf_%') . '\'' . ') AND ' . db_string_not_equal_to('id_type', 'category') . ' AND ' . db_string_not_equal_to('id_type', 'forum') . ' AND ' . db_string_not_equal_to('id_type', 'topic') . ' AND ' . db_string_not_equal_to('id_type', 'post') . ' AND ' . db_string_not_equal_to('id_type', 'f_poll') . ' AND ' . db_string_not_equal_to('id_type', 'group') . ' AND ' . db_string_not_equal_to('id_type', 'member')); } $session = get_session_id(); } if ($session != get_session_id()) { // Remap given to current $GLOBALS['SITE_DB']->query_delete('import_session', array('imp_session' => get_session_id()), '', 1); $GLOBALS['SITE_DB']->query_delete('import_parts_done', array('imp_session' => get_session_id())); $GLOBALS['SITE_DB']->query_delete('import_id_remap', array('id_session' => get_session_id())); $GLOBALS['SITE_DB']->query_update('import_session', array('imp_session' => get_session_id()), array('imp_session' => $session), '', 1); $GLOBALS['SITE_DB']->query_update('import_parts_done', array('imp_session' => get_session_id()), array('imp_session' => $session)); $GLOBALS['SITE_DB']->query_update('import_id_remap', array('id_session' => get_session_id()), array('id_session' => $session)); } // Get details from the session row $importer = filter_naughty(get_param('importer')); require_code('hooks/modules/admin_import/' . filter_naughty_harsh($importer)); $object = object_factory('Hook_' . filter_naughty_harsh($importer)); $info = $object->info(); $session_row = $GLOBALS['SITE_DB']->query_select('import_session', array('*'), array('imp_session' => get_session_id()), '', 1); if (array_key_exists(0, $session_row)) { $old_base_dir = $session_row[0]['imp_old_base_dir']; $db_name = $session_row[0]['imp_db_name']; $db_user = $session_row[0]['imp_db_user']; $db_table_prefix = $session_row[0]['imp_db_table_prefix']; $refresh_time = $session_row[0]['imp_refresh_time']; } else { $old_base_dir = get_file_base() . '/old'; $db_name = get_db_site(); $db_user = get_db_site_user(); $db_table_prefix = array_key_exists('prefix', $info) ? $info['prefix'] : $GLOBALS['SITE_DB']->get_table_prefix(); $refresh_time = 15; } // Build the form $fields = new ocp_tempcode(); require_code('form_templates'); if (!method_exists($object, 'probe_db_access')) { $fields->attach(form_input_line(do_lang_tempcode('DATABASE_NAME'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_name', $db_name, true)); $fields->attach(form_input_line(do_lang_tempcode('DATABASE_USERNAME'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_user', $db_user, true)); $fields->attach(form_input_password(do_lang_tempcode('DATABASE_PASSWORD'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_password', false)); // Not required as there may be a blank password $fields->attach(form_input_line(do_lang_tempcode('TABLE_PREFIX'), do_lang_tempcode('_FROM_IMPORTING_SYSTEM'), 'db_table_prefix', $db_table_prefix, true)); } $fields->attach(form_input_line(do_lang_tempcode('FILE_BASE'), do_lang_tempcode('FROM_IMPORTING_SYSTEM'), 'old_base_dir', $old_base_dir, true)); if (intval(ini_get('safe_mode')) == 0) { $fields->attach(form_input_integer(do_lang_tempcode('REFRESH_TIME'), do_lang_tempcode('DESCRIPTION_REFRESH_TIME'), 'refresh_time', $refresh_time, true)); } if (method_exists($object, 'get_extra_fields')) { $fields->attach($object->get_extra_fields()); } $url = build_url(array('page' => '_SELF', 'type' => 'hook', 'session' => $session, 'importer' => $importer), '_SELF'); $message = array_key_exists('message', $info) ? $info['message'] : ''; breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('IMPORT')), array('_SELF:_SELF:session', do_lang_tempcode('IMPORT_SESSION')))); return do_template('FORM_SCREEN', array('_GUID' => '15f2c855acf0d365a2e6329bec692dc8', 'TEXT' => $message, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $url, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'))); }
function referrer_report_script($ret = false) { $member_id = get_param_integer('member_id', NULL); if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) { access_denied('ZONE_ACCESS', 'adminzone'); } require_lang('referrals'); $csv = get_param_integer('csv', 0) == 1; $where = db_string_not_equal_to('i_email_address', '') . ' AND i_inviter<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()); if ($member_id !== NULL) { $where .= ' AND referrer.id=' . strval($member_id); } $max = get_param_integer('max', $csv ? 10000 : 30); $start = get_param_integer('start', 0); $data = array(); $table = 'f_invites i LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referrer ON referrer.id=i_inviter LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referee ON referee.m_email_address=i_email_address'; $referrals = $GLOBALS['FORUM_DB']->query('SELECT i_time AS time,referrer.id AS referrer_id,referrer.m_username AS referrer,referrer.m_email_address AS referrer_email,referee.id AS referee_id,referee.m_username AS referee,referee.m_email_address AS referee_email,i_taken AS qualified FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where . ' ORDER BY i_time DESC', $max, $start); $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where); if (count($referrals) == 0) { inform_exit(do_lang_tempcode('NO_ENTRIES')); } foreach ($referrals as $ref) { $data_row = array(); $data_row[do_lang('DATE_TIME')] = get_timezoned_date($ref['time'], true, true, false, true); if (is_null($member_id)) { if ($csv) { $deleted = true; $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referrer']; } else { $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer_id']) ? '' : strval($ref['referrer_id']); } $data_row[do_lang('TYPE_REFERRER') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = $ref['referrer_email']; $data_row[do_lang('QUALIFIED_REFERRER')] = do_lang(referrer_is_qualified($ref['referrer_id']) ? 'YES' : 'NO'); } $deleted = false; if (is_null($ref['referee'])) { $deleted = $ref['qualified'] == 1; //!is_null($GLOBALS['SITE_DB']->query_value_null_ok('adminlogs','id',array('the_type'=>'DELETE_MEMBER','param_b'=>TODO Unfortunately we can't tell))); } if ($csv) { $data_row[do_lang('REFEREE')] = is_null($ref['referee']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referee']; } else { $data_row[do_lang('REFEREE')] = is_null($ref['referee_id']) ? '' : strval($ref['referee_id']); } $data_row[do_lang('REFEREE') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = is_null($ref['referee_email']) ? '' : $ref['referee_email']; $data_row[do_lang('QUALIFIED_REFERRAL')] = do_lang($ref['qualified'] == 1 ? 'YES' : 'NO'); $data[] = $data_row; } if ($csv) { require_code('files2'); make_csv($data, (is_null($member_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($member_id)) . ' referrals.csv'); } else { require_code('templates_results_table'); $fields_title = new ocp_tempcode(); $fields = new ocp_tempcode(); foreach ($data as $i => $data_row) { if ($i == 0) { $fields_title->attach(results_field_title(array_keys($data_row))); } foreach ($data_row as $key => $val) { if ($key == do_lang('REFEREE') || $key == do_lang('TYPE_REFERRER')) { if ($val == '') { $val = do_lang('UNKNOWN'); } else { $val = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($val, true); } } $data_row[$key] = escape_html($val); } $fields->attach(results_entry($data_row)); } $table = results_table(do_lang('REFERRALS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields); if ($ret) { return $table; } $title = get_page_title('REFERRALS'); $out = new ocp_tempcode(); $out->attach($title); $out->attach($table); $out = globalise($out, NULL, '', true); $out->evaluate_echo(); } return NULL; }
/** * Common theme change saving for adding and editing themes. * * @param ID_TEXT The name of the theme */ function save_theme_changes($theme) { if (!file_exists(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini')) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if (post_param_integer('use_on_all', 0) == 1) { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($theme) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone')); } persistant_cache_empty(); $before = better_parse_ini_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini'); $myfile = @fopen(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini', 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($theme) . '/theme.ini'); if (fwrite($myfile, 'title=' . post_param('title') . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } if (fwrite($myfile, 'description=' . post_param('description') . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } foreach ($before as $key => $val) { if ($key != 'title' && $key != 'description' && $key != 'author' && $key != 'mobile_pages' && $key != 'supports_wide') { fwrite($myfile, $key . '=' . $val . chr(10)); } } if (fwrite($myfile, 'author=' . post_param('author') . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } if (fwrite($myfile, 'mobile_pages=' . post_param('mobile_pages') . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } if (fwrite($myfile, 'supports_wide=' . strval(post_param_integer('supports_wide', 0)) . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); sync_file(($theme == 'default' ? get_file_base() : get_custom_file_base()) . '/themes/' . filter_naughty($theme) . '/theme.ini'); require_code('permissions2'); set_category_permissions_from_environment('theme', $theme); $map = file_exists(get_file_base() . '/themes/map.ini') ? better_parse_ini_file(get_file_base() . '/themes/map.ini') : array(); $new_map = array(); foreach ($map as $key => $val) { if ($val != $theme) { $new_map[$key] = $val; } } if (array_key_exists('mapping', $_POST)) { foreach ($_POST['mapping'] as $val) { if (get_magic_quotes_gpc()) { $val = stripslashes($val); } $new_map[$val] = $theme; } } $myfile = @fopen(get_file_base() . '/themes/map.ini', 'wt') or intelligent_write_error(get_file_base() . '/themes/map.ini'); foreach ($new_map as $key => $val) { if (fwrite($myfile, $key . '=' . $val . chr(10)) == 0) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } } fclose($myfile); sync_file('themes/map.ini'); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (!addon_installed('catalogues')) { return; } $time = time(); $done_reports = array('daily' => false, 'weekly' => false, 'monthly' => false, 'quarterly' => false); $catalogues = $GLOBALS['SITE_DB']->query('SELECT c_title,c_name,c_send_view_reports FROM ' . get_table_prefix() . 'catalogues WHERE ' . db_string_not_equal_to('c_send_view_reports', '') . ' AND ' . db_string_not_equal_to('c_send_view_reports', 'never')); $doing = array(); foreach ($catalogues as $catalogue) { switch ($catalogue['c_send_view_reports']) { case 'daily': $amount = 60 * 60 * 24; break; case 'weekly': $amount = 60 * 60 * 24 * 7; break; case 'monthly': $amount = 60 * 60 * 24 * 31; break; case 'quarterly': $amount = 60 * 60 * 24 * 93; break; default: $amount = NULL; } if (!is_null($amount)) { $last_time = intval(get_value('last_catalogue_reports_' . $catalogue['c_send_view_reports'])); if ($last_time <= $time - $amount) { // Mark done if (!$done_reports[$catalogue['c_send_view_reports']]) { set_value('last_catalogue_reports_' . $catalogue['c_send_view_reports'], strval($time)); $done_reports[$catalogue['c_send_view_reports']] = true; } $doing[] = $catalogue; // Mark as doing, rather than do immediately - so to avoid race conditions } } } if (count($doing) != 0) { require_code('notifications'); require_code('catalogues'); require_lang('catalogues'); } if (function_exists('set_time_limit')) { @set_time_limit(0); } // Now for the intensive part foreach ($doing as $catalogue) { $start = 0; do { // So, we find all the entries in their catalogue, and group them by submitters $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('id', 'ce_submitter', 'ce_views', 'ce_views_prior'), array('c_name' => $catalogue['c_name']), 'ORDER BY ce_submitter', 2000, $start); $members = array(); foreach ($entries as $entry) { if (!array_key_exists($entry['ce_submitter'], $members)) { $members[$entry['ce_submitter']] = array(); } $members[$entry['ce_submitter']][] = $entry; } $catalogue_title = get_translated_text($catalogue['c_title']); $regularity = do_lang('VR_' . strtoupper($catalogue['c_send_view_reports'])); $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue['c_name']), 'ORDER BY id', 1); // And now we send out mails, and get ready for the next report foreach ($members as $member_id => $member) { // Work out the contents of the mail $buildup = ''; foreach ($member as $entry) { $field_values = get_catalogue_entry_field_values($catalogue['c_name'], $entry, array(0), $fields); $entry_title = $field_values[0]['effective_value']; $views = $entry['ce_views'] - $entry['ce_views_prior']; $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views_prior' => $entry['ce_views']), array('id' => $entry['id']), '', 1); $temp = do_lang($catalogue['c_name'] . '__CATALOGUE_VIEW_REPORT_LINE', comcode_escape(is_object($entry_title) ? $entry_title->evaluate() : $entry_title), integer_format($views), NULL, NULL, false); if (is_null($temp)) { $temp = do_lang('DEFAULT__CATALOGUE_VIEW_REPORT_LINE', comcode_escape(is_object($entry_title) ? $entry_title->evaluate() : $entry_title), integer_format($views)); } $buildup .= $temp; } $mail = do_lang($catalogue['c_name'] . '__CATALOGUE_VIEW_REPORT', $buildup, comcode_escape($catalogue_title), $regularity, get_lang($member_id), false); if (is_null($mail)) { $mail = do_lang('DEFAULT__CATALOGUE_VIEW_REPORT', $buildup, comcode_escape($catalogue_title), array($regularity, get_site_name()), get_lang($member_id)); } $subject_tag = do_lang($catalogue['c_name'] . '__CATALOGUE_VIEW_REPORT_SUBJECT', $catalogue_title, get_site_name(), NULL, get_lang($member_id), false); if (is_null($subject_tag)) { $subject_tag = do_lang('DEFAULT__CATALOGUE_VIEW_REPORT_SUBJECT', comcode_escape($catalogue_title), comcode_escape(get_site_name()), NULL, get_lang($member_id)); } // Send actual notification dispatch_notification('catalogue_view_reports__' . $catalogue['c_name'], NULL, $subject_tag, $mail, array($member_id), A_FROM_SYSTEM_PRIVILEGED); } $start += 2000; } while (count($entries) == 2000); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ip_bans($db, $table_prefix, $file_base) { require_code('failure'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'banlist WHERE ' . db_string_not_equal_to('ban_ip', '')); foreach ($rows as $row) { if (import_check_if_imported('ip_ban', strval($row['ban_id']))) { continue; } add_ip_ban($this->_un_phpbb_ip($row['ban_ip'])); import_id_remap_put('ip_ban', strval($row['ban_id']), 0); } }
/** * 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'] = ''; } if (!array_key_exists('title', $map)) { $map['title'] = 'I support'; } //default value $max = array_key_exists('max', $map) ? intval($map['max']) : 100; $height = !empty($map['height']) ? $map['height'] : '100%'; //default: 100% $set_height = ''; if ($height != '100%') { $set_height = ' style="overflow: auto; width: 100%!important; height: ' . $height . '!important;" '; } 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_CUSTOM', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'BANNER' => $bd, 'MORE_COMING' => $more_coming))); } return do_template('BLOCK_MAIN_BUTTONS', array('EXTRA' => $map['extra'], 'TYPE' => $map['param'], 'ASSEMBLE' => $assemble, 'TITLE' => $map['title'], 'SET_HEIGHT' => $set_height)); }
/** * Make a theme. Note that this will trigger the AFM. * * @param string Name of the theme. * @param ID_TEXT The theme it's being generated from * @param ID_TEXT The algorithm to use * @set equations hsv * @param string Seed colour to use. * @param boolean Whether to use the theme immediately. * @param ?boolean Whether it will be a dark theme (NULL: autodetect). * @param boolean Whether to inherit the CSS, for easier theme upgrading. */ function make_theme($themename, $source_theme, $algorithm, $seed, $use, $dark = false, $inherit_css = false) { $GLOBALS['NO_QUERY_LIMIT'] = true; load_themewizard_params_from_theme($source_theme, $algorithm == 'hsv'); if (file_exists(get_custom_file_base() . '/themes/' . $themename)) { require_code('abstract_file_manager'); force_have_afm_details(); $extending_existing = true; } else { if ($source_theme == 'default') { actual_add_theme($themename); } else { require_code('themes3'); actual_copy_theme($source_theme, $themename); } $extending_existing = false; } if ($seed != find_theme_seed($source_theme) || $dark != find_theme_dark($source_theme)) { list($colours, $landscape) = calculate_theme($seed, $source_theme, $algorithm, 'colours', $dark); // Make images global $THEME_WIZARD_IMAGES, $THEME_WIZARD_IMAGES_NO_WILD, $IMG_CODES; if (function_exists('imagecolorallocatealpha')) { require_code('themes2'); $full_img_set = array(); foreach ($THEME_WIZARD_IMAGES as $expression) { if (substr($expression, -1) == '*') { $expression = substr($expression, 0, strlen($expression) - 2); // remove "/*" $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images', $expression))); $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images/' . fallback_lang(), $expression))); } else { $full_img_set[] = $expression; } } if ($extending_existing) { $temp_all_ids = collapse_2d_complexity('id', 'path', $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $themename))); } else { $temp_all_ids = array(); } $_langs = find_all_langs(true); foreach ($full_img_set as $image_code) { if (!in_array($image_code, $THEME_WIZARD_IMAGES_NO_WILD)) { if ($extending_existing && array_key_exists($image_code, $temp_all_ids) && strpos($temp_all_ids[$image_code], $themename . '/images_custom/') !== false && (!url_is_local($temp_all_ids[$image_code]) || file_exists(get_custom_file_base() . '/' . $temp_all_ids[$image_code]))) { continue; } foreach (array_keys($_langs) as $lang) { $orig_path = find_theme_image($image_code, true, true, $source_theme, $lang); if ($orig_path == '') { continue; } // Theme has specified non-existent image as themewizard-compatible if (strpos($orig_path, '/' . $lang . '/') === false && $lang != fallback_lang()) { continue; } if (strpos($orig_path, '/' . fallback_lang() . '/') !== false) { $composite = 'themes/' . filter_naughty($themename) . '/images/' . $lang . '/'; } else { $composite = 'themes/' . filter_naughty($themename) . '/images/'; } $saveat = get_custom_file_base() . '/' . $composite . $image_code . '.png'; $saveat_url = $composite . $image_code . '.png'; // Wipe out ones that might have been copied from source theme if ($source_theme != 'default' && strpos($orig_path, 'images_custom') !== false) { @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.png'); @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpg'); @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.gif'); @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpeg'); } if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') { $image = calculate_theme($seed, $source_theme, $algorithm, $image_code, $dark, $colours, $landscape, $lang); if (!is_null($image)) { $pos = strpos($image_code, '/'); if ($pos !== false || strpos($orig_path, '/' . fallback_lang() . '/') !== false) { afm_make_directory($composite . substr($image_code, 0, $pos), true, true); } @imagepng($image, $saveat) or intelligent_write_error($saveat); imagedestroy($image); fix_permissions($saveat); sync_file($saveat); actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true); //if ($lang==fallback_lang()) $IMG_CODES['site'][$image_code]=$saveat_url; } } else { actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true); } } } } } // Make sheets $dh = opendir(get_file_base() . '/themes/' . filter_naughty($source_theme) . ($source_theme == 'default' ? '/css/' : '/css_custom/')); while (($sheet = readdir($dh)) !== false) { if (substr($sheet, -4) == '.css') { $saveat = get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet; if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') { $fp = @fopen($saveat, 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet); if ($inherit_css) { $output = '{+START,CSS_INHERIT,' . basename($sheet, '.css') . ',' . filter_naughty($source_theme) . ',' . $seed . ',' . ($dark ? '1' : '0') . ',' . $algorithm . '}{+END}'; } else { $output = theme_wizard_colours_to_sheet($sheet, $landscape, $source_theme, $algorithm, $seed); } if (fwrite($fp, $output) < strlen($output)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($fp); fix_permissions($saveat); sync_file($saveat); if (!$inherit_css) { $c_success = @copy(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/css/' . $sheet, $saveat . '.editfrom'); if ($c_success !== false) { fix_permissions($saveat . '.editfrom'); sync_file($saveat . '.editfrom'); } } else { @unlink($saveat . '.editfrom'); } } } } } // Use it, if requested if ($use) { $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($themename) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone')); $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename)); foreach (array_keys($groups) as $group_id) { if (in_array($group_id, $admin_groups)) { continue; } $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename, 'group_id' => $group_id)); } persistant_cache_empty(); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_polls_and_votes($db, $table_prefix, $file_base) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'topics t LEFT JOIN ' . $table_prefix . 'poll_options o ON t.topic_id=o.topic_id WHERE ' . db_string_not_equal_to('poll_title', '')); foreach ($rows as $row) { if (import_check_if_imported('poll', strval($row['topic_id']))) { continue; } $topic_id = import_id_remap_get('topic', strval($row['topic_id']), true); $is_open = $row['poll_start'] > time() && ($row['poll_length'] == 0 || $row['poll_start'] + $row['poll_length'] < time()); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'poll_options WHERE topic_id=' . strval($row['topic_id']) . ' ORDER BY poll_option_id'); $answers = array(); foreach ($rows2 as $answer) { $answers[] = $answer['poll_option_text']; } $maximum = 1; $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'poll_votes WHERE topic_id=' . strval($row['topic_id'])); foreach ($rows2 as $row2) { $row2['vote_user_id'] = import_id_remap_get('member', strval($row2['vote_user_id']), true); } $id_new = ocf_make_poll($topic_id, $row['poll_option_text'], 0, $is_open ? 1 : 0, 1, $maximum, 0, $answers, false); $answers = collapse_1d_complexity('id', $GLOBALS['FORUM_DB']->query_select('f_poll_answers', array('id'), array('pa_poll_id' => $id_new))); // Effectively, a remapping from IPB vote number to ocP vote number foreach ($rows2 as $row2) { $member_id = $row2['vote_user_id']; if (!is_null($member_id) && $member_id != 0) { if ($row2['poll_option_id'] == 0 || !array_key_exists($row2['poll_option_id'] - 1, $answers)) { $answer = -1; } else { $answer = $answers[$row2['poll_option_id'] - 1]; } $GLOBALS['FORUM_DB']->query_insert('f_poll_votes', array('pv_poll_id' => $id_new, 'pv_member_id' => $member_id, 'pv_answer_id' => $answer)); } } import_id_remap_put('poll', strval($row['topic_id']), $id_new); } }
/** * Import to ocPortal database table from an XML row (possibly having descendant rows, via tree structure). * * @param object The XML parser object * @param array Existing data in table * @param array Field meta data for all fields * @param array Meta data about table IDs * @param array The record details being imported * @param array The insert IDs thus far * @param ?AUTO_LINK The ID of the auto-inserted parent to this row (NULL: N/A) * @return array List of operations performed */ function _import_xml_row($parsed, &$all_existing_data, $all_fields, $all_id_fields, $table, &$insert_ids, $last_parent_id = NULL) { $ops = array(); if (!array_key_exists($table[0], $all_fields)) { return array(); } // No such table if (!array_key_exists($table[0], $all_existing_data)) { $all_existing_data[$table[0]] = $GLOBALS['SITE_DB']->query_select($table[0], array('*'), NULL, '', NULL, NULL, false, array()); } $data = array(); // Collate simple data $data = array(); foreach ($table[1] as $key => $val) { // Find corresponding field foreach ($all_fields[$table[0]] as $field) { if ($field['m_name'] == $key) { break; } } if ($field['m_name'] != $key) { continue; } // No such field $value = mixed(); switch (str_replace('?', '', str_replace('*', '', $field['m_type']))) { case 'TIME': $value = $val == '' ? NULL : strtotime($val); break; case 'GROUP': case 'USER': case 'BINARY': case 'SHORT_INTEGER': case 'INTEGER': case 'AUTO_LINK': case 'AUTO': $value = $val == '' ? NULL : intval($val); break; case 'REAL': // float $value = floatval($val); break; default: $value = $val; break; } if ($value === 'PARENT_INSERT_ID') { $value = $last_parent_id; } elseif (substr($value, 0, strlen('LAST_INSERT_ID_')) === 'LAST_INSERT_ID_') { $value = isset($insert_ids[substr($value, strlen('LAST_INSERT_ID_'))]) ? $insert_ids[substr($value, strlen('LAST_INSERT_ID_'))] : NULL; } $data[$key] = $value; } $tree_children = array(); foreach ($table[3] as $__) { if (!is_array($__)) { continue; } list($row_tag, $row_attributes, $row_value, $row_children) = $__; // Find corresponding field foreach ($all_fields[$table[0]] as $field) { if ($field['m_name'] == $row_tag) { break; } } if ($field['m_name'] != $row_tag) { $tree_children[] = $__; } else { if (count($row_children) != 0 && trim($row_value) == '') { $row_value = $parsed->pull_together($row_children); } if (strpos($field['m_type'], 'TRANS') === false) { $value = mixed(); switch (str_replace('?', '', str_replace('*', '', $field['m_type']))) { case 'TIME': $value = $row_value == '' ? NULL : strtotime($row_value); break; case 'GROUP': case 'USER': case 'BINARY': case 'SHORT_INTEGER': case 'INTEGER': case 'AUTO_LINK': case 'AUTO': $value = $row_value == '' ? NULL : intval($row_value); break; case 'REAL': // float $value = floatval($row_value); break; default: $value = $row_value; break; } if ($value === 'PARENT_INSERT_ID') { $value = $last_parent_id; } elseif (is_string($value) && substr($value, 0, strlen('LAST_INSERT_ID_')) === 'LAST_INSERT_ID_') { $value = isset($insert_ids[substr($value, strlen('LAST_INSERT_ID_'))]) ? $insert_ids[substr($value, strlen('LAST_INSERT_ID_'))] : NULL; } $data[$row_tag] = $value; } } } // Does it already exist $key_map = array(); $update = NULL; $existing_data = NULL; foreach ($all_fields[$table[0]] as $field) { if (strpos($field['m_type'], '*') !== false) { if (!array_key_exists($field['m_name'], $data)) { $update = false; break; } $key_map[$field['m_name']] = $data[$field['m_name']]; } } if (is_null($update)) { $same = false; foreach ($all_existing_data[$table[0]] as $i => $e) { $same = true; foreach ($key_map as $xk => $xv) { if ($e[$xk] !== $xv) { $same = false; // will reset to true right away except for the last iteration - in which case the "$update=$same;" line will take note continue 2; } } // If we're still here we got a match $existing_data = $all_existing_data[$table[0]][$i]; unset($all_existing_data[$table[0]][$i]); break; } $update = $same; } // Collate lang string data foreach ($table[3] as $__) { if (!is_array($__)) { continue; } list($row_tag, $row_attributes, $row_value, $row_children) = $__; if (count($row_children) != 0 && trim($row_value) == '') { $row_value = $parsed->pull_together($row_children); } // Find corresponding field foreach ($all_fields[$table[0]] as $field) { if ($field['m_name'] == $row_tag) { break; } } if ($field['m_name'] != $row_tag) { continue; } // No such field if (strpos($field['m_type'], 'TRANS') !== false || $table[0] == 'config' && $field['m_name'] == 'config_value' && $row_value != '' && strpos($data['the_type'], 'trans') !== false) { if ($update) { $lang_update_map = array('text_original' => $row_value, 'text_parsed' => ''); if (array_key_exists('source_user', $row_attributes)) { $lang_update_map['source_user'] = intval($row_attributes['source_user']); } if (array_key_exists('importance_level', $row_attributes)) { $lang_update_map['importance_level'] = intval($row_attributes['importance_level']); } $lang_where_map = array('id' => $existing_data[$row_tag], 'language' => array_key_exists('language', $row_attributes) ? $row_attributes['language'] : get_site_default_lang()); $GLOBALS['SITE_DB']->query_update('translate', $lang_update_map, $lang_where_map, '', 1); $data[$row_tag] = $existing_data[$row_tag]; } else { $data[$row_tag] = $GLOBALS['SITE_DB']->query_insert('translate', array('source_user' => array_key_exists('source_user', $row_attributes) ? intval($row_attributes['source_user']) : get_member(), 'broken' => 0, 'importance_level' => array_key_exists('importance_level', $row_attributes) ? intval($row_attributes['importance_level']) : 2, 'text_original' => $row_value, 'text_parsed' => '', 'language' => array_key_exists('language', $row_attributes) ? $row_attributes['language'] : get_site_default_lang()), true); } } } // Amend DB $id_field = array_key_exists($table[0], $all_id_fields) ? $all_id_fields[$table[0]] : NULL; if ($update) { $GLOBALS['SITE_DB']->query_update($table[0], $data, $key_map, '', 1); $data_diff = $data; foreach ($existing_data as $key => $val) { if (array_key_exists($key, $data_diff) && $data_diff[$key] == $val) { unset($data_diff[$key]); } } $ops[] = array(do_lang('UPDATED_IN_TABLE', $table[0]), do_lang('RECORD_IDENTIFIED_BY', make_map_nice($key_map)), $data_diff == array() ? do_lang('NO_CHANGES_MADE') : make_map_nice($data_diff)); $insert_ids[$table[0]] = array_key_exists($id_field, $key_map) ? $key_map[$id_field] : NULL; } else { $insert_ids[$table[0]] = $GLOBALS['SITE_DB']->query_insert($table[0], $data, !is_null($id_field) && !array_key_exists($id_field, $data)); $ops[] = array(do_lang('INSERTED_TO_TABLE', $table[0]), make_map_nice($data)); } // Special case for CPF's if ($table[0] == 'f_custom_fields') { $test = $GLOBALS['SITE_DB']->query_select('f_member_custom_fields', array('*'), NULL, '', 1); if (!array_key_exists('field_' . strval($insert_ids[$table[0]]), $test[0])) { $_record = $GLOBALS['SITE_DB']->query_select($table[0], array('*'), array('id' => $insert_ids[$table[0]])); $record = $_record[0]; $encrypted = $record['cf_encrypted']; $type = $record['cf_type']; $id = $insert_ids[$table[0]]; $index = false; switch ($type) { case 'multilist': case 'long_text': $index = true; $_type = 'LONG_TEXT'; break; case 'short_trans': $_type = '?SHORT_TRANS'; break; case 'long_trans': $_type = '?LONG_TRANS'; break; case 'tick': $_type = 'BINARY'; break; case 'integer': $_type = '?INTEGER'; break; default: $index = true; $_type = $encrypted == 1 ? 'LONG_TEXT' : 'SHORT_TEXT'; } require_code('database_action'); // ($index?'#':''). $GLOBALS['SITE_DB']->add_table_field('f_member_custom_fields', 'field_' . strval($id), $_type); // Default will be made explicit when we insert rows if ($index) { $indices_count = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'f_custom_fields WHERE ' . db_string_not_equal_to('cf_type', 'integer') . ' AND ' . db_string_not_equal_to('cf_type', 'tick') . ' AND ' . db_string_not_equal_to('cf_type', 'long_trans') . ' AND ' . db_string_not_equal_to('cf_type', 'short_trans')); if ($indices_count < 60) { $GLOBALS['SITE_DB']->create_index('f_member_custom_fields', '#mcf' . strval($id), array('field_' . strval($id)), 'mf_member_id'); } } } } // Handle tree children $this_id = isset($insert_ids[$table[0]]) ? $insert_ids[$table[0]] : NULL; foreach ($tree_children as $__) { $_ops = _import_xml_row($parsed, $all_existing_data, $all_fields, $all_id_fields, $__, $insert_ids, $this_id); $ops = array_merge($ops, $_ops); } return $ops; }
/** * Delete an old moniker, and place a new one. * * @param ID_TEXT Page name. * @param ID_TEXT Screen type code. * @param ID_TEXT Resource ID. * @param string String from which a moniker will be chosen (may not be blank). * @param ?string Whether to skip the exists check for a certain moniker (will be used to pass "existing self" for edits) (NULL: nothing existing to check against). * @return string Chosen moniker. */ function _choose_moniker($page, $type, $id, $moniker_src, $no_exists_check_for = NULL) { $moniker_src = strip_comcode($moniker_src); $moniker = str_replace(array('ä', 'ö', 'ü', 'ß'), array('ae', 'oe', 'ue', 'ss'), $moniker_src); $moniker = strtolower(preg_replace('#[^A-Za-z\\d\\_\\-]#', '-', $moniker)); if (strlen($moniker) > MAX_MONIKER_LENGTH) { $pos = strrpos(substr($moniker, 0, MAX_MONIKER_LENGTH), '-'); if ($pos === false || $pos < 12) { $pos = MAX_MONIKER_LENGTH; } $moniker = substr($moniker, 0, $pos); } $moniker = preg_replace('#\\-+#', '-', $moniker); $moniker = rtrim($moniker, '-'); if ($moniker == '') { $moniker = 'untitled'; } // Check it does not already exist $moniker_origin = $moniker; $next_num = 1; if (is_numeric($moniker)) { $moniker .= '_1'; } $test = mixed(); do { if (!is_null($no_exists_check_for)) { if ($moniker == preg_replace('#^.*/#', '', $no_exists_check_for)) { return $moniker; } // This one is okay, we know it is safe } $test = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT m_resource_id FROM ' . get_table_prefix() . 'url_id_monikers WHERE ' . db_string_equal_to('m_resource_page', $page) . ' AND ' . db_string_equal_to('m_resource_type', $type) . ' AND ' . db_string_not_equal_to('m_resource_id', $id) . ' AND (' . db_string_equal_to('m_moniker', $moniker) . ' OR m_moniker LIKE \'' . db_encode_like('%/' . $moniker) . '\')'); if (!is_null($test)) { $next_num++; $moniker = $moniker_origin . '_' . strval($next_num); } } while (!is_null($test)); return $moniker; }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_lang('search'); require_css('search'); $zone = array_key_exists('zone', $map) ? $map['zone'] : get_module_zone('search'); $max_tags = array_key_exists('max', $map) ? intval($map['max']) : 30; $tags = array(); $largest_num = 0; $smallest_num = mixed(); $search_limiter = array('all_defaults' => '1'); // Find all keywords, hence all tags $limit_to = array_key_exists('param', $map) ? $map['param'] : ''; // HACKHACK: No correlation between meta keywords and search hook names, so we have to specify both in here if ($limit_to != '') { $where = ''; foreach (explode(',', $limit_to) as $l) { if ($where != '') { $where .= ' OR '; } $where .= db_string_equal_to('meta_for_type', $l); $search_limiter['search_' . $l] = 1; } $search_limiter['all_defaults'] = '0'; } else { $where = '1=1'; } $where .= ' AND ' . db_string_not_equal_to('text_original', ''); $meta_rows = $GLOBALS['SITE_DB']->query('SELECT meta_for_type,meta_for_id,text_original AS meta_keywords_nice,meta_keywords FROM ' . get_table_prefix() . 'seo_meta m LEFT JOIN ' . get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND m.meta_keywords=t.id WHERE ' . $where . ' ORDER BY m.id DESC', 300); foreach ($meta_rows as $mr) { if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($mr['meta_keywords_nice'])) { $mr['meta_keywords_nice'] = get_translated_text($mr['meta_keywords']); } $keywords = explode(',', $mr['meta_keywords_nice']); foreach ($keywords as $keyword) { $keyword = trim($keyword); if ($keyword == '') { continue; } if (strlen(is_numeric($keyword) ? strval(intval($keyword)) : $keyword) < 4) { continue; } // Won't be indexed, plus will uglify the tag list if (!array_key_exists($keyword, $tags)) { $tags[$keyword] = 0; } $tags[$keyword]++; } } arsort($tags); $_tags = $tags; $tags = array(); foreach ($_tags as $tag => $count) { if (!is_string($tag)) { $tag = strval($tag); } $tags[$tag] = $count; if (count($tags) == $max_tags) { break; } } ksort($tags); if (count($tags) == 0) { return new ocp_tempcode(); } // Work out variation in sizings foreach ($tags as $tag => $count) { if (is_null($smallest_num) || $count < $smallest_num) { $smallest_num = $count; } if ($count > $largest_num) { $largest_num = $count; } } // Scale tag sizings into em figures, and generally prepare for templating $max_em = 2.5; $min_em = 0.85; $tpl_tags = array(); foreach ($tags as $tag => $count) { if (!is_string($tag)) { $tag = strval($tag); } if ($smallest_num == $largest_num) { $em = 1.0; } else { $fraction = floatval($count - $smallest_num) / floatval($largest_num); $em = $min_em + $fraction * ($max_em - $min_em); } $tpl_tags[] = array('TAG' => $tag, 'COUNT' => strval($count), 'EM' => float_to_raw_string($em), 'LINK' => build_url(array('page' => 'search', 'type' => 'results', 'content' => '"' . $tag . '"', 'days' => -1, 'only_search_meta' => '1') + $search_limiter, $zone)); } $title = array_key_exists('title', $map) ? $map['title'] : do_lang('TAG_CLOUD'); return do_template('BLOCK_SIDE_TAG_CLOUD', array('TAGS' => $tpl_tags, 'TITLE' => $title)); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_blocks($db, $table_prefix, $old_base_dir) { require_code('menus2'); //start importing PHP blocks $rows = $db->query('SELECT * FROM ' . $table_prefix . 'blocks WHERE ' . db_string_not_equal_to('file', '') . ' AND ' . db_string_equal_to('active', 'checked') . ' ORDER BY progressive ASC'); foreach (array('', '/site') as $zone) { $left_panel = get_file_base() . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_left.txt'; $right_panel = get_file_base() . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/panel_right.txt'; $center_panel = get_file_base() . $zone . '/pages/comcode_custom/' . get_site_default_lang() . '/start.txt'; //ensure that there is custom left panel if (!file_exists($left_panel)) { $source_path = get_file_base() . $zone . '/pages/comcode/' . get_site_default_lang() . '/panel_left.txt'; if (file_exists($source_path)) { copy($source_path, $left_panel); } else { //create file $myfile = @fopen($left_panel, 'w'); if ($myfile !== false) { fwrite($myfile, ''); fclose($myfile); } } } //ensure that there is custom right panel if (!file_exists($right_panel)) { $source_path = get_file_base() . $zone . '/pages/comcode/' . get_site_default_lang() . '/panel_right.txt'; if (file_exists($source_path)) { copy($source_path, $right_panel); } else { //create file $myfile = @fopen($right_panel, 'w'); if ($myfile !== false) { fwrite($myfile, ''); fclose($myfile); } } } //ensure that there is custom start panel if (!file_exists($center_panel)) { $source_path = get_file_base() . $zone . '/pages/comcode/' . get_site_default_lang() . '/start.txt'; if (file_exists($source_path)) { copy($source_path, $center_panel); } else { //create file $myfile = @fopen($center_panel, 'wt'); if ($myfile !== false) { fwrite($myfile, ''); fclose($myfile); } } } //blocks remap array $blocks_remap = array('Online Users' => 'side_users_online', 'online_home' => 'side_users_online', 'Calendar' => 'side_calendar', 'last_downloads' => 'main_recent_downloads', 'Latest News' => 'main_news', 'Site Stats' => 'side_stats', 'Random Image' => 'main_iotd', 'random_quote' => 'main_quotes', 'poll' => 'main_poll', 'search' => 'main_search', 'Lang' => 'side_language', 'Boardnews' => 'main_forum_news', 'Last Shouts' => 'side_shoutbox'); //go through all of the PHP blocks foreach ($rows as $row) { //find whether it is left (position=sinistra), center (position=centro), or right (position=destra). $position = $row['position'] == 'sinistra' ? $left_panel : ($row['position'] == 'destra' ? $right_panel : $center_panel); $middle = $position == $center_panel; $orig_block = $row['title']; //ignore blocks that could not be remapped if (!isset($blocks_remap[$row['title']]) || strlen($blocks_remap[$row['title']]) == 0) { $exceptions = array('Board Menu', 'Personal Menu', 'last_blog_post', 'last_forum_post', 'Latest News'); //skip next steps, if not needed if (!in_array($orig_block, $exceptions)) { continue; } //board menu if ($orig_block == 'Board Menu') { //get position block content $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/forum_features/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block="forum_features" type="tree" caption="Forums"]side_stored_menu[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } //personal menu if ($orig_block == 'Personal Menu') { //get position block content $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/pc_features/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block="pc_features" type="tree" caption="My stuff"]side_stored_menu[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } //if the block is not set we need to include it at the end if (preg_match('/pc_edit/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block="pc_edit" type="tree" caption="Settings" silent_failure="1"]side_stored_menu[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } //last blog post if ($orig_block == 'last_blog_post') { //get position block content $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/Last\\sblog\\spost/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block="1" blogs="1" title="Last blog post"]side_news[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } //news if ($orig_block == 'Latest News') { //get position block content $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/main\\_news/', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block blogs="0"]main_news[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } //last forum posts if ($orig_block == 'last_forum_post') { //get position block content $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/Last\\sforum\\spost/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block="General chat" title="Last forum post"]main_forum_topics[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } continue; } $remapped_block = $blocks_remap[$row['title']]; $contents = @file_get_contents($position); if ($contents === false) { continue; } //if the block is not set we need to include it at the end if (preg_match('/' . $remapped_block . '/im', $contents) == 0) { $myfile = @fopen($position, 'at+'); if ($myfile === false) { continue; } $out = ''; $out .= chr(10) . ($middle ? chr(10) : '') . '[block]' . $remapped_block . '[/block]'; fwrite($myfile, $out); //add block to the appropiate position in the end of the file fclose($myfile); } } //get pinned category id $pinned_news_cat_id = $this->get_news_category_id(do_lang('PINNED_NEWS'), ''); $pinned_news = $GLOBALS['SITE_DB']->query_value_null_ok('news', 'id', array('news_category' => $pinned_news_cat_id)); if (!is_null($pinned_news)) { //add pinned news module at the top of the center panel (start.txt) $contents = @file_get_contents($center_panel); if ($contents === false) { $contents = ''; } $myfile = @fopen($center_panel, 'wt+'); if ($myfile !== false) { //prepare the content to be written $out = ''; //just to ensure $out .= '[block="10000" blogs="0" filter="' . $pinned_news_cat_id . '" title="' . do_lang('PINNED_NEWS') . '"]main_news[/block]' . (chr(10) . ($middle ? chr(10) : '')) . $contents; //fseek($myfile, 0); //set the pointer at the start of the file fwrite($myfile, $out); //write the content of the from it's start fclose($myfile); //close file } } fix_permissions($left_panel); fix_permissions($right_panel); fix_permissions($center_panel); sync_file($left_panel); sync_file($right_panel); sync_file($center_panel); } //start importing PHP blocks $rows = $db->query('SELECT * FROM ' . $table_prefix . 'blocks WHERE ' . db_string_equal_to('file', '') . ' AND ' . db_string_equal_to('active', 'checked') . ' ORDER BY progressive ASC'); //go through all of the non-PHP blocks foreach ($rows as $row) { if (preg_match('/class="mkicon"/im', $row['content']) != 0) { //it is a links block $matches = array(); preg_match_all('/href=\\"(.*)\\".*>(.*)<\\/a>/Uim', $row['content'], $matches); $matches_url = isset($matches[1]) && is_array($matches[1]) ? $matches[1] : array(); $matches_titles = isset($matches[2]) && is_array($matches[2]) ? $matches[2] : array(); $block_title = @html_entity_decode($row['title'], ENT_QUOTES, get_charset()); $out = chr(10) . '[block="mkp_block_' . strval($row['id']) . '" type="tree" caption="' . comcode_escape($block_title) . '"]side_stored_menu[/block]'; $left_panel_contents = file_get_contents($left_panel); if (strpos($left_panel_contents, $out) === false) { $myfile = @fopen($left_panel, 'at'); if ($myfile !== false) { fwrite($myfile, $out); //write the content of the from it's start fclose($myfile); //close file } fix_permissions($left_panel); sync_file($left_panel); } //if there are urls to be changed if (count($matches_url) > 0) { foreach ($matches_url as $key => $url) { $link_title = isset($matches_titles[$key]) && strlen($matches_titles[$key]) > 0 ? $matches_titles[$key] : ''; $_url_match = array(); preg_match('/pid=.*/i', $url, $_url_match); $url_match = isset($_url_match[0]) && strlen($_url_match[0]) > 0 ? $_url_match[0] : ''; $url_match = preg_replace('/pid=/', '', $url_match); add_menu_item_simple('mkp_block_' . strval($row['id']), NULL, html_entity_decode($link_title, ENT_QUOTES, get_charset()), ':pn' . $url_match); } } } else { //it is not a links block, so we write it into a new page $page_title = $row['title']; $page = ''; $c_dir = get_custom_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/'; $comcode_pages_title = do_lang('COMCODE_PAGES'); //get other custom comcode pages names $older_comcode_files = array(); $d = opendir($c_dir); while (false !== ($entry = readdir($d))) { if (preg_match('/pn.*\\.txt/', $entry) != 0) { $arr_index = intval(preg_replace('/pn|\\.txt/', '', $entry)); $older_comcode_files[$arr_index] = $arr_index; } } closedir($d); ksort($older_comcode_files); //get the highest comcode page id $max_index = end($older_comcode_files); $max_index = is_null($max_index) ? 1 : $max_index; $page .= ' - [page caption="' . $page_title . '"]pn' . strval($max_index + 1) . '[/page]' . chr(10); $page2 = do_template('IMPORT_MKPORTAL_FCOMCODEPAGE', array('TITLE' => $page_title, 'SUBTITLE' => '', 'PAGE_HEADER' => '', 'TEXT' => $page, 'PAGE_FOOTER' => '', 'SIGNATURE' => '')); //save the comcode file $path = $c_dir . 'pn' . strval($max_index + 1) . '.txt'; $myfile = @fopen($path, 'at'); if ($myfile === false) { intelligent_write_error($path); } fwrite($myfile, $page2->evaluate()); fclose($myfile); fix_permissions($path); sync_file($path); //add info about comcode file $path = $c_dir . 'pnindex.txt'; $myfile = @fopen($path, 'at'); if ($myfile === false) { intelligent_write_error($path); } fwrite($myfile, $page); fclose($myfile); fix_permissions($path); sync_file($path); } } }
/** * Delete a privilege, and every usergroup is then relaxed from the restrictions of this permission. * * @param ID_TEXT The codename of the permission */ function delete_specific_permission($name) { $GLOBALS['SITE_DB']->query_delete('sp_list', array('the_name' => $name), '', 1); $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'gsp WHERE ' . db_string_not_equal_to('module_the_name', 'forums') . ' AND ' . db_string_equal_to('specific_permission', $name)); }
/** * Get a list of authors. * * @param ?ID_TEXT The author to select by default (NULL: no specific default) * @return tempcode The list */ function nice_get_authors($it = NULL) { $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\''); $authors = array(); foreach ($author_fields as $field) { if ($field['m_table'] != 'modules' && $field['m_table'] != 'blocks' && $field['m_table'] != 'addons') { $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name']); foreach ($rows_new as $row) { $authors[] = $row[$field['m_name']]; } } } $authors = array_unique($authors); sort($authors); $out = new ocp_tempcode(); foreach ($authors as $author) { $selected = $author == $it; $out->attach(form_input_list_entry($author, $selected, $author)); } return $out; }
/** * Standard modular render function for profile tabs edit hooks. * * @param MEMBER The ID of the member who is being viewed * @param MEMBER The ID of the member who is doing the viewing * @param boolean Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later * @return ?array A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set) */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $order = 0; // Actualiser if (post_param('submitting_settings_tab', NULL) !== NULL) { require_code('ocf_members_action2'); $is_ldap = ocf_is_ldap_member($member_id_of); $is_httpauth = ocf_is_httpauth_member($member_id_of); $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote'; if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) { $password = NULL; } else { $password = post_param('edit_password'); if ($password == '') { $password = NULL; } else { $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } } } $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', NULL); if (has_specific_permission($member_id_viewing, 'member_maintenance')) { $validated = post_param_integer('validated', 0); $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL); $is_perm_banned = post_param_integer('is_perm_banned', 0); $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned'); if ($old_is_perm_banned != $is_perm_banned) { if ($is_perm_banned == 1) { ocf_ban_member($member_id_of); } else { ocf_unban_member($member_id_of); } } $highlighted_name = post_param_integer('highlighted_name', 0); if (has_specific_permission($member_id_viewing, 'probate_members')) { $on_probation_until = get_input_date('on_probation_until'); $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) { log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) { log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } } else { $on_probation_until = NULL; } } else { $validated = NULL; $primary_group = NULL; $highlighted_name = NULL; $on_probation_until = NULL; } if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) { $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL); } else { $username = NULL; } $email = post_param('email_address', NULL); if (!is_null($email)) { $email = trim($email); } $theme = post_param('theme', NULL); if ($is_remote) { $preview_posts = NULL; $zone_wide = NULL; $auto_monitor_contrib_content = NULL; $views_signatures = NULL; $timezone = NULL; } else { $preview_posts = post_param_integer('preview_posts', 0); $zone_wide = post_param_integer('zone_wide', 0); $auto_monitor_contrib_content = NULL; //post_param_integer('auto_monitor_contrib_content',0); Moved to notifications tab $views_signatures = post_param_integer('views_signatures', 0); $timezone = post_param('timezone', get_site_timezone()); } ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until); if (!array_key_exists('secondary_groups', $_POST)) { $_POST['secondary_groups'] = array(); } require_code('ocf_groups_action2'); $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) { continue; } if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) { ocf_add_member_to_group($member_id_of, $group['id']); } } foreach ($members_groups as $group_id) { if (!in_array(strval($group_id), $_POST['secondary_groups'])) { ocf_member_leave_group($group_id, $member_id_of); } } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', '')); // So any re-confirms can happen if (addon_installed('awards')) { require_code('awards'); handle_award_setting('member', strval($member_id_of)); } attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $title = do_lang_tempcode('SETTINGS'); $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of); if (is_null($myrow)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } require_code('ocf_members_action2'); list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('member', strval($member_id_of))); } $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $hidden->attach(form_input_hidden('redirect', $redirect)); } $hidden->attach(form_input_hidden('submitting_settings_tab', '1')); $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $text = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Standard modular run function for search results. * * @param string Search string * @param boolean Whether to only do a META (tags) search * @param ID_TEXT Order direction * @param integer Start position in total results * @param integer Maximum results to return in total * @param boolean Whether only to search titles (as opposed to both titles and content) * @param string Where clause that selects the content according to the main search string (SQL query fragment) (blank: full-text search) * @param SHORT_TEXT Username/Author to match for * @param ?MEMBER Member-ID to match for (NULL: unknown) * @param TIME Cutoff date * @param string The sort type (gets remapped to a field in this function) * @set title add_date * @param integer Limit to this number of results * @param string What kind of boolean search to do * @set or and * @param string Where constraints known by the main search code (SQL query fragment) * @param string Comma-separated list of categories to search under * @param boolean Whether it is a boolean search * @return array List of maps (template, orderer) */ function run($content, $only_search_meta, $direction, $max, $start, $only_titles, $content_where, $author, $author_id, $cutoff, $sort, $limit_to, $boolean_operator, $where_clause, $search_under, $boolean_search) { unset($limit_to); if (get_forum_type() != 'ocf') { return array(); } require_code('ocf_members'); $remapped_orderer = ''; switch ($sort) { case 'title': $remapped_orderer = 'm_username'; break; case 'add_date': $remapped_orderer = 'm_join_time'; break; case 'relevance': case 'rating': break; default: $remapped_orderer = preg_replace('#[^\\w]#', '', $sort); break; } require_lang('ocf'); // Calculate our where clause (search) if ($author != '') { $where_clause .= ' AND '; $where_clause .= db_string_equal_to('m_username', $author); } if (!is_null($cutoff)) { $where_clause .= ' AND '; $where_clause .= 'm_join_time>' . strval($cutoff); } $raw_fields = array('m_username'); $trans_fields = array(); $rows = ocf_get_all_custom_fields_match(NULL, 1, 1); $table = ''; require_code('fields'); $non_trans_fields = 0; foreach ($rows as $i => $row) { $ob = get_fields_hook($row['cf_type']); list(, , $storage_type) = $ob->get_field_value_row_bits($row); if (strpos($storage_type, '_trans') === false) { $non_trans_fields++; } } $index_issue = $non_trans_fields > 16; foreach ($rows as $i => $row) { $ob = get_fields_hook($row['cf_type']); list(, , $storage_type) = $ob->get_field_value_row_bits($row); $param = get_param('option_' . strval($row['id']), ''); if ($param != '') { $where_clause .= ' AND '; if (db_has_full_text($GLOBALS['SITE_DB']->connection_read) && method_exists($GLOBALS['SITE_DB']->static_ob, 'db_has_full_text_boolean') && $GLOBALS['SITE_DB']->static_ob->db_has_full_text_boolean() && !is_under_radar($param)) { $temp = db_full_text_assemble('"' . $param . '"', true); } else { $temp = db_like_assemble($param); } if ($row['cf_type'] == 'short_trans' || $row['cf_type'] == 'long_trans') { $where_clause .= preg_replace('#\\?#', 't' . strval(count($trans_fields) + 1) . '.text_original', $temp); } else { $where_clause .= preg_replace('#\\?#', 'field_' . strval($row['id']), $temp); } } if (strpos($storage_type, '_trans') === false) { $raw_fields[] = 'field_' . strval($row['id']); } else { $trans_fields[] = 'field_' . strval($row['id']); } } $age_range = get_param('option__age_range', get_param('option__age_range_from', '') . '-' . get_param('option__age_range_to', '')); if ($age_range != '' && $age_range != '-') { $bits = explode('-', $age_range); if (count($bits) == 2) { $lower = strval(intval(date('Y', utctime_to_usertime())) - intval($bits[0])); $upper = strval(intval(date('Y', utctime_to_usertime())) - intval($bits[1])); $where_clause .= ' AND '; $where_clause .= '(m_dob_year<' . $lower . ' OR m_dob_year=' . $lower . ' AND (m_dob_month<' . date('m') . ' OR m_dob_month=' . date('m') . ' AND m_dob_day<=' . date('d') . '))'; $where_clause .= ' AND '; $where_clause .= '(m_dob_year>' . $upper . ' OR m_dob_year=' . $upper . ' AND (m_dob_month>' . date('m') . ' OR m_dob_month=' . date('m') . ' AND m_dob_day>=' . date('d') . '))'; } if (either_param_integer('option__photo_thumb_url', 0) == 1) { $where_clause .= ' AND '; $where_clause .= db_string_not_equal_to('m_photo_thumb_url', ''); } } $user_group = get_param('option__user_group', ''); if ($user_group != '') { $bits = explode(',', $user_group); $where_clause .= ' AND '; $group_where_clause = ''; foreach ($bits as $i => $bit) { $group = intval($bit); $table .= ' LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_group_members g' . strval($i) . ' ON (g' . strval($i) . '.gm_group_id=' . strval($group) . ' AND g' . strval($i) . '.gm_member_id=r.id)'; if ($group_where_clause != '') { $group_where_clause .= ' OR '; } $group_where_clause .= 'g' . strval($i) . '.gm_validated=1 OR m_primary_group=' . strval($group); } $where_clause .= '(' . $group_where_clause . ')'; } if (!has_specific_permission(get_member(), 'see_unvalidated')) { $where_clause .= ' AND '; $where_clause .= 'm_validated=1'; } // Calculate and perform query $rows = get_search_rows(NULL, NULL, $content, $boolean_search, $boolean_operator, $only_search_meta, $direction, $max, $start, $only_titles, 'f_members r JOIN ' . get_table_prefix() . 'f_member_custom_fields a ON r.id=a.mf_member_id' . $table, array('!', 'm_signature') + $trans_fields, $where_clause, $content_where, $remapped_orderer, 'r.*,a.*,r.id AS id', $raw_fields); $out = array(); foreach ($rows as $i => $row) { /*if ($user_group!='') { $bits=explode(',',$user_group); $ok=false; $groups=$GLOBALS['FORUM_DRIVER']->get_members_groups($row['id']); foreach ($bits as $bit) { if (in_array($user_group,$groups)) $ok=true; } if (!$ok) continue; }*/ if (!is_guest($row['id'])) { $out[$i]['data'] = $row; if ($remapped_orderer != '' && array_key_exists($remapped_orderer, $row)) { $out[$i]['orderer'] = $row[$remapped_orderer]; } elseif (substr($remapped_orderer, 0, 7) == '_rating') { $out[$i]['orderer'] = $row['compound_rating']; } } else { $out[$i]['data'] = NULL; } unset($rows[$i]); } return $out; }