Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / www / html / sman1baleendahok / tiny_mce / plugins / ajaxfilemanager / | server ip : 104.21.89.46 your ip : 108.162.242.54 H O M E |
Filename | /var/www/html/sman1baleendahok/tiny_mce/plugins/ajaxfilemanager/ajax_save_name.php |
Size | 2.64 kb |
Permission | rw-rw-r-- |
Owner | ulung : ulung |
Create time | 27-Apr-2025 11:12 |
Last modified | 05-Feb-2025 08:55 |
Last accessed | 08-Jul-2025 00:05 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* ajax save name
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
*/
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
$error = '';
$fileInfo = array();
if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME)
{
$error = SYS_DISABLED;
}
elseif(empty($_POST['name']))
{
$error = ERR_RENAME_EMPTY;
}elseif(!preg_match("/^[a-zA-Z0-9 _\-.]+$/", $_POST['name']))
{
$error = ERR_RENAME_FORMAT;
}elseif(empty($_POST['original_path']) || !file_exists($_POST['original_path']))
{
$error = ERR_RENAME_FILE_NOT_EXISTS;
}elseif(substr(slashToBackslash(removeTrailingSlash($_POST['original_path'])), strrpos(slashToBackslash(removeTrailingSlash($_POST['original_path'])), "/") + 1) == $_POST['name'])
{
$error = ERR_NO_CHANGES_MADE;
}elseif(file_exists(addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
{
$error = ERR_RENAME_EXISTS;
}elseif(is_file($_POST['original_path']) && !isValidExt($_POST['name'], explode(",", CONFIG_UPLOAD_VALID_EXTS), explode(",", CONFIG_UPLOAD_INVALID_EXTS)))
{
$error = ERR_RENAME_FILE_TYPE_NOT_PERMITED;
}elseif(!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
{
$error = ERR_RENAME_FAILED;
}else
{
//update record of session if image exists in session for cut or copy
include_once(CLASS_SESSION_ACTION);
$sessionAction = new SessionAction();
$selectedDocuments = $sessionAction->get();
if(removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments))
{
if(($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false)
{
$selectedDocuments[$key] = $_POST['name'];
$sessionAction->set($selectedDocuments);
}
}elseif(removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path']))
{
$sessionAction->setFolder($_POST['original_path']);
}
$path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'];
if(is_file($path))
{
include_once(CLASS_FILE);
$file = new file($path);
$fileInfo = $file->getFileInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
}else
{
include_once(CLASS_MANAGER);
$manager = new manager($path, false);
$fileInfo = $manager->getFolderInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
}
}
echo "{";
echo "error:'" . $error . "' ";
foreach ($fileInfo as $k=>$v)
{
echo "," . $k . ":'" . $v . "' ";
}
echo "}";
?>
/**
* ajax save name
* @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
* @link www.phpletter.com
* @since 22/May/2007
*
*/
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
$error = '';
$fileInfo = array();
if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_RENAME)
{
$error = SYS_DISABLED;
}
elseif(empty($_POST['name']))
{
$error = ERR_RENAME_EMPTY;
}elseif(!preg_match("/^[a-zA-Z0-9 _\-.]+$/", $_POST['name']))
{
$error = ERR_RENAME_FORMAT;
}elseif(empty($_POST['original_path']) || !file_exists($_POST['original_path']))
{
$error = ERR_RENAME_FILE_NOT_EXISTS;
}elseif(substr(slashToBackslash(removeTrailingSlash($_POST['original_path'])), strrpos(slashToBackslash(removeTrailingSlash($_POST['original_path'])), "/") + 1) == $_POST['name'])
{
$error = ERR_NO_CHANGES_MADE;
}elseif(file_exists(addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
{
$error = ERR_RENAME_EXISTS;
}elseif(is_file($_POST['original_path']) && !isValidExt($_POST['name'], explode(",", CONFIG_UPLOAD_VALID_EXTS), explode(",", CONFIG_UPLOAD_INVALID_EXTS)))
{
$error = ERR_RENAME_FILE_TYPE_NOT_PERMITED;
}elseif(!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name']))
{
$error = ERR_RENAME_FAILED;
}else
{
//update record of session if image exists in session for cut or copy
include_once(CLASS_SESSION_ACTION);
$sessionAction = new SessionAction();
$selectedDocuments = $sessionAction->get();
if(removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments))
{
if(($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false)
{
$selectedDocuments[$key] = $_POST['name'];
$sessionAction->set($selectedDocuments);
}
}elseif(removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path']))
{
$sessionAction->setFolder($_POST['original_path']);
}
$path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'];
if(is_file($path))
{
include_once(CLASS_FILE);
$file = new file($path);
$fileInfo = $file->getFileInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
}else
{
include_once(CLASS_MANAGER);
$manager = new manager($path, false);
$fileInfo = $manager->getFolderInfo();
$fileInfo['mtime'] = date(DATE_TIME_FORMAT,$fileInfo['mtime']);
}
}
echo "{";
echo "error:'" . $error . "' ";
foreach ($fileInfo as $k=>$v)
{
echo "," . $k . ":'" . $v . "' ";
}
echo "}";
?>