<?php $fs = new \PFC\Editor\Sources($_POST['root']); $base = $_POST['root']; $path = urldecode($_POST['path']); $expl = explode('/', $path); if ($fs->fileExists($path)) { $text = $fs->getFileContents($path); //check string strict for encoding out of list of supported encodings $enc = mb_detect_encoding($text, mb_list_encodings(), true); //overwrite ASCII if ($enc === false) { $enc = "UNKWN"; $textToSend = $text; $saveToOpen = false; } elseif ($enc !== "UTF-8") { //$text = mb_convert_encoding($text, 'UTF-8', $enc); /* if(function_exists('incov')) { $text = incov($enc,'UTF-8',$text); } else { */ $textToSend = \ForceUTF8\Encoding::fixUTF8(\ForceUTF8\Encoding::toUTF8($text)); $test = mb_convert_encoding($textToSend, $enc, 'UTF-8'); if ($test != $text) { $saveToOpen = false; } else { $saveToOpen = true; }
<?php $succ = 'no'; $msg = ""; $fs = new \PFC\Editor\Sources($_POST['root']); $filename = $_POST['path'] . $_POST['filename']; if ($fs->fileExists($filename)) { $err = 'File already exists'; } else { $exts = explode('.', $filename); $ext = end($exts); if ($ext == 'php') { $contents = "<?php \n"; } else { $contents = ""; } if ($fs->createNewFile($filename, $contents)) { $succ = 'yes'; $msg = 'File succesfully created'; } else { $msg = 'Fail create new file'; } } echo json_encode(array('succ' => $succ, 'msg' => $msg));
<?php set_time_limit(0); $root = $_GET['root']; $path = $_GET['path']; $fs = new \PFC\Editor\Sources($root); if ($fs->fileExists($path) && !$fs->isDir($path)) { $fs->readFile($path); } elseif ($fs->fileExists($path)) { //pack to zip //serve } else { echo "NOT EXISTiNG FLESYSTEM PATH {$root} {$path}"; }
$suff = 'bck'; $succ = 'no'; $msg = ""; $fs = new \PFC\Editor\Sources($_POST['root']); $filepath = $_POST['filepath']; $datenowbck = '.' . date('Y-m-d--H-i-s') . '.' . $suff; if (strchr(substr($filepath, 1, strlen($filepath)), '.')) { $exts = explode('.', $filepath); $ext = '.' . end($exts); $origsuff = prev($exts); $filepathbck = $filepath . $datenowbck . $ext; } else { $origsuff = ''; $filepathbck = $filepath . $datenowbck; } if ($fs->fileExists($filepathbck)) { $msg = 'Backup file already exists'; } else { if ($origsuff == $suff || substr($filepath, strlen($filepath) - 3, strlen($filepath)) == $suff) { $msg = 'Backup can not be used for backup file'; } else { if ($fs->createBackupFile($filepath, $filepathbck)) { $succ = 'yes'; $msg = 'Backup file succesfully created'; } else { $msg = 'Backup file is not created'; } } } echo json_encode(array('succ' => $succ, 'msg' => $msg));
<?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>"; } }