예제 #1
0
 /**
  * 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));
 }
예제 #2
0
 /**
  * Get details for an ajax-tree-list of entries for the content covered by this search hook.
  *
  * @return array			A pair: the hook, and the options
  */
 function ajax_tree()
 {
     $catalogue_name = get_param('catalogue_name', '');
     if ($catalogue_name == '') {
         @ob_end_clean();
         $tree = nice_get_catalogues(NULL, true);
         if ($tree->is_empty()) {
             inform_exit(do_lang_tempcode('NO_ENTRIES'));
         }
         require_code('form_templates');
         $fields = form_input_list(do_lang_tempcode('NAME'), '', 'catalogue_name', $tree, NULL, true);
         if (running_script('iframe')) {
             $post_url = get_self_url_easy();
         } else {
             $post_url = get_self_url(false, false, NULL, false, true);
         }
         $submit_name = do_lang_tempcode('PROCEED');
         $hidden = build_keep_post_fields();
         $title = get_page_title('SEARCH');
         $tpl = do_template('FORM_SCREEN', array('_GUID' => 'a2812ac8056903811f444682d45ee448', 'TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
         $echo = globalise($tpl, NULL, '', true);
         $echo->evaluate_echo();
         exit;
     }
     return array('choose_catalogue_category', array('catalogue_name' => $catalogue_name));
 }
예제 #3
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     $forum = get_forum_type();
     $out = new ocp_tempcode();
     if ($forum != 'none') {
         // Standard welcome back vs into greeting
         $member = get_member();
         if (is_guest($member)) {
             $redirect = get_self_url(true, true);
             $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login'));
             $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
             $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url));
             $p = do_lang_tempcode('WELCOME', $join_bits);
             $out->attach(paragraph($p, 'hhrt4dsgdsgd'));
         } else {
             $out->attach(paragraph(do_lang_tempcode('WELCOME_BACK', escape_html($GLOBALS['FORUM_DRIVER']->get_username($member))), 'gfgdf9gjd'));
         }
     }
     $message = get_option('welcome_message');
     if (has_actual_page_access(get_member(), 'admin_config')) {
         if ($message != '') {
             $message .= ' [[page="_SEARCH:admin_config:category:SITE#group_GENERAL"]' . do_lang('EDIT') . '[/page]]';
         }
     }
     $out->attach(comcode_to_tempcode($message, NULL, true));
     return $out;
 }
예제 #4
0
파일: chat.php 프로젝트: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @param  MEMBER		The ID of the member we are getting link hooks for
  * @return array		List of tuples for results. Each tuple is: type,title,url
  */
 function run($member_id)
 {
     if (!addon_installed('chat')) {
         return array();
     }
     $modules = array();
     if (has_actual_page_access(get_member(), 'chat', get_page_zone('chat'))) {
         if (!is_guest() && $member_id != get_member()) {
             require_lang('chat');
             require_code('chat');
             if (!$GLOBALS['FORUM_DRIVER']->is_staff($member_id)) {
                 if (!member_blocked($member_id)) {
                     $modules[] = array('contact', do_lang_tempcode('EXPLAINED_BLOCK_MEMBER'), build_url(array('page' => 'chat', 'type' => 'blocking_add', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
                     if (has_specific_permission(get_member(), 'start_im')) {
                         $modules[] = array('contact', do_lang_tempcode('START_IM'), build_url(array('page' => 'chat', 'type' => 'misc', 'enter_im' => $member_id), get_module_zone('chat')));
                     }
                 } else {
                     $modules[] = array('contact', do_lang_tempcode('EXPLAINED_UNBLOCK_MEMBER'), build_url(array('page' => 'chat', 'type' => 'blocking_remove', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
                 }
             }
             if (!member_befriended($member_id)) {
                 $modules[] = array('contact', do_lang_tempcode('MAKE_BUDDY'), build_url(array('page' => 'chat', 'type' => 'buddy_add', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
             } else {
                 $modules[] = array('contact', do_lang_tempcode('DUMP_BUDDY'), build_url(array('page' => 'chat', 'type' => 'buddy_remove', 'member_id' => $member_id, 'redirect' => get_self_url(true)), get_module_zone('chat')));
             }
         }
     }
     return $modules;
 }
예제 #5
0
 /**
  * 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('MODULE_TRANS_NAME_warnings');
     $order = 80;
     if ($leave_to_ajax_if_possible) {
         return array($title, NULL, $order);
     }
     require_lang('ocf');
     require_css('ocf');
     $warnings = new ocp_tempcode();
     $rows = $GLOBALS['FORUM_DB']->query_select('f_warnings', array('*'), array('w_member_id' => $member_id_of, 'w_is_warning' => 1));
     foreach ($rows as $row) {
         $warning_by = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['w_by']);
         $date = get_timezoned_date($row['w_time']);
         if ($row['w_explanation'] == '') {
             $row['w_explanation'] = '?';
         } else {
             $row['w_explanation'] = str_replace(chr(10), ' ', $row['w_explanation']);
         }
         $row['w_explanation_orig'] = $row['w_explanation'];
         if (strlen($row['w_explanation']) > 30) {
             $row['w_explanation'] = substr($row['w_explanation'], 0, 27) . '...';
         }
         $explanation = hyperlink(build_url(array('page' => 'warnings', 'type' => '_ed', 'id' => $row['id'], 'redirect' => get_self_url(true)), get_module_zone('warnings')), $row['w_explanation'], false, true, $row['w_explanation_orig']);
         $warnings->attach(paragraph(do_lang_tempcode('MEMBER_WARNING', $explanation, $warning_by, array(make_string_tempcode(escape_html($date)))), 'treyerhy34y'));
     }
     $content = do_template('OCF_MEMBER_PROFILE_WARNINGS', array('MEMBER_ID' => strval($member_id_of), 'WARNINGS' => $warnings));
     return array($title, $content, $order);
 }
예제 #6
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     //if (count($_POST)!=0) return new ocp_tempcode();		Can't do that, breaks previewing it
     require_lang('recommend');
     $_map = array('page' => 'recommend', 'from' => get_self_url(true));
     if (array_key_exists('title', $map)) {
         $_map['title'] = $map['title'];
     }
     $recommend_url = build_url($_map, '_SEARCH');
     return do_template('BLOCK_MAIN_SCREEN_ACTIONS', array('PRINT_URL' => get_self_url(true, false, array('wide_print' => 1, 'max' => 1000)), 'RECOMMEND_URL' => $recommend_url, 'EASY_SELF_URL' => str_replace("'", '', urlencode(get_self_url(true))), 'TITLE' => array_key_exists('title', $map) ? $map['title'] : ''));
 }
예제 #7
0
/**
 * Get extra do-next icon for managing custom fields for a content type.
 *
 * @param  ID_TEXT		Award hook codename
 * @return array			Extra do-next icon (single item array, or empty array if catalogues not installed)
 */
function manage_custom_fields_donext_link($content_type)
{
    if (addon_installed('catalogues')) {
        require_lang('fields');
        require_code('hooks/systems/awards/' . $content_type);
        $ob = object_factory('Hook_awards_' . $content_type);
        $info = $ob->info();
        if (array_key_exists('supports_custom_fields', $info) && $info['supports_custom_fields'] && has_specific_permission(get_member(), 'submit_cat_highrange_content', 'cms_catalogues') && has_specific_permission(get_member(), 'edit_cat_highrange_content', 'cms_catalogues')) {
            $exists = !is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => '_' . $content_type)));
            return array(array('edit_one_catalogue', array('cms_catalogues', array('type' => $exists ? '_edit_catalogue' : 'add_catalogue', 'id' => '_' . $content_type, 'redirect' => get_self_url(true)), get_module_zone('cms_catalogues')), do_lang('EDIT_CUSTOM_FIELDS', $info['title'])));
        }
    }
    return array();
}
예제 #8
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('messaging');
     require_code('feedback');
     $to = array_key_exists('param', $map) ? $map['param'] : get_option('staff_address');
     $post = post_param('post', '');
     if (post_param_integer('_comment_form_post', 0) == 1 && $post != '') {
         if (addon_installed('captcha')) {
             if (get_option('captcha_on_feedback') == '1') {
                 require_code('captcha');
                 enforce_captcha();
             }
         }
         $message = new ocp_tempcode();
         /*Used to be written out here*/
         attach_message(do_lang_tempcode('MESSAGE_SENT'), 'inform');
         require_code('mail');
         $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
         mail_wrap(post_param('title'), $post, array($to), NULL, $email_from, $GLOBALS['FORUM_DRIVER']->get_username(get_member()), 3, NULL, false, get_member());
         if ($email_from != '') {
             mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', post_param('title')), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
         }
     } else {
         $message = new ocp_tempcode();
     }
     $box_title = array_key_exists('title', $map) ? $map['title'] : do_lang('CONTACT_US');
     $private = array_key_exists('private', $map) && $map['private'] == '1';
     $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     require_javascript('javascript_editing');
     $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
     require_javascript('javascript_validation');
     $comment_url = get_self_url();
     $email_optional = array_key_exists('email_optional', $map) ? intval($map['email_optional']) == 1 : true;
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = get_option('captcha_on_feedback') == '1' && use_captcha();
         if ($use_captcha) {
             generate_captcha();
         }
     } else {
         $use_captcha = false;
     }
     $comment_details = do_template('COMMENTS_POSTING_FORM', array('JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'EMAIL_OPTIONAL' => $email_optional, 'POST_WARNING' => '', 'COMMENT_TEXT' => '', 'GET_EMAIL' => !$private, 'GET_TITLE' => !$private, 'EM' => $em, 'DISPLAY' => 'block', 'TITLE' => $box_title, 'COMMENT_URL' => $comment_url));
     $out = do_template('BLOCK_MAIN_CONTACT_SIMPLE', array('_GUID' => '298a357f442f440c6b42e58d6717e57c', 'EMAIL_OPTIONAL' => true, 'COMMENT_DETAILS' => $comment_details, 'MESSAGE' => $message));
     return $out;
 }
예제 #9
0
/**
 * Build a bookmarks menu for the current member.
 *
 * @return array			Faked database rows
 */
function build_bookmarks_menu()
{
    require_lang('bookmarks');
    $items = array();
    $rows = $GLOBALS['SITE_DB']->query_select('bookmarks', array('*'), array('b_owner' => get_member()), 'ORDER BY b_folder');
    // For managing existing bookmarks
    if (count($rows) != 0) {
        $rand_id = mt_rand(0, 1000000);
        $_url = build_url(array('page' => 'bookmarks', 'type' => 'misc'), get_module_zone('bookmarks'));
        $items[] = array('id' => $rand_id, 'i_parent' => NULL, 'cap' => do_lang('MANAGE_BOOKMARKS'), 'i_url' => $_url, 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 1, 'i_page_only' => '');
    }
    // For adding a new bookmark
    $self_url = get_param('url', '');
    if ($self_url == '') {
        $self_url = get_self_url(true);
    }
    $rand_id = mt_rand(0, 1000000);
    //$url=build_url(array('page'=>'bookmarks','type'=>'ad','url'=>$self_url,'title'=>get_param('title','',true)),get_module_zone('bookmarks'));
    $keep = symbol_tempcode('KEEP');
    $url = find_script('bookmarks') . '?no_redirect=1&type=ad&url=' . urlencode(base64_encode($self_url)) . '&title=' . urlencode(get_param('title', '', true)) . $keep->evaluate();
    $items[] = array('id' => $rand_id, 'i_parent' => NULL, 'cap' => do_lang('ADD_BOOKMARK'), 'i_popup' => 1, 'i_width' => 600, 'i_height' => 500, 'i_url' => $url, 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 1, 'i_page_only' => '');
    // Existing bookmarks
    if (count($rows) != 0) {
        // Spacer
        $items[] = array('id' => $rand_id, 'i_parent' => NULL, 'cap' => '', 'i_url' => '', 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 1, 'i_page_only' => '');
        // Make our folders first
        $parents = array('' => NULL);
        foreach ($rows as $row) {
            if (!array_key_exists($row['b_folder'], $parents)) {
                $rand_id = mt_rand(0, 1000000);
                $parents[$row['b_folder']] = $rand_id;
                $items[] = array('id' => $rand_id, 'i_parent' => NULL, 'cap' => $row['b_folder'], 'i_url' => '', 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 0, 'i_page_only' => '');
            }
        }
        foreach ($rows as $row) {
            $parent = $parents[$row['b_folder']];
            list($zone, $attributes, $hash) = page_link_decode($row['b_page_link']);
            $_url = build_url($attributes, $zone, NULL, false, false, false, $hash);
            $items[] = array('id' => $row['id'], 'i_parent' => $parent, 'cap' => $row['b_title'], 'i_url' => $_url, 'i_check_permissions' => 0, 'i_expanded' => 0, 'i_new_window' => 0, 'i_page_only' => '');
        }
    }
    return $items;
}
예제 #10
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_code('templates_donext');
     require_code('menus');
     require_all_lang();
     $type = get_param('type', 'misc');
     if ((!has_specific_permission(get_member(), 'avoid_simplified_adminzone_look') || $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) && num_staff_icons() < MIN_STAFF_ICONS_BEFORE_COLLAPSE) {
         if ($type == 'misc') {
             return do_next_manager_admin_simplified();
         }
     }
     // Warning about whether the Setup Wizard still needs running
     if (get_param_integer('cancel_sw_warn', 0) == 1 || !addon_installed('setupwizard')) {
         set_value('setup_wizard_completed', '1');
     } else {
         $_done_sw_once = get_value('setup_wizard_completed');
         $done_sw_once = !is_null($_done_sw_once);
         if (!$done_sw_once && get_param('page', '') != 'admin_setupwizard' && has_actual_page_access(get_member(), 'admin_setupwizard')) {
             $setup_wizard_url = build_url(array('page' => 'admin_setupwizard'), get_module_zone('admin_setupwizard'));
             $cancel_sw_url = get_self_url(false, false, array('cancel_sw_warn' => 1));
             attach_message(do_lang_tempcode('SETUP_WIZARD_NOT_RUN', escape_html($setup_wizard_url->evaluate()), escape_html($cancel_sw_url->evaluate())), 'notice');
         }
     }
     switch ($type) {
         case 'misc':
             return do_next_manager_hooked('ADMIN_ZONE', 'DOC_ADMIN_ZONE', '');
         case 'structure':
             return do_next_manager_hooked('STRUCTURE', 'DOC_STRUCTURE', 'structure');
         case 'usage':
             return do_next_manager_hooked('USAGE', 'DOC_USAGE', 'usage');
         case 'style':
             return do_next_manager_hooked('STYLE', 'DOC_STYLE', 'style');
         case 'setup':
             return do_next_manager_hooked('SETUP', 'DOC_SETUP', 'setup');
         case 'tools':
             return do_next_manager_hooked('TOOLS', 'DOC_TOOLS', 'tools');
         case 'security':
             return do_next_manager_hooked('SECURITY', 'DOC_SECURITY', 'security');
         case 'search':
             return $this->search();
     }
     return new ocp_tempcode();
 }
예제 #11
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $base_url = get_forum_base_url();
     $forums = get_param('url', $base_url . '/');
     if (substr($forums, 0, strlen($base_url)) != $base_url) {
         $base_url = rtrim($forums, '/');
         if (strpos($base_url, '.php') !== false || strpos($base_url, '?') !== false) {
             $base_url = dirname($base_url);
         }
         //log_hack_attack_and_exit('REFERRER_IFRAME_HACK'); No longer a hack attack becase people webmasters changed their forum base URL at some point, creating problems with old bookmarks!
         header('Location: ' . get_self_url(true, false, array('url' => get_forum_base_url())));
         exit;
     }
     $old_method = false;
     if ($old_method) {
         return do_template('FORUMS_EMBED', array('_GUID' => '159575f6b83c5366d29e184a8dd5fc49', 'FORUMS' => $forums));
     }
     $GLOBALS['SCREEN_TEMPLATE_CALLED'] = '';
     require_code('integrator');
     return do_template('COMCODE_SURROUND', array('CLASS' => 'float_surrounder', 'CONTENT' => protect_from_escaping(reprocess_url($forums, $base_url))));
 }
예제 #12
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('newsletter');
     require_lang('javascript');
     $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id));
     if (is_null($_newsletter_title)) {
         return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $newsletter_title = get_translated_text($_newsletter_title);
     $address = post_param('address' . strval($newsletter_id), '');
     if ($address != '') {
         require_code('newsletter');
         require_code('type_validation');
         if (!is_valid_email_address($address)) {
             $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS')));
             return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg));
         }
         if (!array_key_exists('path', $map)) {
             $map['path'] = 'uploads/website_specific/signup.txt';
         }
         require_code('character_sets');
         $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), ''));
         if ($password == '') {
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO')));
         }
         if ($password == do_lang('NA')) {
             $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter'));
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate()))));
         }
         require_code('mail');
         if (file_exists(get_custom_file_base() . '/' . $map['path'])) {
             $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path'];
             mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true);
         }
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password));
     } else {
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url()));
     }
 }
예제 #13
0
/**
 * Log permission checks to the permission_checks.log file, if it exists.
 *
 * @param  MEMBER         The user checking against
 * @param  ID_TEXT        The function that was called to check a permission
 * @param  array          Parameters to this permission-checking function
 * @param  boolean        Whether the permission was held
 */
function handle_permission_check_logging($member, $op, $params, $result)
{
    global $PERMISSION_CHECK_LOGGER, $PERMISSIONS_ALREADY_LOGGED, $SITE_INFO;
    if ($PERMISSION_CHECK_LOGGER === NULL) {
        $file_path = get_custom_file_base() . '/data_custom/permissioncheckslog.php';
        if ((!isset($SITE_INFO['no_extra_logs']) || $SITE_INFO['no_extra_logs'] == '0') && is_file($file_path) && is_writable_wrap($file_path)) {
            $PERMISSION_CHECK_LOGGER = fopen($file_path, 'at');
            if (!function_exists('get_self_url')) {
                require_code('tempcode');
                require_code('urls');
            }
            $self_url = get_self_url(true);
            if (!is_string($self_url)) {
                $self_url = get_self_url_easy();
            }
            // A weirdness can happen here. If some kind of fatal error happens then output buffers can malfunction making it impossible to use Tempcode as above. So we fall back to this. (This function may be called in a fatal error due to the 'display_php_errors' permissions).
            fwrite($PERMISSION_CHECK_LOGGER, chr(10) . chr(10) . date('Y/m/d h:m:i') . ' -- ' . $self_url . ' -- ' . $GLOBALS['FORUM_DRIVER']->get_username(get_member()) . chr(10));
        } else {
            $PERMISSION_CHECK_LOGGER = false;
        }
    }
    static $fbe = NULL;
    if ($fbe === NULL) {
        $fbe = function_exists('fb');
    }
    if ($PERMISSION_CHECK_LOGGER === false && (!$fbe || get_param_integer('keep_firephp', 0) == 0)) {
        return;
    }
    $sz = serialize(array($member, $op, $params));
    if (array_key_exists($sz, $PERMISSIONS_ALREADY_LOGGED)) {
        return;
    }
    $PERMISSIONS_ALREADY_LOGGED[$sz] = 1;
    if ($result) {
        return;
    }
    require_code('permissions2');
    _handle_permission_check_logging($member, $op, $params, $result);
}
예제 #14
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     $file = array_key_exists('param', $map) ? $map['param'] : 'admin_notes';
     $title = array_key_exists('title', $map) ? $map['title'] : do_lang('NOTES');
     $scrolls = array_key_exists('scrolls', $map) ? $map['scrolls'] : '0';
     $new = post_param('new', NULL);
     if (!is_null($new)) {
         set_long_value('note_text_' . $file, $new);
         log_it('NOTES', $file);
         attach_message(do_lang_tempcode('SUCCESS'), 'inform');
     }
     $contents = get_long_value('note_text_' . $file);
     if (is_null($contents)) {
         $contents = '';
     }
     $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' => '2a9e1c512b66600583735552b56e0911', 'TITLE' => $title, 'BLOCK_NAME' => 'main_db_notes', 'MAP' => $map_comcode, 'SCROLLS' => array_key_exists('scrolls', $map) && $map['scrolls'] == '1', 'CONTENTS' => $contents, 'URL' => $post_url));
 }
예제 #15
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     if (!array_key_exists('param', $map)) {
         $map['param'] = 'main';
     }
     if (!array_key_exists('page', $map)) {
         $map['page'] = get_page_name();
     }
     if (array_key_exists('extra_param_from', $map)) {
         $extra = '_' . $map['extra_param_from'];
     } else {
         $extra = '';
     }
     require_code('feedback');
     $self_url = get_self_url();
     $self_title = $map['page'];
     $id = $map['page'] . '_' . $map['param'] . $extra;
     $test_changed = post_param('rating_' . $id, '');
     if ($test_changed != '') {
         decache('main_rating');
     }
     actualise_rating(true, 'block_main_rating', $id, $self_url, $self_title);
     return get_rating_box($self_url, $self_title, 'block_main_rating', $id, true);
 }
