本文整理汇总了PHP中tsload函数的典型用法代码示例。如果您正苦于以下问题:PHP tsload函数的具体用法?PHP tsload怎么用?PHP tsload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tsload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoload
/**
* 系统自动加载ThinkPHP类库
* 并且支持配置自动加载路径
* @param string $classname 对象类名
*/
public static function autoload($classname)
{
// 检查是否存在别名定义
if (tsload($classname)) {
return;
}
// 自动加载当前项目的Actioon类和Model类
if (substr($classname, -5) == 'Model') {
tsload(APP_MODEL_PATH . '/' . $classname . '.class.php');
} elseif (substr($classname, -6) == 'Action') {
tsload(APP_ACTION_PATH . '/' . $classname . '.class.php');
} else {
// 根据自动加载路径设置进行尝试搜索
if (tsconfig('APP_AUTOLOAD_PATH')) {
$paths = explode(',', tsconfig('APP_AUTOLOAD_PATH'));
foreach ($paths as $path) {
if (tsload($path . '/' . $classname . '.class.php')) {
// 如果加载类成功则返回
return;
}
}
}
}
return;
}
示例2: getHooksList
/**
* 获取该插件所需的钩子列表
* @param string $name 插件名称
* @return array 插件所需的钩子列表
*/
public function getHooksList($name)
{
$hooks = $this->getHooksInfo();
$hooksBase = get_class_methods('Hooks');
$list = array();
// 生成插件列表
foreach ($hooks['list'] as $value) {
$dirName = ADDON_PATH . DIRECTORY_SEPARATOR . 'plugins';
tsload($this->path . DIRECTORY_SEPARATOR . 'hooks' . DIRECTORY_SEPARATOR . $value . '.class.php');
$hook = array_diff(get_class_methods($value), $hooksBase);
foreach ($hook as $v) {
$list[$v][$name][] = $value;
}
}
// 排序
foreach ($hooks['sort'] as $key => $value) {
if (isset($list[$name][$key])) {
$temp = array();
foreach ($value as $v) {
$temp[] = $hooks['list'][$v];
}
$list[$name][$key] = $temp;
}
}
return $list;
}
示例3: _initialize
/**
* 初始化方法,生成部门的树形对象模型
* @return void
*/
public function _initialize()
{
$field = array('id' => 'department_id', 'name' => 'title', 'pid' => 'parent_dept_id', 'sort' => 'display_order');
tsload(ADDON_PATH . '/model/CateTreeModel');
$this->treeDo = new CateTreeModel('department');
$this->treeDo->setField($field);
}
示例4: __construct
/**
* 初始化方法,加载phpmailer,初始化默认参数
* @return void
*/
public function __construct()
{
tsload(ADDON_PATH . '/library/phpmailer/class.phpmailer.php');
tsload(ADDON_PATH . '/library/phpmailer/class.pop3.php');
tsload(ADDON_PATH . '/library/phpmailer/class.smtp.php');
$emailset = model('Xdata')->get('admin_Config:email');
$this->option = array('email_sendtype' => $emailset['email_sendtype'], 'email_host' => $emailset['email_host'], 'email_port' => $emailset['email_port'], 'email_ssl' => $emailset['email_ssl'], 'email_account' => $emailset['email_account'], 'email_password' => $emailset['email_password'], 'email_sender_name' => $emailset['email_sender_name'], 'email_sender_email' => $emailset['email_sender_email'], 'email_reply_account' => $emailset['email_sender_email']);
}
示例5: save_charge
function save_charge()
{
$data['charge_value'] = floatval($_REQUEST['charge_value']);
$data['charge_score'] = floatval($_REQUEST['charge_score']);
tsload(ADDON_PATH . '/library/WxPayPubHelper/WxPayPubHelper.php');
// dump(WxPayConf_pub::APPID);
// dump(WxPayConf_pub::MCHID);
// dump(WxPayConf_pub::KEY);
// dump(WxPayConf_pub::APPSECRET);
// dump(WxPayConf_pub::NOTIFY_URL);
$out_trade_no = $_REQUEST["out_trade_no"];
empty($out_trade_no) && ($out_trade_no = 'e2e5096d574976e8f115a8f1e0ffb52b');
// 使用订单查询接口
$orderQuery = new OrderQuery_pub();
$orderQuery->setParameter("out_trade_no", "{$out_trade_no}");
// 商户订单号
// 获取订单查询结果
$orderQueryResult = $orderQuery->getResult();
// 商户根据实际情况设置相应的处理流程,此处仅作举例
if ($orderQueryResult["return_code"] == "FAIL") {
return array('status' => 0, 'msg' => "通信出错:" . $orderQueryResult['return_msg']);
} elseif ($orderQueryResult["result_code"] == "FAIL") {
return array('status' => 0, 'msg' => "错误代码:" . $orderQueryResult['err_code'] . " " . "错误代码描述:" . $orderQueryResult['err_code_des']);
} elseif ($data['charge_value'] != $orderQueryResult['total_fee']) {
return array('status' => 0, 'msg' => "对账失败");
}
// echo "交易状态:" . $orderQueryResult ['trade_state'] . "<br>";
// echo "设备号:" . $orderQueryResult ['device_info'] . "<br>";
// echo "用户标识:" . $orderQueryResult ['openid'] . "<br>";
// echo "是否关注公众账号:" . $orderQueryResult ['is_subscribe'] . "<br>";
// echo "交易类型:" . $orderQueryResult ['trade_type'] . "<br>";
// echo "付款银行:" . $orderQueryResult ['bank_type'] . "<br>";
// echo "总金额:" . $orderQueryResult ['total_fee'] . "<br>";
// echo "现金券金额:" . $orderQueryResult ['coupon_fee'] . "<br>";
// echo "货币种类:" . $orderQueryResult ['fee_type'] . "<br>";
// echo "微信支付订单号:" . $orderQueryResult ['transaction_id'] . "<br>";
// echo "商户订单号:" . $orderQueryResult ['out_trade_no'] . "<br>";
// echo "商家数据包:" . $orderQueryResult ['attach'] . "<br>";
// echo "支付完成时间:" . $orderQueryResult ['time_end'] . "<br>";
$data['serial_number'] = t($_REQUEST['serial_number']);
$data['uid'] = $this->mid;
// TODO 以下信息海全需要从财富通接口取
$data['charge_order'] = t($_REQUEST['charge_order']);
$data['charge_type'] = intval($_REQUEST['charge_type']);
$data['ctime'] = intval($_REQUEST['ctime']);
$data['status'] = intval($_REQUEST['status']);
M('credit_charge')->add($data);
$des['content'] = "充值了" . $data['charge_score'] . "积分";
model('Credit')->setUserCredit($data['uid'], array('name' => 'credit_charge', 'score' => $data['charge_score']), 1, $des);
return array('status' => 1, 'msg' => '充值成功');
}
示例6: connect
/**
* 连接缓存
* @access public
* @param string $type 缓存类型
* @param array $options 配置数组
* @return object
*/
public function connect($type = '', $options = array())
{
if (empty($type)) {
$type = C('DATA_CACHE_TYPE');
}
$type = strtolower(trim($type));
$class = 'Cache' . ucwords($type);
tsload(ADDON_PATH . '/library/cache/' . $class . '.class.php');
if (class_exists($class)) {
$cache = new $class($options);
} else {
throw_exception(L('_CACHE_TYPE_INVALID_') . ':' . $type);
}
return $cache;
}
示例7: tsload
<?php
/**
* 缓存模型 - 业务逻辑模型
* @example
* setType($type) 主动设置缓存类型
* set($key, $value, $expire = null) 设置缓存key=>value,expire表示有效时间,null表示永久
* get($key, $mutex = false) 获取缓存数据,支持mutex模式
* getList($prefix, $key) 批量获取指定前缀下的多个key值的缓存
* rm($key) 删除缓存
* @author jason <yangjs17@yeah.net>
* @version TS3.0
*/
// 加载缓存操作类
tsload(CORE_LIB_PATH . '/Cache.class.php');
class CacheModel
{
//public static $_cacheHash = array(); // 缓存的静态变量
protected $handler;
// 操作句柄
protected $type = 'FILE';
// 缓存类型,默认为文件缓存
/**
* 初始化缓存模型对象,缓存类型
* @return void
*/
public function __construct($type = '')
{
$type = model('Xdata')->get('cacheconfig:cachetype');
// $type = empty($type) ? C('DATA_CACHE_TYPE') : $type;
!$type && ($type = $this->type);
示例8: save_charge
public function save_charge()
{
$data['charge_value'] = floatval($_REQUEST['charge_value']);
$data['charge_score'] = floatval($_REQUEST['charge_score']);
tsload(ADDON_PATH . '/library/WxPayPubHelper/WxPayPubHelper.php');
// dump(WxPayConf_pub::APPID);
// dump(WxPayConf_pub::MCHID);
// dump(WxPayConf_pub::KEY);
// dump(WxPayConf_pub::APPSECRET);
// dump(WxPayConf_pub::NOTIFY_URL);
$out_trade_no = $_REQUEST['out_trade_no'];
empty($out_trade_no) && ($out_trade_no = 'e2e5096d574976e8f115a8f1e0ffb52b');
// 使用订单查询接口
$orderQuery = new OrderQuery_pub();
$orderQuery->setParameter('out_trade_no', "{$out_trade_no}");
// 商户订单号
// 获取订单查询结果
$orderQueryResult = $orderQuery->getResult();
// 商户根据实际情况设置相应的处理流程,此处仅作举例
if ($orderQueryResult['return_code'] == 'FAIL') {
return array('status' => 0, 'msg' => '通信出错:' . $orderQueryResult['return_msg']);
} elseif ($orderQueryResult['result_code'] == 'FAIL') {
return array('status' => 0, 'msg' => '错误代码:' . $orderQueryResult['err_code'] . ' ' . '错误代码描述:' . $orderQueryResult['err_code_des']);
} elseif ($data['charge_value'] != $orderQueryResult['total_fee']) {
return array('status' => 0, 'msg' => '对账失败');
}
$data['serial_number'] = t($_REQUEST['serial_number']);
$data['uid'] = $this->mid;
// TODO 以下信息海全需要从积分通接口取
$data['charge_order'] = t($_REQUEST['charge_order']);
$data['charge_type'] = intval($_REQUEST['charge_type']);
$data['ctime'] = intval($_REQUEST['ctime']);
$data['status'] = intval($_REQUEST['status']);
M('credit_charge')->add($data);
$des['content'] = '充值了' . $data['charge_score'] . '积分';
model('Credit')->setUserCredit($data['uid'], array('name' => 'credit_charge', 'score' => $data['charge_score']), 1, $des);
return array('status' => 1, 'msg' => '充值成功');
}
示例9: verify
/**
* 获取验证码图片操作
*/
public function verify()
{
tsload(ADDON_PATH . '/library/Image.class.php');
tsload(ADDON_PATH . '/library/String.class.php');
Image::buildImageVerify();
}
示例10: tsautoload
/**
* 系统自动加载函数
* @param string $classname 对象类名
* @return void
*/
function tsautoload($classname)
{
// 检查是否存在别名定义
if (tsload($classname)) {
return;
}
// 自动加载当前项目的Actioon类和Model类
if (substr($classname, -5) == "Model") {
if (!tsload(ADDON_PATH . '/model/' . $classname . '.class.php')) {
tsload(APP_LIB_PATH . '/Model/' . $classname . '.class.php');
}
} elseif (substr($classname, -6) == "Action") {
tsload(APP_LIB_PATH . '/Action/' . $classname . '.class.php');
} elseif (substr($classname, -6) == "Widget") {
if (!tsload(ADDON_PATH . '/widget/' . $classname . '.class.php')) {
tsload(APP_LIB_PATH . '/Widget/' . $classname . '.class.php');
}
} elseif (substr($classname, -6) == "Addons") {
if (!tsload(ADDON_PATH . '/plugin/' . $classname . '.class.php')) {
tsload(APP_LIB_PATH . '/Plugin/' . $classname . '.class.php');
}
} else {
$paths = array(ADDON_PATH . '/library');
foreach ($paths as $path) {
if (tsload($path . '/' . $classname . '.class.php')) {
// 如果加载类成功则返回
return;
}
}
}
return;
}
示例11: execWidget
/**
* 执行Widget控制器
*/
public static function execWidget()
{
//防止CSRF
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST' && stripos($_SERVER['HTTP_REFERER'], SITE_URL) !== 0 && $_SERVER['HTTP_USER_AGENT'] !== 'Shockwave Flash' && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'adobe flash player') === false && MODULE_NAME != 'Weixin') {
die('illegal request.');
}
$className = MODULE_NAME . 'Widget';
if (!class_exists($className)) {
if (file_exists(APP_PATH . '/Lib/Widget/' . MODULE_NAME . 'Widget/' . MODULE_NAME . 'Widget.class.php')) {
tsload(APP_PATH . '/Lib/Widget/' . MODULE_NAME . 'Widget/' . MODULE_NAME . 'Widget.class.php');
} else {
tsload(APPS_PATH . '/' . $_GET['app_widget'] . '/Lib/Widget/' . MODULE_NAME . 'Widget/' . MODULE_NAME . 'Widget.class.php');
}
}
$module = new $className();
//异常处理
if (!$module) {
// 模块不存在 抛出异常
throw_exception(L('_MODULE_NOT_EXIST_') . MODULE_NAME);
}
//获取当前操作名
$action = ACTION_NAME;
//执行当前操作
if ($rs = call_user_func(array(&$module, $action))) {
echo $rs;
}
return;
}
示例12: tsload
<?php
/**
* 标准插件抽象。该插件具备插件的标准行为。
* 获取信息,以及该插件拥有的管理操作
* @author sampeng
*
*/
tsload(CORE_LIB_PATH . '/addons/AbstractAddons.class.php');
abstract class SimpleAddons extends AbstractAddons
{
private $name;
private $hooklist = array();
/**
* getHooksList
* 获取该插件的所有钩子列表
* @access public
* @return void
*/
public function getHooksList($name)
{
$this->name = $name;
$this->getHooksInfo();
return $this->hooklist;
}
//管理面板
public function adminMenu()
{
return array();
}
//注册hook位该执行的方法
示例13: parse
/**
* 模板解析入口
* 支持普通标签和TagLib解析 支持自定义标签库
* @access public
* @param string $content 要解析的模板内容
* @return string
*/
public function parse($content)
{
// 内容为空不解析
if (empty($content)) {
return '';
}
$begin = $this->config['taglib_begin'];
$end = $this->config['taglib_end'];
// 检查include语法
$content = $this->parseInclude($content);
// 检查PHP语法
$content = $this->parsePhp($content);
// 首先替换literal标签内容
$content = preg_replace('/' . $begin . 'literal' . $end . '(.*?)' . $begin . '\\/literal' . $end . '/eis', "\$this->parseLiteral('\\1')", $content);
// 获取需要引入的标签库列表
// 标签库只需要定义一次,允许引入多个一次
// 一般放在文件的最前面
// 格式:<taglib name="html,mytag..." />
// 当TAGLIB_LOAD配置为true时才会进行检测
if (C('TAGLIB_LOAD')) {
$this->getIncludeTagLib($content);
if (!empty($this->tagLib)) {
// 对导入的TagLib进行解析
$_taglibs = C('_taglibs_');
foreach ($this->tagLib as $tagLibName) {
// 内置标签库
if (!tsload(CORE_LIB_PATH . '/TagLib/TagLib' . ucwords(strtolower($tagLibName)) . '.class.php')) {
// 扩展标签库
if ($_taglibs && isset($_taglibs[$tagLibName])) {
tsload(CORE_LIB_PATH . '/TagLib/TagLib' . $_taglibs[$tagLibName] . '.class.php');
} else {
throw_exception($tagLibName . L('_TAGLIB_NOT_EXIST_'));
}
}
$this->parseTagLib($tagLibName, $content);
}
}
}
// 预先加载的标签库 无需在每个模板中使用taglib标签加载
if (C('TAGLIB_PRE_LOAD')) {
$tagLibs = explode(',', C('TAGLIB_PRE_LOAD'));
foreach ((array) $taglibs as $tag) {
$this->parseTagLib($tag, $content);
}
}
// 内置标签库 无需使用taglib标签导入就可以使用
$tagLibs = explode(',', C('TAGLIB_BUILD_IN'));
foreach ($tagLibs as $tag) {
$this->parseTagLib($tag, $content, true);
}
//解析普通模板标签 {tagName:}
$content = preg_replace('/(' . $this->config['tmpl_begin'] . ')(\\S.+?)(' . $this->config['tmpl_end'] . ')/eis', "\$this->parseTag('\\2')", $content);
return $content;
}
示例14: createSystemConfigPHPFile
/**
* 官方服务器生成后台页面配置信息
*
* @return [type] void
*/
public function createSystemConfigPHPFile()
{
set_time_limit(0);
// 判断文件夹路径是否存在
if (!file_exists(LANG_PATH)) {
mkdir(LANG_PATH, 0777);
}
$data = D('system_config')->findAll();
$fileName = LANG_PATH . '/system_config.php';
// 权限处理
$fp = fopen($fileName, 'w+');
$fileData = "<?php\n";
$fileData .= "return array(\n";
foreach ($data as $val) {
$val['value'] = unserialize($val['value']);
$arr = 'array(';
if ($val['value']['key']) {
$arr .= '\'key\'=>array(';
foreach ($val['value']['key'] as $k0 => $v0) {
$arr .= '\'' . $k0 . '\'=>\'' . htmlspecialchars($v0, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_name']) {
$arr .= '\'key_name\'=>array(';
foreach ($val['value']['key_name'] as $k1 => $v1) {
$arr .= '\'' . $k1 . '\'=>\'' . htmlspecialchars($v1, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_hidden']) {
$arr .= '\'key_hidden\'=>array(';
foreach ($val['value']['key_hidden'] as $k2 => $v2) {
$arr .= '\'' . $k2 . '\'=>\'' . htmlspecialchars($v2, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_type']) {
$arr .= '\'key_type\'=>array(';
foreach ($val['value']['key_type'] as $k3 => $v3) {
$arr .= '\'' . $k3 . '\'=>\'' . htmlspecialchars($v3, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_default']) {
$arr .= '\'key_default\'=>array(';
foreach ($val['value']['key_default'] as $k4 => $v4) {
$arr .= '\'' . $k4 . '\'=>\'' . htmlspecialchars($v4, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_tishi']) {
$arr .= '\'key_tishi\'=>array(';
foreach ($val['value']['key_tishi'] as $k5 => $v5) {
$arr .= '\'' . $k5 . '\'=>\'' . htmlspecialchars($v5, ENT_QUOTES) . '\',';
}
$arr .= '),';
}
if ($val['value']['key_javascript']) {
$arr .= '\'key_javascript\'=>array(';
foreach ($val['value']['key_javascript'] as $k6 => $v6) {
$arr .= '\'' . $k6 . '\'=>\'' . htmlspecialchars($v6, ENT_QUOTES) . '\',';
}
$arr .= ')';
}
$arr .= ')';
if (empty($val['key']) || empty($val['list']) || $arr == 'array()') {
continue;
}
$content[] = "'{$val['key']}-{$val['list']}'=>" . $arr;
}
$fileData .= implode(",\n", $content);
$fileData .= "\n);";
fwrite($fp, $fileData);
fclose($fp);
unset($fileData);
unset($content);
@chmod($fileName, 0775);
tsload(ADDON_PATH . '/library/Update.class.php');
$updateClass = new Update();
$res = $updateClass->zipPackage($fileName, LANG_PATH, 'system_config', LANG_PATH);
unlink($fileName);
echo $res;
}
示例15: upload
/**
* 上传文件
* @access public
* @param string $savePath 上传文件保存路径
* @return string
* @throws ThinkExecption
*/
public function upload($savePath = '')
{
if (!$this->isOpen()) {
$this->error = '没有开启云图片功能';
return false;
}
$fileInfo = array();
$isUpload = false;
// 获取上传的文件信息,对$_FILES数组信息处理
$files = $this->dealFiles($_FILES);
foreach ($files as $key => $file) {
//过滤无效的上传
if (!empty($file['name'])) {
$file['key'] = $key;
$file['extension'] = $this->getExt($file['name']);
if ($this->savePath) {
$file['savepath'] = $this->savePath;
} else {
$file['savepath'] = $this->customPath;
}
if ($this->saveName) {
$file['savename'] = $this->saveName;
} else {
$file['savename'] = uniqid() . "." . $file['extension'];
}
//移动设备上传的无后缀的图片,默认为jpg
if ($GLOBALS['fromMobile'] == true && empty($file['extension'])) {
$file['extension'] = 'jpg';
$file['savename'] = trim($file['savename'], '.') . '.jpg';
} elseif ($this->autoCheck) {
if (!$this->check($file)) {
return false;
}
}
//计算hash
if (function_exists($this->hashType)) {
$fun = $this->hashType;
$file['hash'] = $fun($file['tmp_name']);
}
//上传到云服务器
$config = $this->getConfig();
tsload(ADDON_PATH . '/library/upyun.class.php');
$cloud = new UpYun($config['cloud_image_bucket'], $config['cloud_image_admin'], $config['cloud_image_password']);
$cloud->setTimeout(60);
$file_content = file_get_contents($file['tmp_name']);
$res = $cloud->writeFile('/' . $file['savepath'] . $file['savename'], $file_content, true);
if (!$res) {
$this->error = '上传到云服务器失败!';
return false;
}
//上传成功后保存文件信息,供其它地方调用
unset($file['tmp_name'], $file['error'], $file_content);
$fileInfo[] = $file;
$isUpload = true;
}
}
if ($isUpload) {
$this->uploadFileInfo = $fileInfo;
return true;
} else {
$this->error = '上传出错!文件不符合上传要求。';
return false;
}
}