本文整理汇总了PHP中wfIsWindows函数的典型用法代码示例。如果您正苦于以下问题:PHP wfIsWindows函数的具体用法?PHP wfIsWindows怎么用?PHP wfIsWindows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfIsWindows函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
protected function __construct() {
$idFile = wfTempDir() . '/mw-' . __CLASS__ . '-UID-nodeid';
$nodeId = is_file( $idFile ) ? file_get_contents( $idFile ) : '';
// Try to get some ID that uniquely identifies this machine (RFC 4122)...
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
wfSuppressWarnings();
if ( wfIsWindows() ) {
// http://technet.microsoft.com/en-us/library/bb490913.aspx
$csv = trim( wfShellExec( 'getmac /NH /FO CSV' ) );
$line = substr( $csv, 0, strcspn( $csv, "\n" ) );
$info = str_getcsv( $line );
$nodeId = isset( $info[0] ) ? str_replace( '-', '', $info[0] ) : '';
} elseif ( is_executable( '/sbin/ifconfig' ) ) { // Linux/BSD/Solaris/OS X
// See http://linux.die.net/man/8/ifconfig
$m = array();
preg_match( '/\s([0-9a-f]{2}(:[0-9a-f]{2}){5})\s/',
wfShellExec( '/sbin/ifconfig -a' ), $m );
$nodeId = isset( $m[1] ) ? str_replace( ':', '', $m[1] ) : '';
}
wfRestoreWarnings();
if ( !preg_match( '/^[0-9a-f]{12}$/i', $nodeId ) ) {
$nodeId = MWCryptRand::generateHex( 12, true );
$nodeId[1] = dechex( hexdec( $nodeId[1] ) | 0x1 ); // set multicast bit
}
file_put_contents( $idFile, $nodeId ); // cache
}
$this->nodeId32 = wfBaseConvert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
$this->nodeId48 = wfBaseConvert( $nodeId, 16, 2, 48 );
// If different processes run as different users, they may have different temp dirs.
// This is dealt with by initializing the clock sequence number and counters randomly.
$this->lockFile88 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-88';
$this->lockFile128 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-128';
}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:33,代码来源:UIDGenerator.php
示例2: __construct
function __construct() {
global $wgWebStoreSettings, $wgUploadDirectory, $wgTmpDirectory, $wgFileStore;
foreach ( $wgWebStoreSettings as $name => $value ) {
$this->$name = $value;
}
if ( !$this->tmpDir ) {
$this->tmpDir = $wgTmpDirectory;
}
if ( !$this->publicDir ) {
$this->publicDir = $wgUploadDirectory;
}
if ( !$this->deletedDir ) {
if ( isset( $wgFileStore['deleted']['directory'] ) ) {
$this->deletedDir = $wgFileStore['deleted']['directory'];
} else {
// No deletion
$this->errors[] = new WebStoreWarning( 'webstore_no_deleted' );
$this->deletedDir = false;
}
}
$this->windows = wfIsWindows();
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:25,代码来源:WebStoreCommon.php
示例3: getLineEnding
function getLineEnding()
{
if (wfIsWindows()) {
return "\r\n";
} else {
return "\n";
}
}
开发者ID:valhallasw,项目名称:mediawiki-extensions-OpenStackManager,代码行数:8,代码来源:OpenStackNovaController.php
示例4: testToString
/**
* @covers MailAddress::toString
* @dataProvider provideToString
*/
public function testToString($useRealName, $address, $name, $realName, $expected)
{
if (wfIsWindows()) {
$this->markTestSkipped('This test only works on non-Windows platforms');
}
$this->setMwGlobals('wgEnotifUseRealName', $useRealName);
$ma = new MailAddress($address, $name, $realName);
$this->assertEquals($expected, $ma->toString());
}
开发者ID:rploaiza,项目名称:dbpedia-latinoamerica,代码行数:13,代码来源:MailAddressTest.php
示例5: testBug67870
public function testBug67870()
{
$command = wfIsWindows() ? 'for /l %i in (1, 1, 1001) do @echo ' . str_repeat('*', 331) : 'printf "%-333333s" "*"';
// Test several times because it involves a race condition that may randomly succeed or fail
for ($i = 0; $i < 10; $i++) {
$output = wfShellExec($command);
$this->assertEquals(333333, strlen($output));
}
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:wfShellExecTest.php
示例6: testMultipleArgsAsArray
public function testMultipleArgsAsArray()
{
if (wfIsWindows()) {
$expected = '"foo" "bar" "baz"';
} else {
$expected = "'foo' 'bar' 'baz'";
}
$actual = wfEscapeShellArg(['foo', 'bar', 'baz']);
$this->assertEquals($expected, $actual);
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:10,代码来源:wfEscapeShellArgTest.php
示例7: getVars
function getVars($_gv_filename)
{
require $_gv_filename;
$vars = get_defined_vars();
unset($vars['_gv_filename']);
# Clean up line endings
if (wfIsWindows()) {
$vars = unixLineEndings($vars);
}
return $vars;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:11,代码来源:serialize.php
示例8: open
/**
* Open a /dev/urandom file handle
* Returns a Status object
*/
function open() {
if ( $this->urandom ) {
return Status::newGood();
}
if ( wfIsWindows() ) {
return Status::newFatal( 'securepoll-urandom-not-supported' );
}
$this->urandom = fopen( '/dev/urandom', 'rb' );
if ( !$this->urandom ) {
return Status::newFatal( 'securepoll-dump-no-urandom' );
}
return Status::newGood();
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:Random.php
示例9: w2lTempDir
/**
* Tries to get the system directory for temporary files. The TMPDIR, TMP, and
* TEMP environment variables are then checked in sequence, and if none are set
* try sys_get_temp_dir() for PHP >= 5.2.1. All else fails, return /tmp for Unix
* or C:\Windows\Temp for Windows and hope for the best.
* It is common to call it with tempnam().
*
* NOTE: When possible, use instead the tmpfile() function to create
* temporary files to avoid race conditions on file creation, etc.
*
* This function is from MediaWiki 1.19
*
* @return String
*/
function w2lTempDir()
{
foreach (array('TMPDIR', 'TMP', 'TEMP') as $var) {
$tmp = getenv($var);
if ($tmp && file_exists($tmp) && is_dir($tmp) && is_writable($tmp)) {
return $tmp;
}
}
if (function_exists('sys_get_temp_dir')) {
return sys_get_temp_dir();
}
# Usual defaults
return wfIsWindows() ? 'C:\\Windows\\Temp' : '/tmp';
}
开发者ID:mediawiki-extensions,项目名称:wiki2latex,代码行数:28,代码来源:w2lFunctions.php
示例10: toString
/**
* Return formatted and quoted address to insert into SMTP headers
* @return string
*/
function toString()
{
# PHP's mail() implementation under Windows is somewhat shite, and
# can't handle "Joe Bloggs <[email protected]>" format email addresses,
# so don't bother generating them
if ($this->name != '' && !wfIsWindows()) {
$quoted = wfQuotedPrintable($this->name);
if (strpos($quoted, '.') !== false) {
$quoted = '"' . $quoted . '"';
}
return "{$quoted} <{$this->address}>";
} else {
return $this->address;
}
}
开发者ID:negabaro,项目名称:alfresco,代码行数:19,代码来源:UserMailer.php
示例11: testUnitTestFileNamesEndWithTest
/**
* Verify all files that appear to be tests have file names ending in
* Test. If the file names do not end in Test, they will not be run.
*/
public function testUnitTestFileNamesEndWithTest()
{
if (wfIsWindows()) {
$this->markTestSkipped('This test does not work on Windows');
}
$rootPath = escapeshellarg(__DIR__);
$testClassRegex = implode('|', array('ApiFormatTestBase', 'ApiTestCase', 'MediaWikiLangTestCase', 'MediaWikiTestCase', 'PHPUnit_Framework_TestCase'));
$testClassRegex = "^class .* extends ({$testClassRegex})";
$finder = "find {$rootPath} -name '*.php' '!' -name '*Test.php'" . " | xargs grep -El '{$testClassRegex}|function suite\\('";
$results = null;
$exitCode = null;
exec($finder, $results, $exitCode);
$this->assertEquals(0, $exitCode, 'Verify find/grep command succeeds.');
$results = array_filter($results, array($this, 'filterSuites'));
$this->assertEquals(array(), $results, 'Unit test file names must end with Test.');
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:20,代码来源:StructureTest.php
示例12: stream_open
function stream_open($path, $mode, $options, &$opened_path)
{
if ($mode[0] == 'r') {
$options = 'e -bd -so';
} elseif ($mode[0] == 'w') {
$options = 'a -bd -si';
} else {
return false;
}
$arg = wfEscapeShellArg($this->stripPath($path));
$command = "7za {$options} {$arg}";
if (!wfIsWindows()) {
// Suppress the stupid messages on stderr
$command .= ' 2>/dev/null';
}
$this->stream = popen($command, $mode);
return $this->stream !== false;
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:18,代码来源:dumpTextPass.php
示例13: main
public static function main($exit = true)
{
$command = new self();
if (wfIsWindows()) {
# Windows does not come anymore with ANSI.SYS loaded by default
# PHPUnit uses the suite.xml parameters to enable/disable colors
# which can be then forced to be enabled with --colors.
# The below code inject a parameter just like if the user called
# phpunit with a --no-color option (which does not exist). It
# overrides the suite.xml setting.
# Probably fix bug 29226
$command->arguments['colors'] = false;
}
# Makes MediaWiki PHPUnit directory includable so the PHPUnit will
# be able to resolve relative files inclusion such as suites/*
# PHPUnit uses stream_resolve_include_path() internally
# See bug 32022
set_include_path(__DIR__ . PATH_SEPARATOR . get_include_path());
$command->run($_SERVER['argv'], $exit);
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:20,代码来源:MediaWikiPHPUnitCommand.php
示例14: testUnitTestFileNamesEndWithTest
/**
* Verify all files that appear to be tests have file names ending in
* Test. If the file names do not end in Test, they will not be run.
* @group medium
*/
public function testUnitTestFileNamesEndWithTest()
{
if (wfIsWindows()) {
$this->markTestSkipped('This test does not work on Windows');
}
$rootPath = escapeshellarg(__DIR__ . '/..');
$testClassRegex = implode('|', ['ApiFormatTestBase', 'ApiTestCase', 'ApiQueryTestBase', 'ApiQueryContinueTestBase', 'MediaWikiLangTestCase', 'MediaWikiMediaTestCase', 'MediaWikiTestCase', 'ResourceLoaderTestCase', 'PHPUnit_Framework_TestCase', 'DumpTestCase']);
$testClassRegex = "^class .* extends ({$testClassRegex})";
$finder = "find {$rootPath} -name '*.php' '!' -name '*Test.php'" . " | xargs grep -El '{$testClassRegex}|function suite\\('";
$results = null;
$exitCode = null;
exec($finder, $results, $exitCode);
$this->assertEquals(0, $exitCode, 'Verify find/grep command succeeds.');
$results = array_filter($results, [$this, 'filterSuites']);
$strip = strlen($rootPath) - 1;
foreach ($results as $k => $v) {
$results[$k] = substr($v, $strip);
}
$this->assertEquals([], $results, "Unit test file in {$rootPath} must end with Test.");
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:25,代码来源:StructureTest.php
示例15: toString
/**
* Return formatted and quoted address to insert into SMTP headers
* @return string
*/
function toString()
{
# PHP's mail() implementation under Windows is somewhat shite, and
# can't handle "Joe Bloggs <[email protected]>" format email addresses,
# so don't bother generating them
if ($this->address) {
if ($this->name != '' && !wfIsWindows()) {
global $wgEnotifUseRealName;
$name = $wgEnotifUseRealName && $this->realName !== '' ? $this->realName : $this->name;
$quoted = UserMailer::quotedPrintable($name);
if (strpos($quoted, '.') !== false || strpos($quoted, ',') !== false) {
$quoted = '"' . $quoted . '"';
}
return "{$quoted} <{$this->address}>";
} else {
return $this->address;
}
} else {
return "";
}
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:25,代码来源:MailAddress.php
示例16: Wikitext
/**
* Get wikitext from a the file passed as argument or STDIN
* @return string Wikitext
*/
protected function Wikitext()
{
$php_stdin = 'php://stdin';
$input_file = $this->getArg(0, $php_stdin);
if ($input_file === $php_stdin && !$this->mQuiet) {
$ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
$this->error(basename(__FILE__) . ": warning: reading wikitext from STDIN. Press {$ctrl} to parse.\n");
}
return file_get_contents($input_file);
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:14,代码来源:parse.php
示例17: execute
public function execute()
{
global $IP;
// Deregister handler from MWExceptionHandler::installHandle so that PHPUnit's own handler
// stays in tact.
// Has to in execute() instead of finalSetup(), because finalSetup() runs before
// doMaintenance.php includes Setup.php, which calls MWExceptionHandler::installHandle().
restore_error_handler();
$this->forceFormatServerArgv();
# Make sure we have --configuration or PHPUnit might complain
if (!in_array('--configuration', $_SERVER['argv'])) {
// Hack to eliminate the need to use the Makefile (which sucks ATM)
array_splice($_SERVER['argv'], 1, 0, array('--configuration', $IP . '/tests/phpunit/suite.xml'));
}
# --with-phpunitdir let us override the default PHPUnit version
# Can use with either or phpunit.phar in the directory or the
# full PHPUnit code base.
if ($this->hasOption('with-phpunitdir')) {
$phpunitDir = $this->getOption('with-phpunitdir');
# prepends provided PHPUnit directory or phar
$this->output("Will attempt loading PHPUnit from `{$phpunitDir}`\n");
set_include_path($phpunitDir . PATH_SEPARATOR . get_include_path());
# Cleanup $args array so the option and its value do not
# pollute PHPUnit
$key = array_search('--with-phpunitdir', $_SERVER['argv']);
unset($_SERVER['argv'][$key]);
// the option
unset($_SERVER['argv'][$key + 1]);
// its value
$_SERVER['argv'] = array_values($_SERVER['argv']);
}
if (!wfIsWindows()) {
# If we are not running on windows then we can enable phpunit colors
# Windows does not come anymore with ANSI.SYS loaded by default
# PHPUnit uses the suite.xml parameters to enable/disable colors
# which can be then forced to be enabled with --colors.
# The below code injects a parameter just like if the user called
# Probably fix bug 29226
$key = array_search('--colors', $_SERVER['argv']);
if ($key === false) {
array_splice($_SERVER['argv'], 1, 0, '--colors');
}
}
# Makes MediaWiki PHPUnit directory includable so the PHPUnit will
# be able to resolve relative files inclusion such as suites/*
# PHPUnit uses stream_resolve_include_path() internally
# See bug 32022
$key = array_search('--include-path', $_SERVER['argv']);
if ($key === false) {
array_splice($_SERVER['argv'], 1, 0, __DIR__ . PATH_SEPARATOR . get_include_path());
array_splice($_SERVER['argv'], 1, 0, '--include-path');
}
$key = array_search('--debug-tests', $_SERVER['argv']);
if ($key !== false && array_search('--printer', $_SERVER['argv']) === false) {
unset($_SERVER['argv'][$key]);
array_splice($_SERVER['argv'], 1, 0, 'MediaWikiPHPUnitTestListener');
array_splice($_SERVER['argv'], 1, 0, '--printer');
}
foreach (self::$additionalOptions as $option => $default) {
$key = array_search('--' . $option, $_SERVER['argv']);
if ($key !== false) {
unset($_SERVER['argv'][$key]);
if ($this->mParams[$option]['withArg']) {
self::$additionalOptions[$option] = $_SERVER['argv'][$key + 1];
unset($_SERVER['argv'][$key + 1]);
} else {
self::$additionalOptions[$option] = true;
}
}
}
}
开发者ID:Gomyul,项目名称:mediawiki,代码行数:71,代码来源:phpunit.php
示例18: getLog
function getLog($path, $startRev = null, $endRev = null)
{
$lang = wfIsWindows() ? "" : "LC_ALL=en_US.utf-8 ";
$command = sprintf("{$lang}svn log -v -r%s:%s %s %s", wfEscapeShellArg($this->_rev($startRev, 'BASE')), wfEscapeShellArg($this->_rev($endRev, 'HEAD')), $this->getExtraArgs(), wfEscapeShellArg($this->mRepoPath . $path));
$lines = explode("\n", wfShellExec($command));
$out = array();
$divider = str_repeat('-', 72);
$formats = array('rev' => '/^r(\\d+)$/', 'author' => '/^(.*)$/', 'date' => '/^(?:(.*?) )?\\(.*\\)$/', 'lines' => '/^(\\d+) lines?$/');
$state = "start";
foreach ($lines as $line) {
$line = rtrim($line);
switch ($state) {
case "start":
if ($line == $divider) {
$state = "revdata";
break;
} else {
return $out;
# throw new MWException( "Unexpected start line: $line" );
}
case "revdata":
if ($line == "") {
$state = "done";
break;
}
$data = array();
$bits = explode(" | ", $line);
$i = 0;
foreach ($formats as $key => $regex) {
$text = $bits[$i++];
$matches = array();
if (preg_match($regex, $text, $matches)) {
$data[$key] = $matches[1];
} else {
throw new MWException("Unexpected format for {$key} in '{$text}'");
}
}
$data['msg'] = '';
$data['paths'] = array();
$state = 'changedpaths';
break;
case "changedpaths":
if ($line == "Changed paths:") {
// broken when svn messages are not in English
$state = "path";
} elseif ($line == "") {
// No changed paths?
$state = "msg";
} else {
throw new MWException("Expected 'Changed paths:' or '', got '{$line}'");
}
break;
case "path":
if ($line == "") {
// Out of paths. Move on to the message...
$state = 'msg';
} else {
$matches = array();
if (preg_match('/^ (.) (.*)$/', $line, $matches)) {
$data['paths'][] = array('action' => $matches[1], 'path' => $matches[2]);
}
}
break;
case "msg":
$data['msg'] .= $line;
if (--$data['lines']) {
$data['msg'] .= "\n";
} else {
unset($data['lines']);
$out[] = $data;
$state = "start";
}
break;
case "done":
throw new MWException("Unexpected input after end: {$line}");
default:
throw new MWException("Invalid state '{$state}'");
}
}
return $out;
}
开发者ID:yusufchang,项目名称:app,代码行数:81,代码来源:Subversion.php
示例19: wfGetNull
/**
* Get a platform-independent path to the null file, e.g. /dev/null
*
* @return string
*/
function wfGetNull()
{
return wfIsWindows() ? 'NUL' : '/dev/null';
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:9,代码来源:GlobalFunctions.php
示例20: detectVirus
/**
* Generic wrapper function for a virus scanner program.
* This relies on the $wgAntivirus and $wgAntivirusSetup variables.
* $wgAntivirusRequired may be used to deny upload if the scan fails.
*
* @param string $file Pathname to the temporary upload file
* @return mixed false if not virus is found, NULL if the scan fails or is disabled,
* or a string containing feedback from the virus scanner if a virus was found.
* If textual feedback is missing but a virus was found, this function returns true.
*/
function detectVirus( $file ) {
global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired;
if ( !$wgAntivirus ) { # disabled?
wfDebug( __METHOD__ . ": virus scanner disabled\n" );
return null;
}
if ( !$wgAntivirusSetup[$wgAntivirus] ) {
wfDebug( __METHOD__ . ": unknown virus scanner: $wgAntivirus\n" );
$wgOut->addHTML( '<div class="error">' . wfMsg( 'virus-badscanner', $wgAntivirus ) . "\n" );
return wfMsg( 'virus-unknownscanner' ) . $wgAntivirus;
}
# look up scanner configuration
$virus_scanner = $wgAntivirusSetup[$wgAntivirus]['command']; # command pattern
$virus_scanner_codes = $wgAntivirusSetup[$wgAntivirus]['codemap']; # exit-code map
$msg_pattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern']; # message pattern
$scanner = $virus_scanner; # copy, so we can resolve the pattern
if ( strpos( $scanner, "%f" ) === false ) {
$scanner .= ' ' . wfEscapeShellArg( $file ); # simple pattern: append file to scan
} else {
$scanner = str_replace( "%f", wfEscapeShellArg( $file ), $scanner ); # complex pattern: replace "%f" with file to scan
}
wfDebug( __METHOD__ . ": running virus scan: $scanner \n" );
# execute virus scanner
$code = false;
# NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
# that does not seem to be worth the pain.
# Ask me (Duesentrieb) about it if it's ever needed.
if ( wfIsWindows() ) {
exec( "$scanner", $output, $code );
} else {
exec( "$scanner 2>&1", $output, $code );
}
$exit_code = $code; # remeber for user feedback
if ( $virus_scanner_codes ) { # map exit code to AV_xxx constants.
if ( isset( $virus_scanner_codes[$code] ) ) {
$code = $virus_scanner_codes[$code]; # explicite mapping
} elseif ( isset( $virus_scanner_codes['*'] ) ) {
$code = $virus_scanner_codes['*']; # fallback mapping
}
}
if ( $code === AV_SCAN_FAILED ) { # scan failed (code was mapped to false by $virus_scanner_codes)
wfDebug( __METHOD__ . ": failed to scan $file (code $exit_code).\n" );
if ( $wgAntivirusRequired ) {
return wfMsg( 'virus-scanfailed', $exit_code );
} else {
return null;
}
} elseif ( $code === AV_SCAN_ABORTED ) { # scan failed because filetype is unknown (probably immune)
wfDebug( __METHOD__ . ": unsupported file type $file (code $exit_code).\n" );
return null;
} elseif ( $code === AV_NO_VIRUS ) {
wfDebug( __METHOD__ . ": file passed virus scan.\n" );
return false; # no virus found
} else {
$output = join( "\n", $output );
$output = trim( $output );
if ( !$output ) {
$output = true; # if there's no output, return true
} elseif ( $msg_pattern ) {
$groups = array();
if ( preg_match( $msg_pattern, $output, $groups ) ) {
if ( $groups[1] ) {
$output = $groups[1];
}
}
}
wfDebug( __METHOD__ . ": FOUND VIRUS! scanner feedback: $output" );
return $output;
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:95,代码来源:SpecialGiftManagerLogo.php
注:本文中的wfIsWindows函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论