Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Kodowanie linkow, za dlugie linki....
dsk
post
Post #1





Grupa: Zarejestrowani
Postów: 30
Pomógł: 3
Dołączył: 7.03.2006

Ostrzeżenie: (0%)
-----


Hej,

Uzywam obecnie tych funkcji, aby zakodowac link, a dokladniej zmienne przez get

  1. <?php
  2. function rot13($source) {
  3. $from = "abcdefghijklmnopqrstuvwxyz";
  4. $to = "nopqrstuvwxyzabcdefghijklm";
  5.  
  6. $source = strtr($source, $from, $to);
  7.  
  8. $source = strtr($source, strtoupper($from), strtoupper($to));
  9. $source = strrev($source);
  10. return $source;
  11.  }
  12.  
  13.  function Encrypt($source,$key,$pub_key) {
  14. $cr = '';
  15. $index = 0;
  16. $char = '';
  17. $key_char = '';
  18. $enc_string = '';
  19. $encode = '';
  20. $first = '';
  21. $second = '';
  22. $let1 = '';
  23. $let2 = '';
  24. $encrypted = '';
  25. $escapes = '';
  26. $source = rot13($source);
  27. $cr = '&middot;¨ ';
  28.  
  29. $source = str_replace ("n", "", $source);
  30. $source = str_replace ("f", "", $source);
  31. $source = str_replace ("r", $cr, $source);
  32.  
  33. while ( strlen($key) < strlen($source) ) { $key .= $key; }
  34.  
  35.  $key=substr($key,0,strlen($source));
  36.  
  37. while ($index < strlen($source)) {
  38. $char = substr($source,$index,1);
  39. $key_char = substr($key,$index,1);
  40. $enc_string .= chr(ord($char) ^ ord($key_char));
  41. $index++;
  42. }
  43.  
  44. for ($i=0; $i<=255; $i++) {
  45.  $escapes[chr($i)] = sprintf("%2x", $i);
  46. }
  47. $index=0;
  48. while ($index < strlen($enc_string)) {
  49. $char = substr($enc_string,$index,1);
  50. $encode = $escapes[$char];
  51. $first = substr($encode,0,1);
  52. $second = substr($encode,1,1);
  53. $let1=substr($pub_key, hexdec($first),1);
  54. $let2=substr($pub_key, hexdec($second),1);
  55. $encrypted .= $let1.$let2;
  56. $index++;
  57. }
  58. return $encrypted;
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  function Decrypt($encrypted, $key, $pub_key) {
  66. $encrypted = str_replace ("n", "", $encrypted);
  67. $encrypted = str_replace ("r", "", $encrypted);
  68. $encrypted = str_replace ("t", "", $encrypted);
  69. $encrypted = str_replace ("f", "", $encrypted);
  70.  
  71. $cr = '';
  72. $index = 0;
  73. $char = '';
  74. $key_char = '';
  75. $dec_string = '';
  76. $decode = '';
  77. $decode2 = '';
  78. $decrypted = '';
  79.  
  80. while ( strlen($key) < strlen($encrypted) ) { $key .= $key; }
  81.  $key=substr($key,0,strlen($encrypted));
  82.  
  83.  while ($index < strlen($encrypted)) {
  84.  
  85. $decode = sprintf("%1x", strpos($pub_key, substr($encrypted,$index,1)));
  86. $index++;
  87. $decode2 = sprintf("%1x", strpos($pub_key, substr($encrypted,$index,1)));
  88. $index++;
  89. $dec_string .= chr(hexdec($decode.$decode2));
  90.  }
  91.  
  92.  $index=0;
  93.  while( $index < strlen($dec_string) ) {
  94. $char = substr($dec_string,$index,1);
  95. $key_char = substr($key,$index,1);
  96.  
  97. $decrypted .= chr(ord($char) ^ ord($key_char));
  98. $index++;
  99.  }
  100.  $cr = '&middot;¨ ';
  101.  
  102.  $decrypted = str_replace ($cr, "r", $decrypted);
  103.  return rot13( $decrypted );
  104.  }
  105. ?>


Wszystko ladnie dziala, poza tym ze linki sa za dlugie. wiekszosc ma dlugosc ponad 500 znakow exclamation.gif!

Czy zna ktos inny sposob na kodowanie linkow, aby byly nieczytelne, a krotkie ?

Pozdrawiam i dzieki

Ten post edytował dsk 24.05.2006, 16:38:18
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 19:03