Пример #1
0
 protected function init()
 {
     session_start();
     if (empty($_SESSION['user_info']) || empty($_POST['content'])) {
         echo 'error';
         exit;
     } else {
         $content = $_POST['content'];
         $id = $_POST['id'];
         $name = $_SESSION['user_info']['nickname'];
         $header = $_SESSION['user_info']['header'];
         if (empty($header)) {
             $header = 'http://7xngw8.com1.z0.glb.clouddn.com/title.png';
             //默认头像
         }
         $local_db = new lhh_db();
         //检验是不是重复参与的,并计入参与人数
         $num = $local_db->count('dbd_comment', '*', array('AND' => array('u_name' => $name, 'dbd_id' => $id)));
         if (empty($num)) {
             $local_db->update('dbd_list', array('count[+]' => 1), array('id' => $id));
         }
         date_default_timezone_set('PRC');
         $re = $local_db->insert('dbd_comment', array('u_name' => $name, 'header' => $header, 'dbd_id' => $id, 'content' => $content, 'time' => time(), 'up' => 0));
         if ($re > 0) {
             echo 'ok';
         } else {
             echo 'fail';
         }
     }
 }
Пример #2
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/11/24
 * Time: 19:56
 */
require 'medoo.php';
$db = new lhh_db();
$id = $_POST['id'];
$re = $db->count('dbd_comment', '*', array('dbd_id' => $id));
echo $re;
Пример #3
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/11/24
 * Time: 20:47
 */
require 'medoo.php';
$id = $_POST['id'];
session_start();
if (empty($_SESSION['user_info']) || empty($_POST)) {
    echo 'error';
    exit;
}
$db = new lhh_db();
$num = $db->count('dbd_record', '*', array('AND' => array('comment_id' => $id, 'uid' => $_SESSION['user_info']['uid'])));
if (empty($num)) {
    $db->update('dbd_comment', array('up[+]' => 1), array('id' => $id));
    $db->insert('dbd_record', array('comment_id' => $id, 'uid' => $_SESSION['user_info']['uid']));
    echo 'ok';
} else {
    echo 'repeat';
}