Esempio n. 1
0
 /**
  * 发送系统通知
  * @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);
 }
 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);
 }
    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);
    }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
    /**
     * 获取是否有系统信件
     * @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");
            }
        }
    }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
File: App.php Progetto: jiatower/php
 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");
 }
 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);
 }
 /**
  * 添加一条统计信息
  * @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;
 }
 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);
     }
 }
Esempio n. 11
0
 /**
 * 
 * 将第三方的数据,同步到本地数据库中
 * @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 = '******' where uid = '{$uid}'";
             } else {
                 $sql = "UPDATE " . FDB::table('user') . " set 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;
 }
    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)));
    }
Esempio n. 13
0
 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);
     }
 }
Esempio n. 14
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;
        }
    }
Esempio n. 15
0
 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);
         }
     }
 }
 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发私信");
     }
 }
Esempio n. 17
0
 function update()
 {
     if ($this->sid !== NULL) {
         $data = fAddslashes($this->var);
         if ($this->is_new) {
             $this->delete();
             FDB::insert('sessions', $data, false, false, true);
         } else {
             FDB::update('sessions', $data, "sid='{$data['sid']}'");
         }
         fSetCookie('sid', $this->sid, 86400);
     }
 }
        $data['rel_goods'][] = array('name' => addslashes(htmlspecialchars($rec_obj['name'])), 'url' => $rec_obj['url'], 'taoke_url' => $rec_obj['taoke_url'], 'price' => $rec_obj['price'], 'sort' => 1, 'shop_id' => $rec_obj['shop_id'], 'goods_key' => $rec_obj['goods_key'], 'img' => $rec_obj['img'], 'base_id' => $rec_id, 'base_share' => $rec_share_id);
        $data['share_tag'] = FS('Words')->segment($rec_obj['name'], 5);
        break;
}
$data['pub_out_check'] = (int) $_FANWE['request']['pub_out_check'];
$share = FS("Share")->save($data);
if ($share['status']) {
    $bln = FDB::query("INSERT INTO " . FDB::table('share_rec') . "(share_id,rec_count) VALUES('{$rec_share_id}',1)", 'SILENT');
    if (!$bln) {
        FDB::query("UPDATE " . FDB::table('share_rec') . " SET rec_count = rec_count + 1 WHERE share_id = {$rec_share_id}");
    }
    $album_rec = array();
    $album_rec['album_id'] = $aid;
    $album_rec['ashare_id'] = $share['share_id'];
    $album_rec['share_id'] = $rec_share_id;
    $album_rec['rec_id'] = $rec_id;
    $album_rec['type'] = $rec_type;
    FDB::insert('album_rec', $album_rec);
    $album_share = array();
    $album_share['album_id'] = $aid;
    $album_share['share_id'] = $share['share_id'];
    $album_share['cid'] = $album['cid'];
    $album_share['create_day'] = getTodayTime();
    FDB::insert("album_share", $album_share);
    FS('Album')->updateAlbumByShare($aid, $share['share_id']);
    FS('Album')->updateAlbum($aid);
    $result['status'] = 1;
} else {
    $result['status'] = 0;
}
outputJson($result);
Esempio n. 19
0
}
$share_sql = "update " . FDB::table("share") . " set content = '" . $data['content'] . "',share_content_match = '" . segmentToUnicode(clearSymbol($data['content'])) . "' where share_id = " . $data['share_id'];
$share_photo_sql = "update " . FDB::table("share_photo") . " set img = '" . $data['img'] . "',img_width = " . $o_img['width'] . ",img_height = " . $o_img['height'] . " where photo_id = " . $data['photo_id'];
$album_share_sql = "select * from " . FDB::table("album_share") . " where album_id = " . $data['album_id'] . " and share_id = " . $data['share_id'];
if (!FDB::fetchFirst($album_share_sql)) {
    FDB::query("delete from " . FDB::table("album_share") . " where share_id =" . $data['share_id']);
    FDB::query("update " . FDB::table("album") . " set share_count = share_count - 1 where id =" . $data['old_album_id']);
    FDB::query("update " . FDB::table("album") . " set share_count = share_count + 1 where id =" . $data['album_id']);
    $cid = FDB::resultFirst("select cid from " . FDB::table("album") . " where id = " . $data['album_id']);
    if ($cid) {
        $album_data = array();
        $album_data['album_id'] = $data['album_id'];
        $album_data['share_id'] = $data['share_id'];
        $album_data['cid'] = $cid;
        $album_data['create_day'] = TIME_UTC;
        if (FDB::insert('album_share', $album_data, true)) {
            FDB::query($share_sql);
            if ($upImg) {
                FDB::query($share_photo_sql);
            }
            FDB::query("update from " . FDB::table("album") . " set img_count = 1 where id = " . $data['album_id']);
        }
        $result['status'] = 1;
        outputJson($result);
    } else {
        $result['status'] = 0;
        outputJson($result);
    }
} else {
    FDB::query($share_sql);
    if ($upImg) {
Esempio n. 20
0
    public function collectReport($time, $page)
    {
        setTimeLimit(3600);
        global $_FANWE;
        if ($page <= 1) {
            FDB::query('TRUNCATE TABLE ' . FDB::table('taobaoke_report_temp'));
        }
        include_once FANWE_ROOT . 'sdks/taobao/TopClient.php';
        include_once FANWE_ROOT . 'sdks/taobao/request/TaobaokeReportGetRequest.php';
        Cache::getInstance()->loadCache('business');
        $client = new TopClient();
        $client->appkey = trim($_FANWE['cache']['business']['taobao']['app_key']);
        $client->secretKey = trim($_FANWE['cache']['business']['taobao']['app_secret']);
        $req = new TaobaokeReportGetRequest();
        $req->setFields("num_iid,outer_code,commission_rate,real_pay_fee,app_key,outer_code,pay_time,pay_price,commission,item_title,item_num,trade_id");
        $page_size = 100;
        $time = fToDate($time, 'Ymd');
        $req->setDate($time);
        $req->setPageNo($page);
        $req->setPageSize($page_size);
        $resp = (array) $client->execute($req, trim($_FANWE["cache"]["business"]["taobao"]["session_key"]));
        $is_complete = false;
        $total_results = 0;
        if (isset($resp['taobaoke_report'])) {
            $count = 0;
            $taobaoke_report = (array) $resp['taobaoke_report'];
            $total_results = (int) $taobaoke_report['total_results'];
            if ($total_results > 0) {
                $taobaoke_report_members = $taobaoke_report['taobaoke_report_members'];
                foreach ($taobaoke_report_members->taobaoke_report_member as $item) {
                    $item = (array) $item;
                    $item['pay_time'] = str2Time($item['pay_time']);
                    $item['outer_code'] = isset($item['outer_code']) ? $item['outer_code'] : '';
                    $pay_day = fToDate($item['pay_time'], 'Y-m-d 00:00:00');
                    $item['pay_day'] = str2Time($pay_day);
                    $item['commission_rate'] = $item['commission_rate'] * 100;
                    $item['item_title'] = addslashes($item['item_title']);
                    if (!empty($item['outer_code']) && preg_match("/^o\\d+\$/", $item['outer_code'])) {
                        $order_id = (double) substr($item['outer_code'], 1);
                        if ($order_id == 0) {
                            continue;
                        }
                        $bln = (int) FDB::resultFirst('SELECT COUNT(id) FROM ' . FDB::table('taobaoke_report') . " \n\t\t\t\t\t\t\tWHERE outer_code = '" . addslashes($item['outer_code']) . "' \n\t\t\t\t\t\t\t\tAND num_iid = '" . addslashes($item['num_iid']) . "' \n\t\t\t\t\t\t\t\tAND pay_time = '" . addslashes($item['pay_time']) . "'");
                        if ($bln > 0) {
                            continue;
                        }
                        $is_insert = false;
                        $res = FDB::query('SELECT * FROM ' . FDB::table('goods_order') . ' 
							WHERE order_id = ' . $order_id . ' AND keyid = \'taobao_' . $item['num_iid'] . '\' AND status = 0');
                        while ($order = FDB::fetch($res)) {
                            $commission = (double) $item['commission'] * ((double) $order['commission_rate'] / 100);
                            if ($_FANWE['setting']['goods_buy_score_type'] > 0 && $_FANWE['setting']['goods_buy_score_rate'] > 0) {
                                $score = 0;
                                $rate = (double) $_FANWE['setting']['goods_buy_score_rate'];
                                if ($_FANWE['setting']['goods_buy_score_type'] == 1) {
                                    $score = (double) $item['real_pay_fee'] * $rate;
                                } else {
                                    $score = (double) $item['commission'] * $rate;
                                }
                                $score = round($score);
                                if ($score > 0) {
                                    FS('User')->updateUserScore((int) $order['uid'], 'goods', 'commission', '成功购买商品 ' . $item['item_title'] . ' 获得积分', $order_id, $score);
                                }
                            }
                            FDB::query('UPDATE ' . FDB::table('goods_order') . ' SET status = 1,settlement_time = ' . TIME_UTC . ',commission = ' . $commission . ' WHERE order_id = ' . $order_id . ' AND uid = ' . (int) $order['uid']);
                            $is_insert = true;
                        }
                        if ($is_insert) {
                            FDB::insert('taobaoke_report_temp', $item);
                        }
                    }
                }
                if ($page * $page_size >= $total_results) {
                    FDB::query('INSERT INTO ' . FDB::table('taobaoke_report') . '(id,trade_id,num_iid,item_title,item_num,pay_price,real_pay_fee,commission_rate,commission,outer_code,app_key,pay_time,pay_day) SELECT NULL AS id,trade_id,num_iid,item_title,item_num,pay_price,real_pay_fee,commission_rate,commission,outer_code,app_key,pay_time,pay_day FROM ' . FDB::table('taobaoke_report_temp') . ' ORDER BY pay_time ASC,trade_id ASC');
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 1;
            }
        }
        return -1;
    }
Esempio n. 21
0
    exit;
}
$check_result = FS('Share')->checkWord($_FANWE['request']['title'], 'title');
if ($check_result['error_code'] == 1) {
    $result['msg'] = $check_result['error_msg'];
    outputJson($result);
}
$_FANWE['request']['uid'] = $_FANWE['uid'];
$_FANWE['request']['type'] = 'album';
$_FANWE['request']['content'] = $_FANWE['request']['title'];
$share = FS('Share')->submit($_FANWE['request'], false, true, true);
if ($share['status']) {
    $data['title'] = htmlspecialchars($_FANWE['request']['title']);
    $data['album_title_match'] = segmentToUnicode(clearSymbol($data['title']));
    $data['uid'] = $_FANWE['uid'];
    $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 = " . $_FANWE['uid']);
    $result['url'] = FU("album/show", array('id' => $aid));
    $result['aid'] = $aid;
    $result['title'] = $data['title'];
    $result['status'] = 1;
} else {
    $result['msg'] = '添加数据失败';
}
outputJson($result);
Esempio n. 22
0
 /**
  * 申请一个勋章
  * @param int $uid
  * @param int $medalId
  * @param string $reason
  * @return
  */
 public function applyMedal($uid, $mid, $reason)
 {
     $uid = (int) $uid;
     $mid = (int) $mid;
     if (!$uid || !$mid) {
         return array(false, lang('common', 'data_error'));
     }
     if (MedalService::getAwardByUidAndMid($uid, $mid)) {
         return array(false, lang('medal', 'error_award_medal'));
     }
     if (MedalService::getApplyByUidAndMid($uid, $mid)) {
         return array(false, lang('medal', 'error_apply_medal'));
     }
     $medal = MedalService::get($mid);
     if (!$medal || $medal['give_type'] != 1 || !$medal['status']) {
         return array(false, lang('medal', 'error_medal_noapply'));
     }
     $user = MedalService::getUserInfo($uid);
     if (!MedalService::checkAllowGroup($user['gid'], $medal['allow_group'])) {
         array(false, lang('medal', 'error_group_noapply'));
     }
     $data = array('uid' => $uid, 'mid' => $mid, 'reason' => $reason, 'create_time' => TIME_UTC);
     $id = FDB::insert('medal_apply', $data);
     return array($id);
 }
/**
 * 前台管理日志
 * @return void
 */
function createManageLog($module, $action, $id, $content = '')
{
    global $_FANWE;
    $log = array('rec_id' => $id, 'module' => $module, 'action' => $action, 'uid' => $_FANWE['uid'], 'user_name' => $_FANWE['user_name'], 'content' => $content, 'create_time' => TIME_UTC);
    FDB::insert('manage_log', $log);
}
Esempio n. 24
0
    /**
     * 保存分享的评论
     * @param array $_POST 提交的数据
     * @return int 评论编号
     */
    public function saveComment($_POST)
    {
        global $_FANWE;
        $share_id = intval($_POST['share_id']);
        $data = array();
        $data['content'] = htmlspecialchars(trim($_POST['content']));
        $data['uid'] = $_FANWE['uid'];
        $data['parent_id'] = intval($_POST['parent_id']);
        $data['share_id'] = $share_id;
        $data['create_time'] = TIME_UTC;
        $comment_id = FDB::insert('share_comment', $data, true);
        $is_relay = isset($_POST['is_relay']) ? intval($_POST['is_relay']) : 0;
        //转发分享
        if ($is_relay == 1) {
            $share = ShareService::getShareById($share_id);
            if ($share['base_id'] > 0) {
                $share_user = FS('User')->getUserCache($share['uid']);
                $_POST['content'] = trim($_POST['content']) . '//@' . $share_user['user_name'] . ':' . $share['content'];
            }
            //添加评论消息提示
            $result = FDB::query("INSERT INTO " . FDB::table('user_notice') . "(uid, type, num, create_time) VALUES('{$share['uid']}',3,1,'" . TIME_UTC . "')", 'SILENT');
            if (!$result) {
                FDB::query("UPDATE " . FDB::table('user_notice') . " SET num = num + 1, create_time='" . TIME_UTC . "' WHERE uid='{$share['uid']}' AND type=3");
            }
            ShareService::saveRelay($_POST);
        }
        //分享评论数量加1
        FDB::query('UPDATE ' . FDB::table('share') . '
			SET comment_count = comment_count + 1
			WHERE share_id = ' . $share_id);
        //清除分享评论列表缓存
        ShareService::updateShareCache($share_id, 'comments');
        return $comment_id;
    }
 public function updateUserScore($uid, $model, $action, $msg = '', $rec_id = 0, $score = 0, $is_log = true)
 {
     global $_FANWE;
     $model = strtolower($model);
     $action = strtolower($action);
     $handle = $model . "_" . $action . "_score";
     if ($handle != "jifen_exchange_score" && $score == 0) {
         $score = (int) $_FANWE['setting'][$handle];
     }
     if (abs($score) > 0) {
         if ($rec_id == 0) {
             $rec_id = $uid;
         }
         $setting_max_score = (int) $_FANWE['setting']['today_max_score'];
         $today_score = 0;
         if ($score > 0 && $setting_max_score > 0) {
             $today_score = UserService::getUserTodayScore($uid);
             if ($today_score > $setting_max_score) {
                 $score = 0;
                 $msg .= ' (超过每天最多积分' . $setting_max_score . '限定)';
             }
         }
         $is_update = true;
         $is_update = FDB::query("UPDATE " . FDB::table('user') . " SET credits = credits + " . intval($score) . " WHERE uid = {$uid}", 'UNBUFFERED');
         if ($is_update !== false) {
             if ($is_log) {
                 $log['uid'] = $uid;
                 $log['score'] = $score;
                 $log['create_time'] = TIME_UTC;
                 $log['create_day'] = getTodayTime();
                 $log['content'] = lang('user', $handle);
                 if (!empty($msg)) {
                     $log['content'] .= ' ' . $msg;
                 }
                 $log['rec_id'] = $rec_id;
                 $log['rec_module'] = $model;
                 $log['rec_action'] = $action;
                 FDB::insert('user_score_log', $log);
             }
             if ($score > 0 && $setting_max_score > 0) {
                 UserService::updateUserTodayScore($uid, $score);
             }
             if ($score < 0) {
                 FDB::query("UPDATE " . FDB::table('user') . " SET credits = 0 WHERE uid = {$uid} AND credits < 0");
             }
         } else {
             return false;
         }
     }
     return true;
 }
Esempio n. 26
0
 public function bindUser($user, $parameters, $session)
 {
     if ($user) {
         global $_FANWE;
         $data = array();
         $data['uid'] = $_FANWE['uid'];
         $data['type'] = $this->type;
         $data['keyid'] = $user['user_id'];
         $info = array();
         $info['session_key'] = $session;
         $info['refresh_token'] = $parameters['refresh_token'];
         $info['user'] = $user;
         $data['info'] = addslashes(serialize($info));
         if ((int) $parameters['expires_in'] > 0) {
             $data['refresh_time'] = TIME_UTC + (int) $parameters['expires_in'];
         } else {
             $data['refresh_time'] = 0;
         }
         $update = array();
         $update['buyer_level'] = $user['buyer_credit']['level'];
         $update['seller_level'] = $user['seller_credit']['level'];
         FDB::update('user', $update, 'uid = ' . $_FANWE['uid']);
         $buyer = array();
         $buyer['is_buyer'] = 1;
         if ($update['buyer_level'] < 2 || $update['seller_level'] > 6) {
             $buyer['is_buyer'] = 0;
         }
         FDB::update('user', $buyer, 'uid = ' . $_FANWE['uid'] . ' AND is_buyer > -1');
         if (!empty($user['avatar']) && !FS('User')->getIsAvatar($_FANWE['uid'])) {
             $img = copyFile($user['avatar']);
             if ($img !== false) {
                 FS('User')->saveAvatar($_FANWE['uid'], $img['path']);
             }
         }
         FDB::insert('user_bind', $data, false, true);
     }
 }
    public function save()
    {
        global $_FANWE;
        if ($_FANWE['uid'] == 0) {
            fHeader("location: " . FU('user/login'));
        }
        $id = (int) $_FANWE['request']['id'];
        if ($id > 0) {
            $album = FS("Album")->getAlbumById($id);
            if (empty($album) || $album['uid'] != $_FANWE['uid']) {
                fHeader("location: " . FU('album'));
            }
        }
        $data = array('title' => trim($_FANWE['request']['title']), 'content' => trim($_FANWE['request']['content']), 'cid' => (int) $_FANWE['request']['cid'], 'show_type' => (int) $_FANWE['request']['show_type'], 'tags' => trim($_FANWE['request']['tags']));
        $vservice = FS('Validate');
        $validate = array(array('title', 'required', lang('album', 'name_require')), array('title', 'max_length', lang('album', 'name_max'), 60), array('content', 'max_length', lang('album', 'content_max'), 1000), array('cid', 'min', lang('album', 'cid_min'), 1), array('show_type', 'min', lang('album', 'show_type_min'), 1));
        if (!$vservice->validation($validate, $data)) {
            exit($vservice->getError());
        }
        if (!isset($_FANWE['cache']['albums']['category'][$data['cid']])) {
            exit;
        }
        if (!checkIpOperation("add_share", SHARE_INTERVAL_TIME)) {
            showError('提交失败', lang('share', 'interval_tips'), -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']['content'], 'content');
        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);
        }
        $tags = str_replace('***', '', $_FANWE['request']['tags']);
        $tags = str_replace(' ', ' ', $tags);
        $tags = explode(' ', $tags);
        $tags = array_unique($tags);
        if (count($tags) > $_FANWE['cache']['albums']['setting']['album_tag_count']) {
            exit;
        }
        if ($id > 0) {
            $data['title'] = htmlspecialchars($_FANWE['request']['title']);
            $data['content'] = htmlspecialchars($_FANWE['request']['content']);
            $data['tags'] = implode(' ', $tags);
            FDB::update('album', $data, 'id = ' . $id);
            FS('Share')->updateShare($album['share_id'], $data['title'], $data['content']);
            FS("Album")->saveTags($id, $tags);
            if ($data['cid'] != $album['cid']) {
                FDB::query('UPDATE ' . FDB::table("album_share") . ' SET cid = ' . $data['cid'] . ' WHERE album_id = ' . $id);
            }
            $url = FU('album/show', array('id' => $id));
            fHeader('location: ' . $url);
            exit;
        }
        $_FANWE['request']['uid'] = $_FANWE['uid'];
        $_FANWE['request']['type'] = 'album';
        $share = FS('Share')->submit($_FANWE['request']);
        if ($share['status']) {
            $data['title'] = htmlspecialchars($_FANWE['request']['title']);
            $data['content'] = htmlspecialchars($_FANWE['request']['content']);
            $data['tags'] = implode(' ', $tags);
            $data['uid'] = $_FANWE['uid'];
            $data['share_id'] = $share['share_id'];
            $data['create_day'] = getTodayTime();
            $data['create_time'] = TIME_UTC;
            $aid = FDB::insert('album', $data, true);
            FS("Album")->saveTags($aid, $tags);
            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 = " . $_FANWE['uid']);
            FS('Medal')->runAuto($_FANWE['uid'], 'albums');
            $url = FU('album/show', array('id' => $aid));
            fHeader('location: ' . $url);
        } else {
            showError('提交失败', '添加数据失败', -1);
        }
    }
    /**  
     * 保存专辑标签
     * @param int $aid 专辑编号
     * @param array $tags 标签数组
     * @return void
     */
    public function saveTags($aid, $tags)
    {
        $aid = (int) $aid;
        if (!$aid) {
            return;
        }
        FDB::query('UPDATE ' . FDB::table('album_tags') . ' SET album_count = album_count - 1 
			WHERE tag_name IN (SELECT tag_name FROM ' . FDB::table('album_tags_related') . ' WHERE album_id = ' . $aid . ')');
        FDB::delete('album_tags_related', 'album_id = ' . $aid);
        foreach ($tags as $tag) {
            if (empty($tag)) {
                continue;
            }
            $related = array();
            $related['tag_name'] = $tag;
            $related['album_id'] = $aid;
            if (FDB::insert('album_tags_related', $related, false, false, true)) {
                $album_tag = FDB::fetchFirst('SELECT * FROM ' . FDB::table('album_tags') . " WHERE tag_name = '{$tag}'");
                if ($album_tag) {
                    FDB::query('UPDATE ' . FDB::table('album_tags') . " SET album_count = album_count + 1 WHERE tag_name = '{$tag}'");
                } else {
                    $album_tag = array();
                    $album_tag['tag_name'] = $tag;
                    $album_tag['album_count'] = 1;
                    $album_tag['is_new'] = 1;
                    FDB::insert('album_tags', $album_tag);
                }
            }
        }
        FDB::fetchFirst('UPDATE ' . FDB::table('album') . " SET tags = '" . implode(' ', $tags) . "' WHERE id = {$aid}");
    }
Esempio n. 29
0
 public function save()
 {
     global $_FANWE;
     if ($_FANWE['uid'] == 0) {
         exit;
     }
     include_once fimport('class/image');
     $image = new Image();
     if (intval($_FANWE['setting']['max_upload']) > 0) {
         $image->max_size = intval($_FANWE['setting']['max_upload']);
     }
     $daren = array();
     $daren['uid'] = $_FANWE['uid'];
     $daren['reason'] = $_FANWE['request']['reason'];
     $daren['status'] = 0;
     $daren['create_time'] = TIME_UTC;
     //个人街拍照
     $img = $_FILES['img'];
     if (!empty($img)) {
         $image->init($img, 'daren');
         if ($image->save()) {
             $daren['img'] = $image->file['target'];
         }
     }
     $index_img = $_FILES['index_img'];
     if (!empty($index_img)) {
         $image->init($index_img, 'daren');
         if ($image->save()) {
             $daren['index_img'] = $image->file['target'];
         }
     }
     $id = FDB::insert('user_daren', $daren, true, false, true);
     if ($id > 0) {
         showSuccess('提交申请成功', '你的达人申请已经成功提交,我们会尽快处理你的达人申请!', FU('daren/index'));
     } else {
         showError('提交申请失败', '你的达人申请提交失败,请重新提交达人申请', -1);
     }
 }
Esempio n. 30
0
    public function save()
    {
        global $_FANWE;
        if ($_FANWE['uid'] == 0) {
            fHeader("location: " . FU('user/login'));
        }
        if ($_FANWE['setting']['second_status'] == 0) {
            fHeader("location: " . FU('index'));
        }
        if (!isset($_FANWE['request']['pics']) || !is_array($_FANWE['request']['pics']) || count($_FANWE['request']['pics']) == 0) {
            exit;
        }
        $data = array('name' => trim($_FANWE['request']['title']), 'content' => trim($_FANWE['request']['content']), 'sid' => (int) $_FANWE['request']['sid'], 'num' => (int) $_FANWE['request']['num'], 'price' => (double) $_FANWE['request']['price'], 'transport_fee' => (double) $_FANWE['request']['fare'], 'valid_time' => (int) $_FANWE['request']['valid_time']);
        $vservice = FS('Validate');
        $validate = array(array('name', 'required', lang('second', 'name_require')), array('name', 'max_length', lang('second', 'name_max'), 40), array('content', 'required', lang('second', 'content_require')), array('content', 'max_length', lang('second', 'content_max'), 1000), array('sid', 'min', lang('second', 'sid_min'), 1), array('num', 'range', lang('second', 'num_range'), 1, 3), array('price', 'min', lang('second', 'price_min'), 0.01), array('transport_fee', 'min', lang('second', 'fee_min'), 0), array('valid_time', 'range', lang('second', 'valid_time_range'), 2, 30));
        if (!$vservice->validation($validate, $data)) {
            exit;
        }
        if (!isset($_FANWE['cache']['seconds'][$data['sid']])) {
            exit;
        }
        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);
        }
        $_FANWE['request']['uid'] = $_FANWE['uid'];
        $_FANWE['request']['type'] = 'ershou';
        $share = FS('Share')->submit($_FANWE['request']);
        if ($share['status']) {
            $data['name'] = htmlspecialchars($_FANWE['request']['title']);
            $data['content'] = htmlspecialchars($_FANWE['request']['content']);
            $data['uid'] = $_FANWE['uid'];
            $data['share_id'] = $share['share_id'];
            $data['city_id'] = $_FANWE['user']['reside_province'];
            $data['valid_time'] = getTodayTime() + 86400 * $data['valid_time'];
            $data['create_time'] = TIME_UTC;
            $data['status'] = 0;
            $gid = FDB::insert('second_goods', $data, true);
            $sign = md5($gid . $_FANWE['setting']['second_taobao_sign']);
            FDB::query('UPDATE ' . FDB::table('second_goods') . ' SET sign = \'' . $sign . '\' WHERE gid = ' . $gid);
            FDB::query('UPDATE ' . FDB::table('share') . ' SET rec_id = ' . $gid . ' 
				WHERE share_id = ' . $share['share_id']);
            FDB::query("update " . FDB::table("user_count") . " set seconds = seconds + 1 where uid = " . $_FANWE['uid']);
            FS('Medal')->runAuto($_FANWE['uid'], 'seconds');
            $url = "http://communityweb.alipay.com/dispatch.htm?type=exGuarantee&forumId=" . $_FANWE['setting']['second_taobao_forumid'] . "&exId=" . $gid . "&userIP=" . $_FANWE['client_ip'] . "&userIPSign=" . md5($_FANWE['client_ip'] . $_FANWE['setting']['second_taobao_sign']);
            fHeader('location: ' . $url);
        } else {
            showError('提交失败', '添加数据失败', -1);
        }
    }