Ejemplo n.º 1
0
 public function __construct()
 {
     if ($_REQUEST['doNotInit']) {
         return true;
     }
     $content = wp_file_get_contents('php://input');
     !empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
     if ($_GET['encrypt_type'] == 'aes') {
         vendor('WXBiz.wxBizMsgCrypt');
         $this->sReqTimeStamp = I('get.timestamp');
         $this->sReqNonce = I('get.nonce');
         $this->sEncryptMsg = I('get.msg_signature');
         $map['id'] = I('get.id');
         $info = M('member_public')->where($map)->find();
         get_token($info['token']);
         // 设置token
         $this->wxcpt = new \WXBizMsgCrypt('weiphp', $info['encodingaeskey'], $info['appid']);
         $sMsg = "";
         // 解析之后的明文
         $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
         if ($errCode != 0) {
             addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
             exit;
         } else {
             // 解密成功,sMsg即为xml格式的明文
             $content = $sMsg;
         }
     }
     $data = new \SimpleXMLElement($content);
     // $data || die ( '参数获取失败' );
     foreach ($data as $key => $value) {
         $this->data[$key] = strval($value);
     }
 }
Ejemplo n.º 2
0
 function uploadCert($fileId)
 {
     $managerId = $this->mid;
     $path = SITE_PATH . '\\Cert\\wxzf\\' . $managerId;
     $file = M('file')->find($fileId);
     $file['savepath'] = substr($file['savepath'], 0, strlen($file['savepath']) - 1);
     $filename = SITE_PATH . '\\Uploads\\Download\\' . $file['savepath'] . '\\' . $file['savename'];
     //         dump($file);
     //         dump($filename);
     //         dump(file_exists($filename));
     //         die;
     if (!file_exists($filename)) {
         $this->error('上传失败');
         exit;
     }
     // 	    $extend = $file ['ext'];
     // 	    if (! ($extend == 'pem' || $extend == 'p12' )) {
     // 	        $this->error('上传证书格式有误,扩展名应为 pem');
     // 	        exit();
     // 	    }
     $mkres = mkdirs($path);
     $content = wp_file_get_contents($filename);
     $res = file_put_contents($path . '\\' . $file['name'], $content);
     return $res;
 }
Ejemplo n.º 3
0
 function _thumb_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if ($res) {
             return '';
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return '';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return '';
     }
     $map['cover_id'] = $cover_id;
     $map['manager_id'] = $this->mid;
     $this->where($map)->setField('thumb_media_id', $res['media_id']);
     return $res['media_id'];
 }