예제 #16
0
 /**
  * UI to show details of an order
  *
  * @return tempcode	The interface.
  */
 function order_details()
 {
     $id = get_param_integer('id');
     $title = get_page_title('MY_ORDER_DETAILS');
     $order_title = do_lang('CART_ORDER', $id);
     //pagination
     $start = get_param_integer('start', 0);
     $max = get_param_integer('max', 10);
     require_code('templates_results_browser');
     require_code('templates_results_table');
     $sortables = array();
     $query_sort = explode(' ', get_param('sort', 'p_name ASC'), 2);
     if (count($query_sort) == 1) {
         $query_sort[] = 'ASC';
     }
     list($sortable, $sort_order) = $query_sort;
     $fields_title = results_field_title(array(do_lang_tempcode('SLNO'), do_lang_tempcode('PRODUCT_NAME'), do_lang_tempcode('THE_PRICE'), do_lang_tempcode('QUANTITY'), do_lang_tempcode('STATUS')), $sortables, 'sort', $sortable . ' ' . $sort_order);
     $max_rows = $GLOBALS['SITE_DB']->query_value_null_ok('shopping_order_details', 'COUNT(*)', array('order_id' => $id));
     $results_browser = results_browser(do_lang_tempcode('ORDERS'), NULL, $start, 'start', $max, 'max', $max_rows, NULL, 'show_orders', true, true);
     $rows = $GLOBALS['SITE_DB']->query_select('shopping_order_details', array('*'), array('order_id' => $id), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
     $product_entries = new ocp_tempcode();
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('ORDERS')), array('_SELF:_SELF:show_orders', do_lang_tempcode('ORDER_LIST'))));
     foreach ($rows as $row) {
         $product_info_url = build_url(array('page' => 'catalogues', 'type' => 'entry', 'id' => $row['p_id']), get_module_zone('catalogues'));
         $product_name = $row['p_name'];
         $product = hyperlink($product_info_url, $product_name, false, true, do_lang('VIEW'));
         $product_entries->attach(results_entry(array(escape_html(strval($row['p_id'])), $product, ecommerce_get_currency_symbol() . escape_html(float_format($row['p_price'], 2)), escape_html(strval($row['p_quantity'])), do_lang($row['dispatch_status'])), false, NULL));
     }
     $text = do_lang_tempcode('ORDER_DETAILS_TEXT');
     //Collecting order details
     $rows = $GLOBALS['SITE_DB']->query_select('shopping_order', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $data = $rows[0];
     $results_table = results_table(do_lang_tempcode('PRODUCTS'), 0, 'start', $max_rows, 'max', $max_rows, $fields_title, $product_entries, $sortables, $sortable, $sort_order, 'sort', NULL, NULL, 'cart');
     $ordered_by_member_id = $data['c_member'];
     $ordered_by_username = $GLOBALS['FORUM_DRIVER']->get_username($data['c_member']);
     $self_url = get_self_url(true, true);
     $ordr_act_submit = build_url(array('page' => '_SELF', 'type' => 'order_act', 'id' => $id, 'redirect' => $self_url), '_SELF');
     $order_actions = do_template('ADMIN_ORDER_ACTIONS', array('ORDER_TITLE' => $order_title, 'ORDR_ACT_URL' => $ordr_act_submit, 'ORDER_STATUS' => do_lang($data['order_status'])));
     //Shipping address display
     $row = $GLOBALS['SITE_DB']->query_select('shopping_order_addresses', array('*'), array('order_id' => $id), '', 1);
     if (array_key_exists(0, $row)) {
         $address = $row[0];
         $shipping_address = do_template('SHIPPING_ADDRESS', array('ADDRESS_NAME' => $address['address_name'], 'ADDRESS_STREET' => $address['address_street'], 'ADDRESS_CITY' => $address['address_city'], 'ADDRESS_ZIP' => $address['address_zip'], 'ADDRESS_COUNTRY' => $address['address_country'], 'RECEIVER_EMAIL' => $address['receiver_email']));
     } else {
         $shipping_address = new ocp_tempcode();
     }
     return do_template('ECOM_ADMIN_ORDERS_DETAILS_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'CURRENCY' => get_option('currency'), 'RESULT_TABLE' => $results_table, 'RESULTS_BROWSER' => $results_browser, 'ORDER_NUMBER' => strval($id), 'ADD_DATE' => get_timezoned_date($data['add_date'], true, false, true, true), 'TOTAL_PRICE' => float_format($data['tot_price'], 2), 'ORDERED_BY_MEMBER_ID' => strval($ordered_by_member_id), 'ORDERED_BY_USERNAME' => $ordered_by_username, 'ORDER_STATUS' => do_lang($data['order_status']), 'NOTES' => $data['notes'], 'PURCHASED_VIA' => $data['purchase_through'], 'ORDER_ACTIONS' => $order_actions, 'SHIPPING_ADDRESS' => $shipping_address));
 }
예제 #17
0
 /**
  * Actualiser to delete an invoice.
  *
  * @return tempcode	The result.
  */
 function delete()
 {
     $title = get_page_title('DELETE_INVOICE');
     breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES')), array('_SELF:_SELF:undelivered', do_lang_tempcode('UNDELIVERED_INVOICES'))));
     if (post_param_integer('confirmed', 0) != 1) {
         $url = get_self_url();
         $text = do_lang_tempcode('DELETE_INVOICE');
         breadcrumb_set_self(do_lang_tempcode('CONFIRM'));
         $hidden = build_keep_post_fields();
         $hidden->attach(form_input_hidden('confirmed', '1'));
         $hidden->attach(form_input_hidden('from', get_param('from', 'misc')));
         return do_template('CONFIRM_SCREEN', array('_GUID' => '45707062c00588c33726b256e8f9ba40', 'TITLE' => $title, 'FIELDS' => $hidden, 'PREVIEW' => $text, 'URL' => $url));
     }
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     $GLOBALS['SITE_DB']->query_delete('invoices', array('id' => get_param_integer('id')), '', 1);
     $url = build_url(array('page' => '_SELF', 'type' => post_param('from', 'misc')), '_SELF');
     return redirect_screen($title, $url, do_lang_tempcode('SUCCESS'));
 }
예제 #18
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     if (!array_key_exists('param', $map)) {
         $map['param'] = 'main';
     }
     if (!array_key_exists('page', $map)) {
         $map['page'] = str_replace('-', '_', get_page_name());
     }
     if (array_key_exists('extra_param_from', $map)) {
         $extra = '_' . $map['extra_param_from'];
     } else {
         $extra = '';
     }
     require_code('feedback');
     $submitted = post_param_integer('_comment_form_post', 0) == 1;
     $self_url = build_url(array('page' => '_SELF'), '_SELF', NULL, true, false, true);
     $self_title = $map['page'];
     $test_changed = post_param('title', NULL);
     if (!is_null($test_changed)) {
         decache('main_comments');
     }
     $hidden = $submitted ? actualise_post_comment(true, 'block_main_comments', $map['page'] . '_' . $map['param'] . $extra, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, false, NULL, get_page_name() == 'guestbook') : false;
     $out = new ocp_tempcode();
     if (array_key_exists('title', $_POST) && $hidden && $submitted) {
         $out->attach(paragraph(do_lang_tempcode('MESSAGE_POSTED'), 'dsgdgdfl;gkd09'));
         if (get_forum_type() == 'ocf') {
             if (addon_installed('unvalidated')) {
                 require_code('submit');
                 $validate_url = get_self_url(true, false, array('keep_session' => NULL));
                 $_validate_url = build_url(array('page' => 'topics', 'type' => 'validate_post', 'id' => $GLOBALS['LAST_POST_ID'], 'redirect' => $validate_url), get_module_zone('topics'), NULL, false, false, true);
                 $validate_url = $_validate_url->evaluate();
                 send_validation_request('MAKE_POST', 'f_posts', false, $GLOBALS['LAST_POST_ID'], $validate_url);
             }
         }
     }
     $invisible_if_no_comments = array_key_exists('invisible_if_no_comments', $map) && $map['invisible_if_no_comments'] == '1';
     $reverse = array_key_exists('reverse', $map) && $map['reverse'] == '1';
     $allow_reviews = !array_key_exists('reviews', $map) || $map['reviews'] == '1';
     $out->attach(get_comments('block_main_comments', true, $map['page'] . '_' . $map['param'] . $extra, $invisible_if_no_comments, array_key_exists('forum', $map) ? $map['forum'] : NULL, NULL, NULL, get_page_name() == 'guestbook', $reverse, NULL, $allow_reviews));
     return $out;
 }
