示例#1
0
文件: sign.php 项目: ruoL/fun-x
 public function sign_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $e = $this->input->post('name', true);
     $c = $this->input->post('captcha', true);
     $p = $this->input->post('password', true);
     $e = strtolower(trim($e));
     $p = strtolower(trim($p));
     $c = strtolower(trim($c));
     $sess = $this->session->userdata('captcha');
     if (md5($c) != $sess) {
         JSON('error', '验证码输入有误!');
     }
     /** 登录用户登录状态 */
     $user = $this->auth->checkuserlogin($e, $p);
     if (false === $user) {
         JSON('error', '用户名或密码错误!');
     }
     $arr = explode('|', config_item('site_admin_uid'));
     if (!$user->uid or !in_array($user->uid, $arr)) {
         JSON('error', '你的账号状态不正常!');
     }
     /** 处理用户登录 */
     $this->auth->process_login($user);
     JSON('success', '登录成功!', admin_site_url());
 }
 function move_group($id, $group_id)
 {
     is_array($id) || ($id = explode(',', $id));
     $data['uid'] = $map['uid'] = array('in', $id);
     // $data ['group_id'] = $group_id; //TODO 前端微信用户只能有一个微信组
     $res = M('auth_group_access')->where($data)->delete();
     $data['group_id'] = $group_id;
     foreach ($id as $uid) {
         $data['uid'] = $uid;
         $res = M('auth_group_access')->add($data);
         // 更新用户缓存
         D('Common/User')->getUserInfo($uid, true);
     }
     $group = $this->find($group_id);
     // 同步到微信端
     if (C('USER_GROUP') && !empty($group['wechat_group_id'])) {
         $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . get_access_token();
         $map['token'] = get_token();
         $follow = M('public_follow')->where($map)->field('openid, uid')->select();
         foreach ($follow as $v) {
             if (empty($v['openid'])) {
                 continue;
             }
             $param['openid'] = $v['openid'];
             $param['to_groupid'] = $group['wechat_group_id'];
             $param = JSON($param);
             $res = post_data($url, $param);
         }
     }
     return $group;
 }
示例#3
0
文件: server.php 项目: JasonWiki/docs
function callback($status, $msg = 'Yes!', $data = array())
{
    $return = array('status' => $status, 'msg' => $msg, 'data' => $data, 'num' => count($data));
    header('charset=utf-8');
    //die(json_encode($return));
    exit(JSON($return));
}
 function list_data()
 {
     $page = I('p', 1, 'intval');
     $map['token'] = get_token();
     $list_data = M('coupon_shop')->where($map)->order('id DESC')->page($page, 20)->selectPage(20);
     // dump ( $list_data );
     echo JSON($list_data);
 }
示例#5
0
 public function infopart_list($start, $end)
 {
     $info_db = M('info');
     $map['infoid'] = array(array('gt', $start), array('lt', $end));
     $data = $info_db->where($map)->select();
     header('Content-Type:text/html;Charset=UTF-8');
     echo JSON($data);
 }
示例#6
0
 /**
  * 统一数据返回
  * @param unknown_type $status
  * @param unknown_type $msg
  * @param unknown_type $data
  */
 protected function callback($status, $msg = 'Yes!', $data = array())
 {
     $return = array('status' => $status, 'msg' => $msg, 'data' => $data, 'num' => count($data));
     //	header('Content-Type:text/html;charset=utf-8');
     header('Content-Type:application/json;charset=utf-8');
     //die(json_encode($return));
     die(JSON($return));
 }
