예제 #1
0
 /**
  * Standard aed_module run_start.
  *
  * @param  ID_TEXT		The type of module execution
  * @return tempcode		The output of the run
  */
 function run_start($type)
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/emoticons';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_emoticons';
     $this->add_one_label = do_lang_tempcode('ADD_EMOTICON');
     $this->edit_this_label = do_lang_tempcode('EDIT_THIS_EMOTICON');
     $this->edit_one_label = do_lang_tempcode('EDIT_EMOTICON');
     require_lang('dearchive');
     require_code('images');
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_general_action');
     require_code('ocf_general_action2');
     if ($type == 'ad') {
         require_javascript('javascript_ajax');
         $script = find_script('snippet');
         $this->javascript = "\n\t\t\t\tvar form=document.getElementById('main_form');\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_emoticon&name='+window.encodeURIComponent(form.elements['code'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t";
     }
     if ($type == 'misc') {
         return $this->misc();
     }
     if ($type == 'import') {
         return $this->import();
     }
     if ($type == '_import') {
         return $this->_import();
     }
     return new ocp_tempcode();
 }
예제 #2
0
 /**
  * Convert a field value to something renderable.
  *
  * @param  array			The field details
  * @param  mixed			The raw value
  * @return mixed			Rendered field (tempcode or string)
  */
 function render_field_value($field, $ev)
 {
     if (is_object($ev)) {
         return $ev;
     }
     if ($ev == '') {
         return '';
     }
     $original_filename = basename($ev);
     $download_url = (url_is_local($ev) ? get_custom_base_url() . '/' : '') . $ev;
     if (strpos($ev, '::') !== false) {
         list($ev, $original_filename) = explode('::', $ev);
         $keep = symbol_tempcode('KEEP');
         $download_url = find_script('catalogue_file') . '?original_filename=' . urlencode($original_filename) . '&file=' . urlencode(basename($ev)) . $keep->evaluate();
     }
     $extension = get_file_extension($ev);
     require_code('mime_types');
     $mime_type = get_mime_type($extension);
     if ((strpos($mime_type, 'video') !== false || strpos($mime_type, 'audio') !== false) && addon_installed('galleries')) {
         // Video/Audio HTML
         switch ($mime_type) {
             case 'video/quicktime':
                 $tpl = 'GALLERY_VIDEO_QT';
                 break;
             case 'audio/x-pn-realaudio':
                 $tpl = 'GALLERY_VIDEO_RM';
                 break;
             default:
                 $tpl = 'GALLERY_VIDEO_GENERAL';
         }
         return do_template($tpl, array('URL' => url_is_local($ev) ? get_custom_base_url() . '/' . $ev : $ev, 'WIDTH' => get_option('default_video_width'), 'HEIGHT' => get_option('default_video_height'), 'MIME_TYPE' => $mime_type));
     }
     return hyperlink($download_url, $original_filename, true, true);
 }
예제 #3
0
/**
 * Script to make a bookmark add-form popup.
 */
function bookmarks_script()
{
    require_lang('bookmarks');
    $type = get_param('type');
    switch ($type) {
        case '_ad':
            $title = get_page_title('ADD_BOOKMARK');
            $folder = post_param('folder_new', '');
            if ($folder == '') {
                $folder = post_param('folder');
            }
            if ($folder == '!') {
                $folder = '';
            }
            add_bookmark(get_member(), $folder, post_param('title'), post_param('page_link'));
            $content = inform_screen($title, do_lang_tempcode('SUCCESS'));
            $content->attach('<script type="text/javascript">// <![CDATA[
				if (window.opener) window.close();
			//]]></script>');
            break;
        default:
            $url = find_script('bookmarks') . '?no_redirect=1&type=_ad';
            $keep = symbol_tempcode('KEEP');
            $url .= $keep->evaluate();
            $content = add_bookmark_form($url);
            break;
    }
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('ADD_BOOKMARK'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
예제 #4
0
/**
 * Validate an IP address, indirectly by passing through a confirmation code.
 */
function validate_ip_script()
{
    @ob_end_clean();
    global $EXTRA_HEAD;
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $keep = keep_symbol(array('1'));
    $code = either_param('code', '');
    if ($code == '') {
        $title = get_page_title('CONFIRM');
        require_code('form_templates');
        $fields = new ocp_tempcode();
        $fields->attach(form_input_codename(do_lang_tempcode('CODE'), '', 'code', '', true));
        $submit_name = do_lang_tempcode('PROCEED');
        $url = find_script('validateip') . $keep;
        $middle = do_template('FORM_SCREEN', array('_GUID' => 'd92ce4ec82dc709f920a4ce6760778de', 'TITLE' => $title, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => $url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name));
        $echo = globalise($middle, NULL, '', true);
        $echo->evaluate_echo();
        exit;
    }
    // If we're still here, we're ok to go
    require_lang('ocf');
    $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_member_known_login_ips', 'i_val_code', array('i_val_code' => $code));
    if (is_null($test)) {
        warn_exit(do_lang_tempcode('ALREADY_VALIDATED'));
    }
    $GLOBALS['FORUM_DB']->query_update('f_member_known_login_ips', array('i_val_code' => ''), array('i_val_code' => $code), '', 1);
    $title = get_page_title('CONFIRM');
    $middle = redirect_screen($title, get_base_url() . $keep, do_lang_tempcode('SUCCESS'));
    $echo = globalise($middle, NULL, '', true);
    $echo->evaluate_echo();
    exit;
}
예제 #5
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=authors&filter=';
     require_code('authors');
     require_lang('authors');
     // Decide what we're doing
     $type = get_param('type', 'misc');
     if ($type == 'misc') {
         return $this->show_author();
     }
     return new ocp_tempcode();
 }
예제 #6
0
 /**
  * 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 (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) {
         return array();
     }
     require_code('ocf_join');
     if (!referrer_is_qualified($member_id)) {
         return array();
     }
     require_lang('referrals');
     $keep = symbol_tempcode('KEEP');
     return array(array('usage', do_lang_tempcode('REFERRALS'), find_script('referrer_report') . '?member_id=' . strval($member_id) . $keep->evaluate()));
 }
/**
 * Put the contents of a page inside an iframe. This is typically used when a page is being used to traverse a result-set that spans multiple screens.
 *
 * @param  tempcode		The title
 * @param  ?integer		The time between refreshes (NULL: do not refresh)
 * @param  ?mixed			Data. A refresh will only happen if an AJAX-check indicates this data has changed (NULL: no check)
 * @return ?tempcode		The page output to finish off our current page stream such that it will spawn the iframe (NULL: not internalised)
 */
function internalise_own_screen($title, $refresh_time = NULL, $refresh_if_changed = NULL)
{
    if (get_value('no_frames') === '1' || get_param_integer('no_frames', 0) == 1 || get_param_integer('keep_no_frames', 0) == 1) {
        return NULL;
    }
    if (!has_js()) {
        return NULL;
    }
    // We need JS to make this a seamless process
    if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
        return NULL;
    }
    // This is already in the iframe
    require_javascript('javascript_ajax');
    require_javascript('javascript_iframe_screen');
    $url = find_script('iframe') . '?zone=' . rawurlencode(get_zone_name()) . '&wide_high=1&utheme=' . rawurlencode($GLOBALS['FORUM_DRIVER']->get_theme());
    foreach (array_merge($_GET, $_POST) as $key => $param) {
        if (!is_string($param)) {
            continue;
        }
        if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
            continue;
        }
        if (get_magic_quotes_gpc()) {
            $param = stripslashes($param);
        }
        $url .= '&' . $key . '=' . urlencode($param);
    }
    if (!is_null($refresh_if_changed)) {
        require_javascript('javascript_sound');
        $change_detection_url = find_script('change_detection') . '?whatever=1';
        foreach ($_GET as $key => $param) {
            if (!is_string($param)) {
                continue;
            }
            if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                continue;
            }
            if (get_magic_quotes_gpc()) {
                $param = stripslashes($param);
            }
            $change_detection_url .= '&' . $key . '=' . urlencode($param);
        }
    } else {
        $refresh_if_changed = '';
        $change_detection_url = '';
    }
    return do_template('IFRAME_SCREEN', array('_GUID' => '06554eb227428fd5c648dee3c5b38185', 'TITLE' => $title, 'REFRESH_IF_CHANGED' => md5(serialize($refresh_if_changed)), 'CHANGE_DETECTION_URL' => $change_detection_url, 'REFRESH_TIME' => is_null($refresh_time) ? '' : strval($refresh_time), 'IFRAME_URL' => $url));
}
예제 #8
0
function load_lib($relativePath)
{
    $fileName = rectify_file_path($relativePath) . ".php";
    if (!is_null($script = find_script($fileName))) {
        if (!in_array($script, get_included_files())) {
            require_once $script;
        }
        return;
    } elseif (!is_null($combined_script = find_script(dirname($fileName) . ".php")) && !in_array($combined_script, get_included_files())) {
        if (!in_array($combined_script, get_included_files())) {
            require_once $combined_script;
        }
        return;
    }
    throw new PHPScriptNotFoundException($fileName);
}
예제 #9
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)
 {
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=activities&filter=' . strval($member_id_of);
     require_lang('activities');
     $title = do_lang_tempcode('ACTIVITIES_TITLE');
     $order = 70;
     // Need to declare these here as the Tempcode engine can't look as deep, into a loop (I think), as it would need to, to find the block declaring the dependency
     require_css('activities');
     require_javascript('javascript_activities_state');
     require_javascript('javascript_activities');
     require_javascript('javascript_jquery');
     require_javascript('javascript_base64');
     // Allow user to link up things for syndication
     $syndications = array();
     if ($member_id_of == $member_id_viewing) {
         $dests = find_all_hooks('systems', 'syndication');
         foreach (array_keys($dests) as $hook) {
             require_code('hooks/systems/syndication/' . $hook);
             $ob = object_factory('Hook_Syndication_' . $hook);
             if ($ob->is_available()) {
                 if (either_param('syndicate_stop__' . $hook, NULL) !== NULL) {
                     $ob->auth_unset($member_id_of);
                 } elseif (either_param('syndicate_start__' . $hook, NULL) !== NULL) {
                     $url_map = array('page' => '_SELF', 'type' => 'view', 'id' => $member_id_of, 'oauth_in_progress' => 1);
                     $url_map['syndicate_start__' . $hook] = 1;
                     $oauth_url = build_url($url_map, '_SELF', NULL, false, false, false, 'tab__activities');
                     $ob->auth_set($member_id_of, $oauth_url);
                 } elseif (running_script('index') && !$leave_to_ajax_if_possible && $ob->auth_is_set($member_id_of) && either_param('oauth_in_progress', NULL) === NULL && !$GLOBALS['IS_ACTUALLY_ADMIN']) {
                     /*	running_script('index') won't work currently due to execution contexts, and it is never non-AJAX, and it's probably not needed anyway
                     			// Do a refresh to make sure the token is updated
                     			$url_map=array('page'=>'_SELF','type'=>'view','id'=>$member_id_of,'oauth_in_progress'=>1);
                     			$url_map['syndicate_start__'.$hook]=1;
                     			$oauth_url=build_url($url_map,'_SELF',NULL,false,false,false,'tab__activities');
                     			$ob->auth_set($member_id_of,$oauth_url);
                     			*/
                 }
                 $syndications[$hook] = array('SYNDICATION_IS_SET' => $ob->auth_is_set($member_id_of), 'SYNDICATION_SERVICE_NAME' => $ob->get_service_name());
             }
         }
     }
     if ($leave_to_ajax_if_possible) {
         return array($title, NULL, $order);
     }
     $content = do_template('OCF_MEMBER_PROFILE_ACTIVITIES', array('MEMBER_ID' => strval($member_id_of), 'SYNDICATIONS' => $syndications));
     return array($title, $content, $order);
 }
예제 #10
0
/**
 * Shows an HTML page of all authors clickably.
 */
function authors_script()
{
    require_lang('authors');
    global $NON_CANONICAL_PARAMS;
    $NON_CANONICAL_PARAMS[] = 'max';
    $start = get_param_integer('start', 0);
    $max = get_param_integer('max', 300);
    $author_fields = $GLOBALS['SITE_DB']->query('SELECT m_name,m_table FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE m_name LIKE \'' . db_encode_like('%author') . '\'');
    $rows = array();
    foreach ($author_fields as $field) {
        if ($field['m_table'] != 'addons' && $field['m_table'] != 'blocks' && $field['m_table'] != 'modules') {
            $rows_new = $GLOBALS['SITE_DB']->query('SELECT DISTINCT ' . $field['m_name'] . ' AS author FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' WHERE ' . db_string_not_equal_to($field['m_name'], '') . ' ORDER BY ' . $field['m_name'], $max + $start);
            foreach ($rows_new as $a) {
                if (!array_key_exists($a['author'], $rows) || $field['m_table'] == 'authors') {
                    $rows[$a['author']] = $field['m_table'];
                }
            }
        }
    }
    $rows = array_unique($rows);
    $field_name = get_param('field_name');
    $content = new ocp_tempcode();
    $i = 0;
    foreach ($rows as $author => $table) {
        if ($i >= $start && $i < $start + $max) {
            if ($table == 'authors') {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_DEFINED', array('_GUID' => 'cffa9926cebd3ec2920677266a3299ea', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            } else {
                $content->attach(do_template('AUTHOR_POPUP_WINDOW_UNDEFINED', array('_GUID' => '6210be6d1eef4bc2bda7f49947301f97', 'FIELD_NAME' => $field_name, 'AUTHOR' => $author)));
            }
        }
        $i++;
    }
    if ($content->is_empty()) {
        $content = paragraph(do_lang_tempcode('NO_ENTRIES'), 'dfids09fi;lk;3');
    }
    if ($i >= $start + $max) {
        $keep = symbol_tempcode('KEEP');
        $next_link = find_script('authors') . '?field_name=' . urlencode($field_name) . '&start=' . strval($start + $max) . '&max=' . strval($max) . $keep->evaluate();
    } else {
        $next_link = NULL;
    }
    $echo = do_template('STYLED_HTML_WRAP', array('_GUID' => 'ab8d8c9d276530d82ddd84202aacf32f', 'TITLE' => do_lang_tempcode('CHOOSE_AUTHOR'), 'NEXT_LINK' => $next_link, 'CONTENT' => $content));
    $echo->evaluate_echo();
}
예제 #11
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;
}
예제 #12
0
 /**
  * Standard modular run function for symbol hooks. Searches for tasks to perform.
  *
  * @param  array		Symbol parameters
  * @return string		Result
  */
 function run($param)
 {
     $value = '';
     if (get_option('sitewide_im', true) === '1' && !is_guest() && (!array_key_exists(get_session_id(), $GLOBALS['SESSION_CACHE']) || $GLOBALS['SESSION_CACHE'][get_session_id()]['session_invisible'] == 0)) {
         require_code('chat');
         require_lang('chat');
         $messages_php = find_script('messages');
         $im_area_template = do_template('CHAT_LOBBY_IM_AREA', array('_GUID' => '38de4f030d5980790d6d1db1a7e2ff39', 'MESSAGES_PHP' => $messages_php, 'ROOM_ID' => '__room_id__'));
         $im_area_template = do_template('CHAT_SITEWIDE_IM_POPUP', array('_GUID' => 'e520e557f86d0dd4e32d25a208d8f154', 'CONTENT' => $im_area_template));
         $im_area_template = do_template('STYLED_HTML_WRAP', array('_GUID' => '5032bfa802af3fe14e610d09078ef849', 'CSS' => 'sitewide_im_popup_body', 'TITLE' => '__room_name__', 'TARGET' => '_site_opener', 'CONTENT' => $im_area_template));
         $make_buddy_url = build_url(array('page' => '_SELF', 'type' => 'buddy_add', 'member_id' => '__id__'), '_SELF');
         $block_member_url = build_url(array('page' => '_SELF', 'type' => 'blocking_add', 'member_id' => '__id__'), '_SELF');
         $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url(-100, false, true);
         if (is_object($profile_url)) {
             $profile_url = $profile_url->evaluate();
         }
         $profile_url = str_replace('-100', '__id__', $profile_url);
         $im_participant_template = do_template('CHAT_LOBBY_IM_PARTICIPANT', array('_GUID' => '0c5e080d0afb29814a6e3059f0204ad1', 'PROFILE_URL' => $profile_url, 'ID' => '__id__', 'ROOM_ID' => '__room_id__', 'USERNAME' => '__username__', 'ONLINE' => '__online__', 'AVATAR_URL' => '__avatar_url__', 'MAKE_BUDDY_URL' => $make_buddy_url, 'BLOCK_MEMBER_URL' => $block_member_url));
         $_value = do_template('CHAT_SITEWIDE_IM', array('_GUID' => '5ab0404b3dac4578e8b4be699bd43c95', 'IM_AREA_TEMPLATE' => $im_area_template, 'IM_PARTICIPANT_TEMPLATE' => $im_participant_template, 'CHAT_SOUND' => get_chat_sound_tpl()));
         $value = $_value->evaluate();
     }
     return $value;
 }
예제 #13
0
 /**
  * Standard aed_module run_start.
  *
  * @param  ID_TEXT		The type of module execution
  * @return tempcode		The output of the run
  */
 function run_start($type)
 {
     $this->cat_aed_module = new Module_cms_catalogues_cat();
     $this->alt_aed_module = new Module_cms_catalogues_alt();
     $GLOBALS['MODULE_CMS_CATALOGUES'] = $this;
     if (get_value('disable_cat_cat_perms') === '1') {
         $this->permissions_cat_require_b = NULL;
         $this->permissions_cat_name_b = NULL;
         $this->cat_aed_module->permissions_cat_require = NULL;
         $this->cat_aed_module->permissions_cat_name = NULL;
     }
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_catalogues';
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/catalogues';
     require_lang('catalogues');
     require_lang('fields');
     require_code('catalogues');
     if ($type == 'add_catalogue') {
         require_javascript('javascript_ajax');
         $script = find_script('snippet');
         $this->alt_aed_module->javascript .= "\n\t\t\t\tvar form=document.getElementById('new_field_0_name').form;\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_catalogue&name='+window.encodeURIComponent(form.elements['name'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t";
     }
     // Decide what to do
     if ($type == 'misc') {
         return $this->misc();
     }
     if ($type == 'import') {
         return $this->import_catalogue();
     }
     if ($type == '_import') {
         return $this->_import_catalogue();
     }
     if ($type == 'export') {
         return $this->export_catalogue();
     }
     return new ocp_tempcode();
 }
/**
 * Helper function to work out a results browser URL.
 *
 * @param  array			Map of GET array segments to use (others will be added by this function)
 * @param  array			Map of POST array segments (relayed as GET) to use
 * @param  ?ID_TEXT		The page type this browser is browsing through (e.g. 'category') (NULL: none)
 * @param  ?mixed			The virtual root category this browser uses (NULL: no such concept for our results browser)
 * @param  ?mixed			The category ID we are browsing in (NULL: not applicable)
 * @param  boolean		Whether to keep get data when browsing through
 * @param  ID_TEXT		Hash component to URL
 * @return mixed			The URL
 */
function _build_results_browser_cat_url($url_array, $post_array, $type, $root, $category_id, $keep_all, $hash)
{
    if (!is_null($category_id)) {
        if (!is_string($category_id)) {
            $category_id = strval($category_id);
        }
    }
    $url_array = array_merge($url_array, $post_array);
    if (!is_null($type)) {
        $url_array['type'] = $type;
    }
    if (!is_null($root)) {
        $url_array['root'] = $root;
    }
    if (!is_null($category_id)) {
        $url_array['id'] = $category_id;
        $url_array['kfs' . $category_id] = NULL;
        // For OCF. We don't need this anymore because we're using 'start' explicitly here
    }
    if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
        $cat_url = make_string_tempcode(find_script('iframe') . '?zone=' . get_zone_name());
        if ($keep_all) {
            $url_array = array_merge($_GET, $_POST, $url_array);
        }
        foreach ($url_array as $key => $param) {
            if ($key == 'wide_high') {
                continue;
            }
            if (is_array($param)) {
                continue;
            }
            if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                continue;
            }
            if ($param === '_SELF') {
                $param = get_page_name();
            }
            if (get_magic_quotes_gpc()) {
                $param = stripslashes($param);
            }
            if ($key != 'zone') {
                $cat_url->attach('&' . $key . '=' . urlencode($param));
            }
        }
    } else {
        $cat_url = build_url($url_array, '_SELF', NULL, $keep_all, false, false, $hash);
    }
    return $cat_url;
}
예제 #15
0
/**
 * Get tempcode for a Comcode rich-media attachment.
 *
 * @param  ID_TEXT		The attachment tag
 * @set attachment attachment_safe attachment2
 * @param  array			A map of the attributes (name=>val) for the tag
 * @param  array			A map of the attachment properties (name=>val) for the attachment
 * @param  string			A special identifier to mark where the resultant tempcode is going to end up (e.g. the ID of a post)
 * @param  MEMBER			The member who is responsible for this Comcode
 * @param  boolean		Whether to check as arbitrary admin
 * @param  object			The database connection to use
 * @param  ?array			A list of words to highlight (NULL: none)
 * @param  ?MEMBER		The member we are running on behalf of, with respect to how attachments are handled; we may use this members attachments that are already within this post, and our new attachments will be handed to this member (NULL: member evaluating)
 * @param  boolean		Whether to parse so as to create something that would fit inside a semihtml tag. It means we generate HTML, with Comcode written into it where the tag could never be reverse-converted (e.g. a block).
 * @return tempcode		The tempcode for the attachment
 */
function render_attachment($tag, $attributes, $attachment, $pass_id, $source_member, $as_admin, $connection, $highlight_bits = NULL, $on_behalf_of_member = NULL, $semiparse_mode = false)
{
    require_code('comcode_renderer');
    $extension = get_file_extension($attachment['a_original_filename']);
    require_code('mime_types');
    $mime_type = get_mime_type($extension);
    $attachment['CLEAN_SIZE'] = clean_file_size($attachment['a_file_size']);
    $attachment['MIME_TYPE'] = $mime_type;
    $attachment['PASS_ID'] = intval($pass_id) < 0 ? strval(mt_rand(0, 10000)) : $pass_id;
    $attachment['SCRIPT'] = find_script('attachment');
    $attachment['RAND'] = strval(mt_rand(0, 32000));
    if ($connection->connection_write != $GLOBALS['SITE_DB']->connection_write) {
        $attachment['SUP_PARAMS'] = '&forum_db=1';
        $attachment['FORUM_DB_BIN'] = '1';
    } else {
        $attachment['SUP_PARAMS'] = '';
        $attachment['FORUM_DB_BIN'] = '';
    }
    $type = trim(array_key_exists('type', $attributes) ? $attributes['type'] : 'auto');
    $attachment['id'] = strval($attachment['id']);
    $attachment['a_member_id'] = strval($attachment['a_member_id']);
    $attachment['a_file_size'] = strval($attachment['a_file_size']);
    $attachment['a_last_downloaded_time'] = is_null($attachment['a_last_downloaded_time']) ? '' : strval($attachment['a_last_downloaded_time']);
    $attachment['a_add_time'] = strval($attachment['a_add_time']);
    $attachment['a_num_downloads'] = integer_format($attachment['a_num_downloads']);
    require_code('images');
    $attachment['a_width'] = array_key_exists('width', $attributes) ? strval(intval($attributes['width'])) : '';
    $attachment['a_height'] = array_key_exists('height', $attributes) ? strval(intval($attributes['height'])) : '';
    if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
        if (addon_installed('galleries') && is_video($attachment['a_original_filename']) && url_is_local($attachment['a_url'])) {
            require_code('galleries2');
            $vid_details = get_video_details(get_custom_file_base() . '/' . rawurldecode($attachment['a_url']), $attachment['a_original_filename'], true);
            if ($vid_details !== false) {
                list($_width, $_height, ) = $vid_details;
                if ($attachment['a_width'] == '') {
                    $attachment['a_width'] = strval($_width);
                }
                if ($attachment['a_height'] == '') {
                    $attachment['a_height'] = strval($_height);
                }
            }
        }
        if ($attachment['a_width'] == '' || $attachment['a_height'] == '') {
            if ($attachment['a_width'] == '') {
                $attachment['a_width'] = '240';
            }
            if ($attachment['a_height'] == '') {
                $attachment['a_height'] = '216';
            }
        }
    }
    $attachment['a_align'] = array_key_exists('align', $attributes) ? $attributes['align'] : 'left';
    if (!array_key_exists('a_description', $attachment)) {
        if (array_key_exists('description', $attributes)) {
            $attachment['description'] = $attributes['description'];
        }
        if (!array_key_exists('description', $attachment)) {
            $attachment['description'] = '';
        }
        $attachment['a_description'] = is_object($attachment['description']) ? $attachment['description'] : comcode_to_tempcode($attachment['description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
    } else {
        $attachment['a_description'] = comcode_to_tempcode($attachment['a_description'], $source_member, $as_admin, 60, NULL, $connection, false, false, false, false, false, NULL, $on_behalf_of_member);
    }
    $attachment['a_type'] = $type;
    $attachment['a_thumb'] = array_key_exists('thumb', $attributes) ? $attributes['thumb'] : '1';
    if ($attachment['a_thumb'] != '0') {
        $attachment['a_thumb'] = '1';
    }
    $attachment['a_thumb_url'] = array_key_exists('thumb_url', $attributes) ? $attributes['thumb_url'] : $attachment['a_thumb_url'];
    switch ($type) {
        case 'email':
            require_code('mail');
            global $EMAIL_ATTACHMENTS;
            if (url_is_local($attachment['a_url'])) {
                $attachment['a_url'] = get_custom_base_url() . '/' . $attachment['a_url'];
            }
            $EMAIL_ATTACHMENTS[$attachment['a_url']] = $attachment['a_original_filename'];
            $temp_tpl = new ocp_tempcode();
            break;
        case 'code':
            $url = $attachment['a_url'];
            if (url_is_local($url)) {
                $url = get_custom_base_url() . '/' . $url;
            }
            $file_contents = http_download_file($url, 1024 * 1024 * 20);
            list($_embed, $title) = do_code_box($extension, make_string_tempcode($file_contents));
            if ($attachment['a_original_filename'] != '') {
                $title = escape_html($attachment['a_original_filename']);
            }
            $temp_tpl = do_template('COMCODE_CODE', array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'STYLE' => '', 'TYPE' => $extension, 'CONTENT' => $_embed, 'TITLE' => $title));
            break;
        case 'hyperlink':
            if ($tag == 'attachment') {
                $keep = symbol_tempcode('KEEP');
                $_url = new ocp_tempcode();
                $_url->attach(find_script('attachment') . '?id=' . urlencode($attachment['id']) . $keep->evaluate());
                if (get_option('anti_leech') == '1') {
                    $_url->attach('&for_session=');
                    $_url->attach(symbol_tempcode('SESSION_HASHED'));
                }
            } else {
                $url = $attachment['a_url'];
                if (url_is_local($url)) {
                    $url = get_custom_base_url() . '/' . $url;
                }
                $_url = make_string_tempcode($url);
            }
            $temp_tpl = hyperlink($_url, is_object($attachment['a_description']) ? $attachment['a_description']->evaluate() : $attachment['a_description'] != '' ? $attachment['a_description'] : $attachment['a_original_filename'], true);
            break;
        default:
            if (is_image($attachment['a_original_filename'])) {
                if ($type == 'inline' || $type == 'left_inline' || $type == 'right_inline') {
                    $attachment['mini'] = '1';
                }
                require_code('images');
                ensure_thumbnail($attachment['a_url'], $attachment['a_thumb_url'], 'attachments', 'attachments', intval($attachment['id']), 'a_thumb_url');
                $temp_tpl = do_template('ATTACHMENT_IMG' . (array_key_exists('mini', $attachment) && $attachment['mini'] == '1' ? '_MINI' : ''), map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                if ($type == 'left' || $type == 'left_inline') {
                    $temp_tpl = do_template('ATTACHMENT_LEFT', array('_GUID' => 'aee2a6842d369c8dae212c3478a3a3e9', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl));
                }
                if ($type == 'right' || $type == 'right_inline') {
                    $temp_tpl = do_template('ATTACHMENT_RIGHT', array('_GUID' => '1a7209d67d91db740c86e7a331720195', 'WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true, 'CONTENT' => $temp_tpl));
                }
                break;
            } elseif ($extension == 'swf') {
                $temp_tpl = do_template('ATTACHMENT_SWF', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif (addon_installed('jwplayer') && ($mime_type == 'video/x-flv' || $mime_type == 'video/mp4' || $mime_type == 'video/webm')) {
                $temp_tpl = do_template('ATTACHMENT_FLV', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif ($mime_type == 'video/quicktime') {
                $temp_tpl = do_template('ATTACHMENT_QT', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif ($mime_type == 'audio/x-pn-realaudio') {
                $temp_tpl = do_template('ATTACHMENT_RM', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            } elseif (substr($mime_type, 0, 5) == 'video' || substr($mime_type, 0, 5) == 'audio') {
                $temp_tpl = do_template('ATTACHMENT_MEDIA', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
                break;
            }
            // Continues on, as it's not a media type...
        // Continues on, as it's not a media type...
        case 'download':
            if (is_null($attachment['a_file_size'])) {
                $temp_tpl = do_template('ATTACHMENT_DOWNLOAD_REMOTE', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
            } else {
                $temp_tpl = do_template('ATTACHMENT_DOWNLOAD', map_keys_to_upper($attachment) + array('WYSIWYG_SAFE' => $tag == 'attachment' ? NULL : true));
            }
            break;
    }
    return $temp_tpl;
}
예제 #16
0
 /**
  * The UI to show a video.
  *
  * @param  ?string		Alternate category name to use (NULL: use standard one). This is useful if you are overriding this code to show images in virtual galleries.
  * @param  ?tempcode		Breadcrumbs (NULL: derive in this function).
  * @return tempcode		The UI
  */
 function show_video($category_name = NULL, $tree = NULL)
 {
     $id = get_param_integer('id');
     if (get_param_integer('ajax', 0) == 1) {
         header('Content-type: text/xml');
     }
     list($sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos) = $this->get_sort_order();
     if (addon_installed('awards')) {
         require_code('awards');
         $awards = find_awards_for('video', strval($id));
     } else {
         $awards = array();
     }
     // Pic up some info
     $rows = $GLOBALS['SITE_DB']->query_select('videos', array('*'), array('id' => $id), '', 1);
     if (!array_key_exists(0, $rows)) {
         return warn_screen(get_page_title('ERROR_OCCURRED'), do_lang_tempcode('MISSING_RESOURCE'));
     }
     $myrow = $rows[0];
     $url = $myrow['url'];
     if (url_is_local($url)) {
         $url = get_custom_base_url() . '/' . $url;
     }
     $cat = $myrow['cat'];
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=galleries&filter=' . urlencode($cat);
     if (get_value('no_individual_gallery_view') === '1' && $GLOBALS['SITE_DB']->query_value('galleries', 'flow_mode_interface', array('name' => $cat)) == '1') {
         require_code('site2');
         assign_refresh(build_url(array('page' => '_SELF', 'type' => 'misc', 'id' => $cat, 'probe_id' => $id, 'probe_type' => 'video'), '_SELF'), 0.0);
     }
     $true_category_name = get_translated_text($GLOBALS['SITE_DB']->query_value('galleries', 'fullname', array('name' => $cat)));
     if (is_null($category_name)) {
         $category_name = $true_category_name;
     }
     if (get_param_integer('slideshow', 0) == 1) {
         $title = get_page_title('VIEW_SLIDESHOW', true, array(escape_html($category_name)));
         global $EXTRA_HEAD;
         $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
         // XHTMLXHTML
     } else {
         $title = get_page_title(get_translated_text($myrow['title']) == '' ? 'VIEW_VIDEO' : '_VIEW_VIDEO', true, array(escape_html(get_translated_text($myrow['title']))), NULL, $awards);
     }
     $root = get_param('root', 'root');
     seo_meta_load_for('video', strval($id));
     $thumb_url = $myrow['thumb_url'];
     if (url_is_local($thumb_url)) {
         $thumb_url = get_custom_base_url() . '/' . $thumb_url;
     }
     if (!has_category_access(get_member(), 'galleries', $cat)) {
         access_denied('CATEGORY_ACCESS');
     }
     // Views
     if (get_db_type() != 'xml') {
         $myrow['video_views']++;
         $GLOBALS['SITE_DB']->query_update('videos', array('video_views' => $myrow['video_views']), array('id' => $id), '', 1, NULL, false, true);
     }
     list($rating_details, $comment_details, $trackback_details) = embed_feedback_systems('videos', strval($id), $myrow['allow_rating'], $myrow['allow_comments'], $myrow['allow_trackbacks'], $myrow['validated'], $myrow['submitter'], build_url(array('page' => '_SELF', 'type' => 'video', 'id' => $id), '_SELF', NULL, false, false, true), get_translated_text($myrow['title']) == '' ? do_lang('VIEW_VIDEO_IN', $true_category_name) : get_translated_text($myrow['title']), get_value('comment_forum__videos'));
     // Validation
     if ($myrow['validated'] == 0) {
         if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
             access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
         }
         $warning_details = do_template('WARNING_TABLE', array('_GUID' => 'b32faacba974e648a67e5e91ffd3d8e5', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     // Comments
     $comments = get_translated_tempcode($myrow['comments']);
     if (has_actual_page_access(NULL, 'cms_galleries', NULL, NULL) && has_edit_permission('mid', get_member(), $myrow['submitter'], 'cms_galleries', array('galleries', $cat))) {
         $edit_url = build_url(array('page' => 'cms_galleries', 'type' => '_ev', 'id' => $id), get_module_zone('cms_galleries'));
     } else {
         $edit_url = new ocp_tempcode();
     }
     $add_date = get_timezoned_date($myrow['add_date']);
     $edit_date = is_null($myrow['edit_date']) ? '' : get_timezoned_date($myrow['edit_date']);
     // Video HTML
     $video = show_gallery_media($url, $thumb_url, $myrow['video_width'], $myrow['video_height'], $myrow['video_length']);
     $extension = get_file_extension($url);
     require_code('mime_types');
     $mime_type = get_mime_type($extension);
     list($n, $x, $nav) = $this->build_set_navigation(db_string_equal_to('cat', $cat), '', $category_name, $id, $root, 'video', get_param_integer('slideshow', 0), get_param_integer('wide_high', 0), get_param_integer('start', 0), get_param_integer('max', get_default_gallery_max()), $cat, $sort, $sort_backwards, $sql_suffix_images, $sql_suffix_videos, get_param('select', '*'), get_param('video_select', '*'));
     $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);
     $video_details = show_video_details($myrow);
     if (is_null($tree)) {
         $tree = gallery_breadcrumbs($cat, $root, false, get_module_zone('galleries'));
     }
     breadcrumb_add_segment($tree, do_lang_tempcode('VIEW_VIDEO'));
     $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $myrow['add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($myrow['submitter']), 'publisher' => '', 'modified' => is_null($myrow['edit_date']) ? '' : date('Y-m-d', $myrow['edit_date']), 'type' => 'Video', 'title' => get_translated_text($myrow['title']), 'identifier' => '_SEARCH:galleries:video:' . strval($id), 'description' => get_translated_text($myrow['comments']), 'image' => $thumb_url, 'video' => $url, 'video:height' => strval($myrow['video_height']), 'video:width' => strval($myrow['video_width']), 'video:type' => $mime_type);
     return do_template('GALLERY_ENTRY_SCREEN', array('_GUID' => '91e231906ed899513ec2db8a2974dddf', 'MEDIA_TYPE' => 'video', 'E_TITLE' => get_translated_text($myrow['title']), 'CAT' => $cat, 'SLIDESHOW' => get_param_integer('slideshow', 0) == 1, 'TRUE_GALLERY_TITLE' => $true_category_name, 'GALLERY_TITLE' => $category_name, 'MEMBER_ID' => is_null($member_id) ? '' : strval($member_id), 'ID' => strval($id), 'TAGS' => get_loaded_tags('videos'), 'TITLE' => $title, 'SUBMITTER' => strval($myrow['submitter']), 'URL' => $url, 'VIDEO_DETAILS' => $video_details, 'MEMBER_DETAILS' => $member_details, 'X' => integer_format($x), 'N' => integer_format($n), 'VIEWS' => integer_format($myrow['video_views']), 'ADD_DATE_RAW' => strval($myrow['add_date']), 'EDIT_DATE_RAW' => is_null($myrow['edit_date']) ? '' : strval($myrow['edit_date']), 'ADD_DATE' => $add_date, 'EDIT_DATE' => $edit_date, 'RATING_DETAILS' => $rating_details, 'TRACKBACK_DETAILS' => $trackback_details, 'COMMENT_DETAILS' => $comment_details, 'EDIT_URL' => $edit_url, 'NAV' => $nav, 'COMMENTS' => $comments, 'VIDEO' => $video, 'WARNING_DETAILS' => $warning_details));
 }
예제 #17
0
 /**
  * Standard modular UI to choose an entry to edit.
  *
  * @return tempcode	The UI
  */
 function ed()
 {
     if (!is_null($this->permissions_require) && is_null($this->permissions_cat_require)) {
         check_some_edit_permission($this->permissions_require, NULL, $this->permission_page_name);
     }
     $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);
     $test = $this->choose_catalogue($title);
     if (!is_null($test)) {
         return $test;
     }
     $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST'));
     $next_type = '_e' . $this->type_code;
     if (get_param('type', 'ed') == 'edit_catalogue') {
         $next_type = '_edit_catalogue';
     }
     $map = array('page' => '_SELF', 'type' => $next_type);
     if (either_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = either_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');
     }
     $description = $this->select_name_description != '' ? do_lang_tempcode($this->select_name_description) : new ocp_tempcode();
     if (method_exists($this, 'nice_get_radio_entries')) {
         $entries = $this->nice_get_radio_entries();
         if ($entries->is_empty()) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $fields = form_input_radio(do_lang_tempcode($this->select_name), $description, 'id', $entries, $this->no_blank_ids, true, '');
     } elseif (method_exists($this, 'nice_get_ajax_tree') && ($_fields = $this->nice_get_ajax_tree()) !== NULL) {
         if (is_array($_fields)) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_fields[1]->evaluate()), escape_html($_fields[2]->evaluate())));
             $fields = $_fields[0];
         } else {
             $fields = $_fields;
         }
     } elseif (method_exists($this, 'nice_get_choose_table')) {
         list($test, ) = $this->get_entry_rows();
         if (count($test) == 0) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $table_result = $this->nice_get_choose_table($map);
         if (is_null($table_result)) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $table = $table_result[0];
         $has_ordering = $table_result[1];
         if (array_key_exists(2, $table_result) && !is_null($table_result[2])) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE_EXTRA', escape_html($table_result[2]->evaluate()), escape_html($table_result[3]->evaluate())));
         } else {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_TABLE'));
         }
         return do_template('TABLE_TABLE_SCREEN', array('TITLE' => $title, 'TEXT' => $text, 'TABLE' => $table, 'SUBMIT_NAME' => $has_ordering ? do_lang_tempcode('ORDER') : NULL, 'POST_URL' => get_self_url()));
     } else {
         $_entries = $this->nice_get_entries();
         if (is_array($_entries)) {
             $text = paragraph(do_lang_tempcode('CHOOSE_EDIT_LIST_EXTRA', escape_html($_entries[1]->evaluate()), escape_html($_entries[2]->evaluate())));
             $entries = $_entries[0];
         } else {
             $entries = $_entries;
         }
         if ($entries->is_empty()) {
             inform_exit(do_lang_tempcode($this->type_code == 'd' ? 'NO_ENTRIES' : 'NO_CATEGORIES'));
         }
         $fields = form_input_list(do_lang_tempcode($this->select_name), $description, 'id', $entries, NULL, true, $this->no_blank_ids);
     }
     $post_url = build_url($map, '_SELF', NULL, false, true);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     $submit_name = do_lang_tempcode('PROCEED');
     $keep = symbol_tempcode('KEEP');
     $iframe_url = NULL;
     if (!$this->special_edit_frontend && has_js()) {
         $iframe_url = find_script('iframe') . '?zone=' . get_zone_name() . '&wide_high=1&opens_below=1';
         foreach ($map as $key => $val) {
             $iframe_url .= '&' . $key . '=' . urlencode(str_replace('_SELF', get_page_name(), $val));
         }
         $iframe_url .= $keep->evaluate();
     }
     return do_template('FORM_SCREEN', array('_GUID' => '228a05e24253f324ea286ea8ac3d8b02' . get_class($this), 'GET' => true, 'IFRAME_URL' => $iframe_url, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'SKIP_VALIDATION' => true));
 }
예제 #18
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_forum_type() != 'ocf') {
         warn_exit(do_lang_tempcode('NO_OCF'));
     } else {
         ocf_require_all_forum_stuff();
     }
     require_code('ocf_topicview');
     require_css('ocf');
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'max';
     $NON_CANONICAL_PARAMS[] = 'start';
     $NON_CANONICAL_PARAMS[] = 'threaded';
     $start = get_param_integer('start', 0);
     $default_max = intval(get_option('forum_posts_per_page'));
     $max = get_param_integer('max', $default_max);
     if ($max == 0) {
         $max = $default_max;
     }
     if ($max == 0) {
         $max = 1;
     }
     if ($max > 30 && !has_specific_permission(get_member(), 'remove_page_split')) {
         $max = $default_max;
     }
     $first_unread_id = -1;
     global $NON_CANONICAL_PARAMS;
     foreach (array_keys($_GET) as $key) {
         if (substr($key, 0, 3) == 'kfs') {
             $NON_CANONICAL_PARAMS[] = $key;
         }
     }
     $type = get_param('type', 'misc');
     $id = get_param_integer('id', NULL);
     if (is_guest() && is_null($id)) {
         access_denied('NOT_AS_GUEST');
     }
     if ($type == 'findpost') {
         $post_id = get_param_integer('id');
         $redirect = find_post_id_url($post_id);
         require_code('site2');
         assign_refresh($redirect, 0.0);
         return do_template('REDIRECT_SCREEN', array('_GUID' => '76e6d34c20a4f5284119827e41c7752f', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
     } else {
         if ($type == 'first_unread') {
             $redirect = find_first_unread_url($id);
             require_code('site2');
             assign_refresh($redirect, 0.0);
             return do_template('REDIRECT_SCREEN', array('_GUID' => '12c5d16f60e8c4df03536d9a7a932528', 'URL' => $redirect, 'TITLE' => get_page_title('VIEW_TOPIC'), 'TEXT' => do_lang_tempcode('REDIRECTING')));
         }
     }
     if (!is_null($id)) {
         $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=ocf_topicview&filter=' . strval($id);
     }
     $view_poll_results = get_param_integer('view_poll_results', 0);
     // Mark as read
     if (!is_null($id)) {
         if (!is_guest()) {
             $GLOBALS['FORUM_DB']->query_delete('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id), '', 1);
             $GLOBALS['FORUM_DB']->query_insert('f_read_logs', array('l_member_id' => get_member(), 'l_topic_id' => $id, 'l_time' => time()), false, true);
             // race condition
         }
         $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics SET t_num_views=(t_num_views+1) WHERE id=' . strval((int) $id), 1, NULL, true);
     }
     // Load up topic info
     $topic_info = ocf_read_in_topic($id, $start, $max, $view_poll_results == 1);
     $GLOBALS['META_DATA'] += $topic_info['meta_data'];
     global $SEO_TITLE;
     $SEO_TITLE = do_lang('_VIEW_TOPIC', $topic_info['title']);
     // Render posts according to whether threaded or not
     $threaded = $topic_info['is_threaded'] == 1;
     $may_reply = array_key_exists('may_reply', $topic_info) && ($topic_info['is_open'] || array_key_exists('may_post_closed', $topic_info));
     if (!$threaded) {
         $GLOBALS['META_DATA']['description'] = $topic_info['description'];
         // Poster detail hooks
         $hooks = find_all_hooks('modules', 'topicview');
         $hook_objects = array();
         foreach (array_keys($hooks) as $hook) {
             require_code('hooks/modules/topicview/' . filter_naughty_harsh($hook));
             $object = object_factory('Hook_' . filter_naughty_harsh($hook), true);
             if (is_null($object)) {
                 continue;
             }
             $hook_objects[$hook] = $object;
         }
         // Render non-threaded
         $posts = new ocp_tempcode();
         $replied = false;
         if (is_null($topic_info['forum_id'])) {
             decache('side_ocf_personal_topics', array(get_member()));
             decache('_new_pp', array(get_member()));
         }
         $second_poster = $topic_info['first_poster'];
         foreach ($topic_info['posts'] as $array_id => $_postdetails) {
             if ($array_id == 0) {
                 $description = $topic_info['description'];
             } else {
                 $description = NULL;
             }
             if ($_postdetails['poster'] == get_member()) {
                 $replied = true;
             }
             if ($array_id == 1 && $start == 0 || $array_id == 0 && $start != 0) {
                 $second_poster = $_postdetails['poster'];
             }
             if (array_key_exists('last_edit_time', $_postdetails)) {
                 $last_edited = do_template('OCF_TOPIC_POST_LAST_EDITED', array('_GUID' => '77a28e8bc3cf2ec2211aafdb5ba192bf', 'LAST_EDIT_DATE_RAW' => is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']), 'LAST_EDIT_DATE' => $_postdetails['last_edit_time_string'], 'LAST_EDIT_PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['last_edit_by'], false, true), 'LAST_EDIT_USERNAME' => $_postdetails['last_edit_by_username']));
             } else {
                 $last_edited = new ocp_tempcode();
             }
             $last_edited_raw = array_key_exists('last_edit_time', $_postdetails) ? is_null($_postdetails['last_edit_time']) ? '' : strval($_postdetails['last_edit_time']) : '0';
             $is_spacer_post = $_postdetails['is_spacer_post'];
             // Post buttons
             $buttons = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $buttons = ocf_render_post_buttons($topic_info, $_postdetails, $may_reply);
             }
             // Avatar
             if (array_key_exists('poster_avatar', $_postdetails) && $_postdetails['poster_avatar'] != '') {
                 $post_avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => 'd647ada9c11d56eedc0ff7894d33e83c', 'AVATAR' => $_postdetails['poster_avatar']));
             } else {
                 $post_avatar = new ocp_tempcode();
             }
             // Rank images
             $rank_images = new ocp_tempcode();
             if (!$is_spacer_post) {
                 $posters_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($_postdetails['poster'], true);
                 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 == $GLOBALS['FORUM_DRIVER']->get_member_row_field($_postdetails['poster'], 'm_primary_group'))) {
                         $rank_images->attach(do_template('OCF_RANK_IMAGE', array('_GUID' => '0ff7855482b901be95591964d4212c44', 'GROUP_NAME' => $group_name, 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($_postdetails['poster']), 'IMG' => $rank_image, 'IS_LEADER' => $group_leader == $_postdetails['poster'])));
                     }
                 }
             }
             // Poster details
             if (!$is_spacer_post) {
                 if (!is_guest($_postdetails['poster'])) {
                     require_code('ocf_members2');
                     $poster_details = ocf_show_member_box($_postdetails, false, $hooks, $hook_objects, false);
                 } else {
                     $custom_fields = new ocp_tempcode();
                     if (array_key_exists('ip_address', $_postdetails)) {
                         $custom_fields->attach(do_template('OCF_TOPIC_POST_CUSTOM_FIELD', array('_GUID' => 'd85be094dff0d039a64120d6f8f381bb', 'NAME' => do_lang_tempcode('IP_ADDRESS'), 'VALUE' => $_postdetails['ip_address'])));
                         $poster_details = do_template('OCF_GUEST_DETAILS', array('_GUID' => 'e43534acaf598008602e8da8f9725f38', 'CUSTOM_FIELDS' => $custom_fields));
                     } else {
                         $poster_details = new ocp_tempcode();
                     }
                 }
             } else {
                 $poster_details = new ocp_tempcode();
             }
             if (!is_guest($_postdetails['poster'])) {
                 $poster = do_template('OCF_POSTER_MEMBER', array('_GUID' => 'dbbed1850b6c01a6c9601d85c6aee43f', 'ONLINE' => member_is_online($_postdetails['poster']), 'ID' => strval($_postdetails['poster']), 'POSTER_DETAILS' => $poster_details, 'PROFILE_URL' => $GLOBALS['FORUM_DRIVER']->member_profile_url($_postdetails['poster'], false, true), 'POSTER_USERNAME' => $_postdetails['poster_username'], 'HIGHLIGHT_NAME' => array_key_exists('poster_highlighted_name', $_postdetails) ? strval($_postdetails['poster_highlighted_name']) : NULL));
             } else {
                 $ip_link = array_key_exists('ip_address', $_postdetails) && has_actual_page_access(get_member(), 'admin_lookup') ? build_url(array('page' => 'admin_lookup', 'param' => $_postdetails['ip_address']), get_module_zone('admin_lookup')) : new ocp_tempcode();
                 $poster = do_template('OCF_POSTER_GUEST', array('_GUID' => '36a8e550222cdac5165ef8f722be3def', 'IP_LINK' => $ip_link, 'POSTER_DETAILS' => $poster_details, 'POSTER_USERNAME' => $_postdetails['poster_username']));
             }
             // Signature
             $signature = new ocp_tempcode();
             if (array_key_exists('signature', $_postdetails) && !$_postdetails['signature']->is_empty()) {
                 $signature = $_postdetails['signature'];
             }
             $post_title = $_postdetails['title'];
             $first_unread = $_postdetails['id'] == $first_unread_id || $first_unread_id < 0 && $array_id == count($topic_info['posts']) - 1 ? do_template('OCF_TOPIC_FIRST_UNREAD') : new ocp_tempcode();
             $unvalidated = $_postdetails['validated'] == 0 ? do_lang_tempcode('UNVALIDATED') : new ocp_tempcode();
             $post_url = $GLOBALS['FORUM_DRIVER']->post_url($_postdetails['id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
             if (array_key_exists('intended_solely_for', $_postdetails) && $_postdetails['intended_solely_for'] == get_member()) {
                 decache('side_ocf_personal_topics', array(get_member()));
                 decache('_new_pp', array(get_member()));
             }
             $emphasis = ocf_get_post_emphasis($_postdetails);
             require_code('feedback');
             if (!array_key_exists('intended_solely_for', $_postdetails)) {
                 actualise_rating(true, 'post', strval($_postdetails['id']), get_self_url(), $_postdetails['title']);
                 $rating = display_rating(get_self_url(), $_postdetails['title'], 'post', strval($_postdetails['id']), 'RATING_INLINE_DYNAMIC', $_postdetails['poster']);
             } else {
                 $rating = new ocp_tempcode();
             }
             $rendered_post = do_template('OCF_TOPIC_POST', array('_GUID' => 'sacd09wekfofpw2f', 'ID' => $is_spacer_post ? '' : strval($_postdetails['id']), 'TOPIC_FIRST_POST_ID' => is_null($topic_info['first_post_id']) ? '' : strval($topic_info['first_post_id']), 'TOPIC_FIRST_POSTER' => is_null($topic_info['first_poster']) ? '' : strval($topic_info['first_poster']), 'POST_ID' => $is_spacer_post ? '' : (get_value('seq_post_ids') === '1' ? strval($start + $array_id + 1) : strval($_postdetails['id'])), 'URL' => $post_url, 'CLASS' => $_postdetails['is_emphasised'] ? 'ocf_post_emphasis' : (array_key_exists('intended_solely_for', $_postdetails) ? 'ocf_post_personal' : ''), 'EMPHASIS' => $emphasis, 'FIRST_UNREAD' => $first_unread, 'POSTER_TITLE' => $is_spacer_post ? '' : $_postdetails['poster_title'], 'POST_TITLE' => $post_title, 'POST_DATE_RAW' => strval($_postdetails['time']), 'POST_DATE' => $_postdetails['time_string'], 'POST' => $_postdetails['post'], 'TOPIC_ID' => is_null($id) ? '' : strval($id), 'LAST_EDITED_RAW' => $last_edited_raw, 'LAST_EDITED' => $last_edited, 'POSTER_ID' => strval($_postdetails['poster']), 'POSTER' => $is_spacer_post ? '' : $poster, 'POSTER_DETAILS' => $poster_details, 'POST_AVATAR' => $post_avatar, 'RANK_IMAGES' => $rank_images, 'BUTTONS' => $buttons, 'SIGNATURE' => $signature, 'UNVALIDATED' => $unvalidated, 'DESCRIPTION' => $description, 'RATING' => $rating));
             $posts->attach($rendered_post);
         }
         $serialized_options = mixed();
         $hash = mixed();
     } else {
         require_code('topics');
         $threaded_topic_ob = new OCP_Topic();
         // Load some settings into the renderer
         $threaded_topic_ob->first_post_id = $topic_info['first_post_id'];
         $threaded_topic_ob->topic_description = $topic_info['description'];
         $threaded_topic_ob->topic_description_link = $topic_info['description_link'];
         $threaded_topic_ob->topic_title = $topic_info['title'];
         $threaded_topic_ob->topic_info = $topic_info;
         // Other settings we need
         $max_thread_depth = intval(get_option('max_thread_depth'));
         $num_to_show_limit = get_param_integer('max_comments', intval(get_option('comments_to_show_in_thread')));
         // Load posts
         $threaded_topic_ob->load_from_topic($id, $num_to_show_limit, $start, false, NULL, true);
         $threaded_topic_ob->is_threaded = true;
         // Render posts
         list($posts, $serialized_options, $hash) = $threaded_topic_ob->render_posts($num_to_show_limit, $max_thread_depth, $may_reply, $topic_info['first_poster'], array(), $topic_info['forum_id'], NULL, false);
         $GLOBALS['META_DATA']['description'] = $threaded_topic_ob->topic_description;
         // Get other gathered details
         $replied = $threaded_topic_ob->replied;
         if (!is_null($threaded_topic_ob->topic_title)) {
             // Updated topic title
             $topic_info['title'] = $threaded_topic_ob->topic_title;
         }
         $topic_info['max_rows'] = $threaded_topic_ob->total_posts;
         $second_poster = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         // No definitive post orders
     }
     // Buttons for topic as whole
     $button_array = array();
     if (!is_null($id)) {
         if (get_value('no_threaded_buttons') !== '1') {
             if ($threaded) {
                 $view_as_linear_url = get_self_url(false, false, array('threaded' => 0));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_LINEAR'), 'url' => $view_as_linear_url, 'img' => 'linear');
             } else {
                 $view_as_threaded_url = get_self_url(false, false, array('threaded' => 1));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('VIEW_AS_THREADED'), 'url' => $view_as_threaded_url, 'img' => 'threaded');
             }
         }
         if (!is_guest()) {
             $too_old = $topic_info['last_time'] < time() - 60 * 60 * 24 * intval(get_option('post_history_days'));
             if (get_value('disable_mark_topic_unread') !== '1' && !$too_old) {
                 $map = array('page' => 'topics', 'type' => 'mark_unread_topic', 'id' => $id);
                 $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                 if ($test != -1 && $test != 0) {
                     $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                 }
                 $test = get_param_integer('threaded', -1);
                 if ($test != -1) {
                     $map['threaded'] = $test;
                 }
                 $mark_unread_url = build_url($map, get_module_zone('topics'));
                 $button_array[] = array('immediate' => true, 'title' => do_lang_tempcode('MARK_UNREAD'), 'url' => $mark_unread_url, 'img' => 'mark_unread');
             }
         }
         if ($may_reply && is_null(get_bot_type())) {
             $reply_prevented = false;
             // "Staff-only" reply for support tickets
             if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && addon_installed('tickets')) {
                 require_code('tickets');
                 if (is_ticket_forum($topic_info['forum_id'])) {
                     if (is_guest($second_poster)) {
                         $reply_prevented = true;
                     }
                     require_lang('tickets');
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id, 'intended_solely_for' => $GLOBALS['FORUM_DRIVER']->get_guest_id());
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('TICKET_STAFF_ONLY_REPLY'), 'url' => $new_post_url, 'img' => 'staff_only_reply');
                 }
             }
             if (!$reply_prevented) {
                 if ($topic_info['is_threaded'] == 0) {
                     $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
                     $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                     if ($test != -1 && $test != 0) {
                         $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                     }
                     $test = get_param_integer('threaded', -1);
                     if ($test != -1) {
                         $map['threaded'] = $test;
                     }
                     $new_post_url = build_url($map, get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode($topic_info['is_open'] ? 'REPLY' : 'CLOSED'), 'url' => $new_post_url, 'img' => $topic_info['is_open'] ? 'reply' : 'closed');
                 }
             } else {
                 unset($topic_info['may_use_quick_reply']);
             }
         } elseif ((is_null($topic_info['forum_id']) || has_specific_permission(get_member(), 'submit_lowrange_content', 'topics', array('forums', $topic_info['forum_id']))) && $topic_info['last_poster'] == get_member() && !is_guest() && ocf_may_edit_post_by(get_member(), $topic_info['forum_id'])) {
             $map = array('page' => 'topics', 'type' => 'edit_post', 'id' => $topic_info['last_post_id']);
             $test = get_param_integer('kfs' . strval($topic_info['forum_id']), -1);
             if ($test != -1 && $test != 0) {
                 $map['kfs' . strval($topic_info['forum_id'])] = $test;
             }
             $test = get_param_integer('threaded', -1);
             if ($test != -1) {
                 $map['threaded'] = $test;
             }
             $new_post_url = build_url($map, get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'rel' => 'edit', 'title' => do_lang_tempcode('LAST_POST'), 'url' => $new_post_url, 'img' => 'amend');
         }
         if (!is_null($topic_info['forum_id'])) {
             if (get_value('disable_add_topic_btn_in_topic') !== '1') {
                 if (ocf_may_post_topic($topic_info['forum_id'], get_member())) {
                     $new_topic_url = build_url(array('page' => 'topics', 'type' => 'new_topic', 'id' => $topic_info['forum_id']), get_module_zone('topics'));
                     $button_array[] = array('immediate' => false, 'rel' => 'add', 'title' => do_lang_tempcode('ADD_TOPIC'), 'url' => $new_topic_url, 'img' => 'new_topic');
                 }
             }
         } else {
             $invite_url = build_url(array('page' => 'topics', 'type' => 'invite_member', 'id' => $id), get_module_zone('topics'));
             $button_array[] = array('immediate' => false, 'title' => do_lang_tempcode('INVITE_MEMBER_TO_PT'), 'url' => $invite_url, 'img' => 'invite_member');
         }
     }
     $buttons = ocf_screen_button_wrap($button_array);
     // Poll
     if (array_key_exists('poll', $topic_info)) {
         $_poll = $topic_info['poll'];
         $voted_already = $_poll['voted_already'];
         $poll_results = array_key_exists(0, $_poll['answers']) && array_key_exists('num_votes', $_poll['answers'][0]);
         $answers = new ocp_tempcode();
         $real_button = false;
         if ($_poll['is_open']) {
             if ($poll_results) {
                 $button = new ocp_tempcode();
             } elseif ($_poll['requires_reply'] && !$replied) {
                 $button = do_lang_tempcode('POLL_REQUIRES_REPLY');
             } else {
                 if (!has_specific_permission(get_member(), 'vote_in_polls') || is_guest()) {
                     $button = do_lang_tempcode('VOTE_DENIED');
                 } else {
                     if (!is_null($voted_already)) {
                         $button = do_lang_tempcode('NOVOTE');
                     } else {
                         require_lang('polls');
                         $map = array('page' => 'topicview', 'id' => $id, 'view_poll_results' => 1, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
                         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
                         if ($test != -1 && $test != 0) {
                             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
                         }
                         $test = get_param_integer('threaded', -1);
                         if ($test != -1) {
                             $map['threaded'] = $test;
                         }
                         $results_url = build_url($map, get_module_zone('topics'));
                         $button = do_template('OCF_TOPIC_POLL_BUTTON', array('_GUID' => '94b932fd01028df8f67bb5864d9235f9', 'RESULTS_URL' => $results_url));
                         $real_button = true;
                     }
                 }
             }
         } else {
             $button = do_lang_tempcode('TOPIC_POLL_CLOSED');
         }
         foreach ($_poll['answers'] as $answer) {
             if ($poll_results && ($_poll['requires_reply'] == 0 || $replied)) {
                 $num_votes = $answer['num_votes'];
                 $total_votes = $_poll['total_votes'];
                 if ($total_votes != 0) {
                     $width = intval(round(70.0 * floatval($num_votes) / floatval($total_votes)));
                 } else {
                     $width = 0;
                 }
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER_RESULTS', array('_GUID' => 'b32f4c526e147abf20ca0d668e40d515', 'ID' => strval($_poll['id']), 'NUM_VOTES' => integer_format($num_votes), 'WIDTH' => strval($width), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             } else {
                 $answer_tpl = do_template('OCF_TOPIC_POLL_ANSWER' . ($_poll['maximum_selections'] == 1 ? '_RADIO' : ''), array('REAL_BUTTON' => $real_button, 'ID' => strval($_poll['id']), 'ANSWER' => $answer['answer'], 'I' => strval($answer['id'])));
             }
             $answers->attach($answer_tpl);
         }
         $map = array('page' => 'topics', 'type' => 'vote_poll', 'id' => $id, 'start' => $start == 0 ? NULL : $start, 'max' => $max == $default_max ? NULL : $max);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $vote_url = build_url($map, get_module_zone('topics'));
         if ($_poll['is_private']) {
             $private = paragraph(do_lang_tempcode('TOPIC_POLL_IS_PRIVATE'), 'dfgsdgdsgs');
         } else {
             $private = new ocp_tempcode();
         }
         if ($_poll['maximum_selections'] > 1) {
             $num_choices = paragraph($_poll['minimum_selections'] == $_poll['maximum_selections'] ? do_lang_tempcode('POLL_NOT_ENOUGH_ERROR_2', integer_format($_poll['minimum_selections'])) : do_lang_tempcode('POLL_NOT_ENOUGH_ERROR', integer_format($_poll['minimum_selections']), integer_format($_poll['maximum_selections'])), 'dsfsdfsdfs');
         } else {
             $num_choices = new ocp_tempcode();
         }
         $poll = do_template('OCF_TOPIC_POLL' . ($poll_results ? '_VIEW_RESULTS' : ''), array('ID' => strval($_poll['id']), 'NUM_CHOICES' => $num_choices, 'PRIVATE' => $private, 'QUESTION' => $_poll['question'], 'ANSWERS' => $answers, 'REAL_BUTTON' => $real_button, 'BUTTON' => $button, 'VOTE_URL' => $vote_url, 'MINIMUM_SELECTIONS' => integer_format($_poll['minimum_selections']), 'MAXIMUM_SELECTIONS' => integer_format($_poll['maximum_selections'])));
     } else {
         $poll = new ocp_tempcode();
     }
     // Forum nav tree
     if (!is_null($topic_info['forum_id'])) {
         $tree = ocf_forum_breadcrumbs($topic_info['forum_id'], NULL, NULL, false);
     } else {
         $tree = new ocp_tempcode();
         $tree->attach(hyperlink(build_url(array('page' => 'members'), get_module_zone('members')), do_lang_tempcode('MEMBERS'), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
         $tree->attach(do_template('BREADCRUMB_ESCAPED'));
         if (has_specific_permission(get_member(), 'view_other_pt')) {
             $of_member = $topic_info['pt_from'] == get_member() ? $topic_info['pt_from'] : $topic_info['pt_to'];
         } else {
             $of_member = get_member();
         }
         $of_username = $GLOBALS['FORUM_DRIVER']->get_username($of_member);
         if (is_null($of_username)) {
             $of_username = do_lang('UNKNOWN');
         }
         $personal_topic_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $of_member), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
         $tree->attach(hyperlink($personal_topic_url, do_lang_tempcode('MEMBER_PROFILE', escape_html($of_username)), false, false, do_lang_tempcode('GO_BACKWARDS_TO', do_lang_tempcode('MEMBERS')), NULL, NULL, 'up'));
     }
     // Quick reply
     if (array_key_exists('may_use_quick_reply', $topic_info) && $may_reply && !is_null($id)) {
         $map = array('page' => 'topics', 'type' => '_add_reply', 'topic_id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $_post_url = build_url($map, get_module_zone('topics'));
         $post_url = $_post_url->evaluate();
         $map = array('page' => 'topics', 'type' => 'new_post', 'id' => $id);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $more_url = build_url($map, get_module_zone('topics'));
         $_postdetails = array_key_exists('first_post', $topic_info) ? get_translated_tempcode($topic_info['first_post'], $GLOBALS['FORUM_DB']) : new ocp_tempcode();
         $first_post = $_postdetails;
         $first_post_url = $GLOBALS['FORUM_DRIVER']->post_url($topic_info['first_post_id'], is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']), true);
         $display = 'block';
         $expand_type = 'contract';
         if ($topic_info['max_rows'] > $start + $max) {
             $display = 'none';
             $expand_type = 'expand';
         }
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         require_javascript('javascript_validation');
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $post_warning = '';
         if ($topic_info['is_really_threaded'] == 1) {
             $post_warning = do_lang('THREADED_REPLY_NOTICE', $post_warning);
         }
         $quick_reply = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4c532620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'USE_CAPTCHA' => $use_captcha, 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => false, 'POST_WARNING' => $post_warning, 'COMMENT_TEXT' => '', 'EM' => $em, 'EXPAND_TYPE' => $expand_type, 'DISPLAY' => $display, 'FIRST_POST_URL' => $first_post_url, 'FIRST_POST' => $first_post, 'MORE_URL' => $more_url, 'COMMENT_URL' => $post_url, 'TITLE' => do_lang_tempcode('QUICK_REPLY'), 'SUBMIT_NAME' => do_lang_tempcode('MAKE_POST')));
     } else {
         $quick_reply = new ocp_tempcode();
     }
     $action_url = build_url(array('page' => 'topics', 'id' => $id), get_module_zone('topics'));
     if (!is_null($id)) {
         // Moderation options
         $moderator_actions = '';
         if (is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="categorise_pts">' . do_lang('_CATEGORISE_PTS') . '</option>';
         }
         if (array_key_exists('may_multi_moderate', $topic_info) && array_key_exists('forum_id', $topic_info)) {
             $multi_moderations = ocf_list_multi_moderations($topic_info['forum_id']);
             if (count($multi_moderations) != 0) {
                 $moderator_actions .= '<optgroup label="' . do_lang('MULTI_MODERATIONS') . '">';
                 foreach ($multi_moderations as $mm_id => $mm_name) {
                     $moderator_actions .= '<option value="mm_' . strval($mm_id) . '">' . $mm_name . '</option>';
                 }
                 $moderator_actions .= '</optgroup>';
             }
         }
         if (array_key_exists('may_move_topic', $topic_info)) {
             $moderator_actions .= '<option value="move_topic">' . do_lang('MOVE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_topic', $topic_info)) {
             $moderator_actions .= '<option value="edit_topic">' . do_lang('EDIT_TOPIC') . '</option>';
         }
         if (array_key_exists('may_delete_topic', $topic_info)) {
             $moderator_actions .= '<option value="delete_topic">' . do_lang('DELETE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_pin_topic', $topic_info)) {
             $moderator_actions .= '<option value="pin_topic">' . do_lang('PIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unpin_topic', $topic_info)) {
             $moderator_actions .= '<option value="unpin_topic">' . do_lang('UNPIN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_sink_topic', $topic_info)) {
             $moderator_actions .= '<option value="sink_topic">' . do_lang('SINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_unsink_topic', $topic_info)) {
             $moderator_actions .= '<option value="unsink_topic">' . do_lang('UNSINK_TOPIC') . '</option>';
         }
         if (array_key_exists('may_cascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="cascade_topic">' . do_lang('CASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_uncascade_topic', $topic_info)) {
             $moderator_actions .= '<option value="uncascade_topic">' . do_lang('UNCASCADE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_open_topic', $topic_info)) {
             $moderator_actions .= '<option value="open_topic">' . do_lang('OPEN_TOPIC') . '</option>';
         }
         if (array_key_exists('may_close_topic', $topic_info)) {
             $moderator_actions .= '<option value="close_topic">' . do_lang('CLOSE_TOPIC') . '</option>';
         }
         if (array_key_exists('may_edit_poll', $topic_info)) {
             $moderator_actions .= '<option value="edit_poll">' . do_lang('EDIT_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_delete_poll', $topic_info)) {
             $moderator_actions .= '<option value="delete_poll">' . do_lang('DELETE_TOPIC_POLL') . '</option>';
         }
         if (array_key_exists('may_attach_poll', $topic_info)) {
             $moderator_actions .= '<option value="add_poll">' . do_lang('ADD_TOPIC_POLL') . '</option>';
         }
         if (has_specific_permission(get_member(), 'view_content_history') && $GLOBALS['FORUM_DB']->query_value('f_post_history', 'COUNT(*)', array('h_topic_id' => $id)) != 0) {
             $moderator_actions .= '<option value="topic_history">' . do_lang('POST_HISTORY') . '</option>';
         }
         if (array_key_exists('may_make_personal', $topic_info) && !is_null($topic_info['forum_id'])) {
             $moderator_actions .= '<option value="make_personal">' . do_lang('MAKE_PERSONAL') . '</option>';
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($moderator_actions);
         }
         // Marked post actions
         $map = array('page' => 'topics', 'id' => $id);
         $test = get_param_integer('kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id'])), -1);
         if ($test != -1 && $test != 0) {
             $map['kfs' . (is_null($topic_info['forum_id']) ? '' : strval($topic_info['forum_id']))] = $test;
         }
         $test = get_param_integer('threaded', -1);
         if ($test != -1) {
             $map['threaded'] = $test;
         }
         $action_url = build_url($map, get_module_zone('topics'), NULL, false, true);
         $marked_post_actions = '';
         if (array_key_exists('may_move_posts', $topic_info)) {
             $marked_post_actions .= '<option value="move_posts_a">' . do_lang('MERGE_POSTS') . '</option>';
             $marked_post_actions .= '<option value="move_posts_b">' . do_lang('SPLIT_POSTS') . '</option>';
         }
         if (array_key_exists('may_delete_posts', $topic_info)) {
             $marked_post_actions .= '<option value="delete_posts">' . do_lang('DELETE_POSTS') . '</option>';
         }
         if (array_key_exists('may_validate_posts', $topic_info)) {
             $marked_post_actions .= '<option value="validate_posts">' . do_lang('VALIDATE_POSTS') . '</option>';
         }
         if (get_value('disable_multi_quote') !== '1') {
             if ($may_reply) {
                 $marked_post_actions .= '<option value="new_post">' . do_lang('QUOTE_POSTS') . '</option>';
             }
         }
         if ($GLOBALS['XSS_DETECT']) {
             ocp_mark_as_escaped($marked_post_actions);
         }
     } else {
         $moderator_actions = '';
         $marked_post_actions = '';
     }
     $max_rows = $topic_info['max_rows'];
     if ($max_rows > $max && !$threaded) {
         require_code('templates_results_browser');
         $results_browser = results_browser(do_lang_tempcode('FORUM_POSTS'), $id, $start, 'start', $max, 'max', $max_rows, NULL, 'misc', true, false, 7, array(10, 20, 30));
     } else {
         $results_browser = new ocp_tempcode();
     }
     // Members viewing this topic
     $members = is_null($id) ? array() : get_members_viewing('topicview', '', strval($id), true);
     $num_guests = 0;
     $num_members = 0;
     if (is_null($members)) {
         $members_viewing = new ocp_tempcode();
     } else {
         $members_viewing = new ocp_tempcode();
         foreach ($members as $member_id => $at_details) {
             $username = $at_details['mt_cache_username'];
             if (is_guest($member_id)) {
                 $num_guests++;
             } else {
                 $num_members++;
                 $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true);
                 $map = array('PROFILE_URL' => $profile_url, 'USERNAME' => $username);
                 if (has_specific_permission(get_member(), 'show_user_browsing') || in_array($at_details['the_page'], array('topics', 'topicview')) && $at_details['the_id'] == strval($id)) {
                     $map['AT'] = escape_html($at_details['the_title']);
                 }
                 $map['COLOUR'] = get_group_colour(ocf_get_member_primary_group($member_id));
                 $members_viewing->attach(do_template('OCF_USER_MEMBER', $map));
             }
         }
         if ($members_viewing->is_empty()) {
             $members_viewing = do_lang_tempcode('NONE_EM');
         }
     }
     if (!is_null($id)) {
         breadcrumb_add_segment($tree, do_lang_tempcode(is_null($topic_info['forum_id']) ? 'VIEW_PERSONAL_TOPIC' : 'VIEW_TOPIC'));
     }
     if (is_null($id)) {
         $root_forum_name = $GLOBALS['FORUM_DB']->query_value('f_forums', 'f_name', array('id' => db_get_first_id()));
         $tree = hyperlink(build_url(array('page' => 'forumview', 'id' => db_get_first_id()), get_module_zone('forumview')), escape_html($root_forum_name), false, false, do_lang('GO_BACKWARDS_TO'));
         breadcrumb_add_segment($tree, do_lang('INLINE_PERSONAL_POSTS'));
     }
     if ($topic_info['validated'] == 0) {
         $warning_details = do_template('WARNING_TABLE', array('WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
     } else {
         $warning_details = new ocp_tempcode();
     }
     $topic_tpl = do_template('OCF_TOPIC_WRAP', array('_GUID' => 'bb201d5d59559e5e2bd60e7cf2e6f7e9', 'SERIALIZED_OPTIONS' => $serialized_options, 'HASH' => $hash, 'ID' => strval($id), 'TITLE' => $topic_info['title'], 'MAY_DOUBLE_POST' => has_specific_permission(get_member(), 'double_post'), 'LAST_POSTER' => array_key_exists('last_poster', $topic_info) ? is_null($topic_info['last_poster']) ? '' : strval($topic_info['last_poster']) : '', 'WARNING_DETAILS' => $warning_details, 'MAX' => strval($max), 'MAY_CHANGE_MAX' => array_key_exists('may_change_max', $topic_info), 'ACTION_URL' => $action_url, 'NUM_GUESTS' => integer_format($num_guests), 'NUM_MEMBERS' => integer_format($num_members), 'MEMBERS_VIEWING' => $members_viewing, 'RESULTS_BROWSER' => $results_browser, 'MODERATOR_ACTIONS' => $moderator_actions, 'MARKED_POST_ACTIONS' => $marked_post_actions, 'QUICK_REPLY' => $quick_reply, 'TREE' => $tree, 'POLL' => $poll, 'SCREEN_BUTTONS' => $buttons, 'POSTS' => $posts, 'THREADED' => $threaded));
     if (is_null($id)) {
         $title = get_page_title('INLINE_PERSONAL_POSTS');
     } else {
         if (is_null($topic_info['forum_id'])) {
             $title = get_page_title(do_lang_tempcode('NAMED_PERSONAL_TOPIC', escape_html($topic_info['title'])), false, NULL, do_lang_tempcode('READING_PERSONAL_TOPIC'));
         } else {
             if (addon_installed('awards')) {
                 require_code('awards');
                 $awards = find_awards_for('topic', strval($id));
             } else {
                 $awards = array();
             }
             $title = get_page_title(do_lang_tempcode('NAMED_TOPIC', escape_html($topic_info['title'])), false, NULL, NULL, $awards);
         }
     }
     return ocf_wrapper($title, $topic_tpl, true, false, $topic_info['forum_id']);
 }
예제 #19
0
 /**
  * The main user interface for the file dump.
  *
  * @return tempcode	The UI.
  */
 function module_do_gui()
 {
     $title = get_page_title('FILE_DUMP');
     $place = filter_naughty(get_param('place', '/'));
     if (substr($place, -1, 1) != '/') {
         $place .= '/';
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=filedump&filter=' . $place;
     // Show tree
     $dirs = explode('/', substr($place, 0, strlen($place) - 1));
     $i = 0;
     $pre = '';
     $file_tree = new ocp_tempcode();
     while (array_key_exists($i, $dirs)) {
         if ($i > 0) {
             $d = $dirs[$i];
         } else {
             $d = do_lang('FILE_DUMP');
         }
         if (array_key_exists($i + 1, $dirs)) {
             $tree_url = build_url(array('page' => '_SELF', 'place' => $pre . $dirs[$i] . '/'), '_SELF');
             if (!$file_tree->is_empty()) {
                 $file_tree->attach(do_template('BREADCRUMB', array('_GUID' => '7ee62e230d53344a7d9667dc59be21c6')));
             }
             $file_tree->attach(hyperlink($tree_url, $d));
         }
         $pre .= $dirs[$i] . '/';
         $i++;
     }
     if (!$file_tree->is_empty()) {
         breadcrumb_add_segment($file_tree, $d);
     } else {
         breadcrumb_set_self($i == 1 ? do_lang_tempcode('FILE_DUMP') : make_string_tempcode(escape_html($d)));
     }
     // Check directory exists
     $fullpath = get_custom_file_base() . '/uploads/filedump' . $place;
     if (!file_exists(get_custom_file_base() . '/uploads/filedump' . $place)) {
         if (has_specific_permission(get_member(), 'upload_filedump')) {
             @mkdir($fullpath, 0777) or warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY', escape_html($fullpath), escape_html(dirname($fullpath))));
             fix_permissions($fullpath, 0777);
             sync_file($fullpath);
         }
     }
     // Find all files in the incoming directory
     $handle = opendir(get_custom_file_base() . '/uploads/filedump' . $place);
     $i = 0;
     $filename = array();
     $description = array();
     $filesize = array();
     $filetime = array();
     $directory = array();
     $deletable = array();
     while (false !== ($file = readdir($handle))) {
         if (!should_ignore_file('uploads/filedump' . $place . $file, IGNORE_ACCESS_CONTROLLERS | IGNORE_HIDDEN_FILES)) {
             $directory[$i] = !is_file(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             $filename[$i] = $directory[$i] ? $file . '/' : $file;
             if ($directory[$i]) {
                 $filesize[$i] = do_lang_tempcode('NA_EM');
             }
             $dbrows = $GLOBALS['SITE_DB']->query_select('filedump', array('description', 'the_member'), array('name' => $file, 'path' => $place));
             if (!array_key_exists(0, $dbrows)) {
                 $description[$i] = $directory[$i] ? do_lang_tempcode('NA_EM') : do_lang_tempcode('NONE_EM');
             } else {
                 $description[$i] = make_string_tempcode(escape_html(get_translated_text($dbrows[0]['description'])));
             }
             if ($description[$i]->is_empty()) {
                 $description[$i] = do_lang_tempcode('NONE_EM');
             }
             $deletable[$i] = array_key_exists(0, $dbrows) && $dbrows[0]['the_member'] == get_member() || has_specific_permission(get_member(), 'delete_anything_filedump');
             if ($directory[$i]) {
                 $size = get_directory_size(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = NULL;
             } else {
                 $size = filesize(get_custom_file_base() . '/uploads/filedump' . $place . $file);
                 $timestamp = filemtime(get_custom_file_base() . '/uploads/filedump' . $place . $file);
             }
             $filesize[$i] = clean_file_size($size);
             $filetime[$i] = is_null($timestamp) ? NULL : get_timezoned_date($timestamp);
             $i++;
         }
     }
     closedir($handle);
     if ($i != 0) {
         require_code('templates_table_table');
         $header_row = table_table_header_row(array(do_lang_tempcode('FILENAME'), do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('SIZE'), do_lang_tempcode('DATE_TIME'), do_lang_tempcode('ACTIONS')));
         $rows = new ocp_tempcode();
         for ($a = 0; $a < $i; $a++) {
             if ($directory[$a]) {
                 $link = build_url(array('page' => '_SELF', 'place' => $place . $filename[$a]), '_SELF');
             } else {
                 $link = make_string_tempcode(get_custom_base_url() . '/uploads/filedump' . str_replace('%2F', '/', rawurlencode($place . $filename[$a])));
             }
             if (!$directory[$a]) {
                 if ($deletable[$a]) {
                     $delete_url = build_url(array('page' => '_SELF', 'type' => 'ed', 'file' => $filename[$a], 'place' => $place), '_SELF');
                     $actions = do_template('TABLE_TABLE_ACTION_DELETE_ENTRY', array('_GUID' => '9b91e485d80417b1664145f9bca5a2f5', 'NAME' => $filename[$a], 'URL' => $delete_url));
                 } else {
                     $actions = new ocp_tempcode();
                 }
             } else {
                 $delete_url = build_url(array('page' => '_SELF', 'type' => 'ec', 'file' => $filename[$a], 'place' => $place), '_SELF');
                 $actions = do_template('TABLE_TABLE_ACTION_DELETE_CATEGORY', array('_GUID' => '0fa7d4090c6195328191399a14799169', 'NAME' => $filename[$a], 'URL' => $delete_url));
             }
             $rows->attach(table_table_row(array(hyperlink($link, escape_html($filename[$a]), !$directory[$a]), escape_html($description[$a]), escape_html($filesize[$a]), is_null($filetime[$a]) ? do_lang_tempcode('NA') : make_string_tempcode(escape_html($filetime[$a])), $actions)));
         }
         $files = do_template('TABLE_TABLE', array('_GUID' => '1c0a91d47c5fc8a7c2b35c7d9b36132f', 'HEADER_ROW' => $header_row, 'ROWS' => $rows));
     } else {
         $files = new ocp_tempcode();
     }
     // Do a form so people can upload their own stuff
     if (has_specific_permission(get_member(), 'upload_filedump')) {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ad', 'uploading' => 1), '_SELF');
         $submit_name = do_lang_tempcode('FILEDUMP_UPLOAD');
         $max = floatval(get_max_file_size());
         $text = new ocp_tempcode();
         if ($max < 30.0) {
             $config_url = get_upload_limit_config_url();
             $text->attach(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max / 1024.0 / 1024.0)), escape_html(is_null($config_url) ? '' : $config_url)));
         }
         require_code('form_templates');
         $fields = form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('_DESCRIPTION_UPLOAD'), 'file', true);
         $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', '', false));
         $hidden = new ocp_tempcode();
         $hidden->attach(form_input_hidden('place', $place));
         handle_max_file_size($hidden);
         $upload_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'HIDDEN' => $hidden, 'TEXT' => $text, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $upload_form = new ocp_tempcode();
     }
     // Do a form so people can make folders
     if (get_option('is_on_folder_create') == '1') {
         $post_url = build_url(array('page' => '_SELF', 'type' => 'ac'), '_SELF');
         require_code('form_templates');
         $fields = form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', '', true);
         $hidden = form_input_hidden('place', $place);
         $submit_name = do_lang_tempcode('FILEDUMP_CREATE_FOLDER');
         $create_folder_form = do_template('FORM', array('_GUID' => '043f9b595d3699b7d8cd7f2284cdaf98', 'TABINDEX' => strval(get_form_field_tabindex()), 'SKIP_REQUIRED' => true, 'SECONDARY_FORM' => true, 'HIDDEN' => $hidden, 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
     } else {
         $create_folder_form = new ocp_tempcode();
     }
     return do_template('FILE_DUMP_SCREEN', array('_GUID' => '3f49a8277a11f543eff6488622949c84', 'TITLE' => $title, 'PLACE' => $place, 'FILES' => $files, 'UPLOAD_FORM' => $upload_form, 'CREATE_FOLDER_FORM' => $create_folder_form));
 }
예제 #20
0
/**
 * Get tempcode for a download 'feature box' for the sgiven row
 *
 * @param  array			The database field row of this download
 * @param  boolean		Whether to show a picture
 * @param  boolean		Whether to show breadcrumbs
 * @param  ?ID_TEXT		The zone the download module we're using is in (NULL: find it)
 * @param  ?string		Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none)
 * @return tempcode		A box for this download, linking to the full download page
 */
function get_download_html($row, $pic = true, $breadcrumbs = true, $zone = NULL, $text_summary = NULL)
{
    require_css('downloads');
    if (is_null($zone)) {
        $zone = get_module_zone('downloads');
    }
    // Details
    $filesize = $row['file_size'];
    $filesize = $filesize > 0 ? clean_file_size($filesize) : do_lang('UNKNOWN');
    $description = get_translated_tempcode($row['description']);
    $root = get_param_integer('root', db_get_first_id(), true);
    $download_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $row['id'], 'root' => $root == db_get_first_id() ? NULL : $root), $zone);
    $date = get_timezoned_date($row['add_date'], false);
    $date_raw = $row['add_date'];
    $tree = get_option('show_dload_trees') == '1' && $breadcrumbs ? download_breadcrumbs($row['category_id'], NULL, false, $zone) : new ocp_tempcode();
    $pic_suffix = '';
    $thumb_url = '';
    $full_img_url = '';
    if (addon_installed('galleries') && $pic) {
        // Images
        $rows = $GLOBALS['SITE_DB']->query_select('images', array('url', 'thumb_url', 'id'), array('cat' => 'download_' . strval($row['id'])), '', 1, $row['default_pic'] - 1);
        if (array_key_exists(0, $rows)) {
            $pic_suffix = '_pic';
            require_code('images');
            $full_img_url = $rows[0]['url'];
            $thumb_url = ensure_thumbnail($rows[0]['url'], $rows[0]['thumb_url'], 'galleries', 'images', $rows[0]['id']);
            $imgcode = do_image_thumb($thumb_url, do_lang('DOWNLOAD_THUMBNAIL'));
        } else {
            $imgcode = new ocp_tempcode();
        }
    } else {
        $imgcode = new ocp_tempcode();
    }
    require_code('feedback');
    $rating = $row['allow_rating'] == 1 ? display_rating($download_url, get_translated_text($row['name']), 'downloads', strval($row['id']), 'RATING_INLINE_STATIC', $row['submitter']) : NULL;
    if (!is_null($rating)) {
        if (trim($rating->evaluate()) == '') {
            $rating = NULL;
        }
    }
    $licence_title = NULL;
    $licence_url = NULL;
    $licence_hyperlink = NULL;
    $licence = $row['download_licence'];
    if (!is_null($licence)) {
        $licence_title = $GLOBALS['SITE_DB']->query_value_null_ok('download_licences', 'l_title', array('id' => $licence));
        if (!is_null($licence_title)) {
            $keep = symbol_tempcode('KEEP');
            $licence_url = find_script('download_licence') . '?id=' . strval($licence) . $keep->evaluate();
            $licence_hyperlink = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => '10582f28c37ee7e9e462fdbd6a2cb8dd', 'TITLE' => '', 'CAPTION' => $licence_title, 'URL' => $licence_url, 'WIDTH' => '600', 'HEIGHT' => '500', 'REL' => 'license'));
        } else {
            $licence = NULL;
            // Orphaned
        }
    }
    // Final template
    if ($full_img_url != '' && url_is_local($full_img_url)) {
        $full_img_url = get_custom_base_url() . '/' . $full_img_url;
    }
    return do_template('DOWNLOAD_BOX', array('TEXT_SUMMARY' => $text_summary, 'AUTHOR' => $row['author'], 'ID' => strval($row['id']), 'RATING' => $rating, 'VIEWS' => integer_format($row['download_views']), 'SUBMITTER' => strval($row['submitter']), 'DESCRIPTION' => $description, 'FILE_SIZE' => $filesize, 'DOWNLOADS' => integer_format($row['num_downloads']), 'DATE_RAW' => strval($date_raw), 'DATE' => $date, 'EDIT_DATE_RAW' => is_null($row['edit_date']) ? '' : strval($row['edit_date']), 'SIZE' => $filesize, 'URL' => $download_url, 'NAME' => get_translated_text($row['name']), 'TREE' => $tree, 'IMG_URL' => $thumb_url, 'FULL_IMG_URL' => $full_img_url, 'IMGCODE' => $imgcode, 'LICENCE' => is_null($licence) ? NULL : strval($licence), 'LICENCE_TITLE' => $licence_title, 'LICENCE_HYPERLINK' => $licence_hyperlink));
}
예제 #21
0
/**
 * Get the tempcode for a results table title row. You would take the output of this, and feed it in as $fields_title, in a results_table function call.
 *
 * @param  array			The array of field titles that define the entries in the results table
 * @param  ?array			A map of sortable code (usually, db field names), to strings giving the human name for the sort order (NULL: no sortables)
 * @param  ID_TEXT		The parameter name used to store our sortable
 * @param  ID_TEXT		The current ordering ("$sortable $sort_order")
 * @param  string			GUID to pass to template
 * @return tempcode		The generated title
 */
