示例#1
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  * @author jry <*****@*****.**>
  */
 public function getAllAddon($addon_dir = THINK_ADDON_PATH)
 {
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $map['name'] = array('in', $dirs);
     $list = $this->where($map)->field(true)->order('sort asc,id desc')->select();
     foreach ($list as $addon) {
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['status'] = -1;
                 //未安装
             }
         }
     }
     foreach ($addons as &$val) {
         switch ($val['status']) {
             case '-1':
                 //未安装
                 $val['status'] = '<i class="glyphicon glyphicon-trash" style="color:red"></i>';
                 $val['right_button'] = '<a class="ajax-get" href="' . U('install?addon_name=' . $val['name']) . '">安装</a>';
                 break;
             case '0':
                 //禁用
                 $val['status'] = '<i class="glyphicon glyphicon-ban-circle" style="color:red"></i>';
                 $val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '">启用</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
                 if ($val['adminlist']) {
                     $val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
                 }
                 break;
             case '1':
                 //正常
                 $val['status'] = '<i class="glyphicon glyphicon-ok" style="color:green"></i>';
                 $val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '">禁用</a> ';
                 $val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
                 if ($val['adminlist']) {
                     $val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
                 }
                 break;
         }
     }
     return $addons;
 }
 public function getRank()
 {
     $aType = I('post.type', 'today', 'op_t');
     $name = get_addon_class('CheckIn');
     $class = new $name();
     $html = $class->rank($aType);
     $this->ajaxReturn(array('status' => 1, 'html' => $html));
 }
 public function _initialize()
 {
     $class = get_addon_class('BaiduRankTool');
     if (!class_exists($class)) {
         $this->error('插件不存在');
     }
     $this->addon = new $class();
     $this->_config = $this->addon->getConfig();
 }
示例#4
0
文件: addons.php 项目: Willshon/OLCS
/**
 * 获取插件类的配置文件数组
 * @param string $name 插件名
 */
function get_addon_config($name)
{
    $class = get_addon_class($name);
    if (class_exists($class)) {
        $addon = new $class();
        return $addon->getConfig();
    } else {
        return array();
    }
}
示例#5
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  */
 public function getList($addon_dir = '')
 {
     if (!$addon_dir) {
         $addon_dir = ONETHINK_ADDON_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     //TODO 新增模块插件的支持
     /* $modules=D('Module')->getAll();
        foreach($modules as $m){
            if($m['is_setup']){
                $module_dir=APP_PATH.$m['name'].'/Addons/';
                if(!file_exists($module_dir)){
                    continue;
                }
                $tmp_dirs = array_map('basename',glob($module_dir.'*', GLOB_ONLYDIR));
                $dirs=array_merge($dirs,$tmp_dirs);
            }
        }*/
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->select();
     foreach ($list as $addon) {
         $addon['uninstall'] = 0;
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 unset($addons[$value]['status']);
             }
         }
     }
     //dump($list);exit;
     int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
示例#6
0
 /**
  * 获取插件列表
  *
  * @param string $addon_dir        	
  */
 public function getList($addon_dir = '')
 {
     if (!$addon_dir) {
         $addon_dir = ONETHINK_ADDON_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs === FALSE || !file_exists($addon_dir) || count($dirs) == 0) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->order('id desc')->select();
     foreach ($list as $addon) {
         $addon['is_weixin'] = file_exists($addon_dir . $addon['name'] . '/Model/WeixinAddonModel.class.php');
         $addon['uninstall'] = 0;
         $addon['is_show_text'] = $addon['is_show'] == 1 ? '是' : '否';
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 unset($addons[$value]['status']);
             }
             $addons[$value]['is_weixin'] = file_exists($addon_dir . $value . '/Model/WeixinAddonModel.class.php');
         }
     }
     foreach ($addons as $key => $val) {
         if (!$val['is_weixin']) {
             unset($addons[$key]);
         }
     }
     int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
 public function config()
 {
     $this->getModel();
     if (IS_POST) {
         $flag = D('Common/AddonConfig')->set(_ADDONS, I('config'));
         if ($flag !== false) {
             $this->success('保存成功', Cookie('__forward__'));
         } else {
             $this->error('保存失败');
         }
     }
     $map['name'] = _ADDONS;
     $addon = M('addons')->where($map)->find();
     if (!$addon) {
         $this->error('插件未安装');
     }
     $addon_class = get_addon_class($addon['name']);
     if (!class_exists($addon_class)) {
         trace("插件{$addon['name']}无法实例化,", 'ADDONS', 'ERR');
     }
     $data = new $addon_class();
     $addon['addon_path'] = $data->addon_path;
     $addon['custom_config'] = $data->custom_config;
     $this->meta_title = '设置插件-' . $data->info['title'];
     $db_config = D('Common/AddonConfig')->get(_ADDONS);
     // dump ( $db_config );
     $addon['config'] = (include $data->config_file);
     if ($db_config) {
         foreach ($addon['config'] as $key => $value) {
             if ($value['type'] != 'group') {
                 !isset($db_config[$key]) || ($addon['config'][$key]['value'] = $db_config[$key]);
             } else {
                 foreach ($value['options'] as $gourp => $options) {
                     foreach ($options['options'] as $gkey => $value) {
                         !isset($db_config[$key]) || ($addon['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey]);
                     }
                 }
             }
         }
     }
     $this->assign('data', $addon);
     $this->display();
 }
示例#8
0
 /**
  * 去除插件所有钩子里对应的插件数据
  */
 public function removeHooks($name)
 {
     $addons_class = get_addon_class($name);
     if (!class_exists($addons_class)) {
         return false;
     }
     $methods = get_class_methods($addons_class);
     $hooks = $this->getField('name', true);
     $common = array_intersect($hooks, $methods);
     if ($common) {
         foreach ($common as $hook) {
             $flag = $this->removeAddons($hook, array($name));
             if (false === $flag) {
                 return false;
             }
         }
     }
     return true;
 }
 function config()
 {
     $normal_tips = '配置完保存后,在微信里回复: 会员卡,即可看到效果。';
     $this->assign('normal_tips', $normal_tips);
     $this->getModel();
     if (IS_POST) {
         if ($_POST['config']['background'] == 11) {
             $_POST['config']['background_custom'] = get_cover_url($_POST['config']['bg']);
         }
         $flag = D('Common/AddonConfig')->set(_ADDONS, I('config'));
         if ($flag !== false) {
             $this->success('保存成功', Cookie('__forward__'));
         } else {
             $this->error('保存失败');
         }
     }
     $map['name'] = _ADDONS;
     $addon = M('Addons')->where($map)->find();
     if (!$addon) {
         $this->error('插件未安装');
     }
     $addon_class = get_addon_class($addon['name']);
     $data = new $addon_class();
     $addon['addon_path'] = $data->addon_path;
     $addon['custom_config'] = $data->custom_config;
     $db_config = D('Common/AddonConfig')->get(_ADDONS);
     $addon['config'] = (include $data->config_file);
     if ($db_config) {
         foreach ($addon['config'] as $key => $value) {
             if ($value['type'] != 'group') {
                 !isset($db_config[$key]) || ($addon['config'][$key]['value'] = $db_config[$key]);
             } else {
                 foreach ($value['options'] as $gourp => $options) {
                     foreach ($options['options'] as $gkey => $value) {
                         !isset($db_config[$key]) || ($addon['config'][$key]['options'][$gourp]['options'][$gkey]['value'] = $db_config[$gkey]);
                     }
                 }
             }
         }
     }
     $this->assign('data', $addon);
     $this->display();
 }
示例#10
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  */
 public function getList($addon_dir = '')
 {
     if (!$addon_dir) {
         $addon_dir = ZS_ADDON_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->select();
     foreach ($list as $addon) {
         $addon['uninstall'] = 0;
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             $admin_list = $obj->admin_list;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 unset($addons[$value]['status']);
             }
             if ($admin_list) {
                 $addons[$value]['has_adminlist'] = 1;
             } else {
                 $addons[$value]['has_adminlist'] = 0;
             }
         }
     }
     int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装')));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
示例#11
0
 public function getList()
 {
     $dirs = array_map('basename', glob(ADDON_PATH . '*', GLOB_ONLYDIR));
     if ($dirs === false || !file_exists(ADDON_PATH)) {
         $this->error = '插件目录不可读或者不存在';
         return array();
     }
     $addons = array();
     $list = $this->select();
     foreach ($list as &$info) {
         $info['uninstall'] = 0;
         $addons[$info['name']] = $info;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 $addons[$value]['status'] = null;
             }
         }
     }
     $result = array();
     $map = array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', null => '未安装'));
     foreach ($addons as $key => &$row) {
         if (!in_array($key, $dirs)) {
             $row['status'] = -1;
         }
         $row['status_text'] = $map['status'][$row['status']] ?: '-';
         array_push($result, $row);
     }
     return $result;
 }
示例#12
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  * @param int $limit
  * @return array|bool
  */
 public function getList($addon_dir = '', $limit = 0)
 {
     if (!$addon_dir) {
         $addon_dir = Addon_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs === false || !File::file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return false;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->limit($limit)->select();
     foreach ($list as $addon) {
         $addon['uninstall'] = 0;
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 $addons[$value]['status'] = 99;
             }
         } else {
             //todo 已安装的
         }
     }
     int_to_string($addons, array('status' => array(-1 => '损坏', 0 => '禁用', 1 => '启用', 99 => '未安装')));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
示例#13
0
 public function del($id = '', $name)
 {
     $ids = array_unique((array) I('ids', 0));
     if (empty($ids)) {
         $this->error('请选择要操作的数据!');
     }
     $class = get_addon_class($name);
     if (!class_exists($class)) {
         $this->error('插件不存在');
     }
     $addon = new $class();
     $param = $addon->admin_list;
     if (!$param) {
         $this->error('插件列表信息不正确');
     }
     extract($param);
     if (isset($model)) {
         $addonModel = D("Addons://{$name}/{$model}");
         if (!$addonModel) {
             $this->error('模型无法实列化');
         }
     }
     $map = array('id' => array('in', $ids));
     if ($addonModel->where($map)->delete()) {
         $this->success('删除成功');
     } else {
         $this->error('删除失败!');
     }
 }
 /**
  * 根据Api获取参数
  */
 public function ajax_apiparam()
 {
     if (IS_AJAX) {
         $addonstype = I('cate', 0);
         $addonsid = I('cateid', 0);
         if (!in_array($addonstype, array('local', 'cloud'))) {
             $data['status'] = 0;
             $data['errmsg'] = '插件不存在';
             $this->ajaxReturn($data, 'JSON');
         } else {
             if ($addonstype == 'local') {
                 $addon_name = M('Addons')->where(array('id' => $addonsid))->getField('name');
                 $class = get_addon_class($addon_name);
                 if (!class_exists($class)) {
                     $data['status'] = 0;
                     $data['errmsg'] = '插件不存在';
                     $this->ajaxReturn($data, 'JSON');
                 }
                 $addons = new $class();
                 $paramlist = $addons->info['weixinkeyword']['option'];
                 $newlist = array();
                 foreach ($paramlist as $key => $value) {
                     $newlist[] = array('0' => $key, '2' => $key . '【' . $value . '】');
                 }
                 $data['status'] = 1;
                 $data['msg'] = $newlist;
                 $this->ajaxReturn($data, 'JSON');
             }
         }
     }
 }
示例#15
0
function sendSMS($mobile, $content)
{
    $sms_hook = modC('SMS_HOOK', 'none', 'USERCONFIG');
    $sms_hook = check_sms_hook_is_exist($sms_hook);
    if ($sms_hook == 'none') {
        return L('_THE_ADMINISTRATOR_HAS_NOT_CONFIGURED_THE_SMS_SERVICE_PROVIDER_INFORMATION_PLEASE_CONTACT_THE_ADMINISTRATOR_');
    }
    $name = get_addon_class($sms_hook);
    $class = new $name();
    return $class->sendSms($mobile, $content);
}
 /**
  * 获取插件列表
  * @param string $addon_dir
  */
 public function getList($addon_dir = '')
 {
     if (!$addon_dir) {
         $addon_dir = ONETHINK_ADDON_PATH;
     }
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     //TODO 新增模块插件的支持
     /* $modules=D('Module')->getAll();
        foreach($modules as $m){
            if($m['is_setup']){
                $module_dir=APP_PATH.$m['name'].'/Addons/';
                if(!file_exists($module_dir)){
                    continue;
                }
                $tmp_dirs = array_map('basename',glob($module_dir.'*', GLOB_ONLYDIR));
                $dirs=array_merge($dirs,$tmp_dirs);
            }
        }*/
     if ($dirs === FALSE || !file_exists($addon_dir)) {
         $this->error = L('_THE_PLUGIN_DIRECTORY_IS_NOT_READABLE_OR_NOT_');
         return FALSE;
     }
     $addons = array();
     $where['name'] = array('in', $dirs);
     $list = $this->where($where)->field(true)->select();
     foreach ($list as $addon) {
         $addon['uninstall'] = 0;
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record(L('_PLUGIN_') . $value . L('_THE_ENTRY_FILE_DOES_NOT_EXIST_WITH_EXCLAMATION_'));
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['uninstall'] = 1;
                 unset($addons[$value]['status']);
             }
         }
     }
     //dump($list);exit;
     int_to_string($addons, array('status' => array(-1 => L('_DAMAGE_'), 0 => L('_DISABLE_'), 1 => L('_ENABLE_'), null => L('_NOT_INSTALLED_'))));
     $addons = list_sort_by($addons, 'uninstall', 'desc');
     return $addons;
 }
 public function del($id = '', $name)
 {
     $ids = array_unique((array) I('ids', 0));
     if (empty($ids)) {
         $this->error(L('_ERROR_DATA_SELECT_'));
     }
     $class = get_addon_class($name);
     if (!class_exists($class)) {
         $this->error(L('_PLUGIN_DOES_NOT_EXIST_'));
     }
     $addon = new $class();
     $param = $addon->admin_list;
     if (!$param) {
         $this->error(L('_THE_PLUGIN_LIST_INFORMATION_IS_NOT_CORRECT_'));
     }
     extract($param);
     if (isset($model)) {
         $addonModel = D("Addons://{$name}/{$model}");
         if (!$addonModel) {
             $this->error(L('_MODEL_CANNOT_BE_REAL_'));
         }
     }
     $map = array('id' => array('in', $ids));
     if ($addonModel->where($map)->delete()) {
         $this->success(L('_DELETE_SUCCESS_'));
     } else {
         $this->error(L('_DELETE_FAILED_'));
     }
 }
示例#18
0
 /**
  * 获取插件列表
  * @param string $addon_dir
  * @author jry <*****@*****.**>
  */
 public function getAllAddon()
 {
     $addon_dir = C('ADDON_PATH');
     $dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
     if ($dirs == false || !file_exists($addon_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return false;
     }
     $addons = array();
     $map['name'] = array('in', $dirs);
     $list = $this->where($map)->field(true)->order('sort asc,id desc')->select();
     foreach ($list as $addon) {
         $addons[$addon['name']] = $addon;
     }
     foreach ($dirs as $value) {
         if (!isset($addons[$value])) {
             $class = get_addon_class($value);
             if (!class_exists($class)) {
                 // 实例化插件失败忽略执行
                 \Think\Log::record('插件' . $value . '的入口文件不存在!');
                 continue;
             }
             $obj = new $class();
             $addons[$value] = $obj->info;
             if ($addons[$value]) {
                 $addons[$value]['status'] = -1;
                 // 未安装
             }
         }
     }
     foreach ($addons as &$val) {
         switch ($val['status']) {
             case '-1':
                 // 未安装
                 $val['status'] = '<i class="fa fa-trash" style="color:red"></i>';
                 $val['right_button']['install']['title'] = '安装';
                 $val['right_button']['install']['attribute'] = 'class="label label-success ajax-get" href="' . U('install', array('addon_name' => $val['name'])) . '"';
                 break;
             case '0':
                 // 禁用
                 $val['status'] = '<i class="fa fa-ban" style="color:red"></i>';
                 $val['right_button']['config']['title'] = '设置';
                 $val['right_button']['config']['attribute'] = 'class="label label-info" href="' . U('config', array('id' => $val['id'])) . '"';
                 $val['right_button']['forbid']['title'] = '启用';
                 $val['right_button']['forbid']['attribute'] = 'class="label label-success ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '"';
                 $val['right_button']['uninstall']['title'] = '卸载';
                 $val['right_button']['uninstall']['attribute'] = 'class="label label-danger ajax-get" href="' . U('uninstall', array('id' => $val['id'])) . '"';
                 if ($val['adminlist']) {
                     $val['right_button']['adminlist']['title'] = '数据管理';
                     $val['right_button']['adminlist']['attribute'] = 'class="label label-success" href="' . U('adminlist', array('name' => $val['name'])) . '"';
                 }
                 break;
             case '1':
                 // 正常
                 $val['status'] = '<i class="fa fa-check" style="color:green"></i>';
                 $val['right_button']['config']['title'] = '设置';
                 $val['right_button']['config']['attribute'] = 'class="label label-info" href="' . U('config', array('id' => $val['id'])) . '"';
                 $val['right_button']['forbid']['title'] = '禁用';
                 $val['right_button']['forbid']['attribute'] = 'class="label label-warning ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '"';
                 $val['right_button']['uninstall']['title'] = '卸载';
                 $val['right_button']['uninstall']['attribute'] = 'class="label label-danger ajax-get" href="' . U('uninstall', array('id' => $val['id'])) . '"';
                 if ($val['adminlist']) {
                     $val['right_button']['adminlist']['title'] = '数据管理';
                     $val['right_button']['adminlist']['attribute'] = 'class="label label-success" href="' . U('adminlist', array('name' => $val['name'])) . '"';
                 }
                 break;
         }
     }
     return $addons;
 }
示例#19
0
 /**
  * 卸载插件
  */
 public function uninstall()
 {
     $addonsModel = M('Addons');
     $id = $_REQUEST['id'];
     $db_addons = $addonsModel->find($id);
     $class = get_addon_class($db_addons['name']);
     $this->assign('jumpUrl', U('index'));
     if (!$db_addons || !class_exists($class)) {
         //$this->error('插件不存在');
         $this->mtReturn(300, '插件不存在');
     }
     session('addons_uninstall_error', null);
     $addons = new $class();
     $uninstall_flag = $addons->uninstall();
     if (!$uninstall_flag) {
         //$this->error('执行插件预卸载操作失败'.session('addons_uninstall_error'));
         $this->mtReturn(300, '执行插件预卸载操作失败' . session('addons_uninstall_error'));
     }
     $hooks_update = D('Hooks')->removeHooks($db_addons['name']);
     if ($hooks_update === false) {
         //$this->error('卸载插件所挂载的钩子数据失败');
         $this->mtReturn(300, '卸载插件所挂载的钩子数据失败');
     }
     S('hooks', null);
     $delete = $addonsModel->where("name='{$db_addons['name']}'")->delete();
     if ($delete === false) {
         // $this->error('卸载插件失败');
         $this->mtReturn(300, '卸载插件失败');
     } else {
         //$this->success('卸载成功');
         $this->mtReturn(200, '"' . $db_addons['title'] . '"插件卸载成功', '', 'forward', cookie('_currentUrl_'));
     }
 }
示例#20
0
function sendSMS($mobile, $content)
{
    $sms_hook = modC('SMS_HOOK', 'none', 'USERCONFIG');
    $sms_hook = check_sms_hook_is_exist($sms_hook);
    if ($sms_hook == 'none') {
        return "管理员还未配置短信服务商信息,请联系管理员";
    }
    $name = get_addon_class($sms_hook);
    $class = new $name();
    return $class->sendSms($mobile, $content);
}
示例#21
0
 /**
  * 去除插件所有钩子里对应的插件数据
  */
 public function removeHooks($addons_name)
 {
     $addons_class = get_addon_class($addons_name);
     if (!class_exists($addons_class)) {
         return false;
     }
     $methods = get_class_methods($addons_class);
     $hooks = $this->getModel()->getField('name', true);
     $common = array_intersect($hooks, $methods);
     if ($common) {
         foreach ($common as $hook) {
             $flag = $this->removeAddons($hook, array($addons_name));
             if (false === $flag) {
                 return $this->apiReturnErr($this->getModel()->getDbError());
             }
         }
     }
     return $this->apiReturnSuc("操作成功!");
 }
示例#22
0
文件: thumb.php 项目: ccccy/wuanlife
function getThumbImageById($cover_id, $width = 100, $height = 'auto', $type = 0, $replace = false)
{
    $picture = S('picture_' . $cover_id);
    if (empty($picture)) {
        $picture = M('Picture')->where(array('status' => 1))->getById($cover_id);
        S('picture_' . $cover_id, $picture);
    }
    if (empty($picture)) {
        return get_pic_src('Public/images/nopic.png');
    }
    if ($picture['type'] == 'local') {
        $attach = getThumbImage($picture['path'], $width, $height, $type, $replace);
        return get_pic_src($attach['src']);
    } else {
        $new_img = $picture['path'];
        $name = get_addon_class($picture['type']);
        if (class_exists($name)) {
            $class = new $name();
            if (method_exists($class, 'thumb')) {
                $new_img = $class->thumb($picture['path'], $width, $height, $type, $replace);
            }
        }
        return get_pic_src($new_img);
    }
}
示例#23
0
 /**
  * 插件后台数据编辑
  * @param string $name 插件名
  * @author jry <*****@*****.**>
  */
 public function adminEdit($name, $tab, $id)
 {
     //获取插件实例
     $addon_class = get_addon_class($name);
     if (!class_exists($addon_class)) {
         $this->error('插件不存在');
     } else {
         $addon = new $addon_class();
     }
     //获取插件的$admin_list配置
     $admin_list = $addon->admin_list;
     $admin = $admin_list[$tab];
     $addon_model_object = D('Addons://' . $name . '/' . $admin['model']);
     $param = $addon_model_object->adminList;
     if ($param) {
         if (IS_POST) {
             $data = $addon_model_object->create();
             if ($data) {
                 $result = $addon_model_object->save($data);
             } else {
                 $this->error($addon_model_object->getError());
             }
             if ($result) {
                 $this->success('更新成功', U('Addon/adminList/name/' . $name . '/tab/' . $tab));
             } else {
                 $this->error('更新错误');
             }
         } else {
             //使用FormBuilder快速建立表单页面。
             $builder = new \Common\Builder\FormBuilder();
             $builder->setMetaTitle('编辑数据')->setPostUrl(U('addon/adminEdit/name/' . $name . '/tab/' . $tab))->addFormItem('id', 'hidden', 'ID', 'ID')->setExtraItems($param['field'])->setFormData(M($param['model'])->find($id))->setTemplate('_Builder/formbuilder_addon')->display();
         }
     } else {
         $this->error('插件列表信息不正确');
     }
 }
示例#24
0
 /**
  * saveAvatar  保存头像到本地
  * @param $url
  * @param $oid
  * @param $uid
  * @param $type
  * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
  */
 private function saveAvatar($url, $uid)
 {
     $driver = modC('PICTURE_UPLOAD_DRIVER', 'local', 'config');
     if ($driver == 'local') {
         mkdir('./Uploads/Avatar/' . $uid, 0777, true);
         $img = file_get_contents($url);
         $filename = './Uploads/Avatar/' . $uid . '/crop.jpg';
         file_put_contents($filename, $img);
         $data['path'] = '/' . $uid . '/crop.jpg';
     } else {
         $name = get_addon_class($driver);
         $class = new $name();
         $path = '/Uploads/Avatar/' . $uid . '/crop.jpg';
         $res = $class->uploadRemote($url, 'Uploads/Avatar/' . $uid . '/crop.jpg');
         if ($res !== false) {
             $data['path'] = $res;
         }
     }
     $data['uid'] = $uid;
     $data['create_time'] = time();
     $data['status'] = 1;
     $data['is_temp'] = 0;
     $data['driver'] = $driver;
     D('avatar')->add($data);
 }
示例#25
0
 /**
  * 自动安装插件
  */
 public function install($addon_name)
 {
     $class = get_addon_class($addon_name);
     if (!class_exists($class)) {
         $this->error('插件不存在');
     }
     $addons = new $class();
     $info = $addons->info;
     if (!$info || !$addons->checkInfo()) {
         // 检测信息的正确性
         $this->error('插件信息缺失');
     }
     session('addons_install_error', null);
     $install_flag = $addons->install();
     if (!$install_flag) {
         $this->error('执行插件预安装操作失败' . session('addons_install_error'));
     }
     $addonsModel = D('Addons');
     $data = $addonsModel->create($info);
     if (!$data) {
         $this->error($addonsModel->getError());
     }
     // isset($data['has_adminlist']) || $data['has_adminlist'] = intval(is_array($addons->admin_list) && $addons->admin_list !== array());
     isset($data['type']) || ($data['type'] = intval(file_exists(ONETHINK_ADDON_PATH . $data['name'] . '/Model/WeixinAddonModel.class.php')));
     if ($addonsModel->add($data)) {
         $config = array('config' => json_encode($addons->getConfig()));
         $addonsModel->where("name='{$addon_name}'")->save($config);
         $hooks_update = D('Hooks')->updateHooks($addon_name);
         if ($hooks_update) {
             S('hooks', null);
             $this->success('安装成功');
         } else {
             $addonsModel->where("name='{$addon_name}'")->delete();
             $this->error('更新钩子处插件失败,请卸载后尝试重新安装');
         }
     } else {
         $this->error('写入插件数据失败');
     }
 }
 /**
  * 上传文件
  * @param 文件信息数组 $files ,通常是 $_FILES数组
  */
 public function upload($files = '')
 {
     if ('' === $files) {
         $files = $_FILES;
     }
     if (empty($files)) {
         $this->error = '没有上传的文件!';
         return false;
     }
     /* 检测上传根目录 */
     if (!$this->uploader->checkRootPath()) {
         $this->error = $this->uploader->getError();
         return false;
     }
     /* 检查上传目录 */
     if (!$this->uploader->checkSavePath($this->savePath)) {
         $this->error = $this->uploader->getError();
         return false;
     }
     /* 逐个检测并上传文件 */
     $info = array();
     if (function_exists('finfo_open')) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
     }
     // 对上传文件数组信息处理
     $files = $this->dealFiles($files);
     foreach ($files as $key => $file) {
         if (!isset($file['key'])) {
             $file['key'] = $key;
         }
         /* 通过扩展获取文件类型,可解决FLASH上传$FILES数组返回文件类型错误的问题 */
         if (isset($finfo)) {
             $file['type'] = finfo_file($finfo, $file['tmp_name']);
         }
         /* 获取上传文件后缀,允许上传无后缀文件 */
         $file['ext'] = pathinfo($file['name'], PATHINFO_EXTENSION);
         /* 文件上传检测 */
         if (!$this->check($file)) {
             continue;
         }
         /* 获取文件hash */
         if ($this->hash) {
             $file['md5'] = md5_file($file['tmp_name']);
             $file['sha1'] = sha1_file($file['tmp_name']);
         }
         /* 调用回调函数检测文件是否存在 */
         $data = call_user_func($this->callback, $file);
         if ($this->callback && $data) {
             $drconfig = $this->driverConfig;
             $fname = str_replace('http://' . $drconfig['domain'] . '/', '', $data['url']);
             if (file_exists('.' . $data['path'])) {
                 $info[$key] = $data;
                 continue;
             } elseif ($this->uploader->info($fname)) {
                 $info[$key] = $data;
                 continue;
             } elseif ($this->removeTrash) {
                 call_user_func($this->removeTrash, $data);
                 //删除垃圾据
             }
         }
         /* 生成保存文件名 */
         $savename = $this->getSaveName($file);
         if (false == $savename) {
             continue;
         } else {
             $file['savename'] = $savename;
             //$file['name'] = $savename;
         }
         /* 检测并创建子目录 */
         $subpath = $this->getSubPath($file['name']);
         if (false === $subpath) {
             continue;
         } else {
             $file['savepath'] = $this->savePath . $subpath;
         }
         /* 对图像文件进行严格检测 */
         $ext = strtolower($file['ext']);
         if (in_array($ext, array('gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf'))) {
             $imginfo = getimagesize($file['tmp_name']);
             if (empty($imginfo) || $ext == 'gif' && empty($imginfo['bits'])) {
                 $this->error = '非法图像文件!';
                 continue;
             }
         }
         $file['rootPath'] = $this->config['rootPath'];
         $name = get_addon_class($this->driver);
         if (class_exists($name)) {
             $class = new $name();
             if (method_exists($class, 'uploadDealFile')) {
                 $class->uploadDealFile($file);
             }
         }
         /* 保存文件 并记录保存成功的文件 */
         if ($this->uploader->save($file, $this->replace)) {
             unset($file['error'], $file['tmp_name']);
             $info[$key] = $file;
         } else {
             $this->error = $this->uploader->getError();
         }
     }
     if (isset($finfo)) {
         finfo_close($finfo);
     }
     return empty($info) ? false : $info;
 }
 public function cropPicture($crop = null, $path)
 {
     //如果不裁剪,则发生错误
     if (!$crop) {
         $this->error('必须裁剪');
     }
     $driver = modC('PICTURE_UPLOAD_DRIVER', 'local', 'config');
     if (strtolower($driver) == 'local') {
         //解析crop参数
         $crop = explode(',', $crop);
         $x = $crop[0];
         $y = $crop[1];
         $width = $crop[2];
         $height = $crop[3];
         //本地环境
         $image = ImageWorkshop::initFromPath($path);
         //生成将单位换算成为像素
         $x = $x * $image->getWidth();
         $y = $y * $image->getHeight();
         $width = $width * $image->getWidth();
         $height = $height * $image->getHeight();
         //如果宽度和高度近似相等,则令宽和高一样
         if (abs($height - $width) < $height * 0.01) {
             $height = min($height, $width);
             $width = $height;
         }
         //调用组件裁剪头像
         $image = ImageWorkshop::initFromPath($path);
         $image->crop(ImageWorkshopLayer::UNIT_PIXEL, $width, $height, $x, $y);
         $image->save(dirname($path), basename($path));
         //返回新文件的路径
         return cut_str('/Uploads/Avatar', $path, 'l');
     } else {
         $name = get_addon_class($driver);
         $class = new $name();
         $new_img = $class->crop($path, $crop);
         return $new_img;
     }
 }
