当前位置: 首页>>代码示例>>PHP>>正文


PHP wfGetIP函数代码示例

本文整理汇总了PHP中wfGetIP函数的典型用法代码示例。如果您正苦于以下问题:PHP wfGetIP函数的具体用法?PHP wfGetIP怎么用?PHP wfGetIP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wfGetIP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wfProxyCheck

/**
 * 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);
        }
    }
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:37,代码来源:ProxyTools.php

示例2: ipAuthUserLoadAfterLoadFromSession

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;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:29,代码来源:IPAuth.php

示例3: execute

 /**
  * 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}");
 }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:12,代码来源:MyIP_body.php

示例4: credit

 /**
  *
  * @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 ==");
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:SpecialTransactionsAdmin.php

示例5: handleAFAction

	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;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:Premoderation.class.php

示例6: execute

 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));
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:FundraiserRedirector.body.php

示例7: execute

	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>' );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:SpecialUserDebugInfo.php

示例8: execute

    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;
    }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:TestBadIP.body.php

示例9: execute

 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);
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:GeoLite_body.php

示例10: ubLog

/**
 * 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" );
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:UploadBlacklist.php

示例11: tagProxyChange

 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;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:8,代码来源:AutoProxyBlock.body.php

示例12: submit

 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;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:8,代码来源:SpecialCommunityHiring.php

示例13: getToken2

 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);
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:8,代码来源:EmailLink.body.php

示例14: efNetworkAuth_checkForNetworkAuthUser

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 '';
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:57,代码来源:NetworkAuth.php

示例15: mwBlockerCheck

function mwBlockerCheck()
{
    global $wgDBname;
    $ip = wfGetIP();
    try {
        MWBlocker::queueCheck($ip, "creating account on {$wgDBname}");
    } catch (MWException $e) {
    }
    return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:10,代码来源:MWBlockerHook.php


注:本文中的wfGetIP函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。