本文整理汇总了PHP中c_lib函数的典型用法代码示例。如果您正苦于以下问题:PHP c_lib函数的具体用法?PHP c_lib怎么用?PHP c_lib使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了c_lib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* 打开一张图像
* @param string $imgname 图像路径
* @throws \Exception
*/
public function open($imgname)
{
//检测图像文件
if (!is_file($imgname)) {
throw new \Exception(_('The image file does not exist'));
}
//获取图像信息
$info = getimagesize($imgname);
//检测图像合法性
if (false === $info || IMAGETYPE_GIF === $info[2] && empty($info['bits'])) {
throw new \Exception(_('Illegal image file'));
}
//设置图像信息
$this->info = array('width' => $info[0], 'height' => $info[1], 'type' => image_type_to_extension($info[2], false), 'mime' => $info['mime']);
//销毁已存在的图像
empty($this->img) || imagedestroy($this->img);
//打开图像
if ('gif' == $this->info['type']) {
c_lib()->load('image/GIF');
$class = 'CLib\\Image\\GIF';
$this->gif = new $class($imgname);
$this->img = imagecreatefromstring($this->gif->image());
} else {
$fun = "imagecreatefrom{$this->info['type']}";
$this->img = $fun($imgname);
}
}
示例2: __construct
/**
* @param string $drive_name
* @throws \Exception
*/
function __construct($drive_name = 'Local')
{
c_lib()->load('session/' . $drive_name);
$drive_name = "CLib\\Session\\" . $drive_name;
if (!class_exists($drive_name)) {
throw new \Exception(_("Session Drive Not Found"));
}
$this->drive = new $drive_name();
}
示例3: __construct
function __construct()
{
c_lib()->load('sql');
$this->driver = new Sql(cfg()->get('database'));
if (!$this->driver->status()) {
define('HAS_RUN_ERROR', true);
cfg()->set('HAS_RUN_ERROR', $this->driver->ex_message());
}
}
示例4: __construct
/**
* 构造
* @param bool $encode
*/
public function __construct($encode = false)
{
$this->encode = $encode;
if ($encode) {
if (!class_exists('Safe')) {
c_lib()->load('safe');
}
hook()->add('Request_cookie', array($this, 'de'));
hook()->add('Cookie_set', array($this, 'en'));
}
}
示例5: __construct
/**
* 构造
* @param bool $encode
* @param string $key
*/
public function __construct($encode = false, $key = '')
{
$this->encode = $encode;
if ($encode) {
c_lib()->load('safe');
$this->safe = new Safe();
hook()->add('Request_cookie', array($this, 'de'));
hook()->add('Cookie_set', array($this, 'en'));
}
$this->setKey($key);
}
示例6: __construct
function __construct($drive = 'Mcrypt')
{
if ($drive == 'Mcrypt' && !function_exists('mcrypt_create_iv')) {
$drive = "Simple";
}
c_lib()->load('safe/' . $drive);
$drive_name = "CLib\\Safe\\" . $drive;
if (!class_exists($drive_name)) {
throw new \Exception(_("Safe Drive Not Found"));
}
$this->drive = new $drive_name();
}
示例7: add
/**
* 添加钩子,并初始化部分信息
*/
public function add()
{
if (!db()->status()) {
hook()->add('UriInfo_process', array($this, 'sql_error'));
} else {
c_lib()->load('cookie')->add('cookie', new \CLib\Cookie(cfg()->get('cookie', 'encode')));
lib()->load('setting', 'user', 'plugin', 'version_hook')->add('setting', new Setting());
lib()->add('user', new User(true));
lib()->add("version_hook", new Version_Hook());
l_h('theme.php');
hook()->add('UriInfo_process', array($this, 'router'));
lib()->add('plugin', new Plugin(_BasePath_ . "/ex/plugin"));
}
}
示例8: pcache
/**
* 取得缓存对象的实例
* @return \CLib\PCache
*/
function pcache()
{
static $cache = NULL;
if ($cache !== NULL) {
return $cache;
}
$lib = c_lib();
$cache = $lib->using('cache');
if ($cache === false) {
$lib->load('pcache')->add("pcache", new \CLib\PCache(cfg()->get('pcache', 'drive')));
$cache = $lib->using('pcache');
}
return $cache;
}
示例9: __construct
function __construct()
{
$this->c_router = c_lib()->load('router')->add('router', new \CLib\Router());
//对路由信息反序列化
$router = @unserialize(cfg()->get('option', 'router_list'));
foreach (array_keys($router) as $c) {
if (empty($router[$c])) {
unset($router[$c]);
}
}
$this->router_list = $this->defaultRouter();
if (is_array($router)) {
$this->router_list = array_merge($this->router_list, $router);
}
}
示例10: __construct
/**
* 构造方法
* @param string $drive_name 驱动名称
* @param array $drive_config 驱动构造配置文件
* @throws \Exception 抛出驱动未找到的异常
*/
function __construct($drive_name = 'File', $drive_config = [])
{
if (hook()->apply("PCache_set", true)) {
//只有当缓存启用时才调用页面缓存
$this->status = true;
if (empty($drive_name)) {
$drive_name = "File";
}
c_lib()->load('pcache/' . $drive_name);
$drive_name = "CLib\\PCache\\" . $drive_name;
if (!class_exists($drive_name)) {
throw new \Exception(_("Page Cache Drive Not Found"));
}
$this->drive = new $drive_name($drive_config);
hook()->add("Uri_load_begin", [$this, 'hook_begin']);
hook()->add("Uri_load_end", [$this, 'hook_end']);
} else {
$this->status = false;
}
}
示例11: __construct
/**
* 构造方法,用于实例化一个图片处理对象
* @param int $type
* @param null $imgname 初始名称
* @throws \Exception
*/
public function __construct($type = self::IMAGE_GD, $imgname = NULL)
{
/* 判断调用库的类型 */
switch ($type) {
case self::IMAGE_GD:
$class = 'Gd';
break;
case self::IMAGE_IMAGICK:
$class = 'Imagick';
break;
default:
throw new \Exception(_("Unknown type Exception"));
}
/* 引入处理库,实例化图片处理对象 */
c_lib()->load('image/' . $class);
$class = "CLib\\Image\\{$class}";
if (!class_exists($class)) {
throw new \Exception(_("Image interface class error."));
}
$this->img = new $class($imgname);
}
示例12: c_lib
<?php
// +----------------------------------------------------------------------
// | TOPThink [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://topthink.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
// | ImageImagick.class.php 2013-03-06
// +----------------------------------------------------------------------
namespace CLib\Image;
c_lib()->load('image');
use CLib\Image;
use CLib\ImageInterface;
class Imagick implements ImageInterface
{
/**
* 图像资源对象
* @var \Imagick
*/
private $img;
/**
* 图像信息,包括width,height,type,mime,size
* @var array
*/
private $info;
/**
示例13: c_lib
<?php
/**
* Created by PhpStorm.
* User: hzy
* Date: 14-2-8
* Time: 下午10:07
*/
namespace CLib\Session;
c_lib()->load('session');
use CLib\SessionInterface;
/**
* 使用自带的本地存储Session
* Class Local
* @package CLib\Session
*/
class Local implements SessionInterface
{
private $flag = false;
/**
* 启动Session
* @param array $cfg
*/
public function __construct($cfg = [])
{
$config = ['lifetime' => 0, 'path' => NULL, 'domain' => NULL, 'secure' => false, 'httponly' => true];
$config = array_merge($config, $cfg);
session_set_cookie_params($config['lifetime'], $config['path'], $config['domain'], $config['secure'], $config['httponly']);
if (session_status() === PHP_SESSION_DISABLED || session_id() === "") {
//Session未启用
示例14: insert_comment
/**
* 插入评论内容
* @param string $content
* @param int $parent
* @param int $parent_top
* @param int $user_id
* @return int
*/
private function insert_comment($content, $parent, $parent_top, $user_id)
{
c_lib()->load('input');
$input = new Input();
$ip = $input->getIp()->binIp();
$ua = $input->getUA();
$write = $this->db->getWriter();
$write->pdo->beginTransaction();
$info = ['users_id' => $user_id, 'comment_content' => $content, 'comment_time' => $input->time(), 'comment_parent' => $parent ? $parent : NULL, 'comment_parent_top' => $parent_top ? $parent_top : NULL, 'comment_ip' => $ip, 'comment_agent' => $ua];
$info['comment_status'] = $this->get_comment_status($info);
$comment_id = $write->insert("comments", $info);
if ($comment_id < 1) {
$write->pdo->rollBack();
Log::write(implode(",", $write->error()), Log::SQL);
$this->throwMsg(-5);
}
$has_flag = $write->insert($this->relation_table, ['comments_id' => $comment_id, $this->relation_field => $this->id, 'users_id' => $user_id, 'object_users_id' => $this->get_object_users_id()]);
if ($has_flag < 0) {
$write->pdo->rollBack();
Log::write(implode(",", $write->error()), Log::SQL);
$this->throwMsg(-6);
}
$write->pdo->commit();
$rt = $this->comment_hook($content, $parent, $parent_top, $user_id);
if ($parent != 0) {
hook()->apply('Comment_reply', $rt, $this->comment_type, $this->id, $user_id, $parent, $parent_top, $content);
}
return $comment_id;
}
示例15: lib
<?php
/**
* Created by PhpStorm.
* User: hzy
* Date: 14-2-6
* Time: 上午11:21
*/
namespace ULib;
if (!class_exists('\\ULib\\UserCheck')) {
lib()->load('UserCheck');
}
if (!class_exists('\\CLib\\Ip')) {
c_lib()->load('ip');
}
use Core\Log;
use ULib\UserCheck;
use CLib\Ip;
/**
* 用户注册类
* Class UserRegister
* @package ULib
*/
class UserRegister
{
/**
* 对应的激活信息
* @var string
*/
private $activation_msg = "Unknown";