Example #1
0
 public function login()
 {
     $username = jget('username', 'txt');
     $password = jget('password');
     $openid = jget('openid');
     if ($username == "" || $password == "") {
         json_error("无法登录,用户名或密码不能为空");
     }
     if ($this->Config['login_by_uid']) {
         is_numeric($username) && json_error("禁止使用UID登录");
     }
     if ($GLOBALS['_J']['plugins']['func']['login']) {
         hookscript('login', 'funcs', array('param' => $this->Post, 'step' => 'check'), 'login');
     }
     $rets = jsg_member_login($username, $password);
     $uid = (int) $rets['uid'];
     if ($uid < 1) {
         json_error(array_iconv($this->Config['charset'], 'utf-8', $rets['error']));
     }
     $r = false;
     if ($openid && $uid) {
         $r = jlogic('wechat')->do_bind($openid, $uid);
     }
     if ($r) {
         json_result("绑定成功!");
     } else {
         json_error("绑定失败!");
     }
 }
Example #2
0
 function MasterObject(&$config, $auto_run = false)
 {
     if (!$config['wap']) {
         include ROOT_PATH . 'wap/include/error_wap.php';
         exit;
     }
     $this->Config = $config;
     require_once ROOT_PATH . 'wap/include/func/wap_global.func.php';
     $this->Get =& $_GET;
     $this->Post =& $_POST;
     $this->Module = get_param('mod');
     $this->Code = get_param('code');
     $this->DatabaseHandler =& Obj::registry('DatabaseHandler');
     $this->MemberHandler = jclass('member');
     $this->MemberHandler->init();
     if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) {
         $member_error = $this->MemberHandler->GetError();
         $member_error = array_iconv($this->Config['charset'], 'utf-8', $member_error);
         $this->Messager($member_error, null);
     }
     if (!in_array($this->Module, array('member', 'login', 'other'))) {
         $visit_rets = $this->MemberHandler->visit();
         if ($visit_rets['error']) {
             $this->Messager(null, 'index.php?mod=login&referer=' . urlencode('index.php?' . $_SERVER['QUERY_STRING']));
         }
     }
     $this->Title = $this->MemberHandler->CurrentAction['name'];
     Obj::register("MemberHandler", $this->MemberHandler);
     if ($this->auto_run || $auto_run) {
         $this->auto_run();
     }
 }
Example #3
0
	function save()
	{
		if (true === ENC_IS_GBK && ($_REQUEST['in_ajax'] || true === X_IS_AJAX)) {
			$_POST = array_iconv('UTF-8', 'GBK', $_POST);
		}
		logic('tag')->save();
	}
Example #4
0
 private function _format($id, $data, $type)
 {
     switch ($type) {
         case '1':
             // json
             if (CHARSET == 'gbk') {
                 $data = array_iconv($data, 'gbk', 'utf-8');
             }
             return json_encode($data);
             break;
         case '2':
             // xml
             $xml = Loader::lib('Xml');
             return $xml->xml_serialize($data);
             break;
         case '3':
             // js
             Loader::func('dbsource:global');
             ob_start();
             include template_url($id);
             $html = ob_get_contents();
             ob_clean();
             return format_js($html);
             break;
     }
 }
Example #5
0
function kaixin_sync($data)
{
    $sys_config = kaixin_init();
    if (!$sys_config) {
        return 'kaixin_init is invalid';
    }
    $tid = is_numeric($data['tid']) ? $data['tid'] : 0;
    if ($tid < 1) {
        return 'tid is invalid';
    }
    $uid = is_numeric($data['uid']) ? $data['uid'] : 0;
    if ($uid < 1) {
        return 'uid is invalid';
    }
    $totid = is_numeric($data['totid']) ? $data['totid'] : 0;
    $content = $data['content'];
    if (false !== strpos($content, '[')) {
        $content = preg_replace('~\\[([^\\]]{1,6}?)\\]~', '(#\\1)', $content);
    }
    $content = array_iconv($sys_config['charset'], 'UTF-8', trim(strip_tags($content)));
    if (!$content) {
        return 'content is invalid';
    }
    $content .= " " . get_full_url($sys_config['site_url'], 'index.php?mod=topic&code=' . $tid);
    $kaixin_bind_info = kaixin_bind_info($uid);
    if (!$kaixin_bind_info) {
        return 'bind_info is empty';
    }
    if (!kaixin_has_bind($uid)) {
        return 'bind_info is invalid';
    }
    $kaixin_bind_topic = DB::fetch_first("select * from " . DB::table('kaixin_bind_topic') . " where `tid`='{$tid}'");
    if ($kaixin_bind_topic) {
        return 'bind_topic is invalid';
    } else {
        DB::query("insert into " . DB::table('kaixin_bind_topic') . " (`tid`) values ('{$tid}')");
    }
    $ret = array();
    if ($totid < 1) {
        $p = array();
        $p['access_token'] = $kaixin_bind_info['token'];
        $p['content'] = $content;
        $imageid = (int) $data['imageid'];
        if ($imageid > 0 && $sys_config['kaixin']['is_sync_image']) {
            $topic_image = topic_image($imageid, 'original');
            if (is_image(ROOT_PATH . $topic_image)) {
                $p['picurl'] = $sys_config['site_url'] . '/' . $topic_image;
                $p['save_to_album'] = 1;
            }
        }
        $ret = kaixin_api('records/add', $p);
    }
    $kaixin_id = is_numeric($ret['rid']) ? $ret['rid'] : 0;
    if ($kaixin_id > 0) {
        DB::query("UPDATE " . DB::table('kaixin_bind_topic') . " SET `kaixin_id`='{$kaixin_id}' WHERE `tid`='{$tid}'");
    }
    return $ret;
}
Example #6
0
 function convert($string)
 {
     global $_J;
     $charset = $_J['charset'];
     if (preg_match("/gbk/is", $charset)) {
         if (is_array($string)) {
             $string = array_iconv($charset, OUT_CHARSET, $string);
         } else {
             $string = iconv($charset, OUT_CHARSET, $string);
         }
     }
     return $string;
 }