Ejemplo n.º 4
0
 function getRemoteVersion()
 {
     // cookie ( 'cookie_close_version', 0 );
     $remote = 'http://www.weiphp.cn/index.php?s=/home/index/update_version';
     $new_version = wp_file_get_contents($remote);
     $res = $new_version > C('SYSTEM_UPDATRE_VERSION') && cookie('cookie_close_version') != $new_version;
     echo $res ? $new_version : 0;
 }
 private function get_content_by_url_id($id)
 {
     $url = "http://job.snnu.edu.cn/com/show_info.asp?com_id={$id}&com_version=0&action=com_info";
     $source = wp_file_get_contents($url);
     $s = mb_convert_encoding($source, "UTF-8", "GB18030");
     preg_match_all("/<div id=attitle>([^>]+)<\\/div>/i", $s, $_title);
     //        preg_match_all("/<div id=dwinfor align=\"center\">([^\n]+).*/i", $s, $_subContent);
     //        preg_match_all("/<FONT style=([^\n]+).*/i", $s, $_mainContent);
     $title = trim($_title[1][0]);
     //        $content = $_subContent[0][0].$_mainContent[0][0];
     return array("title" => $title, "url" => $url);
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     if ($_REQUEST['doNotInit']) {
         return true;
     }
     $content = wp_file_get_contents('php://input');
     !empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
     if ($_GET['encrypt_type'] == 'aes') {
         vendor('WXBiz.wxBizMsgCrypt');
         $this->sReqTimeStamp = I('get.timestamp');
         $this->sReqNonce = I('get.nonce');
         $this->sEncryptMsg = I('get.msg_signature');
         if (isset($_GET['appid'])) {
             // if ($_GET ['appid'] == 'wx570bc396a51b8ff8') {
             // 	$info ['token'] = 'gh_3c884a361561';
             // 	$info ['encodingaeskey'] = 'DfEqNBRvzbg8MJdRQCSGyaMp6iLcGOldKFT0r8I6Tnp';
             // 	$info ['appid'] = 'wxea0485bef5247236';
             // } else {
             // 	$map ['appid'] = I ( 'get.appid' );
             // 	$info = D ( 'Common/Public' )->where ( $map )->find ();
             // }
             $map['appid'] = I('get.appid');
             $info = D('Common/Public')->where($map)->find();
         } else {
             $id = I('get.id');
             $info = D('Common/Public')->getInfo($id);
         }
         get_token($info['token']);
         // 设置token
         $this->wxcpt = new \WXBizMsgCrypt($info['mp_token'], $info['encodingaeskey'], $info['appid']);
         $sMsg = "";
         // 解析之后的明文
         $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
         if ($errCode != 0) {
             addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
             addWeixinLog($content, "DecryptMsg Error: content");
             exit;
         } else {
             // 解密成功,sMsg即为xml格式的明文
             $content = $sMsg;
         }
     }
     $data = new \SimpleXMLElement($content);
     // $data || die ( '参数获取失败' );
     foreach ($data as $key => $value) {
         $this->data[$key] = safe(strval($value));
     }
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     if ($_REQUEST['doNotInit']) {
         return true;
     }
     $content = wp_file_get_contents('php://input');
     !empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
     if ($_GET['encrypt_type'] == 'aes') {
         vendor('WXBiz.wxBizMsgCrypt');
         $this->sReqTimeStamp = I('get.timestamp');
         $this->sReqNonce = I('get.nonce');
         $this->sEncryptMsg = I('get.msg_signature');
         if (isset($_GET['appid'])) {
             $map['appid'] = I('get.appid');
             $info = D('Common/Public')->where($map)->find();
         } else {
             $id = I('get.pid');
             $info = D('Common/Public')->getInfo($id);
         }
         $info['encodingaeskey'] = 'Wry3C6IG6yzFR55cnje0W7CWd2jqlqQrAIK5ilOIfo3';
         $info['appid'] = D('Addons://PublicBind/PublicBind')->component_appid;
         get_token($info['token']);
         // 设置token
         $this->wxcpt = new \WXBizMsgCrypt('youkang120', $info['encodingaeskey'], $info['appid']);
         $sMsg = "";
         // 解析之后的明文
         $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
         if ($errCode != 0) {
             addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
             addWeixinLog($content, "DecryptMsg Error: content");
             exit;
         } else {
             // 解密成功,sMsg即为xml格式的明文
             $content = $sMsg;
         }
     }
     $data = new \SimpleXMLElement($content);
     // $data || die ( '参数获取失败' );
     foreach ($data as $key => $value) {
         $this->data[$key] = safe(strval($value));
     }
 }
Ejemplo n.º 8
0
 public function tongbuyonghuhao()
 {
     //同步用户号
     $token = get_token();
     $access_token = get_access_token($token);
     $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . $access_token . '';
     $users = json_decode(wp_file_get_contents($url), true);
     if (!$users['total']) {
         $this->error("更新失败");
     }
     $data = $users['data'];
     $openidArray = $data['openid'];
     foreach ($openidArray as $key => $openid) {
         $userInfo = getWeixinUserInfo($openid, $token);
         $map['openid'] = $userInfo['openid'];
         $data['nickname'] = $userInfo['nickname'];
         $data['sex'] = $userInfo['sex'];
         $data['city'] = $userInfo['city'];
         $data['country'] = $userInfo['country'];
         $data['province'] = $userInfo['province'];
         $data['language'] = $userInfo['language'];
         $data['headimgurl'] = $userInfo['headimgurl'];
         $data['subscribe_time'] = $userInfo['subscribe_time'];
         $data['status'] = $userInfo['subscribe'];
         $data['token'] = $token;
         $result_id = M('Follow')->where($map)->getField('id');
         if ($result_id) {
             //更新
             $data['id'] = $result_id;
             M('Follow')->save($data);
             unset($data);
         } else {
             //新增
             D('Common/Follow')->init_follow($userInfo['openid']);
         }
     }
     $this->success("同步完成!");
 }
