作者:ruo
项目:fun-
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());
}
作者:yxz102
项目:weiphp3.
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;
}
作者:JasonWik
项目:doc
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));
}
作者:yxz102
项目:weiphp3.
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);
}
作者:huangxule
项目:ap
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);
}
作者:cyndiWad
项目:xintu
/**
* 统一数据返回
* @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));
}
作者:kevinstudi
项目:zaodianl
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);
}
作者:ruo
项目:fun-
public function stats_action()
{
if (!$this->input->is_ajax_request()) {
show_404();
}
$this->_clear();
$stats = $this->_stats();
JSON('success', '共计 ' . $stats['rows'] . ' 个标签,当前操作已成功更新 ' . $stats['affe'] . ' 条记录!');
}
作者:PunkAvai
项目:ThinkWecha
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;
}
作者:zhangwenhua02
项目:baid
$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";
作者:J1Dura
项目:ph-we
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);
}
}
作者:HuangFuGu
项目:HuangFuGui.github.i
<?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);
作者:chenpus
项目:haozhixian_ba
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'];
}
}
作者:ruo
项目:fun-
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', '对不起,删除分类失败,请重试!');
}
}
作者:doumaoma
项目:bookmanage
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;
}
作者:chenpus
项目:haozhixian_ba
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);
//.........这里部分代码省略.........
作者:JennysGi
项目:PH
</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;
作者:qinzuoyu
项目:phptrai
<?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';
}
作者:ruo
项目:fun-
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', '上传出现错误');
}
}
作者:ruo
项目:fun-
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', '删除失败,请重试');
}
}