function tmp_path_create($path) { global $ftp_host, $ftp_login, $ftp_passw; $path_tmp = path_tmp(); $arr = explode("/", $path); $path_array = array_slice($arr, 1, -1); $file_name = end($arr); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (file_exists($path_tmp) === false) { @mkdir($path_tmp); } foreach ($path_array as $path_value) { if ($path_value != "." && $path_value != "..") { $path_tmp = $path_tmp . "/" . $path_value; if (file_exists($path_tmp) === false) { @mkdir($path_tmp); } } } } else { $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_login, $ftp_passw); if (file_exists($path_tmp) === false) { ftp_mkdir($conn_id, ftp_path_correct($path_tmp)); } foreach ($path_array as $path_value) { if ($path_value != "." && $path_value != "..") { $path_tmp = $path_tmp . "/" . $path_value; if (file_exists($path_tmp) === false) { @ftp_mkdir($conn_id, ftp_path_correct($path_tmp)); } } } ftp_close($conn_id); } return $path_tmp . "/" . $file_name; }
<?php if (!$_SESSION['admin']) { exit; } $folder_name = rawurldecode(htmlspecialchars($_POST['folder_name'], ENT_QUOTES)); $folder_name_new = rawurldecode(htmlspecialchars($_POST['folder_name_new'], ENT_QUOTES)); $path = rawurldecode(htmlspecialchars($_POST['path'], ENT_QUOTES)); $path_ftp = ftp_path_correct(rawurldecode(htmlspecialchars($_POST['path'], ENT_QUOTES))); if (is_dir($path)) { if (file_exists($path . "/" . $folder_name)) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (@rename($path . "/" . $folder_name, $path . "/" . $folder_name_new)) { echo 1; } else { echo 2; } } else { $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_login, $ftp_passw); if (@ftp_rename($conn_id, $path_ftp . "/" . $folder_name, $path_ftp . "/" . $folder_name_new)) { echo 1; } else { echo 2; } ftp_close($conn_id); exit; } } else { echo 2; exit;
<?php if (!$_SESSION['admin']) { exit; } $folder_name = rawurldecode(htmlspecialchars($_POST['folder_name'], ENT_QUOTES)); $folder_name_ftp = ftp_path_correct(rawurldecode(htmlspecialchars($_POST['folder_name'], ENT_QUOTES))); if (file_exists($folder_name)) { $dir_name = substr($folder_name, 0, strrpos($folder_name, "/")); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { @rmdir($folder_name); } else { $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_login, $ftp_passw); @ftp_rmdir($conn_id, $folder_name_ftp); ftp_close($conn_id); } if (!file_exists($folder_name)) { echo "1"; } else { @rmdir($folder_name); if (!file_exists($folder_name)) { echo "1"; } else { echo "2"; } } exit; } else { echo "2"; }
<?php if (!$_SESSION['admin']) { exit; } $file_name = ftp_path_correct(rawurldecode(htmlspecialchars($_POST['file_name'], ENT_QUOTES))); //echo $file_name; //exit; $file_chmod = htmlspecialchars($_POST['chmod'], ENT_QUOTES); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { echo "1"; exit; } $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_login, $ftp_passw); $mode = octdec('0' . (int) $file_chmod); if (ftp_chmod($conn_id, $mode, $file_name) !== false) { echo "1"; } else { if (chmod($file_name, $mode) !== false) { echo "1"; } else { echo "2"; } } ftp_close($conn_id); /* function chmod_R($path, $filemode) { if (!is_dir($path)) return chmod($path, $filemode);
exit; } if ($f_load != "") { if ($size_f > 1024 * 5 * 1024 || $size_f == 0) { ?> <script language="javascript"> alert("Размер загружаемого файла превышает 5 Мб!"); location.replace("<?php echo $_SERVER['REQUEST_URI']; ?> "); </script> <?php } $fil_nam = htmlspecialchars($_POST['path'], ENT_QUOTES); $fil_nam_ftp = ftp_path_correct(htmlspecialchars($_POST['path'], ENT_QUOTES)); if (!is_writable($fil_nam)) { $permiss_first = substr(sprintf('%o', fileperms($fil_nam)), -4); $ftp_object = new FtpFileChmod($ftp_host, $ftp_login, $ftp_passw); $ftp_object->file_chmod($fil_nam_ftp, '0777'); } $file_full_name = $fil_nam . '/' . $f_name; if (!file_exists($file_full_name)) { move_uploaded_file($_FILES["filename"]["tmp_name"], $file_full_name); } if ($ftp_object) { $ftp_object->file_chmod($fil_nam_ftp, $permiss_first); unset($ftp_object); } } }