http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88819
Revision: 88819
Author: reedy
Date: 2011-05-25 19:30:57 +0000 (Wed, 25 May 2011)
Log Message:
-----------
Fix spaces to tabs
Set svn:eol-style native
Modified Paths:
--------------
trunk/extensions/ShortUrl/ShortUrl.functions.php
trunk/extensions/ShortUrl/SpecialShortUrl.php
Property Changed:
----------------
trunk/extensions/ShortUrl/README
trunk/extensions/ShortUrl/install.settings
Property changes on: trunk/extensions/ShortUrl/README
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/extensions/ShortUrl/ShortUrl.functions.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.functions.php 2011-05-25 19:26:10 UTC
(rev 88818)
+++ trunk/extensions/ShortUrl/ShortUrl.functions.php 2011-05-25 19:30:57 UTC
(rev 88819)
@@ -15,68 +15,66 @@
/* stolen from http://www.php.net/manual/en/function.base64-encode.php#63543 */
function urlsafe_b64encode( $string ) {
- $data = base64_encode( $string );
- $data = str_replace( array( '+', '/', '=' ), array( '-', '_', '' ), $data
);
- return $data;
+ $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 */
function urlsafe_b64decode( $string ) {
- $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
- $mod4 = strlen( $data ) % 4;
- if ( $mod4 ) {
- $data .= substr( '====', $mod4 );
- }
- return base64_decode( $data );
+ $data = str_replace( array( '-', '_' ), array( '+', '/' ), $string );
+ $mod4 = strlen( $data ) % 4;
+ if ( $mod4 ) {
+ $data .= substr( '====', $mod4 );
+ }
+ return base64_decode( $data );
}
function shorturlEncode ( $title ) {
- global $wgMemc;
+ global $wgMemc;
- $id = null;
- $id = $wgMemc->get( wfMemcKey( 'shorturls', 'title', $title->getFullText()
) );
- if ( !$id ) {
- $dbr = wfGetDB( DB_SLAVE );
- $query = $dbr->select(
- 'shorturls',
- array( 'su_id' ),
- array( 'su_namespace' => $title->getNamespace(), 'su_title' =>
$title->getText() ),
- __METHOD__ );
- if ( $dbr->numRows( $query ) > 0 ) {
- $entry = $dbr->fetchRow( $query );
- $id = $entry['su_id'];
- } else {
- $dbw = wfGetDB( DB_MASTER );
- $row_data = array(
- 'su_id' => $dbw->nextSequenceValue( 'shorturls_id_seq' ),
- 'su_namespace' => $title->getNamespace(),
- 'su_title' => $title->getText()
- );
- $dbw->insert( 'shorturls', $row_data );
- $id = $dbw->insertId();
- }
- $wgMemc->set( wfMemcKey( 'shorturls', 'title', $title->getFullText()
), $id, 0 );
- }
+ $id = $wgMemc->get( wfMemcKey( 'shorturls', 'title',
$title->getFullText() ) );
+ if ( !$id ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $query = $dbr->select(
+ 'shorturls',
+ array( 'su_id' ),
+ array( 'su_namespace' => $title->getNamespace(),
'su_title' => $title->getText() ),
+ __METHOD__ );
+ if ( $dbr->numRows( $query ) > 0 ) {
+ $entry = $dbr->fetchRow( $query );
+ $id = $entry['su_id'];
+ } else {
+ $dbw = wfGetDB( DB_MASTER );
+ $row_data = array(
+ 'su_id' => $dbw->nextSequenceValue(
'shorturls_id_seq' ),
+ 'su_namespace' => $title->getNamespace(),
+ 'su_title' => $title->getText()
+ );
+ $dbw->insert( 'shorturls', $row_data );
+ $id = $dbw->insertId();
+ }
+ $wgMemc->set( wfMemcKey( 'shorturls', 'title',
$title->getFullText() ), $id, 0 );
+ }
return urlsafe_b64encode( $id );
}
function shorturlDecode ( $data ) {
- global $wgMemc;
+ global $wgMemc;
- $id = intval( urlsafe_b64decode ( $data ) );
- $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
- if ( !$entry ) {
- $dbr = wfGetDB( DB_SLAVE );
- $query = $dbr->select(
- 'shorturls',
- array( 'su_namespace', 'su_title' ),
- array( 'su_id' => $id ),
- __METHOD__
- );
+ $id = intval( urlsafe_b64decode ( $data ) );
+ $entry = $wgMemc->get( wfMemcKey( 'shorturls', 'id', $id ) );
+ if ( !$entry ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $query = $dbr->select(
+ 'shorturls',
+ array( 'su_namespace', 'su_title' ),
+ array( 'su_id' => $id ),
+ __METHOD__
+ );
- $entry = $dbr->fetchRow( $query );
- $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
- }
- return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
-
+ $entry = $dbr->fetchRow( $query );
+ $wgMemc->set( wfMemcKey( 'shorturls', 'id', $id ), $entry, 0 );
+ }
+ return Title::makeTitle( $entry['su_namespace'], $entry['su_title'] );
}
Modified: trunk/extensions/ShortUrl/SpecialShortUrl.php
===================================================================
--- trunk/extensions/ShortUrl/SpecialShortUrl.php 2011-05-25 19:26:10 UTC
(rev 88818)
+++ trunk/extensions/ShortUrl/SpecialShortUrl.php 2011-05-25 19:30:57 UTC
(rev 88819)
@@ -36,7 +36,7 @@
* @param $par Mixed: Parameters passed to the page
*/
public function execute( $par ) {
- global $wgOut, $wgRequest;
+ global $wgOut;
$title = shorturlDecode( $par );
if ( $title ) {
Property changes on: trunk/extensions/ShortUrl/install.settings
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs