示例#1
0
 public function testRemoveAll()
 {
     // Remove the following lines when you implement this test.
     $map = new HashMap();
     $map->put(5, 5);
     $map->put(6, 6);
     $this->assertTrue($this->object->removeAll($map));
     $this->assertFalse($this->object->containsKey(5));
     $map = new HashMap();
     $map->put(8, 5);
     $map->put(78, 6);
     $this->assertTrue($this->object->removeAll($map));
 }
 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.');
     }
 }
示例#3
0
 /**
  * V4.0对商户提交的参数进行校验,最终返回一个提交给平台的HashMap
  * @param HashMap $param 商户提交的参数
  * @param HashMap $fields1 必填的参数
  * @param HashMap $fields2 非必填参数
  */
 public static function getData($param, $fields1, $fields2)
 {
     //需要进行日期校验的参数
     $field_date = new HashMap();
     $field_date->put("settle_date", "settle_date");
     $field_date->put("mer_date", "mer_date");
     $field_date->put("payDate", "payDate");
     //需要进行RAS加密的参数
     $field_ras = new HashMap();
     $field_ras->put("card_id", "card_id");
     $field_ras->put("valid_date", "valid_date");
     $field_ras->put("cvv2", "cvv2");
     $field_ras->put("pass_wd", "pass_wd");
     $field_ras->put("identity_code", "identity_code");
     $field_ras->put("card_holder", "card_holder");
     //付款请求添加RAS加密的参数
     $field_ras->put("recv_account", "recv_account");
     $field_ras->put("recv_user_name", "recv_user_name");
     $field_ras->put("identity_holder", "identity_holder");
     $data = new HashMap();
     if (!$fields1->isEmpty() && $fields1->size() > 0) {
         $keys = $fields1->keys();
         foreach ($keys as $key) {
             $value = StringUtil::trim($param->get($key));
             $length = StringUtil::trim($fields1->get($key));
             $flag = $field_date->containsKey($key);
             $flag1 = $field_ras->containsKey($key);
             if ($flag1) {
                 if ("" == $value) {
                     die($key . "为空或者长度超过限制");
                 } else {
                     $value = iconv("UTF-8", "GBK", $value);
                     $value = RSACryptUtil::encrypt($value);
                     $data->put($key, $value);
                 }
             } elseif ($flag) {
                 if (!DateUtil::checkData($value)) {
                     die($key . "为空或者长度不符合要求");
                 } else {
                     $data->put($key, $value);
                 }
             } elseif ("split_data" == $key) {
                 if ("" == $value) {
                     die($key . "为空或者长度超过限制");
                 } else {
                     $data->put($key, $value);
                 }
             } else {
                 if ("" == $value || strlen($value) > $length) {
                     die($key . "为空或者长度超过限制");
                 } else {
                     $data->put($key, $value);
                 }
             }
         }
         $keys1 = $fields2->keys();
         foreach ($keys1 as $key) {
             if (!is_null($param->get($key))) {
                 $value = StringUtil::trim($param->get($key));
                 $length = StringUtil::trim($fields2->get($key));
                 $flag1 = $field_ras->containsKey($key);
                 if ($flag1) {
                     if ("" != $value) {
                         if (strlen($value) > $length) {
                             die($key . "为空或者长度超过限制");
                         } else {
                             $value = iconv("UTF-8", "GBK", $value);
                             $value = RSACryptUtil::encrypt($value);
                             $data->put($key, $value);
                         }
                     }
                 } elseif ($field_date->containsKey($key)) {
                     if (!DateUtil::checkData($value)) {
                         die($key . "为空或者长度不符合要求");
                     } else {
                         $data->put($key, $value);
                     }
                 } elseif ("split_data" == $key) {
                     if ("" != $value) {
                         $data->put($key, $value);
                     }
                 } else {
                     if ("" != $value) {
                         if (strlen($value) > $length) {
                             die($key . "为空或者长度超过限制");
                         } else {
                             $data->put($key, $value);
                         }
                     }
                 }
             }
         }
     } else {
         die("获取请求参数字符串失败:传入参数为空!");
     }
     return $data;
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function has($key)
 {
     $this->validateKey($key);
     return $this->store->containsKey($key);
 }
示例#5
0
function getid($facebook, $uid)
{
    $HL = new HashMap();
    $HC = new HashMap();
    $user_profile = $facebook->api($uid . '/feed?fields=comments.fields(from,id),likes.fields(name),message,from,story_tags&limit=40');
    // print_r($user_profile);
    $catch = json_encode($user_profile);
    //echo $catch;
    //print $de->{'data'}[$i]->{'comments'}->{'data'}[$j]
    $totallcount = 0;
    $totalccount = 0;
    $cidlist;
    $lidlist;
    $de = json_decode($catch);
    //print_r ($de);
    $arr = $de->{'data'};
    //print_r $arr[0];
    $datacount = count($arr);
    for ($i = 0; $i < $datacount; $i++) {
        //comments id
        $dataarr = $de->{'data'}[$i]->{'comments'}->{'data'};
        $data2count = count($dataarr);
        $pid = new HashMap();
        for ($j = 0; $j < $data2count; $j++) {
            //print "COMMENT:";
            $cid = $de->{'data'}[$i]->{'comments'}->{'data'}[$j]->{'from'}->{'id'};
            if ($pid->containsKey($cid)) {
                $HC->put($cid, 0.5);
            } else {
                $pid->put($cid, 0);
                $HC->put($cid, 1);
            }
            $totalccount++;
        }
        $dataarr = $de->{'data'}[$i]->{'likes'}->{'data'};
        $data2count = count($dataarr);
        for ($j = 0; $j < $data2count; $j++) {
            //likes id
            $lid = $de->{'data'}[$i]->{'likes'}->{'data'}[$j]->{'id'};
            $HL->put($lid, 1);
            $totallcount++;
        }
        $mid = $de->{'data'}[$i]->{'from'}->{'id'};
        //get message fromid
        $HC->put($mid, 1);
        $totalccount++;
        $ka = array_keys((array) $de->{'data'}[$i]->{'story_tags'});
        for ($x = 0; $x < count($ka); $x++) {
            //get story tagid
            $type = $de->{'data'}[$i]->{'story_tags'}->{$ka[$x]}[0]->{'type'};
            if ($type == "user") {
                $sid = $de->{'data'}[$i]->{'story_tags'}->{$ka[$x]}[0]->{'id'};
                $HC->put($sid, 1);
            }
        }
    }
    //echo $de;
    //echo ("</br>LIKES:$totallcount</br>");
    //echo ("COMMENTS:$totalccount</br>");
    $HC->putAll($HC);
    $HC->putAll($HL);
    // echo array_sum($HC->values());
    $HL->removeAll();
    $HC->remove($uid);
    $HC->maxAll($HC, 10);
    return $HC;
}