public function __construct()
 {
     //        $_POST['phone']=15001204748;
     //        $_POST['sig']='729d93c9145133c1ec25d8fcf17bedae';
     if (empty($_POST['phone']) || empty($_POST['sig'])) {
         echo json_encode(array('ret' => '104', 'msg' => '身份验证失败'));
         exit;
     } else {
         $phone = $_POST['phone'];
         $sig = $_POST['sig'];
         $verify = login_verify($phone, $sig);
         if ($verify !== true) {
             echo json_encode(array('ret' => $verify, 'msg' => '身份验证失败'));
             exit;
         }
         $user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where mobile =" . $phone);
         if (!$user) {
             echo json_encode(array('ret' => '-1', 'msg' => '用户不存在'));
             exit;
         }
         $GLOBALS['user_info'] = $user;
     }
 }
<?php

// Manegerial dashboard
// Functions
require "../api/api.fnc.php";
require "../api/settings.php";
require "loginverification.fnc.php";
// Wrapper
$userData = login_verify($_COOKIE);
$db = configure_active_database();
$socket = ConnectToDatabase($db);
$event = $socket->real_escape_string(filter_var($_GET['event'], FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES));
$query = MakeDatabaseQuery("SELECT * FROM `registrations` WHERE `for`={$event};", $socket);
$inc = 0;
foreach ($query as $key) {
    $inc++;
}
if ($_GET[csv] == true) {
    header("Content-Type: text/plain");
    header("Content-Disposition: attachment;filename=registrations.csv");
    foreach ($query as $key) {
        if (!empty($key[dietary])) {
            echo "{$key['name']}, {$key['school']}, {$key['email']}, {$key['phone']}, {$key['dietary']},\n";
        } else {
            echo "{$key['name']}, {$key['school']}, {$key['email']}, {$key['phone']}, none,\n";
        }
    }
} else {
    require "../attendees/header.php";
    ?>
 /**
  * 添加淘信
  */
 public function app_add_taoxin()
 {
     if (empty($_POST['title'])) {
         echo json_encode(array('ret' => '102', 'msg' => '标题太短'));
     } elseif (empty($_POST['phone']) || empty($_POST['sig'])) {
         echo json_encode(array('ret' => '104', 'msg' => '身份验证失败'));
     } else {
         $phone = $_POST['phone'];
         $sig = $_POST['sig'];
         $verify = login_verify($phone, $sig);
         if ($verify !== true) {
             echo json_encode(array('ret' => $verify));
             exit;
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = addslashes(trim($v));
         }
         try {
             $taoxin = array();
             $taoxin['title'] = $_POST['title'];
             $taoxin['price'] = isset($_POST['price']) ? $_POST['price'] : "";
             $taoxin['address'] = isset($_POST['address']) ? $_POST['address'] : "";
             $taoxin['contact'] = isset($_POST['contact']) ? $_POST['contact'] : "";
             $taoxin['qq'] = $_POST['qq'];
             $taoxin['detail'] = $_POST['detail'];
             $taoxin['create_time'] = time();
             $taoxin['city_id'] = !empty($_POST['city_id']) ? $_POST['city_id'] : 1;
             $taoxin['area_id'] = !empty($_POST['area_id']) ? $_POST['area_id'] : 0;
             $taoxin['cate_id'] = empty($_POST['subcate_id']) ? isset($_POST['cate_id']) ? $_POST['cate_id'] : 1 : $_POST['subcate_id'];
             $uid = $GLOBALS['app_add_taoxin']['id'];
             $taoxin['uid'] = $GLOBALS['user_info']['id'];
             $taoxin['verify'] = 0;
             $taoxin['longitude'] = !empty($_POST['lng']) ? $_POST['lng'] : '119.025595';
             $taoxin['latitude'] = !empty($_POST['lat']) ? $_POST['lat'] : '33.596043';
             $taoxin['location'] = 'GeomFromText("POINT(' . $taoxin['longitude'] . ' ' . $taoxin['latitude'] . ')")';
             $uplod_file_ret = upload_taoxin_files();
             if (!empty($uplod_file_ret['file_link'])) {
                 $taoxin['goods_photos'] = json_encode($uplod_file_ret['file_link']);
             }
             if (!empty($_POST['id'])) {
                 // 如果是编辑
                 $id = $_POST['id'];
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "taoxin", $taoxin, "UPDATE", "id=" . $id);
                 echo json_encode(array('ret' => '0', 'taoxin_id' => $id));
             } else {
                 if ($GLOBALS['db']->autoExecute(DB_PREFIX . "taoxin", $taoxin, "INSERT")) {
                     $id = $GLOBALS['db']->insert_id();
                     echo json_encode(array('ret' => '0', 'taoxin_id' => $id));
                 } else {
                     throw new Exception('淘信添加失败');
                 }
             }
         } catch (Exception $e) {
             echo json_encode(array('ret' => '-1', 'msg' => $e->getMessage()));
         }
     }
 }