Page MenuHomeMiraheze
Paste P149

(An Untitled Masterwork)
ActivePublic

Authored by Paladox on Nov 30 2018, 01:46.
Tags
None
Referenced Files
F870236:
Nov 30 2018, 21:57
F870235:
Nov 30 2018, 21:56
F869764:
Nov 30 2018, 03:17
F869743:
Nov 30 2018, 02:26
F869738:
Nov 30 2018, 02:06
F869733:
Nov 30 2018, 01:47
F869732:
Nov 30 2018, 01:46
Subscribers
None
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Maintenance
* @author Paladox
* @version 1.0
*/
require_once( '/srv/mediawiki/w/maintenance/Maintenance.php' );
class ScriptMira extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "";
}
public function execute() {
global $wgDBname;
$wikiDB = wfGetDB( DB_MASTER );
$pageTitle = $wikiDB->select(
'page',
'page_title',
[ 'page_namespace' => '6' ],
__METHOD__
);
if ( !$pageTitle || !is_object( $pageTitle ) ) {
throw new MWException( '$pageId was not set to a valid array.' );
}
foreach ( $pageTitle as $id ) {
$page_title = $id->page_title;
$this->output("fetching json for page title {$page_title}\n");
$json = file_get_contents("http://nonciclopedia.wikia.com/api.php?action=query&list=allimages&ailimit=500&aifrom={$page_title}&aito={$page_title}&aiprop=dimensions%7Cmime%7Cuser&format=json");
$obj = json_decode( $json, true );
if ( !$obj || !is_array( $obj ) ) {
throw new MWException( '$obj was not set to a valid array.' );
}
if ( isset( $obj['query'] ) && isset( $obj['query']['allimages'] ) ) {
foreach ( $obj['query']['allimages'] as $object ) {
if (isset( $object['name'] ) &&
isset( $object['user'] )
) {
$name = urlencode( $object['name'] );
$user = urlencode( $object['user'] );
exec( "/usr/bin/nice -n -19 /usr/bin/php /srv/mediawiki/w/extensions/MirahezeMagic/maintenance/fixImageUser.php --wiki={$wgDBname} --image-name={$name} 127.0.0.1 {$user}");
}
}
}
}
}
}
$maintClass = 'ScriptMira';
require_once RUN_MAINTENANCE_IF_MAIN;

Event Timeline

Paladox edited the content of this paste. (Show Details)
Paladox edited the content of this paste. (Show Details)