本文整理汇总了PHP中Pi类的典型用法代码示例。如果您正苦于以下问题:PHP Pi类的具体用法?PHP Pi怎么用?PHP Pi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _pi_autoloader_core
function _pi_autoloader_core($class)
{
if (($pos = strpos($class, '_')) !== false) {
$class = explode('_', $class);
if (empty($class)) {
return false;
}
$first_dir = strtolower($class[0]);
$fileName = array_pop($class);
$class = array_map('strtolower', $class);
$root = $first_dir == 'util' ? PI_ROOT : COM_ROOT;
$file = $root . implode(DOT, $class) . DOT . $fileName . '.php';
if (is_readable($file)) {
Pi::inc($file);
}
} else {
//优先加载工程中的lib,其次加载框架中的util
if (is_readable(PI_UTIl . $class . '.php')) {
Pi::inc(PI_UTIl . $class . '.php');
} else {
if (is_readable(COM_ROOT . 'lib/' . $class . '.php')) {
Pi::inc(COM_ROOT . 'lib/' . $class . '.php');
}
}
}
}
开发者ID:xtzlyp,项目名称:newpi,代码行数:26,代码来源:Loader.php
示例2: __construct
public function __construct()
{
$dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
if (!is_readable($dispatcher) || !Pi::inc($dispatcher)) {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
开发者ID:hihus,项目名称:newpi,代码行数:7,代码来源:WebRouterPipe.php
示例3: index
public function index()
{
//$this->jump('/login',true);
echo "<br>";
echo "in index";
echo "<br>";
$xz = new Xcrypt();
$num = rand(10000, 20000) . rand(10000, 20000) . rand(10000, 20000);
$res = $xz->encode($num);
echo $res;
echo '<br>';
$login = Pi::com('login');
$res = $login->dologin(array('111' => 1241, 'hihu' => 1241));
print_r($res);
// $q = new Queue("hihu",'users',600);
// $q->push(array("queue"=>'真的'));
// $q->push(array("queue"=>'真的'));
// $q->push(array("queue"=>'真的'));
// var_dump($q->getSize());
// var_dump($q->pop());
// var_dump($q->pop());
// var_dump($q->getSize());
// var_dump($q->clear());
// var_dump($q->pop());
}
开发者ID:hihus,项目名称:pi,代码行数:25,代码来源:IndexCtr.php
示例4: __construct
public function __construct()
{
$dispatcher = Pcf::get('global.dispatcher_path', PIPE_HELPER . 'RouteDispatcher.php');
if (!Pi::inc($dispatcher)) {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
开发者ID:hihus,项目名称:pi,代码行数:7,代码来源:WebRouterPipe.php
示例5: execute
public function execute(App $app)
{
$argv = $app->argv;
$script = $app->task_name;
$script = explode('_', $script);
$cls_file = ucfirst(strtolower(array_pop($script)));
if (empty($cls_file)) {
throw new Exception('task.err for run the task for :' . $this->task_name, 1033);
}
$path = '';
$class = '';
if (!empty($script)) {
foreach ($script as $p) {
$p = strtolower($p);
$path .= $p . DOT;
$class .= ucfirst($p);
}
}
$class .= $cls_file;
$path = TASK_PATH . $path;
$file = $path . $cls_file . '.php';
Pi::inc(PI_CORE . 'BaseTask.php');
if (!Pi::inc($file)) {
throw new Exception('task.err can not load the file :' . $file, 1034);
}
if (!class_exists($class)) {
throw new Exception('task.err can not find the class :' . $class, 1035);
}
$cls = new $class();
if (!is_subclass_of($cls, 'BaseTask')) {
throw new Exception('task.err the class ' . $class . ' is not the subclass of BaseTask ', 1036);
}
$cls->execute($argv);
}
开发者ID:xtzlyp,项目名称:newpi,代码行数:34,代码来源:TaskProcessPipe.php
示例6: __invoke
/**
* Invoke as a functor
*
* @return CacheAdapter
*/
public function __invoke()
{
if (!$this->cache) {
$this->cache = clone Pi::service('cache')->storage();
$this->cache->getOptions()->setNamespace($this->getEvent()->getRouteMatch()->getParam('module') . 'action');
}
return $this->cache;
}
开发者ID:Andyyang1981,项目名称:pi,代码行数:13,代码来源:Cache.php
示例7: __construct
/**
* @link http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
*/
public function __construct()
{
$raspi = new Pi();
if ($raspi->getVersion() < 4) {
$this->pins = array(0, 1, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 21, 22, 23, 24, 25);
$this->hackablePins = array(4, 7, 8, 9, 10, 11, 17, 18, 21, 22, 23, 24, 25);
} else {
if ($raspi->getVersion() < 16) {
# new GPIO layout (REV2)
$this->pins = array(2, 3, 4, 7, 8, 9, 10, 11, 14, 15, 17, 18, 22, 23, 24, 25, 27);
$this->hackablePins = array(4, 7, 8, 9, 10, 11, 17, 18, 22, 23, 24, 25, 27);
} else {
# new GPIO layout (B+)
$this->pins = array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
$this->hackablePins = array(4, 5, 6, 12, 13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
}
}
}
开发者ID:sensi,项目名称:php-gpio,代码行数:21,代码来源:Gpio.php
示例8: __construct
public function __construct()
{
$dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php');
if (file_exists($dispatcher)) {
Pi::inc($dispatcher);
} else {
throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032);
}
}
开发者ID:gelcaas,项目名称:newpi,代码行数:9,代码来源:WebRouterPipe.php
示例9: __construct
public function __construct()
{
try {
$url = isset($_GET['url']) ? explode('/', rtrim($_GET['url'], '/')) : null;
if (empty($url[0])) {
$url[0] = 'index';
}
require 'lib/controllers/pi.controller.php';
$controller = new Pi();
$controller->load_model('pi');
if (!method_exists($controller, $url[0])) {
throw new Exception('Invalid method', 404);
}
$params = array_slice($url, 1);
call_user_func_array(array($controller, $url[0]), $params);
} catch (Exception $e) {
$this->error($e);
}
}
开发者ID:rlemon,项目名称:pi.rlemon.com,代码行数:19,代码来源:bootstrap.class.php
示例10: run
public function run()
{
//初始化pipe
$default_pipe = array('WebReqPipe' => 'default', 'WebRouterPipe' => 'default');
$pipes = Pi::get('global.pipes', array());
if (empty($pipes)) {
$pipes = $default_pipe;
}
$this->pipeLoadContainer = $pipes;
parent::run();
}
开发者ID:xtzlyp,项目名称:newpi,代码行数:11,代码来源:Web.php
示例11: getConfig
public static function getConfig($name)
{
$conf = Pi::get('cache.' . $name, array());
if (empty($conf)) {
return null;
}
foreach ($conf as $server) {
if (!isset($server['host']) || !isset($server['port']) || !isset($server['port']) || !isset($server['pconnect'])) {
return null;
}
}
return $conf;
}
开发者ID:xtzlyp,项目名称:newpi,代码行数:13,代码来源:Memcache.php
示例12: dispatch
public function dispatch()
{
if (!$this->checkSign()) {
$this->output('api.err sign', 7099);
}
$mod_name = Pcf::get("global.mod", 'mod');
$func_name = Pcf::get("global.func", 'func');
$mod_seg = Pcf::get("global.mod_seg", '/');
$api_path = Pcf::get("global.base_path", PI_APP_ROOT . PI_APP_NAME . DOT . 'logic' . DOT);
$mod = Comm::Req($mod_name);
$func = Comm::Req($func_name);
$mod = explode($mod_seg, $mod);
$pattern = '/^[0-9a-zA-Z\\/]*$/';
$class = '';
if (!empty($mod)) {
foreach ($mod as $k => $m) {
if (empty($m) || !is_string($m)) {
if (!preg_match($pattern, $m)) {
$this->output('api.err error format mod:' . $m, 1005);
}
unset($mod[$k]);
}
$mod[$k] = strtolower($m);
$class .= ucfirst($mod[$k]);
}
}
if (empty($mod)) {
$this->output('api.err empty api mod:' . $mod, 1006);
}
if (empty($func) || !is_string($func) || !preg_match($pattern, $func)) {
$this->output('api.err empty or error api func:' . $func, 1007);
}
Pi::inc(PI_CORE . 'BaseApi.php');
$file = $api_path . implode(DOT, $mod) . DOT . $class . '.api.php';
if (!Pi::inc($file)) {
$this->output('api.err api router can not load file:' . $file, 1008);
}
if (!class_exists($class)) {
$this->output('api.err api router not find class:' . $class, 1009);
}
$cls = new $class();
if (!is_subclass_of($cls, 'PiBaseApi')) {
$this->output('api.err is not the subclass of BaseApi', 1010);
}
if (!is_callable(array($cls, $func))) {
$this->output('api.err api class:' . $class . ' can not call method:' . $func, 1011);
}
$res = Pi::piCallMethod($cls, $func);
return $res;
}
开发者ID:hihus,项目名称:pi,代码行数:50,代码来源:ApiRouter.php
示例13: dispatch
public function dispatch()
{
$mod_name = Conf::get("global.mod", 'mod');
$func_name = Conf::get("global.func", 'func');
$mod_seg = Conf::get("global.mod_seg", '/');
$api_path = Conf::get("global.base_path", APP_ROOT . APP_NAME . DOT . 'logic' . DOT);
$mod = Comm::Req($mod_name);
$func = Comm::Req($func_name);
$mod = explode($mod_seg, $mod);
$pattern = '/^[0-9a-zA-Z\\/]*$/';
$class = '';
if (!empty($mod)) {
foreach ($mod as $k => $m) {
if (empty($m) || !is_string($m)) {
if (!preg_match($pattern, $m)) {
throw new Exception('error format mod:' . $m, 1005);
}
unset($mod[$k]);
}
$mod[$k] = strtolower($m);
$class .= ucfirst($mod[$k]);
}
}
if (empty($mod)) {
throw new Exception('empty api mod:' . $mod, 1006);
}
if (empty($func) || !is_string($func) || !preg_match($pattern, $func)) {
throw new Exception("empty api func:" . $func, 1007);
}
$file = $api_path . implode(DOT, $mod) . DOT . $class . '.api.php';
if (!is_readable($file)) {
throw new Exception('api router can not load file:' . $file, 1008);
}
Pi::inc(PI_CORE . 'BaseApi.php');
Pi::inc($file);
if (!class_exists($class)) {
throw new Exception('api router not find class:' . $class, 1009);
}
$cls = new $class();
if (!is_subclass_of($cls, 'BaseApi')) {
throw new Exception('api.err is not the subclass of BaseApi ', 1010);
}
$res = $this->_call_method($cls, $func);
if ($res === false) {
throw new Exception('api class:' . $class . ' call method ' . $func . ' err ', 1011);
}
}
开发者ID:gelcaas,项目名称:newpi,代码行数:47,代码来源:ApiRouter.php
示例14: execute
public function execute(PiApp $app)
{
$this->app = $app;
$router = Conf::get('global.router_file', 'ApiRouter.php');
$router_class = Conf::get('global.router_class', 'PiApiRouter');
if (is_readable(PI_CORE . $router)) {
Pi::inc(PI_CORE . $router);
} else {
throw new Exception('api.router can not find the api router : ' . $router, 1030);
}
if (class_exists($router_class)) {
$cls = new $router_class($app);
$cls->dispatch();
} else {
throw new Exception('api.router can not find the router class : ' . $router_class, 1031);
}
}
开发者ID:hihus,项目名称:newpi,代码行数:17,代码来源:ApiHttpRouterPipe.php
示例15: _initLogger
protected function _initLogger()
{
//获得log path
if (!defined("LOG_PATH")) {
define("LOG_PATH", Pi::get('log.path', ''));
}
if (!is_dir(LOG_PATH)) {
die('pi.err can not find the log path');
}
Pi::inc(Pi::get('LogLib'));
$logFile = $this->task_name;
$logLevel = $this->debug === true ? Logger::LOG_DEBUG : Pi::get('log.level', Logger::LOG_TRACE);
$roll = Pi::get('log.roll', Logger::DAY_ROLLING);
$basic = array('logid' => $this->appId);
Logger::init(LOG_PATH, $logFile, $logLevel, array(), $roll);
Logger::addBasic($basic);
}
开发者ID:hihus,项目名称:newpi,代码行数:17,代码来源:Task.php
示例16: execute
public function execute(PiApp $app)
{
$this->app = $app;
$router = Pcf::get('global.router_file', 'ApiRouter.php');
$router_class = Pcf::get('global.router_class', 'PiApiRouter');
if (!Pi::inc(PIPE_HELPER . $router)) {
throw new Exception('api.router can not find the api router : ' . $router, 1030);
}
if (class_exists($router_class)) {
$cls = new $router_class($app);
$res = $cls->dispatch();
//线上环境请处理输出做加密
$cls->output($res);
} else {
throw new Exception('api.router can not find the router class : ' . $router_class, 1031);
}
}
开发者ID:hihus,项目名称:pi,代码行数:17,代码来源:ApiHttpRouterPipe.php
示例17: getConfig
private static function getConfig($name)
{
$c = Pi::get('db.' . $name, null);
$conf = array();
if (empty($c) || !is_array($c)) {
return null;
}
if (!isset($c['master']) && isset($c['slave'])) {
$conf['master'] = $c['slave'];
} else {
if (!isset($c['master']) && !isset($c['slave'])) {
$conf['master'] = $c;
} else {
$conf = $c;
}
}
foreach ($conf as $k => $v) {
if ($k != 'master' && $k != 'slave') {
unset($conf[$k]);
continue;
}
//端口默认 3306
if (!isset($conf[$k]['port'])) {
$conf[$k]['port'] = 3306;
}
//类型默认 mysql
if (!isset($conf[$k]['database_type'])) {
$conf[$k]['database_type'] = 'mysql';
}
//默认字符集
if (!isset($conf[$k]['charset'])) {
$conf[$k]['charset'] = 'utf8';
}
if (!isset($conf[$k]['prefix'])) {
$conf[$k]['prefix'] = '';
}
}
if (empty($conf)) {
return null;
}
return $conf;
}
开发者ID:xtzlyp,项目名称:newpi,代码行数:42,代码来源:db.php
示例18: run
public function run()
{
//内网api调用
if ($this->checkInnerApi()) {
//如果有其他调试输出忽略
ob_start();
define("USE_INNER_API", 1);
Pi::inc(PI_CORE . 'Proxy.php');
PiProxyServer::Server();
} else {
//初始化pipe
$default_pipe = array('ApiReqPipe' => 'default', 'ApiHttpRouterPipe' => 'default');
$pipes = Pi::get('global.pipes', array());
if (empty($pipes)) {
$pipes = $default_pipe;
}
$this->pipeLoadContainer = $pipes;
parent::run();
}
}
开发者ID:hihus,项目名称:pi,代码行数:20,代码来源:Api.php
示例19: loadPipes
function loadPipes($pipes = null, $root = null)
{
//pipe 数组格式 path => class_name
//加载默认的处理管道
if ($pipes == null) {
$pipes = array();
$input = Pi::get('DefaultInputPipe');
$output = Pi::get('DefaultOutputPipe');
$pipes = array($input => PI_PIPE . $input . '.php', $output => PI_PIPE . $output . '.php');
} else {
if (is_string($pipes)) {
$pipes = array($pipes);
}
if (empty($pipes)) {
return false;
}
//加载管道位置
$root = $root == 'default' ? PI_ROOT : COM_ROOT;
foreach ($pipes as $k => $cls) {
$pipes[$cls] = $root . 'pipe' . DOT . $cls . '.php';
unset($pipes[$k]);
}
}
foreach ($pipes as $cls => $path) {
if (isset($this->arr_pipe[$cls])) {
continue;
}
if (is_readable($path)) {
Pi::inc($path);
if (class_exists($cls)) {
$this->arr_pipe[$cls] = new $cls();
}
} else {
throw new Exception('the pipe ' . $cls . ' can not load,check pipe file', 1020);
}
}
}
开发者ID:gelcaas,项目名称:newpi,代码行数:37,代码来源:PipeExecutor.php
示例20: array
<?php
/**
* Pi Engine (http://pialog.org)
*
* @link http://code.pialog.org for the Pi Engine source repository
* @copyright Copyright (c) Pi Engine http://pialog.org
* @license http://pialog.org/license.txt New BSD License
*/
/**
* @author Hossein Azizabadi <[email protected]>
*/
return array('category' => array(array('title' => _a('Admin'), 'name' => 'admin'), array('title' => _a('News module'), 'name' => 'news'), array('title' => _a('Guide module'), 'name' => 'guide'), array('title' => _a('View'), 'name' => 'view'), array('title' => _a('Social'), 'name' => 'social'), array('title' => _a('Manage'), 'name' => 'manage'), array('title' => _a('Order'), 'name' => 'order')), 'item' => array('admin_perpage' => array('category' => 'admin', 'title' => _a('Perpage'), 'description' => '', 'edit' => 'text', 'filter' => 'number_int', 'value' => 10), 'use_news_topic' => array('category' => 'news', 'title' => _a('Use news topics'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'use_guide_category' => array('category' => 'guide', 'title' => _a('Use guide category'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'use_guide_location' => array('category' => 'guide', 'title' => _a('Use guide location'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'filter_location_level' => array('title' => _a('Select location level for show on filter form'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array(1 => _a('level 1'), 2 => _a('level 2'), 3 => _a('level 3'), 4 => _a('level 4'), 5 => _a('level 5')))), 'filter' => 'number_int', 'value' => 1, 'category' => 'guide'), 'view_list_type' => array('title' => _a('Event list type'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array('line' => _a('Line : each event on one line'), 'box' => _a('Box : each event as box and 3 box on one line')))), 'filter' => 'text', 'value' => 'event', 'category' => 'view'), 'view_perpage' => array('category' => 'view', 'title' => _a('Perpage'), 'description' => '', 'edit' => 'text', 'filter' => 'number_int', 'value' => 10), 'related_event' => array('category' => 'view', 'title' => _a('Show related event'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'related_event_type' => array('title' => _a('Related event type'), 'description' => '', 'edit' => array('type' => 'select', 'options' => array('options' => array('event' => _a('By event module topics'), 'guide' => _a('By guide module categories')))), 'filter' => 'text', 'value' => 'event', 'category' => 'view'), 'image_homepage' => array('category' => 'view', 'title' => _a('Set wide image for homepage'), 'description' => '', 'edit' => 'text', 'filter' => 'string', 'value' => ''), 'price_filter' => array('category' => 'view', 'title' => _a('Price filter'), 'description' => _a('Input method : 100-200,Between 100 to 200|200-300,Between 200 to 300|'), 'edit' => 'textarea', 'filter' => 'string', 'value' => ''), 'social_sharing' => array('title' => _t('Social sharing items'), 'description' => '', 'edit' => array('type' => 'multi_checkbox', 'options' => array('options' => Pi::service('social_sharing')->getList())), 'filter' => 'array', 'category' => 'social'), 'manage_active' => array('category' => 'manage', 'title' => _a('Manage event by users'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'manage_approval' => array('category' => 'manage', 'title' => _a('Auto approval user events'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_active' => array('category' => 'order', 'title' => _a('Active order'), 'description' => _a('Manage event registration, ticket stock and activate orders'), 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_free' => array('category' => 'order', 'title' => _a('Show free word for free events'), 'description' => '', 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'order_discount' => array('category' => 'order', 'title' => _a('Active discount system'), 'description' => _a('Discount percent for each rule on each event'), 'edit' => 'checkbox', 'filter' => 'number_int', 'value' => 1), 'text_description_index' => array('category' => 'head_meta', 'title' => _a('Description for index page'), 'description' => '', 'edit' => 'textarea', 'filter' => 'string', 'value' => '')));
开发者ID:pi-module,项目名称:event,代码行数:13,代码来源:config.php
注:本文中的Pi类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论