Пример #1
0
/**
 * Forks processes to scan the originating IP for an open proxy server
 * MemCached can be used to skip IPs that have already been scanned
 */
function wfProxyCheck()
{
    global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
    global $wgUseMemCached, $wgMemc, $wgProxyMemcExpiry;
    global $wgProxyKey;
    if (!$wgBlockOpenProxies) {
        return;
    }
    $ip = wfGetIP();
    # Get MemCached key
    $skip = false;
    if ($wgUseMemCached) {
        $mcKey = wfMemcKey('proxy', 'ip', $ip);
        $mcValue = $wgMemc->get($mcKey);
        if ($mcValue) {
            $skip = true;
        }
    }
    # Fork the processes
    if (!$skip) {
        $title = Title::makeTitle(NS_SPECIAL, 'Blockme');
        $iphash = md5($ip . $wgProxyKey);
        $url = $title->getFullURL('ip=' . $iphash);
        foreach ($wgProxyPorts as $port) {
            $params = implode(' ', array(escapeshellarg($wgProxyScriptPath), escapeshellarg($ip), escapeshellarg($port), escapeshellarg($url)));
            exec("php {$params} &>/dev/null &");
        }
        # Set MemCached key
        if ($wgUseMemCached) {
            $wgMemc->set($mcKey, 1, $wgProxyMemcExpiry);
        }
    }
}
Пример #2
0
function ipAuthUserLoadAfterLoadFromSession($user)
{
    global $wgIPAuthUsers;
    if ($user->isLoggedIn()) {
        return true;
    }
    $ip = wfGetIP();
    if (isset($wgIPAuthUsers[$ip])) {
        $name = $wgIPAuthUsers[$ip];
        $xuser = User::newFromName($name);
        if ($xuser->getID() == 0) {
            wfDebug("User {$name} assigned to IP {$ip} does not exist!\n");
        } else {
            # HACK: force user data reload by assigning members directly
            $user->mId = $xuser->mId;
            $user->mName = $xuser->mName;
            $user->loadFromId();
            wfDebug("User {$name} assigned to IP {$ip} logged in.\n");
            if (!isset($_SESSION['wsUserID'])) {
                wfDebug("Setting up a session for {$name} assigned to IP {$ip} logged in.\n");
                wfSetupSession();
                $_SESSION['wsToken'] = "IP:{$ip}";
                $_SESSION['wsUserName'] = $name;
                $user->setCookies();
            }
        }
    }
    return true;
}
Пример #3
0
 /**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgOut;
     $wgOut->setPageTitle(wfMsg('myip'));
     $ip = wfGetIP();
     $wgOut->addWikiText(wfMsg('myip-out') . " {$ip}");
 }
 /**
  *
  * @param string $name
  * @param int $amount
  * @return boolean false if failed
  */
 private function credit($name = null, $amount = 0)
 {
     $output = $this->getOutput();
     $output->addWikiText("=== Credit (name, amount) ===");
     $output->addWikiText("name = {$name}");
     $output->addWikiText("amount = {$amount}");
     $user = User::newFromName($name);
     if (!$user || $user->getId() == 0) {
         $output->addWikiText("=== ERROR: Invalid UserName ===");
         return false;
     }
     $output->addWikiText("=== User ===");
     $output->addWikiText("user_id = " . $user->getId());
     $output->addWikiText("user_name = " . $user->getName());
     $output->addWikiText("user_realname = " . $user->getRealName());
     $output->addWikiText("user_email = " . $user->getEmail());
     $output->addWikiText("=== Transaction ===");
     $output->addWikiText("True balance before = " . TMRecord::getTrueBalanceFromDB($user->getId()));
     if (!is_int($amount) || $amount <= 0 || $amount > 1000) {
         $output->addWikiText("=== ERROR: Invalid Amount ===");
         return false;
     }
     $tmr = array('tmr_type' => TM_REFUND_TYPE, 'tmr_user_id' => $user->getId(), 'tmr_mail' => $user->getEmail(), 'tmr_ip' => IP::sanitizeIP(wfGetIP()), 'tmr_amount' => $amount, 'tmr_currency' => 'EUR', 'tmr_desc' => 'tm-refund', 'tmr_status' => 'OK');
     wfRunHooks('CreateTransaction', array(&$tmr));
     $output->addWikiText("==== DONE ====");
     $output->addWikiText("True balance after = " . TMRecord::getTrueBalanceFromDB($user->getId()));
     $output->addWikiText("== SUCCESS ==");
 }
	public static function handleAFAction( $action, $parameters, $title, $vars, $rule_desc ) {
		global $wgUser;
		
		$dbw = wfGetDB( DB_MASTER );
		$dbQuery = array(
			'pmq_id' => '',
			'pmq_page_last_id' => $title->getLatestRevID(),
			'pmq_page_ns' => $title->getNamespace(),
			'pmq_page_title' => $title->getDBkey(),
			'pmq_user' => $wgUser->getID(),
			'pmq_user_text' => $wgUser->getName(),
			'pmq_timestamp' => $dbw->timestamp( wfTimestampNow() ),
			'pmq_minor' => $vars->getVar( 'minor_edit' )->toInt(),
			'pmq_summary' => $vars->getVar( 'summary' )->toString(),
			'pmq_len' => $title->getLength(),
			'pmq_text' => $vars->getVar( 'new_wikitext' )->toString(),
			'pmq_flags' => false,
			'pmq_ip' => wfGetIP(),
			'pmq_status' => 'new'
		);
		$dbw->insert( 'pm_queue', $dbQuery, __METHOD__ );
		$dbw->commit();
		
		return true;
	}
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgFundraiserLPDefaults;
     // Set the country parameter
     $country = $wgRequest->getVal('country');
     // If no country was passed do a GeoIP lookup
     if (!$country) {
         if (function_exists('geoip_country_code_by_name')) {
             $ip = wfGetIP();
             if (IP::isValid($ip)) {
                 $country = geoip_country_code_by_name($ip);
             }
         }
     }
     // If country still isn't set, set it to the default
     if (!$country) {
         $country = $wgFundraiserLPDefaults['country'];
     }
     $params = array('country' => $country);
     // Pass any other params that are set
     $excludeKeys = array('country', 'title');
     foreach ($wgRequest->getValues() as $key => $value) {
         // Skip the required variables
         if (!in_array($key, $excludeKeys)) {
             $params[$key] = $value;
         }
     }
     // Redirect to FundraiserLandingPage
     $wgOut->redirect($this->getTitleFor('FundraiserLandingPage')->getLocalUrl($params));
 }
	public function execute( $subpage ) {
		$this->setHeaders();

		$out = $this->getOutput();
		$out->addHTML( Xml::openElement( 'table', array( 'class' => 'wikitable' ) ) );

		$out->addHTML( '<thead>' );
		$out->addHTML( '<tr>' );
		$out->addHTML( '<th>' );
		$out->addWikiMsg( 'userdebuginfo-key' );
		$out->addHTML( '</th>' );
		$out->addHTML( '<th>' );
		$out->addWikiMsg( 'userdebuginfo-value' );
		$out->addHTML( '</th>' );
		$out->addHTML( '</tr>' );
		$out->addHTML( '</thead>' );

		$out->addHTML( '<tbody>' );

		$this->printRow( 'userdebuginfo-useragent', htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) );

		if ( isset( $_SERVER['REMOTE_HOST'] ) ) {
			$this->printRow( 'userdebuginfo-remotehost', $_SERVER['REMOTE_HOST'] );
		}

		$this->printRow( 'userdebuginfo-remoteaddr', wfGetIP() );
		$this->printRow( 'userdebuginfo-language', htmlspecialchars( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) );

		$out->addHTML( '</tbody>' );
		$out->addHTML( '</table>' );
	}