示例#7
0
function post_youkang_data1($url, $param, $is_file = false, $return_array = true)
{
    $param = JSON($param);
    $data = http_build_query($param);
    $length = strlen($data);
    $fp = fsockopen("http://www.youkang120.com", 80, $errno, $errstr, 10) or exit($errstr . "--->" . $errno);
    $header = "POST /mobileConsultationList HTTP/1.1\r\n";
    $header .= "Host:localhost\r\n";
    $header .= "Content-Length: " . $lenght . "\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= 'Connection: Keep-Alive\\r\\n';
    $header .= 'Pragma: no-cache\\r\\n';
    $header .= 'Cache-Control: no-cache\\r\\n';
    $header .= "Connection: Close\r\n\r\n";
    $header .= $data . "\r\n";
    fwrite($fp, $header);
    while (!feof($fp)) {
        echo fgets($fp, 1280);
    }
    fclose($fp);
}
示例#8
0
文件: tag.php 项目: ruoL/fun-x
 public function stats_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $this->_clear();
     $stats = $this->_stats();
     JSON('success', '共计 ' . $stats['rows'] . ' 个标签,当前操作已成功更新 ' . $stats['affe'] . ' 条记录!');
 }
示例#9
0
function post_data($url, $param, $is_file = false, $return_array = true)
{
    if (!$is_file && is_array($param)) {
        $param = JSON($param);
    }
    if ($is_file) {
        $header[] = "content-type: multipart/form-data; charset=UTF-8";
    } else {
        $header[] = "content-type: application/json; charset=UTF-8";
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $res = curl_exec($ch);
    $flat = curl_errno($ch);
    if ($flat) {
        $data = curl_error($ch);
        addWeixinLog($flat, 'post_data flat');
        addWeixinLog($data, 'post_data msg');
    }
    curl_close($ch);
    $return_array && ($res = json_decode($res, true));
    return $res;
}
示例#10
0
         $search_text = $_POST['search_text'];
         $sql = "insert into baidu(search_text) values(" . "'{$search_text}'" . ")";
         mysql_query($sql, $conn);
         echo "save_ok";
         mysql_close($conn);
     }
 } else {
     if ($code == "show") {
         if ($_POST['search_text']) {
             $search_text = $_POST['search_text'];
             //使用模糊查询进行关键字搜索
             $sql = "select search_text from baidu where search_text like '%" . $search_text . "%'";
             $res = mysql_query($sql, $conn);
             $result = "";
             while ($row = mysql_fetch_assoc($res)) {
                 $result = $result . JSON($row) . "#";
                 //以#字符作为json字符串数组的分隔符
             }
             echo $result;
             mysql_free_result($res);
             mysql_close($conn);
         }
     } else {
         if ($code == "delete") {
             if ($_POST['search_text']) {
                 $search_text = $_POST['search_text'];
                 //删除该关键字的数据库记录
                 $sql = "delete from baidu where search_text = '{$search_text}'";
                 $res = mysql_query($sql, $conn);
                 if ($res) {
                     $result = "succeed";
示例#11
0
function verificarLogin()
{
    $datos = $_POST;
    try {
        $user = Usuario_NetoSolis::find(array('conditions' => array('email = ? AND password =  ?', $datos['email'], $datos['password'])));
        if ($user) {
            if ($user->status == 1) {
                JSON(true, 'Bienvenido tus datos son correctos.');
            } else {
                JSON(false, 'Tu cuenta no esta activada. Te enviamos un email con un link para activar tu cuenta.');
            }
        } else {
            JSON(false, 'Los datos son incorrectos. Favor de verificarlos.');
        }
    } catch (Exception $e) {
        JSON(false, 'Los datos son incorrectos. Favor de verificarlos.' . $e);
    }
}
<?php

require "link.php";
require "jsonHelper.php";
$array;
$i = 0;
$sql = "SELECT * FROM weekassignment WHERE id >0";
$result = $mysql->query($sql);
while ($final = $result->fetch_array()) {
    $array[$i]['id'] = $final['id'];
    $array[$i]['startdate'] = $final['startdate'];
    $array[$i]['enddate'] = $final['enddate'];
    $array[$i]['assignment'] = $final['assignment'];
    $array[$i]['process'] = $final['process'];
    $i++;
}
echo JSON($array);
 function _send_by_openid($openids)
 {
     $openids = wp_explode($openids);
     if (empty($openids)) {
         $this->error('要发送的OpenID值不能为空');
     }
     if (count($openids) < 2) {
         $this->error('OpenID至少需要2个或者2个以上');
     }
     $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=' . get_access_token();
     $info = $this->_sucai_media_info();
     $param['touser'] = $openids;
     if ($info['msgtype'] == 'text') {
         $param['text']['content'] = $info['media_id'];
         $param['msgtype'] = $info['msgtype'];
     } else {
         if ($info['msgtype'] == 'mpnews') {
             $param['mpnews']['media_id'] = $info['media_id'];
             $param['msgtype'] = $info['msgtype'];
         } else {
             if ($info['msgtype'] == 'voice') {
                 $param['voice']['media_id'] = $info['media_id'];
                 $param['msgtype'] = $info['msgtype'];
             } else {
                 if ($info['msgtype'] == 'mpvideo') {
                     $param['video']['media_id'] = $info['media_id'];
                     $param['msgtype'] = $info['video'];
                 }
             }
         }
     }
     $param = JSON($param);
     $res = post_data($url, $param);
     if ($res['errcode'] != 0) {
         $this->error(error_msg($res));
     } else {
         return $res['msg_id'];
     }
 }
示例#14
0
文件: category.php 项目: ruoL/fun-x
 public function delete_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $cid = (int) $this->input->post('cid');
     $new = (int) $this->input->post('newcategory');
     $category = $this->category_model->get_info(array('cid' => $cid));
     if (!$category or $new === 0) {
         JSON('error', '对不起,没有找到您要删除的分类!');
     }
     $this->db->delete('category', array('cid' => $cid));
     if ($this->db->affected_rows()) {
         // 转移该分类下的所有文章
         $this->db->update('article', array('cid' => $new), array('cid' => $cid));
         JSON('success', '恭喜,分类 ' . $category->name . ' 删除成功!');
     } else {
         JSON('error', '对不起,删除分类失败,请重试!');
     }
 }
示例#15
0
     case 'getpersons':
         if ($type == 0) {
             $persons = PersonManager::searchPersons($query, 1, -1);
         } else {
             $persons = PersonManager::searchPersonsBySunccoNo($query, 1, -1);
         }
         if ($persons === false) {
             return;
         }
         $personNames = array();
         $personCount = count($persons['persons']);
         for ($i = 0; $i < $personCount; $i++) {
             $person = $persons['persons'][$i];
             $personNames[$i] = $person->name . "_" . $person->personId . "_" . $person->sunccoNo;
         }
         echo JSON($personNames);
         return;
         break;
     case 'getBorrowerInfo':
         if (strlen($query) != 0) {
             $person = BookManager::getPerson($query);
             if ($person === false) {
                 echo "";
             } else {
                 echo $person->name . "_" . $person->personId . "_" . $person->sunccoNo;
             }
         }
         break;
     default:
         break;
 }
 function index()
 {
     $gameId = I('games_id', 0, 'intval');
     if (empty($gameId)) {
         $this->error('还没有配置活动');
     }
     $info = D('Addons://Draw/Games')->getInfo($gameId);
     if ($info['status'] == 0) {
         $info['status'] = '已关闭';
     } else {
         if (NOW_TIME >= $info['end_time']) {
             $info['status'] = '已结束';
         } else {
             if (NOW_TIME < $info['start_time']) {
                 $info['status'] = '未开始';
             } else {
                 $info['status'] = '进行中';
             }
         }
     }
     //分享数据
     $shareData['title'] = $info['title'];
     $shareData['desc'] = $info['title'];
     switch ($info['game_type']) {
         case 1:
             $shareData['imgUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/guaguale_cover.jpg';
             break;
         case 2:
             $shareData['imgUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/dzp_cover.jpg';
             break;
         case 3:
             $shareData['imgUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/zjd_cover.jpg';
             break;
         case 4:
             $shareData['imgUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/nine_cover.jpg';
             break;
     }
     $shareData['link'] = U('index', array('games_id' => $info['id']));
     $this->assign('shareData', $shareData);
     //奖品列表
     $awardLists = D('Addons://Draw/LotteryGamesAwardLink')->getGamesAwardlists($gameId);
     foreach ($awardLists as $v) {
         $jp['title'] = $v['grade'];
         $jp['pic'] = $v['img'];
         $jp['picUrl'] = $v['img_url'];
         $jp['award_id'] = $v['award_id'];
         $jplist[] = $jp;
     }
     //所有获奖列表
     $luckLists = D('Addons://Draw/LuckyFollow')->getGamesLuckyLists($gameId);
     //个人获奖列表
     $uid = $this->mid;
     $userLucky = D('Addons://Draw/LuckyFollow')->getGamesLuckyLists($gameId, $uid, 0);
     $hasPrize = 0;
     if (!empty($userLucky)) {
         $hasPrize = 1;
     }
     // 	    dump($awardLists);
     $tmp = '';
     switch ($info['game_type']) {
         case 1:
             //刮刮乐
             $tmp = 'guaguale';
             break;
         case 2:
             $jp['title'] = '加油';
             $jp['picUrl'] = ADDON_PUBLIC_PATH . '/ungeted_pic.png';
             $jp['award_id'] = 0;
             $jplist[] = $jp;
             //大转盘
             $tmp = 'dzp';
             break;
         case 3:
             //砸金蛋
             $tmp = 'zajindan';
             break;
         case 4:
             //九宫格
             $count = count($jplist);
             $num = 10 - $count;
             if ($num > 0) {
                 for ($i = 0; $i < $num; $i++) {
                     $jp['title'] = '加油';
                     $jp['picUrl'] = ADDON_PUBLIC_PATH . '/ungeted_pic.png';
                     $jp['award_id'] = 0;
                     $jplist[] = $jp;
                 }
             }
             shuffle($jplist);
             $tmp = 'ninegrid';
             break;
     }
     $jplist = JSON($jplist);
     $joinUrl = addons_url('Draw://Wap/draw_lottery', array('games_id' => $gameId));
     $this->assign('joinurl', $joinUrl);
     $this->assign('has_prize', $hasPrize);
     $this->assign('jplist', $jplist);
     $this->assign('luck_lists', $luckLists);
     $this->assign('award_lists', $awardLists);
     $this->assign('info', $info);
     $this->display($tmp);
 }
示例#17
0
</table>
<div id="showMessage" style="border:1px #666 solid;">
</div>
<script type="text/javascript">
window.onload = function(){
    var tag = document.getElementById("showMessage");
    tag.style.display = "none";
}
function tip(event) {
    var aUserName = new Array();
    var aTempName, aUserName, tag, sVal, sHtml, mesTag, selectedTag, didTag, widths;
    var postion = new Array();
                var sId = 0;//用于给每个名字加一个id的顺序
                var whichType;//用户输入的类型,是数字呢还是中文。
                aUserName = <?php 
echo JSON($json);
?>
;
                //aUserName = eval('(' + aTempName + ')');
                tag = document.getElementById("neirong");
                didTag = document.getElementById("did");
                //输入框坐标获取
                postion = getElementPos(tag);

                //显示div坐标调整
                mesTag = document.getElementById("showMessage");
                mesTag.style.position = "absolute";
                mesTag.style.left = postion[0]
                mesTag.style.top = postion[1];
                widths = tag.style.width + "px";
                mesTag.width = widths;
示例#18
0
<?php

session_start();
/**
 * Created by PhpStorm.
 * User: Lijin
 * Date: 2015/8/5
 * Time: 21:45
 * 如果用户没有关联任何项目,返回false
 */
require "sqlHelper.php";
require "jsonHelper.php";
if (isset($_SESSION['username'])) {
    $userID = $_SESSION['userID'];
    $sql = "SELECT project.projectID,project.projectName,project.projectBanner FROM user_project,project WHERE user_project.userID='{$userID}' AND user_project.projectID=project.projectID";
    $sqlResult = $mysql->query($sql);
    $result;
    if (!empty($sqlResult)) {
        foreach ($sqlResult as $row => $rowVal) {
            $result[$row] = $rowVal;
        }
        $json = JSON($result);
        echo $json;
    } else {
        echo "no-project";
    }
} else {
    echo 'session-out-of-time';
}
示例#19
0
文件: upload.php 项目: ruoL/fun-x
 public function exampleimage()
 {
     if (isset($_FILES['attach']) and is_uploaded_file($_FILES['attach']['tmp_name']) and $_FILES['attach']['error'] === 0) {
         $imgsize = $_FILES['attach']['size'];
         $maxsize = config_item('site_image_maxsize');
         if ($imgsize > $maxsize * 1024 * 1024) {
             JSON('error', '上传图片大小超过 ' . $maxsize . 'MB');
         }
         $imginfo = pathinfo($_FILES['attach']['name']);
         $imgexte = config_item('site_image_ext');
         $imgexte = explode('|', $imgexte);
         if (!in_array(strtolower($imginfo['extension']), $imgexte)) {
             JSON('error', '上传图片只允许 ' . implode(', ', $imgexte) . ' 格式');
         }
         $savepath = $this->_attach_dir . 'example' . DIRECTORY_SEPARATOR;
         if (@is_dir($savepath) === false) {
             create_dir($savepath);
         }
         $filename = date('dis') . rand(1000, 9999) . '.' . strtolower($imginfo['extension']);
         $fullname = $savepath . $filename;
         move_upload_file($_FILES['attach']['tmp_name'], $fullname);
         if (@is_file($fullname) === false) {
             JSON('error', '上传失败,找不到此文件');
         }
         list($width, $height, $type, $attr) = getimagesize($fullname);
         $fullpath = $fullname;
         $fullname = base_url($fullname);
         $data = array('filename' => $filename, 'fullpath' => $fullpath, 'filepath' => $fullname, 'width' => $width, 'height' => $height);
         JSON('success', '文件上传成功', $data);
     } else {
         JSON('error', '上传出现错误');
     }
 }
示例#20
0
文件: link.php 项目: ruoL/fun-x
 public function delete_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $lid = (int) $this->input->get('lid');
     if ($this->link_model->delete_by_lid($lid)) {
         JSON('success', '该链接已成功删除');
     } else {
         JSON('error', '删除失败,请重试');
     }
 }
示例#21
0
 /**
  * Response
  *
  * @param string $format : json, xml, jsonp, string
  * @param array $data:
  * @param boolean $die: die if set to true, default is true
  */
 public static function response($data, $format = 'json', $die = TRUE)
 {
     switch ($format) {
         default:
         case 'json':
             $file = FUNC_PATH . '/FString.php';
             Yaf_Loader::import($file);
             if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest") {
                 $data = JSON($data);
             } else {
                 if (isset($_REQUEST['ajax'])) {
                     $data = JSON($data);
                 } else {
                     //pr($data); die; // URL 测试打印数组出来
                     echo json_encode($data);
                     die;
                 }
             }
             break;
         case 'jsonp':
             $data = $_GET['jsoncallback'] . '(' . json_encode($data) . ')';
             break;
         case 'string':
             break;
     }
     echo $data;
     if ($die) {
         die;
     }
 }
示例#22
0
 public function getTitleJson()
 {
     $poetry_db = M('Poetry');
     $poetrylist = $poetry_db->field('poetryid,title')->order("convert(title using gb2312) ASC")->select();
     foreach ($poetrylist as $key => $val) {
         $data[$key]['id'] = $val['poetryid'];
         $data[$key]['text'] = $val['title'];
     }
     header('Content-Type:text/html;Charset=UTF-8');
     echo JSON($data);
 }
 function tongbu_follow()
 {
     $map['manager_id'] = $this->mid;
     $map['token'] = get_token();
     $list = M('auth_group')->where($map)->select();
     foreach ($list as $v) {
         $arr[$v['id']] = $v['wechat_group_id'];
     }
     $id = I('id', 0, 'intval');
     $map['id'] = array('gt', $id);
     $map['has_subscribe'] = 1;
     $map['token'] = get_token();
     $follow_list = M('public_follow')->where($map)->order('id asc')->limit(5)->select();
     if (!$follow_list) {
         echo 'update over!';
         exit;
     }
     $access_token = get_access_token();
     $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . $access_token;
     foreach ($follow_list as $follow) {
         $param['openid'] = $follow['openid'];
         $param['to_groupid'] = intval($arr[$follow['group']]);
         $param = JSON($param);
         $res = post_data($url, $param);
         $has_subscribe = $res['errcode'] == 43004 ? 0 : 1;
         M('public_follow')->where('id=' . $follow['id'])->setField('has_subscribe', $has_subscribe);
     }
     $param2['id'] = $follow['id'];
     $url = U('tongbu_follow', $param2);
     $url = addons_url('tongbu_follow');
     $this->success('同步用户数据中,请勿关闭', $url);
     // echo 'update follow_id: ' . $follow ['id'] . ', please wait!';
     // echo '<script>window.location.href="' . $url . '";</script>';
 }
示例#24
0
文件: page.php 项目: ruoL/fun-x
 public function delete_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $pid = (int) $this->input->get('pid');
     $page = $this->page_model->get_info(array('pid' => $pid));
     if (!$page) {
         JSON('error', '找不到您要删除的页面!');
     }
     $state = $this->page_model->delete_by_pid($pid);
     if ($state) {
         // 删除页面的图片
         $this->load->library('action');
         $this->action->unlink_string_attach($page->content);
         JSON('success', '恭喜,页面删除成功!');
     } else {
         JSON('error', '对不起,页面文章失败,请重试!');
     }
 }
示例#25
0
文件: product.php 项目: ruoL/fun-x
 public function one()
 {
     $id = $this->input->post('id');
     $exam = $this->example_model->get_info(['id' => $id]);
     JSON('success', '', $exam);
 }
示例#26
0
文件: huangye.php 项目: ruoL/fun-x
 public function return_to_normal()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $aid = (int) $this->input->get('aid');
     $this->db->update('huangye', array('state' => 1), array('aid' => $aid));
     if ($this->db->affected_rows()) {
         JSON('success', '文章已恢复正常!');
     } else {
         JSON('error', '操作失败,请重试!');
     }
 }
示例#27
0
function ajax_select($parentid, $keyid)
{
    $keyid = intval($keyid);
    $datas = getcache($keyid, 'linkage');
    $infos = $datas['data'];
    $json_str = "[";
    $json = array();
    foreach ($infos as $k => $v) {
        if ($v['parentid'] == $parentid) {
            $r = array('region_id' => $v['linkageid'], 'region_name' => $v['name']);
            $json[] = JSON($r);
        }
    }
    $json_str .= implode(',', $json);
    $json_str .= "]";
    echo $json_str;
}
 function _deal_content($data)
 {
     $dd['Content'] = $data['Content'];
     switch ($data['MsgType']) {
         case 'image':
             $msgtype = 'image';
             if (empty($data['Content'])) {
                 $coverid = down_media($data['MediaId']);
                 $data['PicUrl'] = get_cover_url($coverid);
                 $dd['url'] = $data['PicUrl'];
                 //保存到Content里
                 $addContent['msgtype'] = 'image';
                 $addContent['image']['media_id'] = $data['MediaId'];
                 $addContent['picurl'] = $dd['url'];
                 $save['Content'] = JSON($addContent);
                 M('weixin_message')->where(array('id' => $data['id']))->save($save);
             } else {
                 $con = json_decode($data['Content'], true);
                 $dd['url'] = $con['picurl'];
             }
             // 				$data ['Content'] = '<a target="_blank" href="' . $data ['PicUrl'] . '"><img width="100" height="100" src="' . $data ['PicUrl'] . '"></a>';
             break;
         case 'voice':
             $msgtype = 'voice';
             $fileid = down_file_media($data['MediaId'], 'voice');
             if (empty($data['Content'])) {
                 // $fileid=down_file_media($data['MediaId'],'voice');
                 if ($fileid) {
                     $file_voice = M('file')->find($fileid);
                     $dd['id'] = $file_voice['id'];
                     //保存到Content里
                     $addContent['msgtype'] = 'voice';
                     $addContent['voice']['media_id'] = $data['MediaId'];
                     $addContent['file_id'] = $dd['id'];
                     $save['Content'] = JSON($addContent);
                     M('weixin_message')->where(array('id' => $data['id']))->save($save);
                 }
             } else {
                 $con = json_decode($data['Content'], true);
                 $dd['id'] = $con['file_id'];
             }
             $data['Content'] = 'voice';
             // TODO
             break;
         case 'video':
             $msgtype = 'video';
             if (empty($data['Content'])) {
                 $fileid = down_file_media($data['MediaId'], 'video');
                 if ($fileid) {
                     $file_video = M('file')->find($fileid);
                     $dd['id'] = $file_video['id'];
                     //保存到Content里
                     $addContent['msgtype'] = 'video';
                     $addContent['video']['media_id'] = $data['MediaId'];
                     $addContent['file_id'] = $dd['id'];
                     $save['Content'] = JSON($addContent);
                     M('weixin_message')->where(array('id' => $data['id']))->save($save);
                 }
             } else {
                 $con = json_decode($data['Content'], true);
                 $dd['id'] = $con['file_id'];
             }
             $data['Content'] = 'video';
             // TODO
             break;
         case 'shortvideo':
             $msgtype = 'shortvideo';
             $data['Content'] = 'shortvideo';
             // TODO
             break;
         case 'location':
             $msgtype = 'location';
             $data['Content'] = 'location';
             // TODO
             break;
         case 'link':
             $msgtype = 'link';
             $dd['url'] = $data['Url'];
             $dd['title'] = $data['Title'];
             $dd['description'] = $data['Description'];
             // 				$data ['Content'] = '<a herf="' . $data ['Url'] . '"<h3>' . $data ['Title'] . '</h3><br>' . $data ['Description'] . '</a>';
             break;
         default:
             $content = json_decode($data['Content'], true);
             $msgtype = $content['msgtype'];
             // 			    dump($data);
             if (!empty($content)) {
                 if (isset($content['image'])) {
                     $imagemap['media_id'] = $content['image']['media_id'];
                     $imagemap['token'] = get_token();
                     $image = M('material_image')->where($imagemap)->find();
                     if ($image['cover_url']) {
                         $dd['url'] = $image['cover_url'];
                     } else {
                         $coverid = down_media($content['image']['media_id']);
                         if (!$coverid) {
                             $coverid = do_down_image($content['image']['media_id']);
                         }
                         $data['PicUrl'] = get_cover_url($coverid);
                         $dd['url'] = $data['PicUrl'];
                     }
                     // 				         $data ['Content'] = '<a target="_blank" href="' . $data ['PicUrl'] . '"><img width="100" height="100" src="' . $data ['PicUrl'] . '"></a>';
                 } else {
                     if (isset($content['voice'])) {
                         $voicemap['media_id'] = $content['voice']['media_id'];
                         $voicemap['token'] = get_token();
                         $voicemap['type'] = 1;
                         $file_voice = M('material_file')->where($voicemap)->find();
                         $dd['id'] = $file_voice['id'];
                         $dd['title'] = $file_voice['title'];
                         $dd['file_id'] = $file_voice['file_id'];
                         // 			            $img_url=SITE_URL.'/Public/Home/images/icon_sound.png';
                         // 			            $str='<div class="sound_item" onClick="playSound("sound_'.$file_voice['id'].'",this);">
                         //                             <img class="icon_sound" src="'.$img_url.'"/>
                         //                             <p class="audio_name">'.$file_voice['title'].'<span class="fr colorless"></span></p>
                         //                             <p class="ctime colorless"></p>
                         //                             <audio id="sound_'.$file_voice['id'].'" src="'.get_file_url($file_voice['file_id']).'"></audio>
                         //                         </div>';
                         // 			          $data['Content']=$str;
                     } else {
                         if (isset($content['news'])) {
                             // 			            dump($content['news']);
                             $news = $content['news']['articles'];
                             $index = count($news) - 1;
                             $fist = $news[$index];
                             unset($news[$index]);
                             $other = $news;
                             $dd['first'] = $fist;
                             $dd['child'] = $other;
                             // 			            dump($dd);
                             // 			            $dd=$content['news'];
                         } else {
                             if (isset($content['video'])) {
                                 $videomap['media_id'] = $content['video']['media_id'];
                                 $videomap['token'] = get_token();
                                 $videomap['type'] = 2;
                                 $file_video = M('material_file')->where($videomap)->find();
                                 $dd['id'] = $file_video['id'];
                                 $dd['title'] = $file_video['title'];
                                 $dd['file_id'] = $file_video['file_id'];
                                 $dd['introduction'] = $file_video['introduction'];
                                 // 			            $str='<div class="video_item">
                                 //                         	<p class="title">'.$file_video['title'].'</p>
                                 //                             <p class="ctime colorless">'.time_format($file_video['cTime']).'</p>
                                 //                             <div class="video_area">
                                 //                             	<video src="'.get_file_url($file_video['file_id']).'" controls="controls">您的浏览器不支持 video 标签。</video>
                                 //                             </div>
                                 //                              <p>'.$file_video['introduction'].'</p>
                                 //                         </div>';
                             }
                         }
                     }
                 }
             }
             break;
     }
     $dd['msg_type'] = $msgtype;
     if (empty($dd['msg_type'])) {
         $dd['msg_type'] = 'text';
         vendor("emoji");
         $tmpStr = json_encode($data['Content']);
         $tmpStr = preg_replace("#(\\\\ue[0-9a-f]{3})#ie", "addslashes('\\1')", $tmpStr);
         $text = json_decode($tmpStr);
         // 		    dump($text);
         // 		    $te=$this->unicode_decode('\ue11a');
         // 		    dump($te);
         // 		    dump($text);
         $src = array(array(0x2600), array(0x1f494), array(0x1f197), array(0x32, 0x20e3));
         foreach ($src as $unified) {
             $bytes = '';
             $hex = array();
             foreach ($unified as $cp) {
                 $bytes .= $this->utf8_bytes('\\ue40e');
                 // 		            dump($bytes);
                 // 		            $hex[] = sprintf('U+%04X', $cp);
             }
             // 		        dump($bytes);
             // 		        $str = "Hello $bytes World";
             // 		        echo emoji_unified_to_html($str);
         }
         // 		    dump($text);
         // 		    $clean_text = emoji_docomo_to_unified($text);
         // 		    dump('--------');
         // 		    dump($clean_text);
         // 		    $html = emoji_unified_to_html($data['Content']);
         // 		    dump('123');
         // 		    dump($html);
         // 		    $dd['Content']=$html;
     }
     $data['Content'] = $dd;
     return $data['Content'];
 }
示例#29
0
<?php

$json = array();
$json['message'] = $message;
$json['amazing_level'] = $json['message'] === null ? $productModel->product_mark : null;
$json['commentList'] = null;
if ($message === null) {
    foreach ($results as $key => $result) {
        $json['commentList'][$key]['id'] = $result['id'];
        $json['commentList'][$key]['text'] = $result['text'];
        $json['commentList'][$key]['create_time'] = $result['create_time'];
        $json['commentList'][$key]['amazing_level'] = $result['amazing_level'];
    }
}
$json = JSON($json);
responseJSON($json);
示例#30
0
文件: user.php 项目: ruoL/fun-x
 public function delete_action()
 {
     if (!$this->input->is_ajax_request()) {
         show_404();
     }
     $uid = (int) $this->input->post('uid');
     $new = (int) $this->input->post('newuid');
     $user = $this->user_model->get_info(array('uid' => $uid));
     if (!$user or $new === 0) {
         JSON('error', '对不起,没有找到您要删除的用户!');
     }
     $this->db->delete('user', array('uid' => $uid));
     if ($this->db->affected_rows()) {
         // 转交该用户的文章和页面
         $this->db->update('article', array('uid' => $new), array('uid' => $uid));
         $this->db->update('page', array('uid' => $new), array('uid' => $uid));
         JSON('success', '恭喜,用户 ' . $user->username . ' 删除成功!');
     } else {
         JSON('error', '对不起,删除用户失败,请重试!');
     }
 }