Example #7
0
function widget_output($result, $status = '', $code = 0)
{
    $outputs = array();
    if ($status) {
        $outputs['status'] = $status;
        $outputs[$status] = true;
    }
    if ($code) {
        $outputs['code'] = $code;
    }
    $outputs['result'] = $result;
    $outputs = array_iconv($GLOBALS['_J']['charset'], 'utf-8', $outputs);
    ob_clean();
    echo json_encode($outputs);
}
Example #8
0
 /**
  * 请求远程数据
  * @param string $url       需要请求的地址。
  * @param string $backurl   返回地址
  */
 private static function _get_data($url, $backurl = '')
 {
     if ($data = @file_get_contents(self::$server_url . $url)) {
         $data = json_decode($data, true);
         //如果系统是GBK的系统,把UTF8转码为GBK
         if (pc_base::load_config('system', 'charset') == 'gbk') {
             $data = array_iconv($data, 'utf-8', 'gbk');
         }
         if ($data['status'] != 1) {
             showmessage($data['msg'], $backurl);
         } else {
             return $data['msg'];
         }
     } else {
         showmessage(L('your_server_it_may_not_have_access_to') . self::$server_url . L('_please_check_the_server_configuration'));
     }
 }
Example #9
0
 public function array_iconv($data, $encodedTypeOut = null)
 {
     $this->_setEncodedTypeOut($encodedTypeOut);
     $encoded = mb_detect_encoding($data, $this->encodedTypeIn);
     //自动判断编码
     if (!is_array($data)) {
         return mb_convert_encoding($data, $this->encodedTypeOut, $this->encodedTypeIn);
     } else {
         foreach ($data as $key => $val) {
             if (is_array($val)) {
                 $data[$key] = array_iconv($val, $this->encodedTypeOut);
             } else {
                 $data[$key] = mb_convert_encoding($data, $this->encodedTypeOut, $this->encodedTypeIn);
             }
         }
         return $data;
     }
 }
Example #10
0
 /**
  * 栏目列表
  */
 public function listing()
 {
     $cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : MSG(L('parameter_error'));
     $category = get_cache('category_' . $cid, 'content');
     //分页初始化
     $page = max(intval($GLOBALS['page']), 1);
     $pagesize = isset($GLOBALS['pagesize']) ? intval($GLOBALS['pagesize']) : 20;
     $model_r = get_cache('model_content', 'model');
     $master_table = $model_r[$category['modelid']]['master_table'];
     if ($category['type'] == 1) {
         $r = $this->db->get_one($master_table, array('cid' => $cid));
         if ($r) {
             extract($r, EXTR_SKIP);
             if ($attr_table = $model_r[$category['modelid']]['attr_table']) {
                 $r = $this->db->get_one($attr_table, array('id' => $id));
                 json_encode($r);
             }
         }
     } else {
         if ($category['child']) {
             $this->childs = '';
             $this->get_child($cid);
             $cids = implode(',', $this->childs);
             $where = '`cid` IN (' . $cids . ') AND `status`=9';
         } else {
             $where = "`cid`='{$cid}' AND `status`=9";
         }
         $result = $this->db->get_list($master_table, $where, '*', 0, $pagesize, $page, 'sort DESC,id DESC');
         if (empty($result)) {
             echo json_encode('finish');
             exit;
         }
         foreach ($result as $key => $rs) {
             $result[$key]['catname'] = $this->categorys[$rs['cid']]['name'];
             $result[$key]['updatetime'] = date('Y-m-d', $rs['updatetime']);
         }
         if (strtolower(CHARSET) == 'gbk') {
             $result = array_iconv('gbk', 'utf-8', $result);
         }
         echo json_encode($result);
     }
 }
Example #11
0
	/**
	* 通过外部接口方式获取详细地址信息
	* @return $localinfo province 省份 city城市  sp网络 提供商  pinyin拼音
	*/
	public function getcitybyapi($ip) {
		$api_url = $localinfo = '';
		$xml = pc_base::load_sys_class('xml');
		pc_base::load_sys_func('iconv');
		$api_url = 'http://ipquery.sdo.com/getipinfo.php?ip='.$ip;
		$data = $xml->xml_unserialize(@file_get_contents($api_url));
		if (CHARSET == 'gbk') {
			$data = !empty($data) ? array_iconv($data, 'utf-8', 'gbk') : array();
		}		
		if($data['ip']['result']) {
			$localinfo['province'] = $data['ip']['country'];
			$localinfo['city'] = $data['ip']['city'];
			$localinfo['sp'] = $data['ip']['sp'];		
			//$name = strtolower(CHARSET) == 'gbk' ? $localinfo['city'] : iconv(CHARSET,'gbk',$localinfo['city']);
			$name = str_replace(L('city'),'',$localinfo['city']);
			$letters = gbk_to_pinyin($name);	
			$localinfo['pinyin'] =strtolower(implode('', $letters));		
		}		
		return $localinfo;		
	}
