Beispiel #1
0
 public function add()
 {
     if (!$GLOBALS['islogin']) {
         exit;
     }
     if (!checkpost()) {
         exit;
     }
     $diary = M('diary');
     $uid = $GLOBALS['i']['uid'];
     $data['uid'] = $GLOBALS['i']['uid'];
     $content = postvar('content');
     $data['original_cont'] = exp_content($content);
     $content = msubstr($content, 0, 100, 'utf-8', false);
     $data['content'] = exp_content($content);
     $data['mood'] = postvar('mood');
     $data['read_type'] = postvar('read_type', 1);
     $data['add_time'] = time();
     $data['set_time'] = strtotime(postvar('set_time'));
     $did = $diary->add($data);
     //echo $diary->getLastSql();
     $member_field = M('member_field');
     $data1['diary_num'] = array('exp', 'diary_num+1');
     $member_field->where("uid={$uid}")->save($data1);
     $body = array('did' => $did, 'content' => $data['content']);
     //feed_publish(1, $body, $did);
     $feedModel = D('Feed');
     $feedModel->feed_publish(1, $body, $did);
     echo '{"errno":200}';
 }
Beispiel #2
0
 public function answer_task()
 {
     if (!$GLOBALS['islogin']) {
         exit('error');
     }
     if (!checkpost()) {
         exit;
     }
     $uid = postvar('receiver_uid', 1);
     $tid = postvar('related', 1);
     $task = M('task');
     $t = $task->where("tid={$tid}")->find();
     if (!$t) {
         exit('error');
     }
     $task_answer = M('task_answer');
     $rs = $task_answer->where("tid={$tid} AND uid={$GLOBALS['i']['uid']}")->find();
     if ($rs) {
         exit('{"stat":5,"error":"\\u60a8\\u5df2\\u7ecf\\u5e2e\\u8fc7\\u4e86"}');
     }
     $data['tid'] = $t['tid'];
     $data['uid'] = $GLOBALS['i']['uid'];
     $data['username'] = $GLOBALS['i']['username'];
     $data['default_pic'] = $GLOBALS['i']['default_pic'];
     $data['content'] = exp_content(postvar('content'));
     $data['is_anonymity'] = postvar('is_anonymity', 1);
     $data['add_time'] = time();
     $rs = $task_answer->add($data);
     if ($rs) {
         $edit['answer_count'] = array('exp', 'answer_count+1');
         $task->where("tid={$t['tid']}")->save($edit);
         $msgModel = D('Msg');
         $ta = $GLOBALS['i']['sex'] == 1 ? '她' : '他';
         $ta2 = $GLOBALS['i']['sex'] == 1 ? '他' : '她';
         $content = exp_content(postvar('content'));
         $str = "<div class=\"textbg f_6\"><b>你参与了{$ta}发布的任务:{$t['title']}</b></div>";
         $str2 = "<div class=\"textbg f_6\"><b>{$ta2}参与了你发布的任务:{$t['title']}</b></div>";
         $str3 = "<div class=\"textbg f_6\"><b>任务:{$t['title']}</b></div>";
         $main = "<p class=\"word_break\"><span class=\"word_break\">回应:{$data['content']}</span></p>";
         $str = $str . $main;
         $str2 = $str2 . $main;
         $str3 = $str3 . $main;
         $msgModel->chat($GLOBALS['i']['uid'], $uid, $str, 0, $str2, $str3);
     }
     //echo $task->getLastSql();
     exit('{"stat":0}');
 }
Beispiel #3
0
 public function send_16($uid, $id)
 {
     $diary = M('diary');
     $rs = $diary->where("did={$id} AND uid={$uid}")->find();
     if (!$rs) {
         exit;
     }
     $ta = $GLOBALS['i']['sex'] == 1 ? '她' : '他';
     $ta2 = $GLOBALS['i']['sex'] == 1 ? '他' : '她';
     $content = exp_content(postvar('content'));
     $str = "<div class=\"textbg f_6\"><b>你对{$ta}“写两句”的评论:{$content}</b></div>";
     $str2 = "<div class=\"textbg f_6\"><b>{$ta2}对你“写两句”的评论:{$content}</b></div>";
     $str3 = "<div class=\"textbg f_6\"><b>{$GLOBALS['i']['username']}的评论:{$content}</b></div>";
     $bak = "<p><span class=\"word_break f_green\">评论:{$content}</span></p>";
     $main = "<p class=\"word_break\"><span class=\"word_break\">“写两句”:{$rs['content']}</span></p>";
     $str = $main . $str;
     $str2 = $main . $str2;
     $str3 = $main . $str3;
     $this->chat($GLOBALS['i']['uid'], $uid, $str, 0, $str2, $str3);
     $this->comment($uid, 16, $content);
 }
Beispiel #4
0
 public function api()
 {
     if (!checkpost()) {
         exit;
     }
     $k = getvar('k');
     $arr = explode('|', authcode($k));
     $count = sizeof($arr);
     if ($count != 3) {
         exit(print_r($arr));
     }
     $i = $arr[0];
     $u = $arr[1];
     $roomid = $arr[2];
     $id = getvar('id');
     if ($roomid != decrypt($id)) {
         exit;
     }
     $msg = M('msg');
     $result = $msg->where("uid={$i} AND receiver_uid={$u}")->getField('roomid');
     if (!$result || $result != $roomid) {
         exit;
     }
     $content = exp_content(postvar('postcontent'));
     $msgModel = D('Msg');
     if (!$msgModel->check_link($u, $i)) {
         $msgModel->exitError();
     }
     $msgModel->chat($i, $u, $content, 0, '', '', 1);
     //聊天过程中新消息自动清零
     $rs = $msg->where("uid={$i} AND receiver_uid={$u}")->find();
     $member_field = M('member_field');
     $edit['new_msg'] = array('exp', "new_msg-{$rs['new']}");
     $member_field->where("uid={$i}")->save($edit);
     $edit2['new'] = 0;
     $msg->where("id={$rs['id']}")->save($edit2);
     //聊天过程中新消息自动清零
 }
