コード例 #1
0
ファイル: help.php プロジェクト: erico-deh/ocPortal
 /**
  * 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'), '');
     }
 }
コード例 #2
0
ファイル: main_notes.php プロジェクト: erico-deh/ocPortal
 /**
  * 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));
 }
コード例 #3
0
 /**
  * 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));
 }
コード例 #4
0
ファイル: themewizard.php プロジェクト: erico-deh/ocPortal
/**
 * 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);
    }
}
コード例 #5
0
ファイル: unvalidated.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
 }
コード例 #6
0
ファイル: inst_special.php プロジェクト: erico-deh/ocPortal
/**
 * 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'));
}
コード例 #7
0
 /**
  * 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()));
         }
     }
 }
コード例 #8
0
ファイル: site_adminzone.php プロジェクト: erico-deh/ocPortal
/**
 * Extend breadcrumbs for the Admin Zone (called by breadcrumbs_get_default_stub).
 *
 * @param  tempcode		Reference to the breadcrumbs stub we're assembling
 */
function adminzone_extend_breadcrumbs(&$stub)
{
    global $BREADCRUMB_SET_PARENTS;
    if (count($BREADCRUMB_SET_PARENTS) > 0 && !is_object($BREADCRUMB_SET_PARENTS[0][0])) {
        // Works by finding where our oldest ancestor connects on to the do-next menus, and carries from there
        list($zone, $attributes, ) = page_link_decode($BREADCRUMB_SET_PARENTS[0][0]);
        $type = array_key_exists('type', $attributes) ? $attributes['type'] : 'misc';
        $page = $attributes['page'];
        if ($page == '_SELF') {
            $page = get_page_name();
        }
        if ($zone == '_SEARCH') {
            $zone = get_module_zone($page);
        }
        if ($zone == '_SELF') {
            $zone = get_zone_name();
        }
    } else {
        // Works by finding where we connect on to the do-next menus, and carries from there
        $type = get_param('type', 'misc');
        $page = get_page_name();
        $zone = get_zone_name();
    }
    if ($page != 'admin' && $page != 'cms') {
        // Loop over menus, hunting for connection
        $hooks = find_all_hooks('systems', 'do_next_menus');
        $_hooks = array();
        $page_looking = $page;
        $page_looking = preg_replace('#^(cms|admin)\\_#', '', $page_looking);
        if (array_key_exists($page_looking, $hooks)) {
            $_hooks[$page_looking] = $hooks[$page_looking];
            unset($hooks[$page_looking]);
            $hooks = array_merge($_hooks, $hooks);
        }
        foreach ($hooks as $hook => $sources_dir) {
            $run_function = extract_module_functions(get_file_base() . '/' . $sources_dir . '/hooks/systems/do_next_menus/' . $hook . '.php', array('run'));
            if ($run_function[0] !== NULL) {
                $info = is_array($run_function[0]) ? call_user_func_array($run_function[0][0], $run_function[0][1]) : eval($run_function[0]);
                foreach ($info as $i) {
                    if ($i === NULL) {
                        continue;
                    }
                    if ($page == $i[2][0] && (!array_key_exists('type', $i[2][1]) && $type == 'misc' || array_key_exists('type', $i[2][1]) && ($type == $i[2][1]['type'] || $i[2][1]['type'] == 'misc')) && $zone == $i[2][2]) {
                        if ($i[0] == 'cms') {
                            $url = build_url(array('page' => 'cms', 'type' => $i[0] == 'cms' ? NULL : $i[0]), 'cms');
                        } else {
                            $url = build_url(array('page' => 'admin', 'type' => $i[0]), 'adminzone');
                        }
                        require_lang('menus');
                        require_lang('security');
                        $stub->attach(hyperlink($url, do_lang_tempcode(strtoupper($i[0])), false, false, do_lang_tempcode('GO_BACKWARDS_TO', @html_entity_decode(strip_tags(do_lang(strtoupper($i[0]))), ENT_QUOTES, get_charset()))));
                        //if ((!array_key_exists('type',$i[2][1])) || ($type==$i[2][1]['type'])) break;
                        return;
                    }
                }
            }
        }
    }
}
コード例 #9
0
 /**
  * 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));
 }
コード例 #10
0
ファイル: submit.php プロジェクト: erico-deh/ocPortal
/**
 * 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);
}
コード例 #11
0
ファイル: commands.php プロジェクト: erico-deh/ocPortal
 /**
  * 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('commands', array('h'), array()), '', '');
     } else {
         $hooks = find_all_hooks('modules', 'admin_occle_commands');
         $commands = array_keys($hooks);
         sort($commands);
         return array('', do_template('OCCLE_COMMANDS', array('COMMANDS' => $commands)), '', '');
     }
 }
コード例 #12
0
ファイル: stats.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     if (!is_null($GLOBALS['CURRENT_SHARE_USER'])) {
         return new ocp_tempcode();
     }
     $hooks = find_all_hooks('systems', 'disposable_values');
     foreach (array_keys($hooks) as $hook) {
         $GLOBALS['SITE_DB']->query_delete('values', array('the_name' => $hook), '', 1);
     }
     persistant_cache_delete('VALUES');
     return new ocp_tempcode();
 }
コード例 #13
0
ファイル: realtime_rain.php プロジェクト: erico-deh/ocPortal
/**
 * 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;
}
コード例 #14
0
ファイル: edit.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
 }
コード例 #15
0
ファイル: activities.php プロジェクト: erico-deh/ocPortal
 /**
  * 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;
 }
コード例 #16
0
ファイル: comments.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
 }
コード例 #17
0
 /**
  * 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();
         }
     }
 }
コード例 #18
0
ファイル: content_link.php プロジェクト: erico-deh/ocPortal
 /**
  * Find what field types this hook can serve. This method only needs to be defined if it is not serving a single field type with a name corresponding to the hook itself.
  *
  * @return array			Map of field type to field type title
  */
 function get_field_types()
 {
     $hooks = find_all_hooks('systems', 'ajax_tree');
     $ret = array();
     foreach (array_keys($hooks) as $hook) {
         if (substr($hook, 0, 7) == 'choose_' && $hook != 'catalogue_entry') {
             $_hook = preg_replace('#^choose_#', '', $hook);
             if ($_hook == 'forum_topic' || is_file(get_file_base() . '/sources_custom/hooks/systems/content_meta_aware/' . $_hook . '.php') || is_file(get_file_base() . '/sources/hooks/systems/content_meta_aware/' . $_hook . '.php')) {
                 $ret['at_' . $hook] = do_lang_tempcode('FIELD_TYPE_content_link_x', escape_html($_hook));
             }
         }
     }
     return $ret;
 }