예제 #19
0
 /**
  * A bug report for a test.
  *
  * @return tempcode	The result of execution.
  */
 function report()
 {
     $id = get_param_integer('id');
     $test_row = $GLOBALS['SITE_DB']->query_select('tests t LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'test_sections s ON t.t_section=s.id', array('*'), array('t.id' => $id), '', 1);
     if (!array_key_exists(0, $test_row)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $section = $test_row[0]['s_section'];
     $test = $test_row[0]['t_test'];
     $self_title = $section . '/' . substr($test, 0, 20);
     $title = get_page_title('BUG_REPORT_FOR', true, array(escape_html($self_title)));
     require_code('feedback');
     $self_url = get_self_url();
     $forum = get_option('tester_forum_name');
     actualise_post_comment(true, 'bug_report', strval($id), $self_url, $self_title, $forum);
     $comment_text = str_replace('{1}', $test, get_option('bug_report_text'));
     $comments = get_comments('bug_report', true, strval($id), false, $forum, $comment_text);
     return do_template('TESTER_REPORT', array('_GUID' => '0c223a0a29a2c5289d71fbb69b0fe40d', 'TITLE' => $title, 'TEST' => $test, 'COMMENTS' => $comments));
 }
예제 #20
0
/**
 * Show a post, isolated of the other posts in it's topic.
 *
 * @param  array		The post row.
 * @param  boolean	Whether to use the post title, as opposed to the post's topic's title.
 * @return tempcode  The isolated post.
 */
function ocf_show_isolated_post($row, $use_post_title = false)
{
    require_code('ocf_groups');
    require_css('ocf');
    // Poster title
    $primary_group = $GLOBALS['FORUM_DRIVER']->get_member_row_field($row['p_poster'], 'm_primary_group');
    if (!is_null($primary_group)) {
        if (addon_installed('ocf_member_titles')) {
            $poster_title = $GLOBALS['OCF_DRIVER']->get_member_row_field($row['p_poster'], 'm_title');
            if ($poster_title == '') {
                $poster_title = get_translated_text(ocf_get_group_property($primary_group, 'title'), $GLOBALS['FORUM_DB']);
            }
        } else {
            $poster_title = '';
        }
        $avatar = $GLOBALS['FORUM_DRIVER']->get_member_avatar_url($row['p_poster']);
        $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($row['p_poster'], true);
    } else {
        $poster_title = '';
        $avatar = '';
        $posters_groups = array();
    }
    // Avatar
    if (is_guest($row['p_poster'])) {
        if ($row['p_poster_name_if_guest'] == do_lang('SYSTEM')) {
            $avatar = find_theme_image('ocf_default_avatars/default_set/ocp_fanatic', true);
        }
    }
    if ($avatar != '') {
        $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('AVATAR' => $avatar));
    } else {
        $post_avatar = new ocp_tempcode();
    }
    // Rank images
    $rank_images = new ocp_tempcode();
    foreach ($posters_groups as $group) {
        $rank_image = ocf_get_group_property($group, 'rank_image');
        $group_leader = ocf_get_group_property($group, 'group_leader');
        $group_name = ocf_get_group_name($group);
        $rank_image_pri_only = ocf_get_group_property($group, 'rank_image_pri_only');
        if ($rank_image != '' && ($rank_image_pri_only == 0 || $group == $primary_group)) {
            $rank_images->attach(do_template('OCF_RANK_IMAGE', array('GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $row['p_poster'])));
        }
    }
    // Poster details
    if (!is_guest($row['p_poster']) && !is_null($primary_group)) {
        require_code('ocf_members2');
        $poster_details = ocf_show_member_box($row['p_poster'], false, NULL, NULL, false);
    } else {
        $custom_fields = new ocp_tempcode();
        $poster_details = new ocp_tempcode();
    }
    if (!is_guest($row['p_poster']) && !is_null($primary_group)) {
        $poster = do_template('OCF_POSTER_MEMBER', array('ONLINE' => member_is_online($row['p_poster']), 'ID' => strval($row['p_poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_poster'], false, true), 'POSTER_USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($row['p_poster']), 'HIGHLIGHT_NAME' => NULL));
    } else {
        $poster = do_template('OCF_POSTER_GUEST', array('IP_LINK' => '', 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $row['p_poster_name_if_guest'] != '' ? $row['p_poster_name_if_guest'] : do_lang('GUEST')));
    }
    // Last edited
    if (!is_null($row['p_last_edit_time'])) {
        $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('LAST_EDIT_DATE_RAW' => is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']), 'LAST_EDIT_DATE' => get_timezoned_date($row['p_last_edit_time']), 'LAST_EDIT_PROFILE_URL' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->member_profile_url($row['p_last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => is_null($row['p_last_edit_by']) ? '' : $GLOBALS['FORUM_DRIVER']->get_username($row['p_last_edit_by'])));
    } else {
        $last_edited = new ocp_tempcode();
    }
    $last_edited_raw = is_null($row['p_last_edit_time']) ? '' : strval($row['p_last_edit_time']);
    // Misc stuff
    $poster_id = $row['p_poster'];
    $tree = ocf_forum_breadcrumbs($row['p_cache_forum_id']);
    $post_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $row['id']), get_module_zone('topicview'));
    $post_url->attach('#post_' . strval($row['id']));
    if (get_page_name() != 'search' && array_key_exists('text_parsed', $row) && !is_null($row['text_parsed']) && $row['text_parsed'] != '' && $row['p_post'] != 0) {
        $post = new ocp_tempcode();
        if (!$post->from_assembly($row['text_parsed'], true)) {
            $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
        }
    } else {
        $post = get_translated_tempcode($row['p_post'], $GLOBALS['FORUM_DB']);
    }
    $post_date = get_timezoned_date($row['p_time']);
    $post_date_raw = $row['p_time'];
    if ($use_post_title) {
        $post_title = $row['p_title'];
    } else {
        $post_title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $row['p_topic_id']));
        if ($row['p_title'] != $post_title) {
            $post_title .= ': ' . $row['p_title'];
        }
    }
    //if ($post_title=='') $post_title=do_lang_tempcode('ISOLATED_POST_TITLE',strval($row['id']));
    $emphasis = new ocp_tempcode();
    if ($row['p_is_emphasised'] == 1) {
        $emphasis = do_lang_tempcode('IMPORTANT');
    } elseif (!is_null($row['p_intended_solely_for'])) {
        $pp_to_username = $GLOBALS['FORUM_DRIVER']->get_username($row['p_intended_solely_for']);
        if (is_null($pp_to_username)) {
            $pp_to_username = do_lang('UNKNOWN');
        }
        $emphasis = do_lang('PP_TO', $pp_to_username);
    }
    require_code('feedback');
    actualise_rating(true, 'post', strval($row['id']), get_self_url(), $row['p_title']);
    $rating = display_rating(get_self_url(), $row['p_title'], 'post', strval($row['id']), 'RATING_INLINE_DYNAMIC', $row['p_poster']);
    // Render
    return do_template('OCF_ISOLATED_POST', array('_GUID' => '9456f4fe4b8fb1bf34f606fcb2bcc9d7', 'URL' => $post_url, 'ID' => strval($row['id']), 'TREE' => $tree, 'POST' => do_template('OCF_TOPIC_POST', array('ID' => strval($row['id']), 'TOPIC_FIRST_POST_ID' => '', 'TOPIC_FIRST_POSTER' => '', 'POST_ID' => strval($row['id']), 'URL' => $post_url, 'CLASS' => $row['p_is_emphasised'] == 1 ? 'ocf_post_emphasis' : (!is_null($row['p_intended_solely_for']) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => '', 'POSTER_TITLE' => $poster_title, 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($post_date_raw), 'POST_DATE' => $post_date, 'POST' => $post, 'TOPIC_ID' => is_null($row['p_topic_id']) ? '' : strval($row['p_topic_id']), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($poster_id), 'POSTER' => $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => '', 'SIGNATURE' => '', 'UNVALIDATED' => '', 'DESCRIPTION' => '', 'PREVIEWING' => true, 'RATING' => $rating))));
}
예제 #21
0
 /**
  * Standard modular UI to edit an entry.
  *
  * @return tempcode	The UI
  */
 function _ed()
 {
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name;
     $submit_name = do_lang_tempcode('SAVE');
     //$test=$this->choose_catalogue($title);
     //if (!is_null($test)) return $test;
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id);
     if (get_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = get_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) {
         $map['uploading'] = 1;
     }
     $post_url = build_url($map, '_SELF');
     if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) {
         require_code('lang2');
         $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang()));
         attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn');
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
     } else {
         $submitter = NULL;
         $date_and_time = NULL;
     }
     if (!is_null($this->permissions_require)) {
         check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
     }
     if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $bits = $this->fill_in_edit_form($id);
     $delete_fields = new ocp_tempcode();
     $all_delete_fields_given = false;
     $fields2 = new ocp_tempcode();
     if (is_array($bits)) {
         $fields = $bits[0];
         $hidden = $bits[1];
         if (array_key_exists(2, $bits) && !is_null($bits[2])) {
             $delete_fields = $bits[2];
         }
         if (array_key_exists(3, $bits) && !is_null($bits[3])) {
             $this->edit_text = $bits[3];
         }
         if (array_key_exists(4, $bits) && $bits[4]) {
             $all_delete_fields_given = true;
         }
         if (array_key_exists(5, $bits) && !is_null($bits[5])) {
             $this->posting_form_text = $bits[5];
         }
         if (array_key_exists(6, $bits) && !is_null($bits[6])) {
             $fields2 = $bits[6];
         }
         if (array_key_exists(7, $bits)) {
             $this->posting_form_text_parsed = $bits[7];
         }
     } else {
         $fields = $bits;
         $hidden = new ocp_tempcode();
     }
     // Add in custom fields
     if ($this->has_tied_catalogue()) {
         require_code('fields');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE'))));
         append_form_custom_fields($this->award_type, $id, $fields, $hidden);
     }
     // SEO?
     if (!is_null($this->seo_type)) {
         require_code('seo2');
         $fields2->attach(seo_get_fields($this->seo_type, $id));
     }
     // Awards?
     if (addon_installed('awards')) {
         if (!is_null($this->award_type)) {
             require_code('awards');
             $fields2->attach(get_award_fields($this->award_type, $id));
         }
     }
     // Action fields / deletion options
     $delete_permission = true;
     if (!is_null($this->permissions_require)) {
         $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)));
     }
     $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission;
     // Deletion options
     $action_fields = new ocp_tempcode();
     if ($may_delete) {
         if (!$all_delete_fields_given) {
             $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
         }
         if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) {
             $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
             if (!is_null($points_test)) {
                 require_lang('points');
                 $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false));
             }
         }
         $action_fields->attach($delete_fields);
     }
     if (!$this->appended_actions_already && !$action_fields->is_empty()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     }
     $fields2->attach($action_fields);
     if (!is_object($this->edit_text)) {
         $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text);
     }
     if (!is_null($this->upload)) {
         if ($this->upload == 'image') {
             require_code('images');
             $max = floatval(get_max_image_size()) / floatval(1024 * 1024);
             if ($max < 3.0) {
                 require_code('files2');
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         } else {
             require_code('files2');
             $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
             if ($max < 30.0) {
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         }
     }
     if (get_param('type', '_ed') == '_edit_catalogue') {
         require_javascript('javascript_catalogues');
         // Existing fields
         $field_count = 0;
         $c_name = get_param('id', false, true);
         $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order');
         $fields_existing = new ocp_tempcode();
         foreach ($rows as $i => $myrow) {
             $name = get_translated_text($myrow['cf_name']);
             $description = get_translated_text($myrow['cf_description']);
             $prefix = 'existing_field_' . strval($myrow['id']) . '_';
             list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']);
             if (!is_ecommerce_catalogue($c_name) || $i > 9) {
                 $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
                 $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false));
             }
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate()));
             $fields_existing->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         // New field
         $fields_new = new ocp_tempcode();
         for ($i = 0; $i < 5; $i++) {
             list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count);
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate()));
             $fields_new->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         $fields->attach($fields2);
         return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     if (!is_null($this->posting_form_title)) {
         $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required);
         return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript));
     } else {
         $fields->attach($fields2);
         return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
 }
