4
0
mirror of https://github.com/cwinfo/envayasms.git synced 2025-07-03 05:37:44 +00:00

PHP server library with example implementation; add 'check now' button on menu

This commit is contained in:
Jesse Young
2011-09-12 16:53:38 -07:00
parent d5b973411b
commit cb8d95ebd5
16 changed files with 442 additions and 29 deletions

46
server/php/example/server.php Executable file
View File

@ -0,0 +1,46 @@
<?php
/*
* Example standalone HTTP server that routes all .php URIs to PHP files under ./example_www,
* and routes all other URIs to static files under ./example_www.
*
* index.php is used as the directory index.
*
* Just run it on the command line like "php example_server.php".
*/
require_once __DIR__ . '/httpserver/httpserver.php';
class ExampleServer extends HTTPServer
{
function __construct()
{
parent::__construct(array(
'port' => 8002,
));
}
function route_request($request)
{
$uri = $request->uri;
$doc_root = __DIR__ . '/www';
if (preg_match('#/$#', $uri))
{
$uri .= "index.php";
}
if (preg_match('#\.php$#', $uri))
{
return $this->get_php_response($request, "$doc_root$uri");
}
else
{
return $this->get_static_response($request, "$doc_root$uri");
}
}
}
$server = new ExampleServer();
$server->run_forever();