$textToSend = \ForceUTF8\Encoding::fixUTF8(\ForceUTF8\Encoding::toUTF8($text)); $test = mb_convert_encoding($textToSend, $enc, 'UTF-8'); if ($test != $text) { $saveToOpen = false; } else { $saveToOpen = true; } //} } else { $textToSend = $text; $saveToOpen = true; } if ($enc === 'ASCII' && mb_check_encoding($text, 'UTF-8')) { $enc = 'UTF-8'; } $json = new \stdClass(); $json->succ = 'yes'; $json->name = end($expl); $json->path = $path; $json->id = $base . '_' . str_replace('.', '_', str_replace('/', '_', $path)); $json->code = $textToSend; $json->base = $base; $json->lu = $fs->getLastModificationTime($path); $json->encoding = $enc; $json->saveToOpen = $saveToOpen ? 'yes' : 'no'; } else { $json = new \stdClass(); $json->succ = 'no'; $json->msg = 'File dont exists'; } echo json_encode($json);
<?php $root = $_POST['root']; $path = $_POST['path']; $last = $_POST['lu']; $fs = new \PFC\Editor\Sources($root); if ($fs->fileExists($path)) { echo json_encode(array('uptodate' => $fs->getLastModificationTime($path) > $last ? 'no' : 'yes', "actualTime" => $fs->getLastModificationTime($path))); } else { echo json_encode(array('uptodate' => 'not-exists')); }
if(in_array($enc,$supportedTransEnc)) $textToConvert = htmlentities($text,ENT_HTML5,'UTF-8'); else $textToConvert = $text; */ $textToConvert = mb_convert_encoding($text, $enc, 'UTF-8'); /* if(in_array($enc,$supportedTransEnc)) $textToSave = html_entity_decode($textToConvert,ENT_HTML5,$enc); else { */ $textToSave = $textToConvert; $test = mb_convert_encoding($textToSave, 'UTF-8', $enc); //} if ($test != $text && $notConfirmedOverWrite) { echo json_encode(array('succ' => 'waiting', 'type' => 'cant-succ-convert', 'msg' => 'Cant succesfully convert file contents')); } else { if ($fs->writeFileContents($path, $textToSave)) { echo json_encode(array('succ' => 'yes', 'msg' => $notConfirmedOverWrite ? 'File contents succesfully converted and saved' : 'File contents converted and succesfully saved', 'lu' => $fs->getLastModificationTime($path))); } else { echo json_encode(array('succ' => 'no', 'msg' => 'Error writing file contents')); } } } else { if ($fs->writeFileContents($path, $text)) { echo json_encode(array('succ' => 'yes', 'msg' => 'Succesfully saved', 'lu' => $fs->getLastModificationTime($path))); } else { echo json_encode(array('succ' => 'no', 'msg' => 'Error writing file contents')); } }
<?php set_time_limit(0); $root = $_POST['root']; $fs = new \PFC\Editor\Sources($root); $dirs = explode('/', $_SERVER['REQUEST_URI']); $actualDir = $dirs[count($dirs) - 2]; $dir = $_POST['dir']; if ($fs->fileExists($dir) && $fs->isDir($dir)) { $files = $fs->scandir($dir); if (count($files) > 2) { /* The 2 accounts for . and .. */ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if ($file != '.' && $file != '..' && $fs->fileExists($dir . $file) && $fs->isDir($dir . $file) && !($root == 'public' && $file == $actualDir)) { echo "<li class=\"directory collapsed\"><a href=\"#\" lastModification=\"" . $fs->getLastModificationTime($dir . $file) . "\" rel=\"" . htmlentities($dir . $file) . "/\">" . htmlentities($file) . "</a></li>"; } } // All files foreach ($files as $file) { if ($file != '.' && $file != '..' && $fs->fileExists($dir . $file) && !$fs->isDir($dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); echo "<li class=\"file ext_{$ext}\"><a extension=\"{$ext}\" lastModification=\"" . $fs->getLastModificationTime($dir . $file) . "\" href=\"#\" rel=\"" . htmlentities($dir . $file) . "\">" . htmlentities($file) . "</a></li>"; } } echo "</ul>"; } }