Ejemplo n.º 1
0
 protected function checkOnline()
 {
     $dao = D("Online");
     // 记录最后访问时间
     $map = new HashMap();
     $ip = ip2long(get_client_ip());
     $map->put('activeTime', time());
     $map->put('userId', $this->mid);
     $map->put('uri', $_SERVER['PHP_SELF']);
     if ($online = $dao->getBy('onlineIp', $ip)) {
         // 已经存在 更新最后访问时间
         $map->put('id', $online->id);
         $dao->save($map);
     } else {
         $map->put('onlineIp', $ip);
         $dao->add($map);
     }
     // 归档并删除24小时未在线用户
     $dao->deleteAll("(activeTime+86000)<" . time());
     // 15分钟活动用户
     $count[] = $dao->count("(activeTime+900)>=" . time());
     // 24小时活动用户
     $count[] = $dao->count("(activeTime+900)<" . time());
     return $count;
 }
Ejemplo n.º 2
0
 function testPutSameElementTwice()
 {
     $map = new HashMap("integer", "string");
     $map->put(4, "Peter");
     $map->put(4, "Raf");
     $this->assertEqual(1, $map->size());
     $this->assertEqual("Raf", $map->get(4));
 }
Ejemplo n.º 3
0
 public function addAll(HashMap $items)
 {
     if ($items->size() < 1) {
         return false;
     }
     foreach ($items->getAll() as $itemKey => $itemValue) {
         $this->add($itemKey, $itemValue);
     }
     return true;
 }
Ejemplo n.º 4
0
function getCommentCount($recordId, $module)
{
    //评论数量
    $map = new HashMap();
    $map->put('recordId', $recordId);
    $map->put('module', $module);
    $dao = D("Comment");
    $count = $dao->count($map);
    return $count;
}
Ejemplo n.º 5
0
 public function testOffsetUnset()
 {
     $arr = ['a' => '111', 'b' => '222'];
     $hash = new HashMap($arr);
     $this->assertTrue(isset($hash['a']));
     unset($hash['a']);
     $this->assertFalse(isset($hash['a']));
     $this->assertTrue(isset($hash['b']));
     $hash->offsetUnset();
     $this->assertFalse(isset($hash['b']));
 }
Ejemplo n.º 6
0
 /**
  * @depends      test_getIterator_any_returnsCorrectInstance
  * @dataProvider provide_rangeZeroToN
  */
 function test_containsN_returnsKeyValuePairCorrectly($dataToAdd)
 {
     $map = new HashMap();
     foreach ($dataToAdd as $key => $value) {
         $map[$key] = $value;
     }
     foreach ($map->getIterator() as $key => $value) {
         $expect = $dataToAdd[$key];
         $this->assertEquals($expect, $value);
     }
 }
Ejemplo n.º 7
0
 function sendbox()
 {
     $map = new HashMap();
     $map->put('fromUserId', $this->mid);
     $dao = D("Message");
     $count = $dao->count($map);
     $this->assign('msgNum', $count);
     $rows = '10';
     $p = new Page($count, $rows);
     $voList = $dao->findAll($map, '*', 'cTime desc', $p->firstRow . ',' . $p->listRows);
     $page = $p->show();
     $this->assign('list', $voList);
     $this->assign("page", $page);
     $this->display();
 }
Ejemplo n.º 8
0
 /**
  * コンストラクタの引数の型に応じた初期データが生成されることを確認します.
  * 
  * @covers Peach\Util\ArrayMap::__construct
  */
 public function testConstructor()
 {
     $obj1 = new ArrayMap();
     $this->assertSame(0, $obj1->size());
     $obj2 = new ArrayMap(array("foo" => 1, "bar" => 10, "hoge" => 200));
     $this->assertSame(3, $obj2->size());
     $obj3 = new ArrayMap($this->object);
     $this->assertSame($this->object->asArray(), $obj3->asArray());
     $hashMap = new HashMap();
     $hashMap->put(new ArrayMapTest_Object("key1"), 100);
     $hashMap->put(new ArrayMapTest_Object("key2"), 200);
     $hashMap->put(new ArrayMapTest_Object("key3"), 300);
     $obj4 = new ArrayMap($hashMap);
     $this->assertSame(200, $obj4->get("Test:key2"));
 }
Ejemplo n.º 9
0
 public function testRetainAll()
 {
     // Remove the following lines when you implement this test.
     $map = new HashMap();
     $map->put(1, 1);
     $map->put(2, 5);
     $map->put(3, 3);
     $this->object->retainAll($map);
 }
Ejemplo n.º 10
0
 /**
  * Tests HashMap->put()
  */
 public function testPut()
 {
     //组织请求参数
     //		$map = new HashMap();
     //		$map->put("merId","9996");
     //		$map->put("orderId",rand(100000,999999));
     //		$map->put("merDate",date("Ymd"));
     //		$map->put("amount","1");
     //		$map->put("version","3.0");
     //后台直连下订单
     //		$map = new HashMap();
     //		$map->put("merId", "9996");
     //		$map->put("goodsId", "1001");
     //		$map->put("mobileId", "13720040275");
     //		$map->put("orderId", "467242");
     //		$map->put("merDate", "20100402");
     //		$map->put("amount", "1");
     //		$map->put("amtType", "01");
     //		$map->put("bankType", "3");
     //		$map->put("notyfuUrl", "http://pay.test.umpay.com/pay/test/testNotify.jsp");
     //		$map->put("merPriv", "");
     //		$map->put("expand", "");
     //		$map->put("version", "3.0");
     //订单查询
     $map = new HashMap();
     $map->put("merId", "9996");
     $map->put("goodsId", "100");
     $map->put("orderId", "236798");
     $map->put("merDate", "20100302");
     $map->put("mobileId", "13910173623");
     $map->put("version", "3.0");
     //获取请求数据对象
     //		$reqData = MerToPlat::cancelByGet($map);//商户撤销
     //		$reqData = MerToPlat::directPayByGet($map);//后台直连下单
     $reqData = MerToPlat::queryTransByGet($map);
     //订单
     //获取请求URL
     $url = $reqData->getUrl();
     //		echo "\n" . $url;
     //请求平台取得平台响应结果
     $html = file_get_contents($url);
     //		echo "\n".$html;
     //解析平台响应数据
     //		$resData = PlatToMer::getCancelByHtml($html);//商户撤销职务
     //		$resData = PlatToMer::getDirectPayByHtml($html);//后台直连下单
     $resData = PlatToMer::getQueryTransByHtml($html);
     $retCode = $resData->get("retCode");
     //判断退费结果,retCode=0000为成功,其他为失败,
     if ($retCode == "0000") {
         echo "\n商户退费成功";
     } else {
         echo "\n商户退失败,响应码:" . $retCode;
     }
 }
Ejemplo n.º 11
0
 function index()
 {
     $userId = $this->uid;
     //我的留言
     $dao = D('Wall');
     $map = new HashMap();
     $map->put("userId", $userId);
     $count = $dao->count($map);
     $this->assign('count', $count);
     $listRows = 10;
     $p = new Page($count, $listRows);
     $voList = $dao->findAll($map, '*', 'cTime desc', $p->firstRow . ',' . $p->listRows);
     $page = $p->show();
     $this->assign('userId', $userId);
     $this->assign('guestId', $this->mid);
     $this->assign('list', $voList);
     $this->assign("page", $page);
     $this->display();
 }
Ejemplo n.º 12
0
 function addFriend($friendId, $userId)
 {
     if ($friendId == $userId) {
         return '-1';
     }
     $count = $this->getCount("friendId='{$friendId}' AND userId='{$userId}'");
     if ($count > 0) {
         return '-2';
     }
     $map = new HashMap();
     $map->put('friendId', $friendId);
     $map->put('userId', $userId);
     $map->put('cTIme', time());
     if ($result = $this->add($map)) {
         return $result;
     } else {
         return '-3';
     }
 }
Ejemplo n.º 13
0
 public function __construct($get, $post, $files)
 {
     $this->get = HashMap::fromArray("string", "?", $get);
     $this->post = HashMap::fromArray("string", "?", $post);
     $this->files = $files;
     $this->postVars = new ArrayList("MovicoPostVar");
     foreach ($post as $name => $value) {
         if (String::create($name)->startsWith("#")) {
             $type = isset($post[self::TYPE_PREFIX . $name]) ? $post[self::TYPE_PREFIX . $name] : self::DEFAULT_TYPE;
             $this->postVars->add(new MovicoPostVar($name, $value, $type));
         }
     }
 }
