Exemplo n.º 1
0
 public function end()
 {
     // Set the script's execution time limit to the previous value but without the time that elapsed before the
     // "pause" was made (simply setting it to the previous value would reset the timer).
     $newExecutionTimeLimit = $this->m_exeTimeLimitBeforePause - $this->m_secondsElaplsedBeforePause;
     if ($newExecutionTimeLimit <= 0) {
         $newExecutionTimeLimit = 1;
     }
     CSystem::setExecutionTimeLimit($newExecutionTimeLimit);
     $this->m_done = true;
 }
Exemplo n.º 2
0
    <td width="42">
      <?php 
echo w2PshowImage('control-center.png', 42, 42, '');
?>
    </td>
    <td align="left" class="subtitle">
      <?php 
echo $AppUI->_('System Status');
?>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left">
      <?php 
$system = new CSystem();
if ('*****@*****.**' == w2PgetConfig('admin_email', '*****@*****.**')) {
    ?>
            <a href="?m=system&a=systemconfig#admin_email"><?php 
    echo $AppUI->_('Set the Admin Email Address');
    ?>
</a> -
            <span class="error"><?php 
    echo $AppUI->_('Please set an email address for your Web2project Administrator.');
    ?>
</span>
            <?php 
}
echo '<br />';
if ($system->upgradeRequired()) {
    ?>
Exemplo n.º 3
0
}
$perms = $AppUI->acl();
// let's see if the user has sys access
if (!canEdit('system')) {
    $AppUI->redirect('m=public&a=access_denied');
}
$titleBlock = new w2p_Theme_TitleBlock($AppUI->_('Upgrade System'), 'control-center.png', $m, $m . '.' . $a);
$titleBlock->addCrumb('?m=system', 'system admin');
$titleBlock->show();
?>
<table class="std list" width="100%" border="0" cellpadding="0" cellspacing="5">
	<tr>
		<td class="title" colspan="2">Step 2: Update Database</td>
	</tr>
	<?php 