예제 #22
0
 /**
  * The UI to translate code.
  *
  * @return tempcode		The UI
  */
 function interface_code()
 {
     $lang = filter_naughty_harsh(get_param('lang', ''));
     $lang_new = get_param('lang_new', $lang);
     if ($lang_new != '') {
         require_code('type_validation');
         if (!is_alphanumeric($lang_new, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         if (strlen($lang_new) > 5) {
             warn_exit(do_lang_tempcode('INVALID_LANG_CODE'));
         }
         $lang = $lang_new;
     }
     if ($lang == '') {
         $title = get_page_title('TRANSLATE_CODE');
         $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_FIND_LANG_STRING_TIP');
         return $this->choose_lang($title, true, true, do_lang_tempcode('CHOOSE_EDIT_LIST_LANG_FILE'));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE'))));
     breadcrumb_set_self(do_lang_tempcode('TRANSLATE_CODE'));
     $base_lang = fallback_lang();
     $map_a = get_file_base() . '/lang/langs.ini';
     $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
     $search = get_param('search', '', true);
     if ($search != '') {
         $title = get_page_title('TRANSLATE_CODE');
         require_code('form_templates');
         $fields = new ocp_tempcode();
         global $LANGUAGE;
         foreach ($LANGUAGE[user_lang()] as $key => $value) {
             if (strpos(strtolower($value), strtolower($search)) !== false) {
                 $fields->attach(form_input_text($key, '', 'l_' . $key, str_replace('\\n', chr(10), $value), false));
             }
         }
         if ($fields->is_empty()) {
             inform_exit(do_lang_tempcode('NO_ENTRIES'));
         }
         $post_url = build_url(array('page' => '_SELF', 'type' => '_code2'), '_SELF');
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('redirect', get_self_url(true)));
         $hidden->attach(form_input_hidden('lang', $lang));
         return do_template('FORM_SCREEN', array('_GUID' => '2d7356fd2c4497ceb19450e65331c9c5', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => '', 'SUBMIT_NAME' => do_lang('TRANSLATE_CODE')));
     }
     $lang_file = get_param('lang_file');
     if (!file_exists($map_b)) {
         $map_b = $map_a;
     }
     $map = better_parse_ini_file($map_b);
     $title = get_page_title('_TRANSLATE_CODE', true, array(escape_html($lang_file), escape_html(array_key_exists($lang, $map) ? $map[$lang] : $lang)));
     // Upgrade to custom if not there yet (or maybe we are creating a new lang - same difference)
     $custom_dir = get_custom_file_base() . '/lang_custom/' . $lang;
     if (!file_exists($custom_dir)) {
         require_code('abstract_file_manager');
         force_have_afm_details();
         afm_make_directory('lang_custom/' . $lang, true);
         $cached_dir = get_custom_file_base() . '/lang_cached/' . $lang;
         if (!file_exists($cached_dir)) {
             afm_make_directory('lang_cached/' . $lang, true);
         }
         // Make comcode page dirs
         $zones = find_all_zones();
         foreach ($zones as $zone) {
             $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/comcode_custom/' . $lang, true);
             }
             $_special_dir = get_custom_file_base() . '/' . $zone . '/pages/html_custom/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory($zone . ($zone == '' ? '' : '/') . 'pages/html_custom/' . $lang, true);
             }
         }
         // Make templates_cached dirs
         require_code('themes2');
         $themes = find_all_themes();
         foreach (array_keys($themes) as $theme) {
             $_special_dir = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang;
             if (!file_exists($_special_dir)) {
                 afm_make_directory('themes/' . $theme . '/templates_cached/' . $lang, true);
             }
         }
     }
     // Get some stuff
     $for_lang = get_lang_file_map($lang, $lang_file);
     $for_base_lang = get_lang_file_map($base_lang, $lang_file, true);
     $descriptions = get_lang_file_descriptions($base_lang, $lang_file);
     // Make our translation page
     $lines = '';
     $intertrans = $this->get_intertran_conv($lang);
     $actions = new ocp_tempcode();
     $next = 0;
     $trans_lot = '';
     $delimit = chr(10) . '=-=-=-=-=-=-=-=-' . chr(10);
     foreach ($for_base_lang as $name => $old) {
         if (array_key_exists($name, $for_lang)) {
             $current = $for_lang[$name];
         } else {
             $current = '';
             //$this->find_lang_matches($old,$lang); Too slow / useless for code translation
         }
         if ($current == '' && strtolower($name) != $name) {
             $trans_lot .= str_replace('\\n', chr(10), str_replace(array('{', '}'), array('(((', ')))'), $old)) . $delimit;
         }
     }
     $translated_stuff = array();
     if ($trans_lot != '' && $intertrans != '') {
         $result = http_download_file('http://translate.google.com/translate_t', NULL, false, false, 'ocPortal', array('text' => $trans_lot, 'langpair' => 'en|' . $intertrans));
         if (!is_null($result)) {
             require_code('character_sets');
             $result = convert_to_internal_encoding($result);
             $matches = array();
             if (preg_match('#<div id=result_box dir="ltr">(.*)</div>#Us', convert_to_internal_encoding($result), $matches) != 0) {
                 $result2 = $matches[1];
                 $result2 = @html_entity_decode($result2, ENT_QUOTES, get_charset());
                 $result2 = preg_replace('#\\s?<br>\\s?#', chr(10), $result2);
                 $result2 = str_replace('> ', '>', str_replace(' <', ' <', str_replace('</ ', '</', str_replace(array('(((', ')))'), array('{', '}'), $result2))));
                 $translated_stuff = explode(trim($delimit), $result2 . chr(10));
             }
         }
     }
     foreach ($for_base_lang + $for_lang as $name => $old) {
         if (array_key_exists($name, $for_lang)) {
             $current = $for_lang[$name];
         } else {
             $current = '';
             //$this->find_lang_matches($old,$lang); Too slow / useless for code translation
         }
         $description = array_key_exists($name, $descriptions) ? $descriptions[$name] : '';
         if ($current == '' && strtolower($name) != $name && array_key_exists($next, $translated_stuff)) {
             $_current = '';
             $translate_auto = trim($translated_stuff[$next]);
             $next++;
         } else {
             $_current = str_replace('\\n', chr(10), $current);
             $translate_auto = NULL;
         }
         if ($_current == '') {
             $_current = str_replace('\\n', chr(10), $old);
         }
         if ($intertrans != '' && get_value('google_translate_api_key') !== NULL) {
             $actions = do_template('TRANSLATE_ACTION', array('_GUID' => '9e9a68cb2c1a1e23a901b84c9af2280b', 'LANG_FROM' => get_site_default_lang(), 'LANG_TO' => $lang, 'NAME' => 'trans_' . $name, 'OLD' => $_current));
         }
         $temp = do_template('TRANSLATE_LINE', array('_GUID' => '9cb331f5852ee043e6ad30b45aedc43b', 'TRANSLATE_AUTO' => $translate_auto, 'DESCRIPTION' => $description, 'NAME' => $name, 'OLD' => str_replace('\\n', chr(10), $old), 'CURRENT' => $_current, 'ACTIONS' => $actions));
         $lines .= $temp->evaluate();
     }
     $url = build_url(array('page' => '_SELF', 'type' => '_code', 'lang_file' => $lang_file, 'lang' => $lang), '_SELF');
     return do_template('TRANSLATE_SCREEN', array('_GUID' => 'b3429f8bd0b4eb79c33709ca43e3207c', 'PAGE' => $lang_file, 'INTERTRANS' => get_value('google_translate_api_key') !== NULL ? $intertrans : '', 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url));
 }
예제 #23
0
 /**
  * The UI to create an automated what's new newsletter.
  *
  * @return tempcode		The UI
  */
 function automatic_whats_new()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/newsletter_from_changes';
     $title = get_page_title('NEW_CONTENT');
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     if (post_param('message', '') != '') {
         return $this->send_gui(post_param('message'));
     }
     $_hooks = find_all_hooks('modules', 'admin_newsletter');
     $chosen_content = post_param_integer('chosen_content', 0);
     if ($chosen_content == 0) {
         require_code('form_templates');
         require_lang('menus');
         $fields = new ocp_tempcode();
         $_cutoff_time = get_value('newsletter_whatsnew');
         $cutoff_time = is_null($_cutoff_time) ? NULL : intval($_cutoff_time);
         if (is_null($cutoff_time)) {
             $cutoff_time = time() - 60 * 60 * 24 * 365 * 3;
         }
         $fields->attach(form_input_date(do_lang_tempcode('CUTOFF_DATE'), do_lang_tempcode('DESCRIPTION_CUTOFF_DATE'), 'cutoff', false, false, true, $cutoff_time, 3, intval(date('Y')) - 3, NULL, true));
         //$fields->attach(do_template('FORM_SCREEN_FIELD_SPACER',array('TITLE'=>do_lang_tempcode('CONTENT'))));
         $fields->attach(form_input_tick(do_lang_tempcode('EMBED_FULL_ARTICLES'), do_lang_tempcode('DESCRIPTION_EMBED_FULL_ARTICLES'), 'in_full', post_param_integer('in_full', 0) == 1));
         //$_fields=array();
         $chosen_categories = '';
         foreach (array_keys($_hooks) as $hook) {
             require_code('hooks/modules/admin_newsletter/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_whats_news_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $done = false;
             if (method_exists($object, 'choose_categories')) {
                 list($cats, $_title) = $object->choose_categories();
                 //$field=form_input_multi_list($_title,'','whatsnew_'.$hook.'_filter',$cats);
                 if (is_object($cats)) {
                     $cats = $cats->evaluate($lang);
                 }
                 $matches = array();
                 $num_matches = preg_match_all('#<option [^>]*value="([^"]*)"[^>]*>([^<]*)</option>#', $cats, $matches);
                 if ($num_matches < 500) {
                     for ($i = 0; $i < $num_matches; $i++) {
                         $hook_result = $object->run(0, $lang, $matches[1][$i]);
                         if ($hook_result == array()) {
                             continue;
                         }
                         list($hook_content, $_title) = $hook_result;
                         if (!$hook_content->is_empty()) {
                             $decoded = @html_entity_decode($matches[2][$i], ENT_QUOTES, get_charset());
                             $chosen_categories .= $_title . ': ' . trim($decoded) . ' [' . $hook . '/' . $matches[1][$i] . "]\n";
                         }
                     }
                     $done = true;
                 }
             }
             if (!$done) {
                 $new = $object->run(0, $lang, '');
                 if ($new != array()) {
                     list($hook_content, $_title) = $new;
                     if (!$hook_content->is_empty()) {
                         //$field=form_input_tick($_title,'','whatsnew_'.$hook.'_include',false);
                         $chosen_categories .= $_title . ' [' . $hook . "]\n";
                     }
                 }
             }
             //$_fields[$_title]=$field;
         }
         /*ksort($_fields);
         		foreach ($_fields as $field)
         		{
         			$fields->attach($field);
         		}*/
         $fields->attach(form_input_huge(do_lang_tempcode('CONTENT'), do_lang('NEWSLETTER_CONTENT_SELECT'), 'chosen_categories', $chosen_categories, true));
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('chosen_content', '1'));
         if (cron_installed()) {
             $periodic_options = new ocp_tempcode();
             $current_periodic_newsletters = $GLOBALS['SITE_DB']->query_select('newsletter_periodic', array('*'));
             if (count($current_periodic_newsletters) == 0) {
                 $extra_help = do_lang('PERIODIC_NEWSLETTER_EMPTY');
                 $periodic_choice_name = do_lang('PERIODIC_CREATE');
                 $periodic_choice_help = do_lang('PERIODIC_CREATE_HELP');
                 $periodic_options->attach(form_input_list_entry('no_change', true, do_lang('DONT_MAKE_PERIODIC_NEWSLETTER'), false, false));
                 $periodic_options->attach(form_input_list_entry('make_periodic', false, do_lang('MAKE_PERIODIC_NEWSLETTER'), false, false));
             } else {
                 $extra_help = do_lang('PERIODIC_NEWSLETTER_EXISTS');
                 $periodic_choice_name = do_lang('PERIODIC_REPLACE');
                 $periodic_choice_help = do_lang('PERIODIC_REPLACE_HELP');
                 $periodic_options->attach(form_input_list_entry('no_change', true, do_lang('LEAVE_PERIODIC_NEWSLETTER'), false, false));
                 $periodic_options->attach(form_input_list_entry('make_periodic', false, do_lang('MAKE_PERIODIC_NEWSLETTER'), false, false));
                 foreach ($current_periodic_newsletters as $current_periodic_newsletter) {
                     $periodic_options->attach(form_input_list_entry('remove_existing_' . strval($current_periodic_newsletter['id']), false, do_lang('REMOVE_PERIODIC', $current_periodic_newsletter['np_subject'], strval($current_periodic_newsletter['id'])), false, false));
                     $periodic_options->attach(form_input_list_entry('replace_existing_' . strval($current_periodic_newsletter['id']), false, do_lang('REPLACE_PERIODIC', $current_periodic_newsletter['np_subject'], strval($current_periodic_newsletter['id'])), false, false));
                 }
             }
             $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang('PERIODIC_NEWSLETTER_SETTINGS'), 'HELP' => do_lang('PERIODIC_NEWSLETTER_HELP', $extra_help))));
             $fields->attach(form_input_list($periodic_choice_name, $periodic_choice_help, 'periodic_choice', $periodic_options, NULL, false, false));
         }
         return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('SELECT_CATEGORIES_WANTED'), 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('NEXT'), 'URL' => get_self_url(false, false, array('lang' => $lang))));
     } else {
         $cutoff_time = get_input_date('cutoff');
     }
     $matches = array();
     // Bit of a hack, but we include the remove option here for simplicity
     // It has a confirm screen
     if (preg_match('#^remove\\_existing\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) {
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('chosen_content', '1'));
         $hidden->attach(form_input_hidden('periodic_choice', 'periodic_remove_confirmed_' . $matches[1]));
         return do_template('PERIODIC_NEWSLETTER_REMOVE', array('TITLE' => get_page_title('REMOVE_PERIODIC_NEWSLETTER'), 'URL' => get_self_url(), 'HIDDEN' => $hidden));
     }
     // It has an actualiser
     if (preg_match('#^periodic\\_remove\\_confirmed\\_(\\d+)$#', post_param('periodic_choice', ''), $matches) != 0) {
         $GLOBALS['SITE_DB']->query_delete('newsletter_periodic', array('id' => intval($matches[1])), '', 1);
         // We redirect back to the admin_newsletter main page
         $url = build_url(array('page' => 'admin_newsletter', 'type' => 'misc', 'redirected' => '1'), get_module_zone('admin_newsletter'));
         return redirect_screen(do_lang('PERIODIC_REMOVED'), $url, do_lang('PERIODIC_REMOVED_TEXT'));
     }
     $in_full = post_param_integer('in_full', 0) == 1;
     $chosen_categories = post_param('chosen_categories');
     $message = $this->generate_whats_new_comcode($chosen_categories, $in_full, $lang, $cutoff_time);
     return $this->send_gui($message);
 }
예제 #24
0
 /**
  * The UI for an "regular mode" gallery.
  *
  * @param  tempcode		Rating area
  * @param  tempcode		Commenting area
  * @param  ID_TEXT		Our gallery ID
  * @param  ID_TEXT		Virtual root gallery
  * @param  tempcode		The description of the gallery
  * @param  tempcode		The tempcode for our visible child galleries
  * @param  boolean		Whether may "download this gallery"
  * @param  tempcode		The URL to "edit this gallery"
  * @param  tempcode		The URL to "add a gallery"
  * @param  tempcode		The URL to "submit an image to this gallery"
  * @param  tempcode		The URL to "submit a video to this gallery"
  * @param  tempcode		The title of the page (our of get_page_title)
  * @param  string			The gallery title
  * @param  tempcode		Sorting UI
  * @return tempcode		The UI
  */
 function do_gallery_regular_mode($rating_details, $comment_details, $cat, $root, $description, $children, $may_download, $edit_url, $add_gallery_url, $submit_image_url, $submit_video_url, $title, $fullname, $sorting)
 {
     $max = get_param_integer('max', get_default_gallery_max());
     $start = get_param_integer('start', 0);
     if ($max < 1) {
         $max = 1;
     }
     $page_num = $max == 0 ? 0 : intval(floor(floatval($start) / floatval($max))) + 1;
     // Work out totals
     $num_images = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)', array('cat' => $cat));
     $num_videos = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)', array('cat' => $cat));
     $total_rows = $num_images + $num_videos;
     $total_pages = $max == 0 ? 1 : intval(ceil(floatval($total_rows) / floatval($max)));
     if ($total_pages == 0) {
         $total_pages = 1;
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     $where = db_string_equal_to('cat', $cat);
     if (!has_specific_permission(get_member(), 'see_unvalidated')) {
         $where .= ' AND validated=1';
     }
     if (get_param('days', '') != '') {
         $where .= ' AND add_date>' . strval(time() - get_param_integer('days') * 60 * 60 * 24);
     }
     $rows = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_videos . ' FROM ' . get_table_prefix() . 'videos e WHERE ' . $where . ' ORDER BY ' . $sort, $max, $start);
     if (count($rows) < $max) {
         $where = db_string_equal_to('cat', $cat);
         if (!has_specific_permission(get_member(), 'see_unvalidated')) {
             $where .= ' AND validated=1';
         }
         $rows2 = $GLOBALS['SITE_DB']->query('SELECT *' . $sql_suffix_images . ' FROM ' . get_table_prefix() . 'images e WHERE ' . $where . ' ORDER BY ' . $sort, $max - count($rows), max(0, $start - $num_videos));
     } else {
         $rows2 = array();
     }
     $entries = new ocp_tempcode();
     $image_select = get_param('select', '*');
     $video_select = get_param('video_select', '*');
     // Display videos
     foreach ($rows as $row_video) {
         $view_url = build_url(array('page' => '_SELF', 'type' => 'video', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_video['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $start == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF');
         $thumb_url = ensure_thumbnail($row_video['url'], $row_video['thumb_url'], 'galleries', 'videos', $row_video['id']);
         if ($thumb_url == '') {
             $thumb_url = find_theme_image('na');
         }
         $thumb = do_image_thumb($thumb_url, '', true);
         $this_full_url = $row_video['url'];
         if (url_is_local($this_full_url)) {
             $this_full_url = get_custom_base_url() . '/' . $this_full_url;
         }
         $entry_rating_details = $row_video['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_video['title']), 'videos', strval($row_video['id']), 'RATING_INLINE_STATIC', $row_video['submitter']) : NULL;
         $map = array('_GUID' => '395f0aa1212e69da5752d228a6efe54d', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_video['title']), 'DESCRIPTION' => get_translated_tempcode($row_video['comments']), 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_video['id']), 'VIEWS' => strval($row_video['video_views']), 'ADD_DATE_RAW' => strval($row_video['add_date']), 'EDIT_DATE_RAW' => is_null($row_video['edit_date']) ? '' : strval($row_video['edit_date']), 'SUBMITTER' => strval($row_video['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url, 'VIDEO_DETAILS' => show_video_details($row_video));
         $entry = do_template('GALLERY_VIDEO', $map);
         $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'bc0d3de5d0160b00e3250d78658888c1', 'ENTRY' => $entry) + $map));
     }
     // Display images
     foreach ($rows2 as $row_image) {
         $view_url = build_url(array('page' => '_SELF', 'type' => 'image', 'root' => $root == 'root' ? NULL : $root, 'wide' => 1, 'id' => $row_image['id'], 'start' => $start == 0 ? NULL : $start, 'max' => $max == get_default_gallery_max() ? NULL : $max, 'days' => get_param('days', '') == '' ? NULL : get_param('days'), 'sort' => $sort == 'add_date DESC' ? NULL : $sort, 'select' => $image_select == '*' ? NULL : $image_select, 'video_select' => $video_select == '*' ? NULL : $video_select), '_SELF');
         $thumb_url = ensure_thumbnail($row_image['url'], $row_image['thumb_url'], 'galleries', 'images', $row_image['id']);
         $thumb = do_image_thumb($thumb_url, '', true);
         $this_full_url = $row_image['url'];
         if (url_is_local($this_full_url)) {
             $file_size = file_exists(get_custom_file_base() . '/' . rawurldecode($this_full_url)) ? strval(filesize(get_custom_file_base() . '/' . rawurldecode($this_full_url))) : '';
             $this_full_url = get_custom_base_url() . '/' . $this_full_url;
         } else {
             $file_size = '';
         }
         $entry_rating_details = $row_image['allow_rating'] == 1 ? display_rating(get_self_url(true), get_translated_text($row_image['title']), 'images', strval($row_image['id']), 'RATING_INLINE_STATIC', $row_image['submitter']) : NULL;
         $map = array('_GUID' => 'aa70f543297e25379c49fa25d6dbcac0', 'RATING_DETAILS' => $entry_rating_details, 'TITLE' => get_translated_text($row_image['title']), 'DESCRIPTION' => get_translated_tempcode($row_image['comments']), 'FILE_SIZE' => $file_size, 'CAT' => $cat, 'THUMB_URL' => $thumb_url, 'FULL_URL' => $this_full_url, 'ID' => strval($row_image['id']), 'VIEWS' => strval($row_image['image_views']), 'ADD_DATE_RAW' => strval($row_image['add_date']), 'EDIT_DATE_RAW' => is_null($row_image['edit_date']) ? '' : strval($row_image['edit_date']), 'SUBMITTER' => strval($row_image['submitter']), 'THUMB' => $thumb, 'VIEW_URL' => $view_url);
         $entry = do_template('GALLERY_IMAGE', $map);
         $entries->attach(do_template('GALLERY_ENTRY_WRAP', array('_GUID' => 'ea12d7acf47eab493b6fb4658b3c0346', 'ENTRY' => $entry) + $map));
     }
     // Member gallery?
     $member_id = get_member_id_from_gallery_name($cat, NULL, true);
     if (get_forum_type() == 'ocf') {
         require_code('ocf_members');
         require_code('ocf_members2');
     }
     $member_details = is_null($member_id) || get_forum_type() != 'ocf' ? new ocp_tempcode() : ocf_show_member_box($member_id);
     // Results browser
     require_code('templates_results_browser');
     $_selectors = array_map('intval', explode(',', get_option('gallery_selectors')));
     $results_browser = results_browser(do_lang('ENTRY'), $cat, $start, 'start', $max, 'max', $total_rows, $root, 'misc', true, false, 10, $_selectors);
     return do_template('GALLERY_REGULAR_MODE_SCREEN', array('_GUID' => 'cec405597f47f5079b7c7f581fa6b5c2', 'SORTING' => $sorting, '_TITLE' => $fullname, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'RESULTS_BROWSER' => $results_browser, 'TAGS' => get_loaded_tags('galleries'), 'CAT' => $cat, 'MEMBER_DETAILS' => $member_details, 'RATING_DETAILS' => $rating_details, 'COMMENT_DETAILS' => $comment_details, 'ADD_GALLERY_URL' => $add_gallery_url, 'EDIT_URL' => $edit_url, 'CHILDREN' => $children, 'TITLE' => $title, 'DESCRIPTION' => $description, 'IMAGE_URL' => $submit_image_url, 'VIDEO_URL' => $submit_video_url, 'MAY_DOWNLOAD' => $may_download, 'ENTRIES' => $entries));
 }
