Files
EasySoft-ZenTaoPMS/bin/ztcli
2013-01-23 02:50:40 +00:00

68 lines
2.0 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env php
<?php
/**
* 禅道系统命令行访问入口。使用方法http://www.zentao.net/help-read-78899.html
* The cli router file of zentaopms.
*
* @copyright Copyright 2009-2013 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package bin
* @version $Id$
* @link http://www.ZenTaoPMS.com
*/
error_reporting(E_ALL ^ E_NOTICE);
define('IN_SHELL', true);
/* Judge the args. */
if($argc != 2) die('Usage: ' . basename(__FILE__) . " <request>\n");
/* Parse the request into params. */
$request = parse_url(trim($argv[1]));
$_SERVER['HTTP_HOST'] = $request['host'];
/* Load the framework. */
chdir(dirname(dirname(__FILE__)));
include './framework/router.class.php';
include './framework/control.class.php';
include './framework/model.class.php';
include './framework/helper.class.php';
include './config/config.php';
/* Set the PATH_INFO variable. */
if($config->requestType == 'PATH_INFO')
{
$path = pathinfo($request['path']);
/* url like http://pms.zentao.net/zentao/my-todo.html, PATH_INFO is 'my-todo.html'. */
if(strpos($path['basename'], $config->requestFix))
{
$_SERVER['PATH_INFO'] = $path['basename'];
}
else
{
/* url like http://pms.zentao.net/zentao/my/, PATH_INFO is 'my'. */
if(is_dir('./module/' . $path['basename']))
{
$_SERVER['PATH_INFO'] = $path['basename'];
}
/* url like http://pms.zentao.net/zentao/, PATH_INFO is '/'. */
else
{
$_SERVER['PATH_INFO'] = '/';
}
}
}
else
{
parse_str($request['query'], $_GET);
$_SERVER['SCRIPT_NAME'] = $_SERVER['HTTP_HOST'] . 'index.php';
$_SERVER['REQUEST_URI'] = isset($request['query']) ? $request['query'] : '';
}
/* Instance the app and run it. */
$app = router::createApp('pms', dirname(dirname(__FILE__)));
$common = $app->loadCommon();
$app->parseRequest();
$app->loadModule();