Beispiel #1
0
function qa_get_form_security_code($action)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    qa_set_form_security_key();
    $timestamp = qa_opt('db_time');
    return (int) qa_is_logged_in() . '-' . $timestamp . '-' . qa_calc_form_security_hash($action, $timestamp);
}
Beispiel #2
0
/**
 *	Run the appropriate qa-page-*.php file for this request and return back the $qa_content it passed
 */
function qa_get_request_content()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $requestlower = strtolower(qa_request());
    $requestparts = qa_request_parts();
    $firstlower = strtolower($requestparts[0]);
    $routing = qa_page_routing();
    if (isset($routing[$requestlower])) {
        qa_set_template($firstlower);
        $qa_content = (require QA_INCLUDE_DIR . $routing[$requestlower]);
    } elseif (isset($routing[$firstlower . '/'])) {
        qa_set_template($firstlower);
        $qa_content = (require QA_INCLUDE_DIR . $routing[$firstlower . '/']);
    } elseif (is_numeric($requestparts[0])) {
        qa_set_template('question');
        $qa_content = (require QA_INCLUDE_DIR . 'pages/question.php');
    } else {
        qa_set_template(strlen($firstlower) ? $firstlower : 'qa');
        // will be changed later
        $qa_content = (require QA_INCLUDE_DIR . 'pages/default.php');
        // handles many other pages, including custom pages and page modules
    }
    if ($firstlower == 'admin') {
        $_COOKIE['qa_admin_last'] = $requestlower;
        // for navigation tab now...
        setcookie('qa_admin_last', $_COOKIE['qa_admin_last'], 0, '/', QA_COOKIE_DOMAIN);
        // ...and in future
    }
    if (isset($qa_content)) {
        qa_set_form_security_key();
    }
    return $qa_content;
}
 /**
  * Outputs cache to the user
  */
 private function get_cache()
 {
     qa_report_process_stage('init_page');
     qa_db_connect('qa_page_db_fail_handler');
     qa_page_queue_pending();
     qa_load_state();
     qa_check_login_modules();
     if (QA_DEBUG_PERFORMANCE) {
         if (qa_qa_version_below('1.7')) {
             qa_usage_mark('setup');
         } else {
             //global $qa_usage;
             //$qa_usage->mark('setup');
             null;
         }
     }
     qa_check_page_clicks();
     qa_set_form_security_key();
     if (!QA_CACHING_FILE) {
         $contents = $this->get_cache_db();
     } else {
         $contents = $this->get_cache_file();
     }
     $qa_content = array();
     // Dummy contents
     $userid = qa_get_logged_in_userid();
     $questionid = qa_request_part(0);
     $cookieid = qa_cookie_get(true);
     if (is_numeric($questionid)) {
         $question = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $questionid));
         if (is_numeric($questionid) && qa_opt('do_count_q_views') && !preg_match("/^(?:POST|PUT)\$/i", $_SERVER["REQUEST_METHOD"]) && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $userid || !isset($question['userid'])) && ($question['cookieid'] != $cookieid || !isset($question['cookieid'])))) {
             $qa_content['inc_views_postid'] = $questionid;
         } else {
             $qa_content['inc_views_postid'] = null;
         }
         qa_do_content_stats($qa_content);
     }
     if (QA_DEBUG_PERFORMANCE) {
         ob_start();
         if (qa_qa_version_below('1.7')) {
             qa_usage_output();
         } else {
             global $qa_usage;
             $qa_usage->output();
         }
         $contents .= ob_get_contents();
         ob_end_clean();
     }
     qa_db_disconnect();
     header('Content-type: ' . strtr('^type/^format; charset=utf-8', array('^type' => 'text', '^format' => $this->get_cache_file_extension())));
     exit($contents);
 }
Beispiel #4
0
/**
 *	Run the appropriate qa-page-*.php file for this request and return back the $qa_content it passed
 */
function qa_get_request_content()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $requestlower = strtolower(qa_request());
    $requestparts = qa_request_parts();
    $firstlower = strtolower($requestparts[0]);
    $routing = qa_page_routing();
    //AGGIUNTO DA BAFIO
    $favoritecategory = array();
    $userid = qa_get_logged_in_userid();
    if ($userid) {
        $categories = qa_db_select_with_pending(qa_db_user_favorite_categories_selectspec($userid));
        foreach ($categories as $cat) {
            $backpath = array_reverse(explode('/', $cat['backpath']));
            if (count($backpath) > 2) {
                array_push($favoritecategory, $backpath);
            }
            $backpath = null;
        }
    }
    if (isset($routing[$requestlower])) {
        qa_set_template($firstlower);
        $qa_content = (require QA_INCLUDE_DIR . $routing[$requestlower]);
    } elseif (isset($routing[$firstlower . '/'])) {
        qa_set_template($firstlower);
        $qa_content = (require QA_INCLUDE_DIR . $routing[$firstlower . '/']);
    } elseif (is_numeric($requestparts[0])) {
        qa_set_template('question');
        $qa_content = (require QA_INCLUDE_DIR . 'pages/question.php');
    } else {
        if (qa_get_logged_in_userid() && $requestparts[0] == '' && count($favoritecategory)) {
            qa_set_template(strlen($firstlower) ? $firstlower : 'qa');
            // will be changed later
            $qa_content = (require QA_INCLUDE_DIR . 'pages/login-default.php');
            // handles many other pages, including custom pages and page modules
        } else {
            qa_set_template(strlen($firstlower) ? $firstlower : 'qa');
            // will be changed later
            $qa_content = (require QA_INCLUDE_DIR . 'pages/default.php');
            // handles many other pages, including custom pages and page modules
        }
    }
    if ($firstlower == 'admin') {
        $_COOKIE['qa_admin_last'] = $requestlower;
        // for navigation tab now...
        setcookie('qa_admin_last', $_COOKIE['qa_admin_last'], 0, '/', QA_COOKIE_DOMAIN);
        // ...and in future
    }
    if (isset($qa_content)) {
        qa_set_form_security_key();
    }
    return $qa_content;
}