#!/usr/bin/env php * @package bin * @version $Id$ * @link http://www.zentao.net */ error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT); define('IN_SHELL', true); /* Judge the args. */ if($argc < 2 or $argc > 3) die('Usage: ' . basename(__FILE__) . " \n"); /* Parse the request into params. */ $request = parse_url(trim($argv[1])); $_SERVER['HTTP_HOST'] = $request['host']; $_SERVER['SCRIPT_NAME'] = $request['path']; /* 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'; /* Instance the app and run it. */ $app = router::createApp('pms', dirname(dirname(__FILE__)), 'router'); $common = $app->loadCommon(); /* Set the PATH_INFO request. */ if(!empty($argv[2]) && $argv[2] == 'pathinfo') { $config->requestType = 'PATH_INFO'; $config->requestFix = '-'; } /* 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'] = '/'; } } $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; } else { parse_str($request['query'], $_GET); $_SERVER['SCRIPT_NAME'] = $request['path']; $_SERVER['REQUEST_URI'] = isset($request['query']) ? $request['query'] : ''; } $app->parseRequest(); $app->loadModule();