Example #12
0
 function push_msg($uids, $msg = '')
 {
     if ($GLOBALS['_J']['config']['iphone_push_enable'] && $this->passphrase && $this->pem && $uids && $msg) {
         $tokens = $this->get_token($uids);
     }
     if ($tokens) {
         $ctx = stream_context_create();
         stream_context_set_option($ctx, 'ssl', 'local_cert', $this->pem);
         stream_context_set_option($ctx, 'ssl', 'passphrase', $this->passphrase);
         $fp = stream_socket_client('ssl:/' . '/gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
         if ($fp) {
             $body['aps'] = array('alert' => array_iconv(strtolower($GLOBALS['_J']['charset']), 'utf-8', $msg), 'sound' => 'default');
             $payload = json_encode($body);
             foreach ($tokens as $token) {
                 $pushmsg = chr(0) . pack('n', 32) . pack('H*', $token) . pack('n', strlen($payload)) . $payload;
                 fwrite($fp, $pushmsg, strlen($pushmsg));
             }
             fclose($fp);
         }
     }
 }
 function insert_data($array,$father='')
 {   $i = 0;
     foreach ($array as $key => $dir) {
         if (is_array($dir)){
             $this->insert_data($dir,$key);
         }elseif($key!='path'){
             //初始化插入数据
             $i++;
             $pic_name = array_iconv($dir);
             $file_path = array_iconv($father);
             $where = array('cat_original_name' => $file_path);
             $get_data = $this->product_cat->get_one($where, 'cat_id');
             $in_post = array(
                 'cat_id' => $get_data[cat_id],
                 'img_path' => array_iconv($array[path]).'/'.$pic_name,
                 'original_name' => $pic_name,
             );
             if($i == 1)$in_post[is_thumb] = 1;
             $this->insert($in_post);
         }
     }
 }
Example #14
0
 public function Pic()
 {
     $page = $_GET['page'] ? (int) $_GET['page'] : 0;
     if ($page) {
         $limit = '40,1000';
     } else {
         $limit = 40;
     }
     $r = jlogic('image')->get(array('where' => 'tid > 0', 'order' => 'id DESC', 'limit' => $limit));
     foreach ($r['list'] as $value) {
         $value['pics'] = topic_image($value['id'], 'small', 0);
         $value['pico'] = topic_image($value['id'], 'default', 0);
         $value['link'] = $this->Config[site_url] . '/index.php?mod=topic&amp;code=' . $value['tid'];
         $topic_list[] = $value;
     }
     $rss = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
     $rss .= "<rss version=\"2.0\" xmlns:media=\"http:/" . "/search.yahoo.com/mrss/\" xmlns:atom=\"http:/" . "/www.w3.org/2005/Atom\">\r\n";
     $rss .= "<channel>\r\n";
     $rss .= "<title>photo</title>\r\n";
     $rss .= "<link>{$this->Config[site_url]}</link>\r\n";
     $rss .= "<description>photo</description>\r\n";
     $rss .= "<language>zh_CN</language>\r\n";
     $rss .= "<pubDate>" . Date('Y-m-d H:i:s', time()) . "</pubDate>\r\n";
     $rss .= "<atom:link href=\"{$this->Config[site_url]}/index.php?mod=rss\" rel=\"self\" type=\"application/rss+xml\" />\r\n";
     $rss .= "<atom:link rel=\"next\" href=\"{$this->Config[site_url]}/index.php?mod=rss&amp;page=2\" />\r\n";
     foreach ($topic_list as $val) {
         $val['name'] = array_iconv($GLOBALS['_J']['charset'], 'utf-8', $val['name']);
         $rss .= "<item>\r\n";
         $rss .= "<title><![CDATA[{$val['name']}]]></title>\r\n";
         $rss .= "<link>{$val['link']}</link>\r\n";
         $rss .= "<media:thumbnail url=\"{$val['pics']}\"/>\r\n";
         $rss .= "<media:content url=\"{$val['pico']}\"/>\r\n";
         $rss .= "<guid isPermaLink=\"false\">{$val['link']}</guid>\r\n";
         $rss .= "</item>\r\n";
     }
     $rss .= "</channel>\r\n</rss>";
     return $rss;
 }
Example #15
0
 public function import()
 {
     if (isset($_POST['dosubmit'])) {
         $type = isset($_POST['type']) && trim($_POST['type']) ? trim($_POST['type']) : showmessage(L('illegal_operation'), HTTP_REFERER);
         if ($type == 1) {
             $filename = $_FILES['file']['tmp_name'];
             if (strtolower(substr($_FILES['file']['name'], -3, 3)) != 'txt') {
                 showmessage(L('only_allowed_to_upload_txt_files'), HTTP_REFERER);
             }
             $code = json_decode(base64_decode(file_get_contents($filename)), true);
             @unlink($filename);
         } elseif ($type == 2) {
             $code = isset($_POST['code']) && trim($_POST['code']) ? json_decode(base64_decode(trim($_POST['code'])), true) : showmessage(L('illegal_operation'), HTTP_REFERER);
             if (!isset($code['dirname'])) {
                 showmessage(L('illegal_parameters'), HTTP_REFERER);
             }
         }
         if (pc_base::load_config('system', 'charset') == 'gbk') {
             $code = array_iconv($code, 'utf-8', 'gbk');
         }
         echo $this->filepath . $code['dirname'] . DIRECTORY_SEPARATOR . 'config.php';
         if (!file_exists($this->filepath . $code['dirname'] . DIRECTORY_SEPARATOR . 'config.php')) {
             if (@is_writable($this->filepath . $code['dirname'] . DIRECTORY_SEPARATOR)) {
                 @mkdir($this->filepath . $code['dirname'] . DIRECTORY_SEPARATOR, 0755, true);
                 @file_put_contents($this->filepath . $code['dirname'] . DIRECTORY_SEPARATOR . 'config.php', '<?php return ' . var_export($code, true) . ';?>');
                 showmessage(L('operation_success'), HTTP_REFERER, '', 'import');
             } else {
                 showemssage(L('template_directory_not_write'), HTTP_REFERER);
             }
         } else {
             showmessage(L('file_exists'), HTTP_REFERER);
         }
     } else {
         $show_header = true;
         include $this->admin_tpl('style_import');
     }
 }
Example #16
0
 /**
  * 获取子栏目json
  * Enter description here ...
  * @param unknown_type $myid
  */
 public function creat_sub_json($myid, $str = '')
 {
     $sub_cats = $this->get_child($myid);
     $n = 0;
     if (is_array($sub_cats)) {
         foreach ($sub_cats as $c) {
             $data[$n]['id'] = iconv(CHARSET, 'utf-8', $c['catid']);
             if ($this->get_child($c['catid'])) {
                 $data[$n]['liclass'] = 'hasChildren';
                 $data[$n]['children'] = array(array('text' => '&nbsp;', 'classes' => 'placeholder'));
                 $data[$n]['classes'] = 'folder';
                 $data[$n]['text'] = iconv(CHARSET, 'utf-8', $c['catname']);
             } else {
                 if ($str) {
                     @extract(array_iconv($c, CHARSET, 'utf-8'));
                     eval("\$data[{$n}]['text'] = \"{$str}\";");
                 } else {
                     $data[$n]['text'] = iconv(CHARSET, 'utf-8', $c['catname']);
                 }
             }
             $n++;
         }
     }
     return json_encode($data);
 }
Example #17
0
 /**
  * 导出采集配置
  */
 public function export()
 {
     $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
     if ($data = $this->db->getby_nodeid($nodeid)) {
         unset($data['nodeid'], $data['name']);
         if (CHARSET == 'gbk') {
             $data = array_iconv($data);
         }
         header("Content-type: application/octet-stream");
         header("Content-Disposition: attachment; filename=yun_collection_" . $nodeid . '.txt');
         echo base64_encode(json_encode($data));
     } else {
         showmessage(L('notfound'));
     }
 }
Example #18
0
 /**
  * json方式读取风格列表,推送部分调用
  */
 public function public_change_tpl()
 {
     pc_base::load_sys_class('form', '', 0);
     $models = getcache('model', 'commons');
     $modelid = intval($_GET['modelid']);
     if ($_GET['modelid']) {
         $style = $models[$modelid]['default_style'];
         $category_template = $models[$modelid]['category_template'];
         $list_template = $models[$modelid]['list_template'];
         $show_template = $models[$modelid]['show_template'];
         $html = array('template_list' => $style, 'category_template' => form::select_template($style, 'content', $category_template, 'name="setting[category_template]"', 'category'), 'list_template' => form::select_template($style, 'content', $list_template, 'name="setting[list_template]"', 'list'), 'show_template' => form::select_template($style, 'content', $show_template, 'name="setting[show_template]"', 'show'));
         if (CHARSET == 'gbk') {
             $html = array_iconv($html, 'gbk', 'utf-8');
         }
         echo json_encode($html);
     }
 }
Example #19
0
 public function export()
 {
     $nodeid = isset($_GET['nodeid']) ? intval($_GET['nodeid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
     if ($data = $this->db->get_one(array('nodeid' => $nodeid))) {
         unset($data['nodeid'], $data['name'], $data['siteid']);
         if (pc_base::load_config('system', 'charset') == 'gbk') {
             $data = array_iconv($data);
         }
         header("Content-type: application/octet-stream");
         header("Content-Disposition: attachment; filename=pc_collection_" . $nodeid . '.txt');
         echo base64_encode(json_encode($data));
     } else {
         showmessage(L('notfound'));
     }
 }
Example #20
0
 /**
  * Function http
  * 执行http post数据到接口
  * @param array $datas post数据参数 如:array('method'=>'AlbumVideoList', 'p'=>1, 's'=>6,....)
  */
 private function post($datas = array())
 {
     //构造post数据
     $data['sn'] = $this->ku6api_sn;
     $data['posttime'] = SYS_TIME;
     $data['token'] = $this->xxtea->encrypt($data['posttime'], $this->ku6api_skey);
     if (strtolower(CHARSET) == 'gbk') {
         $datas = array_iconv($datas, 'gbk', 'utf-8');
     }
     if (is_array($datas)) {
         foreach ($datas as $_k => $d) {
             if (is_array($d)) {
                 $data[$_k] = json_encode($d);
             } else {
                 $data[$_k] = $d;
             }
         }
     }
     //向vms post数据,并获取返回值
     $this->http->post($this->ku6api_url, $data);
     $get_data = $this->http->get_data();
     $get_data = json_decode($get_data, true);
     //成功时vms返回code=200 而ku6返回status=1
     if ($get_data['code'] == 200 || $get_data['status'] == 1) {
         //将gbk编码转为utf-8编码
         if (strtolower(CHARSET) == 'gbk') {
             $get_data = array_iconv($get_data, 'utf-8', 'gbk');
         }
         return $get_data;
     } else {
         return $get_data;
     }
 }
Example #21
0
$siteid = $cat_info['siteid'];
$modelid = $cat_info['modelid'];
//根据模型id,得到视频字段名
$r = $model_field->get_one(array('modelid' => $modelid, 'formtype' => 'video'), 'field');
$fieldname = $r['field'];
if ($_POST['posid']) {
    $data['posids'][] = $_POST['posid'];
}
$data['thumb'] = safe_replace(format_url($_POST['picpath']));
$data[$fieldname] = 1;
//组合POST数据
$_POST[$fieldname . '_video'][1] = array('videoid' => $videoid, 'listorder' => 1);
$data['status'] = $video_data['status'] == 21 || $_POST['status'] == 1 ? 99 : 1;
//调用内容模型
if (strtolower(CHARSET) != 'utf-8') {
    $data = array_iconv($data, 'utf-8', 'gbk');
}
$content->set_model($modelid);
$cid = $content->add_content($data);
//更新对应关系
//$content_video_db = pc_base::load_model('video_content_model');
//$content_video_db->insert(array('contentid'=>$cid, 'videoid'=>$videoid, 'modelid'=>$modelid, 'listorder'=>1));
//更新点击次数
if ($_POST['playnum']) {
    $views = intval($_POST['playnum']);
    $hitsid = 'c-' . $modelid . '-' . $cid;
    $count = pc_base::load_model('hits_model');
    $count->update(array('views' => $views), array('hitsid' => $hitsid));
}
echo json_encode(array('msg' => 'Add Success', 'code' => '200'));
exit;
Example #22
0
 /**
  * Function add_f_ckeditor
  * ckeditor中添加视频
  */
 public function add_f_ckeditor()
 {
     //首先处理,提交过来的数据
     $data = array();
     $data['vid'] = $_GET['vid'];
     if (!$data['vid']) {
         exit('1');
     }
     $data['title'] = isset($_GET['title']) && trim($_GET['title']) ? addslashes(trim($_GET['title'])) : exit('2');
     $data['title'] = safe_replace($data['title']);
     $data['title'] = str_replace(array('select', 'from', 'concat'), '', $data['title']);
     $data['description'] = addslashes(trim($_GET['description']));
     $data['description'] = safe_replace(str_replace(array('select', 'from', 'concat'), '', $data['description']));
     $data['keywords'] = addslashes(trim(strip_tags($_GET['keywords'])));
     $data['keywords'] = safe_replace(str_replace(array('select', 'from', 'concat'), '', $data['keywords']));
     //其次向vms post数据,并取得返回值
     $get_data = $this->ku6api->vms_add($data);
     if (!$get_data) {
         exit('3');
     }
     $data['vid'] = $get_data['vid'];
     $data['addtime'] = SYS_TIME;
     if (strtolower(CHARSET) == 'gbk') {
         $data = array_iconv($data, 'utf-8', 'gbk');
     }
     $data['userupload'] = intval($_GET['userupload']);
     $videoid = $this->v->add($data);
     $vid_url = $data['vid'];
     exit($vid_url);
 }
Example #23
0
	/**
	 * 在线安装
	 */
	public function install_online() {
		$data = array();
		$id = intval($_GET['id']);
		$data = file_get_contents('http://open.ZLCMS.cn/index.php?m=open&c=api&a=get_detail_byappid&id='.$id);
		$data = array_iconv(json_decode($data, true),'utf-8',CHARSET);
		
		//如果为iframe类型应用,无需下载压缩包,之间创建插件文件夹
		if(!empty($data['iframe'])) {
			$appdirname = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$data['appenname'];
			if(!file_exists($appdirname)) {
				if(!mkdir($appdirname)) {
					showmessage(L('plugin_mkdir_fail', '', 'plugin'));
				} else {
					//创建安装、配置文件
					$installdata = <<<EOF
<?php 
	defined('IN_ZLCMS') or exit('No permission resources.');
	\$op_status = TRUE;
?>
EOF;
					$uninstallres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'uninstall.php', $installdata);
					$installres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'install.php', $installdata);
					
					$cfgdata = <<<EOF
<?php
return array (
  'identification' => '$data[appenname]',
  'dir' => '$data[appenname]',
  'appid' => '$data[id]',
  'plugin'=> array(
		  'version' => '1.0',
		  'name' => '$data[appname]',
		  'copyright' => 'ZLCMS team',
		  'description' =>'$data[description]',
		  'installfile' => 'install.php',
		  'uninstallfile' => 'uninstall.php',
		  'iframe' => array('width'=>'960','height'=>'640','url'=>'$data[iframe]'),		  
	),
   'plugin_var'=> array(   array('title'=>'宽度','description'=>'','fieldname'=>'width','fieldtype'=>'text','value'=>'960','formattribute'=>'style="width:50px"','listorder'=>'1',),		array('title'=>'高度','description'=>'','fieldname'=>'height','fieldtype'=>'text','value'=>'640','formattribute'=>'style="width:50px"','listorder'=>'2',),   
	),	
);
?>				
EOF;
					$cfgres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'plugin_'.$data['appenname'].'.cfg.php', $cfgdata);
					
					//检查配置文件是否写入成功
					if($installres*$uninstallres*$cfgres > 0) {
						showmessage(L('plugin_configure_success', '', 'plugin'), 'index.php?m=zl_admin&c=plugin&a=import&dir='.$data['appenname']);
					} else {
						showmessage(L('plugin_install_fail', '', 'plugin'));
					}
				}
			} else {
				showmessage(L('plugin_allready_exists', '', 'plugin'));
			}
		} else {	
			//远程压缩包地址
			$upgradezip_url = $data['downurl'];
			if(empty($upgradezip_url)) {
				showmessage(L('download_fail', '', 'plugin'), 'index.php?m=zl_admin&c=plugin&a=appcenter');
			}
			
			//创建缓存文件夹
			if(!file_exists(CACHE_PATH.'caches_open')) {
				@mkdir(CACHE_PATH.'caches_open');
			}
			//保存到本地地址
			$upgradezip_path = CACHE_PATH.'caches_open'.DIRECTORY_SEPARATOR.$data['id'].'.zip';
			//解压路径
			$upgradezip_source_path = CACHE_PATH.'caches_open'.DIRECTORY_SEPARATOR.$data['id'];
				
			//下载压缩包
			@file_put_contents($upgradezip_path, @file_get_contents($upgradezip_url));
			//解压缩
			pc_base::load_app_class('pclzip', 'upgrade', 0);
			$archive = new PclZip($upgradezip_path);
	
			if($archive->extract(PCLZIP_OPT_PATH, $upgradezip_source_path, PCLZIP_OPT_REPLACE_NEWER) == 0) {
				die("Error : ".$archive->errorInfo(true));
			}
			//删除压缩包
			@unlink($upgradezip_path);
			
			//拷贝gbk/upload文件夹到根目录
			$copy_from = $upgradezip_source_path.DIRECTORY_SEPARATOR.CHARSET;
			//动态程序路径
			$copy_to_pcpath = PC_PATH.'plugin';
			//静态程序路径
			$copy_to_staticspath = ZLCMS_PATH.'statics'.DIRECTORY_SEPARATOR.'plugin';

			//应用文件夹名称
			$appdirname = $data['appenname'];
	
			$this->copyfailnum = 0;
			$this->copydir($copy_from.DIRECTORY_SEPARATOR.'ZLCMS'.DIRECTORY_SEPARATOR.'plugin', $copy_to_pcpath, $_GET['cover']);
			$this->copydir($copy_from.DIRECTORY_SEPARATOR.'statics'.DIRECTORY_SEPARATOR.'plugin', $copy_to_staticspath, $_GET['cover']);
			$this->deletedir($copy_from);
			//检查文件操作权限,是否复制成功
			if($this->copyfailnum > 0) {
				showmessage(L('download_fail', '', 'plugin'), 'index.php?m=zl_admin&c=plugin&a=appcenter');
			} else {
				showmessage(L('download_success', '', 'plugin'), 'index.php?m=zl_admin&c=plugin&a=import&dir='.$appdirname);
			}
		}
	}
Example #24
0
 public function complete_info()
 {
     if (isset($_POST['dosubmit'])) {
         $info = safe_replace($_POST['info']);
         //包含隐藏的uid
         if (CHARSET == 'gbk') {
             $info = array_iconv($info);
         }
         //提交数据,获取SKEY,SN
         $return_skey_sn = $this->ku6api->complete_info($info);
         if (is_array($return_skey_sn) && !empty($return_skey_sn)) {
             $setting = array2string($return_skey_sn);
             setcache('video', $return_skey_sn);
             $this->ku6api->ku6api_skey = $return_skey_sn['skey'];
             $this->ku6api->ku6api_sn = $return_skey_sn['sn'];
             $this->module_db->update(array('setting' => $setting), array('module' => 'video'));
             showmessage('资料提交成功,已成功开通视频应用,正在返回!', '?m=video&c=video&a=open');
         } else {
             echo $return_skey_sn;
             exit;
             showmessage('资料提交失败,请联系商务人员处理!', '?m=video&c=video&a=open');
         }
     } else {
         //如果传递uid,snid则为登录通行证成功,返回完善资料,没有传递则为自行填写资料申请开通视频应用
         $uid = intval($_GET['uid']);
         $snid = $_GET['snid'];
         if (empty($this->setting['skey']) || empty($this->setting['sn'])) {
             if (!$snid) {
                 showmessage("请先登录盛大通行证");
             }
         }
         //如果skey,sn存在,通过接口调取用户完善的资料,再提交为修改操作
         $skey_sn_array = getcache('video');
         if (!empty($skey_sn_array['skey']) && !empty($skey_sn_array['sn'])) {
             $return_info = $this->ku6api->Get_Complete_Info($skey_sn_array);
             if (CHARSET == 'gbk') {
                 $return_info = array_iconv($return_info, 'utf-8', 'gbk');
             }
             $complete_info = is_array($return_info) ? $return_info : array();
             $uid = $complete_info['uid'];
             $snid = $complete_info['sndaid'];
         } else {
             //没有配置则判断域名在聚合平台是否已经存在,如果存在进行验证获取SKEY
             $check_user_back = APP_PATH . 'api.php?op=video_api';
             $return_check = $this->ku6api->check_user_back($check_user_back);
             if ($return_check == 200) {
                 //存在同域名记录,进行email验证
                 showmessage('域名已经存在,请验证开通视频应用!', '?m=video&c=video&a=check_user_back');
             }
             $complete_info = array();
         }
         $show_dialog = 1;
         $show_header = $show_scroll = true;
         include $this->admin_tpl('video_complete_info');
     }
 }
