# Conflicts:
#	App/Controllers/Blog.php
deploy
a74589669 2019-08-28 20:49:42 +08:00
commit c4be46d55a
6 changed files with 19 additions and 11 deletions

View File

@ -27,6 +27,7 @@ class Blog extends Controller
}
function articleAction(){
View::renderTemplate("/blog/basic.html",['docs'=>null,'index'=>false]);
print_r($this->query_string);
}
function jsAction(){
print_r($_SERVER);

View File

@ -18,10 +18,7 @@ class Home extends \Core\Controller
* @return void
*/
public function indexAction() {
$ret = [];
$ret[1] = "hello";
//View::renderTemplate('Home/index.html');
$this->JsonResp(200,$ret,"OK");
}
public function usersAction() {
$user = Models\User::getAll();

View File

@ -6,7 +6,6 @@
<script type="text/javascript" src="/api/App/Views/blog/js/jquery.js"></script>
<link href="/api/App/Views/blog/css/left.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/api/App/Views/blog/js/left.js"></script>
<script type="text/javascript" src="/api/App/Views/blog/js/showdown.min.js"></script>
<script type="text/javascript" src="/api/App/Views/blog/js/scripts.js"></script>
</head>
<style>

View File

@ -20,6 +20,7 @@ abstract class Controller
public $body ;
protected $input;
protected $debug = false;
protected $query_string;
/**
* Class constructor
*
@ -35,6 +36,7 @@ abstract class Controller
$this->input = json_decode($this->body);
break;
}
$this->query_string = $_SERVER["QUERY_STRING"];
$this->route_params = $route_params;
}
/**
@ -51,11 +53,9 @@ abstract class Controller
public function __call($name, $args)
{
$method = $name . 'Action';
if (method_exists($this, $method)) {
if ($this->before() !== false) {
call_user_func_array([$this, $method], $args);
$this->after();
}
} else {

View File

@ -45,7 +45,9 @@ class Router
// Add start and end delimiters, and case insensitive flag
$route = '/^' . $route . '$/i';
echo '<pre>';
print_r($route);
echo '</pre>';
$this->routes[$route] = $params;
}
public function AddPrefix($prefix){
@ -80,9 +82,9 @@ class Router
//print_r($route);
//echo "</pre>";
if (preg_match($route, $url, $matches)) {
//cho "<pre>";
//print_r($matches);
//echo "</pre>";
echo "<pre>";
print_r($matches);
echo "</pre>";
// Get named capture group values
foreach ($matches as $key => $match) {
if (is_string($key)) {

View File

@ -35,6 +35,15 @@ try{
print "";
return;
}else{
print_r($_SERVER["REQUEST_URI"]);
preg_match("/^.{0,}\?(.{0,})$/i", $_SERVER['REQUEST_URI'], $matches);
echo '<pre>';
print_r($matches['1']);
echo '</pre>';
$pieces = explode("=", $matches['1']);
echo '<pre>';
print_r($pieces);
echo '</pre>';
$router->dispatch($_SERVER['REQUEST_URI']);
}
}catch (Exception $exception){