コード例 #1
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;
}
コード例 #2
0
 /**
  * Get details for an ajax-tree-list of entries for the content covered by this search hook.
  *
  * @return array			A pair: the hook, and the options
  */
 function ajax_tree()
 {
     $catalogue_name = get_param('catalogue_name', '');
     if ($catalogue_name == '') {
         @ob_end_clean();
         $tree = nice_get_catalogues(NULL, true);
         if ($tree->is_empty()) {
             inform_exit(do_lang_tempcode('NO_ENTRIES'));
         }
         require_code('form_templates');
         $fields = form_input_list(do_lang_tempcode('NAME'), '', 'catalogue_name', $tree, NULL, true);
         if (running_script('iframe')) {
             $post_url = get_self_url_easy();
         } else {
             $post_url = get_self_url(false, false, NULL, false, true);
         }
         $submit_name = do_lang_tempcode('PROCEED');
         $hidden = build_keep_post_fields();
         $title = get_page_title('SEARCH');
         $tpl = do_template('FORM_SCREEN', array('_GUID' => 'a2812ac8056903811f444682d45ee448', 'TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
         $echo = globalise($tpl, NULL, '', true);
         $echo->evaluate_echo();
         exit;
     }
     return array('choose_catalogue_category', array('catalogue_name' => $catalogue_name));
 }
コード例 #3
0
ファイル: ocworld.php プロジェクト: erico-deh/ocPortal
/**
 * Show the current user a message. Function does not return.
 *
 * @param  tempcode	The message to show
 * @param  ID_TEXT	Code of message type to show
 * @set    warn inform fatal
 */
function ocw_refresh_with_message($message, $msg_type = 'inform')
{
    $url = build_url(array('page' => 'ocworld'), '_SELF');
    @ob_end_clean();
    $title = get_page_title('MESSAGE');
    $tpl = redirect_screen($title, $url, $message, false, $msg_type);
    $echo = globalise($tpl, NULL, '', true);
    $echo->evaluate_echo();
    exit;
}
コード例 #4
0
ファイル: main_feedback.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_code('feedback');
     require_javascript('javascript_validation');
     $is_occle_talking = ocp_srv('HTTP_USER_AGENT') == 'ocPortal' && ocp_srv('HTTP_HOST') == 'ocportal.com';
     $self_url = get_self_url();
     $self_title = get_page_name();
     $type = 'block_main_feedback';
     $id = array_key_exists('param', $map) ? $map['param'] : '';
     $out = new ocp_tempcode();
     if (post_param_integer('_comment_form_post', 0) == 1) {
         if (!has_no_forum()) {
             $hidden = actualise_post_comment(true, $type, $id, $self_url, $self_title, array_key_exists('forum', $map) ? $map['forum'] : NULL, $is_occle_talking || get_option('captcha_on_feedback') == '0', 1, false, true, true);
             if (array_key_exists('title', $_POST)) {
                 $redirect = get_param('redirect', NULL);
                 if (!is_null($redirect)) {
                     $redirect_screen = redirect_screen(get_page_title('_FEEDBACK'), $redirect, do_lang_tempcode('FEEDBACK_THANKYOU'));
                     @ob_end_clean();
                     $echo = globalise($redirect_screen, NULL, '', true);
                     $echo->evaluate_echo();
                     exit;
                 } else {
                     attach_message(do_lang_tempcode('SUCCESS'), 'inform');
                 }
             }
         } else {
             $post = post_param('post', '');
             $title = post_param('title', '');
             if ($post != '') {
                 require_code('notifications');
                 dispatch_notification('new_feedback', $type, do_lang('NEW_FEEDBACK_SUBJECT', $title, NULL, NULL, get_site_default_lang()), do_lang('NEW_FEEDBACK_MESSAGE', $post, NULL, NULL, get_site_default_lang()));
                 $email_from = trim(post_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())));
                 if ($email_from != '') {
                     require_code('mail');
                     mail_wrap(do_lang('YOUR_MESSAGE_WAS_SENT_SUBJECT', $title), do_lang('YOUR_MESSAGE_WAS_SENT_BODY', $post), array($email_from), NULL, '', '', 3, NULL, false, get_member());
                 }
             }
         }
     }
     // Comment posts
     $forum = get_option('comments_forum_name');
     $count = 0;
     $_comments = $GLOBALS['FORUM_DRIVER']->get_forum_topic_posts($GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum, $type . '_' . $id), $count);
     if ($_comments !== -1) {
         $em = $GLOBALS['FORUM_DRIVER']->get_emoticon_chooser();
         require_javascript('javascript_editing');
         $comcode_help = build_url(array('page' => 'userguide_comcode'), get_comcode_zone('userguide_comcode', false));
         require_javascript('javascript_validation');
         $comment_url = get_self_url();
         if (addon_installed('captcha')) {
             require_code('captcha');
             $use_captcha = !$is_occle_talking && get_option('captcha_on_feedback') == '1' && use_captcha();
             if ($use_captcha) {
                 generate_captcha();
             }
         } else {
             $use_captcha = false;
         }
         $comment_details = do_template('COMMENTS_POSTING_FORM', array('_GUID' => '4ca32620f3eb68d9cc820b18265792d7', 'JOIN_BITS' => '', 'FIRST_POST_URL' => '', 'FIRST_POST' => '', 'USE_CAPTCHA' => $use_captcha, 'POST_WARNING' => get_param('post_warning', ''), 'COMMENT_TEXT' => '', 'GET_EMAIL' => false, 'EMAIL_OPTIONAL' => true, 'GET_TITLE' => true, 'EM' => $em, 'DISPLAY' => 'block', 'COMMENT_URL' => $comment_url, 'TITLE' => do_lang_tempcode('FEEDBACK')));
     } else {
         $comment_details = new ocp_tempcode();
     }
     $out->attach($comment_details);
     return $out;
 }
