Beispiel #1
0
 function getRoutes($routes, $link = null)
 {
     foreach ($routes as $route) {
         //echo "<pre>";
         //print_r($route);
         //echo "</pre>";
         echo "<ul>";
         echo "<li>";
         echo "<a href=\"" . $link . $route['options']['route'] . "\">" . $route['options']['route'] . "</a>";
         echo "</li>";
         if (isset($route['child_routes'])) {
             getRoutes($route['child_routes'], $link . $route['options']['route']);
         }
         echo "</ul>";
     }
 }
Beispiel #2
0
 public function run()
 {
     $uri = $this->getBaseUri();
     $data = explode('/', $uri);
     $routes = getRoutes();
     foreach ($data as $value) {
         if (isset($controller)) {
             $this->newController($controller, $value);
             break;
         }
         if (in_array($value, $routes)) {
             $controller = ucfirst($value);
             $controller .= 'Controller';
         }
     }
     if (!isset($controller) && $uri !== '/') {
         redirect('/error/index');
     }
 }
<?php

require_once 'includes/widgets/header.php';
use libAllure\FormHandler;
use libAllure\ElementTextbox;
class FormRouting extends \libAllure\Form
{
    public function __construct()
    {
        parent::__construct('formRouting', 'Update Routing');
        $routes = getSetting('routes');
        $this->addElement(new ElementTextbox('routes', 'Routes', $routes));
        $this->addDefaultButtons();
    }
    public function process()
    {
        setSetting('routes', $this->getElementValue('routes'));
    }
}
$f = new FormRouting();
if ($f->validate()) {
    $f->process();
}
$tpl->assign('routes', getRoutes());
$tpl->display('routing.tpl');
$tpl->assignForm($f);
$tpl->display('form.tpl');
require_once 'includes/widgets/footer.php';
			<select name='from' id='from' onchange='selectSite(this.options[selectedIndex].value)'>
				<?php 
getPlaces($_GET['from']);
?>
			</select><br/>
			to...<br/>
			<select name='to' id='to' onchange='selectSite(this.options[selectedIndex].value)'>
				<?php 
getPlaces($_GET['to']);
?>
			</select><br/>
			</div>
			<div style='border:solid 3px gray; margin:10px; padding:10px;'>
				<input type='submit' value='Show me' />
			</div>
		<form>
		<div style='border:solid 3px gray; margin:10px; padding:10px;'>
<?php 
if (isset($_GET['from']) && isset($_GET['to'])) {
    getRoutes($_GET['from'], $_GET['to']);
}
?>
		</div>
		<div id="credits"><?php 
$include = true;
include '../credits.php';
?>
</div>
	</body>
</html>
Beispiel #5
0
 public function FrontController($uri)
 {
     //检测是否是需要加载的资源
     $ext = pathinfo($uri, PATHINFO_EXTENSION);
     if ($ext && $ext != TEMPLATE_TYPE) {
         if ($this->includeResources($uri, $ext)) {
             return;
         }
     }
     if ($uri == '/' || !$uri) {
         $this->newController('IndexController', 'index');
         return;
     }
     if ($uri == '404') {
         $this->newController('ErrorController', 'index');
         return;
     }
     $data = explode('/', $uri);
     $_SESSION['route'] = $data;
     $routes = getRoutes();
     //dd($data);
     $controller = '';
     $method = $this->checkUrl($data, $routes);
     if (!empty($method)) {
         $controller = ucfirst($method) . 'Controller';
     }
     if ($controller) {
         $_SESSION['webname'] = '测试一下';
         $this->newController($controller, 'index');
         return;
     }
     if (!$controller && $uri !== '/') {
         redirect('/404');
     }
 }
Beispiel #6
0
    $stmt = $mysqli->prepare('SELECT route.id, route.nav_title, is_live FROM route ORDER BY route.nav_order');
    $stmt->execute();
    $stmt->bind_result($id, $title, $is_live);
    $results = array();
    $i = 0;
    while ($stmt->fetch()) {
        $results[$i]['id'] = $id;
        $results[$i]['title'] = $title;
        $results[$i]['is_live'] = $is_live;
        $i++;
    }
    $stmt->close();
    $mysqli->close();
    return $results;
}
$routes = getRoutes($DB_SERVER, $DB_USERNAME, $DB_PASSWORD, $DB_DATABASE);
?>
<html>
<head>
    <title>List Routes</title>
    <?php 
include 'includes/head.php';
?>
</head>
<body>

<?php 
include 'includes/header.php';
?>

<section>
function getRepositoryByPackageFilename($filename)
{
    foreach (getRoutes() as $route) {
        $source = null;
        switch ($route->type) {
            case 'jenkins':
                if (isset($_SERVER['HTTP_JOB_NAME'])) {
                    $source = $_SERVER['HTTP_JOB_NAME'];
                }
                break;
            case 'filename':
                $source = $filename;
                break;
            default:
                continue;
        }
        if (ruleEval($source, $route)) {
            echo "Matched: {$route->line}\n";
            return getRepositoryByName($route->destination);
        } else {
            echo 'Rule does not match: ' . $route->line . "\n";
        }
    }
    throw new Exception('Could not determine which repo to use.');
}
Beispiel #8
0
/**
 * Main
 * @return int Program exit code
 */
function main()
{
    logMessage("VPN Connection at ", date("Y-m-d H:i:s"));
    logMessage("System arguments:\n", getArgumentsDump($_SERVER['argv']));
    // Load in the routes.json config
    $routes = getRoutes();
    if (!$routes) {
        return 1;
    }
    $remoteIp = $_SERVER['argv'][5];
    $remoteIpConfigs = expectObjectGetArray($routes['remotes'], "Invalid remotes value in routes.json");
    // If we have a list of networks to send to this remote IP, set them
    if (isset($remoteIpConfigs[$remoteIp])) {
        logMessage("Configuring routes for {$remoteIp}");
        setRoutes($remoteIpConfigs[$remoteIp]);
    } else {
        // this remote IP is not known by the config
        logMessage("Notice: No routes configured for remote {$remoteIp}");
    }
    return 0;
}
Beispiel #9
0
function printnav($PID, $LID)
{
    $nodes = getNodes($LID, $PID);
    $numN = count($nodes) / 3;
    echo "<div id='Nav'>";
    echo "<div>";
    for ($x = 0; $x < $numN; $x = $x + 3) {
        $NID = $nodes[$x + 2];
        $activities = getActivities($NID, $PID);
        $numA = count($activities) / 3;
        echo "<p title='" . $nodes[$x + 1] . "' class='ActionP'><b>{$nodes[$x]}</b></p>";
        for ($y = 0; $y < $numA; $y = $y + 3) {
            $AID = $activities[$y + 2];
            $desc = $activities[$y + 1];
            $name = $activities[$y];
            echo "<p title='{$desc}' class='InvP'><form action='action.php#invtab' method='post'>\n\t\t\t\t\t<input type='text' value='ACTION' name='mode' hidden>\n\t\t\t\t\t<input type='text' value='{$AID}' name='activity' hidden>\n\t\t\t\t\t<input type='submit' value='{$name}' title=''> </form></p>";
        }
    }
    echo "</div>";
    echo "<div>";
    echo "<p><b>Travel</b></p>";
    $paths = getRoutes($LID);
    $pathsN = count($paths);
    for ($x = 0; $x < $pathsN; $x = $x + 4) {
        $desc = $paths[$x + 2];
        $name = $paths[$x + 1];
        $idkey = $paths[$x];
        echo "<p title='{$desc}' class='InvP'><form action='action.php#invtab' method='post'>\n\t\t\t<input type='text' value='MOVE' name='mode' hidden>\n\t\t\t<input type='text' value='{$idkey}' name='route' hidden>\n\t\t\t<input type='submit' value='{$name}'>\n\t\t\t</form></p>";
    }
    echo "</div>";
    echo "</div>";
}
Beispiel #10
0
 public function applyRoute()
 {
     # dans cette fonction on va appliquer la route donnée et appeler le controller adapté
     include_once 'app/config/routes.php';
     $routes = getRoutes();
     if ($this->isIndex === TRUE) {
         # Cas ou l'url est seulement index.php
         foreach ($routes as $url => $pathToControllerAndMethod) {
             if (strcmp($url, '__default') === 0) {
                 # on découpe la route pour trouver le controller
                 $paths = explode('/', $pathToControllerAndMethod);
                 $pathOfTheController = 'app/controllers/' . ucfirst($paths[0]) . 'Controller.php';
                 if (file_exists($pathOfTheController) === TRUE) {
                     include_once $pathOfTheController;
                     # ici on va definir le basepath
                     //$basePath = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
                     //var_dump($basepath)
                     //echo 'lol'; die;
                     $phpRequest = ucfirst($paths[0]) . 'Controller::' . $paths[1] . '();';
                     eval($phpRequest);
                 } else {
                     echo 'bad route';
                 }
                 die;
             }
         }
         # erreur 404
         echo 'erreur 404 1';
         #  faire le nécéssaire#
     } else {
         # I hope
         $cleanuUrl = implode('/', $this->segments);
         //var_dump($cleanuUrl); die;
         $error404 = TRUE;
         foreach ($routes as $url => $pathToControllerAndMethod) {
             //echo $cleanuUrl . ' ' .$url . '<br>';
             if (strcmp($cleanuUrl, $url) === 0) {
                 //echo 'oui';
                 # Cas ou on a tapé une url validée dans les routes
                 $error404 = FALSE;
                 # on découpe la route pour trouver le controller
                 $paths = explode('/', $pathToControllerAndMethod);
                 if (count($paths) == 2) {
                     # Cas normal
                     $pathOfTheController = 'app/controllers/' . ucfirst($paths[0]) . 'Controller.php';
                     if (file_exists($pathOfTheController) === TRUE) {
                         include_once $pathOfTheController;
                         $phpRequest = ucfirst($paths[0]) . 'Controller::' . $paths[1] . '();';
                         eval($phpRequest);
                     } else {
                         echo 'bad route';
                     }
                 } else {
                     # bad route entered
                     echo 'bad route format :: ex: controller/method';
                 }
             }
         }
         if ($error404 === TRUE) {
             echo 'erreur 404 2';
         }
     }
 }
Beispiel #11
0
<?php

require_once "php/globals.php";
require_once "php/controllers.php";
$requestUri = getCurrentUri();
$routes = getRoutes($requestUri);
if (count($routes) < 1) {
    home_page_controller();
} else {
    if (isset($routes[0])) {
        if (strtolower($routes[0]) == "home") {
            if (!isset($routes[1])) {
                home_page_controller();
            } else {
                if (isset($routes[1])) {
                    if (strtolower($routes[1]) == "strategy") {
                        strategy_page_controller();
                    } else {
                        if (strtolower($routes[1]) == "visualization") {
                            visualization_page_controller();
                        } else {
                            if (strtolower($routes[1]) == "video") {
                                video_page_controller();
                            } else {
                                if (strtolower($routes[1]) == "training") {
                                    training_page_controller();
                                } else {
                                    if (strtolower($routes[1]) == "contact") {
                                        contact_page_controller();
                                    } else {
                                        if (strtolower($routes[1]) == "spinn") {
Beispiel #12
0
 /**
  * @param \Auryn\Injector $injector
  * @param $routesFunction
  * @return \ImagickDemo\Response\Response|StandardHTTPResponse|null
  */
 function servePage()
 {
     $routesFunction = getRoutes();
     $dispatcher = \FastRoute\simpleDispatcher($routesFunction);
     $httpMethod = 'GET';
     //$uri = '/';
     $uri = '/image/Imagick/adaptiveResizeImage';
     if (array_key_exists('REQUEST_URI', $_SERVER)) {
         $uri = $_SERVER['REQUEST_URI'];
     }
     ///$uri = '/image/Imagick/adaptiveResizeImage';
     $path = $uri;
     $queryPosition = strpos($path, '?');
     if ($queryPosition !== false) {
         $path = substr($path, 0, $queryPosition);
     }
     $routeInfo = $dispatcher->dispatch($httpMethod, $path);
     $dispatcherResult = $routeInfo[0];
     if ($dispatcherResult == \FastRoute\Dispatcher::FOUND) {
         $handler = $routeInfo[1];
         $vars = $routeInfo[2];
         if (array_key_exists('category', $vars)) {
             $className = sprintf('ImagickDemo\\%s\\functions', $vars['category']);
             $className::load();
         }
         $params = InjectionParams::fromParams($vars);
         return new Tier($handler, $params);
     } else {
         if ($dispatcherResult == \FastRoute\Dispatcher::NOT_FOUND) {
             return new StandardHTTPResponse(404, $uri, "Route not found");
         }
     }
     //TODO - need to embed allowedMethods....theoretically.
     // $allowedMethods = $routeInfo[1];
     // ... 405 Method Not Allowed
     return new StandardHTTPResponse(405, $uri, "Not allowed");
 }
                <td>' . $routeTag . '</td>
                <td>' . implode(", ", $dirTagArray) . '</td>
               </tr>';
    }
    print '</table><br />';
}
$agencyArray = Agency::getAgencies();
?>

<h2>Routes with more than two directions having useForUI=true</h2>

<p><a href="index.php">Home</a></p>

<b>Version: <?php 
print $version;
?>
 </b>

<p><b>AC Transit</b></p>
<?php 
$routeArray = getRoutes($agencyArray['actransit'], $version);
displayTable($routeArray);
?>



<p><b>SF-Muni</b></p>
<?php 
$routeArray = getRoutes($agencyArray['sf-muni'], $version);
displayTable($routeArray);
require 'footer.php';