function results_field_title($values, $sortables = NULL, $order_param = 'sort', $current_ordering = '', $guid = 'fbcaf8b021e3939bfce1dce9ff8ed63a')
{
    if (is_null($sortables)) {
        $sortables = array();
    }
    $cells = new ocp_tempcode();
    foreach ($values as $value) {
        $found = mixed();
        foreach ($sortables as $key => $sortable) {
            $_value = is_object($value) ? $value->evaluate() : $value;
            if (is_string($sortable) && $sortable == $_value || is_object($sortable) && $sortable->evaluate() == $_value) {
                $found = $key;
                break;
            }
        }
        if (!is_null($found)) {
            if (strpos(ocp_srv('REQUEST_URI'), '/iframe.php') !== false) {
                $cat_url = find_script('iframe') . '?zone=' . get_zone_name();
                $url_array = array_merge($_GET, $_POST);
                unset($url_array[$order_param]);
                foreach ($url_array as $key => $param) {
                    if (is_array($param)) {
                        continue;
                    }
                    if ($key == 'wide_high') {
                        continue;
                    }
                    if (substr($key, 0, 5) == 'keep_' && skippable_keep($key, $param)) {
                        continue;
                    }
                    if ($param === '_SELF') {
                        $param = get_page_name();
                    }
                    if (get_magic_quotes_gpc()) {
                        $param = stripslashes($param);
                    }
                    $cat_url .= '&' . $key . '=' . urlencode($param);
                }
                $sort_url_asc = $cat_url . '&' . $order_param . '=' . urlencode($found) . ' ASC';
                $sort_url_desc = $cat_url . '&' . $order_param . '=' . urlencode($found) . ' DESC';
            } else {
                $sort_url_asc = get_self_url(false, false, array($order_param => $found . ' ASC'), true);
                $sort_url_desc = get_self_url(false, false, array($order_param => $found . ' DESC'), true);
            }
            $sort_asc_selected = $current_ordering == $found . ' ASC';
            $sort_desc_selected = $current_ordering == $found . ' DESC';
            $cells->attach(do_template('RESULTS_TABLE_FIELD_TITLE_SORTABLE', array('_GUID' => $guid, 'VALUE' => $value, 'SORT_ASC_SELECTED' => $sort_asc_selected, 'SORT_DESC_SELECTED' => $sort_desc_selected, 'SORT_URL_DESC' => $sort_url_desc, 'SORT_URL_ASC' => $sort_url_asc)));
        } else {
            $cells->attach(do_template('RESULTS_TABLE_FIELD_TITLE', array('_GUID' => $guid, 'VALUE' => $value)));
        }
    }
    return $cells;
}
예제 #22
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=iotds&filter=';
     require_lang('iotds');
     require_code('feedback');
     require_code('iotds');
     require_css('iotds');
     // What action are we going to do?
     $type = get_param('type', 'misc');
     if ($type == 'view') {
         return $this->view();
     }
     if ($type == 'misc') {
         return $this->iotd_browse();
     }
     return new ocp_tempcode();
 }
