• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP to_guid_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中to_guid_string函数的典型用法代码示例。如果您正苦于以下问题:PHP to_guid_string函数的具体用法?PHP to_guid_string怎么用?PHP to_guid_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了to_guid_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getInstance

 /**
  * 取得数据库类实例
  * @static
  * @access public
  * @return mixed 返回数据库驱动类
  */
 public static function getInstance($db_config = '')
 {
     static $_instance = array();
     $guid = to_guid_string($db_config);
     if (!isset($_instance[$guid])) {
         $obj = new Db();
         $_instance[$guid] = $obj->factory($db_config);
     }
     return $_instance[$guid];
 }
开发者ID:tiger2soft,项目名称:thinkphp-zcms,代码行数:16,代码来源:Db.class.php


示例2: getInstance

 /**
  * 取得缓存类实例
  * 
  * @static
  *
  * @access public
  * @return mixed
  */
 static function getInstance($type = '', $options = array())
 {
     static $_instance = array();
     $guid = $type . to_guid_string($options);
     if (!isset($_instance[$guid])) {
         $obj = new Cache();
         $_instance[$guid] = $obj->connect($type, $options);
     }
     return $_instance[$guid];
 }
开发者ID:siimanager,项目名称:sii,代码行数:18,代码来源:Cache.class.php


