Beispiel #1
0
<?php

if (!function_exists('curl_init')) {
    throw new \System\Error\Wtf('Facebook needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
    throw new \System\Error\Wtf('Facebook needs the JSON PHP extension.');
}
$request->facebook = new \Helper\Social\Facebook(array('appId' => cfg('facebook', 'app_id'), 'secret' => cfg('facebook', 'app_secret')));
if ($request->facebook->logged_in()) {
    $request->facebook->update();
    $account = $request->facebook->get_account();
    if ($account->user) {
        $account->user->create_session($request);
    }
} else {
    $url = $request->facebook->getLoginUrl(array("scope" => implode(', ', cfg('facebook', 'scope')), "redirect_uri" => 'http://' . $request->host . $request->path));
    redirect_now($url);
}
//The same applies to the GET var csv.
if (isset($_GET['email'])) {
    if ($_GET['email'] != "") {
        if (isset($_GET['table'])) {
            //We 'unpack' the GET vars our caller send us
            $email = $_GET['email'];
            $csv = $_GET['table'];
            //Then we try to call our c++ .out file with the get vars as parameters.
            try {
                //We assign main.out's output to the variable $out.
                exec("./main.out {$csv} {$email}", $out);
                //we display the content of $out in the browser
                foreach ($out as $line) {
                    echo $line . "\n";
                }
                redirect_now("/download?succes=1");
            } catch (Exception $tx) {
                print 'Exception: ' . $tx->getMessage() . "\n";
            }
        } else {
            $output = 'csv not given!';
            echo $output;
            return $output;
        }
    } else {
        $output = 'email not given!';
        echo $output;
        return $output;
    }
} else {
    $output = 'email not given!';
Beispiel #3
0
<?php

\System\Database::init();
if (Godmode\Router::entered($request)) {
    Godmode\Router::init();
    if ($request->logged_in()) {
        if (!\Godmode\Gatekeeper::canAccessGodmode($request->user)) {
            throw new \System\Error\AccessDenied();
        }
    } else {
        $url_login = \System\Router::get_url($request->host, 'god_login');
        if ($request->path != $url_login) {
            redirect_now($url_login);
        }
    }
}
Beispiel #4
0
<?php

$policy = function ($rq, $res) {
    if (strpos($rq->host, 'www') !== 0) {
        return true;
    }
    $host = preg_replace('/^www\\./', '', $rq->host);
    $redir = ($rq->secure ? 'https' : 'http') . '://' . $host . $rq->path . ($rq->query ? '?' . $rq->query : '');
    redirect_now($redir, \System\Http\Response::MOVED_PERMANENTLY);
    return false;
};