このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
076server/app/Http/Controllers/FileController.php

223 行
6.8 KiB
PHP
Raw 通常表示 履歴

2018-01-24 01:36:47 +09:00
<?php
namespace App\Http\Controllers;
2018-01-24 04:44:45 +09:00
use Illuminate\Support\Facades\DB;
2018-01-24 01:36:47 +09:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class FileController extends Controller {
2018-02-02 18:27:57 +09:00
public function getAllFiles() { // /api/rpc/store/file/getallfiles
2018-01-24 23:58:21 +09:00
return DB::table('str_file')
->select('*')
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getAllApprovedFiles() { // /api/rpc/store/file/getallapprovedfiles
2018-01-24 23:58:21 +09:00
return DB::table('str_file')
->select('*')
->where('isApproved', 1)
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getAllBrokenFiles() { // /api/rpc/store/file/getallbrokenfiles
2018-01-24 23:58:21 +09:00
return DB::table('str_file')
->select('*')
->where('isBroken', 1)
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getAllPendingFiles() { // /api/rpc/store/file/getallpendingfiles
2018-01-24 23:58:21 +09:00
return DB::table('str_file')
->select('*')
->where('isApproved', 0)
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getNewFiles() { // /api/rpc/store/file/getnewfiles
2018-01-31 20:05:52 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'submit_date'
)
2018-01-31 20:05:52 +09:00
->where('isApproved', 1)
->orderBy('submit_date', 'desc')
->limit(5)
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getHotFiles() { // /api/rpc/store/file/gethotfiles
2018-01-31 20:05:52 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'downloads'
)
2018-01-31 20:05:52 +09:00
->where('isApproved', 1)
->orderBy('downloads', 'desc')
->limit(5)
->get();
2018-01-24 01:36:47 +09:00
}
2018-02-02 18:27:57 +09:00
public function getFilesPageAll($cat, $from, $to) { // /api/rpc/store/file/getfilespageall/cat/from/to
2018-01-31 17:33:47 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->offset($from)
->limit($to)
->get();
}
2018-02-02 18:27:57 +09:00
public function getFilesPageApproved($cat, $from, $to) { // /api/rpc/store/file/getfilespageapproved/cat/from/to
2018-01-31 17:33:47 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('isApproved', 1)
->offset($from)
->limit($to)
->get();
}
2018-02-02 18:27:57 +09:00
public function getFilesPagePopularView($cat, $from, $to) { // /api/rpc/store/file/getfilespagepopularview/cat/from/to
2018-01-31 17:33:47 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('views', '>', 1000)
->offset($from)
->limit($to)
->get();
}
2018-02-02 18:27:57 +09:00
public function getFilesPagePopularDownload($cat, $from, $to) { // /api/rpc/store/file/getfilespagepopulardownload/cat/from/to
2018-01-31 17:33:47 +09:00
return DB::table('str_file')
->select(
'id',
'title',
'version',
'description',
'submit_date',
'last_date',
'views',
'downloads'
)
->where('cat_id', $cat)
->where('downloads', '>', 1000)
->offset($from)
->limit($to)
->get();
}
2018-02-02 18:27:57 +09:00
public function getFile($id) { // /api/rpc/store/file/getfile/id
return DB::table('str_owners')
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
->where('file_id', $id)
->get(array(
"file_id",
"user_id",
"cat_id",
2018-02-02 18:27:57 +09:00
"title",
"version",
"description",
"changelog",
"views",
"downloads",
"submit_date",
"last_date",
"username",
"avatar",
"perm_id",
"gender",
"display_name",
"name_colour",
));
2018-01-24 01:36:47 +09:00
}
public function getFileName($id) { // /api/rpc/store/file/getfilename/id
2018-01-25 00:35:17 +09:00
return DB::table('str_file')
->select('title')
2018-01-25 00:35:17 +09:00
->where('id', $id)
->get();
}
public function getFilesInCategory($cat_id) { // /api/rpc/store/file/getfilesincategory/cat_id
2018-01-25 00:35:17 +09:00
return DB::table('str_file')
->select('*')
->where('cat_id', $cat_id)
2018-01-25 00:35:17 +09:00
->get();
}
public function countFilesInCategory($cat_id) { // /api/rpc/store/file/countfilesincategory/cat_id
2018-01-24 23:58:21 +09:00
return DB::table('str_file')
->where('cat_id', $cat_id)
->where('isApproved', 1)
->count();
}
public function countFilesInCategoryFull($cat_id) { // /api/rpc/store/file/countfilesincategoryfull/cat_id
return DB::table('str_file')
->where('cat_id', $cat_id)
->count();
2018-01-24 01:36:47 +09:00
}
2018-01-25 00:30:18 +09:00
2018-02-02 18:27:57 +09:00
public function insertEntry(Request $request) { // /api/rpc/store/file/insert
2018-02-01 04:47:29 +09:00
return;
}
2018-02-02 18:27:57 +09:00
public function updateEntry(Request $request) { // /api/rpc/store/file/update
2018-02-01 04:47:29 +09:00
return DB::table('str_file')
->where('id', $request->id)
->update([
'cat_id' => $request->cat_id,
'title' => $request->title,
'version' => $request->version,
'description' => $request->description,
'changelog' => $request->changelog,
'warningnote' => $request->warningnote,
'last_date' => $request->last_date
]);
}
2018-02-02 18:27:57 +09:00
public function restoreEntry(Request $request) { // /api/rpc/store/file/restore
2018-02-01 04:47:29 +09:00
return DB::table('str_file')
->where('id', $request->id)
->update(['isApproved', 1]);
}
2018-02-02 18:27:57 +09:00
public function removeEntry(Request $request) { // /api/rpc/store/file/remove
2018-02-01 04:47:29 +09:00
return DB::table('str_file')
->where('id', $request->id)
->update(['isApproved', 0]);
}
2018-01-24 01:36:47 +09:00
}