コード例 #19
0
/**
 * @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;
}
コード例 #20
0
ファイル: content.php プロジェクト: erico-deh/ocPortal
/**
 * Find a different content type code from the one had. In future we intend to change everything to be cma_hook internally.
 *
 * @param  ID_TEXT		Content type type we know
 * @set addon cma_hook award_hook search_hook table seo_type_code feedback_type_code permissions_type_code module
 * @param  ID_TEXT		Content type ID we know
 * @param  ID_TEXT		Desired content type
 * @set addon cma_hook search_hook table seo_type_code feedback_type_code permissions_type_code module
 * @return ID_TEXT		Corrected content type type (blank: could not find)
 */
function convert_ocportal_type_codes($type_has, $type_id, $type_wanted)
{
    $real_type_wanted = $type_wanted;
    if ($type_wanted == 'award_hook') {
        $type_wanted = 'cma_hook';
    }
    // TODO: remove legacy later
    if ($type_has == 'award_hook') {
        if ($type_id == 'seedy_page') {
            $type_id = 'cedi_page';
        }
        if ($type_id == 'seedy_post') {
            $type_id = 'cedi_post';
        }
        $type_has = 'cma_hook';
    }
    $type_id = preg_replace('#^catalogues__\\w+_#', 'catalogues_', $type_id);
    // Search content-meta-aware hooks
    $found_type_id = '';
    $cma_hooks = find_all_hooks('systems', 'content_meta_aware');
    foreach (array_keys($cma_hooks) as $cma_hook) {
        if ($type_has == 'cma_hook' && $cma_hook == $type_id || $type_has != 'cma_hook') {
            require_code('hooks/systems/content_meta_aware/' . $cma_hook);
            $cms_ob = object_factory('Hook_content_meta_aware_' . $cma_hook);
            $cma_info = $cms_ob->info();
            $cma_info['cma_hook'] = $cma_hook;
            if (isset($cma_info[$type_has]) && isset($cma_info[$type_wanted]) && ($cma_info[$type_has] == $type_id || $cma_info[$type_has] == preg_replace('#__.*$#', '', $type_id))) {
                $found_type_id = $cma_info[$type_wanted];
                break;
            }
        }
    }
    if ($real_type_wanted == 'award_hook') {
        // TODO: remove legacy later
        if ($found_type_id == 'cedi_page') {
            $found_type_id = 'seedy_page';
        }
        if ($found_type_id == 'cedi_post') {
            $found_type_id = 'seedy_post';
        }
        if ($found_type_id == 'iotd') {
            $found_type_id = '';
        }
        // TODO: No award hook right now
    }
    return $found_type_id;
}
コード例 #21
0
ファイル: activities.php プロジェクト: erico-deh/ocPortal
 /**
  * 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);
 }
コード例 #22
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run_start()
 {
     require_lang('ecommerce');
     require_code('ecommerce');
     if (get_value('unofficial_ecommerce') != '1' && count(find_all_hooks('systems', 'ecommerce')) == 8) {
         if (get_forum_type() != 'ocf') {
             warn_exit(do_lang_tempcode('NO_OCF'));
         } else {
             ocf_require_all_forum_stuff();
         }
     }
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/ecommerce';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_ecommerce';
     $type = get_param('type', 'misc');
     $this->add_one_label = do_lang_tempcode('ADD_USERGROUP_SUBSCRIPTION');
     $this->edit_this_label = do_lang_tempcode('EDIT_THIS_USERGROUP_SUBSCRIPTION');
     $this->edit_one_label = do_lang_tempcode('EDIT_USERGROUP_SUBSCRIPTION');
     if ($type == 'misc') {
         return $this->misc();
     }
     if ($type == 'logs') {
         return $this->logs();
     }
     if ($type == 'ecom_usage') {
         return $this->usage();
     }
     if ($type == 'cash_flow') {
         return $this->cash_flow();
     }
     if ($type == 'profit_loss') {
         return $this->profit_loss();
     }
     //if ($type=='balance_sheet') return $this->balance_sheet();
     if ($type == 'trigger') {
         return $this->trigger();
     }
     if ($type == '_trigger') {
         return $this->_trigger();
     }
     if (get_forum_type() == 'ocf') {
         breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS'))));
     }
     return new ocp_tempcode();
 }
コード例 #23
0
ファイル: ocf_profiles.php プロジェクト: erico-deh/ocPortal
/**
 * 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)));
}
コード例 #24
0
ファイル: feedback2.php プロジェクト: erico-deh/ocPortal
/**
 * 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();
}
コード例 #25
0
/**
 * 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));
}
コード例 #26
0
ファイル: notifications.php プロジェクト: erico-deh/ocPortal
/**
 * Find the notification object for a particular notification code.
 *
 * @param  ID_TEXT		The notification code to use
 * @return ?object		Notification object (NULL: could not find)
 */
function _get_notification_ob_for_code($notification_code)
{
    $path = 'hooks/systems/notifications/' . filter_naughty($notification_code);
    if (!is_file(get_file_base() . '/sources/' . $path . '.php') && !is_file(get_file_base() . '/sources_custom/' . $path . '.php')) {
        require_all_lang();
        $hooks = find_all_hooks('systems', 'notifications');
        foreach (array_keys($hooks) as $hook) {
            $path = 'hooks/systems/notifications/' . filter_naughty($hook);
            require_code($path);
            $ob = object_factory('Hook_Notification_' . filter_naughty($hook));
            if (method_exists($ob, 'list_handled_codes')) {
                if (array_key_exists($notification_code, $ob->list_handled_codes())) {
                    return $ob;
                }
            }
        }
    } else {
        require_code($path);
        return object_factory('Hook_Notification_' . filter_naughty($notification_code));
    }
    return NULL;
    //return object_factory('Hook_Notification'); // default
}
コード例 #27
0
ファイル: admin_cleanup.php プロジェクト: erico-deh/ocPortal
 /**
  * The actualiser for emptying caches.
  *
  * @return tempcode		The UI
  */
 function do_rebuild()
 {
     $hooks = find_all_hooks('modules', 'admin_cleanup');
     // Fiddle the order a bit
     if (array_key_exists('ocf_topics', $hooks)) {
         unset($hooks['ocf_topics']);
         $hooks['ocf_topics'] = 'sources_custom';
     }
     if (array_key_exists('ocf', $hooks)) {
         unset($hooks['ocf']);
         $hooks['ocf'] = 'sources_custom';
     }
     if (array_key_exists('ocf_members', $hooks)) {
         unset($hooks['ocf_members']);
         $hooks['ocf_members'] = 'sources_custom';
     }
     $todo = array();
     foreach (array_keys($hooks) as $hook) {
         if (post_param_integer($hook, 0) == 1) {
             $todo[] = $hook;
         }
     }
     $messages = ocportal_cleanup($todo);
     $messages->attach(paragraph(do_lang_tempcode('SUCCESS')));
     $title = get_page_title('CLEANUP_TOOLS');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CLEANUP_TOOLS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return do_template('CLEANUP_COMPLETED_SCREEN', array('_GUID' => '598510a9ad9f01f3c0806319b32b5033', 'TITLE' => $title, 'MESSAGES' => $messages));
 }