Пример #8
0
    function execute($par)
    {
        global $wgRequest, $wgOut, $wgUser;
        $target = isset($par) ? $par : $wgRequest->getVal('target');
        if ($target == 'getip') {
            //$h = print_r($_SERVER, true);
            $wgOut->disable();
            echo wfGetIP();
            return;
        }
        $wgOut->addHTML(<<<END
<script type='text/javascript'>

\t\t\t\$(document).ready(function() {
\t\t\t\t\t\tvar obj = \$.ajax({
   type: 'POST',
   url:'/Special:TestBadIP',
\tdata: 'target=getip',
   success: function(msg){
     alert( msg +   obj.getAllResponseHeaders());
\t
   }
 });
\t\t\t\t\t}
\t\t\t\t);
\t\t\t
\t\t</script>
END
);
        return;
    }
Пример #9
0
 public function execute($sub)
 {
     global $wgOut, $wgRequest;
     global $wgLandingPageBase, $wgChapterLandingPages, $wgLandingPageDefaultTarget;
     $lang = preg_match('/^[A-Za-z-]+$/', $wgRequest->getVal('lang')) ? $wgRequest->getVal('lang') : 'en';
     $utm_source = $wgRequest->getVal('utm_source');
     $utm_medium = $wgRequest->getVal('utm_medium');
     $utm_campaign = $wgRequest->getVal('utm_campaign');
     $referrer = $wgRequest->getHeader('referer');
     $target = $wgRequest->getVal('target', null);
     if (!$target) {
         $target = $wgLandingPageDefaultTarget;
     }
     $tracking = '?' . wfArrayToCGI(array('utm_source' => "{$utm_source}", 'utm_medium' => "{$utm_medium}", 'utm_campaign' => "{$utm_campaign}", 'referrer' => "{$referrer}", 'target' => "{$target}"));
     $ip = $wgRequest->getVal('ip') ? $wgRequest->getVal('ip') : wfGetIP();
     if (IP::isValid($ip)) {
         $country = geoip_country_code_by_name($ip);
         if (is_string($country) && array_key_exists($country, $wgChapterLandingPages)) {
             $wgOut->redirect($this->getDestination($utm_source) . '/' . $wgChapterLandingPages[$country] . $tracking);
             return;
         }
     }
     // No valid IP or chapter page - let's just go for the passed in url or our fallback
     if (Http::isValidURI($target)) {
         $wgOut->redirect($target . '/' . $lang . $tracking);
         return;
     } else {
         $wgOut->redirect($wgLandingPageBase . $target . '/' . $lang . $tracking);
     }
 }
/**
 * Set $wgDebugLogGroups['UploadBlacklist'] to direct logging to a particular
 * file instead of the debug log.
 *
 * @param string $action
 * @param string $hash
 * @param string $saveName
 * @param string $tempName
 * @access private
 */
function ubLog( $action, $hash, $saveName, $tempName ) {
	global $wgUser;
	$user = $wgUser->getName();
	$ip = wfGetIP();
	$ts = wfTimestamp( TS_DB );
	wfDebugLog( 'UploadBlacklist', "$ts $action [$hash] name:$saveName file:$tempName user:$user ip:$ip" );
}
 function tagProxyChange($recentChange)
 {
     global $wgTagProxyActions, $wgUser;
     if ($wgTagProxyActions && self::isProxy(wfGetIP()) && !$wgUser->isAllowed('notagproxychanges')) {
         ChangeTags::addTags('proxy', $recentChange->mAttribs['rc_id'], $recentChange->mAttribs['rc_this_oldid'], $recentChange->mAttribs['rc_logid']);
     }
     return true;
 }
 function submit($info)
 {
     global $wgOut, $wgCommunityHiringDatabase;
     $dbw = wfGetDB(DB_MASTER, array(), $wgCommunityHiringDatabase);
     $dbw->insert('community_hiring_application', array('ch_data' => json_encode($info), 'ch_ip' => wfGetIP(), 'ch_timestamp' => wfTimestampNow(TS_DB)), __METHOD__);
     $wgOut->addWikiMsg('communityhiring-done');
     return true;
 }
Пример #13
0
 function getToken2()
 {
     global $wgRequest, $wgUser;
     $target = urldecode($wgRequest->getVal('target'));
     //$s = $wgUser->getID() . $_SERVER['HTTP_X_FORWARDED_FOR'] . $_SERVER['REMOTE_ADDR'] . $target . date ("YmdH", time() - 40 * 40);
     $s = $wgUser->getID() . wfGetIP() . $target . date("YmdH", time() - 40 * 40);
     return md5($s);
 }
Пример #14
0
function efNetworkAuth_checkForNetworkAuthUser()
{
    global $wgNetworkAuthUsers;
    $ip = wfGetIP();
    foreach ($wgNetworkAuthUsers as $networkAuthUser) {
        if (isset($networkAuthUser['user'])) {
            if (isset($networkAuthUser['iprange'])) {
                if (is_array($networkAuthUser['iprange'])) {
                    $ranges = $networkAuthUser['iprange'];
                } else {
                    $ranges = explode("\n", $networkAuthUser['iprange']);
                }
                $hex = IP::toHex($ip);
                foreach ($ranges as $range) {
                    $parsedRange = IP::parseRange($range);
                    if ($hex >= $parsedRange[0] && $hex <= $parsedRange[1]) {
                        global $wgNetworkAuthHost;
                        $wgNetworkAuthHost = $ip;
                        return $networkAuthUser['user'];
                    }
                }
            }
            if (isset($networkAuthUser['ippattern'])) {
                if (is_array($networkAuthUser['ippattern'])) {
                    $patterns = $networkAuthUser['ippattern'];
                } else {
                    $patterns = explode("\n", $networkAuthUser['ippattern']);
                }
                foreach ($patterns as $pattern) {
                    if (preg_match($pattern, $ip)) {
                        global $wgNetworkAuthHost;
                        $wgNetworkAuthHost = $ip;
                        return $networkAuthUser['user'];
                    }
                }
            }
            if (isset($networkAuthUser['hostpattern'])) {
                if (is_array($networkAuthUser['hostpattern'])) {
                    $patterns = $networkAuthUser['hostpattern'];
                } else {
                    $patterns = explode("\n", $networkAuthUser['hostpattern']);
                }
                $host = gethostbyaddr($ip);
                foreach ($patterns as $pattern) {
                    if (preg_match($pattern, $host)) {
                        global $wgNetworkAuthHost;
                        $wgNetworkAuthHost = $host;
                        return $networkAuthUser['user'];
                    }
                }
            }
        } else {
            # No user for range - useless.
        }
    }
    return '';
}
Пример #15
0
function mwBlockerCheck()
{
    global $wgDBname;
    $ip = wfGetIP();
    try {
        MWBlocker::queueCheck($ip, "creating account on {$wgDBname}");
    } catch (MWException $e) {
    }
    return true;
}
Пример #16
0
 /**
  * Calls the library function recaptcha_check_answer to verify the users input.
  * Sets $this->recaptcha_error if the user is incorrect.
  * @return boolean 
  *
  */
 function passCaptcha()
 {
     global $recaptcha_private_key;
     $recaptcha_response = recaptcha_check_answer($recaptcha_private_key, wfGetIP(), $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
     if (!$recaptcha_response->is_valid) {
         $this->recaptcha_error = $recaptcha_response->error;
         return false;
     }
     $recaptcha_error = null;
     return true;
 }
/**
 * Add extra info to the e-mail which gets sent to the staff.
 * @return Boolean: true
 */
function enhanceContactForm(&$to, &$replyto, &$subject, &$text)
{
    global $wgRequest;
    $text = 'Contact message by the user: ' . $wgRequest->getText('wpText') . "\n";
    // Now add the custom stuff
    $text .= 'URL of the wiki: ' . $wgRequest->getText('wpWikiURL') . "\n";
    $text .= 'Database name: ' . $wgRequest->getText('wpDBname') . "\n";
    $text .= 'IP address of the reporter: ' . wfGetIP() . "\n";
    $text .= 'Browser: ' . $wgRequest->getText('wpBrowser') . "\n";
    $text .= 'Operating system: ' . $wgRequest->getText('wpOperatingSystem') . "\n";
    $text .= 'User-Agent string: ' . $wgRequest->getText('wpUserAgent') . "\n";
    return true;
}
 function reassignArticleAnon($articleid)
 {
     global $wgUser;
     $dbw = wfGetDB(DB_MASTER);
     $rev_id = $dbw->selectField('revision', 'rev_id', array('rev_page' => intval($articleid), 'rev_user_text' => wfGetIP()), __METHOD__);
     if ($rev_id != '') {
         wfDebug("AXXX: reassinging {$rev_id} to {$wgUser->getName()}\n");
         $ret = $dbw->update('revision', array('rev_user_text' => $wgUser->getName(), 'rev_user' => $wgUser->getID()), array('rev_id' => $rev_id), __METHOD__);
         $ret = $dbw->update('recentchanges', array('rc_user_text' => $wgUser->getName(), 'rc_user' => $wgUser->getID()), array('rc_this_oldid' => $rev_id), __METHOD__);
     }
     $ret = $dbw->update('firstedit', array('fe_user_text' => $wgUser->getName(), 'fe_user' => $wgUser->getID()), array('fe_page' => $articleid, 'fe_user_text' => wfGetIP()), __METHOD__);
     return false;
 }
Пример #19
0
function wfUserLoginLogError(&$tmpl)
{
    global $wgUser, $wgServerUser;
    if ($tmpl->data['message'] && $tmpl->data['messagetype'] == 'error') {
        $log = new LogPage('userlogin', false);
        $tmp = $wgUser->mId;
        if ($tmp == 0) {
            $wgUser->mId = $wgServerUser;
        }
        $log->addEntry('error', $wgUser->getUserPage(), $tmpl->data['message'], array(wfGetIP()));
        $wgUser->mId = $tmp;
    }
    return true;
}
Пример #20
0
function wfCheckIp($article, $user, $text)
{
    global $wgUser;
    $ip = wfGetIP();
    if (strpos($ip, "192.168.100") !== false) {
        $alerts = new MailAddress("alerts@wikihow.com");
        $subject = "Bad ip connected to " . wfHostname() . " - " . date("r");
        $body = "UHOH: {$ip} User {$wgUser->getName()} " . "\n-------------------------------------\n" . print_r(getallheaders(), true) . "\n-------------------------------------\n" . print_r($_POST, true) . "\n-------------------------------------\n" . print_r($_SERVER, true) . "\n-------------------------------------\n" . print_r($wgUser, true) . "\n-------------------------------------\n" . wfBacktrace() . "\n-------------------------------------\n" . print_r($article) . "\n";
        UserMailer::send($alerts, $alerts, $subject, $body, $alerts);
        error_log($body);
        wfDebug($body);
    }
    return true;
}
Пример #21
0
/**
 * Hook function for RecentChange_save
 * Saves user data into the cu_changes table
 */
function efUpdateCheckUserData($rc)
{
    global $wgUser;
    // Extract params
    extract($rc->mAttribs);
    // Get IP
    $ip = wfGetIP();
    // Get XFF header
    $xff = wfGetForwardedFor();
    list($xff_ip, $trusted) = efGetClientIPfromXFF($xff);
    // Our squid XFFs can flood this up sometimes
    $isSquidOnly = efXFFChainIsSquid($xff);
    // Get agent
    $agent = wfGetAgent();
    // Store the log action text for log events
    // $rc_comment should just be the log_comment
    // BC: check if log_type and log_action exists
    // If not, then $rc_comment is the actiontext and comment
    if (isset($rc_log_type) && $rc_type == RC_LOG) {
        $target = Title::makeTitle($rc_namespace, $rc_title);
        $actionText = LogPage::actionText($rc_log_type, $rc_log_action, $target, NULL, explode('\\n', $rc_params));
    } else {
        $actionText = '';
    }
    $dbw = wfGetDB(DB_MASTER);
    $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq');
    $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent);
    ## On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set!
    if (isset($rc_cur_id)) {
        $rcRow['cuc_page_id'] = $rc_cur_id;
    }
    $dbw->insert('cu_changes', $rcRow, __METHOD__);
    # Every 100th edit, prune the checkuser changes table.
    wfSeedRandom();
    if (0 == mt_rand(0, 99)) {
        # Periodically flush old entries from the recentchanges table.
        global $wgCUDMaxAge;
        $cutoff = $dbw->timestamp(time() - $wgCUDMaxAge);
        $recentchanges = $dbw->tableName('cu_changes');
        $sql = "DELETE FROM {$recentchanges} WHERE cuc_timestamp < '{$cutoff}'";
        $dbw->query($sql);
    }
    return true;
}
Пример #22
0
function fnGetGeoIP($ip_address = null)
{
    if (!isset($ip_address)) {
        $ip_address = IP::sanitizeIP(wfGetIP());
    }
    if (isset($_GET['ip'])) {
        $ip_address = IP::sanitizeIP($_GET['ip']);
    }
    if (!IP::isIPv4($ip_address)) {
        throw new UnsupportedGeoIP('Only IPv4 addresses are supported.');
    }
    $dbr = wfGetDB(DB_SLAVE);
    $long_ip = IP::toUnsigned($ip_address);
    $conditions = array('begin_ip_long <= ' . $long_ip, $long_ip . ' <= end_ip_long');
    $country_code = $dbr->selectField('geoip', 'country_code', $conditions, __METHOD__);
    if (!$country_code) {
        throw new NotFoundGeoIP('Could not identify the country for the provided IP address.');
    }
    return $country_code;
}
Пример #23
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgBlockOpenProxies, $wgProxyKey;
     $this->setHeaders();
     $this->outputHeader();
     $ip = wfGetIP();
     if (!$wgBlockOpenProxies || $wgRequest->getText('ip') != md5($ip . $wgProxyKey)) {
         $wgOut->addWikiMsg('proxyblocker-disabled');
         return;
     }
     $user = User::newFromName(wfMsgForContent('proxyblocker'));
     if (!$user->isLoggedIn()) {
         $user->addToDatabase();
     }
     $id = $user->getId();
     $reason = wfMsg('proxyblockreason');
     $block = new Block($ip, 0, $id, $reason, wfTimestampNow());
     $block->insert();
     $wgOut->addWikiMsg('proxyblocksuccess');
 }
Пример #24
0
 /**
  * Calls the library function recaptcha_check_answer to verify the users input.
  * Sets $this->recaptcha_error if the user is incorrect.
  * @return boolean
  *
  */
 function passCaptcha()
 {
     global $wgReCaptchaPrivateKey, $wgRequest;
     // API is hardwired to return wpCaptchaId and wpCaptchaWord, so use that if the standard two are empty
     $challenge = $wgRequest->getVal('recaptcha_challenge_field', $wgRequest->getVal('wpCaptchaId'));
     $response = $wgRequest->getVal('recaptcha_response_field', $wgRequest->getVal('wpCaptchaWord'));
     if ($response === null) {
         // new captcha session
         return false;
     }
     // Compat: WebRequest::getIP is only available since MW 1.19.
     $ip = method_exists($wgRequest, 'getIP') ? $wgRequest->getIP() : wfGetIP();
     $recaptcha_response = recaptcha_check_answer($wgReCaptchaPrivateKey, $ip, $challenge, $response);
     if (!$recaptcha_response->is_valid) {
         $this->recaptcha_error = $recaptcha_response->error;
         return false;
     }
     $recaptcha_error = null;
     return true;
 }
Пример #25
0
 static function log($pluginName)
 {
     global $wgRequest;
     $ip = wfGetIP();
     $action = $wgRequest->getVal('action', '<no action>');
     $title = $wgRequest->getVal('title', '<no title>');
     $text = $wgRequest->getVal('wpTextbox1');
     if (is_null($text)) {
         $text = '<no text>';
     } else {
         if (strlen($text) > 60) {
             $text = '"' . substr($text, 0, 60) . '..."';
         } else {
             $text = "\"{$text}\"";
         }
     }
     $action = str_replace("\n", '', $action);
     $title = str_replace("\n", '', $title);
     $text = str_replace("\n", '', $text);
     wfDebugLog('AntiBot', "{$ip} AntiBot plugin {$pluginName} hit: {$action} [[{$title}]] {$text}\n");
 }
	function execute( $par ) {

		global $wgOut, $wgUser, $wgRequest;

		$wgOut->setPageTitle( 'Add Collection' );

		if ( !$wgUser->isAllowed( 'addcollection' ) ) {
			$wgOut->addHTML( 'You do not have permission to add a collection.' );
			return false;
		}

		$dbr = wfGetDB( DB_MASTER );

		if ( $wgRequest->getText( 'collection' ) ) {
			require_once( 'WikiDataAPI.php' );
			require_once( 'Transaction.php' );

			$dc = $wgRequest->getText( 'dataset' );
			$collectionName = $wgRequest->getText( 'collection' );
			startNewTransaction( $wgUser->getID(), wfGetIP(), 'Add collection ' . $collectionName );
			bootstrapCollection( $collectionName, $wgRequest->getText( 'language' ), $wgRequest->getText( 'type' ), $dc );
			$wgOut->addHTML( wfMsg( 'ow_collection_added', $collectionName ) . "<br />" );
		}
		$datasets = wdGetDatasets();
		$datasetarray[''] = wfMsgSc( "none_selected" );
		foreach ( $datasets as $datasetid => $dataset ) {
			$datasetarray[$datasetid] = $dataset->fetchName();
		}

		$wgOut->addHTML( getOptionPanel(
			array(
				'Collection name:' => getTextBox( 'collection' ),
				'Language of name:' => getSuggest( 'language', 'language' ),
				'Collection type:' => getSelect( 'type', array( '' => 'None', 'RELT' => 'RELT', 'LEVL' => 'LEVL', 'CLAS' => 'CLAS', 'MAPP' => 'MAPP' ) ),
				'Dataset:' => getSelect( 'dataset', $datasetarray )
			),
			'', array( 'create' => wfMsg( 'ow_create' ) )
		) );
	}
Пример #27
0
/**
 *
 */
function wfSpecialBlockme()
{
    global $wgRequest, $wgBlockOpenProxies, $wgOut, $wgProxyKey;
    $ip = wfGetIP();
    if (!$wgBlockOpenProxies || $wgRequest->getText('ip') != md5($ip . $wgProxyKey)) {
        $wgOut->addWikiMsg('proxyblocker-disabled');
        return;
    }
    $blockerName = wfMsg("proxyblocker");
    $reason = wfMsg("proxyblockreason");
    $u = User::newFromName($blockerName);
    $id = $u->idForName();
    if (!$id) {
        $u = User::newFromName($blockerName);
        $u->addToDatabase();
        $u->setPassword(bin2hex(mt_rand(0, 0x7fffffff)));
        $u->saveSettings();
        $id = $u->getID();
    }
    $block = new Block($ip, 0, $id, $reason, wfTimestampNow());
    $block->insert();
    $wgOut->addWikiMsg("proxyblocksuccess");
}
 public function execute($sub)
 {
     global $wgRequest, $wgPriorityCountries;
     // Pull in query string parameters
     $language = $wgRequest->getVal('language', 'en');
     $this->basic = $wgRequest->getBool('basic');
     $country = $wgRequest->getVal('country');
     // If no country was passed, try to do GeoIP lookup
     // Requires php5-geoip package
     if (!$country && function_exists('geoip_country_code_by_name')) {
         $ip = wfGetIP();
         if (IP::isValid($ip)) {
             $country = geoip_country_code_by_name($ip);
         }
     }
     if (!$country) {
         $country = 'US';
         // Default
     }
     // determine if we are fulfilling a request for a priority country
     $priority = in_array($country, $wgPriorityCountries);
     // handle the actual redirect
     $this->routeRedirect($country, $language, $priority);
 }
Пример #29
0
 /**
  * @return string
  */
 function IPInfo()
 {
     $ip = str_replace('--', ' - ', htmlspecialchars(wfGetIP()));
     return "<!-- visited from {$ip} -->\n" . "<span style='display:none'>visited from {$ip}</span>";
 }
Пример #30
0
 public static function newLogEntry($timestamp, &$title, &$user, $actionComment, $ip = '', $type, $action, $target, $logComment, $params, $newId = 0)
 {
     global $wgRequest;
     if (!$ip) {
         $ip = wfGetIP();
         if (!$ip) {
             $ip = '';
         }
     }
     $rc = new RecentChange();
     $rc->mAttribs = array('rc_timestamp' => $timestamp, 'rc_cur_time' => $timestamp, 'rc_namespace' => $target->getNamespace(), 'rc_title' => $target->getDBkey(), 'rc_type' => RC_LOG, 'rc_minor' => 0, 'rc_cur_id' => $target->getArticleID(), 'rc_user' => $user->getId(), 'rc_user_text' => $user->getName(), 'rc_comment' => $logComment, 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_bot' => $user->isAllowed('bot') ? $wgRequest->getBool('bot', true) : 0, 'rc_moved_to_ns' => 0, 'rc_moved_to_title' => '', 'rc_ip' => $ip, 'rc_patrolled' => 1, 'rc_new' => 0, 'rc_old_len' => null, 'rc_new_len' => null, 'rc_deleted' => 0, 'rc_logid' => $newId, 'rc_log_type' => $type, 'rc_log_action' => $action, 'rc_params' => $params);
     $rc->mExtra = array('prefixedDBkey' => $title->getPrefixedDBkey(), 'lastTimestamp' => 0, 'actionComment' => $actionComment);
     return $rc;
 }