[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // eZSetup 4 // 5 // Created on: <08-Nov-2002 11:00:54 kd> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 // This file holds the test functions that are used by step 1 30 31 define( 'EZ_SETUP_TEST_SUCCESS', 1 ); 32 define( 'EZ_SETUP_TEST_FAILURE', 2 ); 33 34 function eZSetupTestTable() 35 { 36 return array( 'phpversion' => array( 'eZSetupTestPhpVersion' ), 37 'php_session' => array( 'eZSetupTestExtension' ), 38 'directory_permissions' => array( 'eZSetupTestFilePermissions' ), 39 'settings_permission' => array( 'eZSetupTestFilePermissions' ), 40 'database_extensions' => array( 'eZSetupTestExtension' ), 41 'database_all_extensions' => array( 'eZSetupTestExtension' ), 42 'php_magicquotes' => array( 'eZSetupCheckMagicQuotes' ), 43 'magic_quotes_runtime' => array( 'eZSetupCheckMagicQuotesRuntime' ), 44 'php_register_globals' => array( 'eZSetupCheckRegisterGlobals' ), 45 'mbstring_extension' => array( 'eZSetupMBStringExtension' ), 46 'zlib_extension' => array( 'eZSetupTestExtension' ), 47 'file_upload' => array( 'eZSetupTestFileUpload' ), 48 'open_basedir' => array( 'eZSetupTestOpenBasedir' ), 49 'safe_mode' => array( 'eZSetupTestSafeMode' ), 50 'image_conversion' => array( 'eZSetupCheckTestFunctions' ), 51 'imagegd_extension' => array( 'eZSetupCheckGDVersion' ), 52 'texttoimage_functions' => array( 'eZSetupTestFunctionExists' ), 53 'imagemagick_program' => array( 'eZSetupCheckExecutable' ), 54 'memory_limit' => array( 'eZSetupTestMemLimit' ), 55 'execution_time' => array( 'eZSetupTestExecutionTime' ), 56 'allow_url_fopen' => array( 'eZSetupTestAllowURLFOpen' ), 57 'accept_path_info' => array( 'eZSetupTestAcceptPathInfo' ) ); 58 } 59 60 function eZSetupConfigVariable( $type, $name ) 61 { 62 $config =& eZINI::instance( 'setup.ini' ); 63 return $config->variable( $type, $name ); 64 } 65 66 function eZSetupImageConfigVariableArray( $type, $name ) 67 { 68 $config =& eZINI::instance( 'image.ini' ); 69 return $config->variableArray( $type, $name ); 70 } 71 72 function eZSetupConfigVariableArray( $type, $name ) 73 { 74 $config =& eZINI::instance( 'setup.ini' ); 75 return $config->variableArray( $type, $name ); 76 } 77 78 function eZSetupRunTests( $testList, &$arguments, $client, &$givenPersistentList ) 79 { 80 eZSetupPrvtExtractExtraPaths( $givenPersistentList ); 81 82 $testTable = eZSetupTestTable(); 83 84 $testResults = array(); 85 $persistenceResults = array(); 86 $testResult = EZ_SETUP_TEST_SUCCESS; 87 $successCount = 0; 88 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 89 $http =& eZHTTPTool::instance(); 90 foreach ( $testList as $testItem ) 91 { 92 $testName = $testItem; 93 $testElement = array(); 94 $testElement[0] = EZ_SETUP_TEST_FAILURE; 95 if ( !isset( $testTable[$testItem] ) ) 96 { 97 eZDebug::writeError( "The setup test '$testName' is not defined", $client ); 98 continue; 99 } 100 if ( $http->hasPostVariable( $testItem . '_Ignore' ) and 101 $http->postVariable( $testItem . '_Ignore' ) != 0 ) 102 { 103 continue; 104 } 105 $testInfo = $testTable[$testItem]; 106 $testFunction = $testInfo[0]; 107 if ( !function_exists( $testFunction ) ) 108 continue; 109 $testResultArray = $testFunction( $testName, $arguments ); 110 if ( $testResultArray['result'] ) 111 { 112 $testElement[0] = EZ_SETUP_TEST_SUCCESS; 113 ++$successCount; 114 } 115 else 116 $testResult = EZ_SETUP_TEST_FAILURE; 117 if ( isset( $testResultArray['persistent_data'] ) ) 118 { 119 $persistenceResults[] = array( $testName, $testResultArray['persistent_data'] ); 120 } 121 else if ( isset( $testResultArray['persistence_list'] ) ) 122 { 123 $persistenceResults = array_merge( $persistenceResults, $testResultArray['persistence_list'] ); 124 } 125 $testElement[1] = $testName; 126 $testElement[2] = $testResultArray; 127 $testResults[] = $testElement; 128 } 129 return array( 'result' => $testResult, 130 'results' => $testResults, 131 'persistence_list' => $persistenceResults, 132 'success_count' => $successCount ); 133 } 134 135 function eZSetupCheckTestFunctions( $type, &$arguments ) 136 { 137 $testList = eZSetupConfigVariableArray( $type, 'TestList' ); 138 $requireType = eZSetupConfigVariable( $type, 'Require' ); 139 140 $runResult = eZSetupRunTests( $testList, $arguments, 'eZSetupCheckTestFunctions', $dummy = null ); 141 $testResults = $runResult['results']; 142 $testResult = $runResult['result']; 143 $successCount = $runResult['success_count']; 144 $persistenceData = $runResult['persistence_list']; 145 146 $result = true; 147 if ( $requireType == 'one' ) 148 { 149 if ( $successCount == 0 ) 150 $result = false; 151 } 152 else if ( $successCount < count( $extensionList ) ) 153 $result = false; 154 return array( 'result' => $result, 155 'persistence_list' => $persistenceData, 156 'test_results' => $testResults ); 157 } 158 159 function eZSetupTestFileUpload( $type, &$arguments ) 160 { 161 $uploadEnabled = ini_get( 'file_uploads' ) != 0; 162 $uploadDir = ini_get( 'upload_tmp_dir' ); 163 $uploadDirExists = true; 164 $uploadDirWriteable = true; 165 $uploadDirCreateFile = true; 166 $uploadIsRoot = false; 167 // Empty upload_tmp_dir variable means that the system 168 // default is used. However the system default variable is hidden 169 // from PHP code and must be guessed. 170 // See: http://www.php.net/manual/en/ini.sect.file-uploads.php#ini.upload-tmp-dir 171 if ( strlen( trim( $uploadDir ) ) == 0 ) 172 { 173 $osType = eZSys::osType(); 174 if ( $osType == 'win32' ) 175 { 176 // Windows machines use the TEMP and TMP env variable. 177 // TEMP is checked first. 178 $uploadDir = isset( $_ENV['TEMP'] ) ? $_ENV['TEMP'] : ''; 179 if ( strlen( $uploadDir ) == 0 ) 180 { 181 $uploadDir = isset( $_ENV['TMP'] ) ? $_ENV['TMP'] : ''; 182 } 183 // When TEMP/TMP is not set we have to guess the directory 184 // The only valid guess is %SYSTEMROOT%/TEMP 185 // If %SYSTEMROOT% is missing we keep the string empty 186 if ( strlen( $uploadDir ) == 0 ) 187 { 188 if ( isset( $_ENV['SYSTEMROOT'] ) ) 189 { 190 $uploadDir = $_ENV['SYSTEMROOT'] . '/TEMP'; 191 } 192 } 193 } 194 else if ( $osType == 'unix' or 195 $osType == 'mac' ) 196 { 197 $uploadDir = isset( $_ENV['TMPDIR'] ) ? $_ENV['TMPDIR'] : ''; 198 // When TMPDIR is not set we have to guess the directory 199 // On Unix systems we expect /tmp to be used 200 if ( strlen( $uploadDir ) == 0 ) 201 { 202 $uploadDir = '/tmp'; 203 } 204 } 205 } 206 $uploadDirs = array(); 207 if ( strlen( $uploadDir ) > 0 ) 208 { 209 $uploadDirExists = file_exists( $uploadDir ); 210 $uploadDirWriteable = eZDir::isWriteable( $uploadDir ); 211 if ( $uploadDirExists and $uploadDirWriteable ) 212 { 213 $uploadDirCreateFile = false; 214 $tmpFile = 'ezsetuptmp_' . md5( microtime() ) . '.tmp'; 215 $tmpFilePath = $uploadDir . '/' . $tmpFile; 216 if ( $fd = @fopen( $tmpFilePath, 'w' ) ) 217 { 218 $uploadDirCreateFile = true; 219 @fclose( $fd ); 220 unlink( $tmpFilePath ); 221 } 222 } 223 $splitDirs = explode( '/', trim( $uploadDir, '/' ) ); 224 $dirPath = ''; 225 foreach ( $splitDirs as $splitDir ) 226 { 227 $dirPath .= '/' . $splitDir; 228 $uploadDirs[] = $dirPath; 229 } 230 if ( substr( $uploadDir, 0, 5 ) == '/root' ) 231 { 232 $uploadIsRoot = true; 233 } 234 } 235 $result = ( $uploadEnabled and $uploadDirExists and 236 $uploadDirWriteable and $uploadDirCreateFile ); 237 238 $userInfo = eZSetupPrvPosixExtension(); 239 return array( 'result' => $result, 240 'php_upload_is_enabled' => $uploadEnabled, 241 'php_upload_is_root' => $uploadIsRoot, 242 'php_upload_dir' => $uploadDir, 243 'php_upload_split_dirs' => $uploadDirs, 244 'upload_dir_exists' => $uploadDirExists, 245 'upload_dir_writeable' => $uploadDirWriteable, 246 'upload_dir_create_file' => $uploadDirCreateFile, 247 'user_info' => $userInfo, 248 'persistent_data' => array( 'result' => array( 'value' => $result ) ) ); 249 } 250 251 function eZSetupCheckMagicQuotesRuntime( $type, &$arguments ) 252 { 253 $magicQuote = get_magic_quotes_runtime(); 254 $result = ( $magicQuote == 0 ); 255 return array( 'result' => $result, 256 'persistent_data' => array( 'result' => array( 'value' => $result ) ) ); 257 } 258 259 function eZSetupCheckMagicQuotes( $type, &$arguments ) 260 { 261 $magicQuote = get_magic_quotes_gpc(); 262 $result = ( $magicQuote == 0 ); 263 return array( 'result' => $result, 264 'persistent_data' => array( 'result' => array( 'value' => $result ) ) ); 265 } 266 267 /*! 268 Test if PHP version is equal or greater than required version 269 */ 270 function eZSetupTestPhpVersion( $type, &$arguments ) 271 { 272 $minVersion = eZSetupConfigVariable( $type, 'MinimumVersion' ); 273 $unstableVersionArray = eZSetupConfigVariableArray( $type, 'UnstableVersions' ); 274 275 /* 276 // Get the operating systems name 277 $operatingSystem = split( " ", php_uname() ); 278 $operatingSystem = strtolower( $operatingSystem[0] ); 279 280 // Find out if there is an os specific version needed 281 if ( isset( $argArray["req"][$operatingSystem] ) ) 282 $neededVersion = $argArray["req"][$operatingSystem]; 283 else if ( isset( $argArray["req"] ) ) 284 $neededVersion = $argArray["req"]; 285 else 286 $neededVersion = $argArray["req"]; 287 */ 288 289 $neededVersion = $minVersion; 290 291 // compare the versions 292 $currentVersion = phpversion(); 293 $currentVersionArray = explode( '.', $currentVersion ); 294 $neededVersionArray = explode( '.', $neededVersion ); 295 296 $warningVersion = false; 297 $result = eZSetupPrvtVersionCompare( $currentVersionArray, $neededVersionArray ) >= 0; 298 299 if ( $result ) 300 { 301 foreach ( array_keys( $unstableVersionArray ) as $key ) 302 { 303 $unstableVersion = explode( '.', $unstableVersionArray[$key] ); 304 if ( eZSetupPrvtVersionCompare( $currentVersionArray, $unstableVersion ) == 0 ) 305 { 306 $result = false; 307 $warningVersion = true; 308 break; 309 } 310 } 311 } 312 313 return array( 'result' => $result, 314 'persistent_data' => array( 'result' => array( 'value' => $result ), 315 'found' => array( 'value' => $currentVersion ), 316 'required' => array( 'value' => $neededVersion ) ), 317 'needed_version' => $neededVersion, 318 'current_version' => $currentVersion, 319 'warning_version' => $warningVersion ); 320 } 321 322 /*! 323 Test if allowed to open URLs using fopen 324 */ 325 function eZSetupTestAllowURLFOpen( $type, &$arguments ) 326 { 327 $allowFOpen = ini_get( 'allow_url_fopen' ) != 0; 328 return array( 'result' => $allowFOpen, 329 'persistent_data' => array( 'result' => array( 'value' => $allowFOpen ) ) ); 330 } 331 332 /*! 333 Test if Apache setting for AcceptPathInfo is enabled 334 */ 335 function eZSetupTestAcceptPathInfo( $type, &$arguments ) 336 { 337 // rl: this one works only if 'allow_url_fopen' is On 338 // $allowFOpen = ini_get( 'allow_url_fopen' ) != 0; 339 // todo: additional check for case of 'allow_url_fopen' is Off 340 341 $testPath = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '/eZ_accept_path_info_test'; 342 $protocol = 'http'; 343 /* We attempt to use the https protocol when the https port is used */ 344 if ( $_SERVER['SERVER_PORT'] == 443 ) 345 { 346 $protocol = 'https'; 347 } 348 $testPath = "{$protocol}://" . str_replace( '//', '/', $testPath ); 349 $fp = @fopen( $testPath, 'r' ); 350 351 return array( 'result' => ( $fp !== false ), 352 'persistent_data' => array( 'result' => array( 'value' => ( $fp !== false ) ) ) ); 353 } 354 355 function eZSetupTestFunctionExists( $type, &$arguments ) 356 { 357 $functionList = eZSetupConfigVariableArray( $type, 'Functions' ); 358 $requireType = eZSetupConfigVariable( $type, 'Require' ); 359 $foundFunctions = array(); 360 $failedFunctions = array(); 361 foreach ( $functionList as $function ) 362 { 363 $function = strtolower( $function ); 364 if ( function_exists( $function ) ) 365 { 366 $foundFunctions[] = $function; 367 } 368 else 369 { 370 $failedFunctions[] = $function; 371 } 372 } 373 $result = true; 374 if ( $requireType == 'one' ) 375 { 376 if ( count( $foundFunctions ) == 0 ) 377 $result = false; 378 } 379 else if ( count( $foundFunctions ) < count( $functionList ) ) 380 $result = false; 381 382 return array( 'result' => $result, 383 'persistent_data' => array( 'result' => array( 'value' => $result ), 384 'found' => array( 'value' => $foundFunctions, 385 'merge' => false, 386 'unique' => true ), 387 'checked' => array( 'value' => $functionList, 388 'merge' => true, 389 'unique' => true ) ), 390 'require_type' => $requireType, 391 'extension_list' => $functionList, 392 'failed_extensions' => $failedFunctions, 393 'found_extensions' => $foundFunctions ); 394 } 395 396 /*! 397 Test if the extensios are loaded 398 */ 399 function eZSetupTestExtension( $type, &$arguments ) 400 { 401 $extensionList = eZSetupConfigVariableArray( $type, 'Extensions' ); 402 $requireType = eZSetupConfigVariable( $type, 'Require' ); 403 $foundExtensions = array(); 404 $failedExtensions = array(); 405 foreach ( $extensionList as $extension ) 406 { 407 // if ( false ) 408 if ( extension_loaded( $extension ) ) 409 { 410 $foundExtensions[] = $extension; 411 } 412 else 413 { 414 $failedExtensions[] = $extension; 415 } 416 } 417 $result = true; 418 if ( $requireType == 'one' ) 419 { 420 if ( count( $foundExtensions ) == 0 ) 421 $result = false; 422 } 423 else if ( count( $foundExtensions ) < count( $extensionList ) ) 424 $result = false; 425 426 return array( 'result' => $result, 427 'persistent_data' => array( 'result' => array( 'value' => $result ), 428 'found' => array( 'value' => $foundExtensions, 429 'merge' => false, 430 'unique' => true ), 431 'checked' => array( 'value' => $extensionList, 432 'merge' => true, 433 'unique' => true ) ), 434 'require_type' => $requireType, 435 'extension_list' => $extensionList, 436 'failed_extensions' => $failedExtensions, 437 'found_extensions' => $foundExtensions ); 438 } 439 440 441 /*! 442 Test file permissions 443 */ 444 function eZSetupTestFilePermissions( $type, &$arguments ) 445 { 446 $fileList = eZSetupConfigVariableArray( $type, 'CheckList' ); 447 include_once ( 'lib/ezfile/classes/ezdir.php' ); 448 449 $ini =& eZINI::instance(); 450 $dirPermission = $ini->variable( 'FileSettings', 'StorageDirPermissions' ); 451 $filePermission = $ini->variable( 'FileSettings', 'StorageFilePermissions' ); 452 453 $result = true; 454 $resultElements = array(); 455 foreach ( $fileList as $file ) 456 { 457 $resultElement = array(); 458 $resultElement['file'] = $file; 459 unset( $fileResult ); 460 $fileResult =& $resultElement['result']; 461 $fileResult = true; 462 unset( $filePerm ); 463 $filePerm =& $resultElement['permission']; 464 $filePerm = false; 465 $resultElements[] = $resultElement; 466 467 $file = eZDir::cleanPath( $file ); 468 if ( !file_exists( $file ) ) 469 continue; 470 if ( is_dir( $file ) ) 471 { 472 $filePerm = $dirPermission; 473 $dir = $file; 474 475 if ( !eZSetupPrvtAreDirAndFilesWritable( $dir ) ) 476 { 477 $result = false; 478 $fileResult = false; 479 } 480 } 481 else if ( is_file( $file ) ) 482 { 483 $filePerm = $filePermission; 484 485 if ( !eZFile::isWriteable( $file ) ) 486 { 487 $result = false; 488 $fileResult = false; 489 } 490 } 491 } 492 $safeMode = ini_get( 'safe_mode' ) != 0; 493 $userInfo = eZSetupPrvPosixExtension(); 494 495 return array( 'result' => $result, 496 'safe_mode' => $safeMode, 497 'user_info' => $userInfo, 498 'persistent_data' => array( 'result' => array( 'value' => $result ) ), 499 'current_path' => realpath( '.' ), 500 'result_elements' => $resultElements ); 501 } 502 503 /*! 504 Figures out current user and group running the system by 505 using the \c posix extension. If this is not available 506 \c has_extension is set to \c false. 507 \return An array with information, if no extension is found only \c has_extension is set. 508 */ 509 function eZSetupPrvPosixExtension() 510 { 511 $userInfo = array( 'has_extension' => false ); 512 if ( extension_loaded( 'posix' ) ) 513 { 514 $userInfo['has_extension'] = true; 515 $uinfo = posix_getpwuid( posix_getuid() ); 516 $ginfo = posix_getgrgid( posix_getgid() ); 517 $userInfo['user_name'] = $uinfo['name']; 518 $userInfo['user_id'] = $uinfo['uid']; 519 $userInfo['group_name'] = $ginfo['name']; 520 $userInfo['group_id'] = $ginfo['gid']; 521 $userInfo['group_members'] = $ginfo['members']; 522 $userInfo['script_user_id'] = getmyuid(); 523 $userInfo['script_group_id'] = getmygid(); 524 } 525 return $userInfo; 526 } 527 528 529 /*! 530 Test if a program can be found in our path and is executable 531 */ 532 function eZSetupCheckExecutable( $type, &$arguments ) 533 { 534 include_once ( 'lib/ezutils/classes/ezsys.php' ); 535 include_once ( 'lib/ezfile/classes/ezdir.php' ); 536 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 537 $http =& eZHTTPTool::instance(); 538 539 $filesystemType = eZSys::filesystemType(); 540 $envSeparator = eZSys::envSeparator(); 541 $programs = eZSetupConfigVariableArray( $type, $filesystemType . '_Executable' ); 542 $systemSearchPaths = explode( $envSeparator, eZSys::path() ); 543 $additionalSearchPaths = eZSetupConfigVariableArray( $type, $filesystemType . '_SearchPaths' ); 544 $excludePaths = eZSetupConfigVariableArray( $type, $filesystemType . '_ExcludePaths' ); 545 $imageIniPath = eZSetupImageConfigVariableArray( 'ShellSettings', 'ConvertPath' ); 546 547 /* 548 We save once entered extra path in the persistent data list 549 to keep it within setup steps. 550 551 This trick is needed, for example, in "registration" step, 552 where user has no chance to enter extra path again 553 due to missing input field for this purpose. 554 */ 555 556 // compute extra path 557 $extraPath = array(); 558 if ( $http->hasPostVariable( $type . '_ExtraPath' ) ) 559 { 560 $GLOBALS['eZSetupCheckExecutable_'.$type.'_ExtraPath'] = $http->postVariable( $type . '_ExtraPath' ); 561 $extraPath = explode( $envSeparator, $http->postVariable( $type . '_ExtraPath' ) ); 562 } 563 else if ( isset( $GLOBALS['eZSetupCheckExecutable_'.$type.'_ExtraPath'] ) ) 564 $extraPath = explode( $envSeparator, $GLOBALS['eZSetupCheckExecutable_'.$type.'_ExtraPath'] ); 565 566 // if extra path was given in any way 567 if ( $extraPath ) 568 { 569 // remove program from path name if entered 570 foreach ( $extraPath as $path ) 571 { 572 foreach ( $programs as $program ) 573 { 574 if ( strpos( $path, $program) == strlen( $path ) - strlen( $program ) ) 575 { 576 $extraPath[] = substr( $path, strpos( $path, $program) ); 577 } 578 } 579 } 580 } 581 582 $searchPaths = array_merge( $systemSearchPaths, $additionalSearchPaths, $extraPath, $imageIniPath ); 583 584 $result = false; 585 $correctPath = false; 586 $correctProgram = false; 587 foreach ( $programs as $program ) 588 { 589 foreach( $searchPaths as $path ) 590 { 591 $pathProgram = eZDir::path( array( $path, $program ) ); 592 if ( file_exists( $pathProgram ) ) 593 { 594 if ( $filesystemType == 'unix' ) 595 { 596 $relativePath = $path; 597 if ( preg_match( "#^/(.+)$#", $path, $matches ) ) 598 $relativePath = $matches[1]; 599 $relativePath = eZDir::cleanPath( $relativePath ); 600 } 601 else // windows 602 { 603 $relativePath = $path; 604 if ( preg_match( "#^[a-zA-Z]:[/\\\\](.+)$#", $path, $matches ) ) 605 $relativePath = $matches[1]; 606 $relativePath = eZDir::cleanPath( $relativePath ); 607 } 608 $exclude = false; 609 foreach ( $excludePaths as $excludePath ) 610 { 611 $excludePath = strtolower( $excludePath ); 612 $match = strtolower( $program . "@" . $relativePath ); 613 if ( $match == $excludePath ) 614 { 615 $exclude = true; 616 break; 617 } 618 else if ( $relativePath == $excludePath ) 619 { 620 $exclude = true; 621 break; 622 } 623 } 624 if ( $exclude ) 625 continue; 626 if ( function_exists( "is_executable" ) ) 627 { 628 if ( is_executable( $pathProgram ) ) 629 { 630 $result = true; 631 $correctPath = $path; 632 $correctProgram = $program; 633 break; 634 } 635 } 636 else 637 { 638 // Windows system 639 $result = true; 640 $correctPath = $path; 641 $correctProgram = $program; 642 break; 643 } 644 } 645 } 646 if ( $result ) 647 break; 648 } 649 650 $extraPathAsString = implode( $envSeparator, $extraPath ); 651 652 return array( 'result' => $result, 653 'persistent_data' => array( 'path' => array( 'value' => $correctPath ), 654 'program' => array( 'value' => $correctProgram ), 655 'extra_path' => array( 'value' => $extraPathAsString, 656 'merge' => TRUE ), 657 'result' => array( 'value' => $result ) ), 658 'env_separator' => $envSeparator, 659 'filesystem_type' => $filesystemType, 660 'extra_path' => $extraPath, 661 'correct_path' => $correctPath, 662 'system_search_path' => $systemSearchPaths, 663 'additional_search_path' => $additionalSearchPaths ); 664 } 665 666 667 668 /*! 669 Test php ini settings 670 */ 671 function testPHPIni( $parameters ) 672 { 673 $setting = $parameters["setting"]; 674 $state = $parameters["state"]; 675 676 if ( (bool) ini_get( $setting ) == $state ) 677 $pass = true; 678 else 679 $pass = false; 680 681 $status = $pass; 682 return array( "status" => $status, "pass" => $pass ); 683 } 684 685 686 /*! 687 Test GD version 688 */ 689 function eZSetupCheckGDVersion( $type, &$arguments ) 690 { 691 $result = function_exists( 'imagegd2' ); 692 return array( 'result' => $result, 693 'persistent_data' => array( 'result' => array( 'value' => $result ) ) ); 694 } 695 696 /*! 697 Test if mbstring is available 698 */ 699 function eZSetupMBStringExtension( $type, &$arguments ) 700 { 701 include_once ( "lib/ezi18n/classes/ezmbstringmapper.php" ); 702 $result = eZMBStringMapper::hasMBStringExtension(); 703 $charsetList = eZMBStringMapper::charsetList(); 704 return array( 'result' => $result, 705 'persistent_data' => array( 'result' => array( 'value' => $result ) ), 706 'charset_list' => $charsetList ); 707 } 708 709 710 function eZSetupCheckRegisterGlobals( $type, &$arguments ) 711 { 712 $registerGlobals = ini_get( 'register_globals' ) != 0; 713 $result = !$registerGlobals; 714 return array( 'result' => $result, 715 'persistent_data' => array() ); 716 } 717 718 /*! 719 Check the php.ini file to get timeout limit 720 */ 721 function eZSetupTestExecutionTime( $type, &$arguments ) 722 { 723 $minExecutionTime = eZSetupConfigVariable( $type, 'MinExecutionTime' ); 724 $execTimeLimit = ini_get( 'max_execution_time' ); 725 726 if ( $execTimeLimit == false ) 727 { 728 return array( 'result' => true, 729 'persistent_data' => array( 'result' => array( 'value' => true ) ) ); 730 } 731 732 if ( $minExecutionTime <= $execTimeLimit ) 733 return array( 'result' => true, 734 'persistent_data' => array( 'result' => array( 'value' => true ) ) ); 735 736 return array( 'result' => false, 737 'persistent_data' => array( 'result' => array( 'value' => false ) ), 738 'required_execution_time' => $minExecutionTime, 739 'current_execution_time' => $execTimeLimit ); 740 } 741 742 /*! 743 Checks the php.ini file to see if the memory limit is set high enough 744 */ 745 function eZSetupTestMemLimit( $type, &$arguments ) 746 { 747 $minMemory = eZSetupConfigVariable( $type, 'MinMemoryLimit' ); 748 $memoryLimit = ini_get( 'memory_limit' ); 749 if ( $memoryLimit === '' || $memoryLimit == -1 ) 750 { 751 return array( 'result' => true, 752 'persistent_data' => array( 'result' => array( 'value' => true ) ) ); 753 } 754 755 $byteMinMem = intval( $minMemory ); 756 switch ( $minMemory{strlen( $minMemory ) - 1} ) 757 { 758 case 'G': 759 $byteMinMem *= 1024; 760 case 'M': 761 $byteMinMem *= 1024; 762 case 'K': 763 $byteMinMem *= 1024; 764 } 765 766 $byteMemLimit = intval( $memoryLimit ); 767 switch ( $memoryLimit{strlen( $memoryLimit ) - 1} ) 768 { 769 case 'G': 770 $byteMemLimit *= 1024; 771 case 'M': 772 $byteMemLimit *= 1024; 773 case 'K': 774 $byteMemLimit *= 1024; 775 } 776 777 if ( $byteMinMem <= $byteMemLimit ) 778 return array( 'result' => true, 779 'persistent_data' => array( 'result' => array( 'value' => true ) ) ); 780 781 return array( 'result' => false, 782 'persistent_data' => array( 'result' => array( 'value' => false ) ), 783 'required_memory' => $minMemory, 784 'current_memory' => $memoryLimit ); 785 } 786 787 function eZSetupTestOpenBasedir( $type, &$arguments ) 788 { 789 $openBasedir = ini_get( 'open_basedir' ); 790 $returnData = array( 'result' => true, 791 'persistent_data' => array() ); 792 if ( $openBasedir != '' and 793 $openBasedir != '.' ) 794 { 795 $returnData['warnings'] = array( array( 'name' => 'open_basedir', 796 'text' => array( 'open_basedir is in use and can give problems running eZ publish due to bugs in some PHP versions.', 797 'It\'s recommended that it is turned off if you experience problems running eZ publish.' ) ) ); 798 } 799 return $returnData; 800 } 801 802 /*! 803 Check if setup is installed using windows or linux installer 804 805 \return 'linux' if using linux installer, 806 'windows' if using windows installer, 807 false if not using any installer 808 */ 809 function eZSetupTestInstaller() 810 { 811 if ( file_exists( '.linux' ) ) 812 { 813 return 'linux'; 814 } 815 else if ( file_exists( '.windows' ) ) 816 { 817 return 'windows'; 818 } 819 return false; 820 } 821 822 function eZSetupTestSafeMode( $type, &$arguments ) 823 { 824 $safeMode = ini_get( 'safe_mode' ) != 0; 825 $result = !$safeMode; 826 return array( 'result' => $result, 827 'current_path' => realpath( '.' ), 828 'persistent_data' => array() ); 829 } 830 831 /*! 832 Check if two version arrays are equel, greater or less than each other 833 834 \param user first version array 835 \param second version array 836 837 \return < 0 if 1. version less than 2. version 838 0 if versions are equal 839 > 0 if 1. version is greater than 2. version 840 */ 841 function eZSetupPrvtVersionCompare( $versionArray1, $versionArray2 ) 842 { 843 $equal = false; 844 $count = min( count( $versionArray1 ), count( $versionArray2 ) ); 845 for ( $i = 0; $i < $count; ++$i ) 846 { 847 $equal = false; 848 if ( (int) $versionArray1[$i] > (int) $versionArray2[$i] ) 849 { 850 return 1; 851 } 852 else if ( (int) $versionArray1[$i] < (int) $versionArray2[$i] ) 853 { 854 return -1; 855 } 856 $equal = true; 857 } 858 if ( $equal ) 859 return 0; 860 } 861 862 863 /* Find previously saved extra paths and export them 864 * to global variables. 865 */ 866 function eZSetupPrvtExtractExtraPaths( &$givenPersistentList ) 867 { 868 if( !$givenPersistentList ) // null or empty array 869 return; 870 871 foreach( $givenPersistentList as $key => $val ) 872 { 873 if( isset( $val['extra_path'] ) ) 874 $GLOBALS['eZSetupCheckExecutable_'.$key.'_ExtraPath'] = $val['extra_path']; 875 } 876 } 877 878 /*! Check if a given directory and all files within that directory 879 * are writable 880 */ 881 function eZSetupPrvtAreDirAndFilesWritable( $dir ) 882 { 883 if ( !eZDir::isWriteable( $dir ) ) 884 return FALSE; 885 886 // Check if all files within a given directory are writeable 887 $files = eZDir::findSubitems( $dir, 'f' ); // find only files, skip dirs and symlinks 888 $fileSeparator = eZSys::fileSeparator(); 889 890 foreach ( $files as $file ) 891 { 892 if ( !eZFile::isWriteable( $dir . $fileSeparator . $file ) ) 893 return FALSE; 894 } 895 896 return TRUE; 897 } 898 899 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |