public function testUpdate() { $fdao = new FilesDao(); $file = new File(); $file->fid = "testfid"; $file->name = "testname"; $fdao->save($file); $res = $fdao->getByFid("testfid"); $this->assertGreaterThan(0, $res); $dfile = $res; $dfile->name = "changedname"; $fdao->save($dfile); $mfile = $fdao->getById($dfile->id); $this->assertEquals("changedname", $mfile->name); }
public function delete($print_response = true) { $file_names = $this->get_file_names_params(); $dtoken = $_GET['dtoken']; if (!isset($dtoken)) { return $this->header('HTTP/1.1 404 Not Found'); } $fdao = new FilesDao(); if (empty($file_names)) { $file_names = array($this->get_file_name_param()); } $response = array(); foreach ($file_names as $file_name) { $dfile = $fdao->getByFid($file_name); if ($dfile->dtoken === $dtoken) { $file_path = $this->get_upload_path($file_name); $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); if ($success) { foreach ($this->options['image_versions'] as $version => $options) { if (!empty($version)) { $file = $this->get_upload_path($file_name, $version); if (is_file($file)) { unlink($file); } } } $fdao->deleteFile($file_name); } } else { $success = false; } $response[$file_name] = $success; } return $this->generate_response($response, $print_response); }
<?php require $_SERVER['DOCUMENT_ROOT'] . '/_/inc/init.php'; if (isset($_POST['key']) && isset($_POST['value']) && isset($_POST['gv']) && $_COOKIE['cv'] == $_POST['gv']) { $cdao = new ConfigDao(); $cdao->save(new ConfigObj($_POST['key'], $_POST['value'])); echo "Config saved"; } $fdao = new FilesDao(); $searchname = isset($_GET['s']) ? $_GET['s'] : ""; $searchfid = isset($_GET['fid']) ? $_GET['fid'] : ""; $start = is_numeric($_GET['start']) ? $_GET['start'] : 0; $end = is_numeric($_GET['end']) ? $_GET['end'] : 50; $filenb = $fdao->countFiles(); if ($searchfid != "") { $filesList = array($fdao->getByFid($searchfid)); } else { if ($searchname != "") { $filesList = $fdao->searchByName($searchname); } else { $filesList = $fdao->getLastFiles($start, $end); } } $filesTotalSize = $fdao->filesTotalSize() / 1000000; $fullurl = get_full_url() . '/'; $sdao = new SessionsDao(); $sessionscount = $sdao->countSessions(); $usercount = $sdao->countUsers(); $sessionstoday = $sdao->getSessionToday(); $action = isset($_GET['dis']) ? $_GET['dis'] : 1; ?>