コード例 #1
0
    private function recreateRevTable()
    {
        $sql_create = <<<SQL
CREATE TABLE IF NOT EXISTS `{$this->schemaTableName}` (
  `id` bigint(20) NOT NULL,
  `tms` bigint(20) NOT NULL,
  `log` text NOT NULL,
  PRIMARY KEY (`id`)
)
SQL;
        ldb_query($sql_create);
    }
コード例 #2
0
ファイル: del_files.php プロジェクト: petrows/Upload-service
 function run()
 {
     # 1. Update all files data
     ldb_query('UPDATE `upload` SET `file_count`=(SELECT COUNT(*) FROM `file` WHERE `file`.`upid`=`upload`.`id`),`file_size`=(SELECT SUM(`file_size`) FROM `file` WHERE `file`.`upid`=`upload`.`id`)');
     # 2. Remove upload-files by TTL-time
     ldb_query('DELETE FROM `upload` WHERE `tms_delete`<' . time() . ' OR `file_count`=0');
     # 3. Remove files by no-parent
     ldb_query('DELETE FROM `file` WHERE `file`.`upid` NOT IN (SELECT `id` FROM `upload`)');
     # 4. Scan folders by no-parent uploads
     $this->clean_d();
     $this->clean_dir('/tmp/upload', 24 * 3600);
     $this->clean_dir('/tmp/sid', 24 * 3600);
     $this->clean_dir('/tmp/sid_api', 24 * 3600);
 }
コード例 #3
0
ファイル: stat.php プロジェクト: petrows/Upload-service
 function process_upload($data)
 {
     # Get last download time
     $path = ROOT_PATH . '/d/' . substr($data['code'], 0, 2) . '/' . substr($data['code'], 2);
     $flist = ldb_select('file', '*', '`upid`=' . $data['id']);
     $mtimes = array();
     foreach ($flist as $f) {
         $mt = @filemtime($path . '/' . $f['upn'] . '.dt');
         if (!$mt) {
             continue;
         }
         $mtimes[] = $mt;
         ldb_query('UPDATE `file` SET `tms_last`=' . $mt . ' WHERE `id`=' . $f['id'] . ' LIMIT 1');
     }
     ldb_query('UPDATE `upload` SET `tms_last`=' . min($mtimes) . ' WHERE `id`=' . $data['id'] . ' LIMIT 1');
 }
コード例 #4
0
ファイル: mod_api.php プロジェクト: petrows/Upload-service
 function delete()
 {
     $id = intval($_GET['id']);
     $data = ldb_select_one('upload', '*', $id);
     if (!$data || @$data['uid'] != $this->uid) {
         return $this->error('UPLOAD_NF', 'Upload is not found...');
     }
     ldb_query('DELETE FROM `upload` WHERE `id`=' . $id);
     echo '<delete status="ok"/>' . "\n";
 }
コード例 #5
0
ファイル: mod_upload.php プロジェクト: petrows/Upload-service
 function get_final()
 {
     # Okay, remove th SID
     @unlink(ROOT_PATH . '/tmp/sid/' . md5($this->sid));
     # Check upload data
     $u_data = ldb_select_one('upload', '*', $this->sid, 'code');
     if (!$u_data || $u_data['uid'] != user('id')) {
         return core_error_404();
     }
     include_once CORE_PATH . '/ttl.php';
     $ttl = @$_POST['files_ttl'];
     if (!isset($GLOBALS['ttl'][$ttl])) {
         $ttl = $GLOBALS['ttl_def'];
     }
     $tms_del = $u_data['tms_last'] + $ttl;
     $ttl_p = @$_POST['files_ttl_prol'] ? 'Y' : 'N';
     # Update TTL
     ldb_update_by_id('upload', $u_data['id'], array('tms_delete' => $tms_del, 'ttl' => $ttl, 'prolong' => $ttl_p, 'comment' => @$_POST['files_descr']));
     ldb_query('UPDATE `upload` SET `file_count`=(SELECT COUNT(*) FROM `file` WHERE `file`.`upid`=`upload`.`id`),`file_size`=(SELECT SUM(`file_size`) FROM `file` WHERE `file`.`upid`=`upload`.`id`) WHERE `id`=' . $u_data['id']);
     # Redirect to the file control...
     @header('Location: ' . URL . '/f/' . $this->sid . '/');
 }
コード例 #6
0
ファイル: mod_f.php プロジェクト: petrows/Upload-service
 function del($data)
 {
     ldb_query('DELETE FROM `upload` WHERE `id`=' . $data['id']);
     redirect_msg(URL . '/files/', lang('delete_ok'));
     exit;
 }
コード例 #7
0
 function recount()
 {
     # Delete old attached (temp) files
     ldb_query('DELETE FROM `site_attach_post` WHERE `id_2`<0 AND `tms_added`<' . (time() - 86400));
     # Recount link's count
     # ldb_query ('UPDATE `site_attach_files` SET `links_count`=(SELECT COUNT(*) FROM `site_attach_post` WHERE `site_attach_post`.`file_id`=`site_attach_files`.`id`) WHERE `id` IN ('.implode($ids).')');
     ldb_query('UPDATE `site_attach_files` SET `links_count`=(SELECT COUNT(*) FROM `site_attach_post` WHERE `site_attach_post`.`file_id`=`site_attach_files`.`id`) WHERE `att_type`=\'ATTACH\'');
     # Delete attaches without parents
     $data = ldb_select('site_attach_files', '*', '`links_count`<=0');
     if ($data) {
         for ($x = 0; $x < count($data); $x++) {
             @unlink(ROOT_PATH . '/uploads/att-' . $data[$x]['id'] . '.dat');
             @unlink(ROOT_PATH . '/uploads/att-' . $data[$x]['id'] . '.inf');
         }
         ldb_query('DELETE FROM `site_attach_files` WHERE `id` IN (' . implode(',', array_ids($data)) . ')');
     }
 }