Controller\Websaccre::generic_request PHP Метод

generic_request() публичный Метод

Handles Your little Hurl.it like service to make requests to remote servers using various methods
public generic_request ( controller\Base $f3 )
$f3 controller\Base
    public function generic_request(\Base $f3)
    {
        $web = \Web::instance();
        $this->response->data['SUBPART'] = 'websaccre_generic_request.html';
        $audit_instance = \Audit::instance();
        if ($f3->get('VERB') == 'POST') {
            $error = false;
            if ($f3->devoid('POST.url')) {
                $error = true;
                \Flash::instance()->addMessage('Please enter a url e.g. http://africahackon.com', 'warning');
            } else {
                $audited_url = $audit_instance->url($f3->get('POST.url'));
                if ($audited_url == TRUE) {
                    //handle POST data
                    $postReceive = $f3->get('POST.postReceive');
                    $createPostArray = parse_str($postReceive, $postData);
                    if (ini_get('open_basedir')) {
                        $follow_loc = FALSE;
                    } else {
                        $follow_loc = TRUE;
                    }
                    $address = $f3->get('POST.url');
                    if ($f3->get('POST.means') == "POST") {
                        $options = array('method' => $f3->get('POST.means'), 'content' => http_build_query($postData), 'follow_location' => $follow_loc);
                        $request_successful = $web->request($address, $options);
                    } elseif ($f3->get('POST.means') == "GET" or $f3->get('POST.means') == "TRACE" or $f3->get('POST.means') == "OPTIONS" or $f3->get('POST.means') == "HEAD") {
                        $options = array('method' => $f3->get('POST.means'), 'follow_location' => $follow_loc);
                        $request_successful = $web->request($address, $options);
                    } else {
                        \Flash::instance()->addMessage('Unsupported Header Method', 'danger');
                    }
                    if (!$request_successful) {
                        \Flash::instance()->addMessage('Something went wrong your request could not be completed.', 'warning');
                    } else {
                        $result_body = $request_successful['body'];
                        $result_headers = $request_successful['headers'];
                        $engine = $request_successful['engine'];
                        $headers_max = implode("\n", $result_headers);
                        $myFinalRequest = "Headers: \n\n" . $headers_max . "\n\n Body:\n\n" . $result_body . "\n\n Engine Used: " . $engine;
                        $this->response->data['content'] = $myFinalRequest;
                    }
                } else {
                    \Flash::instance()->addMessage('You have entered an invalid URL try something like: http://africahackon.com', 'danger');
                }
            }
        }
    }