Пример #1
0
	/**
	 * 添加规则
	 */
	public function add() {
		if (isset($_POST['dosubmit'])) {
			$ruledata['fromid'] = isset($_POST['fromid']) ? intval($_POST['fromid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
			$ruledata['toid'] = isset($_POST['toid']) ? intval($_POST['toid']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
			$ruledata['fromrate'] = isset($_POST['fromrate']) ? intval($_POST['fromrate']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
			$ruledata['torate'] = isset($_POST['torate']) ? intval($_POST['torate']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
			if(empty($_POST['from']) || empty($_POST['to'])) {
				showmessage(L('illegal_parameters'), HTTP_REFERER);
			}
			$fromarr = explode('_', $_POST['from']);
			$toarr = explode('_', $_POST['to']);
			$ruledata['from'] = isset($fromarr[0]) ? $fromarr[0] : '';
			$ruledata['fromname'] = isset($fromarr[1]) ? $fromarr[1] : '';
			$ruledata['fromunit'] = isset($fromarr[2]) ? $fromarr[2] : '';
			$ruledata['to'] = isset($toarr[0]) ? $toarr[0] : '';
			$ruledata['toname'] = isset($toarr[1]) ? $toarr[1] : '';
			$ruledata['tounit'] = isset($toarr[2]) ? $toarr[2] : '';
			
			$creditlistarr = $this->db->get_one(array('name'=>'creditrate'));
			
			$creditlist = string2array($creditlistarr['data']);
			$creditlist[] = $ruledata;
			$noticedata['creditlist'] = $creditlist;
			//加入消息队列
			messagequeue::add('credit_update', $noticedata);
			
			setcache('creditlist', $creditlist);
			$this->db->insert(array('name'=>'creditrate', 'data'=>array2string($creditlist)), 1, 1);
			showmessage(L('operation_success'), HTTP_REFERER);
		}
		$applist = getcache('applist');
	
		include $this->admin_tpl('credit_add');
	}
Пример #2
0
 /**
  * 删除会员
  */
 public function delete()
 {
     $uidarr = isset($_POST['uid']) ? $_POST['uid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
     $new_arr = array();
     foreach ($uidarr as $v) {
         $v = intval($v);
         $new_arr[] = $v;
         //删除头像
         $dir = ps_getavatar($v, 1);
         ps_unlink($dir);
     }
     $where = to_sqls($new_arr, '', 'uid');
     //ucenter部份
     if ($this->config['ucuse']) {
         pc_base::load_config('uc_config');
         include PHPCMS_PATH . 'api/uc_client/client.php';
         $s = $this->db->select($where, 'ucuserid');
         if ($s) {
             $uc_data = array();
             foreach ($s as $k => $v) {
                 $uc_data[$k] = $v['ucuserid'];
             }
             if (!empty($uc_data)) {
                 $r = uc_user_delete($uc_data);
             }
             if (!$r) {
                 showmessage(L('operation_failure'), HTTP_REFERER);
             }
         } else {
             showmessage(L('operation_failure'), HTTP_REFERER);
         }
     }
     if ($this->db->delete($where)) {
         /*插入消息队列*/
         $noticedata = array('uids' => $new_arr);
         messagequeue::add('member_delete', $noticedata);
         showmessage(L('operation_success'), HTTP_REFERER);
     } else {
         showmessage(L('operation_failure'), HTTP_REFERER);
     }
 }
Пример #3
0
 public function synlogin($get, $post)
 {
     header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     $uid = intval($get['uid']);
     if (empty($uid)) {
         return API_RETURN_FAILED;
     }
     //获取UC中用户的信息
     $r = $this->uc_db->get_one(array('uid' => $uid));
     if ($data = $this->member_db->get_one(array('ucuserid' => $uid))) {
         //当用户存在时,获取用户的登陆信息
         $this->member_db->update(array('lastip' => $r['lastloginip'], 'lastdate' => $r['lastlogindate']), array('uid' => $data['uid']));
     } else {
         //当用户不存在是注册新用户
         $datas = $data = array('username' => $r['username'], 'password' => $r['password'], 'random' => $r['salt'], 'email' => $r['email'], 'regip' => $r['regip'], 'regdate' => $r['regdate'], 'lastdate' => $r['lastlogindate'], 'appname' => 'ucenter', 'type' => 'app');
         $datas['ucuserid'] = $uid;
         $datas['lastip'] = $r['lastloginip'];
         if ($s = $this->member_db->get_one(array('username' => $r['username']))) {
             $this->member_db->update($datas, array('uid' => $s['uid']));
             $data['uid'] = $s;
         } else {
             $data['uid'] = $this->member_db->insert($datas, true);
         }
         //向所有的应用中发布新用户注册通知
         pc_base::load_app_func('global', 'admin');
         pc_base::load_app_class('messagequeue', 'admin', 0);
         messagequeue::add('member_add', $data);
     }
     //输出应用登陆
     $res = '';
     foreach ($this->applist as $v) {
         if (!$v['synlogin']) {
             continue;
         }
         $f = strstr($v['url'] . $v['apifilename'], '?') ? '&' : '?';
         $res .= '<script type="text/javascript" src="' . $v['url'] . $v['apifilename'] . $f . 'time=' . SYS_TIME . '&code=' . urlencode(sys_auth('action=synlogin&username=&uid=' . $data['uid'] . '&password=&time=' . SYS_TIME, 'ENCODE', $v['authkey'])) . '" reload="1"></script>';
     }
     header("Content-type: text/javascript");
     return format_js($res);
 }
Пример #4
0
	/**
	 * 兑换积分
	 * @param int $uid			phpssouid
	 * @param int $from			本系统积分类型id
	 * @param int $toappid 		目标系统应用appid
	 * @param int $to			目标系统积分类型id
	 * @param int $credit		本系统扣除积分数
	 * @return bool 			{1:成功;0:失败}
	 */
	public function changecredit() {
		$this->uid = isset($this->data['uid']) ? $this->data['uid'] : exit('0');
		$this->toappid = isset($this->data['toappid']) ? $this->data['toappid'] : exit('0');
		$this->from = isset($this->data['from']) ? $this->data['from'] : exit('0');
		$this->to = isset($this->data['to']) ? $this->data['to'] : exit('0');
		$this->credit = isset($this->data['credit']) ? $this->data['credit'] : exit('0');
		$this->appname = $this->applist[$this->appid]['name'];
		$outcredit = $this->getcredit(1);
		//目标系统积分增加数
		$this->credit = floor($this->credit * $outcredit[$this->from.'_'.$this->to]['torate'] / $outcredit[$this->from.'_'.$this->to]['fromrate']);
			
		/*插入消息队列*/
		$noticedata['appname'] = $this->appname;
		$noticedata['uid'] = $this->uid;
		$noticedata['toappid'] = $this->toappid;
		$noticedata['totypeid'] = $this->to;
		$noticedata['credit'] = $this->credit;
		messagequeue::add('change_credit', $noticedata);
		exit('1');
	}