Ejemplo n.º 9
0
 function getSendInfo($id)
 {
     $info = $this->getInfo($id);
     $map['id'] = $info['shop_id'];
     $api_key = M('shop')->where($map)->getField('api_key');
     empty($api_key) && ($api_key = '02727dd96ccf4c4eabb091d85cb7fa10');
     $url = 'http://v.juhe.cn/exp/index?key=' . $api_key . '&com=' . $info['send_code'] . '&no=' . $info['send_number'];
     $data = wp_file_get_contents($url);
     $data = json_decode($data, true);
     if ($data['resultcode'] == 200) {
         $save['order_id'] = $id;
         $save['status_code'] = 3;
         $save['extend'] = 1;
         M('shop_order_log')->where($save)->delete();
         foreach ($data['result']['list'] as $vo) {
             $save['cTime'] = strtotime($vo['datetime']);
             $save['remark'] = $vo['zone'] . ' ' . $vo['remark'];
             M('shop_order_log')->add($save);
         }
     }
     return $data;
 }
Ejemplo n.º 10
0
 function _updateWechatGroup()
 {
     // 先取当前用户组数据
     $map['token'] = get_token();
     $map['manager_id'] = $this->mid;
     $map['type'] = 1;
     $group_list = M('auth_group')->where($map)->getField('wechat_group_id,id');
     $url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token=' . get_access_token();
     $data = wp_file_get_contents($url);
     $data = json_decode($data, true);
     foreach ($data['groups'] as $d) {
         if (isset($group_list[$d['id']])) {
             continue;
         }
         $map['wechat_group_id'] = $d['id'];
         $map['wechat_group_name'] = $d['name'];
         $map['wechat_group_count'] = $d['count'];
         // 增加本地数据
         $map['title'] = $d['name'];
         $map['qr_code'] = '';
         M('auth_group')->add($save);
     }
 }
 function syc_openid()
 {
     error_log('第一步:获取全部用户的ID,并先保存到public_follow表中,新的用户UID暂时为0,后面的步骤补充');
     // 获取openid列表
     $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . get_access_token() . '&next_openid=' . I('next_openid');
     $data = wp_file_get_contents($url);
     $data = json_decode($data, true);
     if (!isset($data['count']) || $data['count'] == 0) {
         // 拉取完毕
         $this->success('同步用户数据中,请勿关闭', U('syc_user'));
         exit;
     }
     $map['openid'] = array('in', $data['data']['openid']);
     $map['token'] = $save['token'] = get_token();
     $res = M('public_follow')->where($map)->setField('syc_status', 0);
     if ($res != $data['count']) {
         // 更新的数量不一致,可能有增加的用户openid
         $openids = (array) M('public_follow')->where($map)->getFields('openid');
         $diff = array_diff($data['data']['openid'], $openids);
         if (!empty($diff)) {
             foreach ($diff as $id) {
                 $save['openid'] = $id;
                 $save['uid'] = 0;
                 $save['syc_status'] = 0;
                 $res = M('public_follow')->add($save);
             }
         }
     }
     $param2['next_openid'] = $data['next_openid'];
     $url = U('syc_openid', $param2);
     $this->success('同步用户OpenID中,请勿关闭', $url);
 }
 function updateWechatGroup()
 {
     error_log('与微信的用户组保持同步');
     // 先取当前用户组数据
     $map['token'] = get_token();
     $map['manager_id'] = $this->mid;
     $map['type'] = 1;
     $group_list = M('auth_group')->where($map)->field('id,title,wechat_group_id,wechat_group_name,wechat_group_count')->select();
     foreach ($group_list as $g) {
         $groups[$g['wechat_group_id']] = $g;
     }
     $url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token=' . get_access_token();
     $data = wp_file_get_contents($url);
     $data = json_decode($data, true);
     if (!isset($data['errcode'])) {
         foreach ($data['groups'] as $d) {
             $save['wechat_group_id'] = $map['wechat_group_id'] = $d['id'];
             $save['wechat_group_name'] = $d['name'];
             $save['wechat_group_count'] = $d['count'];
             if (isset($groups[$d['id']])) {
                 // 更新本地数据
                 $old = $groups[$d['id']];
                 if ($old['title'] != $d['name']) {
                     $old['wechat_group_name'] = $old['title'];
                     $save['wechat_group_name'] = $old['title'];
                     //修改微信端的数据
                     $updateUrl = "https://api.weixin.qq.com/cgi-bin/groups/update?access_token=" . get_access_token();
                     $newGroup['group']['id'] = $d['id'];
                     $newGroup['group']['name'] = $save['wechat_group_name'];
                     $res = post_data($updateUrl, $newGroup);
                 }
                 if ($old['wechat_group_name'] != $d['name'] || $old['wechat_group_count'] != $d['count']) {
                     // 					$save['title']=$save['wechat_group_name'];
                     M('auth_group')->where($map)->save($save);
                 }
                 unset($groups[$d['id']]);
             } else {
                 // 增加本地数据
                 $save = array_merge($save, $map);
                 $save['title'] = $d['name'];
                 $save['qr_code'] = '';
                 M('auth_group')->add($save);
             }
         }
         foreach ($groups as $v) {
             $map2['id'] = $map3['group_id'] = $v['id'];
             $wechat_group_id = intval($v['wechat_group_id']);
             if ($wechat_group_id == -1) {
                 // 增加微信端的数据
                 $url = 'https://api.weixin.qq.com/cgi-bin/groups/create?access_token=' . get_access_token();
                 $param['group']['name'] = $v['title'];
                 $param = JSON($param);
                 $res = post_data($url, $param);
                 if (!empty($res['group']['id'])) {
                     $info['wechat_group_id'] = $save['wechat_group_id'] = $res['group']['id'];
                     $save['wechat_group_name'] = $res['group']['name'];
                     M('auth_group')->where($map2)->save($save);
                 }
             } else {
                 // 删除本地数据
                 M('auth_group')->where($map2)->delete();
                 M('auth_group_access')->where($map3)->delete();
             }
         }
     }
     if (isset($_GET['need_return'])) {
         redirect(addons_url('UserCenter://UserCenter/syc_openid'));
     }
 }
