Permalink
Browse files

Replaced dirname(__FILE__) PHP 5.3.0+ __DIR__

  • Loading branch information...
1 parent 9c841c2 commit 3563fb6682acbeeb1018ad2428bac3ea7aff4b68 @benkeen committed Nov 3, 2013
View
@@ -4,7 +4,7 @@
* This handles all Ajax requests for the Data Generator Core. Note that we only include the library.php
* here, we don't Core::init(). Depending on the context (e.g. installation), that may not be desired.
*/
-require_once(realpath(dirname(__FILE__) . "/library.php"));
+require_once(__DIR__ . "/library.php");
// sessions needed here AFTER installation, to get access to $user [or should it be passed &
// validated with all requests?]
View
@@ -1,6 +1,6 @@
<?php
-require_once(realpath(dirname(__FILE__) . "/library.php"));
+require_once(__DIR__ . "/library.php");
Core::init("generation");
$gen = new DataGenerator($_POST);
View
@@ -9,32 +9,32 @@
* automatically by the installation script.
*/
-require_once(dirname(__FILE__) . "/resources/classes/Account.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/AjaxRequest.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Core.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/CountryPlugin.abstract.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/CountryPluginHelper.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Database.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/DataGenerator.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/DataTypePlugin.abstract.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/DataTypePluginHelper.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Emails.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/ErrorCodes.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/ExportTypePlugin.abstract.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/ExportTypePluginHelper.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/GeoData.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Installation.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Language.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Minification.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/SessionManager.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Settings.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Templates.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Translations.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/Utils.class.php");
+require_once(__DIR__ . "/resources/classes/Account.class.php");
+require_once(__DIR__ . "/resources/classes/AjaxRequest.class.php");
+require_once(__DIR__ . "/resources/classes/Core.class.php");
+require_once(__DIR__ . "/resources/classes/CountryPlugin.abstract.class.php");
+require_once(__DIR__ . "/resources/classes/CountryPluginHelper.class.php");
+require_once(__DIR__ . "/resources/classes/Database.class.php");
+require_once(__DIR__ . "/resources/classes/DataGenerator.class.php");
+require_once(__DIR__ . "/resources/classes/DataTypePlugin.abstract.class.php");
+require_once(__DIR__ . "/resources/classes/DataTypePluginHelper.class.php");
+require_once(__DIR__ . "/resources/classes/Emails.class.php");
+require_once(__DIR__ . "/resources/classes/ErrorCodes.class.php");
+require_once(__DIR__ . "/resources/classes/ExportTypePlugin.abstract.class.php");
+require_once(__DIR__ . "/resources/classes/ExportTypePluginHelper.class.php");
+require_once(__DIR__ . "/resources/classes/GeoData.class.php");
+require_once(__DIR__ . "/resources/classes/Installation.class.php");
+require_once(__DIR__ . "/resources/classes/Language.class.php");
+require_once(__DIR__ . "/resources/classes/Minification.class.php");
+require_once(__DIR__ . "/resources/classes/SessionManager.class.php");
+require_once(__DIR__ . "/resources/classes/Settings.class.php");
+require_once(__DIR__ . "/resources/classes/Templates.class.php");
+require_once(__DIR__ . "/resources/classes/Translations.class.php");
+require_once(__DIR__ . "/resources/classes/Utils.class.php");
// Smarty - use SecureSmarty!
-require_once(dirname(__FILE__) . "/resources/libs/smarty/Smarty.class.php");
-require_once(dirname(__FILE__) . "/resources/classes/SecureSmarty.class.php");
+require_once(__DIR__ . "/resources/libs/smarty/Smarty.class.php");
+require_once(__DIR__ . "/resources/classes/SecureSmarty.class.php");
// handle magic quotes
@@ -52,4 +52,4 @@
}
}
unset($process);
-}
+}
@@ -19,8 +19,8 @@ public function __construct($runtimeContext) {
parent::__construct($runtimeContext);
if ($runtimeContext == "generation") {
$this->smarty = new SecureSmarty();
- $this->smarty->template_dir = realpath(dirname(__FILE__) . "/../../../resources/libs/smarty");
- $this->smarty->compile_dir = realpath(dirname(__FILE__) . "/../../../cache");
+ $this->smarty->template_dir = realpath(__DIR__ . "/../../../resources/libs/smarty");
+ $this->smarty->compile_dir = realpath(__DIR__ . "/../../../cache");
}
}
@@ -151,7 +151,7 @@ public static function init($runtimeContext = "ui") {
* @access private
*/
private static function loadSettingsFile() {
- $settingsFilePath = realpath(dirname(__FILE__) . "/../../settings.php");
+ $settingsFilePath = realpath(__DIR__ . "/../../settings.php");
if (file_exists($settingsFilePath)) {
self::$settingsFileExists = true;
require_once($settingsFilePath);
@@ -398,8 +398,8 @@ public static function isSmartySecurityEnabled() {
*/
private function initSmarty() {
self::$smarty = new SecureSmarty();
- self::$smarty->template_dir = realpath(dirname(__FILE__) . "/../templates/");
- self::$smarty->compile_dir = realpath(dirname(__FILE__) . "/../../cache/");
+ self::$smarty->template_dir = realpath(__DIR__ . "/../templates/");
+ self::$smarty->compile_dir = realpath(__DIR__ . "/../../cache/");
self::$smarty->assign("version", self::getVersion());
self::$smarty->assign("samePage", Utils::getCleanPhpSelf());
}
@@ -26,7 +26,7 @@ public static function getCountryPlugins($installedOnly = true) {
$allowedCountries = explode(",", $installedCountries);
}
- $countryPluginsFolder = realpath(dirname(__FILE__) . "/../../plugins/countries");
+ $countryPluginsFolder = realpath(__DIR__ . "/../../plugins/countries");
$countryPlugins = array();
if ($handle = opendir($countryPluginsFolder)) {
@@ -131,7 +131,7 @@ public static function getDataTypePlugins($runtimeContext, $installedOnly = true
$allowedDataTypes = explode(",", $installedDataTypes);
}
- $dataTypesFolder = realpath(dirname(__FILE__) . "/../../plugins/dataTypes");
+ $dataTypesFolder = realpath(__DIR__ . "/../../plugins/dataTypes");
$dataTypes = array();
if ($handle = opendir($dataTypesFolder)) {
while (false !== ($item = readdir($handle))) {
@@ -18,7 +18,7 @@ public static function getExportTypePlugins($runtimeContext, $installedOnly = tr
$exportTypes = Settings::getSetting("installedExportTypes");
$allowedExportTypes = explode(",", $exportTypes);
}
- $exportTypesFolder = realpath(dirname(__FILE__) . "/../../plugins/exportTypes");
+ $exportTypesFolder = realpath(__DIR__ . "/../../plugins/exportTypes");
$exportTypes = array();
if ($handle = opendir($exportTypesFolder)) {
while (false !== ($item = readdir($handle))) {
@@ -179,7 +179,7 @@ public static function getExportTypeCodeMirrorModes($exportTypes) {
foreach ($exportTypes as $exportType) {
$modes = $exportType->getCodeMirrorModes();
foreach ($modes as $mode) {
- if (file_exists(realpath(dirname(__FILE__) . "/../libs/codemirror/mode/{$mode}/{$mode}.js"))) {
+ if (file_exists(realpath(__DIR__ . "/../libs/codemirror/mode/{$mode}/{$mode}.js"))) {
$files[] = "resources/libs/codemirror/mode/{$mode}/{$mode}.js";
}
}
@@ -27,7 +27,7 @@ public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $db
\$encryptionSalt = '$encryptionSalt';
END;
- $file = dirname(__FILE__) . "/../../settings.php";
+ $file = __DIR__ . "/../../settings.php";
$handle = @fopen($file, "w");
if ($handle) {
fwrite($handle, $content);
@@ -33,7 +33,7 @@ function __construct($languageFile, $overrideDefault = true) {
// TODO exception handling here
- $fileAndPath = realpath(dirname(__FILE__) . "/../lang/" . $this->currentLanguageFile . ".php");
+ $fileAndPath = realpath(__DIR__ . "/../lang/" . $this->currentLanguageFile . ".php");
require($fileAndPath);
$this->currentLanguageStrings = $L;
}
@@ -116,7 +116,7 @@ private function overrideDefaultLanguageFile() {
}
if (!empty($overriddenLangFile)) {
- $fileAndPath = realpath(dirname(__FILE__) . "/../lang/{$overriddenLangFile}.php");
+ $fileAndPath = realpath(__DIR__ . "/../lang/{$overriddenLangFile}.php");
if (file_exists($fileAndPath)) {
$languageFile = $overriddenLangFile;
}
@@ -38,7 +38,7 @@ public static function createAppStartFile() {
$js = 'require(["manager","generator","accountManager",' . $exportTypeJSModules . "," . $dataTypeJSModules . ',"pageInit"], function(manager) {manager.start(); });';
- $file = realpath(dirname(__FILE__) . "/../../cache/") . "/appStartGenerated.js";
+ $file = realpath(__DIR__ . "/../../cache/") . "/appStartGenerated.js";
if (is_file($file)) {
unlink($file);
}
@@ -51,7 +51,7 @@ public static function createAppStartFile() {
}
private static function checkMinifiedFileExists() {
- @include(realpath(dirname(__FILE__) . "/../../cache/minifiedResourcePaths.php"));
+ @include(realpath(__DIR__ . "/../../cache/minifiedResourcePaths.php"));
$info = get_defined_vars();
if (!isset($info["MINIFIED"])) {
@@ -56,7 +56,7 @@ public static function displayPage($template, $pageVars = array(), $action = "di
}
try {
- $templatePath = realpath(dirname(__FILE__) . "/../../$template");
+ $templatePath = realpath(__DIR__ . "/../../$template");
if ($action == "display") {
Core::$smarty->display($templatePath);
@@ -87,8 +87,8 @@ public static function evalSmartyTemplate($template, $placeholders) {
*/
public static function evalSmartyString($placeholderStr, $placeholders) {
$smarty = new SecureSmarty();
- $smarty->template_dir = realpath(dirname(__FILE__) . "/../libs/smarty");
- $smarty->compile_dir = realpath(dirname(__FILE__) . "/../../cache");
+ $smarty->template_dir = realpath(__DIR__ . "/../libs/smarty");
+ $smarty->compile_dir = realpath(__DIR__ . "/../../cache");
if (!empty($placeholders)) {
while (list($key, $value) = each($placeholders)) {
@@ -14,7 +14,7 @@ class Translations {
* @return array a hash of filename => language name
*/
function __construct() {
- $translationsFolder = realpath(dirname(__FILE__) . "/../lang/");
+ $translationsFolder = realpath(__DIR__ . "/../lang/");
$translations = array();
if ($handle = opendir($translationsFolder)) {
while (false !== ($item = readdir($handle))) {
@@ -48,7 +48,7 @@ public static function assert($statements) {
break;
case "noSettingsFile":
- $settingsFileAndPath = realpath(dirname(__FILE__) . "/../settings.php");
+ $settingsFileAndPath = realpath(__DIR__ . "/../settings.php");
$settingsFileExists = file_exists($settingsFileAndPath);
if ($values === true && $settingsFileExists) {
throw new GDException(Exceptions::SETTINGSFILEEXISTS);

0 comments on commit 3563fb6

Please sign in to comment.