Bladeren bron

encodeDistributionChannelId

zz 4 jaren geleden
bovenliggende
commit
568992a12b
1 gewijzigde bestanden met toevoegingen van 10 en 22 verwijderingen
  1. 10 22
      app/Libs/Helpers.php

+ 10 - 22
app/Libs/Helpers.php

@@ -227,38 +227,26 @@ function ImageNewsToArray($datas)
 /**
  * 加密site id
  */
-function encodeDistributionChannelId($id)
-{
-    $encrypt_pool = [];
-    if (isset($encrypt_pool[$id])) {
+function encodeDistributionChannelId($id){
+    $encrypt_pool = ['10497'=>'wdtest'];
+    if(isset($encrypt_pool[$id])){
         return $encrypt_pool[$id];
     }
-    /*$db_encrypt_info = \DB::table('distribution_channel_id_encrypt')
-        ->where('distribution_channel_id',$id)
-        ->where('is_enable',1)
-        ->select('en_distribution_channel_id')
-        ->first();
-
-    if($db_encrypt_info && $db_encrypt_info->en_distribution_channel_id){
-        return $db_encrypt_info->en_distribution_channel_id;
-    }*/
-    $hashids = new \Hashids\Hashids('', 16, 'abcdefghjklmnopqrstuvwxyz1234567890');
+    $hashids = new \Hashids\Hashids(config('hashids.connections.main.salt'),16,'abcdefghjklmnopqrstuvwxyz1234567890');
     return $hashids->encode($id);
 }
 
 /**
  * 解密密site id
  */
-function decodeDistributionChannelId($code)
-{
-    $encrypt_pool = [];
-    if (isset($encrypt_pool[$code])) {
+function decodeDistributionChannelId($code){
+    $encrypt_pool = ['wdtest'=>'10497'];
+    if(isset($encrypt_pool[$code])){
         return $encrypt_pool[$code];
     }
-
-    $hashids = new \Hashids\Hashids('', 16, 'abcdefghjklmnopqrstuvwxyz1234567890');
-    $res     = $hashids->decode($code);
-    if ($res && isset($res[0])) {
+    $hashids = new \Hashids\Hashids(config('hashids.connections.main.salt'),16,'abcdefghjklmnopqrstuvwxyz1234567890');
+    $res = $hashids->decode($code);
+    if($res && isset($res[0])){
         return $res[0];
     }
     return null;