Beispiel #5
0
 public function answer()
 {
     if (!checkpost()) {
         exit;
     }
     $uid = postvar('q_uid', 1);
     $member = M("member");
     $u = $member->getByUid($uid);
     $qid = postvar('q_id', 1);
     $question = M("question");
     $old = $question->where("qh_question.id={$qid}")->find();
     //dump($question->getLastSql());
     if (!$u || !$old) {
         exit('error');
     }
     $vote = intval($_POST['vote']);
     $vote = $vote == 1 ? 1 : 2;
     $answer = M('answer');
     $data['uid'] = $GLOBALS['i']['uid'];
     $data['username'] = $GLOBALS['i']['username'];
     $data['default_pic'] = $GLOBALS['i']['default_pic'];
     $data['q_id'] = $qid;
     $data['answer_cont'] = exp_content(postvar('answer_cont'));
     $data['vote'] = $vote;
     $data['is_anonymity'] = postvar('is_anonymity', 1);
     $data['is_show'] = postvar('is_show', 1);
     $data['answer_time'] = time();
     $a_id = $answer->add($data);
     $member_field = M('member_field');
     $data1['new_answer'] = array('exp', 'new_answer+1');
     $member_field->where("uid={$uid}")->save($data1);
     if ($data['is_anonymity'] != 1 && $old['is_anonymity'] != 1) {
         $data2['answer_num'] = array('exp', 'answer_num+1');
         $uid1 = $GLOBALS['i']['uid'];
         $member_field->where("uid={$uid1}")->save($data2);
     }
     if (!$a_id) {
         exit('unkonw');
     }
     $body = array('q_id' => $qid, 'q_uid' => $old['uid'], 'question' => $old['question'], 'a_id' => $a_id, 'a_uid' => $GLOBALS['i']['uid'], 'sex' => $GLOBALS['i']['sex'], 'a_username' => $GLOBALS['i']['username'], 'answer' => $data['answer_cont'], 'photo_url' => $old['photo_url']);
     $body_arr[$a_id] = $body;
     //feed_publish(4, $body_arr);
     $feedModel = D('Feed');
     $feedModel->feed_publish(4, $body_arr);
     $edit['answer_count'] = array('exp', 'answer_count+1');
     $edit['new_answer'] = array('exp', 'new_answer+1');
     if ($vote == 1) {
         $edit['agree_count'] = array('exp', 'agree_count+1');
     } else {
         $edit['against_count'] = array('exp', 'against_count+1');
     }
     $edit['answer_news'] = array('exp', 'answer_news+1');
     $edit['answer_count'] = array('exp', 'answer_count+1');
     if (!empty($_POST['answer_cont'])) {
         $edit['answer_cont_num'] = array('exp', 'answer_cont_num+1');
     }
     //问问随机展示问题处理start
     if ($old['answer_count'] == 19) {
         $edit['timeline'] = time();
     }
     $GLOBALS['i']['question_t'] = $old['timeline'];
     //问问随机展示问题处理end
     $question->where("id={$qid}")->save($edit);
     $questionModel = D("Question");
     $new = $questionModel->getOne(1);
     //问问随机展示问题处理start
     $questionModel->answerTrigger($old);
     //问问随机展示问题处理start
     $wh = getwh($new['photo_url'], 320, 320);
     $wh = explode(',', $wh);
     $new['photo_width'] = $wh[0];
     $new['photo_height'] = $wh[1];
     $new['photo_url'] = $GLOBALS['s']['urlupload'] . $new['photo_url'] . '_480x480.jpg';
     $array = array("code" => 1, "msg" => "回答成功", "answer" => array("uid" => $GLOBALS['i']['uid'], "question_id" => $qid, "question_uid" => $u['uid'], "answer_cont" => $_POST['answer_cont'], "answer_time" => $data['answer_time'], "vote" => $vote, "star_count" => 0, "status" => 0, "is_anonymity" => $old['is_anonymity'], "is_show" => 0), "m_anwer_num" => 41, "question" => $new, "q_code" => NULL, "prev_userinfo" => array("nickname" => $u['username'], "question_uid" => $u['uid'], "location_prov" => $u['hometown_prov'], "location_city" => "", "is_anonymity" => $old['is_anonymity'], "birth_y" => date("Y") - $u['birth_y'], "sex" => $u['sex'], "u_sex" => $u['sex'] == 1 ? '他' : '她', "face" => $GLOBALS['s']['urlupload'] . $u['default_pic'] . '_120x120.jpg', "question_type" => $old['type_name']));
     echo json_encode($array);
 }
Beispiel #6
0
$u = $arr[1];
$roomid = encrypt($arr[2]);
$roomdir = 'pub/cache/' . substr($roomid, 0, 2) . '/' . substr($roomid, 2, 2) . '/' . substr($roomid, 4);
if (isset($_POST['clean'])) {
    exit(0);
}
if (isset($_POST['getdata'])) {
    exit(0);
}
if (isset($_POST['content'])) {
    $content = $_POST['content'];
    $content = isset($_GET['skip']) ? $content : htmlspecialchars(trim($content));
    if (strlen($content) > 800) {
        exit;
    }
    $content = exp_content($content);
    $data = array('uid' => $i, 'content' => $content, 'add_time' => time());
    $file = $roomdir . '/' . $i . '.php';
    $tmp = microtime() . json_encode($data);
    if (!is_dir($roomdir)) {
        mkdirs($roomdir);
    }
    file_put_contents($file, $tmp);
    exit(0);
}
$file = $roomdir . '/' . $u . '.php';
$url = $file;
$k = urlencode($k);
$referer = preg_replace("/https?:\\/\\/([^\\:\\/]+).*/i", "\\1", $_SERVER['HTTP_REFERER']);
if (!$referer) {
    $referer = 'www.dxslaw.com';