/** * 通过判断is_feed 向UCenter提交Feed * * @access public * @param integer $value_id $order_id or $comment_id * @param interger $feed_type BUY_GOODS or COMMENT_GOODS * * @return void */ function add_feed($id, $feed_type) { $feed = array(); if ($feed_type == BUY_GOODS) { if (empty($id)) { return; } $id = intval($id); $sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_desc, g.goods_thumb, o.goods_price FROM " . $this->pre . "order_goods AS o, " . $this->pre . "goods AS g WHERE o.order_id='{$id}' AND o.goods_id=g.goods_id"; $order_res = $this->query($sql); foreach ($order_res as $goods_data) { if (!empty($goods_data['goods_thumb'])) { $url = __URL__ . $goods_data['goods_thumb']; //ECTouch::ecs()->url() . $goods_data['goods_thumb']; } else { $url = __URL__ . C('no_picture'); //ECTouch::ecs()->url() . C('no_picture'); } $link = __HOST__ . url('goods/index', array('id' => $goods_data["goods_id"])); //ECTouch::ecs()->url() . "goods.php?id=" . $goods_data["goods_id"]; $feed['icon'] = "goods"; $feed['title_template'] = '<b>{username} ' . L('feed_user_buy') . ' {goods_name}</b>'; $feed['title_data'] = array('username' => $_SESSION['user_name'], 'goods_name' => $goods_data['goods_name']); $feed['body_template'] = '{goods_name} ' . L('feed_goods_price') . ':{goods_price} ' . L('feed_goods_desc') . ':{goods_desc}'; $feed['body_data'] = array('goods_name' => $goods_data['goods_name'], 'goods_price' => $goods_data['goods_price'], 'goods_desc' => sub_str(strip_tags($goods_data['goods_desc']), 150, true)); $feed['images'][] = array('url' => $url, 'link' => $link); uc_call("uc_feed_add", array($feed['icon'], $_SESSION['user_id'], $_SESSION['user_name'], $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images'])); } } return; }
/** * 兑换积分 * * @param integer $uid 用户ID * @param integer $fromcredits 原积分 * @param integer $tocredits 目标积分 * @param integer $toappid 目标应用ID * @param integer $netamount 积分数额 * * @return boolean */ function exchange_points($uid, $fromcredits, $tocredits, $toappid, $netamount) { $ucresult = uc_call('uc_credit_exchange_request', array($uid, $fromcredits, $tocredits, $toappid, $netamount)); if (!$ucresult) { return false; } else { return true; } }
function edit_user($cfg, $forget_pwd = '0') { $real_username = $cfg['username']; $cfg['username'] = addslashes($cfg['username']); $set_str = ''; $valarr = array('email' => 'email', 'gender' => 'sex', 'bday' => 'birthday'); foreach ($cfg as $key => $val) { if ($key == 'username' || $key == 'password' || $key == 'old_password') { continue; } $set_str .= $valarr[$key] . '=' . "'{$val}',"; } $set_str = substr($set_str, 0, -1); if (!empty($set_str)) { $sql = "UPDATE " . $GLOBALS['ecs']->table('users') . " SET {$set_str} WHERE user_name = '{$cfg['username']}'"; $GLOBALS['db']->query($sql); $flag = true; } if (!empty($cfg['email'])) { $ucresult = uc_call("uc_user_edit", array($cfg['username'], '', '', $cfg['email'], 1)); if ($ucresult > 0) { $flag = true; } elseif ($ucresult == -4) { //echo 'Email 格式有误'; $this->error = ERR_INVALID_EMAIL; return false; } elseif ($ucresult == -5) { //echo 'Email 不允许注册'; $this->error = ERR_INVALID_EMAIL; return false; } elseif ($ucresult == -6) { //echo '该 Email 已经被注册'; $this->error = ERR_EMAIL_EXISTS; return false; } elseif ($ucresult < 0) { return false; } } if (!empty($cfg['old_password']) && !empty($cfg['password']) && $forget_pwd == 0) { $ucresult = uc_call("uc_user_edit", array($real_username, $cfg['old_password'], $cfg['password'], '')); if ($ucresult > 0) { return true; } else { $this->error = ERR_INVALID_PASSWORD; return false; } } elseif (!empty($cfg['password']) && $forget_pwd == 1) { $ucresult = uc_call("uc_user_edit", array($real_username, '', $cfg['password'], '', '1')); if ($ucresult > 0) { $flag = true; } } return true; }
<?php define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; if (empty($_SESSION['user_id'])) { ecs_header('Location:./'); } uc_call("uc_pm_location", array($_SESSION['user_id'])); //$ucnewpm = uc_pm_checknew($_SESSION['user_id']); //setcookie('checkpm', '');
private function check_email($email) { if (!empty($email)) { $email_exist = uc_call('uc_user_checkemail', array($email)); if ($email_exist == 1) { return false; } else { return true; } } return true; }
/** * 通过判断is_feed 向UCenter提交Feed * * @access public * @param integer $value_id $order_id or $comment_id * @param interger $feed_type BUY_GOODS or COMMENT_GOODS * @return array */ function add_feed($id, $feed_type) { $feed = array(); if ($feed_type == BUY_GOODS) { if (empty($id)) { return; } $order_res = $GLOBALS['db']->getAll("SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_desc, g.goods_thumb, o.goods_price\r\n FROM " . $GLOBALS['ecs']->table('order_goods') . " AS o, " . $GLOBALS['ecs']->table('goods') . " AS g\r\n WHERE o.order_id={$id} AND o.goods_id=g.goods_id"); foreach ($order_res as $goods_data) { $url = $GLOBALS['ecs']->url() . $goods_data['goods_thumb']; $link = $GLOBALS['ecs']->url() . "goods.php?id=" . $goods_data["goods_id"]; $feed['icon'] = "goods"; $feed['title_template'] = '<b>{username}' . $GLOBALS['_LANG']['feed_user_buy'] . '{goods_name}</b>'; $feed['title_data'] = array('username' => $_SESSION['user_name'], 'goods_name' => $goods_data['goods_name']); $feed['body_template'] = '<h3>{goods_name}</h3><br/>' . $GLOBALS['_LANG']['feed_goods_price'] . ':{goods_price}<br/>' . $GLOBALS['_LANG']['feed_goods_desc'] . ':{goods_desc}'; $feed['body_data'] = array('goods_name' => $goods_data['goods_name'], 'goods_price' => $goods_data['goods_price'], 'goods_desc' => sub_str($goods_data['goods_desc'], 0, 150)); $feed['images'][] = array('url' => $url, 'link' => $link); uc_call("uc_feed_add", array($feed['icon'], $_SESSION['user_id'], $_SESSION['user_name'], $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images'])); } } return; }
<?php /** * ECSHOP 短消息文件 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: pm.php 17217 2011-01-19 06:29:08Z liubo $. */ define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; if (empty($_SESSION['user_id']) || $_CFG['integrate_code'] == 'ecshop') { ecs_header('Location:./'); } uc_call('uc_pm_location', array($_SESSION['user_id'])); //$ucnewpm = uc_pm_checknew($_SESSION['user_id']); //setcookie('checkpm', '');
/** * 会员等级、会员、会员价格 */ function process_users() { global $db, $ecs; /* 清空会员、会员等级、会员价格、用户红包、用户地址 */ truncate_table('user_rank'); truncate_table('users'); truncate_table('user_address'); truncate_table('user_bonus'); truncate_table('member_price'); truncate_table('user_account'); /* 查询并插入会员等级 */ $sql = "SELECT * FROM " . $this->sprefix . "mall_member_level order by point desc"; $res = $this->sdb->query($sql); $max_points = 50000; while ($row = $this->sdb->fetchRow($res)) { $user_rank = array(); $user_rank['rank_id'] = $row['levelid']; $user_rank['rank_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['name'])); $user_rank['min_points'] = $row['point']; $user_rank['max_points'] = $max_points; $user_rank['discount'] = round($row['discount'] * 100); $user_rank['show_price'] = '1'; $user_rank['special_rank'] = '0'; if (!$db->autoExecute($ecs->table('user_rank'), $user_rank, 'INSERT', '', 'SILENT')) { //return $db->error(); } $max_points = $row['point'] - 1; } /* 查询并插入会员 */ $sql = "SELECT * FROM " . $this->sprefix . "mall_member"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $user = array(); $user['user_id'] = $row['userid']; $user['email'] = $row['email']; $user['user_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['user'])); $user['password'] = $row['password']; $user['question'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['pw_question'])); $user['answer'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['pw_answer'])); $user['sex'] = $row['sex']; if (!empty($row['birthday'])) { $birthday = strtotime($row['birthday']); if ($birthday != -1 && $birthday !== false) { $user['birthday'] = date('Y-m-d', $birthday); } } $user['user_money'] = $row['advance']; $user['pay_points'] = $row['point']; $user['rank_points'] = $row['point']; $user['reg_time'] = $row['regtime']; $user['last_login'] = $row['regtime']; $user['last_ip'] = $row['ip']; $user['visit_count'] = '1'; $user['user_rank'] = '0'; if (!$db->autoExecute($ecs->table('users'), $user, 'INSERT', '', 'SILENT')) { //return $db->error(); } uc_call('uc_user_register', array($user['user_name'], $user['password'], $user['email'])); } /* 收货人地址 */ $sql = "SELECT * FROM " . $this->sprefix . "mall_member_receiver"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $address = array(); $address['address_id'] = $row['receiveid']; $address['address_name'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['name'])); $address['user_id'] = $row['memberid']; $address['consignee'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['name'])); $address['email'] = $row['email']; $address['address'] = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['address'])); $address['zipcode'] = $row['zipcode']; $address['tel'] = $row['telphone']; $address['mobile'] = $row['mobile']; if (!$db->autoExecute($ecs->table('user_address'), $address, 'INSERT', '', 'SILENT')) { //return $db->error(); } } /* 会员价格 */ $temp_arr = array(); $sql = "SELECT * FROM " . $this->sprefix . "mall_member_price"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { if ($row['gid'] > 0 && $row['levelid'] > 0 && !isset($temp_arr[$row['gid']][$row['levelid']])) { $temp_arr[$row['gid']][$row['levelid']] = true; $member_price = array(); $member_price['goods_id'] = $row['gid']; $member_price['user_rank'] = $row['levelid']; $member_price['user_price'] = $row['price']; if (!$db->autoExecute($ecs->table('member_price'), $member_price, 'INSERT', '', 'SILENT')) { //return $db->error(); } } } unset($temp_arr); /* 帐户明细 */ $sql = "SELECT * FROM " . $this->sprefix . "mall_member_advance"; $res = $this->sdb->query($sql); while ($row = $this->sdb->fetchRow($res)) { $user_account = array(); $user_account['user_id'] = $row['memberid']; $user_account['admin_user'] = $row['doman']; $user_account['amount'] = $row['money']; $user_account['add_time'] = $row['date']; $user_account['paid_time'] = $row['date']; $user_account['admin_note'] = $row['description']; $user_account['process_type'] = $row['money'] >= 0 ? SURPLUS_SAVE : SURPLUS_RETURN; $user_account['is_paid'] = '1'; if (!$db->autoExecute($ecs->table('user_account'), $user_account, 'INSERT', '', 'SILENT')) { //return $db->error(); } } /* 返回 */ return TRUE; }
function edit_user($cfg, $forget_pwd = '0') { $real_username = $cfg['username']; $cfg['username'] = addslashes($cfg['username']); $set_str = ''; $valarr = array('email' => 'email', 'gender' => 'sex', 'bday' => 'birthday'); foreach ($cfg as $key => $val) { if ($key == 'username' || $key == 'password' || $key == 'old_password') { continue; } $set_str .= $valarr[$key] . '=' . "'{$val}',"; } $set_str = substr($set_str, 0, -1); if (!empty($set_str)) { $sql = "UPDATE " . model('Base')->model->pre . "users SET {$set_str} WHERE user_name = '{$cfg['username']}'"; model('Base')->model->query($sql); $flag = true; } // 判断 email 是否进行修改 $data = uc_call("uc_get_user", array($cfg['username'], '0')); list($uid, $username, $email) = $data; if ($cfg['email'] != $email && !empty($cfg['email'])) { if ($this->check_email($cfg['email'])) { $this->error = ERR_EMAIL_EXISTS; return false; } else { $ucresult = uc_call("uc_user_edit", array($cfg['username'], '', '', $cfg['email'], 1)); if ($ucresult > 0) { $flag = true; } elseif ($ucresult == -4) { // echo 'Email 格式有误'; $this->error = ERR_INVALID_EMAIL; return false; } elseif ($ucresult == -5) { // echo 'Email 不允许注册'; $this->error = ERR_INVALID_EMAIL; return false; } elseif ($ucresult == -6) { // echo '该 Email 已经被注册'; $this->error = ERR_EMAIL_EXISTS; return false; } elseif ($ucresult < 0) { return false; } } } if (!empty($cfg['old_password']) && !empty($cfg['password']) && $forget_pwd == 0) { $ucresult = uc_call("uc_user_edit", array($real_username, $cfg['old_password'], $cfg['password'], '')); if ($ucresult > 0) { return true; } else { $this->error = ERR_INVALID_PASSWORD; return false; } } elseif (!empty($cfg['password']) && $forget_pwd == 1) { $ucresult = uc_call("uc_user_edit", array($real_username, '', $cfg['password'], '', '1')); if ($ucresult > 0) { $flag = true; } } return true; }