</td>
					<td><a target="_blank" href="<?php 
                echo isset($vo["url"]) && $vo["url"] !== "" ? $vo["url"] : 'http://www.onethink.cn';
                ?>
"><?php 
                echo $vo["author"];
                ?>
</a></td>
					<td><?php 
                echo $vo["version"];
                ?>
</td>
					<td>
						<?php 
                if (empty($vo["uninstall"])) {
                    $class = get_addon_class($vo['name']);
                    if (!class_exists($class)) {
                        $has_config = 0;
                    } else {
                        $addon = new $class();
                        $has_config = count($addon->getConfig());
                    }
                    ?>
							<?php 
                    if ($has_config) {
                        ?>
								<a href="<?php 
                        echo U('config', array('id' => $vo['id']));
                        ?>
">设置</a>
							<?php 
示例#29
0
 /**
  * 卸载插件
  */
 public function uninstall()
 {
     $addonsModel = M('Addons');
     $id = trim(I('id'));
     $db_addons = $addonsModel->find($id);
     $class = get_addon_class($db_addons['name']);
     $this->assign('jumpUrl', U('index'));
     if (!$db_addons || !class_exists($class)) {
         $this->error('插件不存在');
     }
     session('addons_uninstall_error', null);
     $addons = new $class();
     $uninstall_flag = $addons->uninstall();
     if (!$uninstall_flag) {
         $this->error('执行插件预卸载操作失败' . session('addons_uninstall_error'));
     }
     $hooks_update = D('Hooks')->removeHooks($db_addons['name']);
     if ($hooks_update === false) {
         $this->error('卸载插件所挂载的钩子数据失败');
     }
     S('hooks', null);
     $delete = $addonsModel->where("name='{$db_addons['name']}'")->delete();
     if ($delete === false) {
         $this->error('卸载插件失败');
     } else {
         $this->success('卸载成功');
     }
 }
 public function getCommentList()
 {
     $aApp = I('post.app', '', 'text');
     $aMod = I('post.mod', '', 'text');
     $aRowId = I('post.row_id', '', 'intval');
     $aPage = I('post.page', '', 'intval');
     $count = modC($aMod . '_LOCAL_COMMENT_COUNT', 10, $aApp);
     $commentModel = $this->commentModel;
     $param['where'] = array('app' => $aApp, 'mod' => $aMod, 'row_id' => $aRowId, 'status' => 1);
     $param['page'] = $aPage;
     $param['count'] = $count;
     $sort = modC($aMod . '_LOCAL_COMMENT_ORDER', 0, $aApp) == 0 ? 'desc' : 'asc';
     $param['order'] = 'create_time ' . $sort;
     $param['field'] = 'id';
     $list = $commentModel->getList($param);
     $html = '';
     $class = get_addon_class('LocalComment');
     $object = new $class();
     foreach ($list as $v) {
         $html .= $object->getCommentHtml($v);
     }
     $total_count = $object->getCommentCount($aApp, $aMod, $aRowId);
     $pageCount = ceil($total_count / $count);
     $html .= '<div class="pager">' . getPageHtml('local_comment_page', $pageCount, array('app' => $aApp, 'mod' => $aMod, 'row_id' => $aRowId), $aPage) . '</div>';
     $this->ajaxReturn(array('html' => $html));
 }