public function actionMove()
{
$json = array();
if (isset($_POST['from']) && isset($_POST['to'])) {
$from = rtrim(Yii::app()->params['imagePath'] . 'data/' . str_replace('../', '', html_entity_decode($_POST['from'], ENT_QUOTES, 'UTF-8')), '/');
if (!file_exists($from)) {
$json['error'] = Yii::t('filemanager', 'Warning: File or directory does not exist!');
}
if ($from == Yii::app()->params['imagePath'] . 'data') {
$json['error'] = Yii::t('filemanager', 'Warning: Can not alter your default directory!');
}
$to = rtrim(Yii::app()->params['imagePath'] . 'data/' . str_replace('../', '', html_entity_decode($_POST['to'], ENT_QUOTES, 'UTF-8')), '/');
if (!file_exists($to)) {
$json['error'] = Yii::t('filemanager', 'Warning: Move to directory does not exists!');
}
if (file_exists($to . '/' . basename($from))) {
$json['error'] = Yii::t('filemanager', 'Warning: A file or directory with the same name already exists!');
}
} else {
$json['error'] = Yii::t('filemanager', 'Warning: Please select a directory!');
}
// TODO: check permissions
/*if (!$this->user->hasPermission('modify', 'common/filemanager')) {
$json['error'] = Yii::t('filemanager', 'Warning: Permission Denied!');
}*/
if (!isset($json['error'])) {
rename($from, $to . '/' . basename($from));
$json['success'] = Yii::t('filemanager', 'Success: Your file or directory has been moved!');
}
echo CJSON::encode($json);
}