示例3: position

 /**
  * 推荐位数据获取
  * 参数名	 是否必须	 默认值	 说明
  * posid	 是	 null	 推荐位ID
  * catid	 否	 null	 调用栏目ID
  * thumb	 否	 0	 是否仅必须缩略图
  * order	 否	 null	 排序类型
  * num	 是	 null	 数据调用数量
  * @param type $data 
  */
 public function position($data)
 {
     //缓存时间
     $cache = (int) $data['cache'];
     $cacheID = to_guid_string($data);
     if ($cache && ($return = S($cacheID))) {
         return $return;
     }
     $posid = (int) $data['posid'];
     if ($posid < 1) {
         return false;
     }
     $catid = (int) $data['catid'];
     $thumb = isset($data['thumb']) ? $data['thumb'] : 0;
     $order = empty($data['order']) ? array("listorder" => "DESC", "id" => "DESC") : $data['order'];
     $num = (int) $data['num'];
     $db = M("PositionData");
     $Position = F("Position");
     if ($num == 0) {
         $num = $Position[$posid]['maxnum'];
     }
     $where = array();
     //设置SQL where 部分
     if (isset($data['where']) && $data['where']) {
         $where['_string'] = $data['where'];
     }
     $where['posid'] = array("EQ", $posid);
     if ($thumb) {
         $where['thumb'] = array("EQ", 1);
     }
     if ($catid > 0) {
         $cat = getCategory($catid);
         if ($cat) {
             //是否包含子栏目
             if ($cat['child']) {
                 $where['catid'] = array("IN", $cat['arrchildid']);
             } else {
                 $where['catid'] = array("EQ", $catid);
             }
         }
     }
     $data = $db->where($where)->order($order)->limit($num)->select();
     foreach ($data as $k => $v) {
         $data[$k]['data'] = unserialize($v['data']);
         $tab = ucwords(getModel($v['modelid'], 'tablename'));
         $data[$k]['data']['url'] = M($tab)->where(array("id" => $v['id']))->getField("url");
     }
     //结果进行缓存
     if ($cache) {
         S($cacheID, $data, $cache);
     }
     return $data;
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:63,代码来源:PositionTagLib.class.php


示例4: getInstance

 /**
  * 获取本类实例
  *
  * @author          mrmsl <[email protected]>
  * @date            2013-04-06 12:55:37
  *
  * @param array $config 配置。默认null,C('TEMPLATE_CONFIG')
  *
  * @return object 本类实例
  */
 public static function getInstance($config = null)
 {
     if (null === $config && ($v = C('TEMPLATE_CONFIG'))) {
         $config = $v;
     }
     $config = $config ? $config : array();
     $identify = to_guid_string($config);
     if (!isset(self::$_instance[$identify])) {
         self::$_instance[$identify] = new Template($config);
     }
     return self::$_instance[$identify];
 }
开发者ID:yunsite,项目名称:yablog,代码行数:22,代码来源:Template.class.php


示例5: __construct

 public function __construct(array $config)
 {
     $this->config = $config;
     $unNum = to_guid_string($config);
     $this->link = new Memcached($unNum);
     $this->link->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
     if (!count($this->link->getServerList())) {
         foreach ($config as $server) {
             $this->link->addServer($server['hosts'], $server['port'], $server['weight']);
         }
     }
     return $this;
 }
开发者ID:knowsee,项目名称:uoke_framework,代码行数:13,代码来源:memcached.class.php


示例6: getInstance

 /**
  * 取得Service 服务
  * @static
  * @access public
  * @return mixed
  */
 static function getInstance($type = '', $options = array())
 {
     static $_instance = array();
     $guid = $type . to_guid_string($options);
     if (!isset($_instance[$guid])) {
         $class = strpos($type, '\\') ? $type : 'Libs\\Service\\' . ucwords(strtolower($type));
         if (class_exists($class)) {
             $connect = new $class($options);
             $_instance[$guid] = $connect->connect($type, $options);
         } else {
             E('Service 服务类不存在!');
         }
     }
     return $_instance[$guid];
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:21,代码来源:Service.class.php


示例7: register

 /**
  * 用户注册
  */
 public function register()
 {
     $rv = array('status' => -1, 'msg' => '账号已存在!');
     $loginName = I('username');
     $loginPwd = I('password');
     $rs = $this->checkLoginKey($loginName);
     if ($rs['status'] == 1) {
         $m = M('users');
         $data = array();
         $data['loginName'] = $loginName;
         $data["loginSecret"] = rand(1000, 9999);
         $data['loginPwd'] = md5($loginPwd . $data['loginSecret']);
         $data['userType'] = 0;
         $data['createTime'] = date('Y-m-d H:i:s');
         $data['userFlag'] = 1;
         $rs = $m->add($data);
         if (false !== $rs) {
             $data = array();
             $data["userId"] = $rs;
             $data["loginTime"] = date('Y-m-d H:i:s');
             $data["loginIp"] = get_client_ip();
             $data["loginSrc"] = 2;
             $data["loginRemark"] = I('loginRemark');
             M('log_user_logins')->add($data);
             //记录tokenId
             $data = array();
             $key = sprintf('%011d', $urs['userId']);
             $tokenId = to_guid_string($key . time());
             $rv['status'] = 1;
             $data['userId'] = $rs;
             $data['tokenId'] = $tokenId;
             $data['startTime'] = date('Y-m-d H:i:s');
             $data['deviceId'] = I('deviceId');
             M('app_session')->add($data);
             $rv['data'] = $this->getUserInfo($rs);
             $rv['data']['tokenId'] = $tokenId;
             self::login();
             //注册成功后登录
         }
     }
     return $rv;
 }
开发者ID:moonlight-wang,项目名称:flmall,代码行数:45,代码来源:UsersModel.class.php


示例8: bang

 /**
  * 评论排行榜
  * @param type $data 
  */
 public function bang($data)
 {
     //缓存时间
     $cache = (int) $data['cache'];
     $cacheID = to_guid_string($data);
     if ($cache && ($cachedata = S($cacheID))) {
         return $cachedata;
     }
     //返回信息数
     $num = $data['num'] ? (int) $data['num'] : 10;
     $db = D("Comments");
     $data = $db->field(array('*', 'count(*)' => 'total'))->group('comment_id')->order(array('total' => 'DESC'))->limit($num)->select();
     //数据处理
     $return = array();
     foreach ($data as $r) {
         list($m, $catid, $id) = explode('-', $r['comment_id']);
         if (getCategory($catid, 'type') && getCategory($catid, 'type') != 0) {
             continue;
         }
         $modeid = getCategory($catid, 'modelid');
         $tablename = ucwords(getModel($modeid, 'tablename'));
         $return[$id] = M($tablename)->where(array('id' => $id))->find();
         $return[$id]['comment_total'] = $r['total'];
     }
     //结果进行缓存
     if ($cache) {
         S($cacheID, $return, $cache);
     }
     return $return;
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:34,代码来源:CommentTagLib.class.php


示例9: page

function page($total, $size = 0, $number = 0, $config = array())
{
    static $_pageCache = array();
    $cacheIterateId = to_guid_string(func_get_args());
    if (isset($_pageCache[$cacheIterateId])) {
        return $_pageCache[$cacheIterateId];
    }
    $defaultConfig = array('number' => $number, 'param' => C("VAR_PAGE"), 'rule' => '', 'isrule' => false, 'tpl' => '', 'tplconfig' => array('listlong' => 6, 'listsidelong' => 2, "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => ""));
    $cfg = array('listlong' => 6, 'listsidelong' => 2, 'list' => '*', 'currentclass' => 'current', 'first' => '&laquo;', 'prev' => '&#8249;', 'next' => '&#8250;', 'last' => '&raquo;', 'more' => '...', 'disabledclass' => 'disabled', 'jump' => '', 'jumpplus' => '', 'jumpaction' => '', 'jumplong' => 50);
    if (!empty($config) && is_array($config)) {
        $defaultConfig = array_merge($defaultConfig, $config);
    }
    $defaultConfig['size'] = $size ? $size : C("PAGE_LISTROWS");
    foreach ($cfg as $key => $value) {
        if (isset($defaultConfig[$key])) {
            $defaultConfig['tplconfig'][$key] = isset($defaultConfig[$key]) ? $defaultConfig[$key] : $value;
        }
    }
    import('Page');
    if ($defaultConfig['isrule'] && empty($defaultConfig['rule'])) {
        $URLRULE = $GLOBALS['URLRULE'] ? $GLOBALS['URLRULE'] : URLRULE;
        $PageLink = array();
        if (!is_array($URLRULE)) {
            $URLRULE = explode("~", $URLRULE);
        }
        $PageLink['index'] = $URLRULE['index'] ? $URLRULE['index'] : $URLRULE[0];
        $PageLink['list'] = $URLRULE['list'] ? $URLRULE['list'] : $URLRULE[1];
        $defaultConfig['rule'] = $PageLink;
    } else {
        if ($defaultConfig['isrule'] && !is_array($defaultConfig['rule'])) {
            $URLRULE = explode('|', $defaultConfig['rule']);
            $PageLink = array();
            $PageLink['index'] = $URLRULE[0];
            $PageLink['list'] = $URLRULE[1];
            $defaultConfig['rule'] = $PageLink;
        }
    }
    $Page = new Page($total, $defaultConfig['size'], $defaultConfig['number'], $defaultConfig['list'], $defaultConfig['param'], $defaultConfig['rule'], $defaultConfig['isrule']);
    $Page->SetPager('default', $defaultConfig['tpl'], $defaultConfig['tplconfig']);
    $_pageCache[$cacheIterateId] = $Page;
    return $_pageCache[$cacheIterateId];
}
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:42,代码来源:~runtime.php


示例10: _read

 /**
 +----------------------------------------------------------
 * 数据库Read操作入口
 +----------------------------------------------------------
 * @access private 
 +----------------------------------------------------------
 * @param mixed $condition 查询条件
 * @param string $fields 查询字段
 * @param boolean $all 是否返回多个数据
 * @param string $order 
 * @param string $limit 
 * @param string $group 
 * @param string $having 
 * @param string $join 
 * @param boolean $cache 是否查询缓存
 * @param boolean $relation 是否关联查询
 * @param boolean $lazy 是否惰性查询
 * @param boolean $lock 是否加锁
 +----------------------------------------------------------
 * @return boolean
 +----------------------------------------------------------
 */
 private function _read($condition = '', $fields = '*', $all = false, $order = '', $limit = '', $group = '', $having = '', $join = '', $cache = false, $relation = false, $lazy = false, $lock = false)
 {
     $table = $this->getTableName();
     if (!empty($this->options)) {
         // 已经有定义的查询表达式
         $condition = $this->options['where'] ? $this->options['where'] : $condition;
         $table = $this->options['table'] ? $this->options['table'] : $this->getTableName();
         $fields = $this->options['filed'] ? $this->options['field'] : $fields;
         $limit = $this->options['limit'] ? $this->options['limit'] : $limit;
         $order = $this->options['order'] ? $this->options['order'] : $order;
         $group = $this->options['group'] ? $this->options['group'] : $group;
         $having = $this->options['having'] ? $this->options['having'] : $having;
         $join = $this->options['join'] ? $this->options['join'] : $join;
         $cache = isset($this->options['cache']) ? $this->options['cache'] : $cache;
         $lock = isset($this->options['lock']) ? $this->options['lock'] : $lock;
         $lazy = isset($this->options['lazy']) ? $this->options['lazy'] : $lazy;
         $relation = isset($this->options['link']) ? $this->options['link'] : $relation;
         unset($this->options);
     }
     // 前置调用
     if (!$this->_before_read($condition)) {
         // 如果返回false 中止
         return false;
     }
     if ($cache) {
         //启用动态数据缓存
         if ($all) {
             $identify = $this->name . 'List_' . to_guid_string(func_get_args());
         } else {
             $identify = $this->name . '_' . to_guid_string($condition);
         }
         $result = S($identify);
         if (false !== $result) {
             if (!$all) {
                 $this->cacheLockVersion($result);
             }
             // 后置调用
             $this->_after_read($condition, $result);
             return $result;
         }
     }
     if ($this->viewModel) {
         $condition = $this->checkCondition($condition);
         $fields = $this->checkFields($fields);
         $order = $this->checkOrder($order);
         $group = $this->checkGroup($group);
     }
     $lazy = $this->lazyQuery || $lazy;
     $lock = $this->pessimisticLock || $lock;
     $rs = $this->db->find($condition, $table, $fields, $order, $limit, $group, $having, $join, $cache, $lazy, $lock);
     $result = $this->rsToVo($rs, $all, 0, $relation);
     // 后置调用
     $this->_after_read($condition, $result);
     if ($result && $cache) {
         S($identify, $result);
     }
     return $result;
 }
开发者ID:skiman100,项目名称:thinksns,代码行数:80,代码来源:Model.class.php


示例11: get_instance_of

/**
 * 取得对象实例 支持调用类的静态方法
 * @param string $name 类名
 * @param string $method 方法名,如果为空则返回实例化对象
 * @param array $args 调用参数
 * @return object
 */
function get_instance_of($name, $method = '', $args = array())
{
    static $_instance = array();
    $identify = empty($args) ? $name . $method : $name . $method . to_guid_string($args);
    if (!isset($_instance[$identify])) {
        if (class_exists($name)) {
            $o = new $name();
            if (method_exists($o, $method)) {
                if (!empty($args)) {
                    $_instance[$identify] = call_user_func_array(array(&$o, $method), $args);
                } else {
                    $_instance[$identify] = $o->{$method}();
                }
            } else {
                $_instance[$identify] = $o;
            }
        } else {
            halt(L('_CLASS_NOT_EXIST_') . ':' . $name);
        }
    }
    return $_instance[$identify];
}
开发者ID:omusico,项目名称:MRFOS,代码行数:29,代码来源:functions.php


示例12: top

 /**
  * 排行榜 (top) 
  * 参数名	 是否必须	 默认值	 说明
  * num	 否	 10	 返回数量
  * order	 否	 hits DESC	 排序类型
  */
 public function top($data)
 {
     //缓存时间
     $cache = (int) $data['cache'];
     $cacheID = to_guid_string($data);
     if ($cache && ($return = S($cacheID))) {
         return $return;
     }
     $num = $data['num'] ? $data['num'] : 10;
     $order = array("hits" => "DESC");
     if ($data['order']) {
         $order = $data['order'];
     }
     $where = array();
     //设置SQL where 部分
     if (isset($data['where']) && $data['where']) {
         $where['_string'] = $data['where'];
     }
     $return = $this->db->where($where)->order($order)->limit($num)->select();
     //增加访问路径
     foreach ($return as $k => $v) {
         $url = ShuipFCMS()->Url->tags($v);
         $return[$k]['url'] = $url['url'];
     }
     if ($cache) {
         S($cacheID, $return, $cache);
     }
     return $return;
 }
开发者ID:sandom123,项目名称:king400,代码行数:35,代码来源:Tags.class.php


示例13: category

 /**
  * 栏目列表(category)
  * 参数名	 是否必须	 默认值	 说明
  * catid	 否	 0	 调用该栏目下的所有栏目 ,默认0,调用一级栏目
  * order	 否	 null	 排序方式、一般按照listorder ASC排序,即栏目的添加顺序
  * @param $data
  */
 public function category($data)
 {
     //缓存时间
     $cache = (int) $data['cache'];
     $cacheID = to_guid_string($data);
     if ($cache && ($array = S($cacheID))) {
         return $array;
     }
     $data['catid'] = intval($data['catid']);
     $where = $array = array();
     //设置SQL where 部分
     if (isset($data['where']) && $data['where']) {
         $where['_string'] = $data['where'];
     }
     $db = M('Category');
     $num = (int) $data['num'];
     if (isset($data['catid'])) {
         $where['ismenu'] = 1;
         $where['parentid'] = $data['catid'];
     }
     //如果条件不为空,进行查库
     if (!empty($where)) {
         if ($num) {
             $categorys = $db->where($where)->limit($num)->order($data['order'])->select();
         } else {
             $categorys = $db->where($where)->order($data['order'])->select();
         }
     }
     //结果进行缓存
     if ($cache) {
         S($cacheID, $categorys, $cache);
     }
     return $categorys;
 }
开发者ID:sandom123,项目名称:king400,代码行数:41,代码来源:Content.class.php


示例14: _navigate

 /**
  * 导航标签
  * 使用方法:
  *      用法示例:<navigate catid="$catid" space=" &gt; " />
  * 参数说明:
  *          @catid		栏目id,可以传入数字,也可以传递变量 $catid
  *          @space		分隔符,支持html代码
  *          @blank		是否新窗口打开
  *          @cache                              缓存时间
  * @staticvar array $_navigateCache
  * @param type $attr 标签属性
  * @param type $content 表情内容
  * @return array|string
  */
 public function _navigate($tag, $content)
 {
     $key = to_guid_string(array($tag, $content));
     $cache = (int) $tag['cache'];
     if ($cache) {
         $data = S($key);
         if ($data) {
             return $data;
         }
     }
     //分隔符,支持html代码
     $space = !empty($tag['space']) ? $tag['space'] : '&gt;';
     //是否新窗口打开
     $target = !empty($tag['blank']) ? ' target="_blank" ' : '';
     $catid = $tag['catid'];
     $parsestr = '';
     //如果传入的是纯数字
     if (is_numeric($catid)) {
         $catid = (int) $catid;
         if (getCategory($catid) == false) {
             return '';
         }
         //获取当前栏目的 父栏目列表
         $arrparentid = array_filter(explode(',', getCategory($catid, 'arrparentid') . ',' . $catid));
         foreach ($arrparentid as $cid) {
             $parsestr[] = '<a href="' . getCategory($cid, 'url') . '" ' . $target . '>' . getCategory($cid, 'catname') . '</a>';
         }
         $parsestr = implode($space, $parsestr);
     } else {
         $parsestr = '';
         $parsestr .= '<?php';
         $parsestr .= '  $arrparentid = array_filter(explode(\',\', getCategory(' . $catid . ',"arrparentid") . \',\' . ' . $catid . ')); ';
         $parsestr .= '  foreach ($arrparentid as $cid) {';
         $parsestr .= '      $parsestr[] = \'<a href="\' . getCategory($cid,\'url\')  . \'" ' . $target . '>\' . getCategory($cid,\'catname\') . \'</a>\';';
         $parsestr .= '  }';
         $parsestr .= '  echo  implode("' . $space . '", $parsestr);';
         $parsestr .= '?>';
     }
     if ($cache) {
         S($key, $parsestr, $cache);
     }
     return $parsestr;
 }
开发者ID:sandom123,项目名称:king400,代码行数:57,代码来源:Shuipf.class.php


示例15: _read

 /**
 +----------------------------------------------------------
 * 数据库Read操作入口
 +----------------------------------------------------------
 * @access private 
 +----------------------------------------------------------
 * @param mixed $condition 查询条件
 * @param string $fields 查询字段
 * @param boolean $all 是否返回多个数据
 * @param string $order 
 * @param string $limit 
 * @param string $group 
 * @param string $having 
 * @param string $join 
 * @param boolean $cache 是否查询缓存
 * @param boolean $relation 是否关联查询
 * @param boolean $lazy 是否惰性查询
 * @param boolean $lock 是否加锁
 +----------------------------------------------------------
 * @return boolean
 +----------------------------------------------------------
 */
 private function _read($condition, $fields = '*', $all = false, $order = '', $limit = '', $group = '', $having = '', $join = '', $cache = false, $relation = false, $lazy = false, $lock = false)
 {
     // 前置调用
     if (!$this->_before_read($condition)) {
         // 如果返回false 中止
         return false;
     }
     if ($all) {
         $identify = $this->name . 'List_' . to_guid_string(func_get_args());
     } else {
         $identify = $this->name . '_' . to_guid_string($condition);
     }
     if ($cache) {
         //启用动态数据缓存
         $result = S($identify);
         if (false !== $result) {
             if (!$all) {
                 $this->cacheLockVersion($result);
             }
             // 后置调用
             $this->_after_read($condition, $result);
             return $result;
         }
     }
     if ($this->viewModel) {
         $condition = $this->checkCondition($condition);
         $fields = $this->checkFields($fields);
         $order = $this->checkOrder($order);
         $group = $this->checkGroup($group);
     }
     $lazy = $this->lazyQuery || $lazy;
     $lock = $this->pessimisticLock || $lock;
     $rs = $this->db->find($condition, $this->getTableName(), $fields, $order, $limit, $group, $having, $join, $cache, $lazy, $lock);
     $result = $this->rsToVo($rs, $all, 0, $relation);
     // 后置调用
     $this->_after_read($condition, $result);
     if ($result && $cache) {
         S($identify, $result);
     }
     return $result;
 }
开发者ID:BGCX262,项目名称:zxzjob-svn-to-git,代码行数:63,代码来源:Model.class.php


示例16: microtime

<?php $GLOBALS['_beginTime'] = microtime(TRUE); defined('PIN_VERSION') or define('PIN_VERSION','3.0'); defined('__ROOT__') or define('__ROOT__','.'); defined('__APP__') or define('__APP__','.'); defined('APP_DEBUG') or define('APP_DEBUG',0); defined('PIN_RELEASE') or define('PIN_RELEASE','20121127'); defined('APP_NAME') or define('APP_NAME','app'); defined('APP_PATH') or define('APP_PATH','./app/'); defined('PIN_DATA_PATH') or define('PIN_DATA_PATH','./data/'); defined('EXTEND_PATH') or define('EXTEND_PATH','./app/Extend/'); defined('CONF_PATH') or define('CONF_PATH','./data/config/'); defined('RUNTIME_PATH') or define('RUNTIME_PATH','./data/runtime/'); defined('HTML_PATH') or define('HTML_PATH','./data/html/'); defined('MEMORY_LIMIT_ON') or define('MEMORY_LIMIT_ON',true); defined('RUNTIME_FILE') or define('RUNTIME_FILE','./data/runtime/~runtime.php'); defined('THINK_PATH') or define('THINK_PATH','D:\\saivi4.0\\sc\\_core/'); defined('THINK_VERSION') or define('THINK_VERSION','3.1'); defined('MAGIC_QUOTES_GPC') or define('MAGIC_QUOTES_GPC',false); defined('IS_CGI') or define('IS_CGI',0); defined('IS_WIN') or define('IS_WIN',1); defined('IS_CLI') or define('IS_CLI',0); defined('_PHP_FILE_') or define('_PHP_FILE_','/sc/index.php'); defined('URL_COMMON') or define('URL_COMMON',0); defined('URL_PATHINFO') or define('URL_PATHINFO',1); defined('URL_REWRITE') or define('URL_REWRITE',2); defined('URL_COMPAT') or define('URL_COMPAT',3); defined('CORE_PATH') or define('CORE_PATH','D:\\saivi4.0\\sc\\_core/Lib/'); defined('MODE_PATH') or define('MODE_PATH','./app/Extend/Mode/'); defined('ENGINE_PATH') or define('ENGINE_PATH','./app/Extend/Engine/'); defined('VENDOR_PATH') or define('VENDOR_PATH','./app/Extend/Vendor/'); defined('LIBRARY_PATH') or define('LIBRARY_PATH','./app/Extend/Library/'); defined('COMMON_PATH') or define('COMMON_PATH','./app/Common/'); defined('LIB_PATH') or define('LIB_PATH','./app/Lib/'); defined('LANG_PATH') or define('LANG_PATH','./app/Lang/'); defined('TMPL_PATH') or define('TMPL_PATH','./app/Tpl/'); defined('LOG_PATH') or define('LOG_PATH','./data/runtime/Logs/'); defined('TEMP_PATH') or define('TEMP_PATH','./data/runtime/Temp/'); defined('DATA_PATH') or define('DATA_PATH','./data/runtime/Data/'); defined('CACHE_PATH') or define('CACHE_PATH','./data/runtime/Cache/'); set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH); function G($start,$end='',$dec=4) { static $_info = array(); static $_mem = array(); if(is_float($end)) { $_info[$start] = $end; }elseif(!empty($end)){ if(!isset($_info[$end])) $_info[$end] = microtime(TRUE); if(MEMORY_LIMIT_ON && $dec=='m'){ if(!isset($_mem[$end])) $_mem[$end] = memory_get_usage(); return number_format(($_mem[$end]-$_mem[$start])/1024); }else{ return number_format(($_info[$end]-$_info[$start]),$dec); } }else{ $_info[$start] = microtime(TRUE); if(MEMORY_LIMIT_ON) $_mem[$start] = memory_get_usage(); } } function N($key, $step=0) { static $_num = array(); if (!isset($_num[$key])) { $_num[$key] = 0; } if (empty($step)) return $_num[$key]; else $_num[$key] = $_num[$key] + (int) $step; } function parse_name($name, $type=0) { if ($type) { return ucfirst(preg_replace("/_([a-zA-Z])/e", "strtoupper('\\1')", $name)); } else { return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_")); } } function require_cache($filename) { static $_importFiles = array(); if (!isset($_importFiles[$filename])) { if (file_exists_case($filename)) { require $filename; $_importFiles[$filename] = true; } else { $_importFiles[$filename] = false; } } return $_importFiles[$filename]; } function file_exists_case($filename) { if (is_file($filename)) { if (IS_WIN && C('APP_FILE_CASE')) { if (basename(realpath($filename)) != basename($filename)) return false; } return true; } return false; } function import($class, $baseUrl = '', $ext='.class.php') { static $_file = array(); $class = str_replace(array('.', '#'), array('/', '.'), $class); if ('' === $baseUrl && false === strpos($class, '/')) { return alias_import($class); } if (isset($_file[$class . $baseUrl])) return true; else $_file[$class . $baseUrl] = true; $class_strut = explode('/', $class); if (empty($baseUrl)) { if ('@' == $class_strut[0] || APP_NAME == $class_strut[0]) { $baseUrl = dirname(LIB_PATH); $class = substr_replace($class, basename(LIB_PATH).'/', 0, strlen($class_strut[0]) + 1); }elseif ('think' == strtolower($class_strut[0])){ $baseUrl = CORE_PATH; $class = substr($class,6); }elseif (in_array(strtolower($class_strut[0]), array('org', 'com'))) { $baseUrl = LIBRARY_PATH; }else { $class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1); $baseUrl = APP_PATH . '../' . $class_strut[0] . '/'.basename(LIB_PATH).'/'; } } if (substr($baseUrl, -1) != '/') $baseUrl .= '/'; $classfile = $baseUrl . $class . $ext; if (!class_exists(basename($class),false)) { return require_cache($classfile); } } function load($name, $baseUrl='', $ext='.php') { $name = str_replace(array('.', '#'), array('/', '.'), $name); if (empty($baseUrl)) { if (0 === strpos($name, '@/')) { $baseUrl = COMMON_PATH; $name = substr($name, 2); } else { $baseUrl = EXTEND_PATH . 'Function/'; } } if (substr($baseUrl, -1) != '/') $baseUrl .= '/'; require_cache($baseUrl . $name . $ext); } function vendor($class, $baseUrl = '', $ext='.php') { if (empty($baseUrl)) $baseUrl = VENDOR_PATH; return import($class, $baseUrl, $ext); } function alias_import($alias, $classfile='') { static $_alias = array(); if (is_string($alias)) { if(isset($_alias[$alias])) { return require_cache($_alias[$alias]); }elseif ('' !== $classfile) { $_alias[$alias] = $classfile; return; } }elseif (is_array($alias)) { $_alias = array_merge($_alias,$alias); return; } return false; } function D($name='',$layer='') { if(empty($name)) return new Model; static $_model = array(); $layer = $layer?$layer:C('DEFAULT_M_LAYER'); if(strpos($name,'://')) { $name = str_replace('://','/'.$layer.'/',$name); }else{ $name = C('DEFAULT_APP').'/'.$layer.'/'.$name; } if(isset($_model[$name])) return $_model[$name]; import($name.$layer); $class = basename($name.$layer); if(class_exists($class)) { $model = new $class(); }else { $model = new Model(basename($name)); } $_model[$name] = $model; return $model; } function M($name='', $tablePrefix='',$connection='') { static $_model = array(); if(strpos($name,':')) { list($class,$name) = explode(':',$name); }else{ $class = 'Model'; } $guid = $tablePrefix . $name . '_' . $class; if (!isset($_model[$guid])) $_model[$guid] = new $class($name,$tablePrefix,$connection); return $_model[$guid]; } function A($name,$layer='') { static $_action = array(); $layer = $layer?$layer:C('DEFAULT_C_LAYER'); if(strpos($name,'://')) { $name = str_replace('://','/'.$layer.'/',$name); }else{ $name = '@/'.$layer.'/'.$name; } if(isset($_action[$name])) return $_action[$name]; import($name.$layer); $class = basename($name.$layer); if(class_exists($class,false)) { $action = new $class(); $_action[$name] = $action; return $action; }else { return false; } } function R($url,$vars=array(),$layer='') { $info = pathinfo($url); $action = $info['basename']; $module = $info['dirname']; $class = A($module,$layer); if($class){ if(is_string($vars)) { parse_str($vars,$vars); } return call_user_func_array(array(&$class,$action),$vars); }else{ return false; } } function L($name=null, $value=null) { static $_lang = array(); if (empty($name)) return $_lang; if (is_string($name)) { $name = strtoupper($name); if (is_null($value)) return isset($_lang[$name]) ? $_lang[$name] : $name; $_lang[$name] = $value; return; } if (is_array($name)) $_lang = array_merge($_lang, array_change_key_case($name, CASE_UPPER)); return; } function C($name=null, $value=null) { static $_config = array(); if (empty($name)) { if(!empty($value) && $array = cache('c_'.$value)) { $_config = array_merge($_config, array_change_key_case($array)); } return $_config; } if (is_string($name)) { if (!strpos($name, '.')) { $name = strtolower($name); if (is_null($value)) return isset($_config[$name]) ? $_config[$name] : null; $_config[$name] = $value; return; } $name = explode('.', $name); $name[0] = strtolower($name[0]); if (is_null($value)) return isset($_config[$name[0]][$name[1]]) ? $_config[$name[0]][$name[1]] : null; $_config[$name[0]][$name[1]] = $value; return; } if (is_array($name)){ $_config = array_merge($_config, array_change_key_case($name)); if(!empty($value)) { cache('c_'.$value,$_config); } return; } return null; } function tag($tag, &$params=NULL) { $extends = C('extends.' . $tag); $tags = C('tags.' . $tag); if (!empty($tags)) { if(empty($tags['_overlay']) && !empty($extends)) { $tags = array_unique(array_merge($extends,$tags)); }elseif(isset($tags['_overlay'])){ unset($tags['_overlay']); } }elseif(!empty($extends)) { $tags = $extends; } if($tags) { if(APP_DEBUG) { G($tag.'Start'); trace('[ '.$tag.' ] --START--','','INFO'); } foreach ($tags as $key=>$name) { if(!is_int($key)) { $name = $key; } B($name, $params); } if(APP_DEBUG) { trace('[ '.$tag.' ] --END-- [ RunTime:'.G($tag.'Start',$tag.'End',6).'s ]','','INFO'); } }else{ return false; } } function add_tag_behavior($tag,$behavior,$path='') { $array = C('tags.'.$tag); if(!$array) { $array = array(); } if($path) { $array[$behavior] = $path; }else{ $array[] = $behavior; } C('tags.'.$tag,$array); } function filter($name, &$content) { $class = $name . 'Filter'; require_cache(LIB_PATH . 'Filter/' . $class . '.class.php'); $filter = new $class(); $content = $filter->run($content); } function B($name, &$params=NULL) { $class = $name.'Behavior'; G('behaviorStart'); $behavior = new $class(); $behavior->run($params); if(APP_DEBUG) { trace('Run '.$name.' Behavior [ RunTime:'.G('behaviorStart','behaviorEnd',6).'s ]','','INFO'); } } function W($name, $data=array(), $return=false) { $class = $name . 'Widget'; require_cache(LIB_PATH . 'Widget/' . $class . '.class.php'); if (!class_exists($class)) throw_exception(L('_CLASS_NOT_EXIST_') . ':' . $class); $widget = Think::instance($class); $content = $widget->render($data); if ($return) return $content; else echo $content; } function strip_whitespace($content) { $stripStr = ''; $tokens = token_get_all($content); $last_space = false; for ($i = 0, $j = count($tokens); $i < $j; $i++) { if (is_string($tokens[$i])) { $last_space = false; $stripStr .= $tokens[$i]; } else { switch ($tokens[$i][0]) { case T_COMMENT: case T_DOC_COMMENT: break; case T_WHITESPACE: if (!$last_space) { $stripStr .= ' '; $last_space = true; } break; case T_START_HEREDOC: $stripStr .= "<<<THINK\n"; break; case T_END_HEREDOC: $stripStr .= "THINK;\n"; for($k = $i+1; $k < $j; $k++) { if(is_string($tokens[$k]) && $tokens[$k] == ';') { $i = $k; break; } else if($tokens[$k][0] == T_CLOSE_TAG) { break; } } break; default: $last_space = false; $stripStr .= $tokens[$i][1]; } } } return $stripStr; } function trace($value='[think]',$label='',$level='DEBUG',$record=false) { static $_trace = array(); if('[think]' === $value){ return $_trace; }else{ $info = ($label?$label.':':'').print_r($value,true); if(APP_DEBUG && 'ERR' == $level) { throw_exception($info); } if(!isset($_trace[$level])) { $_trace[$level] = array(); } $_trace[$level][] = $info; if((defined('IS_AJAX') && IS_AJAX) || !C('SHOW_PAGE_TRACE') || $record) { Log::record($info,$level,$record); } } } class Think { private static $_instance = array(); static public function start() { register_shutdown_function(array('Think','fatalError')); set_error_handler(array('Think','appError')); set_exception_handler(array('Think','appException')); spl_autoload_register(array('Think', 'autoload')); App::run(); return ; } public static function autoload($class) { if(alias_import($class)) return ; if(substr($class,-8)=='Behavior') { if(require_cache(CORE_PATH.'Behavior/'.$class.'.class.php') || require_cache(EXTEND_PATH.'Behavior/'.$class.'.class.php') || require_cache(LIB_PATH.'Behavior/'.$class.'.class.php') || (defined('MODE_NAME') && require_cache(MODE_PATH.ucwords(MODE_NAME).'/Behavior/'.$class.'.class.php'))) { return ; } }elseif(substr($class,-5)=='Model'){ if((defined('GROUP_NAME') && require_cache(LIB_PATH.'Model/'.GROUP_NAME.'/'.$class.'.class.php')) || require_cache(LIB_PATH.'Model/'.$class.'.class.php') || require_cache(EXTEND_PATH.'Model/'.$class.'.class.php') ) { return ; } }elseif(substr($class,-6)=='Action'){ if((defined('GROUP_NAME') && require_cache(LIB_PATH.'Action/'.GROUP_NAME.'/'.$class.'.class.php')) || require_cache(LIB_PATH.'Action/'.$class.'.class.php') || require_cache(EXTEND_PATH.'Action/'.$class.'.class.php') ) { return ; } } $paths = explode(',',C('APP_AUTOLOAD_PATH')); foreach ($paths as $path){ if(import($path.'.'.$class)) return ; } } static public function instance($class,$method='') { $identify = $class.$method; if(!isset(self::$_instance[$identify])) { if(class_exists($class)){ $o = new $class(); if(!empty($method) && method_exists($o,$method)) self::$_instance[$identify] = call_user_func_array(array(&$o, $method)); else self::$_instance[$identify] = $o; } else halt(L('_CLASS_NOT_EXIST_').':'.$class); } return self::$_instance[$identify]; } static public function appException($e) { halt($e->__toString()); } static public function appError($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_ERROR: case E_PARSE: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: ob_end_clean(); if(!ini_get('zlib.output_compression') && C('OUTPUT_ENCODE')) ob_start('ob_gzhandler'); $errorStr = "$errstr ".$errfile." 第 $errline 行."; if(C('LOG_RECORD')) Log::write("[$errno] ".$errorStr,Log::ERR); function_exists('halt')?halt($errorStr):exit('ERROR:'.$errorStr); break; case E_STRICT: case E_USER_WARNING: case E_USER_NOTICE: default: $errorStr = "[$errno] $errstr ".$errfile." 第 $errline 行."; trace($errorStr,'','NOTIC'); break; } } static public function fatalError() { if ($e = error_get_last()) { Think::appError($e['type'],$e['message'],$e['file'],$e['line']); } } } class ThinkException extends Exception { private $type; private $extra; public function __construct($message,$code=0,$extra=false) { parent::__construct($message,$code); $this->type = get_class($this); $this->extra = $extra; } public function __toString() { $trace = $this->getTrace(); if($this->extra) array_shift($trace); $this->class = isset($trace[0]['class'])?$trace[0]['class']:''; $this->function = isset($trace[0]['function'])?$trace[0]['function']:''; $this->file = $trace[0]['file']; $this->line = $trace[0]['line']; $file = file($this->file); $traceInfo = ''; $time = date('y-m-d H:i:m'); foreach($trace as $t) { $traceInfo .= '['.$time.'] '.$t['file'].' ('.$t['line'].') '; $traceInfo .= $t['class'].$t['type'].$t['function'].'('; $traceInfo .= implode(', ', $t['args']); $traceInfo .=")\n"; } $error['message'] = $this->message; $error['type'] = $this->type; $error['detail'] = L('_MODULE_').'['.MODULE_NAME.'] '.L('_ACTION_').'['.ACTION_NAME.']'."\n"; $error['detail'] .= ($this->line-2).': '.$file[$this->line-3]; $error['detail'] .= ($this->line-1).': '.$file[$this->line-2]; $error['detail'] .= '<font color="#FF6600" >'.($this->line).': <strong>'.$file[$this->line-1].'</strong></font>'; $error['detail'] .= ($this->line+1).': '.$file[$this->line]; $error['detail'] .= ($this->line+2).': '.$file[$this->line+1]; $error['class'] = $this->class; $error['function'] = $this->function; $error['file'] = $this->file; $error['line'] = $this->line; $error['trace'] = $traceInfo; if(C('LOG_EXCEPTION_RECORD')) { Log::Write('('.$this->type.') '.$this->message); } return $error ; } } abstract class Behavior { protected $options = array(); public function __construct() { if(!empty($this->options)) { foreach ($this->options as $name=>$val){ if(NULL !== C($name)) { $this->options[$name] = C($name); }else{ C($name,$val); } } array_change_key_case($this->options); } } public function __get($name){ return $this->options[strtolower($name)]; } abstract public function run(&$params); } defined('THINK_PATH') or exit(); class ReadHtmlCacheBehavior extends Behavior { protected $options = array( 'HTML_CACHE_ON' => false, 'HTML_CACHE_TIME' => 60, 'HTML_CACHE_RULES' => array(), 'HTML_FILE_SUFFIX' => '.html', ); public function run(&$params){ if(C('HTML_CACHE_ON')) { $cacheTime = $this->requireHtmlCache(); if( false !== $cacheTime && $this->checkHTMLCache(HTML_FILE_NAME,$cacheTime)) { readfile(HTML_FILE_NAME); exit(); } } } static private function requireHtmlCache() { $htmls = C('HTML_CACHE_RULES'); if(!empty($htmls)) { $htmls = array_change_key_case($htmls); $moduleName = strtolower(MODULE_NAME); $actionName = strtolower(ACTION_NAME); if(isset($htmls[$moduleName.':'.$actionName])) { $html = $htmls[$moduleName.':'.$actionName]; }elseif(isset($htmls[$moduleName.':'])){ $html = $htmls[$moduleName.':']; }elseif(isset($htmls[$actionName])){ $html = $htmls[$actionName]; }elseif(isset($htmls['*'])){ $html = $htmls['*']; }elseif(isset($htmls['empty:index']) && !class_exists(MODULE_NAME.'Action')){ $html = $htmls['empty:index']; }elseif(isset($htmls[$moduleName.':_empty']) && $this->isEmptyAction(MODULE_NAME,ACTION_NAME)){ $html = $htmls[$moduleName.':_empty']; } if(!empty($html)) { $rule = $html[0]; $rule = preg_replace('/{\$(_\w+)\.(\w+)\|(\w+)}/e',"\\3(\$\\1['\\2'])",$rule); $rule = preg_replace('/{\$(_\w+)\.(\w+)}/e',"\$\\1['\\2']",$rule); $rule = preg_replace('/{(\w+)\|(\w+)}/e',"\\2(\$_GET['\\1'])",$rule); $rule = preg_replace('/{(\w+)}/e',"\$_GET['\\1']",$rule); $rule = str_ireplace( array('{:app}','{:module}','{:action}','{:group}'), array(APP_NAME,MODULE_NAME,ACTION_NAME,defined('GROUP_NAME')?GROUP_NAME:''), $rule); $rule = preg_replace('/{|(\w+)}/e',"\\1()",$rule); if(!empty($html[2])) $rule = $html[2]($rule); $cacheTime = isset($html[1])?$html[1]:C('HTML_CACHE_TIME'); define('HTML_FILE_NAME',HTML_PATH . $rule.C('HTML_FILE_SUFFIX')); return $cacheTime; } } return false; } static public function checkHTMLCache($cacheFile='',$cacheTime='') { if(!is_file($cacheFile)){ return false; }elseif (filemtime(C('TEMPLATE_NAME')) > filemtime($cacheFile)) { return false; }elseif(!is_numeric($cacheTime) && function_exists($cacheTime)){ return $cacheTime($cacheFile); }elseif ($cacheTime != 0 && NOW_TIME > filemtime($cacheFile)+$cacheTime) { return false; } return true; } static private function isEmptyAction($module,$action) { $className = $module.'Action'; $class = new $className; return !method_exists($class,$action); } } defined('THINK_PATH') or exit(); class CheckRouteBehavior extends Behavior { protected $options = array( 'URL_ROUTER_ON' => false, 'URL_ROUTE_RULES' => array(), ); public function run(&$return){ $regx = trim($_SERVER['PATH_INFO'],'/'); __EXT__ && $regx = $regx . '.' . __EXT__; if(empty($regx)) return $return = true; if(!C('URL_ROUTER_ON')) return $return = false; $routes = C('URL_ROUTE_RULES'); if(!empty($routes)) { $depr = C('URL_PATHINFO_DEPR'); foreach ($routes as $rule=>$route) { $rule = str_replace('\\/$/', '$/', $rule); if(0===strpos($rule,'/') && preg_match($rule,$regx,$matches)) { return $return = $this->parseRegex($matches,$route,$regx); }else{ $len1 = substr_count($regx,'/'); $len2 = substr_count($rule,'/'); if($len1>=$len2) { if('$' == substr($rule,-1,1)) { if($len1 != $len2) { continue; }else{ $rule = substr($rule,0,-1); } } $match = $this->checkUrlMatch($regx,$rule); if($match) return $return = $this->parseRule($rule,$route,$regx); } } } } $return = false; } private function checkUrlMatch($regx,$rule) { $m1 = explode('/',$regx); $m2 = explode('/',$rule); $match = true; foreach ($m2 as $key=>$val){ if(':' == substr($val,0,1)) { if(strpos($val,'\\')) { $type = substr($val,-1); if('d'==$type &am 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP to_html函数代码示例发布时间:2022-05-23
下一篇:
PHP to_decimal函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap