/** * Check if the JS validationbox has to be added and redirect if the site hasn't been validated yet for a while. * * @param object \PH7\Framework\Session\Session $oSess * @return boolean */ public static function needInject(Framework\Session\Session $oSess) { $oVSModel = new ValidateSiteCoreModel(); $iSinceSiteCreated = VDate::getTime(StatisticCoreModel::getSiteSinceDate()); // After over 2 months, the site is still not validated, maybe the validation box doesn't really work, so we redirected to the page form if (!$oVSModel->is() && VDate::setTime('-2 months') > $iSinceSiteCreated && !$oSess->exists(self::SESS_IS_VISITED)) { Header::redirect(Uri::get('validate-site', 'main', 'validationbox')); } if (!$oVSModel->is() && VDate::setTime('-2 days') > $iSinceSiteCreated) { // OK for adding the validation colorbox return true; } return false; }
/** * Check and load the files if necessary. * * @param string $sFileNamePath A pH7Framework filename path. * @return void */ private function _loadFile($sFileNamePath) { $oFile = new File(); $sFullPath = PH7_PATH_FRAMEWORK . $sFileNamePath; $bIsExpiredFile = $oFile->getModifTime($sFullPath) + VDate::setTime('+2 months') < VDate::getTime(); $bFileExists = $oFile->existFile($sFullPath); $bIsTooSmallFile = $oFile->size($sFullPath) < 1000; if (!$bFileExists || $bIsTooSmallFile || $bIsExpiredFile) { if ($bFileExists) { // Delete the file if it already exists $oFile->deleteFile($sFullPath); } $this->_downloadFile($sFileNamePath, $oFile); } unset($oFile); }
/** * Check and load the files if necessary. * * @return void */ private function _loadFile() { $oFile = new File(); $sFileNamePath = PH7_PATH_FRAMEWORK . 'Core/License.class.php'; $bIsExpiredFile = $oFile->modificationTime($sFileNamePath) + VDate::setTime('+1 month') < VDate::getTime(); if (!$oFile->existsFile($sFileNamePath) || $bIsExpiredFile) { if ($bIsExpiredFile) { $oFile->deleteFile($sFileNamePath); } $this->_downloadFile($sFileNamePath, $oFile); } unset($oFile); }