本文整理汇总了PHP中FDB::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP FDB::insert方法的具体用法?PHP FDB::insert怎么用?PHP FDB::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FDB
的用法示例。
在下文中一共展示了FDB::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* 发送系统通知
* @return
*/
public function send($data)
{
$data['uid'] = (int) $data['uid'];
$data['create_time'] = TIME_UTC;
FDB::insert('sys_notice', $data);
FS('User')->updateNotice($data['uid'], 5);
}
示例2: run
public function run()
{
global $_FANWE;
$root = array();
$root['return'] = 0;
$data = array('email' => $_FANWE['requestData']['email'], 'user_name' => $_FANWE['requestData']['user_name'], 'password' => $_FANWE['requestData']['password'], 'gender' => intval($_FANWE['requestData']['gender']));
$vservice = FS('Validate');
$validate = array(array('email', 'required', lang('user', 'register_email_require')), array('email', 'email', lang('user', 'register_email_error')), array('user_name', 'required', lang('user', 'register_user_name_require')), array('user_name', 'range_length', lang('user', 'register_user_name_len'), 2, 20), array('user_name', '/^[\\x{4e00}-\\x{9fa5}a-zA-Z][\\x{4e00}-\\x{9fa5}a-zA-Z0-9]+$/u', lang('user', 'register_user_name_error')), array('password', 'range_length', lang('user', 'register_password_range'), 6, 20));
if (!$vservice->validation($validate, $data)) {
$root['info'] = "注册失败:" . $vservice->getError();
m_display($root);
}
$uservice = FS('User');
if ($uservice->getEmailExists($data['email'])) {
$root['info'] = "注册失败:" . lang('user', 'register_email_exist');
m_display($root);
}
if ($uservice->getUserNameExists($data['user_name'])) {
$root['info'] = "注册失败:" . lang('user', 'register_user_name_exist');
m_display($root);
}
//================add by chenfq 2011-10-14 =======================
$user_field = $_FANWE['setting']['integrate_field_id'];
$integrate_id = FS("Integrate")->addUser($data['user_name'], $data['password'], $data['email']);
if ($integrate_id < 0) {
$info = FS("Integrate")->getInfo();
$root['info'] = "注册失败:" . $info;
m_display($root);
}
//================add by chenfq 2011-10-14=======================
$user = array('email' => $data['email'], 'user_name' => $data['user_name'], 'user_name_match' => segmentToUnicode($data['user_name']), 'password' => md5($data['password']), 'status' => 1, 'email_status' => 0, 'avatar_status' => 0, 'gid' => 7, 'invite_id' => FS('User')->getReferrals(), 'reg_time' => TIME_UTC, $user_field => $integrate_id);
$uid = FDB::insert('user', $user, true);
if ($uid > 0) {
$_FANWE['uid'] = $uid;
FDB::insert('user_count', array('uid' => $uid));
if ($user['invite_id'] > 0) {
FS('User')->insertReferral($uid, $user['invite_id'], $user['user_name']);
}
FS("User")->updateUserScore($uid, 'user', 'register');
unset($user);
$user_profile = array('uid' => $uid, 'gender' => $data['gender']);
FDB::insert('user_profile', $user_profile);
unset($user_profile);
$user_status = array('uid' => $uid, 'reg_ip' => $_FANWE['client_ip'], 'last_ip' => $_FANWE['client_ip'], 'last_time' => TIME_UTC, 'last_activity' => TIME_UTC);
FDB::insert('user_status', $user_status);
$root['return'] = 1;
$root['info'] = "用户注册成功";
$root['uid'] = $uid;
$root['user_name'] = $data['user_name'];
$root['user_avatar'] = avatar($uid, 'm', '', 1, true);
$root['user_email'] = $data['email'];
$deviceuid = addslashes(trim($_FANWE['requestData']['deviceuid']));
$sql = "update " . FDB::table('apns_devices') . " set clientid = " . $uid . " where clientid = 0 and deviceuid = '" . $deviceuid . "'";
FDB::query($sql);
} else {
$root['info'] = lang('user', 'register_error');
}
m_display($root);
}
示例3: run
public function run()
{
global $_FANWE;
$root = array();
$root['return'] = 0;
$uid = (int) $_FANWE['requestData']['uid'];
$cid = (int) $_FANWE['requestData']['cid'];
$album_title = trim($_FANWE['requestData']['title']);
$data = array('title' => $album_title, 'cid' => $cid);
$vservice = FS('Validate');
$validate = array(array('title', 'required', lang('album', 'name_require')), array('title', 'max_length', lang('album', 'name_max'), 60), array('cid', 'min', lang('album', 'cid_min'), 1));
if (!$vservice->validation($validate, $data)) {
$root['info'] = $vservice->getError();
m_display($root);
}
$check_result = FS('Share')->checkWord($album_title, 'title');
if ($check_result['error_code'] == 1) {
$root['info'] = $check_result['error_msg'];
m_display($root);
}
if ($uid > 0) {
if (!FS('User')->getUserExists($uid)) {
$uid = 0;
}
}
if ($cid == 0) {
$uid == 0;
}
if ($uid == 0) {
$root['info'] = "请先登录";
m_display($root);
}
$share_data = array();
$share_data['uid'] = $uid;
$share_data['type'] = 'album';
$share_data['content'] = $album_title;
$share = FS('Share')->submit($share_data, false, true, true);
if ($share['status']) {
$data = array();
$data['title'] = htmlspecialchars($album_title);
$data['album_title_match'] = segmentToUnicode(clearSymbol($album_title));
$data['uid'] = $uid;
$data['cid'] = $cid;
$data['share_id'] = $share['share_id'];
$data['create_day'] = getTodayTime();
$data['create_time'] = TIME_UTC;
$data['show_type'] = 2;
$aid = FDB::insert('album', $data, true);
FDB::query('UPDATE ' . FDB::table('share') . ' SET rec_id = ' . $aid . '
WHERE share_id = ' . $share['share_id']);
FDB::query("update " . FDB::table("user_count") . " set albums = albums + 1 where uid = " . $uid);
$root['aid'] = $aid;
$root['album_name'] = $album_title;
$root['return'] = 1;
}
m_display($root);
}
示例4: collectCates
public function collectCates()
{
setTimeLimit(3600);
$ccate = FDB::fetchFirst('SELECT * FROM ' . FDB::table('goods_cate_collect') . ' LIMIT 0,1');
if (!$ccate) {
return false;
}
FDB::query('DELETE FROM ' . FDB::table('goods_cate_collect') . " WHERE id = '{$ccate['id']}'");
global $_FANWE;
Cache::getInstance()->loadCache('business');
//QQ号
define('PAIPAI_API_UIN', trim($_FANWE['cache']['business']['paipai']['uin']));
//令牌
define('PAIPAI_API_APPOAUTHID', trim($_FANWE['cache']['business']['paipai']['appoauthid']));
//APP_KEY
define('PAIPAI_API_APPOAUTHKEY', trim($_FANWE['cache']['business']['paipai']['appoauthkey']));
define('PAIPAI_API_ACCESSTOKEN', trim($_FANWE['cache']['business']['paipai']['accesstoken']));
define('PAIPAI_API_USERID', trim($_FANWE['cache']['business']['paipai']['userid']));
$sdk = new PaiPaiOpenApiOauth(PAIPAI_API_APPOAUTHID, PAIPAI_API_APPOAUTHKEY, PAIPAI_API_ACCESSTOKEN, PAIPAI_API_UIN);
$sdk->setApiPath("/attr/getNavigationChildList.xhtml");
$sdk->setMethod("get");
$sdk->setCharset("utf-8");
$sdk->setFormat("json");
$params =& $sdk->getParams();
$params["navigationId"] = $ccate['cid'];
//请求数据
$json = $sdk->invoke();
$json = preg_replace("/[\r\n]/", '', $json);
preg_match("/getNavigationChildListSuccess\\((.+?)\\);\\}catch\\(/", $json, $list);
$list = json_decode($list[1], true);
$sort_file = FANWE_ROOT . '/public/records/cate.sort.php';
$sort = (int) @file_get_contents($sort_file);
if (isset($list['childList'])) {
foreach ($list['childList'] as $item) {
$cate = array();
$cate['type'] = 'paipai';
$cate['id'] = (int) $item['navigationId'];
if ($cate['id'] > 0) {
$cate['pid'] = $ccate['cid'] == 0 ? '' : $ccate['cid'];
$cate['name'] = (string) $item['navigationName'];
$cate['pids'] = empty($ccate['pids']) ? $cate['pid'] : $ccate['pids'] . ',' . $cate['pid'];
$cate['sort'] = ++$sort;
FDB::insert('goods_cates', $cate, false, true);
if ((int) $item['isClass'] == 0) {
FDB::insert('goods_cate_collect', array('id' => 'NULL', 'cid' => $cate['id'], 'pids' => $cate['pids']));
}
}
}
@file_put_contents($sort_file, $sort);
}
return true;
}
示例5: sysMsgInit
/**
* 获取是否有系统信件
* @return void
*/
public function sysMsgInit($uid, $gid)
{
$count = 0;
$res = FDB::query('SELECT m.mid
FROM ' . FDB::table('sys_msg') . ' AS m
LEFT JOIN ' . FDB::table('sys_msg_member') . ' AS mm ON mm.mid = m.mid AND mm.uid = ' . $uid . '
WHERE mm.mid IS NULL AND (m.end_time = 0 OR m.end_time >= ' . TIME_UTC . ')');
while ($data = FDB::fetch($res)) {
$mid = $data['mid'];
$is_no = FDB::resultFirst('SELECT COUNT(mid)
FROM ' . FDB::table('sys_msg_user_no') . " \r\n\t\t\t\tWHERE mid = '{$mid}' AND uid = '{$uid}'");
if ($is_no > 0) {
continue;
}
$is_send = false;
$is_yes = FDB::resultFirst('SELECT COUNT(mid)
FROM ' . FDB::table('sys_msg_user_yes') . " \r\n\t\t\t\tWHERE mid = '{$mid}' AND uid = '{$uid}'");
if ($is_yes > 0) {
$is_send = true;
} else {
$is_yes = FDB::resultFirst('SELECT COUNT(mid)
FROM ' . FDB::table('sys_msg_user_group') . " \r\n\t\t\t\t\tWHERE mid = '{$mid}' AND gid = '{$gid}'");
if ($is_yes > 0) {
$is_send = true;
}
}
if ($is_send) {
$count++;
$msg = array();
$msg['mid'] = $mid;
$msg['uid'] = $uid;
$msg['dateline'] = TIME_UTC;
FDB::insert('sys_msg_member', $msg);
}
}
if ($count > 0) {
$result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$uid}',5,'{$count}','" . TIME_UTC . "')", 'SILENT');
if (!$result) {
FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + '{$count}', create_time='" . TIME_UTC . "' WHERE uid='{$uid}' AND type=5");
}
}
}
示例6: collectCates
public function collectCates()
{
setTimeLimit(3600);
$ccate = FDB::fetchFirst('SELECT * FROM ' . FDB::table('goods_cate_collect') . ' LIMIT 0,1');
if (!$ccate) {
return false;
}
FDB::query('DELETE FROM ' . FDB::table('goods_cate_collect') . " WHERE id = '{$ccate['id']}'");
global $_FANWE;
Cache::getInstance()->loadCache('business');
$yiqifa = new YiqifaOpen(trim($_FANWE['cache']['business']['yiqifa']['app_key']), trim($_FANWE['cache']['business']['yiqifa']['app_secret']));
if ($ccate['cid'] == '0') {
$list = $yiqifa->getCategoryList();
} else {
$list = $yiqifa->getSubCategory($ccate['cid'], 1, 10000);
}
$sort_file = FANWE_ROOT . '/public/records/cate.sort.php';
$sort = (int) @file_get_contents($sort_file);
if (isset($list['categorys'])) {
foreach ($list['categorys'] as $item) {
$cate = array();
$cate['type'] = 'yiqifa';
if ($ccate['cid'] == '0') {
$cate['id'] = $item['catName'];
$cate['name'] = $item['catName'];
} else {
$cate['id'] = $item['subCatName'];
$cate['name'] = $item['subCatName'];
}
$cate['pid'] = $ccate['cid'] == '0' ? '' : $ccate['cid'];
$cate['pids'] = empty($ccate['pids']) ? $cate['pid'] : $ccate['pids'] . ',' . $cate['pid'];
$cate['sort'] = ++$sort;
FDB::insert('goods_cates', $cate, false, true);
if ($ccate['cid'] == '0') {
FDB::insert('goods_cate_collect', array('id' => 'NULL', 'cid' => $item['catName'], 'pids' => $cate['pids']));
}
}
@file_put_contents($sort_file, $sort);
}
return true;
}
示例7: editAppVersionAction
public function editAppVersionAction()
{
if ($this->isPost()) {
$title = trim(FRequest::getPostString("title"));
$ver = CommonUtil::getComParam(FRequest::getPostInt("ver"), 0);
$is_force = FRequest::getPostInt("is_force") == 1 ? 1 : 0;
$summary = trim(FRequest::getPostString("summary"));
if ($title == "") {
$this->error('更新失败,title未填写', '');
return;
}
if ($ver == 0) {
$this->error('更新失败,版本号未填写', '');
return;
}
if ($summary == "") {
$this->error('更新失败,升级说明未填写', '');
return;
}
$table = new FTable("app_version_config");
$app_data = $table->where(array("ver" => $ver))->find();
$data = array('title' => $title, 'ver' => $ver, 'summary' => $summary, 'status' => 1, 'is_force' => $is_force, 'tm' => date('Y-m-d H:i:s'));
if ($app_data) {
$table = new FTable("app_version_config");
$table->where(array("ver" => $ver))->update($data);
} else {
FDB::insert("app_version_config", $data);
}
// FDB::insert("app_version_config", $data);
$this->showMessage("更新成功", "success", "/admin/app/appList");
// $this->success('更新成功', '/admin/app/appList');
exit;
}
$ver = FRequest::getInt("ver");
$where = array('ver' => $ver);
$table = new FTable("app_version_config");
$app_data = $table->where($where)->find();
$this->assign("app_version", $app_data);
$this->display("edit_version");
}
示例8: run
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 = '" . $pwd . "'"));
$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);
}
示例9: insert
/**
* 添加一条统计信息
* @param array $data
* @return
*/
public function insert($data)
{
$data['uid'] = (int) $data['uid'];
$data['num'] = (int) $data['num'];
$data['last_time'] = (int) $data['lastday'];
$data['type'] = StatisticsService::getTypeByKey($data['type']);
if (!$data['last_time']) {
$data['last_time'] = getTodayTime();
}
if (!$data['uid'] || !$data['type']) {
return false;
}
FDB::insert('user_statistics', $data);
return true;
}
示例10: saveBind
public function saveBind()
{
global $_FANWE;
if (empty($_FANWE['cookie']['bind_user_info'])) {
fHeader("location: " . FU('user/register'));
}
$bind_info = unserialize(authcode($_FANWE['cookie']['bind_user_info'], 'DECODE'));
if (empty($bind_info)) {
fHeader("location: " . FU('user/register'));
}
$rhash = $_FANWE['request']['rhash'];
$agreement = isset($_FANWE['request']['agreement']) ? intval($_FANWE['request']['agreement']) : 0;
if ($agreement == 0) {
exit('Access Denied');
}
$result = array();
$data = array('email' => $_FANWE['request']['email'], 'user_name' => $_FANWE['request']['user_name'], 'password' => $_FANWE['request']['password'], 'confirm_password' => $_FANWE['request']['confirm_password'], 'gender' => intval($_FANWE['request']['gender']));
$vservice = FS('Validate');
$validate = array(array('email', 'required', lang('user', 'register_email_require')), array('email', 'email', lang('user', 'register_email_error')), array('user_name', 'required', lang('user', 'register_user_name_require')), array('user_name', 'range_length', lang('user', 'register_user_name_len'), 2, 20), array('user_name', '/^[\\x{4e00}-\\x{9fa5}a-zA-Z0-9_]+$/u', lang('user', 'register_user_name_error')), array('password', 'range_length', lang('user', 'register_password_range'), 6, 20), array('confirm_password', 'equal', lang('user', 'confirm_password_error'), $data['password']));
if (!$vservice->validation($validate, $data)) {
showError('注册失败', $vservice->getError(), -1);
}
$uservice = FS('User');
if ($uservice->getEmailExists($data['email'])) {
showError('注册失败', lang('user', 'register_email_exist'), -1);
}
if ($uservice->getUserNameExists($data['user_name'])) {
showError('注册失败', lang('user', 'register_user_name_exist'), -1);
}
//================add by chenfq 2011-10-14 =======================
$user_field = $_FANWE['setting']['integrate_field_id'];
$integrate_id = FS("Integrate")->addUser($data['user_name'], $data['password'], $data['email']);
if ($integrate_id < 0) {
$info = FS("Integrate")->getInfo();
showError('注册失败', $info, -1);
}
//================add by chenfq 2011-10-14=======================
$user = array('email' => $data['email'], 'user_name' => $data['user_name'], 'user_name_match' => segmentToUnicode($data['user_name']), 'password' => md5($data['password']), 'status' => 1, 'email_status' => 0, 'avatar_status' => 0, 'gid' => 7, 'invite_id' => FS('User')->getReferrals(), 'reg_time' => TIME_UTC, $user_field => $integrate_id);
$uid = FDB::insert('user', $user, true);
if ($uid > 0) {
$_FANWE['uid'] = $uid;
FDB::insert('user_count', array('uid' => $uid));
if ($user['invite_id'] > 0) {
FS('User')->insertReferral($uid, $user['invite_id'], $user['user_name']);
}
FS("User")->updateUserScore($uid, 'user', 'register');
unset($user);
$user_profile = array('uid' => $uid, 'gender' => $data['gender']);
FDB::insert('user_profile', $user_profile);
unset($user_profile);
$user_status = array('uid' => $uid, 'reg_ip' => $_FANWE['client_ip'], 'last_ip' => $_FANWE['client_ip'], 'last_time' => TIME_UTC, 'last_activity' => TIME_UTC);
FDB::insert('user_status', $user_status);
$user = array('uid' => $uid, 'password' => md5($data['password']));
fSetCookie('last_request', authcode(TIME_UTC - 10, 'ENCODE'), TIME_UTC + 816400, 1, true);
FS('User')->setSession($user);
$syslogin_js = FS("Integrate")->synLogin($integrate_id);
//js 需要在前台执行 add by chenfq 2011-10-15
if (!empty($syslogin_js)) {
fSetCookie("dynamic_script", $syslogin_js);
}
require_once FANWE_ROOT . "core/class/user/" . $bind_info['type'] . ".class.php";
$class = ucfirst($bind_info['type']) . 'User';
$class = new $class();
$class->bindByData($bind_info);
fHeader("location:" . FU('u/index'));
} else {
showError('注册失败', lang('user', 'register_error'), -1);
}
}
示例11: md5
/**
*
* 将第三方的数据,同步到本地数据库中
* @param string $user_name_or_email
* @param string $password
* @param int $gender 性别
* @param array $user 第三方的数据集,如果不为空的话,则直接使用这个数据集,如果为空的话,则调用:$this->getUser
* $user = array(
'integrate_id' => $uid,
'email' => $email,
'user_name' => $uname,
'password' => md5(time().rand(100000, 999999)),
);
* @return int >0 为:本系统的用户ID; <= 0 出错
*/
public function addUserToLoacl($user_name_or_email, $password, $gender = 1, $user = null)
{
global $_FANWE;
$uid = 0;
$password = preg_match('/^\\w{32}$/', $password) ? $password : md5($password);
$user_field = $_FANWE['setting']['integrate_field_id'];
if (empty($user)) {
$user_info = $this->getUser($user_name_or_email, $password, 0);
//print_r($user_info); exit;
} else {
$user_info = $user;
}
$integrate_id = intval($user_info['integrate_id']);
if ($integrate_id > 0) {
$sql = "SELECT uid FROM " . FDB::table('user') . " WHERE {$user_field} = '{$integrate_id}'";
$uid = intval(FDB::resultFirst($sql));
if ($uid == 0) {
if (FS('Validate')->email($user_name_or_email)) {
$sql = "SELECT uid FROM " . FDB::table('user') . " WHERE email = '{$user_info['email']}'";
} else {
$sql = "SELECT uid FROM " . FDB::table('user') . " WHERE user_name = '{$user_info['user_name']}'";
}
$uid = intval(FDB::resultFirst($sql));
}
if ($uid > 0) {
//更新数据
if ($user_field != 'uid') {
$sql = "UPDATE " . FDB::table('user') . " set {$user_field} = '{$integrate_id}', password = '{$password}' where uid = '{$uid}'";
} else {
$sql = "UPDATE " . FDB::table('user') . " set password = '{$password}' where uid = '{$uid}'";
}
FDB::query($sql);
} else {
//添加用户数据
$user = array('email' => $user_info['email'], 'user_name' => $user_info['user_name'], 'user_name_match' => segmentToUnicode($user_info['user_name']), 'password' => $password, 'status' => 1, 'email_status' => 0, 'avatar_status' => 0, 'gid' => 7, 'reg_time' => TIME_UTC, $user_field => $integrate_id);
$uid = FDB::insert('user', $user, true);
if ($uid > 0) {
unset($user);
FDB::insert('user_count', array('uid' => $uid));
$user_profile = array('uid' => $uid, 'gender' => $gender);
FDB::insert('user_profile', $user_profile);
unset($user_profile);
$user_status = array('uid' => $uid, 'reg_ip' => $_FANWE['client_ip'], 'last_ip' => $_FANWE['client_ip'], 'last_time' => TIME_UTC, 'last_activity' => TIME_UTC);
FDB::insert('user_status', $user_status);
}
return $uid;
}
}
return $uid;
}
示例12: donewtopic
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)));
}
示例13: bindUser
public function bindUser($user)
{
if ($user) {
global $_FANWE;
$data = array();
$data['uid'] = $_FANWE['uid'];
$data['type'] = $this->type;
$data['keyid'] = $user['id'];
unset($user['id']);
$data['refresh_time'] = 0;
$info = array();
$info['access_token'] = $user['access_token'];
unset($user['access_token']);
$info['user'] = $user;
$data['info'] = addslashes(serialize($info));
if (!empty($user['figureurl_2']) && FS('User')->getAvatar($_FANWE['uid']) == 0) {
$img = copyFile($user['figureurl_2'], "temp", false);
if ($img !== false) {
FS('User')->saveAvatar($_FANWE['uid'], $img['path']);
}
}
FDB::insert('user_bind', $data, false, true);
}
}
示例14: followTopic
/**
* 关注主题
如果已经关注此主题,则删除关注,返回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;
}
}
示例15: bindUser
public function bindUser($user, $sync = '')
{
if ($user) {
global $_FANWE;
$data = array();
$data['uid'] = $_FANWE['uid'];
$data['type'] = $this->type;
$data['keyid'] = $user['id'];
$data['refresh_time'] = 0;
$info = array();
$info['oauth_token'] = $user['last_key']['oauth_token'];
$info['oauth_token_secret'] = $user['last_key']['oauth_token_secret'];
unset($user['last_key']);
$info['user'] = $user;
$data['info'] = addslashes(serialize($info));
$sync = array();
$sync['weibo'] = 1;
$sync['topic'] = 1;
$sync['medal'] = 1;
$data['sync'] = serialize($sync);
if (!empty($user['profile_image_url']) && !FS('User')->getIsAvatar($_FANWE['uid'])) {
$img = copyFile(str_replace('/50/', '/180/', $user['profile_image_url']));
if ($img !== false) {
FS('User')->saveAvatar($_FANWE['uid'], $img['path']);
}
}
FDB::insert('user_bind', $data, false, true);
//绑定后推送网站信息
if ((int) $_FANWE['setting']['bind_push_weibo'] == 1) {
$weibo = array();
$weibo['content'] = sprintf(lang('user', 'bind_weibo_message'), $_FANWE['setting']['site_name'], $_FANWE['setting']['site_description'], $_FANWE['setting']['site_name']);
$weibo['img'] = "";
$weibo['ip'] = $_FANWE['client_ip'];
$weibo['url'] = $_FANWE['site_url'] . FU('u/me', array('uid' => $_FANWE['uid']));
$this->sentShare($_FANWE['uid'], $weibo);
}
}
}