コード例 #1
0
ファイル: etsis_Logger.php プロジェクト: parkerj/eduTrac-SIS
 /**
  * Purges system error logs that are older than 30 days old.
  * 
  * @since 1.0.0
  */
 public function purgeErrorLog()
 {
     $logs = glob(APP_PATH . 'tmp/logs/*.txt');
     if (is_array($logs)) {
         foreach ($logs as $log) {
             $filelastmodified = file_mod_time($log);
             if (time() - $filelastmodified >= 30 * 24 * 3600 && is_file($log)) {
                 unlink($log);
             }
         }
     }
 }
コード例 #2
0
 /**
  * Removes any and all stale items from the cache.
  *
  * @since 6.2.0
  * @param int|string $key
  *            Unqiue key of cache.
  * @param int|string $namespace
  *            Optional. Where the cache contents are namespaced. Default: 'default'.
  * @param int $ttl
  *            Time to live sets the life of the cache file. Default: 0.
  */
 protected function removeStaleCache($key, $namespace = 'default', $ttl = 0)
 {
     if (empty($namespace)) {
         $namespace = 'default';
     }
     if (!$this->_exists($key, $namespace)) {
         $this->app->cookies->remove(md5($key));
     }
     $stale = glob($this->_dir . $namespace . DS . '*');
     if (is_array($stale)) {
         foreach ($stale as $filename) {
             if (file_exists($filename)) {
                 if (time() - file_mod_time($filename) > (int) $ttl) {
                     unlink($filename);
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: etsis_Updater.php プロジェクト: parkerj/eduTrac-SIS
 /**
  * Checks if a new release is available.
  * If so, installation along with
  * database will be updated.
  *
  * @since 6.2.2
  */
 public function updateCheck()
 {
     $error = $this->getServerStatus();
     if (is_etsis_exception($error)) {
         echo $error->getMessage();
     } else {
         $this->update->setCurrentVersion(RELEASE_TAG);
         $this->update->setUpdateUrl($this->url . 'core/1.1/update-check');
         // Optional:
         $this->update->addLogHandler(new \Monolog\Handler\StreamHandler(APP_PATH . 'tmp' . DS . 'logs' . DS . 'core-update.' . date('m-d-Y') . '.txt'));
         $this->update->setCache(new \Desarrolla2\Cache\Adapter\File(APP_PATH . 'tmp/cache'), 3600);
         $cacheFile = APP_PATH . 'tmp/cache/__update-versions.php.cache';
         echo '<p>' . sprintf(_t('Last checked on %s @ %s'), date('M d, Y', file_mod_time($cacheFile)), date('h:i A', file_mod_time($cacheFile)));
         if ($this->update->checkUpdate() !== false) {
             if ($this->update->newVersionAvailable()) {
                 // Install new update
                 echo sprintf(_t('<p>New Release: <font color="red">r%s</font></p>'), $this->update->getLatestVersion());
                 echo '<p>' . _t('Installing Updates: ') . '</p>';
                 echo '<pre>';
                 var_dump(array_map(function ($version) {
                     return (string) $version;
                 }, $this->update->getVersionsToUpdate()));
                 echo '</pre>';
                 $result = $this->update->update();
                 echo '<p>' . _t('Database Check . . .') . '</p>';
                 $this->updateDatabaseCheck();
                 echo '<p>' . _t('Directory Check . . .') . '</p>';
                 $this->removeDirCheck();
                 echo '<p>' . _t('File Check . . .') . '</p>';
                 $this->removeFileCheck();
                 if ($result === true) {
                     echo '<p>' . _t('Update successful!') . '</p>';
                 } else {
                     echo '<p>' . sprintf(_t('Update failed: %s!'), $result) . '</p>';
                     if ($result = \VisualAppeal\AutoUpdate::ERROR_SIMULATE) {
                         echo '<pre>';
                         var_dump($this->update->getSimulationResults());
                         echo '</pre>';
                     }
                 }
             } else {
                 echo sprintf(_t('<p>You currently have the latest release of eduTrac SIS installed: <font color="green">r%s</font></p>'), RELEASE_TAG);
             }
         } else {
             echo '<p>' . _t('Could not check for updates! See log file for details.') . '</p>';
         }
     }
 }