Ejemplo n.º 14
0
 public function index()
 {
     //个人信息
     $dao = D('User');
     $list = $dao->find($this->mid);
     $this->assign("user", $list);
     //我的通知
     $dao = D('Notify');
     $map = new HashMap();
     $map->put("toUserId", $this->mid);
     $map->put("status", '0');
     $alertCount = $dao->count($map);
     $list = $dao->findAll($map, '*', 'cTime desc');
     $this->assign('notify', $list);
     $this->assign('notifyCount', $alertCount);
     //最新注册的会员
     $members = D('User')->findAll('', 'id,name', 'cTime desc', '12');
     $this->assign('members', $members);
     //好友动态
     //$friendFeed	=	D('UserFeed')->findAll('','*','cTime desc');
     //$this->assign('friendFeed',$friendFeed);
     $this->display();
 }
Ejemplo n.º 15
0
 /**
  * @return HashMap
  */
 public function getCotacoes()
 {
     $map = new CodeMap();
     $values = new HashMap();
     $values->put("BMF", new ArrayIterator());
     $values->put("London", new ArrayIterator());
     $values->put("NY", new ArrayIterator());
     $values->put("Dolar", new ArrayIterator());
     $values->put("Euro", new ArrayIterator());
     $values->put("Arabica", new ArrayIterator());
     $values->put("IBovespa", new ArrayIterator());
     $dateMap = new DateMap();
     $classifier = new Classifier($dateMap);
     foreach ($this->json as $cotacao) {
         $cotation = $classifier->classify($cotacao);
         if ($cotation != null) {
             $cotation->setJsonInfo($cotacao);
             $values->get($cotation->type())->append($cotation);
         }
         $cot = new Cotacao();
     }
     return $values;
 }
Ejemplo n.º 16
0
 public static function restSubscribe()
 {
     self::initRequests();
     if (strpos(self::link(), "?") !== false) {
         $link = substr(self::link(), 0, strpos(self::link(), "?"));
     } else {
         $link = self::link();
     }
     if (!Session::isLogged()) {
         if (self::$map_requests->containsKey($link)) {
             if (file_exists(self::$map_requests->get($link))) {
                 return self::$map_requests->get($link);
             }
             throw new FileNotFoundException("Arquivo de requisição não encontrado!");
         }
         throw new Exception("Destino não encontrado!");
     } else {
         throw new LoginException('Você não pode realizar seu cadastro com um usuário online.');
     }
 }
Ejemplo n.º 17
0
 private function rssItemsToMap()
 {
     if ($this->map->isEmpty()) {
         $i = 0;
     } else {
         $i = $this->map->size() + 1;
     }
     foreach ($this->rss->channel->item as $item) {
         $itemMap = new HashMap();
         $itemMap->put("title", $item->title);
         $itemMap->put("link", $item->link);
         $itemMap->put("pubDate", $item->pubDate);
         $itemMap->put("description", $item->description);
         $this->map->put($i++, $itemMap);
     }
 }
Ejemplo n.º 18
0
 function inviteEmail()
 {
     $toEmails = $_POST['invites'];
     $emailCount = count($toEmails);
     $dao = D("User");
     $userInfo = $dao->getById(Session::get(C('USER_AUTH_KEY')));
     foreach ($toEmails as $k => $toEmail) {
         $rand = rand(1111, 9999);
         $toEmail = trim($toEmail);
         $code = base64_encode($toEmail . "|" . md5($toEmail . $rand));
         $map = new HashMap();
         $map->put('email', $toEmail);
         $map->put('active', $rand);
         $map->put('inviteUser', Session::get(C('USER_AUTH_KEY')));
         $dao = D('User');
         if ($id = $dao->add($map)) {
             $code = "http://" . $_SERVER['HOST_NAME'] . __APP__ . "/Public/activate/code/" . $code;
             $face = str_replace(WEB_PUBLIC_URL . '/Uploads/', "http://" . $_SERVER['HOST_NAME'] . WEB_PUBLIC_URL . '/Uploads/', $userInfo->face);
             $this->assign('fromuser', $userInfo->name);
             $this->assign('code', $code);
             $this->assign('face', $face);
             $content = $this->fetch('mail');
             $title = $userInfo->name . "邀请您体验ThinkSNS!\n";
             import('@.Util.sendmail');
             if (sendemail($toEmail, $title, $content)) {
                 $success_info .= "<li>{$toEmail} 发送成功!</li>\n";
             } else {
                 $success_info .= "<li><font color=red>{$toEmail} 发送失败!</font></li>\n";
             }
         }
     }
     $this->assign('count', $emailCount);
     $this->assign('info', $success_info);
     $this->display();
 }
Ejemplo n.º 19
0
</head>
<?php 
require_once 'mer2Plat.php';
$service = $_REQUEST['service'];
$charset = $_REQUEST['charset'];
$mer_id = $_REQUEST['mer_id'];
$sign_type = $_REQUEST['sign_type'];
$res_format = $_REQUEST['res_format'];
$version = $_REQUEST['version'];
$trade_no = $_REQUEST['trade_no'];
//使用协议进行支付,上送如下参数:支付协议号必填、商户用户标识和用户业务协议号必填其一
$mer_cust_id = $_REQUEST['mer_cust_id'];
$usr_busi_agreement_id = $_REQUEST['usr_busi_agreement_id'];
$usr_pay_agreement_id = $_REQUEST['usr_pay_agreement_id'];
$map = new HashMap();
$map->put("service", $service);
$map->put("charset", $charset);
$map->put("mer_id", $mer_id);
$map->put("sign_type", $sign_type);
$map->put("res_format", $res_format);
$map->put("version", $version);
$map->put("trade_no", $trade_no);
//使用协议进行支付,上送如下参数:支付协议号必填、商户用户标识和用户业务协议号必填其一
$map->put("mer_cust_id", $mer_cust_id);
$map->put("usr_busi_agreement_id", $usr_busi_agreement_id);
$map->put("usr_pay_agreement_id", $usr_pay_agreement_id);
$reqData = MerToPlat::makeRequestDataByGet($map);
//这个是重要的
$sign = $reqData->getSign();
//这个是为了在本DEMO中显示签名结果。
Ejemplo n.º 20
0
$settle_date = $data->get("settle_date");
$mer_priv = $data->get("mer_priv");
$trade_state = $data->get("trade_state");
$pay_seq = $data->get("pay_seq");
$error_code = $data->get("error_code");
$gate_id = $data->get("gate_id");
$identity_type = $data->get("identity_type");
$identity_code = $data->get("identity_code");
$card_holder = $data->get("card_holder");
$last_four_cardid = $data->get("last_four_cardid");
$usr_busi_agreement_id = $data->get("usr_busi_agreement_id");
$usr_pay_agreement_id = $data->get("usr_pay_agreement_id");
$version = $data->get("version");
$sign = $data->get("sign");
//获取UMPAY平台请求商户的支付结果通知数据,并对请求数据进行验签,此时商户接收到的支付结果通知会存放在这里,商户可以根据此处的trade_state订单状态来更新订单
$resData = new HashMap();
try {
    //获取UMPAY平台请求商户的支付结果通知数据,并对请求数据进行验签
    //如验证平台签名正确,即应响应UMPAY平台返回码为0000。【响应返回码代表通知是否成功,和通知的交易结果(支付失败、支付成功)无关】
    //验签支付结果通知 如验签成功,则返回ret_code=0000
    $reqData = PlatToMer::getNotifyRequestData($data);
    $resData->put("ret_code", "0000");
} catch (Exception $e) {
    //如果验签失败,则抛出异常,返回ret_code=1111
    System . out . printf("验证签名发生异常" + $e);
    $resData->put("ret_code", "1111");
}
//验签后的数据都组织在resData中。
//生成平台响应UMPAY平台数据,将该串放入META标签,以下几个参数为结果通知必备参数
//生成平台响应UMPAY平台数据,将该串放入META标签
$resData->put("mer_id", $data->get("mer_id"));
 protected function groupedList()
 {
     //map <int, ArrayList<Data>>
     $map = new HashMap();
     $arrayList = new ArrayObject();
     $arrayList->append($this->newData(1989, 150));
     $arrayList->append($this->newData(1990, 220));
     $arrayList->append($this->newData(1991, 285));
     $map->put(0, $arrayList);
     $arrayList = new ArrayObject();
     $arrayList->append($this->newAnotherData(1989, 188));
     $arrayList->append($this->newAnotherData(1990, 302));
     $arrayList->append($this->newAnotherData(1991, 254));
     $arrayList->append($this->newAnotherData(1992, 195));
     $map->put(1, $arrayList);
     $arrayList = new ArrayObject();
     $arrayList->append($this->newOtherData(1990, 101));
     $arrayList->append($this->newOtherData(1991, 148));
     $arrayList->append($this->newOtherData(1992, 157));
     $map->put(2, $arrayList);
     return $map;
 }
