/var/www/html/vendor/league/plates/src/Template/Template.php
public function path()
{
return $this->name->getPath();
}
/**
* Render the template and layout.
* @param array $data
* @throws \Throwable
* @throws \Exception
* @return string
*/
public function render(array $data = array())
{
$this->data($data);
unset($data);
extract($this->data);
if (!$this->exists()) {
throw new LogicException(
'The template "' . $this->name->getName() . '" could not be found at "' . $this->path() . '".'
);
}
try {
$level = ob_get_level();
ob_start();
include $this->path();
$content = ob_get_clean();
if (isset($this->layoutName)) {
$layout = $this->engine->make($this->layoutName);
$layout->sections = array_merge($this->sections, array('content' => $content));
$content = $layout->render($this->layoutData);
}
return $content;
} catch (Throwable $e) {
/var/www/html/vendor/league/plates/src/Engine.php
/**
* Create a new template.
* @param string $name
* @return Template
*/
public function make($name)
{
return new Template($this, $name);
}
/**
* Create a new template and render it.
* @param string $name
* @param array $data
* @return string
*/
public function render($name, array $data = array())
{
return $this->make($name)->render($data);
}
}
/var/www/html/src/App/Application.php
}
/**
* @return \League\Route\RouteCollection
*/
public function getRoute() {
return $this->route;
}
public function run() {
$response = $this->route->dispatch($this->container->get('request'),$this->container->get('response'));
$this->container->get('emitter')->emit($response);
}
public function getPlates() {
return $this->plates;
}
public function render($name, $data = []) {
return $this->plates->render($name, $data);
}
//Util
public function trimWord($limit, $txt)
{
return mb_strimwidth($txt, 0, $limit, '...', 'utf-8');
}
public function showMsg()
{
if (!empty($_SESSION['error'])) {
if (is_array($_SESSION['error'])) {
echo "<div class='alert alert-danger'>";
foreach ($_SESSION['error'] as $err) {
if (is_array($err)) {
foreach ($err as $e) {
echo $e . "<br>";
}
} else {
echo $err . "<br>";
/var/www/html/index.php
R::setup( 'mysql:host=localhost;dbname=symphony', 'symadmin', 'SymphonY1@23' );
$route->group('/{lang}', function ($route) use ($app) {
L::getLang();
$route->map("GET", "/", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$html = $app->render("home");
$response->getBody()->write($html);
return $response;
});
$route->map("GET", "/data", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
echo file_get_contents('http://web.ifzq.gtimg.cn/appstock/app/fqkline/get?_var=kline_dayqfq2013¶m=hk01223,day,2010-01-01,2029-12-31,2000,qfq');
die();
});
$route->map("GET", "/{slug}", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$html = $app->render($args['slug']);
$response->getBody()->write($html);
return $response;
});
$route->map("GET", "/page/{slug}", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$html = $app->render('page', ['page' => R::findOne('page', ' slug = ?', [$args['slug']])]);
$response->getBody()->write($html);
return $response;
});
$route->map("GET", "/terms/{slug}", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$html = $app->render('terms', ['terms' => R::findOne('terms', ' slug = ?', [$args['slug']])]);
$response->getBody()->write($html);
return $response;
});
$route->map("GET", "/sales/{id}", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$html = $app->render('sales_detail', ['l' => R::findOne('sales', ' id = ?', [$args['id']])]);
$response->getBody()->write($html);
return $response;
/var/www/html/vendor/league/route/src/Strategy/RequestResponseStrategy.php
<?php
namespace League\Route\Strategy;
use League\Route\Route;
class RequestResponseStrategy extends AbstractStrategy implements StrategyInterface
{
/**
* {@inheritdoc}
*/
public function dispatch(callable $controller, array $vars, Route $route = null)
{
$response = call_user_func_array($controller, [
$this->getRequest(),
$this->getResponse(),
$vars
]);
return $this->determineResponse($response);
}
}
/var/www/html/vendor/league/route/src/Strategy/RequestResponseStrategy.php
<?php
namespace League\Route\Strategy;
use League\Route\Route;
class RequestResponseStrategy extends AbstractStrategy implements StrategyInterface
{
/**
* {@inheritdoc}
*/
public function dispatch(callable $controller, array $vars, Route $route = null)
{
$response = call_user_func_array($controller, [
$this->getRequest(),
$this->getResponse(),
$vars
]);
return $this->determineResponse($response);
}
}
/var/www/html/vendor/league/route/src/Route.php
throw new RuntimeException(
sprintf(
'Invalid class method provided for: %s::%s',
get_class($class),
$callable[1]
)
);
}
$strategy = $this->getStrategy();
if ($strategy instanceof RequestAwareInterface) {
$strategy->setRequest($request);
}
if ($strategy instanceof ResponseAwareInterface) {
$strategy->setResponse($response);
}
return $strategy->dispatch($callable, $vars, $this);
}
/**
* Get the callable.
*
* @return string|callable
*/
public function getCallable()
{
return $this->callable;
}
/**
* Set the callable.
*
* @param string|callable $callable
*
* @return \League\Route\Route
*/
public function setCallable($callable)
/var/www/html/vendor/league/route/src/Dispatcher.php
return $this->handleFound($match[1], $request, $response, (array) $match[2]);
}
/**
* Handle dispatching of a found route.
*
* @param callable $route
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @param array $vars
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function handleFound(
callable $route,
ServerRequestInterface $request,
ResponseInterface $response,
array $vars
) {
return call_user_func_array($route, [$request, $response, $vars]);
}
/**
* Handle a not found route.
*
* @param \Psr\Http\Message\ResponseInterface $response
*
* @throws \League\Route\Http\Exception\NotFoundException if a response cannot be built
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function handleNotFound(ResponseInterface $response)
{
$exception = new NotFoundException;
if ($this->getStrategy() instanceof JsonStrategy) {
return $exception->buildJsonResponse($response);
}
throw $exception;
/var/www/html/vendor/league/route/src/Dispatcher.php
return $this->handleFound($match[1], $request, $response, (array) $match[2]);
}
/**
* Handle dispatching of a found route.
*
* @param callable $route
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @param array $vars
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function handleFound(
callable $route,
ServerRequestInterface $request,
ResponseInterface $response,
array $vars
) {
return call_user_func_array($route, [$request, $response, $vars]);
}
/**
* Handle a not found route.
*
* @param \Psr\Http\Message\ResponseInterface $response
*
* @throws \League\Route\Http\Exception\NotFoundException if a response cannot be built
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function handleNotFound(ResponseInterface $response)
{
$exception = new NotFoundException;
if ($this->getStrategy() instanceof JsonStrategy) {
return $exception->buildJsonResponse($response);
}
throw $exception;
/var/www/html/vendor/league/route/src/Dispatcher.php
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function handle(ServerRequestInterface $request, ResponseInterface $response)
{
$match = $this->dispatch(
$request->getMethod(),
$request->getUri()->getPath()
);
if ($match[0] === FastRoute::NOT_FOUND) {
return $this->handleNotFound($response);
}
if ($match[0] === FastRoute::METHOD_NOT_ALLOWED) {
$allowed = (array) $match[1];
return $this->handleNotAllowed($response, $allowed);
}
return $this->handleFound($match[1], $request, $response, (array) $match[2]);
}
/**
* Handle dispatching of a found route.
*
* @param callable $route
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @param array $vars
*
* @return \Psr\Http\Message\ResponseInterface
*/
protected function handleFound(
callable $route,
ServerRequestInterface $request,
ResponseInterface $response,
array $vars
) {
return call_user_func_array($route, [$request, $response, $vars]);
}
/var/www/html/vendor/league/route/src/RouteCollection.php
$group = new RouteGroup($prefix, $group, $this);
$this->groups[] = $group;
return $group;
}
/**
* Dispatch the route based on the request.
*
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function dispatch(ServerRequestInterface $request, ResponseInterface $response)
{
$dispatcher = $this->getDispatcher($request);
return $dispatcher->handle($request, $response);
}
/**
* Return a fully configured dispatcher.
*
* @param \Psr\Http\Message\ServerRequestInterface $request
*
* @return \League\Route\Dispatcher
*/
public function getDispatcher(ServerRequestInterface $request)
{
if (is_null($this->getStrategy())) {
$this->setStrategy(new RequestResponseStrategy);
}
$this->prepRoutes($request);
return (new Dispatcher($this->getData()))->setStrategy($this->getStrategy());
}
/var/www/html/src/App/Application.php
$this->container->share('emitter', "Zend\\Diactoros\\Response\\SapiEmitter");
$this->route = new \League\Route\RouteCollection($this->container);
$this->plates = new \League\Plates\Engine("views");
$this->plates->addData([
"app" => $this
]);
}
/**
* @return \League\Route\RouteCollection
*/
public function getRoute() {
return $this->route;
}
public function run() {
$response = $this->route->dispatch($this->container->get('request'),$this->container->get('response'));
$this->container->get('emitter')->emit($response);
}
public function getPlates() {
return $this->plates;
}
public function render($name, $data = []) {
return $this->plates->render($name, $data);
}
//Util
public function trimWord($limit, $txt)
{
return mb_strimwidth($txt, 0, $limit, '...', 'utf-8');
}
public function showMsg()
{
if (!empty($_SESSION['error'])) {
/var/www/html/index.php
$reversed = array_reverse($format_list);
echo json_encode($reversed);
exit();
});
});
//Default TC
$route->map("GET", "/", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
header("Location: http://" . $_SERVER['SERVER_NAME'] . "/tc");
exit();
});
$route->map("GET", "/cron_bak", function (ServerRequestInterface $request, ResponseInterface $response, array $args) use ($app) {
$path = "/backup";
$files = scandir($path);
});
try {
$app->run();
} catch (NotFoundException $ex) {
echo "Not Found";
}