Example #25
0
 function SyncReply()
 {
     $sina = jconf::get('sina');
     if (!$sina['is_syncreply_tojishigou']) {
         return;
     }
     $tid = max(0, (int) ($this->Post['tid'] ? $this->Post['tid'] : $this->Get['tid']));
     if (!$tid) {
         return;
     }
     $info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `tid`='{$tid}'");
     if (!$info) {
         return;
     }
     $mid = $info['mid'];
     if (!$mid) {
         return;
     }
     if ($sina['syncweibo_tojishigou_time'] > 0 && $info['last_read_time'] + $sina['syncweibo_tojishigou_time'] > time()) {
         return;
     }
     if (!($topic_info = DB::fetch_first("select * from " . TABLE_PREFIX . "topic where `tid`='{$tid}'"))) {
         return;
     }
     $xwb_bind_info = sina_weibo_bind_info($topic_info['uid']);
     if (!$xwb_bind_info) {
         return;
     }
     if (!sina_weibo_bind($topic_info['uid'])) {
         return;
     }
     if (!sina_weibo_syncreply_tojishigou($topic_info['uid'])) {
         return;
     }
     if (!$this->MemberHandler->HasPermission('xwb', '__syncreply', 0, $topic_info['uid'])) {
         return;
     }
     if ($this->module_config['oauth2_enable']) {
         $p = array('id' => $mid, 'access_token' => $xwb_bind_info['access_token']);
         $rets = sina_weibo_api('2/comments/show', $p, 'GET');
         $datas = $rets['comments'];
     } else {
         require_once ROOT_PATH . 'include/ext/xwb/sina.php';
         $wb = XWB_plugin::getWB();
         $datas = $wb->getComments($mid);
     }
     if ($datas) {
         krsort($datas);
         $TopicLogic = jlogic('topic');
         foreach ($datas as $data) {
             $mid = $data['idstr'] ? $data['idstr'] : ($data['mid'] ? $data['mid'] : $data['id']);
             $sina_uid = $data['user']['id'];
             if ($mid && ($bind_info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_info where `sina_uid`='{$sina_uid}'")) && !DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `mid`='{$mid}'") && ($content = trim(strip_tags(array_iconv('utf-8', $this->Config['charset'], $data['text'] . (isset($data['retweeted_status']) ? " /" . "/@{$data['retweeted_status']['user']['name']}: {$data['retweeted_status']['text']}" : "")))))) {
                 DB::query("insert into " . TABLE_PREFIX . "xwb_bind_topic (`mid`) values ('{$mid}')");
                 $_t = time();
                 if ($data['created_at']) {
                     $_t = strtotime($data['created_at']);
                 }
                 $_t = is_numeric($_t) ? $_t : 0;
                 $add_datas = array('totid' => $tid, 'content' => $content, 'from' => 'sina', 'type' => 'reply', 'uid' => $bind_info['uid'], 'timestamp' => $_t);
                 $add_result = $TopicLogic->Add($add_datas);
                 if (is_array($add_result) && count($add_result)) {
                     $_tid = max(0, (int) $add_result['tid']);
                     if ($_tid) {
                         if ($sina['is_syncimage_tojishigou'] && $data['original_pic']) {
                             $TopicLogic->_parse_url_image($add_result, $data['original_pic']);
                         }
                         DB::query("replace into " . DB::table('xwb_bind_topic') . " (`tid`, `mid`) values ('{$_tid}', '{$mid}')");
                     }
                 }
             }
         }
     }
     DB::query("update `" . TABLE_PREFIX . "xwb_bind_topic` set `last_read_time`='" . time() . "' where `tid`='{$tid}'");
 }
Example #26
0
/**
 * 对数据进行编码转换
 * @param array/string $data       数组
 * @param string $input     需要转换的编码
 * @param string $output    转换后的编码
 */
function array_iconv($data, $input = 'gbk', $output = 'utf-8')
{
    if (!is_array($data)) {
        return iconv($input, $output, $data);
    } else {
        foreach ($data as $key => $val) {
            if (is_array($val)) {
                $data[$key] = array_iconv($val, $input, $output);
            } else {
                $data[$key] = iconv($input, $output, $val);
            }
        }
        return $data;
    }
}
Example #27
0
 public function ajax()
 {
     $reviewsid =& $this->reviewsid;
     $siteid =& $this->siteid;
     $num = isset($_GET['num']) && intval($_GET['num']) ? intval($_GET['num']) : 20;
     $star1 = isset($_GET['star1']) && intval($_GET['star1']) ? intval($_GET['star1']) : 0;
     $star2 = isset($_GET['star2']) && intval($_GET['star2']) ? intval($_GET['star2']) : 0;
     $star3 = isset($_GET['star3']) && intval($_GET['star3']) ? intval($_GET['star3']) : 0;
     $star4 = isset($_GET['star4']) && intval($_GET['star4']) ? intval($_GET['star4']) : 0;
     $star5 = isset($_GET['star5']) && intval($_GET['star5']) ? intval($_GET['star5']) : 0;
     $star6 = isset($_GET['star6']) && intval($_GET['star6']) ? intval($_GET['star6']) : 0;
     $startype = isset($_GET['startype']) && intval($_GET['startype']) ? intval($_GET['startype']) : 1;
     $starnum = isset($_GET['starnum']) && intval($_GET['starnum']) ? intval($_GET['starnum']) : 4;
     $pc_tag = pc_base::load_app_class('reviews_tag');
     $reviews = array();
     if ($reviews = $pc_tag->get_reviews(array('reviewsid' => $reviewsid))) {
         $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1;
         $offset = ($page - 1) * $num;
         $data = array('reviewsid' => $reviewsid, 'site' => $siteid, 'limit' => $offset . ',' . $num, 'star1' => $star1, 'star2' => $star2, 'star3' => $star3, 'star4' => $star4, 'star5' => $star5, 'star6' => $star6, 'startype' => $startype);
         $reviews['data'] = $pc_tag->lists($data);
         pc_base::load_sys_class('format', '', 0);
         foreach ($reviews['data'] as $k => $v) {
             $reviews['data'][$k]['format_time'] = format::date($v['creat_at'], 1);
         }
         $reviews['pages'] = pages($total, $page, $num, 'javascript:reviews_next_page({$page})');
         if (pc_base::load_config('system', 'charset') == 'gbk') {
             $reviews = array_iconv($reviews, 'gbk', 'utf-8');
         }
         echo json_encode($reviews);
     } else {
         exit('0');
     }
 }
Example #28
0
	$o['Value'] = $one['price'];
	$o['Price'] = $one['nowprice'];
	$o['Rebate'] = $one['discount'];
	$bgtime = str_replace('-', '', $one['begintime']).'000000';
	$ovtime = str_replace('-', '', $one['overtime']).'000000';
	$o['StartTime'] = $bgtime;
	$o['EndTime'] = $ovtime;
	$o['Quantity'] = $one['maxnum'];
	$o['Bought'] = $one['num'];
	$o['MinBought'] = $one['successnum'];
	$o['BoughtLimit'] = $one['oncemax'];

		$g = array();
		$g['Name'] = $one['sellername'];
		$g['ProviderName'] = $one['sellername'];
		$g['ProviderUrl'] = $one['sellerurl'];
		$g['ImageUrlSet'] = imager($one['img']);
		$g['Contact'] = $one['sellerphone'];
		$g['Address'] = $one['selleraddress'];
		$g['Map'] = null;
		$g['Description'] = $one['selleraddress'];

	$o['Goods'] = $g;
	$oa[] = $o;
}

header('Content-Type: application/xml; charset=UTF-8');
Output::SetTagSon('ActivitySet', 'Activity');
if (ENC_IS_GBK) $oa = array_iconv('GBK', 'UTF-8', $oa);
Output::XmlCustom($oa, 'ActivitySet');
?>
Example #29
0
 function Download()
 {
     global $_J;
     $attach_config = jconf::get('attach');
     $uid = MEMBER_ID;
     if ($uid < 1) {
         $this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", 'index.php?mod=login');
     }
     $candown = jclass('member')->HasPermission('uploadattach', 'down');
     if (!$candown) {
         $this->Messager("您没有下载附件的权限", null);
     }
     $readmod = 2;
     $downfile = get_param('downfile');
     if (!$downfile) {
         $this->Messager("您的下载链接地址错误", null);
     }
     @(list($dasize, $daid, $datime, $dadown) = explode('|', base64_decode($downfile)));
     $daid = (int) $daid;
     if ($daid <= 0) {
         $this->Messager("您的下载链接地址错误", null);
     }
     $down_attach_file = $this->AttachLogic->get_down_info($daid);
     if (empty($down_attach_file)) {
         $this->Messager("您的下载链接地址错误", null);
     }
     if ($dadown != $down_attach_file['download']) {
         defined('NEDU_MOYO') || $this->Messager("您的下载链接地址已经过期或失效!或您使用的是<font class='R'>360浏览器</font>,因其系统缺陷,请更换其它浏览器进行下载!", null);
     }
     $MIMETypes = array('doc' => 'application/msword', 'ppt' => 'application/vnd.ms-powerpoint', 'pdf' => 'application/pdf', 'xls' => 'application/vnd.ms-excel', 'txt' => 'text/plain', 'rar' => 'application/octet-stream', 'zip' => 'application/zip', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation');
     $de_attach_file_type = explode('|', $this->Config['attach_file_type']);
     foreach ($de_attach_file_type as $val) {
         if (!isset($MIMETypes[$val])) {
             $MIMETypes[$val] = 'application/octet-stream';
         }
     }
     if (!isset($MIMETypes[$down_attach_file['filetype']])) {
         $this->Messager("您只能下载(" . strtoupper(str_replace('|', ',', $this->Config['attach_file_type'])) . ")类型的文件", null);
     }
     if (!$down_attach_file['file'] || empty($down_attach_file['site_url']) && !(file_exists($down_attach_file['file']) && is_readable($down_attach_file['file']))) {
         $this->Messager("在服务器上找不到您要下载的文件,或文件不可读,或被删除,或数据错误,请联系网站管理员", null);
     }
     $auid = $down_attach_file['uid'];
     $score = $down_attach_file['score'];
     $this->AttachLogic->mod_download_num($daid);
     if ($score > 0) {
         if (!in_array($_J['member']['role_id'], explode(',', $attach_config['no_score_user']))) {
             update_credits_by_action('attach_down', $uid, 1, -$score);
         }
         if ($auid != $uid) {
             update_credits_by_action('down_my_attach', $auid, 1, $score);
         }
     }
     if ($down_attach_file['site_url']) {
         $ftptype = getftptype($down_attach_file['site_url']);
         if ($ftptype == 'Aliyun') {
             $ftpkey = getftpkey($down_attach_file['site_url']);
             $ftps = jconf::get('ftp');
             if ($ftps[$ftpkey]['type'] == 'Aliyun') {
                 define('ALI_LOG', FALSE);
                 define('ALI_DISPLAY_LOG', FALSE);
                 define('ALI_LANG', 'zh');
                 define('OSS_ACCESS_ID', $ftps[$ftpkey]['username']);
                 define('OSS_ACCESS_KEY', $ftps[$ftpkey]['password']);
                 define('OSS_BUCKET', $ftps[$ftpkey]['attachdir']);
                 define('OSS_HOST_NAME', $ftps[$ftpkey]['host']);
                 define('OSS_HOST_PORT', $ftps[$ftpkey]['port']);
                 define('OSS_SIGN_TIMEOUT', $ftps[$ftpkey]['timeout']);
                 define('OSS_ENABLED', $ftps[$ftpkey]['on']);
                 $oss = jclass('jishigou/oss');
                 $file = str_replace('./', '', $down_attach_file['file']);
                 $filename = urlencode(array_iconv($this->Config['charset'], 'UTF-8', $down_attach_file['name']));
                 $res = $oss->sign_url($file . '?response-content-disposition=attachment; filename=' . $filename, str_replace('http:/' . '/', '', $down_attach_file['site_url']));
                 $res = str_replace("?OSSAccessKeyId", "&OSSAccessKeyId", $res);
                 $res = str_replace("%3F", "?", $res);
                 $res = str_replace("disposition%3Dattachment", "disposition=attachment", $res);
                 header('location:' . $res);
             }
         } else {
             $fileurl = $down_attach_file['site_url'] . '/' . str_replace('./', '', $down_attach_file['file']);
             $this->Messager("文件存储在外部地址或FTP空间,正在跳转,请稍侯......", $fileurl);
         }
     } else {
         $fileType = $MIMETypes[$down_attach_file['filetype']];
         $down_attach_file['name'] = '"' . (strtolower(str_replace('-', '', $this->Config['charset'])) == 'utf8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($down_attach_file['name']) : $down_attach_file['name']) . '"';
         ob_end_clean();
         ob_start();
         header('Cache-control: max-age=31536000');
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
         header('Content-Encoding: none');
         header('Content-type: ' . $fileType);
         header('Content-Disposition: attachment; filename=' . $down_attach_file['name']);
         header('Content-Length: ' . filesize($down_attach_file['file']));
         if ($readmod == 1 || $readmod == 3) {
             if ($fp = @fopen($down_attach_file['file'], 'rb')) {
                 @fseek($fp, 0);
                 if (function_exists('fpassthru') && $readmod == 3) {
                     @fpassthru($fp);
                 } else {
                     echo @fread($fp, filesize($down_attach_file['file']));
                 }
             }
             @fclose($fp);
         } else {
             @readfile($down_attach_file['file']);
         }
         @flush();
         @ob_flush();
     }
 }
Example #30
-1
 function _qmd_img_list($pic_path = '', $user_uid = 0, $user_face = '', $topic_content = '', $topic_dateline)
 {
     header("Content-type: image/png");
     $bg = imagecreatefromjpeg($pic_path);
     $white = imagecolorallocate($bg, 00, 00, 00);
     $content = str_split($topic_content, 40);
     $content = array_iconv($this->Config['charset'], 'utf-8', $content);
     $topic_url = $this->Config['site_url'];
     $topic_date = array_iconv($this->Config['charset'], 'utf-8', $topic_dateline . ' | ' . '记事狗微博');
     imagettftext($bg, 9, 0, 130, 25, $white, "images/simsun.ttc", $content[0]);
     imagettftext($bg, 9, 0, 130, 45, $white, "images/simsun.ttc", $content[1]);
     imagettftext($bg, 9, 0, 130, 70, $white, "images/simsun.ttc", $topic_date);
     imagettftext($bg, 9, 0, 218, 90, $white, "images/simsun.ttc", $topic_url);
     $dst_im = imagecreatefromjpeg($bg);
     $dst_info = getimagesize($bg);
     $src = $user_face;
     $src_im = imagecreatefromjpeg($src);
     $src_info = getimagesize($src);
     $dst_x = 20;
     $dst_y = 12;
     $src_x = 0;
     $src_y = 0;
     $src_w = $src_info[0];
     $src_h = $src_info[1];
     $alpha = 100;
     imagecopymerge($bg, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $alpha);
     $image_path = RELATIVE_ROOT_PATH . 'images/qmd/' . face_path(MEMBER_ID);
     if (!is_dir($image_path)) {
         jio()->MakeDir($image_path);
     }
     $image_file = $image_path . MEMBER_ID . '_o.png';
     imagepng($bg, $image_file);
     imagedestroy($bg);
     return $image_file;
 }