Ejemplo n.º 22
0
	<link type="text/css" rel="stylesheet" href="../common/syntaxHighlighter/css/SyntaxHighlighter.css"></link>
	<script language="javascript" src="../common/syntaxHighlighter/js/shCore.js"></script>
	<script language="javascript" src="../common/syntaxHighlighter/js/shBrushPhp.js"></script>

  </head>
<?php 
//引入API文件
require_once 'mer2Plat.php';
$service = $_REQUEST['service'];
$charset = $_REQUEST['charset'];
$mer_id = $_REQUEST['mer_id'];
$sign_type = $_REQUEST['sign_type'];
$res_format = $_REQUEST['res_format'];
$version = $_REQUEST['version'];
$refund_no = $_REQUEST['refund_no'];
$map = new HashMap();
$map->put("service", $service);
$map->put("charset", $charset);
$map->put("mer_id", $mer_id);
$map->put("sign_type", $sign_type);
$map->put("res_format", $res_format);
$map->put("refund_no", $refund_no);
$map->put("version", $version);
$reqData = MerToPlat::requestTransactionsByGet($map);
$sign = $reqData->getSign();
//这个是为了在本DEMO中显示签名结果。
$plain = $reqData->getPlain();
//这个是为了在本DEMO中显示签名原串
$url = $reqData->getUrl();
?>
Ejemplo n.º 23
0
 /**
  * V4.0获取商户分账退费结果通知平台请求数据签名明文串
  * @param $map	请求数据
  */
 private static function getSplitMerRefundNotifyPlain($map)
 {
     $data = new HashMap();
     $service = StringUtil::trim($map->get("service"));
     $charset = StringUtil::trim($map->get("charset"));
     $mer_id = StringUtil::trim($map->get("mer_id"));
     $sign_type = StringUtil::trim($map->get("sign_type"));
     $order_id = StringUtil::trim($map->get("order_id"));
     $mer_date = StringUtil::trim($map->get("mer_date"));
     $refund_no = StringUtil::trim($map->get("refund_no"));
     $sub_order_id = StringUtil::trim($map->get("sub_order_id"));
     $sub_refund_amt = StringUtil::trim($map->get("sub_refund_amt"));
     $refund_amount = StringUtil::trim($map->get("refund_amount"));
     $org_amount = StringUtil::trim($map->get("org_amount"));
     $refund_amt = StringUtil::trim($map->get("refund_amt"));
     $is_success = StringUtil::trim($map->get("is_success"));
     $sub_mer_id = StringUtil::trim($map->get("sub_mer_id"));
     $version = StringUtil::trim($map->get("version"));
     $data->put("service", $service);
     $data->put("charset", $charset);
     $data->put("mer_id", $mer_id);
     $data->put("sign_type", $sign_type);
     $data->put("order_id", $order_id);
     $data->put("sub_mer_id", $sub_mer_id);
     $data->put("refund_amount", $refund_amount);
     $data->put("mer_date", $mer_date);
     $data->put("refund_no", $refund_no);
     $data->put("refund_amt", $refund_amt);
     $data->put("is_success", $is_success);
     $data->put("sub_refund_amt", $sub_refund_amt);
     $data->put("org_amount", $org_amount);
     $data->put("sub_order_id", $sub_order_id);
     $data->put("version", $version);
     if (!is_null($map->get("error_code"))) {
         $data->put("error_code", StringUtil::trim($map->get("error_code")));
     }
     return StringUtil::getPlainSortAndByAnd($data);
 }
Ejemplo n.º 24
0
 /**
  * @covers            HashMap::get
  * @expectedException OutOfBoundsException
  */
 public function testExceptionIsRaisedWhenAccessingAnElementThatDoesNotExist()
 {
     $store = new HashMap();
     $store->get('foo');
 }
