<?php $succ = 'no'; $msg = ""; $root = $_POST['root']; $oldname = $_POST['oldname']; $newname = $_POST['newname']; $fs = new \PFC\Editor\Sources($root); if ($fs->renaming($oldname, $newname)) { $succ = 'yes'; $msg = 'Successfully rename'; } else { $msg = 'Fail rename folder or file'; } echo json_encode(array('succ' => $succ, 'msg' => $msg));
<?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 = ""; $root = $_POST['root']; $path = $_POST['path']; $fs = new \PFC\Editor\Sources($root); if ($fs->delete($path)) { $succ = 'yes'; $msg = 'Successfully deleted'; } else { $msg = 'Fail delete folder or file'; } echo json_encode(array('succ' => $succ, 'msg' => $msg, 'fileTab' => '#file_' . $root . '_' . str_replace('.', '_', str_replace('/', '_', $path))));
<?php $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'; } } }
<?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}"; }
<?php $succ = 'no'; $msg = ""; $root = $_POST['root']; $path = $_POST['path']; $action = $_POST['action']; $newright = $_POST['newright']; $perm = '0'; $fs = new \PFC\Editor\Sources($root); if (!$action) { $perm = $fs->security($path, 0, '0'); $succ = 'yes'; $msg = 'Security loaded'; } else { if ($fs->security($path, 1, $newright)) { $succ = 'yes'; $msg = 'Successfully change right'; } else { $msg = 'Fail change right'; } } echo json_encode(array('perm' => $perm, 'succ' => $succ, 'msg' => $msg));
<?php $fs = new \PFC\Editor\Sources($_POST['root']); $path = $_POST['path']; $text = $_POST['code']; $enc = $_POST['encoding']; $notConfirmedOverWrite = isset($_POST['confirmedOverwrite']) && $_POST['confirmedOverwrite'] == 'yes' ? false : true; if ($enc !== 'UTF-8') { /* $supportedTransEnc = array('ISO-8859-1', 'ISO8859-1', 'ISO-8859-5', 'ISO8859-5', 'ISO-8859-15', 'ISO8859-15', 'UTF-8', 'cp866', 'ibm866', '866', 'cp1251', 'Windows-1251', 'win-1251', '1251', 'cp1252', 'Windows-1252', '1252', 'KOI8-R', 'koi8-ru', 'koi8r', 'BIG5', '950', 'GB2312', '936', 'BIG5-HKSCS', 'Shift_JIS', 'SJIS', 'SJIS-win', 'cp932', '932', 'EUC-JP', 'EUCJP', 'eucJP-win', 'MacRoman'); 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))
<?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')); }
<?php @set_time_limit(0); $dd = json_decode($_POST['dir']); if ($dd->root) { $root = $dd->root; $fs = new \PFC\Editor\Sources($root); $dirs = explode('/', $_SERVER['REQUEST_URI']); $actualDir = $dirs[count($dirs) - 2]; $dir = $dd->path; $opendirs = $dd->openedDirs; echo $fs->printDir($dir, $opendirs); } else { echo "no root provided"; }
<?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>"; } }
<?php $succ = 'no'; $msg = ""; $fs = new \PFC\Editor\Sources($_POST['root']); $foldername = $_POST['path'] . $_POST['foldername']; if ($fs->isDir($foldername)) { $msg = 'Folder already exists'; } else { if ($fs->createNewFolder($foldername)) { $succ = 'yes'; $msg = 'Folder succesfully created'; } else { $msg = 'Fail create folder'; } } echo json_encode(array('succ' => $succ, 'msg' => $msg));