Move uriB64[En|De]code() to Horde_Url
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 06:39:59 +0000 (23:39 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 5 Mar 2010 07:09:42 +0000 (00:09 -0700)
framework/Core/lib/Horde.php
framework/Token/lib/Horde/Token.php
framework/Token/package.xml
framework/Url/lib/Horde/Url.php
framework/Url/package.xml
framework/Util/lib/Horde/Util.php
framework/Util/package.xml

index 2140d94..ea7ef12 100644 (file)
@@ -512,7 +512,7 @@ HTML;
 
         $queryString .= '&_t=' . $now . '&_h=';
 
-        return $queryString . Horde_Util::uriB64Encode(hash_hmac('sha1', $queryString, $GLOBALS['conf']['secret_key'], true));
+        return $queryString . Horde_Url::uriB64Encode(hash_hmac('sha1', $queryString, $GLOBALS['conf']['secret_key'], true));
     }
 
     /**
@@ -538,7 +538,7 @@ HTML;
         $queryString = substr($data, 0, $pos);
         $hmac = substr($data, $pos);
 
-        if ($hmac != Horde_Util::uriB64Encode(hash_hmac('sha1', $queryString, $GLOBALS['conf']['secret_key'], true))) {
+        if ($hmac != Horde_Url::uriB64Encode(hash_hmac('sha1', $queryString, $GLOBALS['conf']['secret_key'], true))) {
             return false;
         }
 
index 4315cde..88353c8 100644 (file)
@@ -124,7 +124,7 @@ class Horde_Token
      */
     public function generateId($seed = '')
     {
-        return Horde_Util::uriB64Encode(pack('H*', sha1(uniqid(mt_rand(), true) . $seed . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''))));
+        return Horde_Url::uriB64Encode(pack('H*', sha1(uniqid(mt_rand(), true) . $seed . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''))));
     }
 
     /**
index 2fbc66c..eeb2143 100644 (file)
@@ -55,6 +55,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
     <channel>pear.horde.org</channel>
    </package>
    <package>
+    <name>Url</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Util</name>
     <channel>pear.horde.org</channel>
    </package>
index 9652dff..6f874f2 100644 (file)
@@ -253,4 +253,33 @@ class Horde_Url
         return $link . '>';
     }
 
+    /**
+     * URL-safe base64 encoding, with trimmed '='.
+     *
+     * @param string $string  String to encode.
+     *
+     * @return string  URL-safe, base64 encoded data.
+     */
+    static public function uriB64Encode($string)
+    {
+        return str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode($string));
+    }
+
+    /**
+     * Decode URL-safe base64 data, dealing with missing '='.
+     *
+     * @param string $string  Encoded data.
+     *
+     * @return string  Decoded data.
+     */
+    static public function uriB64Decode($string)
+    {
+        $data = str_replace(array('-', '_'), array('+', '/'), $string);
+        $mod4 = strlen($data) % 4;
+        if ($mod4) {
+            $data .= substr('====', $mod4);
+        }
+        return base64_decode($data);
+    }
+
 }
index 37705e6..a7c0bee 100644 (file)
@@ -29,7 +29,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Initial package.
+ <notes>* Added Horde_Url::uriB64Encode() and Horde_Url::uriB64Decode().
+ * Initial package.
  </notes>
  <contents>
   <dir name="/">
index 527bfde..a36ae11 100644 (file)
@@ -778,35 +778,6 @@ class Horde_Util
     }
 
     /**
-     * URL-safe base64 encoding, with trimmed '='.
-     *
-     * @param string $string  String to encode.
-     *
-     * @return string  URL-safe, base64 encoded data.
-     */
-    static public function uriB64Encode($string)
-    {
-        return str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode($string));
-    }
-
-    /**
-     * Decode URL-safe base64 data, dealing with missing '='.
-     *
-     * @param string $string  Encoded data
-     *
-     * @return string  Decoded data.
-     */
-    static public function uriB64Decode($string)
-    {
-        $data = str_replace(array('-', '_'), array('+', '/'), $string);
-        $mod4 = strlen($data) % 4;
-        if ($mod4) {
-            $data .= substr('====', $mod4);
-        }
-        return base64_decode($data);
-    }
-
-    /**
      * Convert a variable to UTF-8. Recursively handles inner variables.
      *
      * @param mixed $in  The variable to convert.
index 4246f2e..843ec8e 100644 (file)
@@ -29,7 +29,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Removed Horde_Util::strftime2date() and Horde_Util::date2strftime().
+ <notes>* Removed Horde_Util::uriB64Encode() and Horde_Util::uriB64Decode().
+ * Removed Horde_Util::strftime2date() and Horde_Util::date2strftime().
  * Removed Horde_Util::closeWindowJs() and Horde_Util::nocacheUrl().
  * Added Horde_Util::convertToUtf8().
  * Added Horde_Util::abbreviate().