예제 #23
0
 /**
  * The UI for a points profile.
  *
  * @param  ?MEMBER		The member the points profile of which is being viewed (NULL: read from GET parameter 'id')
  * @return tempcode		The UI
  */
 function points_profile($member_id_of = NULL)
 {
     if (is_null($member_id_of)) {
         $member_id_of = get_param_integer('id', get_member());
     }
     $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)));
     if (get_forum_type() == 'ocf') {
         $url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id_of, true, true);
         if (is_object($url)) {
             $url = $url->evaluate();
         }
         return redirect_screen($title, $url . '#tab__points', '');
     }
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=points&filter=' . strval($member_id_of);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('USER_POINT_FIND'))));
     // Previous/Next links
     $max_rows = $GLOBALS['FORUM_DRIVER']->get_members();
     $page_num = intval(floor(floatval($member_id_of - 1) / 1.0)) + 1;
     $num_pages = intval(ceil(floatval($max_rows) / 1.0));
     $tempid = $GLOBALS['FORUM_DRIVER']->get_previous_member($member_id_of);
     if (is_null($tempid)) {
         $previous_link = new ocp_tempcode();
     } else {
         $previous_link = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $tempid), '_SELF');
     }
     $tempid = $GLOBALS['FORUM_DRIVER']->get_next_member($member_id_of);
     if (is_null($tempid)) {
         $next_link = new ocp_tempcode();
     } else {
         $next_link = build_url(array('page' => '_SELF', 'type' => 'member', 'id' => $tempid), '_SELF');
     }
     $browse = do_template('NEXT_BROWSER_BROWSE_NEXT', array('_GUID' => '188c059239b39ca8ee70f85b38019490', 'PREVIOUS_LINK' => $previous_link, 'NEXT_LINK' => $next_link, 'PAGE_NUM' => integer_format($page_num), 'NUM_PAGES' => integer_format($num_pages)));
     require_code('points3');
     $content = points_profile($member_id_of, get_member());
     return do_template('POINTS_SCREEN', array('TITLE' => $title, 'CONTENT' => $content, 'BROWSE' => $browse));
 }
예제 #24
0
/**
 * Display a catalogue entry
 *
 * @param  AUTO_LINK		Entry ID
 * @param  boolean		Whether to skip rendering a title
 * @return tempcode		Tempcode interface to display an entry
 */
function render_catalogue_entry_screen($id, $no_title = false)
{
    require_code('feedback');
    if (addon_installed('ecommerce')) {
        require_code('ecommerce');
    }
    require_code('images');
    require_css('catalogues');
    require_lang('catalogues');
    $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('*'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $entries)) {
        return warn_screen(get_page_title('CATALOGUES'), do_lang_tempcode('MISSING_RESOURCE'));
    }
    $entry = $entries[0];
    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('*'), array('id' => $entry['cc_id']), '', 1);
    if (!array_key_exists(0, $categories)) {
        warn_exit(do_lang_tempcode('CAT_NOT_FOUND', strval($entry['cc_id'])));
    }
    $category = $categories[0];
    $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=catalogues&filter=' . strval($entry['cc_id']);
    $catalogue_name = $category['c_name'];
    $catalogues = $GLOBALS['SITE_DB']->query_select('catalogues', array('*'), array('c_name' => $catalogue_name), '', 1);
    if (!array_key_exists(0, $catalogues)) {
        warn_exit(do_lang_tempcode('CATALOGUE_NOT_FOUND', $catalogue_name));
    }
    $catalogue = $catalogues[0];
    // Permission for here?
    if (!has_category_access(get_member(), 'catalogues_catalogue', $catalogue_name)) {
        access_denied('CATALOGUE_ACCESS');
    }
    if (get_value('disable_cat_cat_perms') !== '1' && !has_category_access(get_member(), 'catalogues_category', strval($entry['cc_id']))) {
        access_denied('CATEGORY_ACCESS');
    }
    $ecommerce = is_ecommerce_catalogue($catalogue_name);
    if ($ecommerce) {
        $tpl_set = 'products';
    } else {
        $tpl_set = $catalogue_name;
    }
    $root = get_param_integer('root', NULL);
    $map = get_catalogue_entry_map($entry, $catalogue, 'PAGE', $tpl_set, $root, NULL, NULL, true, true);
    if (get_db_type() != 'xml') {
        $entry['ce_views']++;
        $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('ce_views' => $entry['ce_views']), array('id' => $id), '', 1, NULL, false, true);
    }
    // Validation
    if ($entry['ce_validated'] == 0) {
        if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) {
            access_denied('SPECIFIC_PERMISSION', 'jump_to_unvalidated');
        }
        $map['WARNINGS'] = do_template('WARNING_TABLE', array('_GUID' => 'bf604859a572ca53e969bec3d91f9cfb', 'WARNING' => do_lang_tempcode(get_param_integer('redirected', 0) == 1 ? 'UNVALIDATED_TEXT_NON_DIRECT' : 'UNVALIDATED_TEXT')));
    } else {
        $map['WARNINGS'] = '';
    }
    //Finding any hook exists for this product--------------------
    if (addon_installed('ecommerce')) {
        $object = find_product(strval($id));
        if (is_object($object) && method_exists($object, 'get_custom_product_map_fields')) {
            $object->get_custom_product_map_fields($id, $map);
        }
    }
    //------------------------------------------------------------
    $map['ENTRY'] = do_template('CATALOGUE_' . $tpl_set . '_ENTRY', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY');
    $map['ADD_DATE'] = get_timezoned_date($entry['ce_add_date']);
    $map['ADD_DATE_RAW'] = strval($entry['ce_add_date']);
    $map['EDIT_DATE'] = is_null($entry['ce_edit_date']) ? '' : get_timezoned_date($entry['ce_edit_date']);
    $map['EDIT_DATE_RAW'] = is_null($entry['ce_edit_date']) ? '' : strval($entry['ce_edit_date']);
    $map['VIEWS'] = integer_format($entry['ce_views']);
    $title_to_use = do_lang_tempcode($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0']);
    $title_to_use_2 = do_lang($catalogue_name . '__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN'], NULL, NULL, NULL, false);
    if (is_null($title_to_use_2)) {
        $title_to_use = do_lang_tempcode('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0']);
        $title_to_use_2 = do_lang('DEFAULT__CATALOGUE_ENTRY', $map['FIELD_0_PLAIN']);
    }
    if ($no_title) {
        $map['TITLE'] = new ocp_tempcode();
    } else {
        if (addon_installed('awards')) {
            require_code('awards');
            $awards = find_awards_for('catalogue_entry', strval($id));
        } else {
            $awards = array();
        }
        $map['TITLE'] = get_page_title($title_to_use, false, NULL, NULL, $awards);
    }
    $map['SUBMITTER'] = strval($entry['ce_submitter']);
    require_code('seo2');
    if (is_object($title_to_use_2)) {
        $title_to_use_2 = $title_to_use_2->evaluate();
    }
    seo_meta_load_for('catalogue_entry', strval($id), strip_tags($title_to_use_2));
    if ($map['TREE'] === '') {
        $map['TREE'] = new ocp_tempcode();
        $url = build_url(array('page' => '_SELF', 'type' => 'index', 'id' => $catalogue_name), '_SELF');
        $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($catalogue['c_title'])), false, false, do_lang('INDEX')));
        $map['TREE']->attach(do_template('BREADCRUMB_ESCAPED'));
        $url = build_url(array('page' => '_SELF', 'type' => 'category', 'id' => $category['id']), '_SELF');
        $map['TREE']->attach(hyperlink($url, escape_html(get_translated_text($category['cc_title'])), false, false, do_lang('GO_BACKWARDS_TO', get_translated_text($category['cc_title'])), NULL, NULL, 'up'));
    }
    $map['CATEGORY_TITLE'] = get_translated_text($category['cc_title']);
    $map['CAT'] = strval($entry['cc_id']);
    $map['TAGS'] = get_loaded_tags('catalogue_entries');
    breadcrumb_add_segment($map['TREE'], $title_to_use);
    if (is_null($root)) {
        breadcrumb_set_parents(array(array('_SELF:_SELF:misc' . ($ecommerce ? ':ecommerce=1' : ''), do_lang('CATALOGUES'))));
    }
    $GLOBALS['META_DATA'] += array('created' => date('Y-m-d', $entry['ce_add_date']), 'creator' => $GLOBALS['FORUM_DRIVER']->get_username($entry['ce_submitter']), 'publisher' => '', 'modified' => is_null($entry['ce_edit_date']) ? '' : date('Y-m-d', $entry['ce_edit_date']), 'type' => get_translated_text($catalogue['c_title']) . ' entry', 'title' => comcode_escape($title_to_use_2), 'identifier' => '_SEARCH:catalogues:entry:' . strval($id), 'description' => '');
    return do_template('CATALOGUE_' . $tpl_set . '_ENTRY_SCREEN', $map, NULL, false, 'CATALOGUE_DEFAULT_ENTRY_SCREEN');
}
예제 #25
0
 /**
  * Standard aed_module run_start.
  *
  * @param  ID_TEXT		The type of module execution
  * @return tempcode		The output of the run
  */
 function run_start($type)
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/customcomcode';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_adv_comcode';
     $this->add_one_label = do_lang_tempcode('ADD_CUSTOM_COMCODE_TAG');
     $this->edit_this_label = do_lang_tempcode('EDIT_THIS_CUSTOM_COMCODE_TAG');
     $this->edit_one_label = do_lang_tempcode('EDIT_CUSTOM_COMCODE_TAG');
     if ($type == 'ad') {
         require_javascript('javascript_ajax');
         $script = find_script('snippet');
         $this->javascript .= "\n\t\t\t\tvar form=document.getElementById('main_form');\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_tag&name='+window.encodeURIComponent(form.elements['tag'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t";
     }
     if ($type == 'misc') {
         return $this->misc();
     }
     return new ocp_tempcode();
 }
