本文整理汇总了PHP中eZSys::osType方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSys::osType方法的具体用法?PHP eZSys::osType怎么用?PHP eZSys::osType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSys
的用法示例。
在下文中一共展示了eZSys::osType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAvailable
static function isAvailable()
{
$extensionName = 'zlib';
if (!extension_loaded($extensionName)) {
$dlExtension = eZSys::osType() == 'win32' ? '.dll' : '.so';
@dl($extensionName . $dlExtension);
}
return extension_loaded($extensionName);
}
示例2: __construct
/**
* Instanciantes the image converter with a set of filters
*
* @param array(ezcImageFilter) $filter Filters to add to the image converter
* @return void
* @throws ezcBaseSettingValueException Error adding the transformation
*/
public function __construct($filter)
{
$imageINI = eZINI::instance('image.ini');
// we get an array of handlers, where order of entries in array gives priority
// for each entry, we need to check if the matching handler is enabled, and this has to be manual
$imageHandlers = $imageINI->variable('ImageConverterSettings', 'ImageConverters');
foreach ($imageHandlers as $imageHandler) {
switch ($imageHandler) {
case 'ImageMagick':
$hasImageMagick = $imageINI->variable('ImageMagick', 'IsEnabled') == 'true';
if ($hasImageMagick) {
break 2;
}
break;
// GD2 is required for the image editor
// @todo Make the image editor degrade as nicely as possible if GD is not bundled
// GD2 is required for the image editor
// @todo Make the image editor degrade as nicely as possible if GD is not bundled
case 'GD':
$hasGD2 = $imageINI->variable('GD', 'IsEnabled') == 'true' && $imageINI->variable('GDSettings', 'HasGD2' == 'true');
if ($hasGD2) {
break 2;
}
break;
}
}
if ($hasImageMagick) {
// we need to use the ImageMagick path configured in the image.ini file
$executable = $imageINI->variable('ImageMagick', 'Executable');
if (eZSys::osType() == 'win32' && $imageINI->hasVariable('ImageMagick', 'ExecutableWin32')) {
$executable = $imageINI->variable('ImageMagick', 'ExecutableWin32');
} else {
if (eZSys::osType() == 'mac' && $imageINI->hasVariable('ImageMagick', 'ExecutableMac')) {
$executable = $imageINI->variable('ImageMagick', 'ExecutableMac');
} else {
if (eZSys::osType() == 'unix' && $imageINI->hasVariable('ImageMagick', 'ExecutableUnix')) {
$executable = $imageINI->variable('ImageMagick', 'ExecutableUnix');
}
}
}
if ($imageINI->hasVariable('ImageMagick', 'ExecutablePath') && $imageINI->variable('ImageMagick', 'ExecutablePath')) {
$executable = $imageINI->variable('ImageMagick', 'ExecutablePath') . eZSys::fileSeparator() . $executable;
}
// @todo Remove if ezc indeed do it automatically
// if ( eZSys::osType() == 'win32' )
// $executable = "\"$executable\"";
$imageHandlerSettings = new ezcImageHandlerSettings('ImageMagick', 'eZIEEzcImageMagickHandler', array('binary' => $executable));
$settings = new ezcImageConverterSettings(array($imageHandlerSettings));
} else {
$settings = new ezcImageConverterSettings(array(new ezcImageHandlerSettings('GD', 'eZIEEzcGDHandler')));
}
$this->converter = new ezcImageConverter($settings);
$mimeType = $imageINI->variable('OutputSettings', 'AllowedOutputFormat');
$this->converter->createTransformation('transformation', $filter, $mimeType);
}
示例3: searchInFiles
/**
* Search text in files using regexps (recursively through folders).
* Assumes egrep is available if not on windows
*/
static function searchInFiles($searchtext, $cachedir, $is_regexp = true)
{
//$fileHandler = eZClusterFileHandler::instance();
$result = array();
if (eZSys::osType() != 'win32') {
if ($is_regexp) {
exec('egrep -s -R -l "' . str_replace('"', '\\"', $searchtext) . "\" \"{$cachedir}\"", $result);
} else {
exec('fgrep -s -R -l "' . str_replace('"', '\\"', $searchtext) . "\" \"{$cachedir}\"", $result);
}
} else {
$files = @scandir($cachedir);
if ($files === false) {
return false;
}
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
if (is_dir($cachedir . '/' . $file)) {
$result = array_merge($result, self::searchInFiles($searchtext, $cachedir . '/' . $file, $is_regexp));
} else {
$txt = @file_get_contents($cachedir . '/' . $file);
/// @todo escape properly #
if ($is_regexp) {
if (preg_match("#" . $searchtext . "#", $txt)) {
$result[] = $cachedir . '/' . $file;
}
} else {
if (strpos($txt, $searchtext) !== false) {
$result[] = $cachedir . '/' . $file;
}
}
$txt = false;
// free memory asap
}
}
}
}
return $result;
}
示例4: eZSetupTestFileUpload
function eZSetupTestFileUpload($type)
{
$uploadEnabled = ini_get('file_uploads') != 0;
$uploadDir = ini_get('upload_tmp_dir');
$uploadDirExists = true;
$uploadDirWriteable = true;
$uploadDirCreateFile = true;
$uploadIsRoot = false;
// Empty upload_tmp_dir variable means that the system
// default is used. However the system default variable is hidden
// from PHP code and must be guessed.
// See: http://www.php.net/manual/en/ini.sect.file-uploads.php#ini.upload-tmp-dir
if (strlen(trim($uploadDir)) == 0) {
$osType = eZSys::osType();
if ($osType == 'win32') {
// Windows machines use the TEMP and TMP env variable.
// TEMP is checked first.
$uploadDir = eZSys::hasEnvironmentVariable('TEMP') ? eZSys::environmentVariable('TEMP') : '';
if ($uploadDir === '') {
$uploadDir = eZSys::hasEnvironmentVariable('TMP') ? eZSys::environmentVariable('TMP') : '';
}
// When TEMP/TMP is not set we have to guess the directory
// The only valid guess is %SYSTEMROOT%/TEMP
// If %SYSTEMROOT% is missing we keep the string empty
if ($uploadDir === '') {
if (eZSys::hasEnvironmentVariable('SYSTEMROOT')) {
$uploadDir = eZSys::environmentVariable('SYSTEMROOT') . '/TEMP';
}
}
} else {
if ($osType == 'unix' or $osType == 'mac') {
$uploadDir = eZSys::hasEnvironmentVariable('TMPDIR') ? eZSys::environmentVariable('TMPDIR') : '';
// When TMPDIR is not set we have to guess the directory
// On Unix systems we expect /tmp to be used
if (strlen($uploadDir) == 0) {
$uploadDir = '/tmp';
}
}
}
}
$uploadDirs = array();
if (strlen($uploadDir) > 0) {
$uploadDirExists = file_exists($uploadDir);
$uploadDirWriteable = eZDir::isWriteable($uploadDir);
if ($uploadDirExists and $uploadDirWriteable) {
$uploadDirCreateFile = false;
$tmpFile = 'ezsetuptmp_' . md5(microtime()) . '.tmp';
$tmpFilePath = $uploadDir . '/' . $tmpFile;
if ($fd = @fopen($tmpFilePath, 'w')) {
$uploadDirCreateFile = true;
@fclose($fd);
unlink($tmpFilePath);
}
}
$splitDirs = explode('/', trim($uploadDir, '/'));
$dirPath = '';
foreach ($splitDirs as $splitDir) {
$dirPath .= '/' . $splitDir;
$uploadDirs[] = $dirPath;
}
if (substr($uploadDir, 0, 5) == '/root') {
$uploadIsRoot = true;
}
}
$result = ($uploadEnabled and $uploadDirExists and $uploadDirWriteable and $uploadDirCreateFile);
$userInfo = eZSetupPrvPosixExtension();
return array('result' => $result, 'php_upload_is_enabled' => $uploadEnabled, 'php_upload_is_root' => $uploadIsRoot, 'php_upload_dir' => $uploadDir, 'php_upload_split_dirs' => $uploadDirs, 'upload_dir_exists' => $uploadDirExists, 'upload_dir_writeable' => $uploadDirWriteable, 'upload_dir_create_file' => $uploadDirCreateFile, 'user_info' => $userInfo, 'persistent_data' => array('result' => array('value' => $result)));
}
示例5: linkCopy
static function linkCopy( $sourceFilename, $destinationFilename, $symbolicLink = true )
{
if ( in_array( eZSys::osType(),
array( 'unix', 'linux', 'mac' ) ) )
{
if ( $symbolicLink )
$result = eZFileHandler::symlink( $sourceFilename, $destinationFilename );
else
$result = eZFileHandler::link( $sourceFilename, $destinationFilename );
if ( $result )
return $result;
return eZFileHandler::copy( $sourceFilename, $destinationFilename );
}
else
{
return eZFileHandler::copy( $sourceFilename, $destinationFilename );
}
}
示例6: isWriteable
static function isWriteable($filename)
{
if (eZSys::osType() != 'win32') {
return is_writable($filename);
}
/* PHP function is_writable() doesn't work correctly on Windows NT descendants.
* So we have to use the following hack on those OSes.
*/
if (!($fd = @fopen($filename, 'a'))) {
return FALSE;
}
fclose($fd);
return TRUE;
}
示例7: installPackage
private function installPackage($package)
{
$persistentData = array();
$persistentData['package_name'] = $package->attribute('name');
$persistentData['currentItem'] = 0;
$persistentData['doItemInstall'] = true;
$persistentData['error'] = array();
$persistentData['error_default_actions'] = array();
$installItemArray = $package->installItemsList(false, eZSys::osType());
foreach ($installItemArray as $installItem) {
$installer = eZPackageInstallationHandler::instance($package, $installItem['type'], $installItem);
if (!$installer || isset($persistentData['error']['choosen_action'])) {
$result = $package->installItem($installItem, $persistentData);
if (!$result) {
$templateName = "design:package/install_error.tpl";
break;
} else {
$persistentData['error'] = array();
}
} else {
$persistentData['doItemInstall'] = false;
$installer->generateStepMap($package, $persistentData);
$displayStep = true;
break;
}
}
$package->setInstalled();
}
示例8: array
$persistentData = array();
$persistentData['package_name'] = $packageName;
$persistentData['currentItem'] = $currentItem;
$persistentData['doItemInstall'] = false;
$persistentData['error'] = array();
$persistentData['error_default_actions'] = array();
}
if ( !eZPackage::canUsePolicyFunction( 'install' ) )
return $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
$package = eZPackage::fetch( $packageName );
if ( !$package )
return $module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
$installItemArray = $package->installItemsList( false, eZSys::osType() );
$tpl = eZTemplate::factory();
if ( $module->isCurrentAction( 'SkipPackage' ) )
{
$http->removeSessionVariable( 'eZPackageInstallerData' );
return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) );
}
elseif ( $module->isCurrentAction( 'InstallPackage' ) )
{
$persistentData['doItemInstall'] = true;
}
elseif ( $module->isCurrentAction( 'HandleError' ) )
{
$persistentData['doItemInstall'] = true;
示例9: isWriteable
static function isWriteable( $dirname )
{
if ( eZSys::osType() != 'win32' )
return is_writable( $dirname );
/* PHP function is_writable() doesn't work correctly on Windows NT descendants.
* So we have to use the following hack on those OSes.
*/
$tmpfname = $dirname . eZSys::fileSeparator() . "ezsetup_" . md5( microtime() ) . ".tmp";
// try to create temporary file
if ( !( $fp = @fopen( $tmpfname, "w" ) ) )
return FALSE;
fclose( $fp );
unlink( $tmpfname );
return TRUE;
}
示例10: convert
function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
{
$argumentList = array();
$executable = $this->Executable;
if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
$executable = $this->ExecutableWin32;
} else {
if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
$executable = $this->ExecutableMac;
} else {
if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
$executable = $this->ExecutableUnix;
}
}
}
if ($this->Path) {
$executable = $this->Path . eZSys::fileSeparator() . $executable;
}
if (eZSys::osType() == 'win32') {
$executable = "\"{$executable}\"";
}
$argumentList[] = $executable;
if ($this->PreParameters) {
$argumentList[] = $this->PreParameters;
}
$frameRangeParameters = $this->FrameRangeParameters;
if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
$sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
}
$argumentList[] = eZSys::escapeShellArgument($sourceMimeData['url']);
$qualityParameters = $this->QualityParameters;
if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
$qualityParameter = $qualityParameters[$destinationMimeData['name']];
$outputQuality = $manager->qualityValue($destinationMimeData['name']);
if ($outputQuality) {
$qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
$argumentList[] = $qualityArgument;
}
}
if ($filters !== false) {
foreach ($filters as $filterData) {
$argumentList[] = $this->textForFilter($filterData);
}
}
$destinationURL = $destinationMimeData['url'];
if ($this->UseTypeTag) {
$destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
}
$argumentList[] = eZSys::escapeShellArgument($destinationURL);
if ($this->PostParameters) {
$argumentList[] = $this->PostParameters;
}
$systemString = implode(' ', $argumentList);
system($systemString, $returnCode);
if ($returnCode == 0) {
if (!file_exists($destinationMimeData['url'])) {
eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
return false;
}
$this->changeFilePermissions($destinationMimeData['url']);
return true;
} else {
eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
return false;
}
}
示例11: convert
function convert($manager, $sourceMimeData, &$destinationMimeData, $filters = false)
{
$argumentList = array();
$executable = $this->Executable;
if (eZSys::osType() == 'win32' and $this->ExecutableWin32) {
$executable = $this->ExecutableWin32;
} else {
if (eZSys::osType() == 'mac' and $this->ExecutableMac) {
$executable = $this->ExecutableMac;
} else {
if (eZSys::osType() == 'unix' and $this->ExecutableUnix) {
$executable = $this->ExecutableUnix;
}
}
}
if ($this->Path) {
$executable = $this->Path . eZSys::fileSeparator() . $executable;
}
if (eZSys::osType() == 'win32') {
$executable = "\"{$executable}\"";
}
$argumentList[] = $executable;
if ($this->PreParameters) {
$argumentList[] = $this->PreParameters;
}
$frameRangeParameters = $this->FrameRangeParameters;
if ($frameRangeParameters && isset($frameRangeParameters[$sourceMimeData['name']])) {
$sourceMimeData['url'] .= $frameRangeParameters[$sourceMimeData['name']];
}
// Issue EZP-21357:
// ImageMagick has it's own meta-characters support, hence:
// $ convert 'File*.jpg'' ...
// Still expand File*.jpg as the shell would do, however, this is only true for the file's basename part and not
// for the whole path.
$argumentList[] = eZSys::escapeShellArgument($sourceMimeData['dirpath'] . DIRECTORY_SEPARATOR . addcslashes($sourceMimeData['filename'], '~*?[]{}<>'));
$qualityParameters = $this->QualityParameters;
if ($qualityParameters and isset($qualityParameters[$destinationMimeData['name']])) {
$qualityParameter = $qualityParameters[$destinationMimeData['name']];
$outputQuality = $manager->qualityValue($destinationMimeData['name']);
if ($outputQuality) {
$qualityArgument = eZSys::createShellArgument($qualityParameter, array('%1' => $outputQuality));
$argumentList[] = $qualityArgument;
}
}
if ($filters !== false) {
foreach ($filters as $filterData) {
$argumentList[] = $this->textForFilter($filterData);
}
}
$destinationURL = $destinationMimeData['url'];
if ($this->UseTypeTag) {
$destinationURL = $this->tagForMIMEType($destinationMimeData) . $this->UseTypeTag . $destinationURL;
}
$argumentList[] = eZSys::escapeShellArgument($destinationURL);
if ($this->PostParameters) {
$argumentList[] = $this->PostParameters;
}
$systemString = implode(' ', $argumentList);
system($systemString, $returnCode);
if ($returnCode == 0) {
if (!file_exists($destinationMimeData['url'])) {
eZDebug::writeError('Unknown destination file: ' . $destinationMimeData['url'] . " when executing '{$systemString}'", 'eZImageShellHandler(' . $this->HandlerName . ')');
return false;
}
$this->changeFilePermissions($destinationMimeData['url']);
return true;
} else {
eZDebug::writeWarning("Failed executing: {$systemString}, Error code: {$returnCode}", __METHOD__);
return false;
}
}
示例12: foreach
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version 2012.8
* @package kernel
*/
$cli->output("Checking link ...");
$cronjobIni = eZINI::instance('cronjob.ini');
$siteURLs = $cronjobIni->variable('linkCheckSettings', 'SiteURL');
$linkList = eZURL::fetchList(array('only_published' => true));
foreach ($linkList as $link) {
$linkID = $link->attribute('id');
$url = $link->attribute('url');
$isValid = $link->attribute('is_valid');
$cli->output("check-" . $cli->stylize('emphasize', $url) . " ", false);
if (preg_match("/^(http:)/i", $url) or preg_match("/^(ftp:)/i", $url) or preg_match("/^(https:)/i", $url) or preg_match("/^(file:)/i", $url) or preg_match("/^(mailto:)/i", $url)) {
if (preg_match("/^(mailto:)/i", $url)) {
if (eZSys::osType() != 'win32') {
$url = trim(preg_replace("/^mailto:(.+)/i", "\\1", $url));
list($userName, $host) = explode('@', $url);
list($host, $junk) = explode('?', $host);
$dnsCheck = checkdnsrr($host, "MX");
if (!$dnsCheck) {
if ($isValid) {
eZURL::setIsValid($linkID, false);
}
$cli->output($cli->stylize('warning', "invalid"));
} else {
if (!$isValid) {
eZURL::setIsValid($linkID, true);
}
$cli->output($cli->stylize('success', "valid"));
}
示例13: changeDBCharsetORACLE
/**
* NOTE: What if other data is also in the db? Either we do not convert it and
* have it most likely corrupted, or we convert it - and leave to the client
* for the other apps to set up NLS_LANG correctly to keep working.
*
* We could use the csalter script iff we where sure that db version was > 9...
*
* Oracle 9 exp exports data using the DB charset
*
* From http://www.experts-exchange.com/Database/Oracle/Q_22836430.html
May be the best procedure is the following one:
On PROD Database:
1. export full=y rows=n file=export_db_structure.dmp
2. export full=y file=export_db_date.dmp
On TEST Database:
1. create tablespaces with the same name on PROD
2. import full=y file=export_db_structure.dmp ignore=y
Now we have users of PROD, on TEST database. SYSTEM user is not imported, because already exists.
3. import fromuser=user1,user2,user3 touser=user1,user2,user3 file=export_db_data.dmp ignore=y
now we have user1..3 data on their tables...
* Unfortunately even if we do that, Oracle will nto let us convert a db from
* latin1 to utf8 charsets. The only way is to drop the db and creater it
* from scratch. Since we have no clue about db storage, we will let the admin
* take care of that part, and only do the export/import parts.
*
* @todo oracle servers might use UTF8 charset instead of AL32UTF8: check before executing!
*
* @todo using dbname as file name does not work with easy conection naming
*
* @todo log somewhere results of imp, exp commands for better understanding of errors
*/
function changeDBCharsetORACLE($charset, $collation)
{
global $db, $oracleDbaAccount, $oracleHome, $eZDir;
//$db = eZDB::instance( false, array( 'user' => $oracleDbaAccount['user'], 'password' => $oracleDbaAccount['password'] ), true );
// since we are here, we should be connected with a dba account (extra conditions check did it)
$oracleCharset = $db->arrayQuery("select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'");
$oracleCharset = $oracleCharset[0]['value'];
//$oracleLocale = $db->arrayQuery("select language||'_'||territory as locale from (select value as language from nls_database_parameters where parameter = 'NLS_LANGUAGE'), (select value as territory from nls_database_parameters where parameter = 'NLS_TERRITORY')");
//$oracleLocale = $oracleLocale[0]['locale'];
/*$users = $db->arrayQuery("select username from all_users where username not in ('SYS', 'SYSTEM')");
$oracleUsers = array();
foreach( $users as $row )
{
$oracleUsers[] = $row['username'];
}*/
if ($oracleCharset == 'AL32UTF8') {
// lucky case: client was configued to use another charset, but db was internally utf8 already!
showMessage3(" database charset is already UTF8: skipping.");
} else {
// get database name
$dbName = $db->DB;
//$dbversion = $db->databaseServerVersion();
// get connection params
//$host = $db->Server;
//$port = $db->Port;
//$user = $db->User;
//$pass = $db->Password;
$connectionParams = $oracleDbaAccount['user'] . '/' . $oracleDbaAccount['password'] . "@{$dbName}";
// get temporary dir to store dumps
$ini = eZINI::instance();
$dumpDir = $ini->variable('FileSettings', 'TemporaryDir') . basename(__FILE__, '.php');
$dumpFile1 = $dbName . "_structure_export.dmp";
$dumpPath1 = "{$dumpDir}/{$dumpFile1}";
$dumpFile2 = $dbName . "_full_export.dmp";
$dumpPath2 = "{$dumpDir}/{$dumpFile2}";
$commandPath = "{$dumpDir}/{$dbName}" . "_cmd.sql";
$logPath = "{$dumpDir}/{$dbName}" . "_cmd.log";
$users = implode(',', $oracleUsers);
//$ora_charset = "";
// prepare utility commands
$exe = eZSys::osType() == 'win32' ? '.exe' : '';
$exec = eZSys::osType() == 'win32' ? '' : './';
$expdb1 = "{$exec}exp{$exe} {$connectionParams} CONSISTENT=Y FULL=Y ROWS=N FILE={$dumpPath1}";
$expdb2 = "{$exec}exp{$exe} {$connectionParams} CONSISTENT=Y FULL=Y FILE={$dumpPath2}";
$impdb1 = "{$exec}imp{$exe} {$connectionParams} FULL=Y IGNORE=Y BUFFER=30960 FILE={$dumpPath1}";
$impdb2 = "{$exec}imp{$exe} {$connectionParams} FROMUSER={$users} TOUSER={$users} IGNORE=Y BUFFER=30960 FILE={$dumpPath2}";
/*
$alterdb = "SET ECHO ON
SPOOL $logPath;
WHENEVER SQLERROR EXIT FAILURE;
WHENEVER OSERROR EXIT FAILURE;";
if ( $dbversion['string'][0] == '8' )
{
/// @todo: check if using oracle < 8.1.5: we have touse svrmgrl then, as sqlplus was not good enough yet
$sqlplus = "{$exec}sqlplus{$exe} $connectionParams";
$alterdb .= "
CONNECT $connectionParams AS SYSDBA";
}
else
{
$sqlplus = "{$exec}sqlplus{$exe} -L $connectionParams as sysdba";
}
//$dropdb = "dropdb $connectionParams";
//$createdb = "createdb $connectionParams";
foreach( $oracleUsers as $user )
{
//.........这里部分代码省略.........