public function run()
 {
     global $_FANWE;
     $root = array();
     $root['return'] = 1;
     $email = $_FANWE['requestData']['email'];
     $pwd = $_FANWE['requestData']['pwd'];
     $uid = intval(FDB::resultFirst("select uid from " . FDB::table("user") . " where user_name='" . $email . "' and password = '******'"));
     $latitude = floatval($_FANWE['requestData']['latitude']);
     //ypoint
     $longitude = floatval($_FANWE['requestData']['longitude']);
     //xpoint
     if ($uid > 0 && $latitude > 0 && $longitude > 0) {
         $user_x_y_point = array('uid' => $uid, 'xpoint' => $longitude, 'ypoint' => $latitude, 'locate_time' => fGmtTime());
         //$root['user_x_y_point'] = $user_x_y_point;
         $id = FDB::insert('user_x_y_point', $user_x_y_point, true);
         //FDB::lastSql();
         $sql = "update " . FDB::table("user") . " set xpoint = {$longitude}, ypoint = {$latitude}, locate_time = " . fGmtTime() . " where uid = {$uid}";
         //$root['sql'] = $sql;
         FDB::query($sql);
     }
     m_display($root);
 }
 public function dosend()
 {
     define("ACTION_NAME", "dosend");
     if (intval($GLOBALS['fanwe']->var['uid']) == 0) {
         fHeader("location: " . FU('user/login'));
     }
     global $_FANWE;
     $uid = intval($_REQUEST['uid']);
     $sql = "select u.uid,u.user_name from " . FDB::table("user") . " as u left join " . FDB::table("user_follow") . " as f on f.f_uid = u.uid where u.uid = " . $uid . " and f.uid = " . intval($GLOBALS['fanwe']->var['uid']);
     $user = FDB::fetchFirst($sql);
     if ($user) {
         $msg['title'] = addslashes(htmlspecialchars(trim($_POST['message_title'])));
         $msg['content'] = addslashes(htmlspecialchars(trim($_POST['message_content'])));
         $msg['author_id'] = intval($GLOBALS['fanwe']->var['uid']);
         $msg['create_time'] = fGmtTime();
         $msg['status'] = 1;
         if ($msg['title'] == '') {
             showError("标题不能为空");
         }
         if ($msg['content'] == '') {
             showError("内容不能为空");
         }
         $mid = FDB::insert("user_msg", $msg, true);
         if ($mid > 0) {
             $rel_data['mid'] = $mid;
             $rel_data['uid'] = $user['uid'];
             FDB::insert("user_msg_rel", $rel_data, true);
             showSuccess("成功发送", "成功发送");
         }
     } else {
         showError("只能给fans发私信", "只能给fans发私信");
     }
 }