コード例 #28
0
ファイル: about.php プロジェクト: erico-deh/ocPortal
 /**
  * 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('PROFILE');
     $order = 10;
     $photo_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_url');
     if ($photo_url != '' && addon_installed('ocf_member_photos') && has_specific_permission($member_id_viewing, 'view_member_photos')) {
         require_code('images');
         $photo_thumb_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_photo_thumb_url');
         $photo_thumb_url = ensure_thumbnail($photo_url, $photo_thumb_url, strpos($photo_url, 'uploads/photos') !== false ? 'photos' : 'ocf_photos', 'f_members', $member_id_of, 'm_photo_thumb_url');
         if (url_is_local($photo_url)) {
             $photo_url = get_complex_base_url($photo_url) . '/' . $photo_url;
         }
         if (url_is_local($photo_thumb_url)) {
             $photo_thumb_url = get_complex_base_url($photo_thumb_url) . '/' . $photo_thumb_url;
         }
     } else {
         $photo_url = '';
         $photo_thumb_url = '';
     }
     $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($member_id_of);
     $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
     // Things staff can do with this user
     $modules = array();
     if (has_specific_permission($member_id_viewing, 'warn_members') && has_actual_page_access($member_id_viewing, 'warnings') && addon_installed('ocf_warnings')) {
         $redir_url = get_self_url(true);
         $modules[] = array('usage', do_lang_tempcode('WARN_MEMBER'), build_url(array('page' => 'warnings', 'type' => 'ad', 'id' => $member_id_of, 'redirect' => $redir_url), get_module_zone('warnings')));
         $modules[] = array('usage', do_lang_tempcode('PUNITIVE_HISTORY'), build_url(array('page' => 'warnings', 'type' => 'history', 'id' => $member_id_of), get_module_zone('warnings')));
     }
     if (has_specific_permission($member_id_viewing, 'view_content_history') && has_actual_page_access($member_id_viewing, 'admin_ocf_history')) {
         $modules[] = !addon_installed('ocf_forum') ? NULL : array('usage', do_lang_tempcode('POST_HISTORY'), build_url(array('page' => 'admin_ocf_history', 'member_id' => $member_id_of), 'adminzone'));
     }
     if (has_actual_page_access($member_id_viewing, 'admin_lookup')) {
         require_lang('submitban');
         $modules[] = array('usage', do_lang_tempcode('INVESTIGATE_USER'), build_url(array('page' => 'admin_lookup', 'param' => $member_id_of), 'adminzone'));
     }
     if (has_actual_page_access($member_id_viewing, 'admin_security')) {
         require_lang('security');
         $modules[] = array('usage', do_lang_tempcode('SECURITY_LOGGING'), build_url(array('page' => 'admin_security', 'member_id' => $member_id_of), 'adminzone'));
     }
     if (addon_installed('actionlog')) {
         if (has_actual_page_access($member_id_viewing, 'admin_actionlog')) {
             require_lang('submitban');
             $modules[] = array('usage', do_lang_tempcode('VIEW_ACTION_LOGS'), build_url(array('page' => 'admin_actionlog', 'type' => 'list', 'id' => $member_id_of), 'adminzone'));
         }
     }
     if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('ocf_forum') && addon_installed('search')) {
         $modules[] = array('content', do_lang_tempcode('SEARCH_POSTS'), build_url(array('page' => 'search', 'type' => 'results', 'id' => 'ocf_posts', 'author' => $username, 'sort' => 'add_date', 'direction' => 'DESC', 'content' => ''), get_module_zone('search')), 'search');
     }
     if (has_actual_page_access($member_id_viewing, 'search') && addon_installed('search')) {
         $modules[] = array('content', do_lang_tempcode('SEARCH'), build_url(array('page' => 'search', 'type' => 'misc', 'author' => $username), get_module_zone('search')), 'search');
     }
     if (addon_installed('authors')) {
         $author = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT author FROM ' . get_table_prefix() . 'authors WHERE (forum_handle=' . strval($member_id_viewing) . ') OR (forum_handle IS NULL AND ' . db_string_equal_to('author', $username) . ')');
         if (has_actual_page_access($member_id_viewing, 'authors') && !is_null($author)) {
             $modules[] = array('content', do_lang_tempcode('AUTHOR'), build_url(array('page' => 'authors', 'type' => 'misc', 'id' => $author), get_module_zone('authors')), 'me');
         }
     }
     require_code('ocf_members2');
     if (!is_guest() && ocf_may_whisper($member_id_of) && has_actual_page_access($member_id_viewing, 'topics') && ocf_may_make_personal_topic() && $member_id_viewing != $member_id_of) {
         $modules[] = !addon_installed('ocf_forum') ? NULL : array('contact', do_lang_tempcode('ADD_PERSONAL_TOPIC'), build_url(array('page' => 'topics', 'type' => 'new_pt', 'id' => $member_id_of), get_module_zone('topics')), 'reply');
     }
     $extra_sections = array();
     $info_details = array();
     $hooks = find_all_hooks('modules', 'members');
     foreach (array_keys($hooks) as $hook) {
         require_code('hooks/modules/members/' . filter_naughty_harsh($hook));
         $object = object_factory('Hook_members_' . filter_naughty_harsh($hook), true);
         if (is_null($object)) {
             continue;
         }
         if (method_exists($object, 'run')) {
             $hook_result = $object->run($member_id_of);
             $modules = array_merge($modules, $hook_result);
         }
         if (method_exists($object, 'get_info_details')) {
             $hook_result = $object->get_info_details($member_id_of);
             $info_details = array_merge($info_details, $hook_result);
         }
         if (method_exists($object, 'get_sections')) {
             $hook_result = $object->get_sections($member_id_of);
             $extra_sections = array_merge($extra_sections, $hook_result);
         }
     }
     if (addon_installed('ocf_contactmember')) {
         if (($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_allow_emails') == 1 || get_option('allow_email_disable') == '0') && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address') != '' && !is_guest($member_id_of) && has_actual_page_access($member_id_viewing, 'contactmember') && $member_id_viewing != $member_id_of) {
             $redirect = get_self_url(true);
             $modules[] = array('contact', do_lang_tempcode('_EMAIL_MEMBER'), build_url(array('page' => 'contactmember', 'redirect' => $redirect, 'id' => $member_id_of), get_module_zone('contactmember')), 'reply');
         }
     }
     require_lang('menus');
     $sections = array('contact' => do_lang_tempcode('CONTACT'), 'profile' => do_lang_tempcode('EDIT_PROFILE'), 'views' => do_lang_tempcode('ACCOUNT'), 'usage' => do_lang_tempcode('USAGE'), 'content' => do_lang_tempcode('CONTENT'));
     $actions = array();
     global $M_SORT_KEY;
     $M_SORT_KEY = mixed();
     $M_SORT_KEY = 1;
     @uasort($modules, 'multi_sort');
     /* @ is to stop PHP bug warning about altered array contents when Tempcode copies are evaluated internally */
     foreach ($sections as $section_code => $section_title) {
         $links = new ocp_tempcode();
         foreach ($modules as $module) {
             if (count($module) == 3) {
                 list($_section_code, $lang, $url) = $module;
                 $rel = NULL;
             } else {
                 list($_section_code, $lang, $url, $rel) = $module;
             }
             if ($section_code == $_section_code) {
                 $links->attach(do_template('OCF_MEMBER_ACTION', array('_GUID' => '67b2a640a368c6f53f1b1fa10f922fd0', 'ID' => strval($member_id_of), 'URL' => $url, 'LANG' => $lang, 'REL' => $rel)));
             }
         }
         $actions[$section_code] = $links;
     }
     // Custom fields
     $_custom_fields = ocf_get_all_custom_fields_match_member($member_id_of, $member_id_viewing != $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_viewing == $member_id_of && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL);
     $custom_fields = array();
     require_code('encryption');
     $value = mixed();
     foreach ($_custom_fields as $name => $_value) {
         $value = $_value['RAW'];
         $rendered_value = $_value['RENDERED'];
         $encrypted_value = '';
         if (is_data_encrypted($value)) {
             $encrypted_value = remove_magic_encryption_marker($value);
         } elseif (is_integer($value)) {
             $value = strval($value);
         } elseif (is_float($value)) {
             $value = float_to_raw_string($value);
         }
         if (!is_object($value) && $value != '' || is_object($value) && !$value->is_empty()) {
             $custom_fields[] = array('NAME' => $name, 'RAW_VALUE' => $value, 'VALUE' => $rendered_value, 'ENCRYPTED_VALUE' => $encrypted_value);
             if ($name == do_lang('KEYWORDS')) {
                 $GLOBALS['SEO_KEYWORDS'] = is_object($value) ? $value->evaluate() : $value;
             }
             if ($name == do_lang('DESCRIPTION')) {
                 $GLOBALS['SEO_DESCRIPTION'] = is_object($value) ? $value->evaluate() : $value;
             }
         }
     }
     // Birthday
     $dob = '';
     if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_reveal_age') == 1) {
         $day = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_day');
         $month = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_month');
         $year = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_dob_year');
         if (!is_null($day)) {
             if (@strftime('%Y', @mktime(0, 0, 0, 1, 1, 1963)) != '1963') {
                 $dob = strval($year) . '-' . str_pad(strval($month), 2, '0', STR_PAD_LEFT) . '-' . str_pad(strval($day), 2, '0', STR_PAD_LEFT);
             } else {
                 $dob = get_timezoned_date(mktime(12, 0, 0, $month, $day, $year), false, true, true);
             }
         }
     }
     // Find forum with most posts
     $forums = $GLOBALS['FORUM_DB']->query('SELECT id,f_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_cache_num_posts>0');
     $best_yet_forum = 0;
     // Initialise to integer type
     $best_yet_forum = NULL;
     $most_active_forum = NULL;
     $_best_yet_forum = $GLOBALS['FORUM_DB']->query_select('f_posts', array('COUNT(*) as cnt', 'p_cache_forum_id'), array('p_poster' => $member_id_of), 'GROUP BY p_cache_forum_id');
     $_best_yet_forum = collapse_2d_complexity('p_cache_forum_id', 'cnt', $_best_yet_forum);
     foreach ($forums as $forum) {
         if (array_key_exists($forum['id'], $_best_yet_forum) && (is_null($best_yet_forum) || $_best_yet_forum[$forum['id']] > $best_yet_forum)) {
             $most_active_forum = has_category_access($member_id_viewing, 'forums', strval($forum['id'])) ? protect_from_escaping(escape_html($forum['f_name'])) : do_lang_tempcode('PROTECTED_FORUM');
             $best_yet_forum = $_best_yet_forum[$forum['id']];
         }
     }
     $post_count = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_cache_num_posts');
     $best_post_fraction = $post_count == 0 ? do_lang_tempcode('NA_EM') : make_string_tempcode(integer_format(100 * $best_yet_forum / $post_count));
     $most_active_forum = is_null($best_yet_forum) ? new ocp_tempcode() : do_lang_tempcode('_MOST_ACTIVE_FORUM', $most_active_forum, make_string_tempcode(integer_format($best_yet_forum)), array($best_post_fraction));
     $time_for_them_raw = tz_time(time(), get_users_timezone($member_id_of));
     $time_for_them = get_timezoned_time(time(), true, $member_id_of);
     $banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned') == 1 ? do_lang_tempcode('YES') : do_lang_tempcode('NO');
     $last_submit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_submit_time');
     $submit_days_ago = intval(floor(floatval(time() - $last_submit_time) / 60.0 / 60.0 / 24.0));
     require_code('ocf_groups');
     $primary_group_id = ocf_get_member_primary_group($member_id_of);
     $primary_group = ocf_get_group_link($primary_group_id);
     $signature = get_translated_tempcode($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_signature'), $GLOBALS['FORUM_DB']);
     $last_visit_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_last_visit_time');
     if (member_is_online($member_id_of)) {
         $online_now = do_lang_tempcode('YES');
         $_online_now = true;
     } else {
         $_online_now = false;
         $minutes_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0));
         $hours_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0));
         $days_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0));
         $months_ago = intval(floor(floatval(time() - $last_visit_time) / 60.0 / 60.0 / 24.0 / 31.0));
         if ($minutes_ago < 180) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MINUTES', integer_format($minutes_ago));
         } elseif ($hours_ago < 72) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_HOURS', integer_format($hours_ago));
         } elseif ($days_ago < 93) {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_DAYS', integer_format($days_ago));
         } else {
             $online_now = do_lang_tempcode('_ONLINE_NOW_NO_MONTHS', integer_format($months_ago));
         }
     }
     $join_time = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_join_time');
     $days_joined = intval(round((time() - $join_time) / 60 / 60 / 24));
     $total_posts = $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)');
     $join_date = $join_time == 0 ? '' : get_timezoned_date($join_time, false);
     $count_posts = do_lang_tempcode('_COUNT_POSTS', integer_format($post_count), float_format(floatval($post_count) / floatval($days_joined == 0 ? 1 : $days_joined)), array(float_format(floatval(100 * $post_count) / floatval($total_posts == 0 ? 1 : $total_posts))));
     $a = $avatar_url == '' ? 0 : ocf_get_member_best_group_property($member_id_of, 'max_avatar_width');
     $b = $photo_thumb_url == '' ? 0 : intval(get_option('thumb_width'));
     $right_margin = max($a, $b) == 0 ? 'auto' : strval(max($a, $b) + 6) . 'px';
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MEMBERS'))));
     if (has_specific_permission($member_id_viewing, 'see_ip')) {
         $ip_address = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_ip_address');
     } else {
         $ip_address = '';
     }
     $secondary_groups = ocf_get_members_groups($member_id_of, true);
     unset($secondary_groups[$primary_group_id]);
     if (count($secondary_groups) > 0) {
         $_secondary_groups = array();
         $all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true, false, false, array_keys($secondary_groups), $member_id_of);
         foreach (array_keys($secondary_groups) as $key) {
             $_secondary_groups[$key] = $all_groups[$key];
         }
         $secondary_groups = $_secondary_groups;
     }
     if (addon_installed('points')) {
         require_code('points');
         $count_points = integer_format(total_points($member_id_of));
     } else {
         $count_points = '';
     }
     $user_agent = NULL;
     $operating_system = NULL;
     if (has_specific_permission($member_id_viewing, 'show_user_browsing') && addon_installed('stats')) {
         $last_stats = $GLOBALS['SITE_DB']->query_select('stats', array('browser', 'operating_system'), array('the_user' => $member_id_of), 'ORDER BY date_and_time DESC', 1);
         if (array_key_exists(0, $last_stats)) {
             $user_agent = $last_stats[0]['browser'];
             $operating_system = $last_stats[0]['operating_system'];
         }
     }
     /*if ((get_option('allow_member_integration')!='off') && (get_option('allow_member_integration')!='hidden'))
     		{
     			$remote=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of,'m_password_compat_scheme')=='remote';
     		} else */
     $remote = NULL;
     $_on_probation = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until');
     if (is_null($_on_probation) || $_on_probation <= time()) {
         $on_probation = NULL;
     } else {
         $on_probation = strval($_on_probation);
     }
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $join_time), 'creator' => $username, 'publisher' => '', 'modified' => '', 'type' => 'Member', 'title' => '', 'identifier' => '_SEARCH:members:view:' . strval($member_id_of), 'description' => '', 'image' => $avatar_url == '' && has_specific_permission($member_id_viewing, 'view_member_photos') ? $photo_url : $avatar_url);
     // Look up member's clubs
     $clubs = array();
     if (addon_installed('ocf_clubs')) {
         $club_ids = $GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of, true);
         $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1), '', 200));
         if (count($club_rows) == 200) {
             $club_rows = NULL;
         }
         foreach ($club_ids as $club_id) {
             if (is_null($club_rows)) {
                 $club_rows = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), array('g_is_private_club' => 1, 'id' => $club_id), '', 200));
                 if (!array_key_exists($club_id, $club_rows)) {
                     continue;
                 }
                 $club_row = $club_rows[$club_id];
                 $club_rows = NULL;
             } else {
                 if (!array_key_exists($club_id, $club_rows)) {
                     continue;
                 }
                 $club_row = $club_rows[$club_id];
             }
             $club_name = get_translated_text($club_row['g_name'], $GLOBALS['FORUM_DB']);
             $club_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums f LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON t.id=f.f_description', 'f.id', array('text_original' => do_lang('FORUM_FOR_CLUB', $club_name)));
             $clubs[] = array('CLUB_NAME' => $club_name, 'CLUB_ID' => strval($club_row['id']), 'CLUB_FORUM' => is_null($club_forum) ? '' : strval($club_forum));
         }
     }
     $content = do_template('OCF_MEMBER_PROFILE_ABOUT', array('_GUID' => 'fodfjdsfjsdljfdls', 'CLUBS' => $clubs, 'REMOTE' => $remote, 'RIGHT_MARGIN' => $right_margin, 'AVATAR_WIDTH' => strval($a) . 'px', 'PHOTO_WIDTH' => strval($b) . 'px', 'MOST_ACTIVE_FORUM' => $most_active_forum, 'TIME_FOR_THEM' => $time_for_them, 'TIME_FOR_THEM_RAW' => strval($time_for_them_raw), 'SUBMIT_DAYS_AGO' => integer_format($submit_days_ago), 'SUBMIT_TIME_RAW' => strval($last_submit_time), 'LAST_VISIT_TIME_RAW' => strval($last_visit_time), 'ONLINE_NOW' => $online_now, '_ONLINE_NOW' => $_online_now, 'BANNED' => $banned, 'USER_AGENT' => $user_agent, 'OPERATING_SYSTEM' => $operating_system, 'DOB' => $dob, 'IP_ADDRESS' => $ip_address, 'COUNT_POSTS' => $count_posts, 'COUNT_POINTS' => $count_points, 'PRIMARY_GROUP' => $primary_group, 'PRIMARY_GROUP_ID' => strval($primary_group_id), 'PHOTO_URL' => $photo_url, 'PHOTO_THUMB_URL' => $photo_thumb_url, 'EMAIL_ADDRESS' => $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_email_address'), 'AVATAR_URL' => $avatar_url, 'SIGNATURE' => $signature, 'JOIN_DATE' => $join_date, 'JOIN_DATE_RAW' => strval($join_time), 'CUSTOM_FIELDS' => $custom_fields, 'ACTIONS_contact' => $actions['contact'], 'ACTIONS_profile' => $actions['profile'], 'ACTIONS_views' => $actions['views'], 'ACTIONS_usage' => $actions['usage'], 'ACTIONS_content' => $actions['content'], 'USERNAME' => $username, 'MEMBER_ID' => strval($member_id_of), 'SECONDARY_GROUPS' => $secondary_groups, 'VIEW_PROFILES' => $member_id_viewing == $member_id_of || has_specific_permission($member_id_viewing, 'view_profiles'), 'ON_PROBATION' => $on_probation, 'EXTRA_INFO_DETAILS' => $info_details, 'EXTRA_SECTIONS' => $extra_sections));
     return array($title, $content, $order);
 }
コード例 #29
0
ファイル: topics.php プロジェクト: erico-deh/ocPortal
 /**
  * Render posts.
  *
  * @param  integer		Maximum to load if non-threaded
  * @param  array			Tree structure of posts
  * @param  boolean		Whether the current user may reply to the topic (influences what buttons show)
  * @param  ?AUTO_LINK	Only show posts under here (NULL: show posts from root)
  * @param  array			Review ratings rows
  * @param  AUTO_LINK		ID of forum this topic in in
  * @return tempcode		Rendered tree structure
  */
 function _render_post_tree($num_to_show_limit, $tree, $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id)
 {
     list($rendered, ) = $tree;
     $sequence = new ocp_tempcode();
     foreach ($rendered as $post) {
         if (get_forum_type() == 'ocf') {
             require_code('ocf_topicview');
             require_code('ocf_posts');
             $post += ocf_get_details_to_show_post($post);
         }
         // Misc details
         $datetime_raw = $post['date'];
         $datetime = get_timezoned_date($post['date']);
         $poster_url = is_guest($post['user']) ? new ocp_tempcode() : $GLOBALS['FORUM_DRIVER']->member_profile_url($post['user'], false, true);
         $poster_name = array_key_exists('username', $post) ? $post['username'] : $GLOBALS['FORUM_DRIVER']->get_username($post['user']);
         if (is_null($poster_name)) {
             $poster_name = do_lang('UNKNOWN');
         }
         $highlight = $highlight_by_user === $post['user'];
         // Find review, if there is one
         $individual_review_ratings = array();
         foreach ($all_individual_review_ratings as $potential_individual_review_rating) {
             if ($potential_individual_review_rating['r_post_id'] == $post['id']) {
                 $individual_review_ratings[$potential_individual_review_rating['r_rating_type']] = array('REVIEW_TITLE' => $potential_individual_review_rating['r_rating_type'], 'REVIEW_RATING' => float_to_raw_string($potential_individual_review_rating['r_rating']));
             }
         }
         // Edit URL
         $emphasis = new ocp_tempcode();
         $buttons = new ocp_tempcode();
         $last_edited = new ocp_tempcode();
         $last_edited_raw = '';
         $unvalidated = new ocp_tempcode();
         $poster = mixed();
         $poster_details = new ocp_tempcode();
         $is_spacer_post = false;
         if (get_forum_type() == 'ocf') {
             // Spacer post fiddling
             if (!is_null($this->first_post_id) && !is_null($this->topic_title) && !is_null($this->topic_description) && !is_null($this->topic_description_link)) {
                 $is_spacer_post = $post['id'] == $this->first_post_id && substr($post['message_comcode'], 0, strlen('[semihtml]' . do_lang('SPACER_POST_MATCHER'))) == '[semihtml]' . do_lang('SPACER_POST_MATCHER');
                 if ($is_spacer_post) {
                     $c_prefix = do_lang('COMMENT') . ': #';
                     if (substr($this->topic_description, 0, strlen($c_prefix)) == $c_prefix && $this->topic_description_link != '') {
                         list($linked_type, $linked_id) = explode('_', substr($this->topic_description, strlen($c_prefix)), 2);
                         $linked_url = $this->topic_description_link;
                         require_code('ocf_posts');
                         list($new_description, $new_post) = ocf_display_spacer_post($linked_type, $linked_id);
                         //if (!is_null($new_description)) $this->topic_description=$new_description;	Actually, it's a bit redundant
                         if (!is_null($new_post)) {
                             $post['message'] = $new_post;
                         }
                         $highlight = false;
                         $this->topic_title = do_lang('SPACER_TOPIC_TITLE_WRAP', $this->topic_title);
                         $post['title'] = do_lang('SPACER_TOPIC_TITLE_WRAP', $post['title']);
                         $this->topic_description = '';
                     }
                 }
             }
             // Misc meta details for post
             $emphasis = ocf_get_post_emphasis($post);
             $unvalidated = $post['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode();
             if (array_key_exists('last_edit_time', $post)) {
                 $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']), 'LAST_EDIT_DATE' => $post['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $post['last_edit_by_username']));
                 $last_edited_raw = is_null($post['last_edit_time']) ? '' : strval($post['last_edit_time']);
             }
             // Post buttons
             if (!$is_spacer_post) {
                 if (!is_null($this->topic_id)) {
                     if (is_null($this->topic_info)) {
                         $this->topic_info = ocf_read_in_topic($this->topic_id, 0, 0, false, false);
                     }
                     require_lang('ocf');
                     $buttons = ocf_render_post_buttons($this->topic_info, $post, $may_reply);
                 }
             }
             // 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_spacer_post) {
                 if (!is_guest($post['poster'])) {
                     require_code('ocf_members2');
                     $poster_details = ocf_show_member_box($post, false, $hooks, $hook_objects, false);
                 } else {
                     $custom_fields = new ocp_tempcode();
                     if (array_key_exists('ip_address', $post) && addon_installed('ocf_forum')) {
                         $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $post['ip_address'])));
                         $poster_details = do_template('OCF_GUEST_DETAILS', array('CUSTOM_FIELDS' => $custom_fields));
                     } else {
                         $poster_details = new ocp_tempcode();
                     }
                 }
             }
             if (addon_installed('ocf_forum')) {
                 if (!is_guest($post['poster'])) {
                     $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($post['poster']), 'ID' => strval($post['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($post['poster'], false, true), 'POSTER_USERNAME' => $post['poster_username']));
                 } else {
                     $ip_link = array_key_exists('ip_address', $post) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $post['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode();
                     $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $post['poster_username']));
                 }
             } else {
                 $poster = make_string_tempcode(escape_html($post['poster_username']));
             }
         }
         // Child posts
         $children = mixed();
         // NULL
         $other_ids = array();
         if (array_key_exists('children', $post)) {
             foreach ($post['children'][1] as $u) {
                 $other_ids[] = strval($u['id']);
             }
             if ($this->is_threaded) {
                 $children = $this->_render_post_tree($num_to_show_limit, $post['children'], $may_reply, $highlight_by_user, $all_individual_review_ratings, $forum_id);
             }
         }
         if (get_forum_type() == 'ocf') {
             require_code('feedback');
             actualise_rating(true, 'post', strval($post['id']), get_self_url(), $post['title']);
             $rating = display_rating(get_self_url(), $post['title'], 'post', strval($post['id']), 'RATING_INLINE_DYNAMIC', $post['user']);
         } else {
             $rating = new ocp_tempcode();
         }
         if (array_key_exists('intended_solely_for', $post)) {
             decache('side_ocf_personal_topics', array(get_member()));
             decache('_new_pp', array(get_member()));
         }
         // Render
         $sequence->attach(static_evaluate_tempcode(do_template('POST', array('_GUID' => 'eb7df038959885414e32f58e9f0f9f39', 'INDIVIDUAL_REVIEW_RATINGS' => $individual_review_ratings, 'HIGHLIGHT' => $highlight, 'TITLE' => $post['title'], 'TIME_RAW' => strval($datetime_raw), 'TIME' => $datetime, 'POSTER_ID' => strval($post['user']), 'POSTER_URL' => $poster_url, 'POSTER_NAME' => $poster_name, 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'ID' => strval($post['id']), 'POST' => $post['message'], 'POST_COMCODE' => isset($post['message_comcode']) ? $post['message_comcode'] : NULL, 'CHILDREN' => $children, 'OTHER_IDS' => count($other_ids) == 0 ? NULL : $other_ids, 'RATING' => $rating, 'EMPHASIS' => $emphasis, 'BUTTONS' => $buttons, 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'TOPIC_ID' => is_null($this->topic_id) ? '' : strval($this->topic_id), 'UNVALIDATED' => $unvalidated, 'IS_SPACER_POST' => $is_spacer_post, 'NUM_TO_SHOW_LIMIT' => strval($num_to_show_limit)))));
     }
     return $sequence;
 }
