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


PHP OS_Guess类代码示例

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


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

示例1: doMakeRPM


//.........这里部分代码省略.........
                 case 'ext':
                     $prefix = '%{_libdir}/php';
                     break;
                     // XXX good place?
                 // XXX good place?
                 case 'src':
                     $srcfiles++;
                     $prefix = '%{_includedir}/php';
                     break;
                     // XXX good place?
                 // XXX good place?
                 case 'test':
                     $prefix = "{$c_prefix}/tests/" . $pf->getPackage();
                     break;
                 case 'data':
                     $prefix = "{$c_prefix}/data/" . $pf->getPackage();
                     break;
                 case 'script':
                     $prefix = '%{_bindir}';
                     break;
                 default:
                     // non-standard roles
                     $prefix = "{$c_prefix}/{$attr['role']}/" . $pf->getPackage();
                     $info['extra_config'] .= "\n        -d {$attr[role]}_dir={$c_prefix}/{$attr[role]} \\";
                     $this->ui->outputData('WARNING: role "' . $attr['role'] . '" used, ' . 'and will be installed in "' . $c_prefix . '/' . $attr['role'] . '/' . $pf->getPackage() . ' - hand-edit the final .spec if this is wrong', $command);
                     break;
             }
             $name = str_replace('\\', '/', $name);
             $info['files'] .= "{$prefix}/{$name}\n";
         }
     }
     if ($srcfiles > 0) {
         require_once 'OS/Guess.php';
         $os = new OS_Guess();
         $arch = $os->getCpu();
     } else {
         $arch = 'noarch';
     }
     $cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'test_dir');
     foreach ($cfg as $k) {
         if ($k == 'master_server') {
             $chan = $reg->getChannel($pf->getChannel());
             $info[$k] = $chan->getServer();
             continue;
         }
         $info[$k] = $this->config->get($k);
     }
     $info['arch'] = $arch;
     $fp = @fopen($spec_template, "r");
     if (!$fp) {
         return $this->raiseError("could not open RPM spec file template {$spec_template}: {$php_errormsg}");
     }
     $info['package'] = $pf->getPackage();
     $info['version'] = $pf->getVersion();
     $info['release_license'] = $pf->getLicense();
     if ($pf->getDeps()) {
         if ($pf->getPackagexmlVersion() == '1.0') {
             $requires = $conflicts = array();
             foreach ($pf->getDeps() as $dep) {
                 if (isset($dep['optional']) && $dep['optional'] == 'yes') {
                     continue;
                 }
                 if ($dep['type'] != 'pkg') {
                     continue;
                 }
                 if (isset($dep['channel']) && $dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
开发者ID:BackupTheBerlios,项目名称:rheinaufcms-svn,代码行数:67,代码来源:Package.php

示例2: _installFile

 /**
  * @param string filename
  * @param array attributes from <file> tag in package.xml
  * @param string path to install the file in
  * @param array options from command-line
  * @access private
  */
 function _installFile($file, $atts, $tmp_path, $options)
 {
     // {{{ return if this file is meant for another platform
     static $os;
     if (!isset($this->_registry)) {
         $this->_registry =& $this->config->getRegistry();
     }
     if (isset($atts['platform'])) {
         if (empty($os)) {
             $os = new OS_Guess();
         }
         if (strlen($atts['platform']) && $atts['platform'][0] == '!') {
             $negate = true;
             $platform = substr($atts['platform'], 1);
         } else {
             $negate = false;
             $platform = $atts['platform'];
         }
         if ((bool) $os->matchSignature($platform) === $negate) {
             $this->log(3, "skipped {$file} (meant for {$atts['platform']}, we are " . $os->getSignature() . ")");
             return PEAR_INSTALLER_SKIPPED;
         }
     }
     // }}}
     $channel = $this->pkginfo->getChannel();
     // {{{ assemble the destination paths
     switch ($atts['role']) {
         case 'doc':
         case 'data':
         case 'test':
             $dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel) . DIRECTORY_SEPARATOR . $this->pkginfo->getPackage();
             unset($atts['baseinstalldir']);
             break;
         case 'ext':
         case 'php':
             $dest_dir = $this->config->get($atts['role'] . '_dir', null, $channel);
             break;
         case 'script':
             $dest_dir = $this->config->get('bin_dir', null, $channel);
             break;
         case 'src':
         case 'extsrc':
             $this->source_files++;
             return;
         default:
             return $this->raiseError("Invalid role `{$atts['role']}' for file {$file}");
     }
     $save_destdir = $dest_dir;
     if (!empty($atts['baseinstalldir'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
     }
     if (dirname($file) != '.' && empty($atts['install-as'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
     }
     if (empty($atts['install-as'])) {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
     } else {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
     }
     $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
     // Clean up the DIRECTORY_SEPARATOR mess
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     list($dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), array($dest_file, $orig_file));
     $final_dest_file = $installed_as = $dest_file;
     if (isset($this->_options['packagingroot'])) {
         $installedas_dest_dir = dirname($final_dest_file);
         $installedas_dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
         $final_dest_file = $this->_prependPath($final_dest_file, $this->_options['packagingroot']);
     } else {
         $installedas_dest_dir = dirname($final_dest_file);
         $installedas_dest_file = $installedas_dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     }
     $dest_dir = dirname($final_dest_file);
     $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     // }}}
     if (empty($this->_options['register-only']) && !@is_dir($dest_dir)) {
         if (!$this->mkDirHier($dest_dir)) {
             return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
         }
         $this->log(3, "+ mkdir {$dest_dir}");
     }
     // pretty much nothing happens if we are only registering the install
     if (empty($this->_options['register-only'])) {
         if (empty($atts['replacements'])) {
             if (!file_exists($orig_file)) {
                 return $this->raiseError("file {$orig_file} does not exist", PEAR_INSTALLER_FAILED);
             }
             if (!@copy($orig_file, $dest_file)) {
                 return $this->raiseError("failed to write {$dest_file}", PEAR_INSTALLER_FAILED);
             }
             $this->log(3, "+ cp {$orig_file} {$dest_file}");
             if (isset($atts['md5sum'])) {
                 $md5sum = md5_file($dest_file);
//.........这里部分代码省略.........
开发者ID:zseand,项目名称:kloxo,代码行数:101,代码来源:Installer.php

示例3: checkOS

 /**
  * Operating system  dependencies check method
  *
  * @param string $os  Name of the operating system
  *
  * @return mixed bool false if no error or the error string
  */
 function checkOS(&$errmsg, $os)
 {
     // XXX Fixme: Implement a more flexible way, like
     // comma separated values or something similar to PEAR_OS
     static $myos;
     if (empty($myos)) {
         $myos = new OS_Guess();
     }
     // only 'has' relation is currently supported
     if ($myos->matchSignature($os)) {
         return false;
     }
     $errmsg = "'{$os}' operating system not supported";
     return PEAR_DEPENDENCY_CONFLICT;
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:22,代码来源:Dependency.php

示例4: _setSystemName

 /** 
  * Resolve the system name
  *
  * @access private
  */
 function _setSystemName()
 {
     $OS_Guess = new OS_Guess();
     $sysname = $OS_Guess->getSysname();
     /* Nasty hack for Debian, as it uses a custom ping version */
     if ('linux' == $sysname) {
         if (file_exists('/etc/debian_version')) {
             $sysname = 'debian';
         }
     }
     return $sysname;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:17,代码来源:Ping.php

示例5: doMakeRPM

 function doMakeRPM($command, $options, $params)
 {
     if (sizeof($params) != 1) {
         return $this->raiseError("bad parameter(s), try \"help {$command}\"");
     }
     if (!file_exists($params[0])) {
         return $this->raiseError("file does not exist: {$params['0']}");
     }
     include_once "Archive/Tar.php";
     include_once "PEAR/Installer.php";
     include_once "System.php";
     $tar = new Archive_Tar($params[0]);
     $tmpdir = System::mktemp('-d pear2rpm');
     $instroot = System::mktemp('-d pear2rpm');
     $tmp = $this->config->get('verbose');
     $this->config->set('verbose', 0);
     $installer = new PEAR_Installer($this->ui);
     $info = $installer->install($params[0], array('installroot' => $instroot, 'nodeps' => true));
     $pkgdir = "{$info['package']}-{$info['version']}";
     $info['rpm_xml_dir'] = '/var/lib/pear';
     $this->config->set('verbose', $tmp);
     if (!$tar->extractList("package.xml", $tmpdir, $pkgdir)) {
         return $this->raiseError("failed to extract {$params['0']}");
     }
     if (!file_exists("{$tmpdir}/package.xml")) {
         return $this->raiseError("no package.xml found in {$params['0']}");
     }
     if (isset($options['spec-template'])) {
         $spec_template = $options['spec-template'];
     } else {
         $spec_template = $this->config->get('data_dir') . '/PEAR/template.spec';
     }
     if (isset($options['rpm-pkgname'])) {
         $rpm_pkgname_format = $options['rpm-pkgname'];
     } else {
         $rpm_pkgname_format = "PEAR::%s";
     }
     $info['extra_headers'] = '';
     $info['doc_files'] = '';
     $info['files'] = '';
     $info['rpm_package'] = sprintf($rpm_pkgname_format, $info['package']);
     $srcfiles = 0;
     foreach ($info['filelist'] as $name => $attr) {
         if ($attr['role'] == 'doc') {
             $info['doc_files'] .= " {$name}";
             // Map role to the rpm vars
         } else {
             $c_prefix = '%{_libdir}/php/pear';
             switch ($attr['role']) {
                 case 'php':
                     $prefix = $c_prefix;
                     break;
                 case 'ext':
                     $prefix = '%{_libdir}/php';
                     break;
                     // XXX good place?
                 // XXX good place?
                 case 'src':
                     $srcfiles++;
                     $prefix = '%{_includedir}/php';
                     break;
                     // XXX good place?
                 // XXX good place?
                 case 'test':
                     $prefix = "{$c_prefix}/tests/" . $info['package'];
                     break;
                 case 'data':
                     $prefix = "{$c_prefix}/data/" . $info['package'];
                     break;
                 case 'script':
                     $prefix = '%{_bindir}';
                     break;
             }
             $info['files'] .= "{$prefix}/{$name}\n";
         }
     }
     if ($srcfiles > 0) {
         include_once "OS/Guess.php";
         $os = new OS_Guess();
         $arch = $os->getCpu();
     } else {
         $arch = 'noarch';
     }
     $cfg = array('master_server', 'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'test_dir');
     foreach ($cfg as $k) {
         $info[$k] = $this->config->get($k);
     }
     $info['arch'] = $arch;
     $fp = @fopen($spec_template, "r");
     if (!$fp) {
         return $this->raiseError("could not open RPM spec file template {$spec_template}: {$php_errormsg}");
     }
     $spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\\1"]', fread($fp, filesize($spec_template)));
     fclose($fp);
     $spec_file = "{$info['rpm_package']}-{$info['version']}.spec";
     $wp = fopen($spec_file, "wb");
     if (!$wp) {
         return $this->raiseError("could not write RPM spec file {$spec_file}: {$php_errormsg}");
     }
     fwrite($wp, $spec_contents);
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:Package.php

示例6: _installFile

 function _installFile($file, $atts, $tmp_path)
 {
     static $os;
     if (isset($atts['platform'])) {
         if (empty($os)) {
             include_once "OS/Guess.php";
             $os = new OS_Guess();
         }
         // return if this file is meant for another platform
         if (!$os->matchSignature($atts['platform'])) {
             $this->log(3, "skipped {$file} (meant for {$atts['platform']}, we are " . $os->getSignature() . ")");
             return PEAR_INSTALLER_SKIPPED;
         }
     }
     switch ($atts['role']) {
         case 'doc':
         case 'data':
         case 'test':
             $dest_dir = $this->config->get($atts['role'] . '_dir') . DIRECTORY_SEPARATOR . $this->pkginfo['package'];
             unset($atts['baseinstalldir']);
             break;
         case 'ext':
         case 'php':
             $dest_dir = $this->config->get($atts['role'] . '_dir');
             break;
         case 'script':
             $dest_dir = $this->config->get('bin_dir');
             break;
         case 'src':
         case 'extsrc':
             $this->source_files++;
             return;
         default:
             return $this->raiseError("Invalid role `{$atts['role']}' for file {$file}");
     }
     if (!empty($atts['baseinstalldir'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
     }
     if (dirname($file) != '.' && empty($atts['install-as'])) {
         $dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
     }
     if (empty($atts['install-as'])) {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
     } else {
         $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
     }
     $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
     // Clean up the DIRECTORY_SEPARATOR mess
     $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
     list($dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!{$ds2}+!"), DIRECTORY_SEPARATOR, array($dest_file, $orig_file));
     $installed_as = $dest_file;
     $final_dest_file = $this->_prependPath($dest_file, $this->installroot);
     $dest_dir = dirname($final_dest_file);
     $dest_file = $dest_dir . DIRECTORY_SEPARATOR . '.tmp' . basename($final_dest_file);
     if (!@is_dir($dest_dir)) {
         if (!$this->mkDirHier($dest_dir)) {
             return $this->raiseError("failed to mkdir {$dest_dir}", PEAR_INSTALLER_FAILED);
         }
         $this->log(3, "+ mkdir {$dest_dir}");
     }
     if (empty($atts['replacements'])) {
         if (!@copy($orig_file, $dest_file)) {
             return $this->raiseError("failed to write {$dest_file}", PEAR_INSTALLER_FAILED);
         }
         $this->log(3, "+ cp {$orig_file} {$dest_file}");
         if (isset($atts['md5sum'])) {
             $md5sum = md5_file($dest_file);
         }
     } else {
         $fp = fopen($orig_file, "r");
         $contents = fread($fp, filesize($orig_file));
         fclose($fp);
         if (isset($atts['md5sum'])) {
             $md5sum = md5($contents);
         }
         $subst_from = $subst_to = array();
         foreach ($atts['replacements'] as $a) {
             $to = '';
             if ($a['type'] == 'php-const') {
                 if (preg_match('/^[a-z0-9_]+$/i', $a['to'])) {
                     eval("\$to = {$a['to']};");
                 } else {
                     $this->log(0, "invalid php-const replacement: {$a['to']}");
                     continue;
                 }
             } elseif ($a['type'] == 'pear-config') {
                 $to = $this->config->get($a['to']);
             } elseif ($a['type'] == 'package-info') {
                 $to = $this->pkginfo[$a['to']];
             }
             if ($to) {
                 $subst_from[] = $a['from'];
                 $subst_to[] = $to;
             }
         }
         $this->log(3, "doing " . sizeof($subst_from) . " substitution(s) for {$final_dest_file}");
         if (sizeof($subst_from)) {
             $contents = str_replace($subst_from, $subst_to, $contents);
         }
         $wp = @fopen($dest_file, "w");
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:101,代码来源:Installer.php

示例7: factory

 /**
  * Factory for Net_Traceroute
  *
  * Call this method to create a new instance of Net_Traceroute
  *
  * @return object Net_Traceroute
  * @access public
  */
 function factory()
 {
     $OS_Guess = new OS_Guess();
     $sysname = $OS_Guess->getSysname();
     $traceroute_path = '';
     if (($traceroute_path = Net_Traceroute::_setTraceroutePath($sysname)) == NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY) {
         return PEAR::throwError(NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY_MSG, NET_TRACEROUTE_CANT_LOCATE_TRACEROUTE_BINARY);
     } else {
         return new Net_Traceroute($traceroute_path, $sysname);
     }
 }
开发者ID:Evolix,项目名称:lilac,代码行数:19,代码来源:Traceroute.php

示例8: _setSystemName

 /** 
  * Resolve the system name
  *
  * @access private
  */
 function _setSystemName()
 {
     $OS_Guess = new OS_Guess();
     $sysname = $OS_Guess->getSysname();
     // Refine the sysname for different Linux bundles/vendors. (This
     // should go away if OS_Guess was ever extended to give vendor
     // and vendor-version guesses.)
     //
     // Bear in mind that $sysname is eventually used to craft a
     // method name to figure out which backend gets used to parse
     // the ping output. Elsewhere, we'll set $sysname back before
     // that.
     if ('linux' == $sysname) {
         if (file_exists('/etc/lsb-release') && false !== ($release = @file_get_contents('/etc/lsb-release')) && preg_match('/gutsy/i', $release)) {
             $sysname = 'linuxredhat9';
         } else {
             if (file_exists('/etc/debian_version')) {
                 $sysname = 'linuxdebian';
             } else {
                 if (file_exists('/etc/redhat-release') && false !== ($release = @file_get_contents('/etc/redhat-release'))) {
                     if (preg_match('/release 8/i', $release)) {
                         $sysname = 'linuxredhat8';
                     } elseif (preg_match('/release 9/i', $release)) {
                         $sysname = 'linuxredhat9';
                     }
                 }
             }
         }
     }
     return $sysname;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:36,代码来源:Ping.php

示例9: System_Folders

 /**
  * Constructor; initializes the system variable.
  */
 function System_Folders()
 {
     $og = new OS_Guess();
     $this->sys = $og->getSysname();
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:8,代码来源:Folders.php

示例10: htmlspecialchars

//lets look at some pear
echo PHP_EOL;
//C:\php\pear\docs\XML_Util\examples\example.php
require_once 'XML/Util.php';
/**
 * building document type declaration
 */
print 'building DocType declaration:<br>';
print htmlspecialchars(XML_Util::getDocTypeDeclaration('package', 'http://pear.php.net/dtd/package-1.0'));
print "\n<br><br>\n";
$modes = mcrypt_list_modes();
echo "mcrypt_list_modes <br>\n";
echo print_r_xml($modes);
//F:\bit5411\php\PEAR\OS\Guess.php  class OS_Guess
require_once 'OS/Guess.php';
$phpwhat = new OS_Guess();
//$phpwhat = OS_Guess::getSignature();  //fatal this
$tmp = $phpwhat->getSignature();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getSysname();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getNodename();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getCpu();
echo $tmp;
echo PHP_EOL;
$tmp = $phpwhat->getRelease();
echo $tmp;
开发者ID:gmgj,项目名称:gjsoap,代码行数:31,代码来源:gjrsi.php

示例11: matchSignature

 /**
  * This makes unit-testing a heck of a lot easier
  */
 function matchSignature($pattern)
 {
     return $this->_os->matchSignature($pattern);
 }
开发者ID:upmunspel,项目名称:abiturient,代码行数:7,代码来源:Dependency2.php


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