From 76dc065d82bcb6a31440bfa20ce195404d3fc45b Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:40:19 -0300 Subject: [PATCH 01/18] Changing instances of dirname(__FILE__) to __DIR__ it's equivalent and easier to read this constant was introduced in php version 5.3. --- editor.php | 10 +++--- index.php | 4 +-- lib/backup-versions.php | 4 +-- lib/bug-files-check.php | 4 +-- lib/file-control-xhr.php | 10 +++--- lib/headers.php | 6 ++-- lib/settings-common.php | 10 +++--- lib/settings-screen.php | 4 +-- lib/settings.php | 50 +++++++++++++++--------------- lib/terminal-xhr.php | 6 ++-- lib/updater.php | 6 ++-- processes/on-bug-check.php | 4 +-- processes/on-editor-load.php | 4 +-- processes/on-file-dir-delete.php | 4 +-- processes/on-file-dir-move.php | 4 +-- processes/on-file-dir-paste.php | 4 +-- processes/on-file-dir-perms.php | 4 +-- processes/on-file-dir-rename.php | 4 +-- processes/on-file-load.php | 4 +-- processes/on-file-replace-text.php | 4 +-- processes/on-file-save.php | 12 +++---- processes/on-file-upload.php | 4 +-- processes/on-get-remote-file.php | 4 +-- processes/on-new-dir.php | 4 +-- processes/on-user-login-fail.php | 4 +-- processes/on-user-login.php | 4 +-- processes/on-user-logout.php | 4 +-- processes/on-user-new.php | 4 +-- test.php | 2 +- 29 files changed, 96 insertions(+), 96 deletions(-) diff --git a/editor.php b/editor.php index ec297290..3e9e6bfe 100644 --- a/editor.php +++ b/editor.php @@ -21,26 +21,26 @@ //--> '; };?> /addon/fold/foldgutter.css?microtime="> /addon/scroll/simplescrollbars.css?microtime="> '; };?> '; };?> '; };?> '; };?>
Zip It!'.PHP_EOL; }; ?> @@ -344,4 +344,4 @@ - \ No newline at end of file + diff --git a/lib/backup-versions.php b/lib/backup-versions.php index f49beb86..2af3c912 100644 --- a/lib/backup-versions.php +++ b/lib/backup-versions.php @@ -110,7 +110,7 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), { @@ -167,4 +167,4 @@ - \ No newline at end of file + diff --git a/lib/bug-files-check.php b/lib/bug-files-check.php index b18c68c4..824c00f2 100644 --- a/lib/bug-files-check.php +++ b/lib/bug-files-check.php @@ -93,7 +93,7 @@ } // Get dir name tmp dir's parent -$tmpLoc = dirname(__FILE__); +$tmpLoc = __DIR__; $tmpLoc = explode(DIRECTORY_SEPARATOR,$tmpLoc); $tmpLoc = $tmpLoc[count($tmpLoc)-2]; @@ -112,4 +112,4 @@ // Finally, display our status in JSON format as the XHR response text echo json_encode($status); -?> \ No newline at end of file +?> diff --git a/lib/file-control-xhr.php b/lib/file-control-xhr.php index cbf70043..3e8351f1 100644 --- a/lib/file-control-xhr.php +++ b/lib/file-control-xhr.php @@ -359,7 +359,7 @@ function stitchChanges($fileLines) { $backupDirFormat = "Y-m-d"; // Establish the base, host and date dir parts... - $backupDirBase = str_replace("\\","/",dirname(__FILE__))."/../backups/"; + $backupDirBase = str_replace("\\","/",__DIR__)."/../backups/"; $backupDirHost = isset($ftpSite) ? parse_url($ftpSite,PHP_URL_HOST) : "localhost"; $backupDirDate = date($backupDirFormat); @@ -815,7 +815,7 @@ function getDetails($fileArr) { } else { // Delete file to tmp dir or full delete $ICEcoder['deleteToTmp'] - ? rename($fullPath,str_replace("\\","/",dirname(__FILE__))."/../tmp/.".str_replace(":","_",str_replace("/","_",$fullPath))) + ? rename($fullPath,str_replace("\\","/",__DIR__)."/../tmp/.".str_replace(":","_",str_replace("/","_",$fullPath))) : unlink($fullPath); } $fileName = basename($fullPath); @@ -847,14 +847,14 @@ function rrmdir($dir) { rrmdir($dir."/".$object); } else { $ICEcoder['deleteToTmp'] - ? rename($dir."/".$object,str_replace("\\","/",dirname(__FILE__))."/../tmp/.".str_replace(":","_",str_replace("/","_",$dir))."/".$object) + ? rename($dir."/".$object,str_replace("\\","/",__DIR__)."/../tmp/.".str_replace(":","_",str_replace("/","_",$dir))."/".$object) : unlink($dir."/".$object); } } } reset($objects); $ICEcoder['deleteToTmp'] - ? rename($dir,str_replace("\\","/",dirname(__FILE__))."/../tmp/.".str_replace(":","_",str_replace("/","_",$dir))) + ? rename($dir,str_replace("\\","/",__DIR__)."/../tmp/.".str_replace(":","_",str_replace("/","_",$dir))) : rmdir($dir); } }; @@ -1009,4 +1009,4 @@ function rrmdir($dir) { "errorMsg" : "'.$errorMsg.'" } }'; -?> \ No newline at end of file +?> diff --git a/lib/headers.php b/lib/headers.php index b178e593..ba32a63f 100644 --- a/lib/headers.php +++ b/lib/headers.php @@ -1,11 +1,11 @@ \ No newline at end of file +?> diff --git a/lib/settings-common.php b/lib/settings-common.php index 00b7512d..d8665eb8 100644 --- a/lib/settings-common.php +++ b/lib/settings-common.php @@ -2,7 +2,7 @@ // Don't display, but log all errors ini_set('display_errors', 0); ini_set('log_errors', 1); -ini_set('error_log', dirname(__FILE__).'/../error-log.txt'); +ini_set('error_log', __DIR__.'/../error-log.txt'); error_reporting(-1); // Set our default timezone and supress warning with @ @@ -22,13 +22,13 @@ ini_set('session.name','ICEcoder_Cookie'); // Set a seperate cookie session name ini_set('session.cookie_lifetime','0'); // Until the browser restarts by default ini_set('session.cookie_domain',''); // This domain only -// ini_set('session.cookie_path',str_replace($_SERVER['DOCUMENT_ROOT'],'',dirname(dirname(__FILE__)))); // ICEcoder path only, fails ON IE +// ini_set('session.cookie_path',str_replace($_SERVER['DOCUMENT_ROOT'],'',dirname(__DIR__))); // ICEcoder path only, fails ON IE ini_set('session.use_trans_sid','0'); // Ensure this insecure feature is disabled ini_set('session.hash_function','sha512'); // Use Sha512 for session ini_set('session.hash_bits_per_character','6'); // Specify hash scheme of 0-9,a-v,A-Z,-,, // ini_set('session.use_strict_mode','1'); // Reject any session ID that was user provided and not generated by the session (since PHP 5.5.2) ini_set('session.httponly','1'); // Only allow http protocol (ie, not JS) access to the cookie (since PHP 5.2.0) - ini_set('session.save_path',dirname(__FILE__).'/../tmp'); // Localise the session files to /tmp + ini_set('session.save_path',__DIR__.'/../tmp'); // Localise the session files to /tmp if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { ini_set('session.cookie_secure','1'); // Only allows access to session ID when protocol is HTTPS, switched on under 'if https' condition @@ -90,7 +90,7 @@ function getData($url,$type='fopen',$dieMessage=false,$timeout=60) { // Logout if that's the action we're taking if (isset($_GET['logout'])) { - include(dirname(__FILE__)."/../processes/on-user-logout.php"); + include(__DIR__."/../processes/on-user-logout.php"); $_SESSION['loggedIn']=false; $_SESSION['username']=false; session_destroy(); @@ -254,7 +254,7 @@ function getVersionsCount($fileLoc,$fileName) { $dateCounts = array(); $backupDateDirs = array(); // Establish the base, host and date dirs within... - $backupDirBase = str_replace("\\","/",dirname(__FILE__))."/../backups/"; + $backupDirBase = str_replace("\\","/",__DIR__)."/../backups/"; $backupDirHost = isset($ftpSite) ? parse_url($ftpSite,PHP_URL_HOST) : "localhost"; // check if folder exists if local before enumerating contents if(!isset($ftpSite)) { diff --git a/lib/settings-screen.php b/lib/settings-screen.php index 068d30a3..4fc9d189 100644 --- a/lib/settings-screen.php +++ b/lib/settings-screen.php @@ -163,7 +163,7 @@
- \ No newline at end of file + diff --git a/lib/settings.php b/lib/settings.php index 7a84934c..44fade45 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -5,10 +5,10 @@ // Create a new config file if it doesn't exist yet. // The reason we create it, is so it has PHP write permissions, meaning we can update it later -if (!file_exists(dirname(__FILE__)."/".$configSettings)) { +if (!file_exists(__DIR__."/".$configSettings)) { // Include our params to make use of (as $newConfigSettingsFile) - include(dirname(__FILE__)."/settings-system-params.php"); - if ($fConfigSettings = fopen(dirname(__FILE__)."/".$configSettings, 'w')) { + include(__DIR__."/settings-system-params.php"); + if ($fConfigSettings = fopen(__DIR__."/".$configSettings, 'w')) { fwrite($fConfigSettings, $newConfigSettingsFile); fclose($fConfigSettings); } else { @@ -17,10 +17,10 @@ } // Load config settings -include(dirname(__FILE__)."/".$configSettings); +include(__DIR__."/".$configSettings); // Load common functions -include_once(dirname(__FILE__)."/settings-common.php"); +include_once(__DIR__."/settings-common.php"); // Establish user settings file $username = ""; @@ -32,15 +32,15 @@ $setPWorLogin = "login"; // Create user settings file if it doesn't exist -if (!file_exists(dirname(__FILE__)."/".$settingsFile) && $ICEcoderSettings['enableRegistration']) { - if (!copy(dirname(__FILE__)."/".$configUsersTemplate, dirname(__FILE__)."/".$settingsFile)) { +if (!file_exists(__DIR__."/".$settingsFile) && $ICEcoderSettings['enableRegistration']) { + if (!copy(__DIR__."/".$configUsersTemplate, __DIR__."/".$settingsFile)) { die("Couldn't create $settingsFile. Maybe you need write permissions on the lib folder?"); } $setPWorLogin = "set password"; } // Load user settings -include(dirname(__FILE__)."/".$settingsFile); +include(__DIR__."/".$settingsFile); // Remove any previous files that are no longer there $prevFiles = explode(",",$ICEcoderUserSettings['previousFiles']); @@ -55,9 +55,9 @@ // Replace our config created date with the filemtime? if (basename($_SERVER['SCRIPT_NAME']) == "index.php" && $ICEcoderUserSettings['configCreateDate'] == 0) { - $settingsContents = getData(dirname(__FILE__)."/".$settingsFile); + $settingsContents = getData(__DIR__."/".$settingsFile); clearstatcache(); - $configfilemtime = filemtime(dirname(__FILE__)."/"."config___settings.php"); + $configfilemtime = filemtime(__DIR__."/"."config___settings.php"); // Make it a number (avoids null, undefined etc) $configfilemtime = intval($configfilemtime); // Set it to the epoch time now if we don't have a real value @@ -66,7 +66,7 @@ } $settingsContents = str_replace('"configCreateDate" => 0,','"configCreateDate" => '.$configfilemtime.',',$settingsContents); // Now update the config file - $fh = fopen(dirname(__FILE__)."/".$settingsFile, 'w') or die("Can't update config file. Please set public write permissions on ".$settingsFile." and press refresh"); + $fh = fopen(__DIR__."/".$settingsFile, 'w') or die("Can't update config file. Please set public write permissions on ".$settingsFile." and press refresh"); fwrite($fh, $settingsContents); fclose($fh); // Set the new value in array @@ -75,7 +75,7 @@ // On mismatch of settings file to system, rename to .old and reload If ($ICEcoderUserSettings["versionNo"] != $ICEcoderSettings["versionNo"]) { - rename(dirname(__FILE__)."/".$settingsFile,dirname(__FILE__)."/".str_replace(".php",".old",$settingsFile)); + rename(__DIR__."/".$settingsFile,__DIR__."/".str_replace(".php",".old",$settingsFile)); header("Location: settings.php"); echo ""; die('Found old settings file, reloading...'); @@ -86,10 +86,10 @@ // Include language file // Load base first as foundation -include(dirname(__FILE__)."/../lang/".basename($ICEcoder['languageBase'])); +include(__DIR__."/../lang/".basename($ICEcoder['languageBase'])); $baseText = $text; // Load chosen language ontop to replace base -include(dirname(__FILE__)."/../lang/".basename($ICEcoder['languageUser'])); +include(__DIR__."/../lang/".basename($ICEcoder['languageUser'])); $text = array_replace_recursive($baseText, $text); $_SESSION['text'] = $text; @@ -117,7 +117,7 @@ $tDaysRemaining = intval($tRemaining/(60*60*24)); // Update this config file? -include(dirname(__FILE__)."/settings-update.php"); +include(__DIR__."/settings-update.php"); // Set loggedIn and username to false if not set as yet if (!isset($_SESSION['loggedIn'])) {$_SESSION['loggedIn'] = false;}; @@ -132,12 +132,12 @@ $_SESSION['username'] = $_POST['username']; } $_SESSION['loggedIn'] = true; - include(dirname(__FILE__)."/../processes/on-user-login.php"); + include(__DIR__."/../processes/on-user-login.php"); header('Location: ../'); echo ""; die('Logging you in...'); } else { - include(dirname(__FILE__)."/../processes/on-user-login-fail.php"); + include(__DIR__."/../processes/on-user-login-fail.php"); } }; @@ -184,10 +184,10 @@ } // Save currently opened files in previousFiles and last10Files arrays -include(dirname(__FILE__)."/settings-save-current-files.php"); +include(__DIR__."/settings-save-current-files.php"); // Display the plugins -include(dirname(__FILE__)."/plugins-display.php"); +include(__DIR__."/plugins-display.php"); // If loggedIn is false or we don't have a password set yet and we're not on login screen, boot user to that if ((!$_SESSION['loggedIn'] || $ICEcoder["password"] == "") && !strpos($_SERVER['SCRIPT_NAME'],"lib/login.php")) { @@ -251,15 +251,15 @@ $serverAddr = "127.0.0.1"; } $settingsFileAddr = 'config-'.$username.str_replace(".","_",$serverAddr).'.php'; - if (!file_exists(dirname(__FILE__)."/".$settingsFileAddr)) { - if (!copy(dirname(__FILE__)."/".$settingsFile, dirname(__FILE__)."/".$settingsFileAddr)) { + if (!file_exists(__DIR__."/".$settingsFileAddr)) { + if (!copy(__DIR__."/".$settingsFile, __DIR__."/".$settingsFileAddr)) { die("Couldn't create $settingsFileAddr. Maybe you need write permissions on the lib folder?"); } } // Disable the enableRegistration config setting if the user had that option chosen if (isset($_POST['disableFurtherRegistration'])) { - $updatedConfigSettingsFile = getData(dirname(__FILE__)."/".$configSettings); - if ($fUConfigSettings = fopen(dirname(__FILE__)."/".$configSettings, 'w')) { + $updatedConfigSettingsFile = getData(__DIR__."/".$configSettings); + if ($fUConfigSettings = fopen(__DIR__."/".$configSettings, 'w')) { $updatedConfigSettingsFile = str_replace('"enableRegistration" => true','"enableRegistration" => false',$updatedConfigSettingsFile); fwrite($fUConfigSettings, $updatedConfigSettingsFile); fclose($fUConfigSettings); @@ -272,7 +272,7 @@ $_SESSION['username']=$_POST['username']; } $_SESSION['loggedIn'] = true; - include(dirname(__FILE__)."/../processes/on-user-new.php"); + include(__DIR__."/../processes/on-user-new.php"); // Finally, load again as now this file has changed and auto login header('Location: ../'); echo ""; @@ -290,4 +290,4 @@ // Continue with whatever we're doing // ================================== } -?> \ No newline at end of file +?> diff --git a/lib/terminal-xhr.php b/lib/terminal-xhr.php index 267f2771..e063cadd 100644 --- a/lib/terminal-xhr.php +++ b/lib/terminal-xhr.php @@ -1,6 +1,6 @@ '; // Create a new config file if it doesn't exist yet. // The reason we create it, is so it has PHP write permissions, meaning we can update it later - if (!file_exists(dirname(__FILE__)."/".$configSettings)) { + if (!file_exists(__DIR__."/".$configSettings)) { echo 'Creating new settings file...
'; // Include our params to make use of (as $newConfigSettingsFile) - include(dirname(__FILE__)."/settings-system-params.php"); - if ($fConfigSettings = fopen(dirname(__FILE__)."/".$configSettings, 'w')) { + include(__DIR__."/settings-system-params.php"); + if ($fConfigSettings = fopen(__DIR__."/".$configSettings, 'w')) { fwrite($fConfigSettings, $newConfigSettingsFile); fclose($fConfigSettings); } else { diff --git a/processes/on-bug-check.php b/processes/on-bug-check.php index 1d14fecd..80a62bde 100644 --- a/processes/on-bug-check.php +++ b/processes/on-bug-check.php @@ -5,7 +5,7 @@ // Purpose: This file is run after a bug check, has $result string and $status arrays available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../bug-logs.log", 'a'); +// $fh = fopen(__DIR__."/../bug-logs.log", 'a'); // fwrite($fh, "Bug check on: ".date("D dS M Y h:i:sa")."\nresult: ".$result.", status array:".var_export($status, true)."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-editor-load.php b/processes/on-editor-load.php index 9adcd8d6..5592c2d3 100644 --- a/processes/on-editor-load.php +++ b/processes/on-editor-load.php @@ -30,7 +30,7 @@ cMdiff.setOption("mode",mode); } } else if (cM && fileName) { - + if (mode != cM.getOption("mode")) { cM.setOption("mode",mode); @@ -195,4 +195,4 @@ top.ICEcoder.caretLocType = caretLocType; } - \ No newline at end of file + diff --git a/processes/on-file-dir-delete.php b/processes/on-file-dir-delete.php index 0fa96486..772776dd 100644 --- a/processes/on-file-dir-delete.php +++ b/processes/on-file-dir-delete.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file or dir is deleted, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "DELETED >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-dir-move.php b/processes/on-file-dir-move.php index c01c8709..e3dc8031 100644 --- a/processes/on-file-dir-move.php +++ b/processes/on-file-dir-move.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file or dir is moved, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "MOVED >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-dir-paste.php b/processes/on-file-dir-paste.php index cd318999..1e689865 100644 --- a/processes/on-file-dir-paste.php +++ b/processes/on-file-dir-paste.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file or dir is pasted, has $fileLoc, $fileName and $dest strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "PASTE >>> ".date("D dS M Y h:i:sa").": ".$dest."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-dir-perms.php b/processes/on-file-dir-perms.php index b6c91dc7..0ab25aec 100644 --- a/processes/on-file-dir-perms.php +++ b/processes/on-file-dir-perms.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file or dir has its perms changed, has $fileLoc, $fileName and $_GET['perms'] strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "PERMS >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName." = ".$_GET['perms']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-dir-rename.php b/processes/on-file-dir-rename.php index 3ab8d1e0..578068ef 100644 --- a/processes/on-file-dir-rename.php +++ b/processes/on-file-dir-rename.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file or dir is renamed, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "RENAMED >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-load.php b/processes/on-file-load.php index 885c1bea..5a09c4a2 100644 --- a/processes/on-file-load.php +++ b/processes/on-file-load.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file is loaded, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "LOAD >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-replace-text.php b/processes/on-file-replace-text.php index 7a56439d..b3da88bb 100644 --- a/processes/on-file-replace-text.php +++ b/processes/on-file-replace-text.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a file has text in it replaced, has $_GET['fileRef'] string available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "REPLACED TEXT >>> ".date("D dS M Y h:i:sa").": ".$_GET['fileRef']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-file-save.php b/processes/on-file-save.php index 10f97ee9..0a7efa5b 100644 --- a/processes/on-file-save.php +++ b/processes/on-file-save.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a user saves a file, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "SAVE >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); @@ -16,9 +16,9 @@ $fileExt = $filePieces[count($filePieces)-1]; // SCSS Compiling if we have SCSSPHP plugin installed -if (strtolower($fileExt) == "scss" && file_exists(dirname(__FILE__)."/../plugins/scssphp/scss.inc.php")) { +if (strtolower($fileExt) == "scss" && file_exists(__DIR__."/../plugins/scssphp/scss.inc.php")) { // Load the SCSSPHP lib and start a new instance - require dirname(__FILE__)."/../plugins/scssphp/scss.inc.php"; + require __DIR__."/../plugins/scssphp/scss.inc.php"; $scss = new scssc(); // Set the import path and formatting type @@ -36,9 +36,9 @@ } // LESS Compiling if we have LESSPHP plugin installed -if (strtolower($fileExt) == "less" && file_exists(dirname(__FILE__)."/../plugins/lessphp/lessc.inc.php")) { +if (strtolower($fileExt) == "less" && file_exists(__DIR__."/../plugins/lessphp/lessc.inc.php")) { // Load the LESSPHP lib and start a new instance - require dirname(__FILE__)."/../plugins/lessphp/lessc.inc.php"; + require __DIR__."/../plugins/lessphp/lessc.inc.php"; $less = new lessc(); // Set the formatting type and if we want to preserve comments @@ -51,4 +51,4 @@ echo ";top.ICEcoder.message('Couldn\'t compile your LESS, error info below:\\n\\n".$e->getMessage()."');"; } } -?> \ No newline at end of file +?> diff --git a/processes/on-file-upload.php b/processes/on-file-upload.php index 6c252226..7dd676d5 100644 --- a/processes/on-file-upload.php +++ b/processes/on-file-upload.php @@ -5,7 +5,7 @@ // Purpose: This file is run when files are uploaded, has $uploads array available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "UPLOAD >>> ".date("D dS M Y h:i:sa").": ".($uploads[0]->name)."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-get-remote-file.php b/processes/on-get-remote-file.php index a83b0e5b..fd4ba37e 100644 --- a/processes/on-get-remote-file.php +++ b/processes/on-get-remote-file.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a remote file is loaded, has $file string available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "GET REMOTE FILE >>> ".date("D dS M Y h:i:sa").": ".$file."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-new-dir.php b/processes/on-new-dir.php index c166fb92..78b6a166 100644 --- a/processes/on-new-dir.php +++ b/processes/on-new-dir.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a dir is created, has $fileLoc and $fileName strings available to it // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../file-dir-access.log", 'a'); +// $fh = fopen(__DIR__."/../file-dir-access.log", 'a'); // fwrite($fh, "NEW DIR >>> ".date("D dS M Y h:i:sa").": ".$fileLoc."/".$fileName."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-user-login-fail.php b/processes/on-user-login-fail.php index 9289a8ce..7bb22b6f 100644 --- a/processes/on-user-login-fail.php +++ b/processes/on-user-login-fail.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a login fail occurs // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../user-access.log", 'a'); +// $fh = fopen(__DIR__."/../user-access.log", 'a'); // fwrite($fh, "FAIL ".date("D dS M Y h:i:sa").": ".$_POST['username']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-user-login.php b/processes/on-user-login.php index 0842dd56..04d05b3c 100644 --- a/processes/on-user-login.php +++ b/processes/on-user-login.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a user logs in // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../user-access.log", 'a'); +// $fh = fopen(__DIR__."/../user-access.log", 'a'); // fwrite($fh, "login ".date("D dS M Y h:i:sa").": ".$_SESSION['username']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-user-logout.php b/processes/on-user-logout.php index ba176bfd..18ec3d04 100644 --- a/processes/on-user-logout.php +++ b/processes/on-user-logout.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a user logs out // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../user-access.log", 'a'); +// $fh = fopen(__DIR__."/../user-access.log", 'a'); // fwrite($fh, "logout ".date("D dS M Y h:i:sa").": ".$_SESSION['username']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/processes/on-user-new.php b/processes/on-user-new.php index 40c57d36..939b2db3 100644 --- a/processes/on-user-new.php +++ b/processes/on-user-new.php @@ -5,7 +5,7 @@ // Purpose: This file is run when a new user sets up // Langs: PHP only // Example: -// $fh = fopen(dirname(__FILE__)."/../user-access.log", 'a'); +// $fh = fopen(__DIR__."/../user-access.log", 'a'); // fwrite($fh, "NEW >>> ".date("D dS M Y h:i:sa").": ".$_SESSION['username']."\n"); // fclose($fh); -?> \ No newline at end of file +?> diff --git a/test.php b/test.php index f75506fc..2646e982 100644 --- a/test.php +++ b/test.php @@ -64,7 +64,7 @@ $configSettings = 'config___settings.php'; // Load config settings -include(dirname(__FILE__)."/lib/".$configSettings); +include(__DIR__."/lib/".$configSettings); echo "This version of ICEcoder is: ".$ICEcoderSettings['versionNo']."

"; echo 'TEST RESULT: '; From 52d8440dc564aef8ca9d612c14e799fd34bae748 Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:42:48 -0300 Subject: [PATCH 02/18] fixing funcion name case mismatch --- lib/get-branch.php | 4 ++-- lib/updater.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/get-branch.php b/lib/get-branch.php index dff4e22e..a66317bd 100644 --- a/lib/get-branch.php +++ b/lib/get-branch.php @@ -137,7 +137,7 @@ function parseGitignore($file) { # $file = '/absolute/path/to/.gitignore' ftpEnd(); // or get local list } else { - $finalArray = scanDir($scanDir.$location); + $finalArray = scandir($scanDir.$location); } foreach($finalArray as $entry) { @@ -479,4 +479,4 @@ function parseGitignore($file) { # $file = '/absolute/path/to/.gitignore' } - \ No newline at end of file + diff --git a/lib/updater.php b/lib/updater.php index 54f5c648..1e223d2b 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -194,7 +194,7 @@ function copyOverSettings($icvInfo) { transposeSettings(PATH."lib/config___users-template.php","config___users-template.php","config___users-template.php"); // Users settings files - $fileList = scanDir(PATH."lib/"); + $fileList = scandir(PATH."lib/"); for ($i=0; $i -1) { echo 'Transposing users settings file '.$fileList[$i].'...
'; From fd2603a956e122af645b81da0139556ae18bfa18 Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:46:29 -0300 Subject: [PATCH 03/18] removing unnecessary variable attributions --- lib/file-control-xhr.php | 4 +--- lib/ftp-control.php | 8 +++----- lib/settings-common.php | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/file-control-xhr.php b/lib/file-control-xhr.php index 3e8351f1..4ac2d8e6 100644 --- a/lib/file-control-xhr.php +++ b/lib/file-control-xhr.php @@ -157,9 +157,7 @@ function stitchChanges($fileLines) { } // Set and return the newly stitched together content - $contents = implode("",$fileLines); - - return $contents; + return implode("",$fileLines); } diff --git a/lib/ftp-control.php b/lib/ftp-control.php index 93b388fb..7d525521 100644 --- a/lib/ftp-control.php +++ b/lib/ftp-control.php @@ -47,10 +47,8 @@ function ftpGetFileInfo($ftpConn, $directory = '.', $fileName) { $detailedList = $ftpListArrays['detailedList']; // Now get the file info for our file - $fileInfo = $detailedList[$fileName]; - - // Return the info - return $fileInfo; + // Return the info + return $detailedList[$fileName]; } // Get contents over FTP @@ -112,4 +110,4 @@ function ftpDelete($ftpConn, $type, $path) { return ftp_rmdir($ftpConn, $path); } } -?> \ No newline at end of file +?> diff --git a/lib/settings-common.php b/lib/settings-common.php index d8665eb8..7bc7add9 100644 --- a/lib/settings-common.php +++ b/lib/settings-common.php @@ -167,8 +167,7 @@ function xssClean($data,$type) { } } - $output = str_replace($bad, $good, $data); - return $output; + return str_replace($bad, $good, $data); } From 972ae19e254febe7f0cbd2ba3bde791d31dcfabe Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:49:45 -0300 Subject: [PATCH 04/18] changing the alias function is_writeable to the php function is_writable --- lib/ftp-manager.php | 4 ++-- lib/github-manager.php | 4 ++-- lib/go-localhost-root.php | 4 ++-- lib/plugins-manager.php | 2 +- lib/properties.php | 4 ++-- lib/settings-save-current-files.php | 6 +++--- lib/settings-update.php | 6 +++--- lib/updater.php | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/ftp-manager.php b/lib/ftp-manager.php index 5cd94215..f2b2fded 100644 --- a/lib/ftp-manager.php +++ b/lib/ftp-manager.php @@ -103,7 +103,7 @@ $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,$repPosEnd,strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -209,4 +209,4 @@ - \ No newline at end of file + diff --git a/lib/github-manager.php b/lib/github-manager.php index 761b831a..32644a35 100644 --- a/lib/github-manager.php +++ b/lib/github-manager.php @@ -48,7 +48,7 @@ $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,$repPosEnd,strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -151,7 +151,7 @@ $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,$repPosEnd,strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); diff --git a/lib/go-localhost-root.php b/lib/go-localhost-root.php index 7117b894..b146a761 100644 --- a/lib/go-localhost-root.php +++ b/lib/go-localhost-root.php @@ -18,7 +18,7 @@ substr($settingsContents,($repPosEnd),strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -34,4 +34,4 @@ ?> \ No newline at end of file +?> diff --git a/lib/plugins-manager.php b/lib/plugins-manager.php index c5aef66b..e71feae4 100644 --- a/lib/plugins-manager.php +++ b/lib/plugins-manager.php @@ -132,7 +132,7 @@ $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,$repPosEnd,strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); diff --git a/lib/properties.php b/lib/properties.php index 615a475b..7ae4db2c 100644 --- a/lib/properties.php +++ b/lib/properties.php @@ -48,7 +48,7 @@

: : - / + / :

@@ -172,4 +172,4 @@ function changePerms(val) { - \ No newline at end of file + diff --git a/lib/settings-save-current-files.php b/lib/settings-save-current-files.php index 44b1b065..0d2cd1f2 100644 --- a/lib/settings-save-current-files.php +++ b/lib/settings-save-current-files.php @@ -26,7 +26,7 @@ } $settingsContents = substr($settingsContents,0,$repPosStart).$saveFiles.substr($settingsContents,($repPosStart+$repPosEnd),strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -45,7 +45,7 @@ if (count($last10FilesArray)>=10) {$ICEcoder["last10Files"]=substr($ICEcoder["last10Files"],0,strrpos($ICEcoder["last10Files"],','));}; $settingsContents = substr($settingsContents,0,$repPosStart).$saveFilesArray[$i].$commaExtra.$ICEcoder["last10Files"].substr($settingsContents,($repPosStart+$repPosEnd),strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -57,4 +57,4 @@ } echo ''; } -?> \ No newline at end of file +?> diff --git a/lib/settings-update.php b/lib/settings-update.php index a759ee12..9364d9ec 100644 --- a/lib/settings-update.php +++ b/lib/settings-update.php @@ -63,7 +63,7 @@ $settingsContents = substr($settingsContents,0,$repPosStart).$settingsNew.substr($settingsContents,($repPosEnd),strlen($settingsContents)); // Now update the config file - if (is_writeable($settingsFile)) { + if (is_writable($settingsFile)) { $fh = fopen($settingsFile, 'w'); fwrite($fh, $settingsContents); fclose($fh); @@ -94,7 +94,7 @@ $generalSettingsContents = str_replace('"enableRegistration" => true','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents); $generalSettingsContents = str_replace('"enableRegistration" => false','"enableRegistration" => '.$isEnableRegistration,$generalSettingsContents); - if (is_writeable($configSettings)) { + if (is_writable($configSettings)) { $fConfigSettings = fopen($configSettings, 'w'); fwrite($fConfigSettings, $generalSettingsContents); fclose($fConfigSettings); @@ -114,4 +114,4 @@ $jsBugFilePaths = "['".str_replace(",","','",str_replace(" ","",strClean($_POST['bugFilePaths'])))."']"; echo ""; } -?> \ No newline at end of file +?> diff --git a/lib/updater.php b/lib/updater.php index 1e223d2b..150a3b74 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -24,7 +24,7 @@ function startUpdate() { $testPath = $source.DIRECTORY_SEPARATOR.$iterator->getSubPathName(); $testPath = str_replace("\\","/",$testPath); if (strpos($testPath,"/backups/")==false && strpos($testPath,"/plugins/")==false && strpos($testPath,"/.git/")==false) { - if (!is_writeable($item)) { + if (!is_writable($item)) { array_push($cantMoveArray,substr($item,count($source)+2)); } } From fe3683a91ba4f919c8b01c25c5be6778dca4752c Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:54:35 -0300 Subject: [PATCH 05/18] simplifying $isMac attribution, it doesn't need a ternary operator --- index.php | 2 +- lib/help.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index bf903fc3..953d6c7d 100644 --- a/index.php +++ b/index.php @@ -21,7 +21,7 @@ } } -$isMac = strpos($_SERVER['HTTP_USER_AGENT'], "Macintosh")>-1 ? true : false; +$isMac = strpos($_SERVER['HTTP_USER_AGENT'], "Macintosh") > -1; ?> diff --git a/lib/help.php b/lib/help.php index 387308fe..274d34a5 100644 --- a/lib/help.php +++ b/lib/help.php @@ -17,7 +17,7 @@