Ejemplo n.º 13
0
 /**
  * 初始化微信推送的数据
  */
 private function init()
 {
     $xml = wp_file_get_contents("php://input");
     $data = self::xml2data($xml);
     //安全模式 或兼容模式
     if (self::$msgSafeMode) {
         if (isset($data['MsgType'])) {
             //兼容模式追加解密后的消息内容
             $data['Decrypt'] = self::extract($data['Encrypt']);
         } else {
             //安全模式
             $data = self::extract($data['Encrypt']);
         }
     }
     $this->data = $data;
 }
 function _footer($temp_type = 'weiphp')
 {
     if ($temp_type == 'pigcms') {
         $param['token'] = $token = get_token();
         $param['temp'] = $this->config['template_footer'];
         $url = U('Home/Index/getFooterHtml', $param);
         $html = wp_file_get_contents($url);
         // dump ( $url );
         // dump ( $html );
         $file = RUNTIME_PATH . $token . '_' . $this->config['template_footer'] . '.html';
         if (!file_exists($file) || true) {
             file_put_contents($file, $html);
         }
         $this->assign('cateMenuFileName', $file);
     } else {
         $list = D('Addons://WeiSite/Footer')->get_list();
         foreach ($list as $k => $vo) {
             if ($vo['pid'] != 0) {
                 continue;
             }
             $one_arr[$vo['id']] = $vo;
             unset($list[$k]);
         }
         foreach ($one_arr as &$p) {
             $two_arr = array();
             foreach ($list as $key => $l) {
                 if ($l['pid'] != $p['id']) {
                     continue;
                 }
                 $two_arr[] = $l;
                 unset($list[$key]);
             }
             $p['child'] = $two_arr;
         }
         $this->assign('footer', $one_arr);
         $html = $this->fetch(ONETHINK_ADDON_PATH . 'WeiSite/View/default/TemplateFooter/' . $this->config['template_footer'] . '/footer.html');
         $this->assign('footer_html', $html);
     }
 }
Ejemplo n.º 15
0
 private function init_follow($data)
 {
     $info = get_token_appinfo($data['ToUserName']);
     $config = S('PUBLIC_AUTH_' . $info['type']);
     if (!$config) {
         $config = M('public_auth')->getField('name,type_' . $info['type'] . ' as val');
         S('PUBLIC_AUTH_' . $info['type'], $config, 86400);
     }
     C($config);
     // 公众号接口权限
     // 初始化用户信息
     $map['token'] = $data['ToUserName'];
     $map['openid'] = $data['FromUserName'];
     $GLOBALS['mid'] = $uid = M('public_follow')->where($map)->getField('uid');
     // 绑定配置
     $config = getAddonConfig('UserCenter', $map['token']);
     if (!$uid && C('USER_BASE_INFO')) {
         // 如果有权限获取用户信息,即自动获取
         $url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . get_access_token() . '&openid=' . $data['FromUserName'] . '&lang=zh_CN';
         $userInfo = wp_file_get_contents($url);
         $userInfo = json_decode($userInfo, true);
         if (isset($userInfo['nickname'])) {
             // 自动注册
             $user = array('experience' => intval($config['experience']), 'score' => intval($config['score']), 'reg_ip' => get_client_ip(1), 'reg_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_time' => NOW_TIME, 'status' => 1, 'is_init' => 1, 'is_audit' => 1);
             $user = array_merge($user, $userInfo);
             $map['uid'] = $uid = D('Common/User')->add($user);
             $res = M('public_follow')->add($map);
         }
     }
     $guestAccess = strtolower(CONTROLLER_NAME) != 'weixin';
     $userNeed = $user['uid'] > 0 && $user['status'] < 2 || empty($user) && $guestAccess;
     if ($config['need_bind'] == 1 && $userNeed && C('USER_OAUTH')) {
         unset($map['uid']);
         $bind_url = addons_url('UserCenter://Wap/bind', $map);
         if ($config['bind_start'] != 0 && strtolower($data['Event']) != 'subscribe') {
             $dao->replyText('请先<a href="' . $bind_url . '">绑定账号</a>再使用');
             exit;
         }
     }
 }
Ejemplo n.º 16
0
 public function GroupsQuery()
 {
     $access_token = $this->accessToken;
     $url = 'https://api.weixin.qq.com/cgi-bin/groups/get?access_token=' . $access_token;
     $tempArr = json_decode(wp_file_get_contents($url), true);
     if (@array_key_exists('groups', $tempArr)) {
         return $tempArr['groups'];
         // 返回数组格式的分组信息
     } else {
         $this->ErrorLogger('groups query falied.');
         $this->AccessTokenGet();
         $this->GroupsQuery();
     }
 }
Ejemplo n.º 17
0
/**
 * 执行SQL文件
 */
function execute_sql_file($sql_path)
{
    // 读取SQL文件
    $sql = wp_file_get_contents($sql_path);
    $sql = str_replace("\r", "\n", $sql);
    $sql = explode(";\n", $sql);
    // 替换表前缀
    $orginal = 'wp_';
    $prefix = C('DB_PREFIX');
    $sql = str_replace("{$orginal}", "{$prefix}", $sql);
    // 开始安装
    foreach ($sql as $value) {
        $value = trim($value);
        if (empty($value)) {
            continue;
        }
        $res = M()->execute($value);
        // dump($res);
        // dump(M()->getLastSql());
    }
}
Ejemplo n.º 18
0
 function get_image_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if (!$res) {
             return 0;
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return 0;
     }
     $param['type'] = 'image';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return 0;
     }
     return $res['media_id'];
 }
Ejemplo n.º 19
0
/**
 * 通过openid获取用户基本信息
 */
function get_wx_user_info($openid = null, $lang = 'zh_CN')
{
    $access_token = get_access_token();
    !empty($openid) || ($openid = get_openid());
    $url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=' . $access_token . '&openid=' . $openid . '&lang=' . $lang;
    return json_decode(wp_file_get_contents($url), true);
}
Ejemplo n.º 20
0
 /**
  * 本地一键安装接口
  *
  * @return void
  */
 public function downloadAndInstall()
 {
     header("content-Type: text/html; charset=utf-8");
     // 获取下载地址
     $id = intval($_GET['id']);
     $url = $this->remoteBaseURL . '/index.php?s=admin/store/downloadApp&id=' . $id;
     // 		dump($url);exit;
     $info = wp_file_get_contents($url);
     $info = json_decode($info, true);
     if (!$info['status']) {
         $this->error($info['error']);
         exit;
     }
     // 载入下载类
     Vendor('Update');
     $updateClass = new \Update();
     // 从服务器端下载应用到本地
     $res = $updateClass->downloadFile($info['data']['packageURL']);
     if ($res != 1) {
         $this->error('下载应用失败,请确认网络是否正常');
         exit;
     }
     // 压缩
     $package = explode('/', $info['data']['packageURL']);
     $packageName = array_pop($package);
     $targetDir = $updateClass->downloadPath . 'unzip';
     // 创建目录unzip
     if (!is_dir($targetDir)) {
         @mkdir($targetDir, 0777);
     }
     $res = $updateClass->unzipPackage($packageName, $targetDir);
     if ($res != 1) {
         $this->error('下载应用解压失败');
         exit;
     }
     // 覆盖代码
     switch ($info['data']['type']) {
         case 3:
             // 万能页面功能块
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Diy/Widget');
             break;
         case 2:
             // 在线素材
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/Material');
             break;
         case 2:
             // 微官网模板
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons/WeiSite/View/default');
             break;
         default:
             // 微信插件
             $res = $updateClass->overWrittenFile(SITE_PATH . '/Addons');
             if (empty($res)) {
                 $this->install($updateClass->addon_name);
                 exit;
             }
     }
     $this->success('安装完成');
 }
Ejemplo n.º 21
0
 function _video_download($media_id, $cover_url)
 {
     $savePath = SITE_PATH . '/Uploads/Download/' . time_format(NOW_TIME, 'Y-m-d');
     mkdirs($savePath);
     $ext = 'mp4';
     if (empty($cover_url)) {
         // 获取图片URL
         $url = 'https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=' . get_access_token();
         $param['media_id'] = $media_id;
         $info = post_data($url, $param);
         // 	        $picjson = json_decode ( $picContent, true );
         if (isset($info['errcode']) && $info['errcode'] != 0) {
             $this->error(error_msg($info, '下载视频文件素材失败'));
             exit;
         }
         // 	        $this->_video_download(0, $info['down_url']);
         return $info;
         // }
     } else {
         $content = wp_file_get_contents($cover_url);
         // 获取图片扩展名
         $picExt = substr($cover_url, strrpos($cover_url, '=') + 1);
         // $picExt=='jpeg'
         if (empty($picExt)) {
             $picExt = $ext;
         }
         $picName = NOW_TIME . '.' . $picExt;
         $picPath = $savePath . '/' . $picName;
         $res = file_put_contents($picPath, $content);
         if (!$res) {
             $this->error('远程视频文件下载失败');
             exit;
         }
     }
     $cover_id = 0;
     if ($res) {
         // 保存记录,添加到picture表里,获取coverid
         $url = U('File/uploadPicture', array('session_id' => session_id()));
         $_FILES['download'] = array('name' => $picName, 'type' => 'application/octet-stream', 'tmp_name' => $picPath, 'size' => $res, 'error' => 0);
         $File = D('File');
         $file_driver = C('DOWNLOAD_UPLOAD_DRIVER');
         $info = $File->upload($_FILES, C('DOWNLOAD_UPLOAD'), C('DOWNLOAD_UPLOAD_DRIVER'), C("UPLOAD_{$file_driver}_CONFIG"));
         $cover_id = $info['download']['id'];
         unlink($picPath);
     }
     return $cover_id;
 }
    function jiamiFile()
    {
        // 取当前用户的网站信息
        $map['uid'] = $this->mid;
        $info = M('web_info')->where($map)->find();
        // 第一步:取文件内容
        $file = SITE_PATH . '/test.php';
        $get = trim(wp_file_get_contents($file));
        if ('<?php' == strtolower(substr($get, 0, 5))) {
            $get = substr($get, 5);
        } else {
            $get = substr($get, 2);
        }
        if ('?>' == substr($get, -2)) {
            $get = substr($get, 0, -2);
        }
        // 第二步:取加密的KEY
        $key = substr($info['web_key'], 0, 5);
        $license = substr($info['web_key'], 5);
        // 代码里插入判断授权的代码段
        $pre_code = <<<str
\t\t\$ip = gethostbyname ( SITE_DOMAIN );
\t\t\$fip = strtok ( \$ip, '.' );
\t\t\$is_free = \$fip == '10' || \$fip == '127' || \$fip == '168' || \$fip == '192';
\t\tif (! \$is_free) {
\t\t\t\$license = C ( 'WEIPHP_STORE_LICENSE' );
\t\t\t\$key = substr ( \$license, 0, 5 );
\t\t\t\$license = substr ( \$license, 5 );\t\t\t
\t\t\t
\t\t\t\$domain_str = md5 ( think_encrypt ( SITE_DOMAIN, \$key ) );
\t\t\t\$ip_str = md5 ( think_encrypt ( \$ip, \$key ) );
\t\t\tif (\$license != \$domain_str && \$license != \$ip_str) {
\t\t\t\theader("Content-Type: text/html;charset=utf-8"); 
\t\t\t\techo '禁止访问未授权的应用';
\t\t\t\texit ();
\t\t\t}
\t\t}
str;
        $content = strip_whitespace($pre_code . $get);
        $content = think_encrypt($content, $key);
        $content = "<?php eval(code_decode('{$content}'));";
        dump($content);
        file_put_contents(SITE_PATH . '/test2.php', $content);
    }
            ?>
<span class="arrow fa fa-sort-up"></span></a></li><?php 
        }
    }
} else {
    echo "";
}
?>
  
  <?php 
if (defined('_ADDONS')) {
    $page = _ADDONS . '_' . _CONTROLLER . '_' . _ACTION;
} else {
    $page = MODULE_NAME . '_' . CONTROLLER_NAME . '_' . ACTION_NAME;
}
$url = wp_file_get_contents(REMOTE_BASE_URL . '/index.php?s=/Home/Index/getDocUrl/page/' . $page);
if (strpos($url, 'http') == 0) {
    ?>
  <span class="fr" style="margin:10px;"><a href="<?php 
    echo $url;
    ?>
"><b style="font-size:16px;" class="fa fa-question-circle"></b>查看配置教程</a></span>
  <?php 
}
?>
</ul>
<?php 
if (!empty($sub_nav)) {
    ?>
<div class="sub-tab-nav">
       <ul class="sub_tab">
 function step01_checkVersionByAjax()
 {
     // 获取官方升级信息
     $url = $this->remoteBaseURL . '/index.php?s=/home/index/update_json&version=' . intval(C('SYSTEM_UPDATRE_VERSION'));
     $list = wp_file_get_contents($url);
     $list = json_decode($list, true);
     $this->assign('_list', $list);
     S('update_version_lists', $list);
     $this->display();
 }