Index: trunk/extensions/ShortUrl/ShortUrl.functions.php |
— | — | @@ -14,31 +14,6 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
18 | | - * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 |
19 | | - * |
20 | | - * @param $string string |
21 | | - */ |
22 | | -function urlsafe_b64encode( $string ) { |
23 | | - $data = base64_encode( $string ); |
24 | | - $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data ); |
25 | | - return $data; |
26 | | -} |
27 | | - |
28 | | -/** |
29 | | - * stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 |
30 | | - * |
31 | | - * @param $string string |
32 | | - */ |
33 | | -function urlsafe_b64decode( $string ) { |
34 | | - $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string ); |
35 | | - $mod4 = strlen( $data ) % 4; |
36 | | - if ( $mod4 ) { |
37 | | - $data .= substr( '====', $mod4 ); |
38 | | - } |
39 | | - return base64_decode( $data ); |
40 | | -} |
41 | | - |
42 | | -/** |
43 | 18 | * @param $title Title |
44 | 19 | * @return mixed|string |
45 | 20 | */ |
— | — | @@ -68,7 +43,7 @@ |
69 | 44 | } |
70 | 45 | $wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText() ), $id, 0 ); |
71 | 46 | } |
72 | | - return urlsafe_b64encode( $id ); |
| 47 | + return base_convert( $id, 10, 36 ); |
73 | 48 | } |
74 | 49 | |
75 | 50 | /** |
— | — | @@ -78,7 +53,7 @@ |
79 | 54 | function shorturlDecode ( $data ) { |
80 | 55 | global $wgMemc; |
81 | 56 | |
82 | | - $id = intval( urlsafe_b64decode ( $data ) ); |
| 57 | + $id = intval( base_convert ( $data, 36, 10 ) ); |
83 | 58 | $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) ); |
84 | 59 | if ( !$entry ) { |
85 | 60 | $dbr = wfGetDB( DB_SLAVE ); |