$this->language->load('common/filemanager');
$json = array();
if (isset($this->request->post['directory'])) {
if (isset($this->request->post['name']) || $this->request->post['name']) {
$directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');
if (!is_dir($directory)) {
$json['error'] = $this->language->get('error_directory');
}
if (file_exists($directory . '/' . str_replace('../', '', $this->request->post['name']))) {
$json['error'] = $this->language->get('error_exists');
}
} else {
$json['error'] = $this->language->get('error_name');
}
} else {
$json['error'] = $this->language->get('error_directory');
}
if (!$this->user->hasPermission('modify', 'common/filemanager')) {
$json['error'] = $this->language->get('error_permission');
}
if (!isset($json['error'])) {
mkdir($directory . '/' . str_replace('../', '', $this->request->post['name']), 0777);
$json['success'] = $this->language->get('text_create');
}
$this->response->setOutput(json_encode($json));