/** * @test */ public function escapeOutputBuffering() { ob_start(); ob_start(); ob_start(); $inceptionLevel = ob_get_level(); SLIR::escapeOutputBuffering(); $this->assertLessThan($inceptionLevel, ob_get_level()); }
/** * Checks the config file being used against the default configuration and determines if anything needs to be updated. * * @since 2.0 * @return SLIRInstallerResponse */ private function checkConfigEntropy() { $this->slir->getConfig(); $reflectDefaults = new ReflectionClass('SLIRConfigDefaults'); $reflectConfig = new ReflectionClass('SLIRConfig'); $defaultProperties = $reflectDefaults->getStaticProperties(); $configProperties = $reflectConfig->getStaticProperties(); $additions = array_diff(array_keys($configProperties), array_keys($defaultProperties)); if (count($additions) === 0) { return new PositiveSLIRInstallerResponse('There are no settings in your config file that are not also found in the default config file.'); } else { return new NegativeSLIRInstallerResponse(vsprintf('There %s in your config file that was not found in the default config file. %s most likely leftover from a previous version and should be addressed. Check the following %s in <code>%s</code> against what is found in <code>%s</code>: <code>$%s</code>', array($this->renderQuantity(count($additions), 'is %d setting', 'are %d settings'), $this->renderQuantity(count($additions), 'This setting was', 'These settings were'), $this->renderQuantity(count($additions), 'setting', 'settings'), $this->getConfigPath(), $this->getDefaultConfigPath(), implode('</code>, <code>$', $additions)))); } }
<?php /** * Main file for SLIR (Smart Lencioni Image Resizer) * * This file is part of SLIR (Smart Lencioni Image Resizer). * * SLIR is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * SLIR is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SLIR. If not, see <http://www.gnu.org/licenses/>. * * @copyright Copyright © 2011, Joe Lencioni * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3) * @since 2.0 * @package SLIR */ // define('SLIR_CONFIG_FILENAME', 'slir-config-alternate.php'); require_once 'core/slir.class.php'; $slir = new SLIR(); $slir->processRequestFromURL();
/** * Removes the file that signifies that the garbage collector is currently running. * * @since 2.0 * @param boolean $successful * @return void */ private function finish($successful = true) { $configClass = SLIR::getConfigClass(); // Delete the file that tells SLIR that the garbage collector is running unlink($configClass::$pathToCacheDir . '/garbageCollector.tmp'); if ($successful) { error_log(sprintf("\n[%s] Garbage collection completed", @gmdate('D M d H:i:s Y')), 3, $configClass::$pathToErrorLog); } }
/** * Checks to see if the SLIR error log exists and is writable. * * @since 2.0 * @return SLIRInstallerResponse */ private function initializeErrorLog() { $configClass = SLIR::getConfigClass(); if (!file_exists($configClass::$pathToErrorLog)) { // Error log does not exist, try creating it if (file_put_contents($configClass::$pathToErrorLog, '') === false) { // Error log was unable to be created return new NegativeSLIRInstallerResponse(sprintf('Error log does not exist and could not be created at <code>%s</code>. Please create this file and make sure the web server has permission to write to it. If you would like to change the path of this file, set $pathToErrorLog in slirconfig.class.php and run the installer again.', $configClass::$pathToErrorLog)); } else { // Everything worked well return new PositiveSLIRInstallerResponse(sprintf('Error log successfully created at <code>%s</code>. If you would like to change the path of this file, set $pathToErrorLog in slirconfig.class.php and run the installer again.', $configClass::$pathToErrorLog)); } } else { if (!is_writable($configClass::$pathToErrorLog)) { // Error log exists, but is not writable return new NegativeSLIRInstallerResponse(sprintf('Error log exists at <code>%s</code> but is not writable. Please make sure the web server has permission to write to this file. If you would like to change the path of this file, set $pathToErrorLog in slirconfig.class.php and run the installer again.', $configClass::$pathToErrorLog)); } else { // Everything is good return new PositiveSLIRInstallerResponse(sprintf('Error log exists at <code>%s</code> and is writable by the web server. If you would like to change the path of this file, set $pathToErrorLog in slirconfig.class.php and run the installer again.', $configClass::$pathToErrorLog)); } } }
/** * @return string * @since 2.0 */ public final function fullPath() { $configClass = SLIR::getConfigClass(); return $configClass::$documentRoot . $this->path; }