Ejemplo n.º 25
0
$sign_type = $_REQUEST['sign_type'];
$res_format = $_REQUEST['res_format'];
$ret_url = $_REQUEST['ret_url'];
$notify_url = $_REQUEST['notify_url'];
$version = $_REQUEST['version'];
$goods_id = $_REQUEST['goods_id'];
$goods_inf = $_REQUEST['goods_inf'];
$order_id = $_REQUEST['order_id'];
$mer_date = $_REQUEST['mer_date'];
$expire_time = $_REQUEST['expire_time'];
$expand = $_REQUEST['expand'];
$mer_priv = $_REQUEST['mer_priv'];
$amount = $_REQUEST['amount'];
$amt_type = $_REQUEST['amt_type'];
$user_ip = $_REQUEST['user_ip'];
$map = new HashMap();
$map->put("service", $service);
$map->put("charset", $charset);
$map->put("mer_id", $mer_id);
$map->put("sign_type", $sign_type);
$map->put("res_format", $res_format);
$map->put("ret_url", $ret_url);
$map->put("notify_url", $notify_url);
$map->put("version", $version);
$map->put("goods_id", $goods_id);
$map->put("goods_inf", $goods_inf);
$map->put("order_id", $order_id);
$map->put("mer_date", $mer_date);
$map->put("amount", $amount);
$map->put("amt_type", $amt_type);
$map->put("mer_priv", $mer_priv);
Ejemplo n.º 26
0
 /**
 +----------------------------------------------------------
 * 写入缓存
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 * @param mixed $value  存储数据
 * @param integer $expire  有效时间(秒)
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function set($name, $value, $expireTime = 0)
 {
     $data = serialize($value);
     $name = addslashes($name);
     $this->W(1);
     if (C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) {
         //数据压缩
         $data = gzcompress($data, 3);
     }
     if (C('DATA_CACHE_CHECK')) {
         //开启数据校验
         $crc = md5($data);
     } else {
         $crc = '';
     }
     $expire = !empty($expireTime) ? $expireTime : $this->options['expire'];
     $map = new HashMap();
     $map->put('cachekey', $name);
     $map->put('data', $data);
     $map->put('datacrc', $crc);
     $map->put('expire', $expireTime == -1 ? -1 : time() + $expire);
     //缓存有效期为-1表示永久缓存
     $map->put('datasize', strlen($data));
     $result = $this->db->getRow('select `id` from `' . $this->options['table'] . '` where `cachekey`=\'' . $name . '\' limit 0,1');
     if (false !== $result) {
         //更新记录
         $result = $this->db->save($map, $this->options['table'], '`cachekey`=\'' . $name . '\'');
     } else {
         //新增记录
         $result = $this->db->add($map, $this->options['table']);
     }
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 27
0
 /**
  * @depends testOffsetSetOffsetGet
  */
 function testHashNull()
 {
     $map = new HashMap();
     $map->offsetSet(null, 1);
     $this->assertEquals(1, $map->offsetGet(null));
 }
 public static function loadFromStream($filename, GenericList $classNotFoundExceptions)
 {
     if (is_null($filename)) {
         throw new NullPointerException('InputStream');
     }
     $whitelistSer = new HashMap();
     $whitelistDeser = new HashMap();
     $typeIds = new HashMap();
     $clientFields = new HashMap();
     $br = new BufferedReader($filename);
     $line = $br->readLine();
     $lineNum = 1;
     while (!is_null($line)) {
         $line = trim($line);
         if (mb_strlen($line) > 0) {
             $components = explode(',', $line);
             if ($components[0] === self::CLIENT_FIELDS_KEYWORD) {
                 /*
                  * Lines starting with '@ClientFields' list potentially serializable fields known to
                  * client code for classes that may be enhanced with additional fields on the server.
                  * If additional server  fields are found, they will be serizalized separately from the
                  * normal RPC process and transmitted to the client as an opaque blob of data stored
                  * in a WeakMapping associated with the object instance.
                  */
                 $binaryTypeName = trim($components[1]);
                 try {
                     $clazz = Classes::classOf($binaryTypeName);
                     $fieldNames = new HashSet();
                     for ($i = 2; $i < count($components); $i++) {
                         $fieldNames->add($components[$i]);
                     }
                     $clientFields->put($clazz, $fieldNames);
                 } catch (ClassNotFoundException $e) {
                     // Ignore the error, but add it to the list of errors if one was
                     // provided.
                     if (!is_null($classNotFoundExceptions)) {
                         $classNotFoundExceptions->add($e);
                     }
                 }
             } else {
                 if (count($components) != 2 && count($components) != 7) {
                     throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
                 }
                 for ($i = 0; $i < count($components); $i++) {
                     $components[$i] = trim($components[$i]);
                     if (mb_strlen($components[$i]) == 0) {
                         throw new ParseException(self::FORMAT_ERROR_MESSAGE, $lineNum);
                     }
                 }
                 $binaryTypeName = trim($components[0]);
                 if (count($components) == 2) {
                     $fieldSer = $fieldDeser = true;
                     $instantSer = $instantDeser = Boolean::valueOf($components[1]);
                     $typeId = $binaryTypeName;
                 } else {
                     $idx = 1;
                     // TODO: Validate the instantiable string better
                     $fieldSer = Boolean::valueOf($components[$idx++]);
                     $instantSer = Boolean::valueOf($components[$idx++]);
                     $fieldDeser = Boolean::valueOf($components[$idx++]);
                     $instantDeser = Boolean::valueOf($components[$idx++]);
                     $typeId = $components[$idx++];
                     if (!$fieldSer && !$fieldDeser && TypeNameObfuscator::SERVICE_INTERFACE_ID != $typeId) {
                         throw new ParseException('Type ' . $binaryTypeName . ' is neither field serializable, field deserializable ' . 'nor the service interface : ', $lineNum);
                     }
                 }
                 try {
                     $clazz = Classes::classOf($binaryTypeName);
                     if ($fieldSer) {
                         $whitelistSer->put($clazz, $instantSer);
                     }
                     if ($fieldDeser) {
                         $whitelistDeser->put($clazz, $instantDeser);
                     }
                     $typeIds->put($clazz, $typeId);
                 } catch (ClassNotFoundException $e) {
                     // Ignore the error, but add it to the list of errors if one was
                     // provided.
                     if (!is_null($classNotFoundExceptions)) {
                         $classNotFoundExceptions->add($e);
                     }
                 }
             }
         }
         $line = $br->readLine();
         $lineNum++;
     }
     return new StandardSerializationPolicy($whitelistSer, $whitelistDeser, $typeIds, $clientFields);
 }
Ejemplo n.º 29
-1
 function testNormalMap()
 {
     $map = new HashMap("string", "integer");
     $map->put("123", 4);
     $map->put("567", 8);
     $this->assertEqual("{123:4,567:8}", $map->__toString());
 }
Ejemplo n.º 30
-1
 function insert()
 {
     $userId = Session::get(C('USER_AUTH_KEY'));
     $recordId = intval($_POST['recordId']);
     if ($_POST['module'] == "Blog") {
         $dao = D('Blog');
         if ($blog = $dao->getById($recordId)) {
             $toUserId = $blog->userId;
             $blogTitle = $blog->title;
         } else {
             $this->error("文章不存在,无法回复!", false);
         }
     } else {
         if ($_POST['module'] == "Photo") {
             $dao = D('Photo');
             if ($photo = $dao->getById($recordId)) {
                 $toUserId = $photo->userId;
                 $photoPath = $photo->imagePath;
             } else {
                 $this->error("图片不存在,无法回复!", false);
             }
         }
     }
     $dao = D("Comment");
     $vo = $dao->create();
     $vo->cTime = time();
     $vo->userId = $userId;
     if ($result = $dao->add($vo)) {
         if ($vo->replyType == 0) {
             $map = new HashMap();
             $map->put('replyId', $result);
             $replyId = $dao->save($map, "id='{$result}'");
         }
         $content = ubb($vo->content);
         if ($_POST['module'] == 'Blog') {
             /* add_user_feed */
             $feedTitle = "评论了日志:<a href=\"/blog/{$recordId}\">{$blogTitle}</a>";
             $feedInfo = '<div class="share-comment"><p>' . $content . '</p></div>';
             $this->addUserFeed($userId, 'add', 'comment', $recordId, $feedTitle, $feedInfo);
             /* /add_user_feed */
             $this->addUserAlert($toUserId, "reply" . $_POST['module'], $_POST['recordId']);
         } elseif ($_POST['module'] == 'Photo') {
             /* add_user_feed */
             $feedTitle = "评论了照片:";
             $feedInfo = "<p class=\"image\"><a href=\"/photo/{$recordId}\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=100&h=100&url={$photoPath}\" alt=\"照片\" /></a></p>" . '<div class="share-comment"><p>' . $content . '</p></div>';
             $this->addUserFeed($userId, 'add', 'comment', $recordId, $feedTitle, $feedInfo);
             /* /add_user_feed */
             $this->addUserAlert($toUserId, "reply" . $_POST['module'], $_POST['recordId']);
         }
         //$this->success('回复成功!');
         if ($_POST['module'] == 'Board') {
             header("Location:" . __APP__ . "/Board");
         } else {
             echo $result;
         }
     } else {
         //$this->error('回复失败!');
         echo false;
     }
 }