/** * Standard code module initialisation function. */ function init__database__xml() { global $SCHEMA_CACHE, $DIR_CONTENTS_CACHE; $SCHEMA_CACHE = array(); $DIR_CONTENTS_CACHE = array(); global $DELIMITERS_FLIPPED, $DELIMITERS, $SYMBOL_DELIMINITER, $DELIMITERS_ALPHA; $DELIMITERS = array_merge(array("\t", ' ', "\n"), _get_sql_keywords()); sort($DELIMITERS); $DELIMITERS_FLIPPED = array_flip($DELIMITERS); $SYMBOL_DELIMINITER = array_flip(array("\t", ' ', "\n", '+', '-', '*', '/', '>', '<', '=', "'", '"', "\\'", '(', ')', ',')); foreach ($DELIMITERS as $d) { if (!isset($DELIMITERS_ALPHA[$d[0]])) { $DELIMITERS_ALPHA[$d[0]] = array(); } $DELIMITERS_ALPHA[$d[0]][] = $d; } global $TABLE_BASES; $TABLE_BASES = array(); // Support for chaining a DB- to make reads faster global $SITE_INFO; if (array_key_exists('db_chain_type', $SITE_INFO) && !running_script('xml_db_import') && get_param_integer('keep_no_chain', 0) != 1) { require_code('database/' . $SITE_INFO['db_chain_type']); $GLOBALS['XML_CHAIN_DB'] = new database_driver($SITE_INFO['db_chain'], $SITE_INFO['db_chain_host'], $SITE_INFO['db_chain_user'], $SITE_INFO['db_chain_password'], get_table_prefix(), false, object_factory('Database_Static_' . $SITE_INFO['db_chain_type'])); } else { $GLOBALS['XML_CHAIN_DB'] = NULL; } if (function_exists('set_time_limit')) { @set_time_limit(100); } // XML DB is *slow* }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { if (get_value('implicit_usergroup_sync') === '1') { $last = get_value('last_implicit_sync'); if (is_null($last) || intval($last) < time() - 60 * 60) { $hooks = find_all_hooks('systems', 'ocf_implicit_usergroups'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/ocf_implicit_usergroups/' . $hook); $ob = object_factory('Hook_implicit_usergroups_' . $hook); $group_id = $ob->get_bound_group_id(); $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_group_id' => $group_id)); $list = $ob->get_member_list(); if (!is_null($list)) { foreach ($list as $member_row) { $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_row['id'], 'gm_validated' => 1)); } } else { $start = 0; do { $members = collapse_1d_complexity('id', $GLOBALS['FORUM_DB']->query_select('f_members', array('id'), NULL, '', 400, $start)); foreach ($members as $member_id) { if ($ob->is_member_within($member_id)) { $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $group_id, 'gm_member_id' => $member_id, 'gm_validated' => 1)); } } $start += 400; } while (count($members) == 400); } } set_value('last_implicit_sync', strval(time())); } } }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists(0, $parameters)) { // Load up the relevant block and grab its help output $hooks = find_all_hooks('modules', 'admin_occle_commands'); $hook_return = NULL; foreach (array_keys($hooks) as $hook) { if ($hook == $parameters[0]) { require_code('hooks/modules/admin_occle_commands/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_return = $object->run(array('help' => NULL), array(), $occle_fs); break; } } if (!is_null($hook_return)) { return array($hook_return[0], $hook_return[1], $hook_return[2], $hook_return[3]); } else { return array('', '', '', do_lang('NO_HELP')); } } else { // Output a standard "how to use Occle" help page return array('window.open(unescape("' . urlencode('http://ocportal.com/docs' . strval(ocp_version()) . '/pg/tut_occle') . '"),"occle_window1","");', '', do_lang('SUCCESS'), ''); } }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { unset($map); require_lang('custom_comcode'); $tags = array(); $wmap = array('tag_enabled' => 1); if (!has_specific_permission(get_member(), 'comcode_dangerous')) { $wmap['tag_dangerous_tag'] = 0; } $tags = array_merge($tags, $GLOBALS['SITE_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); if (isset($GLOBALS['FORUM_DB']) && $GLOBALS['FORUM_DB']->connection_write != $GLOBALS['SITE_DB']->connection_write && get_forum_type() == 'ocf') { $tags = array_merge($tags, $GLOBALS['FORUM_DB']->query_select('custom_comcode', array('tag_title', 'tag_description', 'tag_example', 'tag_parameters', 'tag_replace', 'tag_tag', 'tag_dangerous_tag', 'tag_block_tag', 'tag_textual_tag'), $wmap)); } // From Comcode hooks $hooks = find_all_hooks('systems', 'comcode'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/comcode/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_comcode_' . filter_naughty_harsh($hook), true); $tags[] = $object->get_tag(); } if (!array_key_exists(0, $tags)) { return paragraph(do_lang_tempcode('NONE_EM'), '', 'nothing_here'); } $content = new ocp_tempcode(); foreach ($tags as $tag) { $content->attach(do_template('CUSTOM_COMCODE_TAG_ROW', array('_GUID' => '28c257f5d0c596aa828fd9556b0df4a9', 'TITLE' => is_string($tag['tag_title']) ? $tag['tag_title'] : get_translated_text($tag['tag_title']), 'DESCRIPTION' => is_string($tag['tag_description']) ? $tag['tag_description'] : get_translated_text($tag['tag_description']), 'EXAMPLE' => $tag['tag_example']))); } return do_template('BLOCK_MAIN_CUSTOM_COMCODE_TAGS', array('_GUID' => 'b8d3436e6e5fe679ae9b0a368e607610', 'TAGS' => $content)); }
/** * Get the number of unvalidated items. * * @return array A pair: Number of major things, number of minor things */ function get_num_unvalidated() { $sum = 0; $sum2 = 0; $_hooks = find_all_hooks('modules', 'admin_unvalidated'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/admin_unvalidated/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_unvalidated_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->info(); if (is_null($info)) { continue; } $db = array_key_exists('db', $info) ? $info['db'] : $GLOBALS['SITE_DB']; $amount = $db->query_value($info['db_table'], 'COUNT(*)', array($info['db_validated'] => 0)); if (is_null($info) || array_key_exists('is_minor', $info) && $info['is_minor']) { $sum2 += $amount; } else { $sum += $amount; } } return array($sum, $sum2); }
/** * Standard code module initialisation function. */ function init__themewizard() { global $THEME_WIZARD_IMAGES_CACHE, $THEME_SEED_CACHE, $THEME_DARK_CACHE; $THEME_WIZARD_IMAGES_CACHE = array(); $THEME_SEED_CACHE = array(); $THEME_DARK_CACHE = array(); global $THEME_WIZARD_IMAGES, $THEME_WIZARD_IMAGES_NO_WILD; $THEME_WIZARD_IMAGES = array(); $THEME_WIZARD_IMAGES_NO_WILD = array(); if (function_exists('imagecreatefromgif')) { $THEME_WIZARD_IMAGES[] = ''; } $hooks = find_all_hooks('modules', 'admin_themewizard'); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/admin_themewizard/' . filter_naughty_harsh($hook)); $ob = object_factory('Hook_admin_themewizard_' . filter_naughty_harsh($hook), true); if (is_null($ob)) { continue; } $results = $ob->run(); if (is_null($results)) { continue; } list($a, $b) = $results; $THEME_WIZARD_IMAGES = array_merge($THEME_WIZARD_IMAGES, $a); $THEME_WIZARD_IMAGES_NO_WILD = array_merge($THEME_WIZARD_IMAGES_NO_WILD, $b); } }
/** * Get the list of files that need CHmodding for write access. * * @return array The list of files */ function get_chmod_array() { global $LANG; // if ((function_exists('ocp_enterprise')) && (ocp_enterprise())) // { $extra_files = array('collaboration/pages/html_custom', 'collaboration/pages/html_custom/' . $LANG, 'collaboration/pages/comcode_custom', 'collaboration/pages/comcode_custom/' . $LANG); // } else $extra_files=array(); if (function_exists('find_all_hooks')) { $hooks = find_all_hooks('systems', 'addon_registry'); $hook_keys = array_keys($hooks); foreach ($hook_keys as $hook) { //require_code('hooks/systems/addon_registry/'.filter_naughty_harsh($hook)); //$object=object_factory('Hook_addon_registry_'.filter_naughty_harsh($hook)); //$extra_files=array_merge($extra_files,$object->get_chmod_array()); // Save memory compared to above commented code... $path = get_custom_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; } $matches = array(); if (preg_match('#function get_chmod_array\\(\\)\\s*\\{([^\\}]*)\\}#', file_get_contents($path), $matches) != 0) { if (!defined('HIPHOP_PHP')) { $extra_files = array_merge($extra_files, eval($matches[1])); } else { require_code('hooks/systems/addon_registry/' . $hook); $hook = object_factory('Hook_addon_registry_' . $hook); $extra_files = array_merge($extra_files, $hook->get_chmod_array()); } } } } return array_merge($extra_files, array('safe_mode_temp', 'persistant_cache', 'data_custom/modules/admin_backup', 'data_custom/modules/chat', 'data_custom/fields.xml', 'data_custom/breadcrumbs.xml', 'data_custom/modules/admin_stats', 'data_custom/spelling/write.log', 'data_custom/spelling/output.log', 'data_custom/spelling/personal_dicts', 'themes/map.ini', 'text_custom', 'text_custom/' . $LANG, 'data_custom/modules/chat/chat_last_msg.dat', 'data_custom/modules/chat/chat_last_event.dat', 'lang_cached', 'lang_cached/' . $LANG, 'lang_custom', 'lang_custom/' . $LANG, 'data_custom/errorlog.php', 'ocp_sitemap.xml', 'data_custom/permissioncheckslog.php', 'pages/html_custom', 'site/pages/html_custom', 'docs/pages/html_custom', 'adminzone/pages/html_custom', 'forum/pages/html_custom', 'cms/pages/html_custom', 'pages/html_custom/' . $LANG, 'site/pages/html_custom/' . $LANG, 'docs/pages/html_custom/' . $LANG, 'adminzone/pages/html_custom/' . $LANG, 'forum/pages/html_custom/' . $LANG, 'cms/pages/html_custom/' . $LANG, 'pages/comcode_custom', 'site/pages/comcode_custom', 'docs/pages/comcode_custom', 'adminzone/pages/comcode_custom', 'forum/pages/comcode_custom', 'cms/pages/comcode_custom', 'pages/comcode_custom/' . $LANG, 'site/pages/comcode_custom/' . $LANG, 'docs/pages/comcode_custom/' . $LANG, 'adminzone/pages/comcode_custom/' . $LANG, 'forum/pages/comcode_custom/' . $LANG, 'cms/pages/comcode_custom/' . $LANG, 'themes/default/css_custom', 'themes/default/images_custom', 'themes/default/templates_custom', 'themes/default/templates_cached', 'themes/default/templates_cached/' . $LANG, 'themes/default/theme.ini', 'uploads/incoming', 'uploads/website_specific', 'uploads/personal_sound_effects', 'uploads/banners', 'uploads/downloads', 'uploads/galleries', 'uploads/watermarks', 'uploads/grepimages', 'uploads/galleries_thumbs', 'uploads/iotds', 'uploads/iotds_thumbs', 'uploads/catalogues', 'uploads/attachments', 'uploads/attachments_thumbs', 'uploads/auto_thumbs', 'uploads/ocf_avatars', 'uploads/ocf_cpf_upload', 'uploads/ocf_photos', 'uploads/ocf_photos_thumbs', 'uploads/filedump', 'info.php', 'exports/backups', 'exports/file_backups', 'exports/mods', 'imports/mods', 'site/pages/html_custom/' . $LANG . '/download_tree_made.htm', 'site/pages/html_custom/' . $LANG . '/cedi_tree_made.htm')); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { require_code('textfiles'); $file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes'; $title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES'); $lang_none = array_key_exists('lang_none', $map) ? $map['lang_none'] : '0'; $scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0'; $lang = $lang_none == '1' ? NULL : ''; $file = filter_naughty($file, true); $new = post_param('new', NULL); if (!is_null($new)) { $hooks = find_all_hooks('blocks', 'main_notes'); foreach (array_keys($hooks) as $hook) { require_code('hooks/blocks/main_notes/' . filter_naughty_harsh($hook)); $ob = object_factory('Hook_notes_' . filter_naughty_harsh($hook), true); if (is_null($ob)) { continue; } $ob->run($file); } write_text_file($file, $lang, $new); log_it('NOTES', $file); attach_message(do_lang_tempcode('SUCCESS'), 'inform'); } $contents = read_text_file($file, $lang, true); $post_url = get_self_url(); $map_comcode = ''; foreach ($map as $key => $val) { $map_comcode .= ' ' . $key . '="' . addslashes($val) . '"'; } return do_template('BLOCK_MAIN_NOTES', array('_GUID' => 'f737053505de3bd8ccfe806ec014b8fb', 'TITLE' => $title, 'BLOCK_NAME' => 'main_notes', 'MAP' => $map_comcode, 'CONTENTS' => $contents, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'URL' => $post_url)); }
/** * Standard modular run function. * * @return tempcode The result of execution. */ function run() { require_lang('unvalidated'); $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/unvalidated'; $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_censor'; $_title = get_page_title('UNVALIDATED_RESOURCES'); $out = new ocp_tempcode(); require_code('form_templates'); $_hooks = find_all_hooks('modules', 'admin_unvalidated'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/admin_unvalidated/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_unvalidated_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->info(); if (is_null($info)) { continue; } $identifier_select = is_array($info['db_identifier']) ? implode(',', $info['db_identifier']) : $info['db_identifier']; $db = array_key_exists('db', $info) ? $info['db'] : $GLOBALS['SITE_DB']; $rows = $db->query('SELECT ' . $identifier_select . (array_key_exists('db_title', $info) ? ',' . $info['db_title'] : '') . ' FROM ' . $db->get_table_prefix() . $info['db_table'] . ' WHERE ' . $info['db_validated'] . '=0', 100); $content = new ocp_tempcode(); foreach ($rows as $row) { if (is_array($info['db_identifier'])) { $id = ''; foreach ($info['db_identifier'] as $_id) { if ($id != '') { $id .= ':'; } $id .= $row[$_id]; } } else { $id = $row[$info['db_identifier']]; } if (array_key_exists('db_title', $info)) { $title = $row[$info['db_title']]; if ($info['db_title_dereference']) { $title = get_translated_text($title, $db); } // May actually be comcode (can't be certain), but in which case it will be shown as source } else { $title = '#' . (is_integer($id) ? strval($id) : $id); } if ($title == '') { $title = '#' . strval($id); } $content->attach(form_input_list_entry(is_integer($id) ? strval($id) : $id, false, strip_comcode($title))); } $post_url = build_url(array('page' => $info['edit_module'], 'type' => $info['edit_type'], 'validated' => 1), get_module_zone($info['edit_module']), NULL, false, true); $fields = form_input_list(do_lang_tempcode('EDIT'), do_lang_tempcode('DESCRIPTION_EDIT'), $info['edit_identifier'], $content); if (!$content->is_empty()) { // Could debate whether to include "'TARGET'=>'_blank',". However it does redirect back, so it's a nice linear process like this. If it was new window it could be more efficient, but also would confuse people with a lot of new windows opening and not closing. $content = do_template('FORM', array('_GUID' => '51dcee39273a0fee29569190344f2e41', 'GET' => true, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('EDIT'), 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => '')); } $out->attach(do_template('UNVALIDATED_SECTION', array('_GUID' => '838240008e190b9cbaa0280fbddd6baf', 'TITLE' => $info['title'], 'CONTENT' => $content))); } return do_template('UNVALIDATED_SCREEN', array('_GUID' => '4e971f1c8851b821af030b5c7bbcb3fb', 'TITLE' => $_title, 'SECTIONS' => $out)); }
/** * Send (by e-mail) a validation request for a submitted item to the admin. * * @param ID_TEXT The validation request will say one of this type has been submitted. By convention it is the language code of what was done, e.g. ADD_DOWNLOAD * @param ?ID_TEXT The table saved into (NULL: unknown) * @param boolean Whether the ID field is not an integer * @param ID_TEXT The validation request will say this ID has been submitted * @param tempcode The validation request will link to this URL * @param ?MEMBER Member doing the submitting (NULL: current member) */ function send_validation_request($type, $table, $non_integer_id, $id, $url, $member_id = NULL) { $good = NULL; if (!is_null($table)) { $_hooks = find_all_hooks('modules', 'admin_unvalidated'); foreach (array_keys($_hooks) as $hook) { require_code('hooks/modules/admin_unvalidated/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_unvalidated_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->info(); if (is_null($info)) { continue; } if ($info['db_table'] == $table) { $good = $info; break; } } } $title = mixed(); $title = ''; if (!is_null($good) && !is_array($good['db_identifier'])) { $db = array_key_exists('db', $good) ? $good['db'] : $GLOBALS['SITE_DB']; $where = $good['db_identifier'] . '=' . $id; if ($non_integer_id) { $where = db_string_equal_to($good['db_identifier'], $id); } $rows = $db->query('SELECT ' . $good['db_identifier'] . (array_key_exists('db_title', $good) ? ',' . $good['db_title'] : '') . ' FROM ' . $db->get_table_prefix() . $good['db_table'] . ' WHERE ' . $where, 100); if (array_key_exists('db_title', $good)) { $title = $rows[0][$good['db_title']]; if ($good['db_title_dereference']) { $title = get_translated_text($title, $db); } // May actually be comcode (can't be certain), but in which case it will be shown as source } else { $title = '#' . (is_integer($id) ? strval($id) : $id); } } if ($title == '') { $title = '#' . (is_integer($id) ? strval($id) : $id); } if (is_null($member_id)) { $member_id = get_member(); } require_lang('unvalidated'); $_type = do_lang($type, NULL, NULL, NULL, NULL, false); if (!is_null($_type)) { $type = $_type; } $comcode = do_template('VALIDATION_REQUEST', array('_GUID' => '1885be371b2ff7810287715ef2f7b948', 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id), 'TYPE' => $type, 'ID' => $id, 'URL' => $url), get_site_default_lang()); require_code('notifications'); $subject = do_lang('UNVALIDATED_TITLE', $title, '', '', get_site_default_lang()); $message = $comcode->evaluate(get_site_default_lang(), false); dispatch_notification('needs_validation', NULL, $subject, $message); }
/** * Find all the installed addons. * * @return array List of maps describing the available addons (simulating partial-extended versions of the traditional ocPortal-addon database row) */ function find_installed_addons() { // Find installed addons- database registration method $_rows = $GLOBALS['SITE_DB']->query_select('addons', array('*')); $addons_installed = array(); foreach ($_rows as $row) { $files_rows = array_unique(collapse_1d_complexity('filename', $GLOBALS['SITE_DB']->query_select('addons_files', array('filename'), array('addon_name' => $row['addon_name'])))); $row['addon_files'] = ''; foreach ($files_rows as $file_row_name) { $row['addon_files'] .= $file_row_name . chr(10); } $addons_installed[$row['addon_name']] = $row; } // Find installed addons- file system method (for ocProducts addons). ocProducts addons don't need to be in the DB, although they will be if they are (re)installed after the original ocPortal installation finished. $hooks = find_all_hooks('systems', 'addon_registry'); foreach (array_keys($hooks) as $hook) { if (substr($hook, 0, 4) != 'core') { if (false) { require_code('hooks/systems/addon_registry/' . filter_naughty_harsh($hook)); $hook_ob = object_factory('Hook_addon_registry_' . $hook, true); if (is_null($hook_ob)) { continue; } $description = $hook_ob->get_description(); $file_list = $hook_ob->get_file_list(); $version = $hook_ob->get_version(); } else { $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; } if (!file_exists($path)) { continue; } // Race condition? $_hook_bits = extract_module_functions($path, array('get_description', 'get_file_list', 'get_version')); if (is_null($_hook_bits[0])) { $description = ''; } else { $description = is_array($_hook_bits[0]) ? call_user_func_array($_hook_bits[0][0], $_hook_bits[0][1]) : @eval($_hook_bits[0]); } if (is_null($_hook_bits[1])) { $file_list = array(); } else { $file_list = is_array($_hook_bits[1]) ? call_user_func_array($_hook_bits[1][0], $_hook_bits[1][1]) : @eval($_hook_bits[1]); } if (is_null($_hook_bits[2])) { $version = ''; } else { $version = is_array($_hook_bits[2]) ? call_user_func_array($_hook_bits[2][0], $_hook_bits[2][1]) : @eval($_hook_bits[2]); } } $addons_installed[$hook] = array('addon_name' => $hook, 'addon_author' => 'Core Team', 'addon_organisation' => 'ocProducts', 'addon_version' => $version == ocp_version_number() ? ocp_version_full() : float_format($version, 1), 'addon_description' => $description, 'addon_install_time' => filemtime($path), 'addon_files' => implode(chr(10), make_global_file_list($file_list))); } } return $addons_installed; }
/** * Give an award. * * @param AUTO_LINK The award ID * @param ID_TEXT The content ID * @param ?TIME Time the award was given (NULL: now) */ function give_award($award_id, $content_id, $time = NULL) { require_lang('awards'); if (is_null($time)) { $time = time(); } $awards = $GLOBALS['SITE_DB']->query_select('award_types', array('*'), array('id' => $award_id), '', 1); if (!array_key_exists(0, $awards)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $award_title = get_translated_text($awards[0]['a_title']); log_it('GIVE_AWARD', strval($award_id), $award_title); require_code('hooks/systems/awards/' . filter_naughty_harsh($awards[0]['a_content_type'])); $object = object_factory('Hook_awards_' . $awards[0]['a_content_type']); $info = $object->info(); if (is_null($info)) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } if (array_key_exists('submitter_field', $info) && $awards[0]['a_content_type'] != 'author' && !is_null($info['submitter_field'])) { require_code('content'); list($content_title, $member_id, , $content) = content_get_details($awards[0]['a_content_type'], $content_id); if (is_null($content)) { warn_exit(do_lang_tempcode('_MISSING_RESOURCE', escape_html($awards[0]['a_content_type'] . ':' . $content_id))); } // Lots of fiddling around to work out how to check permissions for this $permission_type_code = convert_ocportal_type_codes('award_hook', $awards[0]['a_content_type'], 'permissions_type_code'); $module = convert_ocportal_type_codes('module', $awards[0]['a_content_type'], 'permissions_type_code'); if ($module == '') { $module = $content_id; } $category_id = mixed(); if (isset($info['category_field'])) { if (is_array($info['category_field'])) { $category_id = $content[$info['category_field'][1]]; } else { $category_id = $content[$info['category_field']]; } } if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'awards') && has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), $module) && ($permission_type_code == '' || is_null($category_id) || has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), $permission_type_code, is_integer($category_id) ? strval($category_id) : $category_id))) { syndicate_described_activity(is_null($member_id) || is_guest($member_id) ? 'awards:_ACTIVITY_GIVE_AWARD' : 'awards:ACTIVITY_GIVE_AWARD', $award_title, $content_title, '', '_SEARCH:awards:award:' . strval($award_id), '', '', 'awards', 1, NULL, false, $member_id); } } else { $member_id = NULL; } if (is_null($member_id)) { $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } if (!is_guest($member_id) && addon_installed('points')) { require_code('points2'); system_gift_transfer(do_lang('_AWARD', get_translated_text($awards[0]['a_title'])), $awards[0]['a_points'], $member_id); } $GLOBALS['SITE_DB']->query_insert('award_archive', array('a_type_id' => $award_id, 'member_id' => $member_id, 'content_id' => $content_id, 'date_and_time' => $time)); decache('main_awards'); decache('main_multi_content'); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { // Loads up correct hook and returns rendering require_lang('custom_comcode'); $type_id = $map['param']; if (!file_exists(get_file_base() . '/sources/hooks/blocks/main_custom_gfx/' . filter_naughty_harsh($type_id) . '.php') && !file_exists(get_file_base() . '/sources_custom/hooks/blocks/main_custom_gfx/' . filter_naughty_harsh($type_id) . '.php')) { return paragraph(do_lang_tempcode('NO_SUCH_RENDERER', $type_id)); } require_code('hooks/blocks/main_custom_gfx/' . filter_naughty_harsh($type_id), true); $object = object_factory('Hook_main_custom_gfx_' . $type_id); return $object->run($map, $this); }
/** * Get all the events within a timestamp range. * * @param TIME From time (inclusive). * @param TIME To time (inclusive). * @return array List of template parameter sets (perfect for use in a Tempcode LOOP). */ function get_realtime_events($from, $to) { //restrictify(); $drops = array(); $hooks = find_all_hooks('systems', 'realtime_rain'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/realtime_rain/' . filter_naughty($hook)); $ob = object_factory('Hook_realtime_rain_' . $hook); $drops = array_merge($drops, $ob->run($from, $to)); } return $drops; }
/** * Standard modular render function for profile tab 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 triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $title = do_lang_tempcode('EDIT_EM'); require_lang('ocf'); require_css('ocf'); $order = 200; if ($leave_to_ajax_if_possible && strtoupper(ocp_srv('REQUEST_METHOD')) != 'POST') { return array($title, NULL, $order); } $tabs = array(); $hooks = find_all_hooks('systems', 'profiles_tabs_edit'); if (isset($hooks['settings'])) { $hooks = array('settings' => $hooks['settings']) + $hooks; } foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/profiles_tabs_edit/' . $hook); $ob = object_factory('Hook_Profiles_Tabs_Edit_' . $hook); if ($ob->is_active($member_id_of, $member_id_viewing)) { $tabs[] = $ob->render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible); } } if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } global $M_SORT_KEY; $M_SORT_KEY = 4; usort($tabs, 'multi_sort'); $javascript = ''; $hidden = new ocp_tempcode(); // Session ID check, if saving if (count($_POST) != 0 && count($tabs) != 0) { global $SESSION_CONFIRMED; if ($SESSION_CONFIRMED == 0) { access_denied('SESSION', '', true); } } $_tabs = array(); $first = true; foreach ($tabs as $i => $tab) { if (is_null($tab)) { continue; } $javascript .= $tab[3]; if (isset($tab[5])) { $hidden->attach($tab[5]); } $_tabs[] = array('TAB_TITLE' => $tab[0], 'TAB_FIELDS' => $tab[1], 'TAB_TEXT' => $tab[2], 'TAB_FIRST' => $first, 'TAB_LAST' => !array_key_exists($i + 1, $tabs)); $first = false; } $url = build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, false); $content = do_template('OCF_MEMBER_PROFILE_EDIT', array('JAVASCRIPT' => $javascript, 'HIDDEN' => $hidden, 'URL' => $url, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'), 'AUTOCOMPLETE' => false, 'SKIP_VALIDATION' => true, 'TABS' => $_tabs)); return array($title, $content, $order); }
/** * Detect whether we have external site-wide syndication support somewhere. * * @return boolean Whether we do */ function has_external_site_wide_syndication() { $dests = find_all_hooks('systems', 'syndication'); foreach (array_keys($dests) as $hook) { require_code('hooks/systems/syndication/' . $hook); $ob = object_factory('Hook_Syndication_' . $hook); if ($ob->is_available() && $ob->auth_is_set_site()) { return true; } } return false; }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { // Find review, if there is one $individual_review_ratings = array(); $review_rating = post_param('review_rating', ''); if ($review_rating != '') { $individual_review_ratings[''] = array('REVIEW_TITLE' => '', 'REVIEW_RATING' => $review_rating); } $poster_name = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $post = comcode_to_tempcode(post_param('post')); // OCF renderings of poster static $hooks = NULL; if (is_null($hooks)) { $hooks = find_all_hooks('modules', 'topicview'); } static $hook_objects = NULL; if (is_null($hook_objects)) { $hook_objects = array(); foreach (array_keys($hooks) as $hook) { require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $hook_objects[$hook] = $object; } } if (!is_guest()) { require_code('ocf_members2'); $poster_details = ocf_show_member_box(get_member(), false, $hooks, $hook_objects, false); } else { $custom_fields = new ocp_tempcode(); $poster_details = new ocp_tempcode(); } if (addon_installed('ocf_forum')) { if (!is_guest()) { $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => true, 'ID' => strval(get_member()), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member(), false, true), 'POSTER_USERNAME' => $poster_name)); } else { $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $poster_name)); } } else { $poster = make_string_tempcode(escape_html($poster_name)); // Should never happen actually, as applies discounts hook from even running } $highlight = false; $datetime_raw = time(); $datetime = get_timezoned_date(time()); $poster_url = $GLOBALS['FORUM_DRIVER']->member_profile_url(get_member()); $title = post_param('title', ''); $tpl = do_template('POST', array('INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $title, 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POST' => $post, 'POSTER_ID' => strval(get_member()), 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => '', 'CHILDREN' => '', 'RATING' => '', 'EMPHASIS' => '', 'BUTTONS' => '', 'TOPIC_ID' => '', 'UNVALIDATED' => '', 'IS_SPACER_POST' => false, 'NUM_TO_SHOW_LIMIT' => '0')); return array($tpl, NULL); }
/** * Standard modular install function. * * @param ?integer What version we're upgrading from (NULL: new install) * @param ?integer What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version) */ function install($upgrade_from = NULL, $upgrade_from_hack = NULL) { $GLOBALS['SITE_DB']->create_table('custom_comcode', array('tag_tag' => '*ID_TEXT', 'tag_title' => 'SHORT_TRANS', 'tag_description' => 'SHORT_TRANS', 'tag_replace' => 'LONG_TEXT', 'tag_example' => 'LONG_TEXT', 'tag_parameters' => 'SHORT_TEXT', 'tag_enabled' => 'BINARY', 'tag_dangerous_tag' => 'BINARY', 'tag_block_tag' => 'BINARY', 'tag_textual_tag' => 'BINARY')); require_lang('custom_comcode'); $ve_hooks = find_all_hooks('systems', 'video_embed'); foreach (array_keys($ve_hooks) as $ve_hook) { require_code('hooks/systems/video_embed/' . $ve_hook); $ve_ob = object_factory('Hook_video_embed_' . $ve_hook); if (method_exists($ve_ob, 'add_custom_comcode_field')) { $ve_ob->add_custom_comcode_field(); } } }
/** * Standard modular run function. * * @return array An array of tuples: The task row to show, the number of seconds until it is due (or NULL if not on a timer), the number of things to sort out (or NULL if not on a queue), The name of the config option that controls the schedule (or NULL if no option). */ function run() { $award_types = $GLOBALS['SITE_DB']->query_select('award_types', array('*')); $out = array(); foreach ($award_types as $award) { // Find out how many submissions we've had since the last award was given if (!file_exists(get_file_base() . '/sources/hooks/systems/awards/' . filter_naughty_harsh($award['a_content_type']) . '.php') && !file_exists(get_file_base() . '/sources_custom/hooks/systems/awards/' . filter_naughty_harsh($award['a_content_type']) . '.php')) { continue; } require_code('hooks/systems/awards/' . $award['a_content_type']); $hook_object = object_factory('Hook_awards_' . $award['a_content_type'], true); if (is_null($hook_object)) { continue; } $details = $hook_object->info(); if (!is_null($details)) { $date = $GLOBALS['SITE_DB']->query_value_null_ok('award_archive', 'date_and_time', array('a_type_id' => $award['id']), 'ORDER BY date_and_time DESC'); $seconds_ago = mixed(); $limit_hours = $award['a_update_time_hours']; if (!is_null($date)) { $seconds_ago = time() - $date; $status = $seconds_ago > $limit_hours * 60 * 60 ? 0 : 1; } else { $status = 0; } $config_url = build_url(array('page' => 'admin_awards', 'type' => '_ed', 'id' => $award['id']), get_module_zone('admin_awards')); $_status = $status == 0 ? do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_0') : do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM_STATUS_1'); $url = $details['add_url']; if (is_object($url)) { $url = $url->evaluate(); } $url = str_replace('=!', '_ignore=1', $url); $task = escape_html(get_translated_text($award['a_title'])); if (!is_null($date) && !is_null($details['date_field'])) { $where = filter_naughty_harsh($details['date_field']) . '>' . strval(intval($date)); $num_queue = $details['connection']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $details['connection']->get_table_prefix() . str_replace('1=1', $where, $details['table']) . ' r WHERE ' . $where); $_num_queue = integer_format($num_queue); $num_new_since = do_lang_tempcode('NUM_NEW_SINCE', $_num_queue); } else { $num_new_since = new ocp_tempcode(); } list($info, $seconds_due_in) = staff_checklist_time_ago_and_due($seconds_ago, $limit_hours); $info->attach($num_new_since); $tpl = do_template('BLOCK_MAIN_STAFF_CHECKLIST_ITEM', array('_GUID' => '4049affae5a6f38712ee3e0237a2e18e', 'CONFIG_URL' => $config_url, 'URL' => $url, 'STATUS' => $_status, 'TASK' => $task, 'INFO' => $info)); $out[] = array($tpl, $seconds_due_in, NULL, NULL); } } return $out; }
/** * @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License * @copyright ocProducts Ltd * @package activity_feed */ function activities_addon_syndicate_described_activity($a_language_string_code = '', $a_label_1 = '', $a_label_2 = '', $a_label_3 = '', $a_pagelink_1 = '', $a_pagelink_2 = '', $a_pagelink_3 = '', $a_addon = '', $a_is_public = 1, $a_member_id = NULL, $sitewide_too = false, $a_also_involving = NULL) { require_code('activities'); require_lang('activities'); if (get_db_type() == 'xml' && get_param_integer('keep_testing_logging', 0) != 1) { return NULL; } $stored_id = 0; if (is_null($a_member_id)) { $a_member_id = get_member(); } if (is_guest($a_member_id)) { return NULL; } $go = array('a_language_string_code' => $a_language_string_code, 'a_label_1' => $a_label_1, 'a_label_2' => $a_label_2, 'a_label_3' => $a_label_3, 'a_is_public' => $a_is_public); $stored_id = mixed(); // Check if this has been posted previously (within the last 10 minutes) to // stop spamming but allow generalised repeat status messages. $test = $GLOBALS['SITE_DB']->query_select('activities', array('a_language_string_code', 'a_label_1', 'a_label_2', 'a_label_3', 'a_is_public'), NULL, 'WHERE a_time>' . strval(time() - 600), 1); if (!array_key_exists(0, $test) || $test[0] != $go || running_script('execute_temp')) { // Log the activity $row = $go + array('a_member_id' => $a_member_id, 'a_also_involving' => $a_also_involving, 'a_pagelink_1' => $a_pagelink_1, 'a_pagelink_2' => $a_pagelink_2, 'a_pagelink_3' => $a_pagelink_3, 'a_time' => time(), 'a_addon' => $a_addon, 'a_is_public' => $a_is_public); $stored_id = $GLOBALS['SITE_DB']->query_insert('activities', $row, true); // Update the latest activity file log_newest_activity($stored_id, 1000); // External places if ($a_is_public == 1 && !$GLOBALS['IS_ACTUALLY_ADMIN']) { $dests = find_all_hooks('systems', 'syndication'); foreach (array_keys($dests) as $hook) { require_code('hooks/systems/syndication/' . $hook); $ob = object_factory('Hook_Syndication_' . $hook); if ($ob->is_available()) { $ob->syndicate_user_activity($a_member_id, $row); if ($sitewide_too && has_specific_permission(get_member(), 'syndicate_site_activity') && post_param_integer('syndicate_this', 0) == 1) { $ob->syndicate_site_activity($row); } } } } list($message) = render_activity($row, false); require_code('notifications'); $username = $GLOBALS['FORUM_DRIVER']->get_username($a_member_id); $subject = do_lang('ACTIVITY_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $username, html_entity_decode(strip_tags($message->evaluate()), ENT_QUOTES, get_charset())); $mail = do_lang('ACTIVITY_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($username), array('[semihtml]' . $message->evaluate() . '[/semihtml]')); dispatch_notification('activity', strval($a_member_id), $subject, $mail); } return $stored_id; }
/** * Standard modular render function for profile tab 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 triple: The tab title, the tab contents, the suggested tab order */ function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false) { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=activities&filter=' . strval($member_id_of); require_lang('activities'); $title = do_lang_tempcode('ACTIVITIES_TITLE'); $order = 70; // Need to declare these here as the Tempcode engine can't look as deep, into a loop (I think), as it would need to, to find the block declaring the dependency require_css('activities'); require_javascript('javascript_activities_state'); require_javascript('javascript_activities'); require_javascript('javascript_jquery'); require_javascript('javascript_base64'); // Allow user to link up things for syndication $syndications = array(); if ($member_id_of == $member_id_viewing) { $dests = find_all_hooks('systems', 'syndication'); foreach (array_keys($dests) as $hook) { require_code('hooks/systems/syndication/' . $hook); $ob = object_factory('Hook_Syndication_' . $hook); if ($ob->is_available()) { if (either_param('syndicate_stop__' . $hook, NULL) !== NULL) { $ob->auth_unset($member_id_of); } elseif (either_param('syndicate_start__' . $hook, NULL) !== NULL) { $url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $member_id_of, 'oauth_in_progress' => 1); $url_map['syndicate_start__' . $hook] = 1; $oauth_url = build_url($url_map, '_SELF', NULL, false, false, false, 'tab__activities'); $ob->auth_set($member_id_of, $oauth_url); } elseif (running_script('index') && !$leave_to_ajax_if_possible && $ob->auth_is_set($member_id_of) && either_param('oauth_in_progress', NULL) === NULL && !$GLOBALS['IS_ACTUALLY_ADMIN']) { /* running_script('index') won't work currently due to execution contexts, and it is never non-AJAX, and it's probably not needed anyway // Do a refresh to make sure the token is updated $url_map=array('page'=>'_SELF','type'=>'view','id'=>$member_id_of,'oauth_in_progress'=>1); $url_map['syndicate_start__'.$hook]=1; $oauth_url=build_url($url_map,'_SELF',NULL,false,false,false,'tab__activities'); $ob->auth_set($member_id_of,$oauth_url); */ } $syndications[$hook] = array('SYNDICATION_IS_SET' => $ob->auth_is_set($member_id_of), 'SYNDICATION_SERVICE_NAME' => $ob->get_service_name()); } } } if ($leave_to_ajax_if_possible) { return array($title, NULL, $order); } $content = do_template('OCF_MEMBER_PROFILE_ACTIVITIES', array('MEMBER_ID' => strval($member_id_of), 'SYNDICATIONS' => $syndications)); return array($title, $content, $order); }
/** * Takes Salmon values from POST and handles their assimilation into the * site. */ function handle_salmon($id) { // Find out what the type our feedback should be for require_code('hooks/systems/content_meta_aware/iotd'); $cma = object_factory('Hook_content_meta_aware_iotd'); $info = $cma->info(); $db_id = $info['id_field_numeric'] ? intval($id) : $id; $_title = $GLOBALS['SITE_DB']->query_value_null_ok($info['table'], $info['title_field'], array($info['id_field'] => $db_id)); if (is_null($_title)) { warn_exit(''); } $title = $info['title_field_dereference'] ? get_translated_text($_title) : $_title; require_code('urls'); list($zone, $attributes, $_) = page_link_decode(str_replace('_WILD', $id, $info['view_pagelink_pattern'])); $url = build_url($attributes, $zone)->evaluate(); require_code('salmon/salmon'); parse_salmon_post($info['feedback_type_code'], filter_naughty($id), $url, $title); }
/** * Render a member profile. * * @param MEMBER The ID of the member who is being viewed * @param ?MEMBER The ID of the member who is doing the viewing (NULL: current member) * @param ?ID_TEXT The username of the member who is being viewed (NULL: work out from member_id_of) * @return tempcode The rendered profile */ function render_profile_tabset($member_id_of, $member_id_viewing = NULL, $username = NULL) { if (is_null($member_id_viewing)) { $member_id_viewing = get_member(); } $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); if (is_null($username) || is_guest($member_id_of)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } $tabs = array(); $hooks = find_all_hooks('systems', 'profiles_tabs'); if (isset($hooks['edit'])) { $hooks = array('edit' => $hooks['edit']) + $hooks; } foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/profiles_tabs/' . $hook); $ob = object_factory('Hook_Profiles_Tabs_' . $hook); if ($ob->is_active($member_id_of, $member_id_viewing)) { $tabs[$hook] = $ob->render_tab($member_id_of, $member_id_viewing, !browser_matches('ie6') && !browser_matches('ie7') && has_js()); } } global $M_SORT_KEY; $M_SORT_KEY = 2; uasort($tabs, 'multi_sort'); require_javascript('javascript_profile'); require_javascript('javascript_ajax'); load_up_all_self_page_permissions($member_id_viewing); if (addon_installed('awards')) { require_code('awards'); $awards = find_awards_for('member', strval($member_id_of)); } else { $awards = array(); } $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of); // Get it again, in case it changed $title = get_page_title('MEMBER_PROFILE', true, array(escape_html($username)), NULL, $awards); $_tabs = array(); $i = 0; foreach ($tabs as $hook => $tab) { $_tabs[] = array('TAB_TITLE' => $tab[0], 'TAB_CODE' => $hook, 'TAB_CONTENT' => $tab[1], 'TAB_FIRST' => $i == 0, 'TAB_LAST' => !array_key_exists($i + 1, $tabs)); $i++; } return do_template('OCF_MEMBER_PROFILE_SCREEN', array('TITLE' => $title, 'TABS' => $_tabs, 'MEMBER_ID' => strval($member_id_of))); }
/** * Output the trackback script and handle trackbacks. */ function trackback_script() { if (get_option('is_on_trackbacks') == '0') { return; } require_lang('trackbacks'); header('Content-type: text/xml'); $page = get_param('page'); $id = get_param_integer('id'); $mode = either_param('__mode', 'none'); $allow_trackbacks = true; $hooks = find_all_hooks('systems', 'trackback'); foreach (array_keys($hooks) as $hook) { if ($hook == $page) { require_code('hooks/systems/trackback/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_trackback_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $allow_trackbacks = $object->run($id); break; } } if ($mode == 'rss') { //List all the trackbacks to the specified page $xml = get_trackbacks($page, strval($id), $allow_trackbacks, 'xml'); } else { $time = get_param_integer('time'); if ($time > time() - 60 * 5) { exit; } // Trackback link intentionally goes stale after 5 minutes, so it can't be statically stored and spam hammered //Add a trackback for the specified page $output = actualise_post_trackback($allow_trackbacks, $page, strval($id)); if ($output) { $xml = do_template('TRACKBACK_XML_NO_ERROR', array()); } else { $xml = do_template('TRACKBACK_XML_ERROR', array('_GUID' => 'ac5e34aeabf92712607e62e062407861', 'TRACKBACK_ERROR' => do_lang_tempcode('TRACKBACK_ERROR'))); } } $echo = do_template('TRACKBACK_XML_WRAPPER', array('_GUID' => 'cd8d057328569803a6cca9f8d37a0ac8', 'XML' => $xml)); $echo->evaluate_echo(); }
/** * Standard modular run function for preview hooks. * * @return array A pair: The preview, the updated post Comcode */ function run() { require_code('setupwizard'); $collapse_zones = post_param_integer('collapse_user_zones', 0) == 1; $installprofile = post_param('installprofile', ''); if ($installprofile != '') { require_code('hooks/modules/admin_setupwizard_installprofiles/' . $installprofile); $object = object_factory('Hook_admin_setupwizard_installprofiles_' . $installprofile); $installprofileblocks = $object->default_blocks(); $block_options = $object->block_options(); } else { $installprofileblocks = array(); $block_options = array(); } $page_structure = _get_zone_pages($installprofileblocks, $block_options, $collapse_zones, $installprofile); $zone_structure = array_pop($page_structure); $preview = do_template('SETUPWIZARD_BLOCK_PREVIEW', array('LEFT' => $zone_structure['left'], 'RIGHT' => $zone_structure['right'], 'START' => $zone_structure['start'])); return array($preview, NULL); }
/** * Find whether a content type has a tied catalogue. * * @param ID_TEXT Award hook codename * @return boolean Whether it has */ function has_tied_catalogue($content_type) { if (addon_installed('catalogues')) { require_code('hooks/systems/awards/' . $content_type); $ob = object_factory('Hook_awards_' . $content_type); $info = $ob->info(); if (array_key_exists('supports_custom_fields', $info) && $info['supports_custom_fields']) { $exists = !is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => '_' . $content_type))); if ($exists) { $first_cat = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_categories', 'MIN(id)', array('c_name' => '_' . $content_type)); if (is_null($first_cat)) { require_code('catalogues2'); require_lang('catalogues'); actual_add_catalogue_category('_' . $content_type, do_lang('CUSTOM_FIELDS_FOR', $info['title']->evaluate()), '', '', NULL); } return true; } } } return false; }
/** * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX. * * @return tempcode The snippet */ function run() { $member_id_viewing = get_member(); $member_id_of = get_param_integer('member_id'); $hook = filter_naughty_harsh(get_param('tab')); require_lang('ocf'); // HACKHACK $_GET['page'] = 'members'; $_GET['type'] = 'view'; $_GET['id'] = strval($member_id_of); unset($_GET['snippet']); unset($_GET['member_id']); unset($_GET['tab']); unset($_GET['url']); unset($_GET['title']); unset($_GET['utheme']); global $RELATIVE_PATH, $ZONE; $RELATIVE_PATH = get_module_zone('members'); $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $RELATIVE_PATH), '', 1); $ZONE = $zones[0]; global $PAGE_NAME_CACHE; $PAGE_NAME_CACHE = 'members'; global $RUNNING_SCRIPT_CACHE; $RUNNING_SCRIPT_CACHE = array('index' => true); require_code('hooks/systems/profiles_tabs/' . $hook); $ob = object_factory('Hook_Profiles_Tabs_' . $hook); if ($ob->is_active($member_id_of, $member_id_viewing)) { global $CSSS, $JAVASCRIPTS; $CSSS = array(); $JAVASCRIPTS = array(); $ret = $ob->render_tab($member_id_of, $member_id_viewing); $out = new ocp_tempcode(); $out->attach(symbol_tempcode('CSS_TEMPCODE')); $out->attach(symbol_tempcode('JS_TEMPCODE')); $out->attach($ret[1]); return $out; } return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INTERNAL_ERROR'))); }
/** * Get the tempcode for a do next manager. A do next manager is a series of linked icons that are presented after performing an action. Modules that do not use do-next pages, usually use REFRESH_PAGE's. * * @param ID_TEXT The title of what we are doing (a language string) * @param ?mixed The language code for the docs of the hook defined do-next manager that we're creating OR tempcode for it (NULL: none) * @param ID_TEXT The menu 'type' we are doing (filters out any icons that don't match it) * @param ?string The title to use for the main links (a language string) (NULL: same as title) * @return tempcode The do next manager */ function do_next_manager_hooked($title, $text, $type, $main_title = NULL) { $links = array(); if (is_null($main_title)) { $main_title = $title; } breadcrumb_set_self(do_lang_tempcode($title)); $hooks = find_all_hooks('systems', 'do_next_menus'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/do_next_menus/' . filter_naughty_harsh($hook)); $object = object_factory('Hook_do_next_menus_' . filter_naughty_harsh($hook), true); if (is_null($object)) { continue; } $info = $object->run(true); foreach ($info as $i) { if (is_null($i)) { continue; } if ($i[0] == $type) { array_shift($i); $links[] = $i; } } } global $M_SORT_KEY; $M_SORT_KEY = 2; @usort($links, 'multi_sort'); if (!is_null($text)) { if (strpos($text, ' ') === false) { $_text = comcode_lang_string($text); } else { $_text = make_string_tempcode($text); } } else { $_text = new ocp_tempcode(); } return do_next_manager(is_null($text) ? NULL : get_page_title($title), $_text, $links, do_lang($main_title)); }
/** * Standard modular run function for OcCLE hooks. * * @param array The options with which the command was called * @param array The parameters with which the command was called * @param array A reference to the OcCLE filesystem object * @return array Array of stdcommand, stdhtml, stdout, and stderr responses */ function run($options, $parameters, &$occle_fs) { if (array_key_exists('h', $options) || array_key_exists('help', $options)) { return array('', do_command_help('find_entry_points', array('h'), array(true)), '', ''); } else { if (!array_key_exists(0, $parameters)) { return array('', '', '', do_lang('MISSING_PARAM', '1', 'find_entry_points')); } // NOTE: this code assumes the search-string is contained within the zone:page portion of the entry point, not any part of the parameterisation $entry_points = array(); $zones = find_all_zones(); require_all_lang(); foreach ($zones as $zone) { $pages = find_all_pages_wrap($zone); foreach ($pages as $page => $type) { if (strpos($zone . ':' . $page, $parameters[0]) !== false) { if ($type == 'modules' || $type == 'modules_custom') { require_code(zone_black_magic_filterer(filter_naughty_harsh($zone) . '/pages/' . filter_naughty_harsh($type) . '/' . filter_naughty_harsh($page) . '.php')); if (class_exists('Mx_' . filter_naughty_harsh($page))) { $object = object_factory('Mx_' . filter_naughty_harsh($page), true); } else { $object = object_factory('Module_' . filter_naughty_harsh($page), true); } if (!is_null($object) && method_exists($object, 'get_entry_points')) { $_entry_points = $object->get_entry_points(); foreach ($_entry_points as $key => $val) { $entry_points[$zone . ':' . $page . ':' . $key] = do_lang($val); } } } else { $entry_points[$zone . ':' . $page] = $page; } } } } return array('', do_template('OCCLE_ENTRY_POINTS', array('_GUID' => 'afaf0b0451ccbdae399dd56e39359c0e', 'ENTRY_POINTS' => $entry_points)), '', ''); } }
/** * Get an addon icon. * * @param ID_TEXT The name of the addon * @return URLPATH Addon icon (blank: could not find one) */ function find_addon_icon($hook) { if ($hook == '') { return ''; } static $addon_icons_cache = array(); if (isset($addon_icons_cache[$hook])) { return $addon_icons_cache[$hook]; } $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; if (!file_exists($path)) { $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php'; } if (!file_exists($path)) { return ''; } $hook_file = file_get_contents($path); $matches = array(); if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) { if (!defined('HIPHOP_PHP')) { $addon_files = eval($matches[1]); } else { require_code('hooks/systems/addon_registry/' . $hook); $hook_ob = object_factory('Hook_addon_registry_' . $hook); $addon_files = $hook_ob->get_file_list(); } foreach ($addon_files as $file) { if (substr($file, 0, 31) == 'themes/default/images/bigicons/') { $addon_icons_cache[$hook] = find_theme_image('bigicons/' . basename($file, '.png'), false, true); return $addon_icons_cache[$hook]; } } } $addon_icons_cache[$hook] = ''; return ''; }