コード例 #30
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('catalogues');
     require_lang('main_google_map');
     // Set up config/defaults
     if (!array_key_exists('title', $map)) {
         $map['title'] = '';
     }
     if (!array_key_exists('region', $map)) {
         $map['region'] = '';
     }
     if (!array_key_exists('latitude', $map)) {
         $map['latitude'] = '0';
     }
     if (!array_key_exists('longitude', $map)) {
         $map['longitude'] = '0';
     }
     $mapwidth = array_key_exists('width', $map) ? $map['width'] : '100%';
     $mapheight = array_key_exists('height', $map) ? $map['height'] : '300px';
     $api_key = array_key_exists('api_key', $map) ? $map['api_key'] : '';
     $set_zoom = array_key_exists('zoom', $map) ? $map['zoom'] : '3';
     $set_center = array_key_exists('center', $map) ? $map['center'] : '0';
     $set_show_links = array_key_exists('show_links', $map) ? $map['show_links'] : '1';
     $cluster = array_key_exists('cluster', $map) ? $map['cluster'] : '0';
     if (!array_key_exists('catalogue', $map)) {
         $map['catalogue'] = '';
     }
     if (!array_key_exists('longfield', $map)) {
         $map['longfield'] = 'Longitude';
     }
     if (!array_key_exists('latfield', $map)) {
         $map['latfield'] = 'Latitude';
     }
     $min_latitude = array_key_exists('min_latitude', $map) ? $map['min_latitude'] : '';
     $max_latitude = array_key_exists('max_latitude', $map) ? $map['max_latitude'] : '';
     $min_longitude = array_key_exists('min_longitude', $map) ? $map['min_longitude'] : '';
     $max_longitude = array_key_exists('max_longitude', $map) ? $map['max_longitude'] : '';
     $longitude_key = $map['longfield'];
     $latitude_key = $map['latfield'];
     $catalogue_name = $map['catalogue'];
     $star_entry = array_key_exists('star_entry', $map) ? $map['star_entry'] : '';
     $max_results = array_key_exists('max_results', $map) && $map['max_results'] != '' ? intval($map['max_results']) : 1000;
     $icon = array_key_exists('icon', $map) ? $map['icon'] : '';
     if (!array_key_exists('filter_category', $map)) {
         $map['filter_category'] = '';
     }
     if (!array_key_exists('filter_rating', $map)) {
         $map['filter_rating'] = '';
     }
     if (!array_key_exists('filter_term', $map)) {
         $map['filter_term'] = '';
     }
     if (!array_key_exists('filter_hours', $map)) {
         $map['filter_hours'] = '';
     }
     $data = array();
     if ($catalogue_name != '') {
         // Data query
         $query = 'SELECT * FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_entries WHERE ce_validated=1 AND ' . db_string_equal_to('c_name', $catalogue_name);
         // Filtering
         if ($map['filter_category'] != '') {
             require_code('ocfiltering');
             $query .= ' AND (' . ocfilter_to_sqlfragment($map['filter_category'], 'id', 'catalogue_categories', 'cc_parent_id', 'cc_id', 'id') . ')';
         }
         if ($map['filter_hours'] != '') {
             $query .= ' AND ce_add_date>' . strval(time() - 60 * 60 * intval($map['filter_hours']));
         }
         if ($map['filter_rating'] != '') {
             $query .= ' AND (SELECT AVG(rating) FROM rating WHERE ' . db_string_equal_to('rating_for_type', 'catalogue_entry') . ' AND rating_for_id=id)>' . strval(intval($map['filter_rating']));
         }
         // Info about our catalogue
         $catalogue_rows = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
         if (!array_key_exists(0, $catalogue_rows)) {
             return paragraph('Could not find the catalogue named "' . escape_html($catalogue_name) . '".', '', 'nothing_here');
         }
         $catalogue_row = $catalogue_rows[0];
         // Get results
         $entries_to_show = array();
         if ($star_entry != '') {
             $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' AND id=' . strval(intval($star_entry))));
             $query .= ' AND id<>' . strval(intval($star_entry));
         }
         $entries_to_show = array_merge($entries_to_show, $GLOBALS['SITE_DB']->query($query . ' ORDER BY ce_add_date DESC', $max_results));
         if (count($entries_to_show) == 0 && ($min_latitude == '' || $max_latitude == '' || $min_longitude == '' || $max_longitude == '')) {
             //return paragraph(do_lang_tempcode('NO_ENTRIES'),'','nothing_here');
         }
         // Make marker data Javascript-friendly
         foreach ($entries_to_show as $i => $entry_row) {
             $entry_row['allow_rating'] = 0;
             // Performance: So rating is not loaded
             $details = get_catalogue_entry_map($entry_row, $catalogue_row, 'CATEGORY', $catalogue_name, NULL);
             $two_d_list = $details['FIELDS_2D'];
             $longitude = NULL;
             $latitude = NULL;
             $entry_title = '';
             $all_output = '';
             foreach ($two_d_list as $index => $l) {
                 if ($l['NAME'] == $longitude_key) {
                     $longitude = $l['VALUE'];
                 }
                 if ($l['NAME'] == $latitude_key) {
                     $latitude = $l['VALUE'];
                 }
                 if ($index == 0) {
                     $entry_title = $l['VALUE'];
                 }
                 $all_output .= (is_object($l['VALUE']) ? $l['VALUE']->evaluate() : $l['VALUE']) . ' ';
             }
             if (is_object($longitude)) {
                 $longitude = $longitude->evaluate();
             }
             if (is_object($latitude)) {
                 $latitude = $latitude->evaluate();
             }
             if (is_object($entry_title)) {
                 $entry_title = $entry_title->evaluate();
             }
             if (is_numeric($longitude) && is_numeric($latitude)) {
                 if ($map['filter_term'] == '' || strpos(strtolower($all_output), strtolower($map['filter_term'])) !== false) {
                     $details['LONGITUDE'] = float_to_raw_string(floatval($longitude));
                     $details['LATITUDE'] = float_to_raw_string(floatval($latitude));
                     $details['ENTRY_TITLE'] = $entry_title;
                     $entry_content = do_template('CATALOGUE_googlemap_ENTRY_EMBED', $details, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_EMBED');
                     //put_in_standard_box(hyperlink($url,do_lang_tempcode('VIEW')),do_lang_tempcode('CATALOGUE_ENTRY').' ('.do_lang_tempcode('IN',get_translated_text($catalogue['c_title'])).')');
                     $details['ENTRY_CONTENT'] = $entry_content;
                     $details['STAR'] = '0';
                     if ($star_entry != '') {
                         if ($entry_row['id'] == intval($star_entry)) {
                             $details['STAR'] = '1';
                         }
                     }
                     $details['CC_ID'] = strval($entry_row['cc_id']);
                     $details['ICON'] = '';
                     $data[] = $details;
                 }
             }
         }
     }
     $hooks_to_use = explode('|', array_key_exists('extra_sources', $map) ? $map['extra_sources'] : '');
     $hooks = find_all_hooks('blocks', 'main_google_map');
     foreach (array_keys($hooks) as $hook) {
         if (in_array($hook, $hooks_to_use)) {
             require_code('hooks/blocks/main_google_map/' . $hook);
             $ob = object_factory('Hook_Map_' . $hook);
             $data = array_merge($data, $ob->get_data($map, $max_results, $min_latitude, $max_latitude, $min_longitude, $max_longitude, $latitude_key, $longitude_key, $catalogue_row, $catalogue_name));
         }
     }
     $uniqid = uniqid('', true);
     $div_id = 'div_' . $catalogue_name . '_' . $uniqid;
     return do_template('BLOCK_MAIN_GOOGLE_MAP', array('TITLE' => $map['title'], 'ICON' => $icon, 'MIN_LATITUDE' => $min_latitude, 'MAX_LATITUDE' => $max_latitude, 'MIN_LONGITUDE' => $min_longitude, 'MAX_LONGITUDE' => $max_longitude, 'DATA' => $data, 'SHOW_LINKS' => $set_show_links, 'DIV_ID' => $div_id, 'CLUSTER' => $cluster, 'REGION' => $map['region'], 'WIDTH' => $mapwidth, 'HEIGHT' => $mapheight, 'LATITUDE' => $map['latitude'], 'LONGITUDE' => $map['longitude'], 'ZOOM' => $set_zoom, 'CENTER' => $set_center));
 }