Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 14, 2023. It is now read-only.
/ICEcoderPublic archive

Commitf196bb9

Browse files
author
mattpass
committed
Fixing Save As issue plus a few PHP notices
1 parentd1deb93 commitf196bb9

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

‎classes/File.php‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ public function writeFile() {
353353
$fileLines =file($file);
354354
$contents =$this->systemClass->stitchChanges($fileLines,$_POST['changes']);
355355

356-
//get old file contents, and count stats on usage \n and \r there
357-
//inthiscase we can keep line endings, which file had before, without
358-
//making code version control systems going crazy about line endings change in whole file.
356+
//Get old file contents, and count stats on usage \n and \r\n
357+
//We usethisinfo shortly to standardise the file to the same line endings
358+
//throughout, whichever is greater
359359
$oldContents =file_exists($file) ?getData($file) :'';
360360
$unixNewLines =preg_match_all('/[^\r][\n]/u',$oldContents);
361361
$windowsNewLines =preg_match_all('/[\r][\n]/u',$oldContents);
@@ -368,11 +368,13 @@ public function writeFile() {
368368
$systemClass->invalidateOPCache($file);
369369
$fh =fopen($file,'w')ordie($t['Sorry, cannot save']);
370370

371-
//replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
371+
//Replace \r\n (Windows), \r (old Mac) and \n (Linux) line endings with whatever we chose to be lineEnding
372372
$contents =str_replace("\r\n",$ICEcoder["lineEnding"],$contents);
373373
$contents =str_replace("\r",$ICEcoder["lineEnding"],$contents);
374374
$contents =str_replace("\n",$ICEcoder["lineEnding"],$contents);
375-
if (isset($_POST['changes']) && (0 <$unixNewLines) || (0 <$windowsNewLines)) {
375+
// Finally, replace the line endings with whatever what greatest in the file before
376+
// (We do this to help avoid a huge number of unnecessary changes simply on line endings)
377+
if (isset($_POST['changes']) && (0 <$unixNewLines ||0 <$windowsNewLines)) {
376378
if ($unixNewLines >$windowsNewLines){
377379
$contents =str_replace($ICEcoder["lineEnding"],"\n",$contents);
378380
}elseif ($windowsNewLines >$unixNewLines){
@@ -735,7 +737,7 @@ public function returnJSON() {
735737
}else {
736738
$itemAbsPath =$file;
737739
$itemPath =dirname($file);
738-
$itemBytes =is_dir($file) ?null :filesize($file);
740+
$itemBytes =is_dir($file)|| !file_exists($file)?null :filesize($file);
739741
$itemType = (file_exists($file) ? (is_dir($file) ?"dir" :"file") :"unknown");
740742
$itemExists = (file_exists($file) ?"true" :"false");
741743
}

‎lib/file-control.php‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,12 @@
136136

137137
if (!$demoMode && (isset($ftpSite) || (file_exists($file) &&is_writable($file)) ||isset($_POST['newFileName']) &&"" !=$_POST['newFileName'])) {
138138

139-
$filemtime = !isset($ftpSite) &&"Windows" !==$serverType ?filemtime($file) :"1000000";
139+
$filemtime = !isset($ftpSite) &&"Windows" !==$serverType&&file_exists($file)?filemtime($file) :"1000000";
140140

141-
// =======================
142-
// MDT'S MATCH, WRITE FILE
143-
// =======================
144-
145-
if (!(isset($_GET['fileMDT'])) ||$filemtime ==$_GET['fileMDT']) {
141+
// ==================================================
142+
// MDT'S MATCH (OR WE'RE SAVING NEW FILE), WRITE FILE
143+
// ==================================================
144+
if (!(isset($_GET['fileMDT'])) ||$filemtime ==$_GET['fileMDT'] ||isset($_POST['newFileName'])) {
146145

147146
// FTP Saving
148147
if (isset($ftpSite)) {
@@ -488,7 +487,7 @@
488487

489488
// No $filemtime yet? Get it now!
490489
if (false ===isset($filemtime) && !is_dir($file)) {
491-
$filemtime ="Windows" !==$serverType ?filemtime($file) :1000000;
490+
$filemtime ="Windows" !==$serverType&&file_exists($file)?filemtime($file) :1000000;
492491
}
493492
if (false ===isset($filemtime)) {
494493
$filemtime =1000000;

‎terminal.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@
9393

9494
<body onclick="document.getElementById('command').focus()">
9595
<?php
96-
chdir($_SESSION['cwd']);
96+
if (true ===isset($_SESSION['cwd'])) {
97+
chdir($_SESSION['cwd']);
98+
}
9799
$user =str_replace("\n","",shell_exec("whoami"));
98100
$cwd =str_replace("\n","",shell_exec("pwd"));
99101
?>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp