http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88838

Revision: 88838
Author:   yuvipanda
Date:     2011-05-25 21:11:30 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Moved to base36

Modified Paths:
--------------
    trunk/extensions/ShortUrl/ShortUrl.functions.php

Modified: trunk/extensions/ShortUrl/ShortUrl.functions.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.functions.php    2011-05-25 20:57:15 UTC 
(rev 88837)
+++ trunk/extensions/ShortUrl/ShortUrl.functions.php    2011-05-25 21:11:30 UTC 
(rev 88838)
@@ -14,31 +14,6 @@
 }
 
 /**
- * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543
- *
- * @param $string string
- */
-function urlsafe_b64encode( $string ) {
-       $data = base64_encode( $string );
-       $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), 
$data );
-       return $data;
-}
-
-/**
- * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543
- *
- * @param $string string
- */
-function urlsafe_b64decode( $string ) {
-       $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
-       $mod4 = strlen( $data ) % 4;
-       if ( $mod4 ) {
-               $data .= substr( '====', $mod4 );
-       }
-       return base64_decode( $data );
-}
-
-/**
  * @param $title Title
  * @return mixed|string
  */
@@ -68,7 +43,7 @@
                }
                $wgMemc->set( wfMemcKey( 'shorturls', 'title', 
$title->getFullText() ), $id, 0 );
        }
-       return urlsafe_b64encode( $id );
+       return base_convert( $id, 10, 36 );
 }
 
 /**
@@ -78,7 +53,7 @@
 function shorturlDecode ( $data ) {
        global $wgMemc;
 
-       $id = intval( urlsafe_b64decode ( $data ) );
+       $id = intval( base_convert ( $data, 36, 10 ) );
        $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
        if ( !$entry ) {
                $dbr = wfGetDB( DB_SLAVE );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to