Archived
1
0

Changes of the last few months including restructuring system from using only ranks to permissions

This commit is contained in:
Marcel
2018-12-26 18:19:28 +01:00
parent 72f3434803
commit 1a1ac17ecf
38 changed files with 845 additions and 361 deletions

View File

@@ -17,18 +17,22 @@ class FileModel extends CI_Model
public function uploadFile($original_name, $tmpname, $size, $type, $userContent = true)
{
$target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$target_dir = 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype;
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0];
$name = $this->generateName();
$target_file = $target_dir . $name . '.' . $filetype;
if (!move_uploaded_file($tmpname, $target_file)) {
die('File couldn\'t be uploaded!');
}
$target_file = str_replace('\\', '/', $target_file);
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file, $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py'));
$this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return "/f/" . $name;
}
@@ -58,7 +62,9 @@ class FileModel extends CI_Model
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py'));
$this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $data['raw_name'];
}
@@ -113,25 +119,31 @@ class FileModel extends CI_Model
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py'));
$this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $data['raw_name'];
}
}
public function uploadFileByContent($content, $original_name, $fullType, $fileSize, $userContent = true) {
$target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$target_dir = 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype;
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0];
$name = $this->generateName();
$target_file = $target_dir . $name . '.' . $filetype;
$fp = fopen($target_file, 'w');
fwrite($fp, $content);
fclose($fp);
$target_file = str_replace('\\', '/', $target_file);
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file, $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py'));
$this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $name;
}