示例#1
0
	/**
	 * 重新通知
	 */
	public function renotice() {
		$noticeid = isset($_POST['noticeid']) ? $_POST['noticeid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
		$appid = isset($_POST['appid']) ? $_POST['appid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
		if ($noticeinfo = $this->db->get_one(array('id'=>$noticeid))) {
			//通知app noticedata 返回通知成功的appid 1
			//debug post appid.phpsso.php?data=noticeinfo[noticedata];
			$applist = getcache('applist');
			$url = $applist[$appid]['url'].$applist[$appid]['apifilename'];
			$data = string2array($noticeinfo['noticedata']);
			$data['action'] = $noticeinfo['operation'];
			
			//转换中文编码
			if (CHARSET != $applist[$appid]['charset'] && isset($data['action']) && $data['action'] == 'member_add') {
				if(isset($data['username']) && !empty($data['username'])) {
					if(CHARSET == 'utf-8') {	//判断phpsso字符集是否为utf-8编码
						//应用字符集如果是utf-8,并且用户名是utf-8编码,转换用户名为phpsso字符集,如果为英文,is_utf8返回false,不进行转换
						if(!is_utf8($data['username'])) {
							$data['username'] = iconv(CHARSET, $applist[$appid]['charset'], $data['username']);
						}
					} else {
						if(!is_utf8($data['username'])) {
							$data['username'] = iconv(CHARSET, $applist[$appid]['charset'], $data['username']);
						}
					}
				}
			}
			$tmp_s = strstr($url, '?') ? '&' : '?';
			$status = ps_send($url.$tmp_s.'appid='.$appid, $data, $applist[$appid]['authkey']);

			//通信次数+1
			$this->db->update(array('totalnum'=>'+=1', 'dateline'=>SYS_TIME), array('id'=>$noticeid));
			
			if($status == 1) {
				//重置消息队列app通信状态
				$appstatusarr = json_decode($noticeinfo['appstatus'], 1);
				$appstatusarr[$appid] = 1;
				$appstatus = json_encode($appstatusarr);
				
				//全部通知成功后更新消息队列状态
				if (!strstr($appstatus, ':0')) {
					$this->db->update(array('succeed'=>1), array('id'=>$noticeid));
				}
				
				//更新消息队列
				$this->db->update(array('appstatus'=>$appstatus), array('id'=>$noticeid));
				exit('1');
			} else {
				exit('0');
			}
		} else {
			exit('0');
		}
	}
示例#2
0
 /**
  * 获取应用积分列表
  */
 public function creditlist()
 {
     $appid = isset($_GET['appid']) ? $_GET['appid'] : exit('0');
     $applist = getcache('applist');
     $url = isset($applist[$appid]) ? $applist[$appid]['url'] . $applist[$appid]['apifilename'] : exit('0');
     $data['action'] = 'credit_list';
     $res = ps_send($url . '&appid=' . $appid, $data, $applist[$appid]['authkey']);
     if (!empty($res)) {
         $creditlist = string2array($res);
         $str = '';
         foreach ($creditlist as $k => $v) {
             $str .= "<option value=" . $k . '_' . $v[0] . '_' . $v[1] . ">" . $v[0] . "(" . $v[1] . ")</option>";
         }
         echo $str;
         exit;
     } else {
         exit('0');
     }
 }
示例#3
0
 /**
  * 通知应用
  */
 public static function notice($operation, $noticedata, $noticeid)
 {
     $db = self::get_db();
     $applist = getcache('applist', 'admin');
     foreach ($applist as $k => $v) {
         //由于编码转换会改变notice_send的值,所以每次循环需要重新赋值noticedate_send
         $noticedata_send = $noticedata;
         //应用添加用户时不重复通知该应用
         if (isset($noticedata_send['appname']) && $noticedata_send['appname'] == $v['name']) {
             $appstatus[$k] = 1;
             continue;
         }
         $url = $v['url'] . $v['apifilename'];
         if (CHARSET != $v['charset'] && isset($noticedata_send['action']) && $noticedata_send['action'] == 'member_add') {
             if (isset($noticedata_send['username']) && !empty($noticedata_send['username'])) {
                 if (CHARSET == 'utf-8') {
                     //判断phpsso字符集是否为utf-8编码
                     //应用字符集如果是utf-8,并且用户名是utf-8编码,转换用户名为phpsso字符集,如果为英文,is_utf8返回false,不进行转换
                     if (!is_utf8($noticedata_send['username'])) {
                         $noticedata_send['username'] = iconv(CHARSET, $v['charset'], $noticedata_send['username']);
                     }
                 } else {
                     if (!is_utf8($noticedata_send['username'])) {
                         $noticedata_send['username'] = iconv(CHARSET, $v['charset'], $noticedata_send['username']);
                     }
                 }
             }
         }
         $tmp_s = strstr($url, '?') ? '&' : '?';
         $status = ps_send($url . $tmp_s . 'appid=' . $k, $noticedata_send, $v['authkey']);
         if ($status == 1) {
             $appstatus[$k] = 1;
         } else {
             $appstatus[$k] = 0;
         }
     }
     $db->update(array('totalnum' => '+=1', 'appstatus' => json_encode($appstatus)), array('id' => $noticeid));
 }