public function execute() { global $wgUser; if ( !$wgUser->isAllowed( 'push' ) || $wgUser->isBlocked() ) { $this->dieUsageMsg( array( 'badaccess-groups' ) ); } global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, $egPushLoginPasswords; $params = $this->extractRequestParams(); if ( !isset( $params['images'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'images' ) ); } if ( !isset( $params['targets'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'targets' ) ); } PushFunctions::flipKeys( $egPushLoginUsers, 'users' ); PushFunctions::flipKeys( $egPushLoginPasswords, 'passwds' ); foreach ( $params['targets'] as &$target ) { $user = false; $pass = false; if ( array_key_exists( $target, $egPushLoginUsers ) && array_key_exists( $target, $egPushLoginPasswords ) ) { $user = $egPushLoginUsers[$target]; $pass = $egPushLoginPasswords[$target]; } elseif ( $egPushLoginUser != '' && $egPushLoginPass != '' ) { $user = $egPushLoginUser; $pass = $egPushLoginPass; } if ( substr( $target, -1 ) !== '/' ) { $target .= '/'; } $target .= 'api.php'; if ( $user !== false ) { $this->doLogin( $user, $pass, $target ); } } foreach ( $params['images'] as $image ) { $title = Title::newFromText( $image, NS_FILE ); if ( !is_null( $title ) && $title->getNamespace() == NS_FILE && $title->exists() ) { $this->doPush( $title, $params['targets'] ); } } }
public function execute() { global $wgUser; if (!$wgUser->isAllowed('push') || $wgUser->isBlocked()) { $this->dieUsageMsg(array('badaccess-groups')); } global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, $egPushLoginPasswords, $egPushLoginDomain, $egPushLoginDomains; $params = $this->extractRequestParams(); if (!isset($params['page'])) { $this->dieUsageMsg(array('missingparam', 'page')); } if (!isset($params['targets'])) { $this->dieUsageMsg(array('missingparam', 'targets')); } PushFunctions::flipKeys($egPushLoginUsers, 'users'); PushFunctions::flipKeys($egPushLoginPasswords, 'passwds'); PushFunctions::flipKeys($egPushLoginDomains, 'domains'); foreach ($params['targets'] as &$target) { $user = false; $pass = false; $domain = false; if (array_key_exists($target, $egPushLoginUsers) && array_key_exists($target, $egPushLoginPasswords)) { $user = $egPushLoginUsers[$target]; $pass = $egPushLoginPasswords[$target]; } elseif ($egPushLoginUser != '' && $egPushLoginPass != '') { $user = $egPushLoginUser; $pass = $egPushLoginPass; } if (array_key_exists($target, $egPushLoginDomains)) { $domain = $egPushLoginDomains[$target]; } elseif ($egPushLoginDomain != '') { $domain = $egPushLoginDomain; } if (substr($target, -1) !== '/') { $target .= '/'; } $target .= 'api.php'; if ($user !== false) { $this->doLogin($user, $pass, $domain, $target); } } foreach ($params['page'] as $page) { $title = Title::newFromText($page); $revision = $this->getPageRevision($title); if ($revision !== false) { $this->doPush($title, $revision, $params['targets']); } } foreach ($this->editResponses as $response) { $this->getResult()->addValue(null, null, FormatJson::decode($response)); } }