Exemple #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $obscuredParameter = 'id')
 {
     $hashids = new Hashids(config('obscure.salt'), config('obscure.length'), config('obscure.alphabet'));
     // decode form request hashs
     if ($request->request->has($obscuredParameter)) {
         $request->request->add([$obscuredParameter => $hashids->decode($request->request->get($obscuredParameter))[0]]);
     }
     // decode route hashs
     if ($this->route->parameter($obscuredParameter)) {
         $this->route->setParameter($obscuredParameter, $hashids->decode($this->route->parameter($obscuredParameter))[0]);
     }
     return $next($request);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->bind('client', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Client::findOrFail($id);
     });
     $router->bind('bank', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return BankDetail::findOrFail($id);
     });
     $router->bind('address', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Address::findOrFail($id);
     });
     $router->bind('property', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return Property::findOrFail($id);
     });
     $router->bind('agreement', function ($value, $route) {
         $hashids = new Hashids('MySecretSalt*(&^%$eo&*^%&r', 20);
         $id = $hashids->decode($value)[0];
         return RentalAgreement::findOrFail($id);
     });
     //
 }
Exemple #3
0
 public function getHashidsShortcodeId($shortcode)
 {
     // create hashids for shortcode using the url row id
     $hashids = new Hashids("this is my salt", 5, "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ1234567890");
     // $shortcode = $hashids->encode($id);
     $numberId = $hashids->decode($shortcode);
     return $numberId;
 }
 /**
  * Decode public id to real id
  *
  * @access      public
  *
  * @param       string      $public_id
  * @return      integer|null
  */
 public static function publicIdDecode($public_id)
 {
     $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet());
     $id = $hashids->decode($public_id);
     if (is_array($id) && isset($id[0])) {
         return $id[0];
     }
     return null;
 }
 /**
  * Process, filter and return the given data
  * @param mixed $jsonValue the value of the property in the JSON
  * @param mixed $objectValue the value of the property in the Object
  * @param bool $jsonToObject If the process works with the json or object value first
  * @return mixed
  */
 public function process($jsonValue, $objectValue, $jsonToObject = true)
 {
     $hashids = new Hashids(JacksonPhp::$hashIdsSalt, 8);
     if ($jsonToObject) {
         $decodedId = $hashids->decode($jsonValue);
         return count($decodedId) > 0 ? $decodedId[0] : "";
     } else {
         return $hashids->encode($objectValue);
     }
 }
 /**
  * Display the contents of the uploaded file
  */
 public function download()
 {
     $hashids = new Hashids(Configure::read('Security.salt'));
     $pk = $hashids->decode($this->request->query['i'])[0];
     $this->loadModel($this->request->query['m']);
     $data = $this->{$this->request->query['m']}->find('first', array('recursive' => -1, 'conditions' => array("{$this->request->query['m']}." . $this->{$this->request->query['m']}->primaryKey => $pk), 'fields' => array("{$this->request->query['m']}.{$this->request->query['f']}")));
     $file = json_decode($data[$this->request->query['m']][$this->request->query['f']], true);
     header('Content-length: ' . $file['size']);
     header('Content-type: ' . $file['type']);
     header('Content-Disposition: inline; filename=' . $file['name']);
     echo base64_decode($file['content']);
     die;
 }
Exemple #7
0
 public function test()
 {
     echo __CLASS__, "</br>", __METHOD__, "</br>";
     $id = 12;
     $hashids = new Hashids('this is mysalt111');
     $en = $hashids->encode($id);
     $de = $hashids->decode($en);
     //var_dump($en,$de);
     $a = $_SERVER["REQUEST_URI"];
     $path = $_SERVER["QUERY_STRING"];
     $query = $_SERVER["SCRIPT_NAME"];
     //echo $a,"<br>",$path,"<br>",$query,"<br>",$_SERVER['HOST'];
     var_dump($_SERVER);
     //echo "hiiiiiiiii";
 }
 public function test()
 {
     $a = $this->one;
     $u = new User();
     $wo = strpos('fling', $a);
     $_SERVER['yyy'] = "xxx";
     header("HTTP/1.1 204 OK");
     header("cache-control:max-age=0");
     header("cache-control:no-cache");
     header("expires:0");
     header("expires:Tue, 01 Jan 1980 1:00:00 GMT");
     header("pragma:no-cache");
     $view = view("testone")->withName("xj");
     // test jsonp
     return $view;
     /*
     echo "head";
     //echo "php_self=".$_SERVER['PHP_SELF']."<BR>";
     //echo "http_referer=".$_SERVER['HTTP_REFERER']."<BR>";
     //return $_SERVER;
     exit;
     echo $_SERVER['SCRIPT_FILENAME']."<BR>";
     echo $_SERVER['HTTP_HOST'],"<BR>";
     echo $_SERVER['REQUEST_URI'],"<BR>";
     //return $_SERVER;
     //      var_dump($_SERVER);
     */
     //exit;
     //echo __CLASS__,"</br>",__METHOD__;
     //$a=Apacl::getinfo("hello");
     //echo $a;
     $a = msgService::add("aaa");
     $b = new msgService();
     $c = $b->info("waa");
     echo $a;
     echo $c;
     exit;
     echo __CLASS__, "</br>", __METHOD__, "</br>";
     $id = 12;
     $hashids = new Hashids('this is mysalt111');
     $en = $hashids->encode($id);
     $de = $hashids->decode($en);
     //var_dump($en,$de);
     $a = $_SERVER["REQUEST_URI"];
     $path = $_SERVER["QUERY_STRING"];
     $query = $_SERVER["SCRIPT_NAME"];
     var_dump($_SERVER);
 }
Exemple #9
0
 public function scopeFindByHashids($query, $hashed)
 {
     $hashids = new Hashids($this->hashids_salt);
     $id = $hashids->decode($hashed);
     return $query->where('id', $id)->firstOrFail();
 }
Exemple #10
0
 /**
  * Decode the hashed value.
  *
  * @param  string  $hashed
  *
  * @return mixed
  */
 public function decode($hashed)
 {
     return head($this->hasher->decode($hashed));
 }
Exemple #11
0
 public function scopeFindByCodeHash($query, $code)
 {
     $hashids = new Hashids('quizprivate123');
     return $query->where('id', $hashids->decode($code))->firstOrFail();
 }
 public function decode($value)
 {
     $hashids = new Hashids(config('paysera.projectid'), 10);
     $decoded = $hashids->decode($value);
     return isset($decoded[0]) ? $decoded[0] : null;
 }
 /**
  * Number to decode.
  *
  * @param string $str    The hash to decode into a number
  * @param int    $length The minimum id length setting
  *
  * @return int The original number is returned
  *
  * @api
  */
 public function decodeID(string $str, int $length = 21) : int
 {
     $this->setCipherKey($this->initializationVector);
     $hashids = new Hashids($this->cipherKey, $length);
     return $hashids->decode($str)[0];
 }
Exemple #14
0
<?php

/**
 * Created by PhpStorm.
 * User: xiehaowei
 * Date: 2016/11/8
 * Time: 下午8:02
 */
use Hashids\Hashids;
$hashId = new Hashids('eric', 6, 'abcdefgABCDEFG1234567890');
$h = $hashId->encode(1000);
echo $h . PHP_EOL;
var_dump($h);
var_dump($hashId->decode('g141G0'));
exit;
Exemple #15
0
 /**
  * Decodes a hash ID.
  *
  * @since 161003 Single hash ID.
  *
  * @param string $hash_id Hash ID.
  *
  * @return int One decoded ID.
  */
 public function decodeOne(string $hash_id) : int
 {
     $ids = $this->Parser->decode($hash_id);
     return $id = (int) ($ids[0] ?? 0);
 }