コード例 #5
0
ファイル: ocf.php プロジェクト: erico-deh/ocPortal
 /**
  * Find if the given member id and password is valid. If username is NULL, then the member id is used instead.
  * All authorisation, cookies, and form-logins, are passed through this function.
  * Some forums do cookie logins differently, so a Boolean is passed in to indicate whether it is a cookie login.
  *
  * @param  ?SHORT_TEXT	The member username (NULL: don't use this in the authentication - but look it up using the ID if needed)
  * @param  ?MEMBER		The member id (NULL: use member name)
  * @param  MD5				The md5-hashed password
  * @param  string			The raw password
  * @param  boolean		Whether this is a cookie login, determines how the hashed password is treated for the value passed in
  * @return array			A map of 'id' and 'error'. If 'id' is NULL, an error occurred and 'error' is set
  */
 function forum_authorise_login($username, $userid, $password_hashed, $password_raw, $cookie_login = false)
 {
     $out = array();
     $out['id'] = NULL;
     require_code('ocf_members');
     require_code('ocf_groups');
     if (!function_exists('require_lang')) {
         require_code('lang');
     }
     if (!function_exists('do_lang_tempcode')) {
         require_code('tempcode');
     }
     if (!function_exists('require_lang')) {
         return $out;
     }
     require_lang('ocf');
     require_code('mail');
     $skip_auth = false;
     if ($userid === NULL) {
         $rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_username', $username), 1);
         if (!array_key_exists(0, $rows) && get_option('one_per_email_address') == '1') {
             $rows = $this->connection->query('SELECT * FROM ' . $this->connection->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_email_address', $username) . ' ORDER BY id ASC', 1);
         }
         if (array_key_exists(0, $rows)) {
             $this->MEMBER_ROWS_CACHED[$rows[0]['id']] = $rows[0];
             $userid = $rows[0]['id'];
         }
     } else {
         $rows[0] = $this->get_member_row($userid);
     }
     // LDAP to the rescue if we couldn't get a row
     global $LDAP_CONNECTION;
     if (!array_key_exists(0, $rows) && $LDAP_CONNECTION !== NULL && $userid === NULL) {
         // See if LDAP has it -- if so, we can add
         $test = ocf_is_on_ldap($username);
         if (!$test) {
             $out['error'] = is_null($username) ? do_lang_tempcode('USER_NO_EXIST') : do_lang_tempcode('_USER_NO_EXIST', escape_html($username));
             return $out;
         }
         $test_auth = ocf_ldap_authorise_login($username, $password_raw);
         if ($test_auth['m_pass_hash_salted'] == '!!!') {
             $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
             return $out;
         }
         if ($test) {
             require_code('ocf_members_action');
             require_code('ocf_members_action2');
             $completion_form_submitted = trim(post_param('email_address', '')) != '';
             if (!$completion_form_submitted && get_value('no_finish_profile') !== '1') {
                 @ob_end_clean();
                 if (!function_exists('do_header')) {
                     require_code('site');
                 }
                 $middle = ocf_member_external_linker_ask($username, 'ldap', ocf_ldap_guess_email($username));
                 $tpl = globalise($middle, NULL, '', true);
                 $tpl->evaluate_echo();
                 exit;
             } else {
                 $userid = ocf_member_external_linker($username, uniqid('', true), 'ldap');
                 $row = $this->get_member_row($userid);
             }
         }
     }
     if (!array_key_exists(0, $rows) || $rows[0] === NULL) {
         $out['error'] = is_null($username) ? do_lang_tempcode('USER_NO_EXIST') : do_lang_tempcode('_USER_NO_EXIST', escape_html($username));
         return $out;
     }
     $row = $rows[0];
     // Now LDAP can kick in and get the correct hash
     if (ocf_is_ldap_member($userid)) {
         //$rows[0]['m_pass_hash_salted']=ocf_get_ldap_hash($userid);
         // Doesn't exist any more? This is a special case - the 'LDAP member' exists in our DB, but not LDAP. It has been deleted from LDAP or LDAP server has jumped
         /*if (is_null($rows[0]['m_pass_hash_salted']))
         		{
         			$out['error']=(do_lang_tempcode('_USER_NO_EXIST',$username));
         			return $out;
         		} No longer appropriate with new authentication mode - instead we just have to give an invalid password message  */
         $row = array_merge($row, ocf_ldap_authorise_login($username, $password_hashed));
     }
     if (addon_installed('unvalidated')) {
         if ($row['m_validated'] == 0) {
             $out['error'] = do_lang_tempcode('USER_NOT_VALIDATED_STAFF');
             return $out;
         }
     }
     if ($row['m_validated_email_confirm_code'] != '') {
         $out['error'] = do_lang_tempcode('USER_NOT_VALIDATED_EMAIL');
         return $out;
     }
     if ($this->is_banned($row['id'])) {
         $out['error'] = do_lang_tempcode('USER_BANNED');
         return $out;
     }
     // Check password
     if (!$skip_auth) {
         // Choose a compatibility screen.
         // Note that almost all cookie logins are the same. This is because the cookie logins use OCF cookies, regardless of compatibility scheme.
         $password_compatibility_scheme = $row['m_password_compat_scheme'];
         switch ($password_compatibility_scheme) {
             case 'remote':
                 // This will work too - we're logging in with the username of a remote profile, so no resynching will happen
             // This will work too - we're logging in with the username of a remote profile, so no resynching will happen
             case '':
                 // ocPortal style salted MD5 algorithm
                 if ($cookie_login) {
                     if ($password_hashed !== $row['m_pass_hash_salted']) {
                         require_code('tempcode');
                         // This can be incidental even in fast AJAX scripts, if an old invalid cookie is present, so we need tempcode for do_lang_tempcode
                         $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
                         return $out;
                     }
                 } else {
                     if (md5($row['m_pass_salt'] . $password_hashed) !== $row['m_pass_hash_salted']) {
                         $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
                         return $out;
                     }
                 }
                 break;
             case 'plain':
                 if ($password_hashed !== md5($row['m_pass_hash_salted'])) {
                     $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
                     return $out;
                 }
                 break;
             case 'md5':
                 // Old style plain md5		(also works if both are unhashed: used for LDAP)
                 if ($password_hashed !== $row['m_pass_hash_salted'] && $password_hashed != '!!!') {
                     $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
                     return $out;
                 }
                 break;
                 /*		case 'httpauth':
                 				// This is handled in get_member()  */
                 break;
             case 'ldap':
                 if ($password_hashed !== $row['m_pass_hash_salted']) {
                     $out['error'] = do_lang_tempcode('USER_BAD_PASSWORD');
                     return $out;
                 }
                 break;
             default:
                 $path = get_file_base() . '/sources_custom/hooks/systems/ocf_auth/' . $password_compatibility_scheme . '.php';
                 if (!file_exists($path)) {
                     $path = get_file_base() . '/sources/hooks/systems/ocf_auth/' . $password_compatibility_scheme . '.php';
                 }
                 if (!file_exists($path)) {
                     $out['error'] = do_lang_tempcode('UNKNOWN_AUTH_SCHEME_IN_DB');
                     return $out;
                 }
                 require_code('hooks/systems/ocf_auth/' . $password_compatibility_scheme);
                 $ob = object_factory('Hook_ocf_auth_' . $password_compatibility_scheme);
                 $error = $ob->auth($username, $userid, $password_hashed, $password_raw, $cookie_login, $row);
                 if (!is_null($error)) {
                     $out['error'] = $error;
                     return $out;
                 }
                 break;
         }
     }
     // Ok, authorised basically, but we need to see if this is a valid login IP
     if (ocf_get_best_group_property($this->get_members_groups($row['id']), 'enquire_on_new_ips') == 1) {
         global $SENT_OUT_VALIDATE_NOTICE;
         $ip = get_ip_address(3);
         $test2 = $this->connection->query_value_null_ok('f_member_known_login_ips', 'i_val_code', array('i_member_id' => $row['id'], 'i_ip' => $ip));
         if ((is_null($test2) || $test2 != '') && !compare_ip_address($ip, $row['m_ip_address'])) {
             if (!$SENT_OUT_VALIDATE_NOTICE) {
                 if (!is_null($test2)) {
                     $this->connection->query_delete('f_member_known_login_ips', array('i_member_id' => $row['id'], 'i_ip' => $ip), '', 1);
                 }
                 $code = !is_null($test2) ? $test2 : uniqid('', true);
                 $this->connection->query_insert('f_member_known_login_ips', array('i_val_code' => $code, 'i_member_id' => $row['id'], 'i_ip' => $ip));
                 $url = find_script('validateip') . '?code=' . $code;
                 $url_simple = find_script('validateip');
                 require_code('comcode');
                 $mail = do_lang('IP_VERIFY_MAIL', comcode_escape($url), comcode_escape(get_ip_address()), array($url_simple, $code), get_lang($row['id']));
                 $email_address = $row['m_email_address'];
                 if ($email_address == '') {
                     $email_address = get_option('staff_address');
                 }
                 if (running_script('index')) {
                     mail_wrap(do_lang('IP_VERIFY_MAIL_SUBJECT', NULL, NULL, NULL, get_lang($row['id'])), $mail, array($email_address), $row['m_username'], '', '', 1);
                 }
                 $SENT_OUT_VALIDATE_NOTICE = true;
             }
             $out['error'] = do_lang_tempcode('REQUIRES_IP_VALIDATION');
             return $out;
         }
     }
     $this->ocf_flood_control($row['id']);
     $out['id'] = $row['id'];
     return $out;
 }
コード例 #6
0
/**
 * Force an AFM login.
 */
function get_afm_form()
{
    $fields = get_afm_form_fields();
    $title = get_page_title('ABSTRACT_FILE_MANAGEMENT');
    $post_url = running_script('index') ? get_self_url(true) : get_self_url_easy();
    $submit_name = do_lang_tempcode('PROCEED');
    $hidden = build_keep_post_fields();
    $hidden->attach(form_input_hidden('got_ftp_details', '1'));
    if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') {
        $hidden->attach(form_input_hidden('uses_ftp', '1'));
    }
    $javascript = "var ftp_ticker=function() { var uses_ftp=document.getElementById('uses_ftp'); if (!uses_ftp) return; var form=uses_ftp.form; form.elements['ftp_domain'].disabled=!uses_ftp.checked; form.elements['ftp_directory'].disabled=!uses_ftp.checked; form.elements['ftp_username'].disabled=!uses_ftp.checked; form.elements['ftp_password'].disabled=!uses_ftp.checked; form.elements['remember_password'].disabled=!uses_ftp.checked; }; ftp_ticker(); document.getElementById('uses_ftp').onclick=ftp_ticker;";
    @ob_end_clean();
    $middle = do_template('FORM_SCREEN', array('_GUID' => 'c47a31fca47a7b22eeef3a6269cc2407', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => paragraph(do_lang_tempcode('TEXT_ABSTRACT_FILE_MANAGEMENT'))));
    $echo = globalise($middle, NULL, '', true);
    $echo->evaluate_echo();
    exit;
}
コード例 #7
0
ファイル: failure.php プロジェクト: erico-deh/ocPortal
/**
 * Show a helpful access-denied page. Has a login ability if it senses that logging in could curtail the error.
 *
 * @param  ID_TEXT		The class of error (e.g. SPECIFIC_PERMISSION)
 * @param  string			The parameteter given to the error message
 * @param  boolean		Force the user to login (even if perhaps they are logged in already)
 */
function _access_denied($class, $param, $force_login)
{
    $GLOBALS['HTTP_STATUS_CODE'] = '401';
    if (!headers_sent()) {
        if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
            header('HTTP/1.0 401 Unauthorized');
        }
        // Stop spiders ever storing the URL that caused this
    }
    require_lang('permissions');
    require_lang('ocf_config');
    $match_keys = $GLOBALS['SITE_DB']->query_select('match_key_messages', array('k_message', 'k_match_key'));
    global $M_SORT_KEY;
    $M_SORT_KEY = 'k_match_key';
    usort($match_keys, 'strlen_sort');
    $match_keys = array_reverse($match_keys);
    $message = NULL;
    foreach ($match_keys as $match_key) {
        if (match_key_match($match_key['k_match_key'])) {
            $message = get_translated_tempcode($match_key['k_message']);
        }
    }
    if (is_null($message)) {
        if (strpos($class, ' ') !== false) {
            $message = make_string_tempcode($class);
        } else {
            if ($class == 'SPECIFIC_PERMISSION') {
                $param = do_lang('PT_' . $param);
            }
            $message = do_lang_tempcode('ACCESS_DENIED__' . $class, escape_html($GLOBALS['FORUM_DRIVER']->get_username(get_member())), escape_html($param));
        }
    }
    // Run hooks, if any exist
    $hooks = find_all_hooks('systems', 'upon_access_denied');
    foreach (array_keys($hooks) as $hook) {
        require_code('hooks/systems/upon_access_denied/' . filter_naughty($hook));
        $ob = object_factory('Hook_upon_access_denied_' . filter_naughty($hook), true);
        if (is_null($ob)) {
            continue;
        }
        $ob->run($class, $param, $force_login);
    }
    require_code('site');
    log_stats('/access_denied', 0);
    if (is_guest() && (running_script('attachment') || running_script('dload') || $GLOBALS['NON_PAGE_SCRIPT'] == 0) || $force_login) {
        @ob_end_clean();
        $redirect = get_self_url(true, true, array('page' => get_param('page', '')));
        // We have to pass in 'page' because an access-denied situation tells get_page_name() (which get_self_url() relies on) that we are on page ''.
        $_GET['redirect'] = $redirect;
        $_GET['page'] = 'login';
        $_GET['type'] = 'misc';
        global $PAGE_NAME_CACHE;
        $PAGE_NAME_CACHE = 'login';
        $middle = load_module_page(_get_module_path('', 'login'), 'login');
        require_code('site');
        attach_message($message, 'warn');
        $echo = globalise($middle, NULL, '', true);
        $echo->evaluate_echo();
        exit;
    }
    //if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) fatal_exit($message);
    warn_exit($message);
}
コード例 #8
0
ファイル: ocf_join.php プロジェクト: erico-deh/ocPortal
function referrer_report_script($ret = false)
{
    $member_id = get_param_integer('member_id', NULL);
    if (!has_zone_access(get_member(), 'adminzone') && $member_id !== get_member()) {
        access_denied('ZONE_ACCESS', 'adminzone');
    }
    require_lang('referrals');
    $csv = get_param_integer('csv', 0) == 1;
    $where = db_string_not_equal_to('i_email_address', '') . ' AND i_inviter<>' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id());
    if ($member_id !== NULL) {
        $where .= ' AND referrer.id=' . strval($member_id);
    }
    $max = get_param_integer('max', $csv ? 10000 : 30);
    $start = get_param_integer('start', 0);
    $data = array();
    $table = 'f_invites i LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referrer ON referrer.id=i_inviter LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members referee ON referee.m_email_address=i_email_address';
    $referrals = $GLOBALS['FORUM_DB']->query('SELECT i_time AS time,referrer.id AS referrer_id,referrer.m_username AS referrer,referrer.m_email_address AS referrer_email,referee.id AS referee_id,referee.m_username AS referee,referee.m_email_address AS referee_email,i_taken AS qualified
		FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where . ' ORDER BY i_time DESC', $max, $start);
    $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . $table . ' WHERE ' . $where);
    if (count($referrals) == 0) {
        inform_exit(do_lang_tempcode('NO_ENTRIES'));
    }
    foreach ($referrals as $ref) {
        $data_row = array();
        $data_row[do_lang('DATE_TIME')] = get_timezoned_date($ref['time'], true, true, false, true);
        if (is_null($member_id)) {
            if ($csv) {
                $deleted = true;
                $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referrer'];
            } else {
                $data_row[do_lang('TYPE_REFERRER')] = is_null($ref['referrer_id']) ? '' : strval($ref['referrer_id']);
            }
            $data_row[do_lang('TYPE_REFERRER') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = $ref['referrer_email'];
            $data_row[do_lang('QUALIFIED_REFERRER')] = do_lang(referrer_is_qualified($ref['referrer_id']) ? 'YES' : 'NO');
        }
        $deleted = false;
        if (is_null($ref['referee'])) {
            $deleted = $ref['qualified'] == 1;
            //!is_null($GLOBALS['SITE_DB']->query_value_null_ok('adminlogs','id',array('the_type'=>'DELETE_MEMBER','param_b'=>TODO Unfortunately we can't tell)));
        }
        if ($csv) {
            $data_row[do_lang('REFEREE')] = is_null($ref['referee']) ? do_lang($deleted ? 'REFEREE_DELETED' : 'REFEREE_NOT_SIGNED_UP') : $ref['referee'];
        } else {
            $data_row[do_lang('REFEREE')] = is_null($ref['referee_id']) ? '' : strval($ref['referee_id']);
        }
        $data_row[do_lang('REFEREE') . ' (' . do_lang('EMAIL_ADDRESS') . ')'] = is_null($ref['referee_email']) ? '' : $ref['referee_email'];
        $data_row[do_lang('QUALIFIED_REFERRAL')] = do_lang($ref['qualified'] == 1 ? 'YES' : 'NO');
        $data[] = $data_row;
    }
    if ($csv) {
        require_code('files2');
        make_csv($data, (is_null($member_id) ? get_site_name() : $GLOBALS['FORUM_DRIVER']->get_username($member_id)) . ' referrals.csv');
    } else {
        require_code('templates_results_table');
        $fields_title = new ocp_tempcode();
        $fields = new ocp_tempcode();
        foreach ($data as $i => $data_row) {
            if ($i == 0) {
                $fields_title->attach(results_field_title(array_keys($data_row)));
            }
            foreach ($data_row as $key => $val) {
                if ($key == do_lang('REFEREE') || $key == do_lang('TYPE_REFERRER')) {
                    if ($val == '') {
                        $val = do_lang('UNKNOWN');
                    } else {
                        $val = $GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($val, true);
                    }
                }
                $data_row[$key] = escape_html($val);
            }
            $fields->attach(results_entry($data_row));
        }
        $table = results_table(do_lang('REFERRALS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $fields);
        if ($ret) {
            return $table;
        }
        $title = get_page_title('REFERRALS');
        $out = new ocp_tempcode();
        $out->attach($title);
        $out->attach($table);
        $out = globalise($out, NULL, '', true);
        $out->evaluate_echo();
    }
    return NULL;
}
コード例 #9
0
/**
 * Function to process the file upload process
 */
function incoming_uploads_script()
{
    $is_uploaded = false;
    if (!file_exists(get_custom_file_base() . '/uploads/incoming')) {
        @mkdir(get_custom_file_base() . '/uploads/incoming', 0777);
        fix_permissions(get_custom_file_base() . '/uploads/incoming', 0777);
        sync_file(get_custom_file_base() . '/uploads/incoming');
    }
    $savename = 'uploads/incoming/' . uniqid('', true) . '.dat';
    if (array_key_exists('file', $_FILES)) {
        if (is_uploaded_file($_FILES['file']['tmp_name'])) {
            $is_uploaded = true;
        } else {
            header('HTTP/1.1 500 File Upload Error');
            @error_log('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error'])), 0);
            exit('ocPortal: ' . do_lang('ERROR_UPLOADING_' . strval($_FILES['file']['error'])));
        }
        $name = $_FILES['file']['name'];
        if ($is_uploaded) {
            @move_uploaded_file($_FILES['file']['tmp_name'], get_custom_file_base() . '/' . $savename) or intelligent_write_error(get_custom_file_base() . '/' . $savename);
        }
    } elseif (post_param('name', '') != '') {
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        $name = post_param('name');
        // Read binary input stream and append it to temp file
        $in = fopen('php://input', 'rb');
        if ($in !== false) {
            // Open temp file
            $out = fopen($savename, 'wb');
            if ($out !== false) {
                $is_uploaded = true;
                do {
                    $buff = fread($in, 4096);
                    fwrite($out, $buff);
                } while (!feof($out));
                fclose($out);
            }
            fclose($in);
        }
    }
    if ($is_uploaded) {
        $max_length = 255;
        $field_type_test = $GLOBALS['SITE_DB']->query_value('db_meta', 'm_type', array('m_name' => 'i_orig_filename'));
        if ($field_type_test == 'ID_TEXT') {
            $max_length = 80;
        }
        // Legacy
        $name = substr($name, max(0, strlen($name) - $max_length));
        header('Content-type: text/plain; charset=' . get_charset());
        require_code('files');
        if (get_param_integer('base64', 0) == 1) {
            $new = base64_decode(file_get_contents(get_custom_file_base() . '/' . $savename));
            $myfile = @fopen(get_custom_file_base() . '/' . $savename, 'wb') or intelligent_write_error(get_custom_file_base() . '/' . $savename);
            fwrite($myfile, $new);
            fclose($myfile);
        }
        fix_permissions(get_custom_file_base() . '/' . $savename);
        sync_file(get_custom_file_base() . '/' . $savename);
        $member_id = get_member();
        $file_db_id = $GLOBALS['SITE_DB']->query_insert('incoming_uploads', array('i_submitter' => $member_id, 'i_date_and_time' => time(), 'i_orig_filename' => $name, 'i_save_url' => $savename), true, false);
        // File is valid, and was successfully uploaded. Now see if there is any metadata to surface from the file.
        require_code('images');
        $outa = array();
        if (is_image($name)) {
            require_code('exif');
            $outa += get_exif_data(get_custom_file_base() . '/' . $savename);
        }
        $outa['upload_id'] = strval($file_db_id);
        $outa['upload_name'] = $name;
        $outa['upload_savename'] = $savename;
        @ini_set('ocproducts.xss_detect', '0');
        $outstr = '{';
        $done = 0;
        foreach ($outa as $key => $val) {
            if (is_float($val)) {
                $val = float_to_raw_string($val);
            } elseif (is_integer($val)) {
                $val = strval($val);
            }
            if (is_string($val) && $val != '') {
                $val = str_replace(chr(0), '', $val);
                if ($done != 0) {
                    $outstr .= ', ';
                }
                $outstr .= '"' . str_replace(chr(10), '\\n', addcslashes($key, "\\\\'\"&\n\r<>")) . '": "' . str_replace(chr(10), '\\n', addcslashes($val, "\\\\'\"&\n\r<>")) . '"';
                $done++;
            }
        }
        $outstr .= '}';
        echo $outstr;
    } else {
        //header('Content-type: text/plain'); @print('No file ('.serialize($_FILES).')');
        header('HTTP/1.1 500 File Upload Error');
        // Test harness
        $title = get_page_title('UPLOAD');
        $fields = new ocp_tempcode();
        require_code('form_templates');
        $fields->attach(form_input_upload(do_lang_tempcode('FILE'), '', 'file', true, NULL, NULL, false));
        $hidden = new ocp_tempcode();
        $out2 = globalise(do_template('FORM_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'TEXT' => '', 'HIDDEN' => $hidden, 'URL' => find_script('incoming_uploads', true), 'FIELDS' => $fields)), NULL, '', true);
        $out2->evaluate_echo();
    }
    exit;
}
コード例 #10
0
ファイル: page_stats.php プロジェクト: erico-deh/ocPortal
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     require_lang('stats');
     require_lang('dates');
     $delete_older_than = post_param_integer('delete_older_than', NULL);
     if (is_null($delete_older_than)) {
         @ob_end_clean();
         $delete_older_than = intval(get_option('stats_store_time'));
         require_code('form_templates');
         $fields = form_input_integer(do_lang_tempcode('DPLU_DAYS'), do_lang_tempcode('DESCRIPTION_DELETE_DAYS'), 'delete_older_than', $delete_older_than, true);
         $post_url = get_self_url(false, false, NULL, false, true);
         $submit_name = do_lang_tempcode('DELETE');
         $hidden = build_keep_post_fields();
         $title = get_page_title('PAGE_STATS_DELETE');
         $tpl = do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => do_lang_tempcode('DELETE_DATA_AVAILABLE'), 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
         $echo = globalise($tpl, NULL, '', true);
         $echo->evaluate_echo();
         exit;
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     // Write install.php file
     $template = get_custom_file_base() . '/data_custom/modules/admin_cleanup/page_stats.php.pre';
     if (!file_exists($template)) {
         $template = get_file_base() . '/data/modules/admin_cleanup/page_stats.php.pre';
     }
     $_install_php_file = file_get_contents($template);
     $install_php_file = ocp_tempnam('ps');
     $tmpfile = fopen($install_php_file, 'wb');
     fwrite($tmpfile, substr($_install_php_file, 0, strpos($_install_php_file, '{!!DB!!}')));
     // Get old data
     do {
         $or_list = '';
         $data = $GLOBALS['SITE_DB']->query('SELECT * FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than), 500);
         foreach ($data as $d) {
             $list = '';
             foreach ($d as $name => $value) {
                 if (is_null($value)) {
                     continue;
                 }
                 if ($list != '') {
                     $list .= ',';
                 }
                 $list .= "'" . (is_string($name) ? $name : strval($name)) . "'=>";
                 if (!is_integer($value)) {
                     $list .= "'" . str_replace('\'', '\\\'', $value) . "'";
                 } else {
                     $list .= strval($value);
                 }
             }
             fwrite($tmpfile, "\t\$GLOBALS['SITE_DB']->query_insert('stats',array({$list}));\n");
             if ($or_list != '') {
                 $or_list .= ' OR ';
             }
             $or_list .= 'id=' . strval($d['id']);
         }
         if ($or_list != '') {
             $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE ' . $or_list);
         }
     } while ($data != array());
     fwrite($tmpfile, substr($_install_php_file, strpos($_install_php_file, '{!!DB!!}') + 8));
     // Make tar
     require_code('tar');
     $file = 'stats-leading-to-' . date('Y-m-d', utctime_to_usertime(time() - 60 * 60 * 24 * $delete_older_than));
     $stats_backup_url = get_custom_base_url() . '/exports/backups/' . $file . '.tar';
     $myfile = tar_open(get_custom_file_base() . '/exports/backups/' . $file . '.tar', 'wb');
     tar_add_file($myfile, $file . '.php', $install_php_file, 0664, time(), true);
     tar_close($myfile);
     fclose($tmpfile);
     @unlink($install_php_file);
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'stats WHERE date_and_time<' . strval(time() - 60 * 60 * 24 * $delete_older_than));
     return do_template('CLEANUP_PAGE_STATS', array('_GUID' => '1df213eee7c5c6b97168e5a34e92d3b0', 'STATS_BACKUP_URL' => $stats_backup_url));
 }
コード例 #11
0
/**
 * Try and login via HTTP authentication. This function is only called if HTTP authentication is currently active. With HTTP authentication we trust the PHP_AUTH_USER setting.
 *
 * @return ?MEMBER		Logged in member (NULL: no login happened)
 */
function try_httpauth_login()
{
    global $LDAP_CONNECTION;
    require_code('ocf_members');
    require_code('ocf_groups');
    require_lang('ocf');
    $member = ocf_authusername_is_bound_via_httpauth($_SERVER['PHP_AUTH_USER']);
    if (is_null($member) && (running_script('index') || running_script('execute_temp'))) {
        require_code('ocf_members_action');
        require_code('ocf_members_action2');
        if (trim(post_param('email_address', '')) == '' && get_value('no_finish_profile') !== '1') {
            @ob_end_clean();
            if (!function_exists('do_header')) {
                require_code('site');
            }
            $middle = ocf_member_external_linker_ask($_SERVER['PHP_AUTH_USER'], get_option('windows_auth_is_enabled', true) != '1' || is_null($LDAP_CONNECTION) ? 'httpauth' : 'ldap');
            $tpl = globalise($middle, NULL, '', true);
            $tpl->evaluate_echo();
            exit;
        } else {
            $member = ocf_member_external_linker($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_USER'], get_option('windows_auth_is_enabled', true) != '1' || is_null($LDAP_CONNECTION) ? 'httpauth' : 'ldap');
        }
    }
    if (!is_null($member)) {
        create_session($member, 1, isset($_COOKIE[get_member_cookie() . '_invisible']) && $_COOKIE[get_member_cookie() . '_invisible'] == '1');
    }
    // This will mark it as confirmed
    return $member;
}
コード例 #12
0
/**
 * Show a comcode parser error.
 *
 * @param  boolean		Whether this is being pre-parsed, to pick up errors before row insertion.
 * @param  array			Error message details to pass to do_lang, or if the first in the list is NULL, use directly
 * @param  integer		The position during parsing that the error occurred at
 * @param  LONG_TEXT		The comcode the parser error occurred in
 * @param  boolean		Whether to only check the Comcode.
 * @return tempcode		An error message to put in the output stream (shown in certain situations, where in other situations we bomb out).
 */
function comcode_parse_error($preparse_mode, $_message, $pos, $comcode, $check_only = false)
{
    //echo $comcode;
    require_lang('comcode');
    if (is_null($_message[0])) {
        $message = $_message[1];
    } else {
        if (strpos($_message[0], ':') === false) {
            $_message[0] = 'comcode:' . $_message[0];
        }
        $message = call_user_func_array('do_lang_tempcode', array_map('escape_html', $_message));
    }
    $posted = false;
    foreach ($_POST + $_GET as $name => $val) {
        if (is_array($val)) {
            continue;
        }
        if (is_integer($name)) {
            $name = strval($name);
        }
        if (post_param($name, '') == $comcode || substr($name, -7) == '_parsed') {
            $posted = true;
        }
    }
    if (!$check_only) {
        if ((get_page_name() == 'admin_import' || count($_POST) == 0 || !$posted) && !$preparse_mode) {
            $line = substr_count(substr($comcode, 0, $pos), chr(10)) + 1;
            $out = do_template('COMCODE_CRITICAL_PARSE_ERROR', array('LINE' => integer_format($line), 'MESSAGE' => $message, 'SOURCE' => $comcode));
            // Won't parse, but we can't help it, so we will skip on
            return $out;
        }
    }
    $len = strlen($comcode);
    $lines = new ocp_tempcode();
    $number = 1;
    $sofar = '';
    $line = NULL;
    for ($i = 0; $i < $len; $i++) {
        $char = $comcode[$i];
        if ($i == $pos) {
            $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR');
            $sofar .= $tmp_tpl->evaluate();
            $line = $number;
        }
        if ($char == chr(10)) {
            $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => '2022be3de10590d525f333b6ac0da37b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar))));
            $sofar = '';
            $number++;
        }
        $sofar .= escape_html($char);
    }
    if ($i == $pos) {
        $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR');
        $sofar .= $tmp_tpl->evaluate();
    }
    $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => 'eebfe1342f3129d4e31fc9fc1963af2b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar))));
    if (is_null($line)) {
        $line = $number;
    }
    // Now, using some kind of miracle, we need to find out what parameter name blew-up. Let's look through the parameters and see what
    // is equal to $comcode. I'd rather not do this in a hackerish way - but the architecture was not designed for this.
    $name = NULL;
    foreach ($_POST as $key => $val) {
        if (!is_string($val)) {
            continue;
        }
        if (post_param($key) == $comcode) {
            $name = $key;
            break;
        }
    }
    if (is_null($name)) {
        if ($check_only) {
            foreach ($_POST as $key => $val) {
                if (!is_string($val)) {
                    continue;
                }
                $val = post_param($key);
                if (strlen($val) > 10 && (strpos($comcode, $val) === 0 || strpos($comcode, $val) === strlen($comcode) - strlen($val))) {
                    $name = $key;
                    break;
                }
            }
        }
        if (is_null($name)) {
            warn_exit(do_lang_tempcode('COMCODE_ERROR', $message, integer_format($line)));
        }
    }
    if (!running_script('comcode_convert')) {
        $GLOBALS['HTTP_STATUS_CODE'] = '400';
        if (!headers_sent()) {
            // NB: Very important this doesn't run on IE. IE is supposed to show error screens literally if more than 512 bytes, and this is much more (irregardless of compression) - but sometimes seems to still hide it with a "friendly" error anyway
            if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) {
                header('HTTP/1.0 400 Bad Request');
            }
        }
    }
    // Output our error / correction form
    @ob_end_clean();
    $hidden = build_keep_post_fields(array($name));
    require_code('form_templates');
    $fields = form_input_text_comcode(do_lang_tempcode('NEW'), do_lang_tempcode('COMCODE_REPLACEMENT'), $name, $comcode, true, NULL, true);
    $post_url = get_self_url();
    $form = do_template('FORM', array('_GUID' => '207bad1252add775029b34ba36e02856', 'URL' => $post_url, 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
    $output = do_template('COMCODE_MISTAKE_SCREEN', array('_GUID' => '0010230e6612b0775566d07ddf54305a', 'EDITABLE' => !running_script('preview'), 'FORM' => $form, 'TITLE' => get_page_title('ERROR_OCCURRED'), 'LINE' => integer_format($line), 'MESSAGE' => $message, 'LINES' => $lines));
    $echo = new ocp_tempcode();
    if (!running_script('preview')) {
        $echo = globalise($output, NULL, '', true);
        $echo->handle_symbol_preprocessing();
    } else {
        $echo->attach(do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'TARGET' => '_top', 'CONTENT' => $output)));
    }
    $echo->evaluate_echo();
    exit;
    return new ocp_tempcode();
    // to trick code checker
}
コード例 #13
0
ファイル: word_filter.php プロジェクト: erico-deh/ocPortal
/**
 * Exit with a message about word-filtering.
 *
 * @param  ?ID_TEXT		The name of the parameter this is coming from. Certain parameters are not checked, for reasons of efficiency (avoiding loading whole word check list if not needed) (NULL: don't know param, do not check to avoid)
 * @param  tempcode		Error message
 */
function warn_exit_wordfilter($name, $message)
{
    global $WORD_FILTERING_ALREADY;
    $WORD_FILTERING_ALREADY = true;
    if (is_null($name)) {
        warn_exit($message);
    }
    // Output our error / correction form
    @ob_end_clean();
    $hidden = build_keep_post_fields(array($name));
    require_code('form_templates');
    $value = post_param($name);
    if (strpos($value, chr(10)) === false) {
        $fields = form_input_line(do_lang_tempcode('CHANGE'), '', $name, $value, true);
    } else {
        $fields = form_input_text(do_lang_tempcode('CHANGE'), '', $name, $value, true);
    }
    $post_url = get_self_url();
    $output = do_template('FORM_SCREEN', array('TITLE' => get_page_title('ERROR_OCCURRED'), 'TEXT' => $message, 'URL' => $post_url, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED')));
    $echo = new ocp_tempcode();
    if (!running_script('preview')) {
        $echo = globalise($output, NULL, '', true);
        $echo->handle_symbol_preprocessing();
    } else {
        $echo->attach(do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'TARGET' => '_top', 'CONTENT' => $output)));
    }
    $echo->evaluate_echo();
    exit;
}
コード例 #14
0
ファイル: ajax.php プロジェクト: erico-deh/ocPortal
/**
 * AJAX script for HTML<>Comcode conversion (and Comcode-Text>Comcode-XML).
 */
function comcode_convert_script()
{
    header("Cache-Control: no-cache, must-revalidate");
    // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    // Date in the past
    global $EXTRA_HEAD;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    require_lang('comcode');
    convert_data_encodings(true);
    $data = post_param('data', NULL, false, false);
    if (is_null($data)) {
        $title = get_page_title('_COMCODE');
        $fields = new ocp_tempcode();
        require_code('form_templates');
        $fields->attach(form_input_huge(do_lang_tempcode('TEXT'), '', 'data', '', true));
        $fields->attach(form_input_tick('Convert HTML to Comcode', '', 'from_html', false));
        $fields->attach(form_input_tick('Convert to semihtml', '', 'semihtml', false));
        $fields->attach(form_input_tick('Lax mode (less parse rules)', '', 'lax', false));
        $hidden = new ocp_tempcode();
        $hidden->attach(form_input_hidden('to_comcode_xml', strval(either_param_integer('to_comcode_xml', 0))));
        $out2 = globalise(do_template('FORM_SCREEN', array('_GUID' => 'dd82970fa1196132e07049871c51aab7', 'TITLE' => $title, 'SUBMIT_NAME' => do_lang_tempcode('VIEW'), 'TEXT' => '', 'HIDDEN' => $hidden, 'URL' => find_script('comcode_convert', true), 'FIELDS' => $fields)), NULL, '', true);
        $out2->evaluate_echo();
        return;
    }
    $panel = either_param_integer('panel', NULL);
    if (!is_null($panel)) {
        global $TEMPCODE_SETGET;
        if ($panel == 0) {
            $TEMPCODE_SETGET['in_panel'] = '0';
        } else {
            $TEMPCODE_SETGET['in_panel'] = '1';
        }
    }
    if (either_param_integer('to_comcode_xml', 0) == 1) {
        require_code('comcode_conversion');
        $out = comcode_text__to__comcode_xml($data);
    } elseif (either_param_integer('from_html', 0) == 1) {
        require_code('comcode_from_html');
        $out = trim(semihtml_to_comcode($data));
    } else {
        if (either_param_integer('lax', 0) == 1) {
            $GLOBALS['LAX_COMCODE'] = true;
        }
        if (either_param_integer('is_semihtml', 0) == 1) {
            require_code('comcode_from_html');
            $data = semihtml_to_comcode($data);
        }
        $db = $GLOBALS['SITE_DB'];
        if (get_param_integer('forum_db', 0) == 1) {
            $db = $GLOBALS['FORUM_DB'];
        }
        $tpl = comcode_to_tempcode($data, get_member(), false, 60, NULL, $db, either_param_integer('semihtml', 0) == 1, false, false, false);
        $evaluated = $tpl->evaluate();
        $out = '';
        if ($evaluated != '') {
            if (get_param_integer('css', 0) == 1) {
                global $CSSS;
                unset($CSSS['global']);
                unset($CSSS['no_cache']);
                $out .= static_evaluate_tempcode(css_tempcode());
            }
            if (get_param_integer('javascript', 0) == 1) {
                global $JAVASCRIPTS;
                unset($JAVASCRIPTS['javascript']);
                unset($JAVASCRIPTS['javascript_staff']);
                $out .= static_evaluate_tempcode(javascript_tempcode());
            }
        }
        $out .= trim(trim($evaluated));
    }
    if (either_param_integer('fix_bad_html', 0) == 1) {
        require_code('xhtml');
        $new = xhtmlise_html($out, true);
        if (preg_replace('#<!--.*-->#Us', '', preg_replace('#\\s+#', '', $new)) != preg_replace('#<!--.*-->#Us', '', preg_replace('#\\s+#', '', $out))) {
            /*$myfile=fopen(get_file_base().'/a','wb');
            			fwrite($myfile,preg_replace('#<!--.*-->#Us','',preg_replace('#\s+#',chr(10),$new)));
            			fclose($myfile);
            
            			$myfile=fopen(get_file_base().'/b','wb');
            			fwrite($myfile,preg_replace('#<!--.*-->#Us','',preg_replace('#\s+#',chr(10),$out)));
            			fclose($myfile);*/
            $out = $new . do_lang('BROKEN_XHTML_FIXED');
        }
    }
    if (either_param_integer('keep_skip_rubbish', 0) == 0) {
        @ini_set('ocproducts.xss_detect', '0');
        $box_title = get_param('box_title', '');
        if (is_object($out)) {
            $out = $out->evaluate();
        }
        if ($box_title != '' && $out != '') {
            $out = static_evaluate_tempcode(put_in_standard_box(make_string_tempcode($out), $box_title));
        }
        header('Content-Type: text/xml');
        echo '<?xml version="1.0" encoding="' . get_charset() . '"?' . '>';
        echo '<request><result>';
        echo xmlentities($out);
        echo '</result></request>';
    } else {
        header('Content-type: text/plain; charset=' . get_charset());
        echo $out;
    }
}
コード例 #15
0
ファイル: cms_booking.php プロジェクト: erico-deh/ocPortal
 /**
  * Get a form for entering a booking.
  *
  * @param  ?array		Details of the booking (NULL: new).
  * @param  ?MEMBER	Who the booking is for (NULL: current member).
  * @return array		Tuple: form fields, hidden fields.
  */
 function get_form_fields($details = NULL, $member_id = NULL)
 {
     $hidden = new ocp_tempcode();
     $fields = new ocp_tempcode();
     if (is_null($details)) {
         $bookable_id = get_param_integer('bookable_id', NULL);
         if (is_null($bookable_id)) {
             // Form to choose bookable
             @ob_end_clean();
             $bookables = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), NULL, 'ORDER BY sort_order');
             if (count($bookables) == 0) {
                 inform_exit(do_lang_tempcode('NO_CATEGORIES'));
             }
             $bookables_list = new ocp_tempcode();
             foreach ($bookables as $bookable) {
                 $bookables_list->attach(form_input_list_entry(strval($bookable['id']), false, get_translated_text($bookable['title'])));
             }
             $fields = form_input_list(do_lang_tempcode('BOOKABLE'), '', 'bookable_id', $bookables_list, NULL, true);
             $post_url = get_self_url(false, false, NULL, false, true);
             $submit_name = do_lang_tempcode('PROCEED');
             $hidden = build_keep_post_fields();
             $title = get_page_title('ADD_BOOKING');
             $tpl = do_template('FORM_SCREEN', array('TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name));
             $echo = globalise($tpl, NULL, '', true);
             $echo->evaluate_echo();
             exit;
         }
         $details = array('bookable_id' => $bookable_id, 'start_day' => get_param_integer('day', intval(date('d'))), 'start_month' => get_param_integer('month', intval(date('m'))), 'start_year' => get_param_integer('year', intval(date('Y'))), 'end_day' => get_param_integer('day', intval(date('d'))), 'end_month' => get_param_integer('month', intval(date('m'))), 'end_year' => get_param_integer('year', intval(date('Y'))), 'quantity' => 1, 'notes' => '', 'supplements' => array());
     }
     if (is_null($member_id)) {
         $member_id = get_member();
     }
     $_bookable = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), array('id' => $details['bookable_id']), '', 1);
     if (!array_key_exists(0, $_bookable)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $bookable = $_bookable[0];
     $fields->attach(form_input_date(do_lang_tempcode('FROM'), '', 'bookable_' . strval($details['bookable_id']) . '_date_from', false, false, false, array(0, 0, $details['start_month'], $details['start_day'], $details['start_year']), 10, NULL, NULL, NULL, true, get_server_timezone()));
     if ($bookable['dates_are_ranges'] == 1) {
         $fields->attach(form_input_date(do_lang_tempcode('TO'), '', 'bookable_' . strval($details['bookable_id']) . '_date_to', false, false, false, array(0, 0, $details['end_month'], $details['end_day'], $details['end_year']), 10, NULL, NULL, NULL, true, get_server_timezone()));
     }
     $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_quantity', $details['quantity'], true));
     $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_notes', $details['notes'], false));
     $member_directory_url = build_url(array('page' => 'members'), get_module_zone('members'));
     $fields->attach(form_input_username(do_lang_tempcode('BOOKING_FOR'), do_lang_tempcode('DESCRIPTION_BOOKING_FOR', escape_html($member_directory_url->evaluate())), 'username', $GLOBALS['FORUM_DRIVER']->get_username($member_id), true, false));
     $supplement_rows = $GLOBALS['SITE_DB']->query_select('bookable_supplement a JOIN ' . get_table_prefix() . 'bookable_supplement_for b ON a.id=b.supplement_id', array('a.*'), array('bookable_id' => $details['bookable_id']), 'ORDER BY sort_order');
     foreach ($supplement_rows as $supplement_row) {
         $quantity = 0;
         $notes = '';
         if (array_key_exists($supplement_row['id'], $details['supplements'])) {
             $quantity = $details['supplements'][$supplement_row['id']]['quantity'];
             $notes = $details['supplements'][$supplement_row['id']]['notes'];
         }
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SUPPLEMENT', escape_html(get_translated_text($supplement_row['title']))))));
         if ($supplement_row['supports_quantities'] == 1) {
             $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity, true));
         } else {
             $fields->attach(form_input_tick(get_translated_text($supplement_row['title']), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity == 1));
         }
         $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_notes', $notes, false));
     }
     return array($fields, $hidden);
 }
コード例 #16
0
ファイル: mail.php プロジェクト: erico-deh/ocPortal
/**
 * Entry script to process a form that needs to be emailed.
 */
function form_to_email_entry_script()
{
    require_lang('mail');
    form_to_email();
    global $PAGE_NAME_CACHE;
    $PAGE_NAME_CACHE = '_form_to_email';
    $title = get_page_title('MAIL_SENT');
    $text = do_lang_tempcode('MAIL_SENT_TEXT', escape_html(post_param('to_written_name', get_site_name())));
    $redirect = get_param('redirect', NULL);
    if (!is_null($redirect)) {
        require_code('site2');
        $GLOBALS['NON_PAGE_SCRIPT'] = 0;
        $tpl = redirect_screen($title, $redirect, $text);
    } else {
        $tpl = do_template('INFORM_SCREEN', array('_GUID' => 'e577a4df79eefd9064c14240cc99e947', 'TITLE' => $title, 'TEXT' => $text));
    }
    $echo = globalise($tpl, NULL, '', true);
    $echo->evaluate_echo();
}
コード例 #17
0
function handle_facebook_connection_login($current_logged_in_member)
{
    if (!class_exists('ocp_tempcode')) {
        return NULL;
    }
    if (is_guest($current_logged_in_member)) {
        $current_logged_in_member = NULL;
        // We are not a normal cookie login so ocPortal has loaded up a Guest session already in the expectation of keeping it. Unsetting it will force a rebind (existing session may be reused though)
        require_code('users_inactive_occasionals');
        set_session_id(-1);
    }
    // If already session-logged-in onto a Facebook account, don't bother doing anything
    if (!is_null($current_logged_in_member) && $GLOBALS['FORUM_DRIVER']->get_member_row_field($current_logged_in_member, 'm_password_compat_scheme') == 'facebook') {
        return $current_logged_in_member;
    }
    // Who is this user, from Facebook's point of view?
    global $FACEBOOK_CONNECT;
    $facebook_uid = $FACEBOOK_CONNECT->getUser();
    if (is_null($facebook_uid)) {
        return $current_logged_in_member;
    }
    try {
        $details = $FACEBOOK_CONNECT->api('/me');
    } catch (Exception $e) {
        return $current_logged_in_member;
    }
    $details2 = $FACEBOOK_CONNECT->api('/me', array('fields' => 'picture', 'type' => 'normal'));
    if (!is_array($details) || !is_array($details2)) {
        return $current_logged_in_member;
    }
    $details = array_merge($details, $details2);
    if (!isset($details['name'])) {
        return $current_logged_in_member;
    }
    $username = $details['name'];
    $photo_url = array_key_exists('picture', $details) ? $details['picture'] : '';
    if (is_array($photo_url)) {
        $photo_url = $photo_url['data']['url'];
    }
    if ($photo_url != '') {
        $photo_url = 'http://graph.facebook.com/' . strval($facebook_uid) . '/picture?type=large';
        // In case URL changes
    }
    $avatar_url = $photo_url == '' ? mixed() : $photo_url;
    $photo_thumb_url = '';
    if ($photo_url != '') {
        $photo_thumb_url = $photo_url;
    }
    $email_address = array_key_exists('email', $details) ? $details['email'] : '';
    $timezone = mixed();
    if (isset($details['timezone'])) {
        require_code('temporal');
        $timezone = convert_timezone_offset_to_formal_timezone($details['timezone']);
    }
    $language = mixed();
    if (isset($details['locale'])) {
        $language = strtoupper($details['locale']);
    }
    if ($language !== NULL) {
        if (!file_exists(get_custom_file_base() . '/lang_custom/' . $language)) {
            $language = preg_replace('#\\_.*$#', '', $language);
            if (!file_exists(get_custom_file_base() . '/lang_custom/' . $language)) {
                $language = '';
            }
        }
    }
    $dob = array_key_exists('birthday', $details) ? $details['birthday'] : '';
    $dob_day = mixed();
    $dob_month = mixed();
    $dob_year = mixed();
    if ($dob != '') {
        $_dob = explode('/', $dob);
        $dob_day = intval($_dob[1]);
        $dob_month = intval($_dob[0]);
        $dob_year = intval($_dob[2]);
    }
    // See if they have logged in before - i.e. have a synched account
    $member_row = $GLOBALS['FORUM_DB']->query_select('f_members', array('*'), array('m_password_compat_scheme' => 'facebook', 'm_pass_hash_salted' => $facebook_uid), 'ORDER BY id DESC', 1);
    $member = array_key_exists(0, $member_row) ? $member_row[0]['id'] : NULL;
    if (is_guest($member)) {
        $member = NULL;
    }
    /*if (!is_null($member)) // Useful for debugging
    	{
    		require_code('ocf_members_action2');
    		ocf_delete_member($member);
    		$member=NULL;
    	}*/
    // If logged in before using Facebook, see if they've changed their name or email or timezone on Facebook -- if so, try and update locally to match
    if (!is_null($member)) {
        if (!is_null($current_logged_in_member) && $current_logged_in_member !== NULL && !is_guest($current_logged_in_member) && $current_logged_in_member != $member) {
            return $current_logged_in_member;
        }
        // User has an active login, and the Facebook account is bound to a DIFFERENT login. Take precedence to the other login that is active on top of this
        $last_visit_time = $member[0]['m_last_visit_time'];
        if ($timezone !== NULL) {
            if (tz_time(time(), $timezone) == tz_time(time(), $member[0]['m_timezone_offset'])) {
                $timezone = $member[0]['m_timezone_offset'];
            }
            // If equivalent, don't change
        }
        $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $username));
        if (!is_null($test)) {
            $update_map = array('m_username' => $username, 'm_dob_day' => $dob_day, 'm_dob_month' => $dob_month, 'm_dob_year' => $dob_year);
            if ($email_address != '') {
                $update_map['m_email_address'] = $email_address;
            }
            if ($avatar_url !== NULL && ($test == '' || strpos($test, 'facebook') !== false || strpos($test, 'fbcdn') !== false)) {
                if ($timezone !== NULL) {
                    $update_map['m_timezone_offset'] = $timezone;
                }
                $update_map['m_avatar_url'] = $avatar_url;
                $update_map['m_photo_url'] = $photo_url;
                $update_map['m_photo_thumb_url'] = $photo_thumb_url;
            }
            $GLOBALS['FORUM_DB']->query_update('f_members', $update_map, array('m_password_compat_scheme' => 'facebook', 'm_pass_hash_salted' => strval($facebook_uid)), '', 1);
            if ($username != $member[0]['m_username']) {
                // Fix cacheing for usernames
                $to_fix = array('f_forums/f_cache_last_username', 'f_posts/p_poster_name_if_guest', 'f_topics/t_cache_first_username', 'f_topics/t_cache_last_username');
                foreach ($to_fix as $fix) {
                    list($table, $field) = explode('/', $fix);
                    $GLOBALS['FORUM_DB']->query_update($table, array($field => $username), array($field => $member[0]['m_username']));
                }
            }
        }
    }
    // Not logged in before using Facebook, so we need to create an account, or bind to the active ocPortal login if there is one
    $in_a_sane_place = get_page_name() != 'login' && (running_script('index') || running_script('execute_temp'));
    // If we're in some weird script, or the login module UI, it's not a sane place, don't be doing account creation yet
    if (is_null($member) && $in_a_sane_place) {
        // Bind to existing ocPortal login?
        if (!is_null($current_logged_in_member)) {
            /*if (post_param_integer('associated_confirm',0)==0)		Won't work because Facebook is currently done in JS and cookies force this. If user wishes to cancel they must go to http://www.facebook.com/settings?tab=applications and remove the app, then run a lost password reset.
            		{
            			$title=get_page_title('LOGIN_FACEBOOK_HEADER');
            			$message=do_lang_tempcode('LOGGED_IN_SURE_FACEBOOK',escape_html($GLOBALS['FORUM_DRIVER']->get_username($current_logged_in_member)));
            			$middle=do_template('YESNO_SCREEN',array('TITLE'=>$title,'TEXT'=>$message,'HIDDEN'=>form_input_hidden('associated_confirm','1'),'URL'=>get_self_url_easy()));
            			$tpl=globalise($middle,NULL,'',true);
            			$tpl->evaluate_echo();
            			exit();
            		}*/
            $GLOBALS['FORUM_DB']->query_update('f_members', array('m_password_compat_scheme' => 'facebook', 'm_pass_hash_salted' => $facebook_uid), array('id' => $current_logged_in_member), '', 1);
            require_code('site');
            require_lang('facebook');
            attach_message(do_lang_tempcode('FACEBOOK_ACCOUNT_CONNECTED', escape_html(get_site_name()), escape_html($GLOBALS['FORUM_DRIVER']->get_username($current_logged_in_member)), array(escape_html($username))), 'inform');
            return $current_logged_in_member;
        }
        // If we're still here, we have to create a new account...
        // -------------------------------------------------------
        $completion_form_submitted = post_param('email_address', '') != '';
        // If there's a conflicting username, we may need to change it (suffix a number)
        require_code('ocf_members_action2');
        $username = get_username_from_human_name($username);
        // Ask ocP to finish off the profile from the information presented in the POST environment (a standard mechanism in ocPortal, for third party logins of various kinds)
        require_lang('ocf');
        require_code('ocf_members');
        require_code('ocf_groups');
        require_code('ocf_members2');
        require_code('ocf_members_action');
        $_custom_fields = ocf_get_all_custom_fields_match(ocf_get_all_default_groups(true), NULL, NULL, NULL, 1);
        if (!$completion_form_submitted && count($_custom_fields) != 0 && get_value('no_finish_profile') !== '1') {
            $GLOBALS['FACEBOOK_FINISHING_PROFILE'] = true;
            $middle = ocf_member_external_linker_ask($username, 'facebook', $email_address, $dob_day, $dob_month, $dob_year);
            $tpl = globalise($middle, NULL, '', true);
            $tpl->evaluate_echo();
            exit;
        } else {
            $username = post_param('username', $username);
            if (count($_custom_fields) != 0 && get_value('no_finish_profile') !== '1') {
                // Was not auto-generated, so needs to be checked
                ocf_check_name_valid($username, NULL, NULL);
            }
            $member = ocf_member_external_linker($username, $facebook_uid, 'facebook', false, $email_address, $dob_day, $dob_month, $dob_year, $timezone, $language, $avatar_url, $photo_url, $photo_thumb_url);
        }
    }
    if (!is_null($member)) {
        require_code('users_inactive_occasionals');
        create_session($member, 1, isset($_COOKIE[get_member_cookie() . '_invisible']) && $_COOKIE[get_member_cookie() . '_invisible'] == '1');
        // This will mark it as confirmed
    }
    return $member;
}
コード例 #18
0
ファイル: view_modes.php プロジェクト: erico-deh/ocPortal
/**
 * Handle special page type output.
 *
 * @param  ID_TEXT		The special page type.
 * @set    query templates tree lang
 * @param  tempcode		The normal script tempcode output
 * @param  string			The normal script evaluated output
 */
function special_page_types($special_page_type, &$out, $out_evaluated)
{
    global $RECORDED_TEMPLATES_USED;
    if (function_exists('set_time_limit')) {
        @set_time_limit(280);
    }
    $echo = do_header();
    //$echo->evaluate_echo();
    $echo2 = new ocp_tempcode();
    if (is_null($out_evaluated)) {
        ob_start();
        $out->evaluate_echo();
        // False evaluation
        ob_end_clean();
    }
    // HACKHACK: Yuck. we have to after-the-fact make it wide, and empty lots of internal caching to reset the state.
    $_GET['wide_high'] = '1';
    $_GET['wide'] = '1';
    $GLOBALS['LOADED_PANELS'] = array();
    $GLOBALS['IS_WIDE_HIGH'] = 1;
    $GLOBALS['IS_WIDE'] = 1;
    $GLOBALS['TEMPCODE_SETGET'] = array();
    $GLOBALS['LOADED_TPL_CACHE'] = array();
    $GLOBALS['HELPER_PANEL_PIC'] = NULL;
    $GLOBALS['HELPER_PANEL_TEXT'] = NULL;
    $GLOBALS['HELPER_PANEL_TUTORIAL'] = NULL;
    $GLOBALS['HELPER_PANEL_HTML'] = NULL;
    // CSS
    if (substr($special_page_type, -4) == '.css') {
        $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_css', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'file' => $special_page_type, 'keep_wide_high' => 1), get_module_zone('admin_themes'));
        header('Location: ' . $url->evaluate());
        exit;
    }
    // Site Tree Editor
    if ($special_page_type == 'site_tree') {
        $url = build_url(array('page' => 'admin_sitetree', 'type' => 'site_tree', 'id' => get_zone_name() . ':' . get_page_name()), get_module_zone('admin_sitetree'));
        header('Location: ' . $url->evaluate());
        exit;
    }
    // IDE linkage
    if ($special_page_type == 'ide_linkage') {
        $title = get_page_title('IDE_LINKAGE');
        $file_links = new ocp_tempcode();
        global $JAVASCRIPTS, $CSSS, $_REQUIRED_CODE, $LANGS_REQUESTED;
        /*foreach (array_keys($JAVASCRIPTS) as $name)	Already in list of templates
        		{
        			$txtmte_url='txmt://open?url=file://'.$name;
        			$file_links->attach(do_template('INDEX_SCREEN_ENTRY',array('URL'=>$txtmte_url,'NAME'=>$name)));
        		}*/
        foreach (array_keys($CSSS) as $name) {
            $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.css', 'css');
            if (!is_null($search)) {
                list($theme, $type) = $search;
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.css';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(CSS)', 'URL' => $txtmte_url, 'NAME' => $name . '.css')));
            }
        }
        foreach (array_keys($_REQUIRED_CODE) as $name) {
            $path_a = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources_custom/' . $name . '.php' : $name);
            $path_b = get_file_base() . '/' . (strpos($name, '.php') === false ? '/sources/' . $name . '.php' : str_replace('_custom', '', $name));
            if (file_exists($path_a)) {
                $txtmte_url = 'txmt://open?url=file://' . $path_a;
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : ''))));
            }
            if (file_exists($path_b)) {
                $txtmte_url = 'txmt://open?url=file://' . $path_b;
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(PHP)', 'URL' => $txtmte_url, 'NAME' => $name . (strpos($name, '.php') === false ? '.php' : ''))));
            }
        }
        foreach (array_keys($LANGS_REQUESTED) as $name) {
            if (file_exists(get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini')) {
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang_custom/' . fallback_lang() . '/' . $name . '.ini';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini')));
            }
            if (file_exists(get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini')) {
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/lang/' . fallback_lang() . '/' . $name . '.ini';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Language)', 'URL' => $txtmte_url, 'NAME' => $name . '.ini')));
            }
        }
        foreach (array_unique($RECORDED_TEMPLATES_USED) as $name) {
            $search = find_template_place($name, get_site_default_lang(), $GLOBALS['FORUM_DRIVER']->get_theme(), '.tpl', 'templates');
            if (!is_null($search)) {
                list($theme, $type) = $search;
                $txtmte_url = 'txmt://open?url=file://' . get_file_base() . '/themes/' . $theme . '/' . $type . '/' . $name . '.tpl';
                $file_links->attach(do_template('INDEX_SCREEN_ENTRY', array('DISPLAY_STRING' => '(Templates)', 'URL' => $txtmte_url, 'NAME' => $name . '.tpl')));
            }
        }
        $echo2 = do_template('INDEX_SCREEN', array('TITLE' => $title, 'CONTENT' => $file_links, 'PRE' => do_lang_tempcode('TXMT_PROTOCOL_EXPLAIN'), 'POST' => ''));
    }
    // Theme images mode
    if ($special_page_type == 'theme_images') {
        $title = get_page_title('THEME_IMAGE_EDITING');
        $theme_images = new ocp_tempcode();
        global $RECORDED_IMG_CODES;
        foreach (array_keys($RECORDED_IMG_CODES) as $theme_image_details) {
            list($id, $theme, $lang) = unserialize($theme_image_details);
            $url = build_url(array('page' => 'admin_themes', 'type' => 'edit_image', 'theme' => is_null($theme) ? $GLOBALS['FORUM_DRIVER']->get_theme() : $theme, 'lang' => $lang, 'id' => $id), 'adminzone');
            $image = find_theme_image($id, false, false, $theme, $lang);
            if ($image == '') {
                continue;
            }
            $theme_images->attach(do_template('INDEX_SCREEN_FANCIER_ENTRY', array('IMG' => $image, 'DESCRIPTION' => '', 'URL' => $url, 'NAME' => $id)));
        }
        $echo2 = do_template('INDEX_SCREEN_FANCIER_SCREEN', array('TITLE' => $title, 'CONTENT' => $theme_images, 'PRE' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'POST' => ''));
    }
    // Profile mode?
    if ($special_page_type == 'profile') {
        if (function_exists('xdebug_dump_function_profile')) {
            $type = XDEBUG_PROFILER_FS_SUM;
            xdebug_dump_function_profile($type);
        } else {
            $echo2 = make_string_tempcode('Check out the dump using KCacheGrind.');
        }
    } elseif (substr($special_page_type, 0, 12) == 'lang_content') {
        $map_a = get_file_base() . '/lang/langs.ini';
        $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
        if (!file_exists($map_b)) {
            $map_b = $map_a;
        }
        $map = better_parse_ini_file($map_b);
        $lang_name = user_lang();
        if (array_key_exists($lang_name, $map)) {
            $lang_name = $map[$lang_name];
        }
        global $RECORDED_LANG_STRINGS_CONTENT;
        require_lang('lang');
        require_code('form_templates');
        $fields = new ocp_tempcode();
        require_code('lang2');
        $names = find_lang_content_names(array_keys($RECORDED_LANG_STRINGS_CONTENT));
        foreach ($RECORDED_LANG_STRINGS_CONTENT as $key => $forum_db) {
            $value_found = get_translated_text($key, $forum_db ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']);
            if ($value_found != '') {
                $description = make_string_tempcode(escape_html($value_found));
                if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) {
                    $actions = new ocp_tempcode();
                } else {
                    require_javascript('javascript_translate');
                    $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'trans_' . strval($key), 'OLD' => $value_found));
                }
                $description->attach($actions);
                $fields->attach(form_input_text(is_null($names[$key]) ? '#' . strval($key) : $names[$key], $description, 'trans_' . strval($key), $value_found, false));
            }
        }
        if ($fields->is_empty()) {
            inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
        }
        $title = get_page_title('__TRANSLATE_CONTENT', true, array($lang_name));
        $post_url = build_url(array('page' => 'admin_lang', 'type' => '_content', 'contextual' => 1), 'adminzone');
        $hidden = form_input_hidden('redirect', get_self_url(true, true));
        $hidden = form_input_hidden('lang', user_lang());
        $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
    } elseif (substr($special_page_type, 0, 4) == 'lang') {
        $map_a = get_file_base() . '/lang/langs.ini';
        $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
        if (!file_exists($map_b)) {
            $map_b = $map_a;
        }
        $map = better_parse_ini_file($map_b);
        $lang_name = user_lang();
        if (array_key_exists($lang_name, $map)) {
            $lang_name = $map[$lang_name];
        }
        global $RECORDED_LANG_STRINGS;
        require_lang('lang');
        require_code('form_templates');
        require_code('lang2');
        $fields = new ocp_tempcode();
        $descriptions = get_lang_file_descriptions(fallback_lang());
        foreach (array_keys($RECORDED_LANG_STRINGS) as $key) {
            $value_found = do_lang($key, NULL, NULL, NULL, NULL, false);
            $description = array_key_exists($key, $descriptions) ? make_string_tempcode($descriptions[$key]) : new ocp_tempcode();
            if (!is_null($value_found)) {
                if (get_value('google_translate_api_key') === NULL || user_lang() == get_site_default_lang()) {
                    $actions = new ocp_tempcode();
                } else {
                    require_javascript('javascript_translate');
                    $actions = do_template('TRANSLATE_ACTION', array('LANG_FROM' => get_site_default_lang(), 'LANG_TO' => user_lang(), 'NAME' => 'l_' . $key, 'OLD' => str_replace('\\n', chr(10), $value_found)));
                }
                $description->attach($actions);
                $fields->attach(form_input_text($key, $description, 'l_' . $key, str_replace('\\n', chr(10), $value_found), false));
            }
        }
        $title = get_page_title('__TRANSLATE_CODE', true, array($lang_name));
        $post_url = build_url(array('page' => 'admin_lang', 'type' => '_code2'), 'adminzone');
        $hidden = form_input_hidden('redirect', get_self_url(true, true));
        $hidden = form_input_hidden('lang', user_lang());
        $echo2 = do_template('FORM_SCREEN', array('_GUID' => '0d4dd16b023d0a7960f3eac85f54ddc4', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => do_lang_tempcode('CONTEXTUAL_EDITING_SCREEN'), 'SUBMIT_NAME' => do_lang_tempcode('SAVE')));
    }
    // Template mode?
    if ($special_page_type == 'templates' || $special_page_type == 'tree') {
        require_lang('themes');
        global $RECORD_TEMPLATES_USED;
        $RECORD_TEMPLATES_USED = false;
        $templates = new ocp_tempcode();
        if ($special_page_type == 'templates') {
            $title = get_page_title('TEMPLATES');
            $_RECORDED_TEMPLATES_USED = array_count_values($RECORDED_TEMPLATES_USED);
            ksort($_RECORDED_TEMPLATES_USED);
            foreach ($_RECORDED_TEMPLATES_USED as $name => $count) {
                //$restore_from=find_template_path($name);
                $file = $name . '.tpl';
                $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'f0file' => $file), 'adminzone', NULL, false, true);
                $templates->attach(do_template('TEMPLATE_LIST_ENTRY', array('COUNT' => integer_format($count), 'NAME' => $name, 'EDIT_URL' => $edit_url)));
            }
        } else {
            $title = get_page_title('TEMPLATE_TREE');
            $hidden = new ocp_tempcode();
            global $CSSS, $JAVASCRIPTS;
            foreach (array_keys($CSSS) as $c) {
                $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', $c . '.css'));
            }
            foreach (array_keys($JAVASCRIPTS) as $c) {
                $hidden->attach(form_input_hidden('f' . strval(mt_rand(0, 100000)) . 'file', strtoupper($c) . '.tpl'));
            }
            $edit_url = build_url(array('page' => 'admin_themes', 'type' => '_edit_templates', 'preview_url' => get_self_url(true, false, array('special_page_type' => NULL)), 'theme' => $GLOBALS['FORUM_DRIVER']->get_theme()), 'adminzone', NULL, false, true);
            $tree = find_template_tree_nice($out->codename, $out->children, $out->fresh);
            $templates = do_template('TEMPLATE_TREE', array('_GUID' => 'ff2a2233b8b4045ba4d8777595ef64c7', 'HIDDEN' => $hidden, 'EDIT_URL' => $edit_url, 'TREE' => $tree));
        }
        $echo2 = do_template('TEMPLATE_LIST_SCREEN', array('_GUID' => 'ab859f67dcb635fcb4d1747d3c6a2c17', 'TITLE' => $title, 'TEMPLATES' => $templates));
    }
    // Query mode?
    if ($special_page_type == 'query') {
        require_lang("profiling");
        global $QUERY_LIST;
        $queries = new ocp_tempcode();
        $total_time = 0.0;
        global $M_SORT_KEY;
        $M_SORT_KEY = 'time';
        usort($QUERY_LIST, 'multi_sort');
        $QUERY_LIST = array_reverse($QUERY_LIST);
        foreach ($QUERY_LIST as $query) {
            $queries->attach(do_template('QUERY_LOG', array('_GUID' => 'ab88e1e92609136229ad920c30647647', 'TIME' => float_format($query['time'], 3), 'TEXT' => $query['text'])));
            $total_time += $query['time'];
        }
        $title = get_page_title("VIEW_PAGE_QUERIES");
        $total = count($QUERY_LIST);
        $echo2 = do_template('QUERY_SCREEN', array('_GUID' => '5f679c8f657b4e4ae94ae2d0ed4843fa', 'TITLE' => $title, 'TOTAL' => integer_format($total), 'TOTAL_TIME' => float_format($total_time, 3), 'QUERIES' => $queries));
    }
    $echo->attach(globalise($echo2));
    $echo->attach(do_footer());
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
    exit;
}