예제 #26
0
    /**
     * Standard aed_module run_start.
     *
     * @param  ID_TEXT		The type of module execution
     * @return tempcode		The output of the run
     */
    function run_start($type)
    {
        //		if (get_file_base()!=get_custom_file_base()) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
        // Message if banners not on
        if (get_option('is_on_banners') == '0') {
            if (has_actual_page_access(get_member(), 'admin_config')) {
                $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'FEATURE'), get_module_zone('admin_config'));
                $config_url = $_config_url->evaluate();
                $config_url .= '#group_BANNERS';
                attach_message(do_lang_tempcode('BANNERS_NOT_ENABLED', escape_html($config_url)), 'warn');
            }
        }
        if (has_specific_permission(get_member(), 'banner_free') && get_option('admin_banners') == '0') {
            attach_message(do_lang_tempcode('PERMISSION_BANNER_SKIP'), 'inform');
        }
        $this->cat_aed_module = new Module_cms_banners_cat();
        require_code('banners');
        require_code('banners2');
        require_lang('banners');
        $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/banners';
        $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_banners';
        if ($type == 'misc') {
            return $this->misc();
        }
        $this->javascript = '
			document.getElementById("importancemodulus").onkeyup=function()
			{
				var _im_here=document.getElementById("im_here");
				if (_im_here)
				{
					var _im_total=document.getElementById("im_total");
					var im_here=window.parseInt(document.getElementById("importancemodulus").value);
					var im_total=window.parseInt(_im_total.className.replace("im_",""))+im_here;
					setInnerHTML(_im_here,im_here);
					setInnerHTML(document.getElementById("im_here_2"),im_here);
					setInnerHTML(_im_total,im_total);
					setInnerHTML(document.getElementById("im_total_2"),im_total);
				}
			}
		';
        if ($type == 'ad') {
            require_javascript('javascript_ajax');
            $script = find_script('snippet');
            $this->javascript .= "\n\t\t\t\tvar form=document.getElementById('main_form');\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_banner&name='+window.encodeURIComponent(form.elements['name'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t";
        }
        if ($type == 'ac') {
            require_javascript('javascript_ajax');
            $script = find_script('snippet');
            $this->cat_aed_module->javascript = "\n\t\t\t\tvar form=document.getElementById('main_form');\n\t\t\t\tform.old_submit=form.onsubmit;\n\t\t\t\tform.onsubmit=function()\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_banner_type&name='+window.encodeURIComponent(form.elements['new_id'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t};\n\t\t\t";
        }
        return new ocp_tempcode();
    }
예제 #27
0
 /**
  * The UI to add a zone.
  *
  * @return tempcode		The UI
  */
 function add_zone()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/zones';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     if (get_option('htm_short_urls') == '1') {
         attach_message(do_lang_tempcode('HTM_SHORT_URLS_CARE'), 'warn');
     }
     $title = get_page_title('ADD_ZONE');
     require_code('form_templates');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'zone', '', true));
     list($_fields, $hidden, ) = $this->get_form_fields();
     $fields->attach($_fields);
     $post_url = build_url(array('page' => '_SELF', 'type' => '_add'), '_SELF');
     $submit_name = do_lang_tempcode('ADD_ZONE');
     $text = paragraph(do_lang_tempcode('ZONE_ADD_TEXT'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ZONES'))));
     require_javascript('javascript_ajax');
     $script = find_script('snippet');
     $javascript = "\n\t\t\tvar form=document.getElementById('main_form');\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_zone&name='+window.encodeURIComponent(form.elements['zone'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     return do_template('FORM_SCREEN', array('_GUID' => 'd8f08884cc370672c2e5604aefe78c6c', 'JAVASCRIPT' => $javascript, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text));
 }
예제 #28
0
파일: chat.php 프로젝트: erico-deh/ocPortal
 /**
  * The UI for a chat room.
  *
  * @return tempcode		The UI
  */
 function chat_room()
 {
     require_javascript('javascript_yahoo_2');
     require_javascript('javascript_colour_picker');
     require_javascript('javascript_posting');
     require_css('colour_picker');
     $prefs = @$_COOKIE['ocp_chat_prefs'];
     $prefs = @explode(';', $prefs);
     //$mode=get_param('mode','');
     $room_id = get_param('id');
     $posting_name = do_lang_tempcode('SEND_MESSAGE');
     $cs_post_url = build_url(array('page' => '_SELF', 'type' => 'options', 'id' => $room_id), '_SELF');
     $yourname = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $debug = get_param_integer('debug', 0) == 1 ? 'block' : 'none';
     $title = get_page_title('ROOM');
     $seteffectslink = hyperlink(build_url(array('page' => '_SELF', 'type' => 'set_effects'), '_SELF'), do_lang_tempcode('CHAT_SET_EFFECTS'), true);
     $logslink = hyperlink(get_base_url() . '/data_custom/jabber-logs/' . strtolower($room_id) . '@conference.' . get_domain(), 'Chat logs', true);
     $links = array($seteffectslink, $logslink);
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY_END_CHAT'))));
     $messages_php = find_script('messages');
     $password_hash = $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_pass_hash_salted');
     return do_template('CHAT_SCREEN', array('_GUID' => '867a0b050c050c81d33482d131783eb0', 'MESSAGES_PHP' => $messages_php, 'PASSWORD_HASH' => $password_hash, 'CHAT_SOUND' => get_chat_sound_tpl(), 'ROOM_ID' => $room_id, 'DEBUG' => $debug, 'OPTIONS_URL' => $cs_post_url, 'ROOM_NAME' => '', 'YOUR_NAME' => $yourname, 'SUBMIT_VALUE' => $posting_name, 'INTRODUCTION' => '', 'TITLE' => $title, 'LINKS' => $links));
 }
예제 #29
0
 /**
  * Put comments RSS link into environment.
  *
  * @param  ID_TEXT		The forum we are working in
  * @param  ID_TEXT		The content type the comments are for
  * @param  ID_TEXT		The content ID the comments are for
  */
 function inject_rss_url($forum, $type, $id)
 {
     $GLOBALS['FEED_URL_2'] = find_script('backend') . '?mode=comments&forum=' . urlencode($forum) . '&filter=' . urlencode($type . '_' . $id);
 }
예제 #30
0
 /**
  * The UI to view a download category tree.
  *
  * @return tempcode		The UI
  */
 function tree_view_screen()
 {
     $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=downloads&filter=';
     require_code('splurgh');
     if ($GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)') > 1000) {
         warn_exit(do_lang_tempcode('TOO_MANY_TO_CHOOSE_FROM'));
     }
     $url_stub = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF', NULL, false, false, true);
     $last_change_time = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories', 'MAX(add_date)');
     $category_rows = $GLOBALS['SITE_DB']->query_select('download_categories', array('id', 'category', 'parent_id'));
     $map = array();
     foreach ($category_rows as $category) {
         if ($category['category'] != db_get_first_id()) {
             if (!has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'downloads', strval($category['id']))) {
                 continue;
             }
         }
         $id = $category['id'];
         $map[$id]['title'] = get_translated_text($category['category']);
         $children = array();
         foreach ($category_rows as $child) {
             if ($child['parent_id'] == $id) {
                 $children[] = $child['id'];
             }
         }
         $map[$id]['children'] = $children;
     }
     $content = splurgh_master_build('id', $map, $url_stub->evaluate(), 'download_tree_made', $last_change_time);
     $title = get_page_title('DOWNLOADS_TREE');
     return do_template('SPLURGH_SCREEN', array('_GUID' => '4efab542cfa3d48a3b23d60b04798a37', 'TITLE' => $title, 'CONTENT' => $content));
 }