Exemplo n.º 1
0
 public function doWebOsetter()
 {
     global $_W, $_GPC;
     $host = o2::getHost();
     $oauther = o2::getOauther($_W['weid']);
     $user = o2::getUserInfo($_W['account']['uid']);
     $poorer = $user['name'] == '初级会员' ? 1 : 0;
     if (empty($host)) {
         message('管理员未开通此功能...', '', 'error');
     }
     if ($host['type'] == 1) {
         //自填
         if (empty($host['key']) || empty($host['secret'])) {
             message('缺失重要的自定义参数', '', 'error');
         }
         $item = array('key' => $host['key'], 'secret' => $host['secret']);
     } else {
         //读取
         $oweid = $host['host'];
         $list = pdo_fetch('SELECT * FROM' . tablename('wechats') . " WHERE weid = :weid", array(':weid' => $oweid));
         if (!empty($list)) {
             $item = array('key' => o2::blurStr($list['key'], 3), 'secret' => o2::blurStr($list['secret'], 3));
         } else {
             message('缺失重要的宿主对象', '', 'error');
         }
     }
     if (checksubmit()) {
         $type = $_GPC['type'];
         //==1不借用..==2借用
         if ($user['name'] == '初级会员' && $type == 2) {
             message('您的权限不够..', '', 'error');
         }
         if ($type == 1) {
             $key = !empty($_GPC['appid_1']) ? $_GPC['appid_1'] : message('重要参数丢失');
             $secret = !empty($_GPC['appsecret_1']) ? $_GPC['appsecret_1'] : message('重要参数丢失');
             $data = array('key' => $key, 'secret' => $secret);
         } elseif ($type == 2) {
         } else {
             message('缺失重要的分类参数', '', 'error');
         }
         $data['type'] = $type;
         if (empty($oauther)) {
             $data['createtime'] = TIMESTAMP;
             $data['weid'] = $_W['weid'];
             pdo_insert($this->table_oauther, $data);
         } else {
             pdo_update($this->table_oauther, $data, array('weid' => $_W['weid']));
         }
         message('诶呦厉害啦..操作成功..', '', 'success');
     }
     include $this->template('osetter');
 }