예제 #25
0
/**
 * The UI for a points 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)
 * @return tempcode		The UI
 */
function points_profile($member_id_of, $member_id_viewing)
{
    require_code('points');
    require_css('points');
    require_lang('points');
    require_javascript('javascript_validation');
    // Get info about viewing/giving user
    if (!is_guest($member_id_viewing)) {
        $viewer_gift_points_available = get_gift_points_to_give($member_id_viewing);
    }
    // Get info about viewed user
    $name = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
    if (is_null($name) || is_guest($member_id_of)) {
        warn_exit(do_lang_tempcode('USER_NO_EXIST'));
    }
    $title = get_page_title('_POINTS', true, array(escape_html($name)));
    $profile_link = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id_of, false, true);
    // Show stats about $member_id_of
    $post_count = $GLOBALS['FORUM_DRIVER']->get_post_count($member_id_of);
    $_point_info = point_info($member_id_of);
    $points_gained_given = array_key_exists('points_gained_given', $_point_info) ? $_point_info['points_gained_given'] : 0;
    $points_gained_rating = array_key_exists('points_gained_rating', $_point_info) ? $_point_info['points_gained_rating'] : 0;
    $points_gained_voting = array_key_exists('points_gained_voting', $_point_info) ? $_point_info['points_gained_voting'] : 0;
    $cedi_post_count = array_key_exists('points_gained_seedy', $_point_info) ? $_point_info['points_gained_seedy'] : 0;
    $chat_post_count = array_key_exists('points_gained_chat', $_point_info) ? $_point_info['points_gained_chat'] : 0;
    $points_used = points_used($member_id_of);
    $remaining = available_points($member_id_of);
    $gift_points_used = get_gift_points_used($member_id_of);
    //$_point_info['gift_points_used'];
    $gift_points_available = get_gift_points_to_give($member_id_of);
    $points_posting = intval(get_option('points_posting'));
    $points_rating = intval(get_option('points_rating'));
    $points_voting = intval(get_option('points_voting'));
    $points_joining = intval(get_option('points_joining'));
    $points_cedi_posting = intval(get_option('points_cedi', true));
    $points_chat_posting = intval(get_option('points_chat', true));
    $points_per_day = intval(get_option('points_per_day', true));
    $points_per_daily_visit = intval(get_option('points_per_daily_visit', true));
    $days_joined = intval(floor(floatval(time() - $GLOBALS['FORUM_DRIVER']->get_member_join_timestamp($member_id_of)) / (60.0 * 60.0 * 24.0)));
    $points_gained_auto = $points_per_day * $days_joined;
    $to = points_get_transactions('to', $member_id_of, $member_id_viewing);
    $from = points_get_transactions('from', $member_id_of, $member_id_viewing);
    // If we're staff, we can show the charge log too
    $chargelog_details = new ocp_tempcode();
    if (has_specific_permission($member_id_viewing, 'view_charge_log')) {
        global $NON_CANONICAL_PARAMS;
        $NON_CANONICAL_PARAMS[] = 'charge_start';
        $NON_CANONICAL_PARAMS[] = 'charge_sort';
        $start = get_param_integer('charge_start', 0);
        $max = get_param_integer('charge_max', 10);
        $sortables = array('date_and_time' => do_lang_tempcode('DATE'), 'amount' => do_lang_tempcode('AMOUNT'));
        $test = explode(' ', get_param('charge_sort', 'date_and_time DESC'), 2);
        if (count($test) == 1) {
            $test[1] = 'DESC';
        }
        list($sortable, $sort_order) = $test;
        if (strtoupper($sort_order) != 'ASC' && strtoupper($sort_order) != 'DESC' || !array_key_exists($sortable, $sortables)) {
            log_hack_attack_and_exit('ORDERBY_HACK');
        }
        $max_rows = $GLOBALS['SITE_DB']->query_value('chargelog', 'COUNT(*)', array('user_id' => $member_id_of));
        $rows = $GLOBALS['SITE_DB']->query_select('chargelog c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND t.id=c.reason', array('*'), array('user_id' => $member_id_of), 'ORDER BY ' . $sortable . ' ' . $sort_order, $max, $start);
        $charges = new ocp_tempcode();
        $fromname = get_site_name();
        $toname = $GLOBALS['FORUM_DRIVER']->get_username($member_id_of);
        if (is_null($toname)) {
            $toname = do_lang('UNKNOWN');
        }
        require_code('templates_results_table');
        $fields_title = results_field_title(array(do_lang_tempcode('DATE'), do_lang_tempcode('AMOUNT'), do_lang_tempcode('FROM'), do_lang_tempcode('TO'), do_lang_tempcode('REASON')), $sortables, 'charge_sort', $sortable . ' ' . $sort_order);
        foreach ($rows as $myrow) {
            $date = get_timezoned_date($myrow['date_and_time']);
            $amount = $myrow['amount'];
            if (get_page_name() != 'search' && array_key_exists('text_parsed', $myrow) && !is_null($myrow['text_parsed']) && $myrow['text_parsed'] != '' && $myrow['reason'] != 0) {
                $reason = new ocp_tempcode();
                if (!$reason->from_assembly($myrow['text_parsed'], true)) {
                    $reason = get_translated_tempcode($myrow['reason']);
                }
            } else {
                $reason = get_translated_tempcode($myrow['reason']);
            }
            $charges->attach(results_entry(array(escape_html($date), escape_html(integer_format($amount)), escape_html($fromname), escape_html($toname), $reason)));
        }
        $chargelog_details = results_table(do_lang_tempcode('CHARGES'), $start, 'charge_start', $max, 'charge_max', $max_rows, $fields_title, $charges, $sortables, $sortable, $sort_order, 'charge_sort', NULL, NULL, NULL, 8, 'fgfdgfdgfdgfdger4gtrhg', false, 'tab__points');
        $chargelog_details->attach(do_template('POINTS_CHARGE', array('_GUID' => 'f1e2d45a7d920ab91553a5fd0728a5ad', 'URL' => build_url(array('page' => 'admin_points', 'type' => 'charge', 'redirect' => get_self_url(true)), get_module_zone('admin_points')), 'USER' => strval($member_id_of))));
    }
    // Show giving form
    if (is_guest($member_id_viewing)) {
        $give_template = do_lang_tempcode('POINTS_MUST_LOGIN');
    } else {
        $have_negative_gift_points = has_specific_permission($member_id_viewing, 'have_negative_gift_points');
        $enough_ok = $viewer_gift_points_available > 0 || $have_negative_gift_points;
        $give_ok = $member_id_viewing != $member_id_of || has_specific_permission($member_id_viewing, 'give_points_self');
        if ($enough_ok && $give_ok) {
            // Show how many points are available also
            $give_url = build_url(array('page' => 'points', 'type' => 'give', 'id' => $member_id_of), get_module_zone('points'));
            $give_template = do_template('POINTS_GIVE', array('_GUID' => 'fa1749d5a803d86b1efbcfde2ad81702', 'GIVE_URL' => $give_url, 'USER' => strval($member_id_of), 'VIEWER_GIFT_POINTS_AVAILABLE' => $have_negative_gift_points ? '' : integer_format($viewer_gift_points_available)));
        } else {
            $give_template = do_lang_tempcode('PE_LACKING_GIFT_POINTS');
        }
        if (!$give_ok) {
            $give_template = new ocp_tempcode();
        }
        if (!has_specific_permission($member_id_of, 'use_points')) {
            $give_template = new ocp_tempcode();
        }
    }
    return do_template('POINTS_PROFILE', array('_GUID' => 'f91208ef0f9a1e1a8633ce307a778a8d', 'TITLE' => $title, 'MEMBER' => strval($member_id_of), 'PROFILE_LINK' => $profile_link, 'NAME' => $name, 'POINTS_JOINING' => integer_format($points_joining), 'POST_COUNT' => integer_format($post_count), 'POINTS_POSTING' => integer_format($points_posting), 'MULT_POINTS_POSTING' => integer_format($points_posting * $post_count), 'POINTS_PER_DAY' => integer_format($points_per_day), 'DAYS_JOINED' => integer_format($days_joined), 'MULT_POINTS_PER_DAY' => integer_format($points_per_day * $days_joined), 'POINTS_GAINED_AUTO' => integer_format($points_gained_auto), 'CEDI_POST_COUNT' => integer_format($cedi_post_count), 'POINTS_CEDI_POSTING' => integer_format($points_cedi_posting), 'MULT_POINTS_CEDI_POSTING' => integer_format($cedi_post_count * $points_cedi_posting), 'CHAT_POST_COUNT' => integer_format($chat_post_count), 'POINTS_CHAT_POSTING' => integer_format($points_chat_posting), 'MULT_POINTS_CHAT_POSTING' => integer_format($chat_post_count * $points_chat_posting), 'POINTS_RATING' => integer_format($points_rating), 'POINTS_GAINED_RATING' => integer_format($points_gained_rating), 'MULT_POINTS_RATING' => integer_format($points_rating * $points_gained_rating), 'POINTS_VOTING' => integer_format($points_voting), 'POINTS_GAINED_VOTING' => integer_format($points_gained_voting), 'MULT_POINTS_VOTING' => integer_format($points_voting * $points_gained_voting), 'POINTS_PER_DAILY_VISIT' => integer_format($points_per_daily_visit), 'POINTS_GAINED_GIVEN' => integer_format($points_gained_given), 'POINTS_USED' => integer_format($points_used), 'REMAINING' => integer_format($remaining), 'GIFT_POINTS_USED' => integer_format($gift_points_used), 'GIFT_POINTS_AVAILABLE' => integer_format($gift_points_available), 'TO' => $to, 'FROM' => $from, 'CHARGELOG_DETAILS' => $chargelog_details, 'GIVE' => $give_template));
}
예제 #26
0
 /**
  * Get a form for posting.
  *
  * @param  ID_TEXT		The content type of what this posting will be for
  * @param  ID_TEXT		The content ID of what this posting will be for
  * @param  boolean		Whether to accept reviews
  * @param  tempcode		URL where form submit will go
  * @param  ?string		The default post to use (NULL: standard courtesy warning)
  * @return tempcode		Posting form
  */
 function get_posting_form($type, $id, $allow_reviews, $post_url, $post_warning)
 {
     require_lang('comcode');
     require_javascript('javascript_editing');
     require_javascript('javascript_validation');
     require_javascript('javascript_swfupload');
     require_css('swfupload');
     $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
     $comment_text = get_option('comment_text');
     if (is_null($post_warning)) {
         $post_warning = do_lang('POST_WARNING');
     }
     if (addon_installed('captcha')) {
         require_code('captcha');
         $use_captcha = use_captcha();
         if ($use_captcha) {
             generate_captcha();
         }
     } else {
         $use_captcha = false;
     }
     $title = do_lang_tempcode($allow_reviews ? 'POST_REVIEW' : 'MAKE_COMMENT');
     $join_bits = new ocp_tempcode();
     if (is_guest()) {
         $redirect = get_self_url(true, true);
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => $redirect), get_module_zone('login'));
         $join_url = $GLOBALS['FORUM_DRIVER']->join_url();
         $join_bits = do_template('JOIN_OR_LOGIN', array('LOGIN_URL' => $login_url, 'JOIN_URL' => $join_url));
     }
     $reviews_rating_criteria = array();
     foreach ($this->reviews_rating_criteria as $review_title) {
         $reviews_rating_criteria[] = array('REVIEW_TITLE' => $review_title);
     }
     if ($this->is_threaded) {
         $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning);
     }
     return do_template('COMMENTS_POSTING_FORM', array('_GUID' => 'c87025f81ee64c885f0ac545efa5f16c', 'EXPAND_TYPE' => 'contract', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'JOIN_BITS' => $join_bits, 'REVIEWS' => $allow_reviews, 'TYPE' => $type, 'ID' => $id, 'REVIEW_RATING_CRITERIA' => $reviews_rating_criteria, 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => $comment_text, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $post_url, 'TITLE' => $title));
 }
예제 #27
0
 /**
  * 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);
 }
예제 #28
0
 /**
  * Standard PHP XML parser function.
  *
  * @param  object			The parser object (same as 'this')
  */
 function endElement($parser)
 {
     $tag = array_pop($this->tag_stack);
     $tag_attributes = array_pop($this->attribute_stack);
     switch ($tag) {
         case 'substitution':
             list($zone, $attributes, $hash) = page_link_decode($this->substitution_current_match_key);
             if ($zone == '_WILD') {
                 $zone = REGEXP_CODENAME;
             }
             if (!isset($attributes['page'])) {
                 $attributes['page'] = '';
             }
             /*
             Commented for performance. This isn't user-data, so we're safe
             $zone=str_replace('~','\~',preg_quote($zone)); // We are using '~' as deliminators for the regexp, as the usual '/' and '#' feature in URL separators
             $hash=str_replace('~','\~',preg_quote($hash));
             */
             if ($attributes['page'] == '_WILD_NOT_START') {
                 $zones = find_all_zones(false, true);
                 if (isset($zones[$zone])) {
                     $attributes['page'] = '(?!' . $zones[$zone][3] . ')' . REGEXP_CODENAME;
                 } else {
                     $attributes['page'] = '_WILD';
                 }
             }
             if ($attributes['page'] == '_WILD') {
                 $attributes['page'] = REGEXP_CODENAME;
             }
             foreach ($attributes as $key => $val) {
                 $attributes[$key] = $val;
             }
             $_source_url = build_url($attributes, $zone, NULL, false, false, true, $hash);
             $source_url = urldecode(urldecode($_source_url->evaluate()));
             // urldecode because we don't want our regexp syntax mangled. Highly unlikely our sub's are going to really use special characters as parts of the URL
             if (strpos($source_url, '.htm') === false && strpos($source_url, '.php') === false) {
                 $source_url .= '(?:/index\\.php)?';
             }
             $source_url1 = str_replace(array('.htm', '?', '(\\?', ')\\?', '&', get_base_url() . '/' . REGEXP_CODENAME . '/'), array('\\.htm', '\\?', '(?', ')?', '(?:&[^<>]*)*&', get_base_url() . '/?' . REGEXP_CODENAME . '/'), $source_url) . '(?:[&\\?][^<>]*)*';
             $escaped_source_url = escape_html($source_url);
             if ($source_url == $escaped_source_url) {
                 $source_url2 = $source_url1;
             } else {
                 $source_url2 = str_replace(array('.htm', '?', '(\\?', ')\\?', '&', get_base_url() . '/' . REGEXP_CODENAME . '/'), array('\\.htm', '\\?', '(?', ')?', '(?:&[^<>]*)*&', get_base_url() . '/?' . REGEXP_CODENAME . '/'), $escaped_source_url) . '(?:[&\\?][^<>]*)*';
             }
             $from = '^.*<a[^<>]*\\shref="(' . $source_url2 . ')"[^<>]*>(<abbr[^<>]*>)?([^<>]*)(</abbr>)?</a>';
             $regexp = '#^' . $source_url1 . '$#';
             $have_url_match = preg_match($regexp, get_self_url(true)) != 0;
             // we either bind rule via URL match, or finding it in the defined breadcrumb chain
             if ($have_url_match && preg_match('~' . $from . '~Us', $this->current_breadcrumbs) == 0) {
                 // Probably it's a non-link chain in the breadcrumbs, so try to bind to the <span> portion too (possibly nested)
                 $from = '^.*(<span>(<span[^<>]*>)?|<a[^<>]*\\shref="(' . $source_url2 . ')"[^<>]*>)(<abbr[^<>]*>)?([^<>]*)(</abbr>)?((</(span)>)?</(a|span)>)';
                 $from_non_link = true;
             } else {
                 $from_non_link = false;
             }
             $to = '';
             foreach (array_reverse($this->links) as $link) {
                 list($zone, $attributes, $hash) = page_link_decode($link[0]);
                 $target_url = build_url($attributes, $zone, NULL, false, false, false, $hash);
                 $_link_title = $link[1] === NULL ? do_lang('UNKNOWN') : $link[1];
                 $link_title = preg_match('#\\{\\!|\\{\\?|\\{\\$|\\[#', $_link_title) == 0 ? $_link_title : static_evaluate_tempcode(comcode_to_tempcode($_link_title));
                 if ($target_url->evaluate() == '') {
                     $to .= $link_title . $this->breadcrumb_tpl;
                 } else {
                     $to .= '<a title="' . do_lang('GO_BACKWARDS_TO', escape_html(strip_tags($link_title))) . '" href="' . escape_html($target_url->evaluate()) . '">' . $link_title . '</a>' . $this->breadcrumb_tpl;
                 }
             }
             $_target_url = $from_non_link ? '${3}' : '${1}';
             $existing_label = $from_non_link ? '${5}' : '${3}';
             $_link_title = $this->substitution_current_label === NULL ? $existing_label : $this->substitution_current_label;
             $link_title = preg_match('#(\\{\\!)|(\\{\\?)|(\\{\\$)|(\\[)#', $_link_title) == 0 ? $_link_title : static_evaluate_tempcode(comcode_to_tempcode($_link_title));
             if ($from_non_link) {
                 $to .= '${1}' . $link_title . '${7}';
             } else {
                 $to .= '<a title="' . do_lang('GO_BACKWARDS_TO', escape_html(strip_tags($link_title))) . '" href="' . escape_html($_target_url) . '">${2}' . $link_title . '${4}</a>';
             }
             $this->substitutions[$from] = $to;
             break;
         case 'link':
             $text = trim(str_replace('\\n', chr(10), $this->text_so_far));
             $this->links[] = array($text, isset($tag_attributes['label']) ? $tag_attributes['label'] : NULL);
             break;
     }
 }
예제 #29
0
destrictify();
require_code('twitter');
require_lang('twitter');
$title = get_page_title('TWITTER_OAUTH');
$api_key = get_option('twitter_api_key', true);
$api_secret = get_option('twitter_api_secret', true);
if (is_null($api_key)) {
    require_code('database_action');
    add_config_option('TWITTER_API_KEY', 'twitter_api_key', 'line', 'return \'\';', 'FEATURE', 'TWITTER_SYNDICATION');
    add_config_option('TWITTER_API_SECRET', 'twitter_api_secret', 'line', 'return \'\';', 'FEATURE', 'TWITTER_SYNDICATION');
    $api_key = '';
    $api_secret = '';
}
if ($api_key == '' || $api_secret == '') {
    $config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'FEATURE', 'redirect' => get_self_url(true)), '_SELF', NULL, false, false, false, 'group_TWITTER_SYNDICATION');
    require_code('site2');
    assign_refresh($config_url, 0.0);
    $echo = do_template('REDIRECT_SCREEN', array('URL' => $config_url, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('TWITTER_SETUP_FIRST')));
    $echo->evaluate_echo();
    return;
}
require_code('hooks/systems/syndication/twitter');
$ob = new Hook_Syndication_twitter();
$result = $ob->auth_set(NULL, get_self_url(false, false, array('oauth_in_progress' => 1)));
if ($result) {
    $out = do_lang_tempcode('TWITTER_OAUTH_SUCCESS');
} else {
    $out = do_lang_tempcode('SOME_ERRORS_OCCURRED');
}
$title->evaluate_echo();
$out->evaluate_echo();
예제 #30
0
 /**
  * The actualiser for deleting a folder.
  *
  * @return tempcode	The UI.
  */
 function module_do_delete_folder()
 {
     $title = get_page_title('FILEDUMP_DELETE_FOLDER');
     $file = filter_naughty(get_param('file'));
     $place = filter_naughty(get_param('place'));
     breadcrumb_set_parents(array(array('_SELF:_SELF', do_lang_tempcode('FILE_DUMP'))));
     if (post_param_integer('confirmed', 0) != 1) {
         $url = get_self_url();
         $text = do_lang_tempcode('CONFIRM_DELETE', $file);
         breadcrumb_set_self(do_lang_tempcode('CONFIRM'));
         $hidden = build_keep_post_fields();
         $hidden->attach(form_input_hidden('confirmed', '1'));
         return do_template('CONFIRM_SCREEN', array('_GUID' => '55cd4cafa3bf8285028da9862508d811', 'TITLE' => $title, 'FIELDS' => $hidden, 'PREVIEW' => $text, 'URL' => $url));
     }
     $ret = @rmdir(get_custom_file_base() . '/uploads/filedump' . $place . $file);
     sync_file('uploads/filedump/' . $place . $file);
     if ($ret) {
         $return_url = build_url(array('page' => '_SELF', 'type' => 'misc', 'place' => $place), '_SELF');
         log_it('FILEDUMP_DELETE_FOLDER', $file, $place);
         return redirect_screen($title, $return_url, do_lang_tempcode('SUCCESS'));
     } else {
         warn_exit(do_lang_tempcode('FOLDER_DELETE_ERROR'));
     }
     return new ocp_tempcode();
 }