--1 ? true : false;?> + -1;?>

@@ -78,4 +78,4 @@ - \ No newline at end of file + From 28ee41c009ce232b6fa018d9f95de0d66368859a Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 00:57:14 -0300 Subject: [PATCH 06/18] using array_merge instead of '+' to merge arrays --- lib/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/settings.php b/lib/settings.php index 44fade45..4a30864a 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -82,7 +82,7 @@ } // Join ICEcoder settings and user settings together to make our final ICEcoder array -$ICEcoder = $ICEcoderSettings + $ICEcoderUserSettings; +$ICEcoder = array_merge($ICEcoderSettings , $ICEcoderUserSettings); // Include language file // Load base first as foundation From 6ed2edb4a107f8530851c3b077e10bd04b94fcc2 Mon Sep 17 00:00:00 2001 From: Rafael Rotelok Date: Sat, 16 Jun 2018 01:04:49 -0300 Subject: [PATCH 07/18] Removing unnecessary semi-colons --- editor.php | 25 ++++++------ files.php | 7 ++-- index.php | 16 ++++---- lib/file-control-xhr.php | 42 +++++++++---------- lib/file-control.php | 25 ++++++------ lib/ftp-manager.php | 10 ++--- lib/get-branch.php | 18 ++++----- lib/github-manager.php | 4 +- lib/go-localhost-root.php | 2 +- lib/login.php | 20 +++++----- lib/multiple-results.php | 37 +++++++++-------- lib/plugins-display.php | 12 +++--- lib/plugins-manager.php | 4 +- lib/properties.php | 20 +++++----- lib/settings-save-current-files.php | 4 +- lib/settings-screen.php | 62 ++++++++++++++--------------- lib/settings-update.php | 4 +- lib/settings.php | 16 ++++---- test/index.php | 4 +- 19 files changed, 165 insertions(+), 167 deletions(-) diff --git a/editor.php b/editor.php index 3e9e6bfe..c1b30914 100644 --- a/editor.php +++ b/editor.php @@ -23,28 +23,28 @@ '; -};?> +} ?> /addon/fold/foldgutter.css?microtime="> /addon/scroll/simplescrollbars.css?microtime="> '; -};?> +} ?> '; -};?> +} ?> '; -};?> +} ?> '; -};?> +} ?>

- +


@@ -147,10 +147,9 @@ echo ''; echo str_replace($docRoot,"",str_replace("|","/",$last10FilesArray[$i])); echo ''; - if ($i + if ($i
@@ -175,8 +174,8 @@
+ } + ?>

:
diff --git a/files.php b/files.php index 3831e2db..7d6cf723 100644 --- a/files.php +++ b/files.php @@ -15,7 +15,8 @@ - +