$system = new CSystem();
$errorMessages = $system->upgradeSystem();
$updatesApplied = $system->getUpdatesApplied();
if (count($updatesApplied) > 0) {
    foreach ($updatesApplied as $update) {
        ?>
				<tr><td colspan="2">Database update - <?php 
        echo $update;
        ?>
 - applied</td></tr>
				<?php 
    }
} else {
    ?>
			<tr><td colspan="2">No database updates applied</td></tr>
			<?php 
Exemplo n.º 4
0
 /**
  * Tries to set a lock on a file so that any other process that attempts to lock the same file either waits for the
  * file to get unlocked or continues without the lock.
  *
  * @param  string $lockFp The path to the file to be locked.
  * @param  bool $wait If the file appears to be already locked, this parameter tells whether to wait for the file
  * to get unlocked (`true`) or to return immediately (`false`).
  *
  * @return bool `true` if the file was successfully locked, `false` otherwise.
  */
 public static function setLock($lockFp, $wait)
 {
     assert('is_cstring($lockFp) && is_bool($wait)', vs(isset($this), get_defined_vars()));
     if (!CFile::exists($lockFp)) {
         // Use `touch` instead of `CFile::create`.
         touch($lockFp);
     }
     $file = fopen($lockFp, "r+");
     if (flock($file, $wait ? LOCK_EX : LOCK_EX | LOCK_NB)) {
         if (!isset(self::$ms_fhFromLockFp)) {
             self::$ms_fhFromLockFp = CMap::make();
         }
         $lockFpAbs = CFilePath::absolute($lockFp);
         self::$ms_fhFromLockFp[$lockFpAbs] = $file;
         return true;
     } else {
         fclose($file);
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * Returns the path to the directory where the running script is located.
  *
  * @return CUStringObject The path to the directory where the running script is located.
  */
 public static function scriptDp()
 {
     return CFilePath::directory(CSystem::initScriptFp());
 }
Exemplo n.º 6
0
 public function testReFindDirectoriesOnNameRecursive()
 {
     $directoryPath = CFilePath::add(CSystem::temporaryFilesDp(), CFile::DEFAULT_TEMPORARY_FILE_PREFIX . self::$ms_tempDirName);
     if (CFile::exists($directoryPath)) {
         CFile::deleteDirectoryRecursive($directoryPath);
     }
     CFile::createDirectory($directoryPath);
     CFile::create(CFilePath::add($directoryPath, "file-a3"));
     CFile::create(CFilePath::add($directoryPath, "file-a20"));
     CFile::create(CFilePath::add($directoryPath, "file-a100"));
     CFile::create(CFilePath::add($directoryPath, "file-b3"));
     CFile::create(CFilePath::add($directoryPath, "file-b20"));
     CFile::create(CFilePath::add($directoryPath, "file-b100"));
     $directoryPathSub0 = CFilePath::add($directoryPath, "dir-a2");
     $directoryPathSub1 = CFilePath::add($directoryPath, "dir-a10");
     $directoryPathSub2 = CFilePath::add($directoryPath, "dir-b2");
     $directoryPathSub3 = CFilePath::add($directoryPath, "dir-b10");
     CFile::createDirectory($directoryPathSub0);
     CFile::createDirectory(CFilePath::add($directoryPathSub0, "dir-a2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub0, "dir-a10"));
     CFile::createDirectory($directoryPathSub1);
     CFile::createDirectory(CFilePath::add($directoryPathSub1, "dir-a2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub1, "dir-a10"));
     CFile::createDirectory($directoryPathSub2);
     CFile::createDirectory(CFilePath::add($directoryPathSub2, "dir-b2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub2, "dir-b10"));
     CFile::createDirectory($directoryPathSub3);
     CFile::createDirectory(CFilePath::add($directoryPathSub3, "dir-b2"));
     CFile::createDirectory(CFilePath::add($directoryPathSub3, "dir-b10"));
     $paths = CFile::reFindDirectoriesOnNameRecursive($directoryPath, "/^.*-b/");
     $comparator = function ($arrayString, $findString) {
         return $arrayString->endsWith($findString);
     };
     $this->assertTrue($paths->length() == 6);
     $this->assertTrue($paths->find("/dir-b2", $comparator) && $paths->find("/dir-b10", $comparator) && $paths->find("/dir-b2/dir-b2", $comparator) && $paths->find("/dir-b2/dir-b10", $comparator) && $paths->find("/dir-b10/dir-b2", $comparator) && $paths->find("/dir-b10/dir-b10", $comparator));
     $paths = CFile::reFindDirectoriesOnNameRecursive($directoryPath, "/^.*-b/", true);
     $this->assertTrue($paths->length() == 6);
     $this->assertTrue($paths[0]->endsWith("/dir-b2") && $paths[1]->endsWith("/dir-b10") && $paths[2]->endsWith("/dir-b2/dir-b2") && $paths[3]->endsWith("/dir-b2/dir-b10") && $paths[4]->endsWith("/dir-b10/dir-b2") && $paths[5]->endsWith("/dir-b10/dir-b10"));
     CFile::deleteDirectoryRecursive($directoryPath);
 }
Exemplo n.º 7
0
<?php

// Phred is providing PHP with a consistent, Unicode-enabled, and completely object-oriented coding standard.
// Copyright (c) 2013-2014 Nazariy Gorpynyuk
// Distributed under the GNU General Public License, Version 2.0
// https://www.gnu.org/licenses/gpl-2.0.txt
// This script is run by Composer after any update to the third-party components.
require __DIR__ . "/Phred.php";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Perform any necessary OOP wrapping of the third-party components.
CSystem::onThirdPartyUpdateByPackageManager();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Exemplo n.º 8
0
 /**
  * Creates an empty file with a unique name in the default directory for temporary files or in a specified
  * directory, and returns the path to the created file.
  *
  * After creating the file, the method sets the file's access permissions as "644", which means read/write access
  * for the file's owner (the user on whose behalf the application runs) and read-only access for other users.
  *
  * @param  string $inDirectoryPath **OPTIONAL. Default is** *the default directory for temporary files*. The path
  * to the directory where the file is to be created. If this parameter is omitted, the used directory is either the
  * OS's default directory for temporary files or, if specified, the directory read from the application's
  * configuration. If specified, the path is not required to end with "/".
  * @param  string $namePrefix **OPTIONAL. Default is** "tmp-". The name prefix for the file.
  *
  * @return CUStringObject The path to the created file.
  */
 public static function createTemporary($inDirectoryPath = null, $namePrefix = self::DEFAULT_TEMPORARY_FILE_PREFIX)
 {
     assert('(!isset($inDirectoryPath) || is_cstring($inDirectoryPath)) && is_cstring($namePrefix)', vs(isset($this), get_defined_vars()));
     if (isset($inDirectoryPath)) {
         $inDirectoryPath = CFilePath::frameworkPath($inDirectoryPath);
     } else {
         $inDirectoryPath = CSystem::temporaryFilesDp();
     }
     $filePath = tempnam($inDirectoryPath, $namePrefix);
     assert('is_cstring($filePath)', vs(isset($this), get_defined_vars()));
     self::setPermissions($filePath, self::DEFAULT_TEMPORARY_FILE_PERMISSIONS);
     return $filePath;
 }
Exemplo n.º 9
0
 public function testAbsolute()
 {
     $directoryPath = CFilePath::add(CSystem::temporaryFilesDp(), CFile::DEFAULT_TEMPORARY_FILE_PREFIX . self::$ms_tempDirName);
     if (CFile::exists($directoryPath)) {
         CFile::deleteDirectoryRecursive($directoryPath);
     }
     CFile::createDirectory($directoryPath);
     $filePathAbs = CFilePath::add($directoryPath, "file");
     CFile::create($filePathAbs);
     CSystem::cd($directoryPath);
     $this->assertTrue(CFilePath::absolute("file")->equals(CFilePath::absolute($filePathAbs)));
     $this->assertTrue(CFilePath::absolute("./file")->equals(CFilePath::absolute($filePathAbs)));
     CFile::deleteDirectoryRecursive($directoryPath);
 }
Exemplo n.º 10
0
// A function used in the OOP wrapping of third-party components.
function _is_non_tp_call()
{
    static $s_thirdPartyAbsDp;
    if (!isset($s_thirdPartyAbsDp)) {
        $s_thirdPartyAbsDp = realpath($GLOBALS["PHRED_PATH_TO_THIRD_PARTY"]);
    }
    $backTrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
    if (count($backTrace) < 2) {
        return true;
    }
    return strpos($backTrace[1]["file"], $s_thirdPartyAbsDp) !== 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If xdebug is used, tell it that the recursion depth of 100 is not always enough.
ini_set("xdebug.max_nesting_level", 4096);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Ready to initialize the framework.
CSystem::initializeFramework();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Register the aliases for the core classes.
$GLOBALS["PHRED_CLASS_ALIASES"] = CConfiguration::option("classaliases");
foreach ($GLOBALS["PHRED_CLASS_ALIASES"] as $className => $alias) {
    class_alias($className, $alias, true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Import OOP methods for the string type.
if (function_exists("register_primitive_type_handler")) {
    register_primitive_type_handler("string", "CUStringObject");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Exemplo n.º 11
0
<?php

// Phred is providing PHP with a consistent, Unicode-enabled, and completely object-oriented coding standard.
// Copyright (c) 2013-2014 Nazariy Gorpynyuk
// Distributed under the GNU General Public License, Version 2.0
// https://www.gnu.org/licenses/gpl-2.0.txt
require __DIR__ . "/Phred.php";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Consider updating some of the third-party components of the framework.
$phpConfigNeedsReload = CSystem::maybeUpdateThirdParty();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// If the script exits with success, it will be a signal for the cron job to ask PHP-FPM to reload its configuration
// (which is located in php.ini).
CShell::exitScript($phpConfigNeedsReload);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -