예제 #1
0
파일: index.php 프로젝트: PayIcam/shotgun
    $gingerClient = new GingerClient(Config::get('ginger_key'), Config::get('ginger_server'));
    $payutcClient = getPayutcClient("WEBSALE");
    if (!isset($_GET["id"]) || !isset($_GET["choice_id"])) {
        $app->redirect("index");
    } else {
        $id = $_GET["id"];
        $choice_id = $_GET["choice_id"];
    }
    $choice = new Choice();
    $choice->select($choice_id);
    if ($choice->descId != $id) {
        $app->flash("info", "A quoi tu joues ?");
        $app->redirect("index");
    }
    try {
        $app->response->redirect($choice->shotgun($gingerClient->getUser($_SESSION["username"]), $payutcClient), 303);
        return;
    } catch (\Exception $e) {
        $app->flash("info", $e->getMessage());
    }
    $app->redirect("shotgun?id=" . $id);
});
// Remove a choice
$app->get('/cancel', function () use($app) {
    $gingerClient = new GingerClient(Config::get('ginger_key'), Config::get('ginger_server'));
    $payutcClient = getPayutcClient("WEBSALE");
    if (!isset($_GET["id"])) {
        $app->redirect("index");
    } else {
        $id = $_GET["id"];
    }
예제 #2
0
use Ginger\Client\GingerClient;
use Payutc\Client\AutoJsonClient;
use Payutc\Client\JsonException;
// Load configuration
require "config.inc.php";
require "cas.php";
// Settings for cookies
$sessionPath = parse_url($_CONFIG["self_url"], PHP_URL_PATH);
session_set_cookie_params(0, $sessionPath);
session_start();
$app = new \Slim\Slim();
$payutcClient = new AutoJsonClient($_CONFIG["payutc_server"], "WEBSALE");
$gingerClient = new GingerClient($_CONFIG["ginger_apikey"], $_CONFIG["ginger_server"]);
$app->get('/', function () use($app, $gingerClient, $_CONFIG) {
    if (isset($_SESSION['username'])) {
        $userInfo = $gingerClient->getUser($_SESSION["username"]);
        $app->render('template.php', array("title" => $_CONFIG["title"], "loggedin" => true, "logoutUrl" => $_CONFIG["self_url"] . "logout", "userInfo" => $userInfo, "cotiseUrl" => $_CONFIG["self_url"] . "cotiser"));
    } else {
        $app->render('template.php', array("title" => $_CONFIG["title"], "loggedin" => false, "loginUrl" => $_CONFIG["self_url"] . "logincas"));
    }
});
$app->get('/logincas', function () use($app, $payutcClient, $_CONFIG) {
    if (empty($_GET["ticket"])) {
        $casUrl = $payutcClient->getCasUrl() . "login?service=" . $_CONFIG["self_url"] . 'logincas';
        $app->response->redirect($casUrl, 303);
    } else {
        $cas = new Cas($payutcClient->getCasUrl());
        $user = $cas->authenticate($_GET["ticket"], $_CONFIG["self_url"] . 'logincas');
        $_SESSION['username'] = $user;
        $app->response->redirect($_CONFIG["self_url"], 303);
    }