Exemplo n.º 1
0
<?php

namespace Skybet;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . "/ErrorReporting/php_error.php";
\php_error\reportErrors();
error_reporting(E_ALL);
$environment = 'development';
//loading routes
$router = new \League\Route\RouteCollection();
$router->addRoute('GET', '/', 'Skybet\\Controllers\\MainController::ListAll');
// Classname::methodName
$router->addRoute('POST', '/add', 'Skybet\\Controllers\\MainController::add');
$router->addRoute('POST', '/update', 'Skybet\\Controllers\\MainController::update');
$router->addRoute('POST', '/delete', 'Skybet\\Controllers\\MainController::del');
$dispatcher = $router->getDispatcher();
$response = $dispatcher->dispatch($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
$response->send();
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Amir Hossein Babaeian
 * Date: 12/26/15
 * Time: 10:44 AM
 */
use Symfony\Component\HttpFoundation\Request;
$router = new League\Route\RouteCollection();
$router->addRoute('GET', '/migrate', 'app\\controllers\\MigrationController::index');
$router->addRoute('GET', '/welcome', 'app\\controllers\\DefaultController::welcome');
$router->addRoute('GET', '/', 'app\\controllers\\DefaultController::shoutBox');
$router->addRoute('POST', '/', 'app\\controllers\\DefaultController::shoutBox');
$router->addRoute('GET', '/{uri}', 'app\\controllers\\DefaultController::index');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 3
0
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\DomCrawler\Crawler;
use Evista\Perform\Service;
use Evista\Perform\Exception\FormFieldException;
date_default_timezone_set('Europe/Budapest');
$router = new League\Route\RouteCollection();
$loader = new Twig_Loader_Filesystem('../src/views');
$crawler = new Crawler();
// Initialize form transpilation service (dependency injection friendly interface)
$formService = new Service($crawler, '../var/uploads');
$twig = new Twig_Environment($loader, array('cache' => '../var/cache'));
$twig->clearCacheFiles();
$router->addRoute('GET', '/', function (Request $request, Response $response) use($twig) {
    // do something clever
    $response = new Response($twig->render('form.twig.html', []));
    return $response;
});
$router->addRoute('POST', '/displayform', function (Request $request, Response $response) use($twig, $crawler, $formService) {
    $formMarkup = $request->request->get('serform');
    $form = $formService->transpileForm($formMarkup);
    // Dump the object
    $response = new JsonResponse(['dump' => var_export($form, true)]);
    return $response;
});
// Use form data
$router->addRoute('POST', '/multiple-file-uploads', function (Request $request, Response $response) use($twig, $crawler, $formService) {
    $formMarkup = urldecode($request->request->get('serform'));
    try {
        $form = $formService->transpileForm($formMarkup);
    } catch (\Exception $exception) {
Exemplo n.º 4
0
<?php

require '../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$router->addRoute('GET', '/', 'Rayac\\searchController::action');
$router->addRoute('POST', '/', 'Rayac\\searchController::find');
$router->addRoute('GET', '/{link}!{from}', 'Rayac\\peopleController::action');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 5
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
$router->addRoute('GET', '/dashboard', 'Controller::dashboard');
$router->addRoute('GET', '/api', 'Controller::api');
$router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
$router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
$router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
$router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
$router->addRoute('POST', '/webmention', 'API::webmention');
$router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
$router->addRoute('GET', '/login', 'Auth::login');
$router->addRoute('GET', '/logout', 'Auth::logout');
$router->addRoute('POST', '/login/start', 'Auth::login_start');
$router->addRoute('GET', '/login/callback', 'Auth::login_callback');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 6
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
# Browser routes
$router->addRoute('GET', '/device', 'Controller::device');
$router->addRoute('GET', '/auth/verify_code', 'Controller::verify_code');
$router->addRoute('GET', '/auth/redirect', 'Controller::redirect');
# Device API
$router->addRoute('POST', '/device/code', 'Controller::generate_code');
$router->addRoute('POST', '/device/token', 'Controller::access_token');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 7
0
<?php

/**
 * Bootstrap. This file, the test suite, and the CLI tool all run the same bootstrap.
 */
require_once 'bootstrap.php';
/**
 * Routes.
 */
$router = new League\Route\RouteCollection();
// Assets, installation, and home.
$router->addRoute('GET', '/{file:.*\\.(?:css|js)}', 'App\\Controllers\\AssetsController::css');
$router->addRoute('GET', '/', 'App\\Controllers\\TagController::index');
// Items.
$router->addRoute('GET', '/create', 'App\\Controllers\\ItemController::edit');
$router->addRoute('POST', '/save', 'App\\Controllers\\ItemController::save');
$router->addRoute('GET', '/{id:number}', 'App\\Controllers\\ItemController::view');
$router->addRoute('GET', '/{id:number}/edit', 'App\\Controllers\\ItemController::edit');
//Tags
$router->addRoute('GET', '/t/{id:number}', 'App\\Controllers\\TagController::index');
$router->addRoute('GET', '/t/{id:number}/edit', 'App\\Controllers\\TagController::edit');
// Files
$router->addRoute('GET', '/{id:number}.png', 'App\\Controllers\\FileController::render');
$router->addRoute('GET', '/{id:number}_{size}.png', 'App\\Controllers\\FileController::render');
$router->addRoute('GET', '/{id:number}_v{version}_{size}.png', 'App\\Controllers\\FileController::render');
// Users and groups.
$router->addRoute('GET', '/login', 'App\\Controllers\\UserController::loginForm');
$router->addRoute('POST', '/login', 'App\\Controllers\\UserController::login');
$router->addRoute('GET', '/register', 'App\\Controllers\\UserController::registerForm');
$router->addRoute('POST', '/register', 'App\\Controllers\\UserController::register');
$router->addRoute('GET', '/remind/{userid}/{token}', 'App\\Controllers\\UserController::remindResetForm');
Exemplo n.º 8
0
$router->get('/', function (Request $request, Response $response) use($twig, $config) {
    $response->setContent($twig->render('index.html.twig', ['players' => $config['players']]));
    return $response;
});
$router->get('/play', function (Request $request, Response $response, array $args) use($twig, $config) {
    return new RedirectResponse('/');
});
$router->get('/obs', function (Request $request, Response $response, array $args) use($twig, $config) {
    $response->setContent($twig->render('obs.html.twig', ['players' => $config['players'], 'display_host' => $config['display_host'], 'contestants' => $config['contestants']]));
    return $response;
});
$router->get('/play/{player}', function (Request $request, Response $response, array $args) use($twig, $config) {
    $player = $args['player'];
    if (!in_array($player, $config['players'], true)) {
        return new RedirectResponse('/');
    }
    $response->setContent($twig->render('play.html.twig', ['players' => $config['players'], 'user' => $player, 'contestants' => $config['contestants']]));
    return $response;
});
$router->get('/all', function (Request $request, Response $response, array $args) use($twig, $config) {
    $response->setContent($twig->render('all.html.twig', ['players' => $config['players'], 'display_host' => $config['display_host'], 'contestants' => $config['contestants']]));
    return $response;
});
$router->addRoute('GET', '/admin', function (Request $request, Response $response) use($twig, $config) {
    $response->setContent($twig->render('admin.html.twig', ['players' => $config['players'], 'contestants' => $config['contestants'], 'enable_toggle' => $config['enable_toggle'], 'current_game' => getenv('CURRENT_GAME')]));
    return $response;
});
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 9
0
<?php

use Rayac\skola\user;
use Symfony\Component\HttpFoundation\Request;
require_once '../vendor/autoload.php';
session_start();
$router = new League\Route\RouteCollection();
if (empty($_SESSION['language'])) {
    $_SESSION['language'] = "en";
}
$router->addRoute('GET', '/', 'Rayac\\skola\\controllers\\homeController::action');
$router->addRoute('GET', '/hr', 'Rayac\\skola\\controllers\\languageController::croatia');
$router->addRoute('GET', '/en', 'Rayac\\skola\\controllers\\languageController::english');
$router->addRoute('GET', '/reg', 'Rayac\\skola\\controllers\\regController::action');
$router->addRoute('GET', '/login', 'Rayac\\skola\\controllers\\loginController::action');
$router->addRoute('GET', '/logout', 'Rayac\\skola\\controllers\\loginController::logout');
$router->addRoute('GET', '/gallery', 'Rayac\\skola\\controllers\\homeController::gallery');
$router->addRoute('GET', '/aboutus', 'Rayac\\skola\\controllers\\homeController::aboutus');
$router->addRoute('GET', '/account', 'Rayac\\skola\\controllers\\accountController::action');
$router->addRoute('GET', '/create', 'Rayac\\skola\\controllers\\postController::action');
$router->addRoute('GET', '/plan/{id}', 'Rayac\\skola\\controllers\\postController::show');
$router->addRoute('POST', '/create', 'Rayac\\skola\\controllers\\postController::create');
$router->addRoute('POST', '/login', 'Rayac\\skola\\controllers\\loginController::login');
$router->addRoute('POST', '/reg', 'Rayac\\skola\\controllers\\regController::register');
$router->addRoute('POST', '/filipmail', 'Rayac\\skola\\controllers\\homeController::filipmail');
//$router->addRoute('GET', '/{link}!{from}', 'Rayac\peopleController::action');
$dispatcher = $router->getDispatcher();
$request = Request::createFromGlobals();
$response = $dispatcher->dispatch($request->getMethod(), $request->getPathInfo());
$response->send();
Exemplo n.º 10
0
<?php

chdir('..');
include 'vendor/autoload.php';
use Errbit\Errbit;
if (Config::$errbitHost) {
    Errbit::instance()->configure(array('api_key' => Config::$errbitKey, 'host' => Config::$errbitHost, 'port' => 443, 'secure' => true))->start();
}
initdb();
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$router = new League\Route\RouteCollection();
$templates = new League\Plates\Engine(dirname(__FILE__) . '/../views');
$router->addRoute('GET', '/', 'Controller::index');
$router->addRoute('GET', '/dashboard', 'Controller::dashboard');
$router->addRoute('GET', '/site/new', 'Controller::new_site');
$router->addRoute('GET', '/site/edit', 'Controller::new_site');
$router->addRoute('POST', '/site/save', 'Controller::save_site');
$router->addRoute('GET', '/api', 'Controller::api');
$router->addRoute('GET', '/superfeedr', 'Controller::superfeedr');
$router->addRoute('GET', '/webmention/{code}/details', 'Controller::webmention_details');
$router->addRoute('GET', '/dashboard/send', 'Controller::dashboard_send');
$router->addRoute('POST', '/dashboard/get_outgoing_links.json', 'Controller::get_outgoing_links');
$router->addRoute('POST', '/dashboard/discover_endpoint.json', 'Controller::discover_endpoint');
$router->addRoute('POST', '/webmention', 'API::webmention');
$router->addRoute('POST', '/superfeedr/{token}', 'API::superfeedr_tracker');
$router->addRoute('GET', '/webmention/{code}', 'API::webmention_status');
$router->addRoute('GET', '/login', 'Auth::login');
$router->addRoute('GET', '/logout', 'Auth::logout');
$router->addRoute('POST', '/login/start', 'Auth::login_start');
$router->addRoute('GET', '/login/callback', 'Auth::login_callback');
// register autoload
require 'vendor/autoload.php';
// use keyword to avoid FQCN declaration
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use League\Route\Http\Exception\NotFoundException;
use Workshop\About;
use Workshop\Profile;
// create route collection
$router = new League\Route\RouteCollection();
// create page object
$about = new About();
$profile = new Profile();
// register route
$router->addRoute('GET', '/about', $about);
$router->addRoute('GET', '/profile', $profile);
// create route dispatcher
$dispatcher = $router->getDispatcher();
// create request object from globals
$request = Request::createFromGlobals();
try {
    // dispatch request
    $response = $dispatcher->dispatch($request->getMethod(), $request->getRequestUri());
} catch (NotFoundException $e) {
    // catch not found exception
    $response = new Response('Not Found', Response::HTTP_NOT_FOUND, ['Content-Type' => 'text/html']);
} finally {
    // send response to browser
    $response->send();
}