Beispiel #3
0
    /**
    * 关注主题
    如果已经关注此主题,则删除关注,返回false
    如果没有关注此主题,则添加关注,返回true
    * @param int $tid 主题编号
    * @return bool
    */
    public function followTopic($tid)
    {
        global $_FANWE;
        if ($_FANWE['uid'] == 0) {
            return false;
        }
        if (TopicService::getIsFollowTid($tid)) {
            FDB::query('DELETE FROM ' . FDB::table('user_attention') . '
				WHERE type = \'bar\' AND uid = ' . $_FANWE['uid'] . ' AND rec_id = ' . $tid);
            TopicService::updateTopicFollowsCache($tid, $_FANWE['uid'], 'delete');
            return false;
        } else {
            $topic = TopicService::getTopicById($tid);
            if (empty($topic) || $_FANWE['uid'] == $topic['uid']) {
                return false;
            }
            $attention = array('uid' => $_FANWE['uid'], 'rec_id' => $tid, 'share_id' => $topic['share_id'], 'type' => 'bar', 'create_time' => fGmtTime());
            FDB::insert('user_attention', $attention);
            $share['share'] = array('share_id' => $topic['share_id'], 'content' => '我关注了这个主题[强]', 'is_no_post' => 0);
            FS('Share')->saveRelay($share);
            TopicService::updateTopicFollowsCache($tid, $_FANWE['uid'], 'add');
            return true;
        }
    }
    function donewtopic()
    {
        global $_FANWE;
        if ($_FANWE['uid'] == 0) {
            fHeader('location: ' . FU('ask/index'));
        }
        $aid = intval($_FANWE['request']['aid']);
        if ($aid == 0) {
            fHeader('location: ' . FU('ask/index'));
        }
        $asks = $_FANWE['cache']['asks'];
        if (!isset($asks[$aid])) {
            fHeader('location: ' . FU('ask/index'));
        }
        $_FANWE['request']['title'] = trim($_FANWE['request']['title']);
        $_FANWE['request']['content'] = trim($_FANWE['request']['content']);
        if ($_FANWE['request']['title'] == '' || $_FANWE['request']['content'] == '') {
            fHeader('location: ' . FU('ask/index'));
        }
        $_FANWE['request']['uid'] = $_FANWE['uid'];
        $_FANWE['request']['type'] = 'ask';
        if (!checkIpOperation("add_share", SHARE_INTERVAL_TIME)) {
            showError('提交失败', lang('share', 'interval_tips'), -1);
        }
        $check_result = FS('Share')->checkWord($_FANWE['request']['content'], 'content');
        if ($check_result['error_code'] == 1) {
            showError('提交失败', $check_result['error_msg'], -1);
        }
        $check_result = FS('Share')->checkWord($_FANWE['request']['title'], 'title');
        if ($check_result['error_code'] == 1) {
            showError('提交失败', $check_result['error_msg'], -1);
        }
        $check_result = FS('Share')->checkWord($_FANWE['request']['tags'], 'tag');
        if ($check_result['error_code'] == 1) {
            showError('提交失败', $check_result['error_msg'], -1);
        }
        $share = FS('Share')->submit($_FANWE['request']);
        if ($share['status']) {
            $thread = array();
            $thread['aid'] = $aid;
            $thread['share_id'] = $share['share_id'];
            $thread['uid'] = $_FANWE['uid'];
            $thread['title'] = htmlspecialchars($_FANWE['request']['title']);
            $thread['content'] = htmlspecialchars($_FANWE['request']['content']);
            $thread['create_time'] = fGmtTime();
            $tid = FDB::insert('ask_thread', $thread, true);
            FDB::query('UPDATE ' . FDB::table('share') . ' SET rec_id = ' . $tid . '
				WHERE share_id = ' . $share['share_id']);
            FDB::query("update " . FDB::table("user_count") . " set ask = ask + 1,threads = threads + 1 where uid = " . $_FANWE['uid']);
            FDB::query("update " . FDB::table("ask") . " set thread_count = thread_count + 1 where aid = " . $aid);
            FS('Medal')->runAuto($_FANWE['uid'], 'ask');
            FS('User')->medalBehavior($_FANWE['uid'], 'continue_ask');
        }
        fHeader('location: ' . FU('ask/forum', array('aid' => $aid)));
    }
 private function buildConfig()
 {
     $config = array();
     @(include FANWE_ROOT . './public/config.global.php');
     if (empty($config)) {
         if (!file_exists(FANWE_ROOT . './public/install.lock')) {
             header('Location: install');
             exit;
         } else {
             systemError('config_not_found');
         }
     }
     if (empty($config['security']['authkey'])) {
         $config['security']['authkey'] = md5($config['cookie']['cookie_pre'] . $config['db'][1]['dbname']);
     }
     if (empty($config['debug']) || !file_exists(fimport('function/debug'))) {
         define('SYS_DEBUG', false);
     } elseif ($config['debug'] === 1 || $config['debug'] === 2 || !empty($_REQUEST['debug']) && $_REQUEST['debug'] === $config['debug']) {
         define('SYS_DEBUG', true);
         if ($config['debug'] == 2) {
             error_reporting(E_ALL);
         }
     } else {
         define('SYS_DEBUG', false);
     }
     timezoneSet($config['time_zone']);
     define('TIME_UTC', fGmtTime());
     $this->config =& $config;
     $this->var['config'] =& $config;
     if (substr($config['cookie']['cookie_path'], 0, 1) != '/') {
         $this->var['config']['cookie']['cookie_path'] = '/' . $this->var['config']['cookie']['cookie_path'];
     }
     $this->var['config']['cookie']['cookie_pre'] = $this->var['config']['cookie']['cookie_pre'] . substr(md5($this->var['config']['cookie']['cookie_path'] . '|' . $this->var['config']['cookie']['cookie_domain']), 0, 4) . '_';
 }
Beispiel #6
0
/**
 * 获取当前时间与指定时间的时间间隔
 *
 * @access  public
 * @param   integer      $time
 * @param   boolean      $is_arr
 *
 * @return  string or array
 */
function getEndTimelag($time, $is_arr = false)
{
    static $today_time = NULL, $timelag_lang = NULL, $sdate = 86400, $shours = 3600, $sminutes = 60;
    if ($today_time === NULL) {
        $today_time = fGmtTime();
        $timelag_lang = lang('time', 'timelag');
    }
    $timelag_arr = array('d' => 0, 'h' => 0, 'm' => 0, 's' => 0);
    $timelag = $time - $today_time;
    if ($timelag / $sdate >= 1) {
        $timelag_arr["d"] = floor($timelag / $sdate);
        $timelag = $timelag % $sdate;
    }
    if ($timelag / $shours >= 1) {
        $timelag_arr["h"] = floor($timelag / $shours);
        $timelag = $timelag % $shours;
    }
    if ($timelag / $sminutes >= 1) {
        $timelag_arr["m"] = floor($timelag / $sminutes);
        $timelag = $timelag % $sminutes;
    }
    if ($timelag > 0) {
        $timelag_arr["s"] = $timelag;
    }
    if ($is_arr) {
        return $timelag_arr;
    } else {
        return sprintf($timelag_lang, $timelag_arr["d"], $timelag_arr["h"], $timelag_arr["m"], $timelag_arr["s"]);
    }
}