コミット
33bdd3f7a0
|
@ -174,6 +174,95 @@ class StoreController extends Controller {
|
|||
->get();
|
||||
}
|
||||
|
||||
public function getChangelog($id) { // /api/rpc/store/entry/getchangelog/id
|
||||
return DB::table('str_file')
|
||||
->select('version', 'changelog')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getNotice($id) { // /api/rpc/store/entry/getnotice/id
|
||||
return DB::table('str_file')
|
||||
->select('title', 'version', 'warningnote')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getDownloadCount($id) { // /api/rpc/store/entry/getdownloadcount/id
|
||||
return DB::table('str_file')
|
||||
->select('downloads')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
}
|
||||
|
||||
public function updateDownloadCount(Request $request) { // /api/rpc/store/entry/updatedownloadcount
|
||||
return DB::table('str_file')
|
||||
->where('id', $request->id)
|
||||
->update(['downloads', $request->downloads]);
|
||||
}
|
||||
|
||||
public function FileSizeConvert($bytes) {
|
||||
$bytes = floatval($bytes);
|
||||
$arBytes = array(
|
||||
0 => array(
|
||||
// "UNIT" => "TiB",
|
||||
// "VALUE" => pow(1024, 4)
|
||||
"UNIT" => "TQ",
|
||||
"VALUE" => pow(4096, 4)
|
||||
),
|
||||
1 => array(
|
||||
// "UNIT" => "GiB",
|
||||
// "VALUE" => pow(1024, 3)
|
||||
"UNIT" => "GQ",
|
||||
"VALUE" => pow(4096, 3)
|
||||
),
|
||||
2 => array(
|
||||
// "UNIT" => "MiB",
|
||||
// "VALUE" => pow(1024, 2)
|
||||
"UNIT" => "MQ",
|
||||
"VALUE" => pow(4096, 2)
|
||||
),
|
||||
3 => array(
|
||||
// "UNIT" => "KiB",
|
||||
// "VALUE" => 1024
|
||||
"UNIT" => "KQ",
|
||||
"VALUE" => 4096
|
||||
),
|
||||
4 => array(
|
||||
// "UNIT" => "B",
|
||||
"UNIT" => "Q",
|
||||
"VALUE" => 1
|
||||
)
|
||||
);
|
||||
|
||||
foreach($arBytes as $arItem) {
|
||||
if($bytes >= $arItem["VALUE"]) {
|
||||
$result = $bytes / $arItem["VALUE"];
|
||||
$result = strval(round($result, 2))." ".$arItem["UNIT"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getFilesOfEntry($id) { // /api/rpc/store/entry/getfilesofentry/id
|
||||
$files = array_map("htmlspecialchars", scandir("assets/store/$id"));
|
||||
$files = array_diff($files, array('..', '.', 'screens'));
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($files as $file) {
|
||||
array_push($result, [
|
||||
'id' => $id,
|
||||
'file' => $file,
|
||||
'size' => $this->FileSizeConvert(filesize('assets/store/'.$id.'/'.$file))
|
||||
]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getEntry($id, $mode) { // /api/rpc/store/entry/getentry/id/mode
|
||||
if ($mode == 'user') {
|
||||
return DB::table('str_owners')
|
||||
|
@ -235,9 +324,9 @@ class StoreController extends Controller {
|
|||
|
||||
}
|
||||
|
||||
public function getEntryName($id) { // /api/rpc/store/entry/getfilename/id
|
||||
public function getEntryName($id) { // /api/rpc/store/entry/getentryname/id
|
||||
return DB::table('str_file')
|
||||
->select('title')
|
||||
->select('title', 'version')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
}
|
||||
|
|
|
@ -31,6 +31,11 @@ Route::get('/api/rpc/store/entry/getentriespageall/{cat}/{from}/{to}', 'StoreCon
|
|||
Route::get('/api/rpc/store/entry/getentriespageapproved/{cat}/{from}/{to}', 'StoreController@getEntriesPageApproved');
|
||||
Route::get('/api/rpc/store/entry/getentriespagepopularview/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularView');
|
||||
Route::get('/api/rpc/store/entry/getentriespagepopulardownload/{cat}/{from}/{to}', 'StoreController@getEntriesPagePopularDownload');
|
||||
Route::get('/api/rpc/store/entry/getdownloadcount/{id}', 'StoreController@getDownloadCount');
|
||||
Route::post('/api/rpc/store/entry/updatedownloadcount', 'StoreController@updateDownloadCount');
|
||||
Route::get('/api/rpc/store/entry/getnotice/{id}', 'StoreController@getNotice');
|
||||
Route::get('/api/rpc/store/entry/getchangelog/{id}', 'StoreController@getChangelog');
|
||||
Route::get('/api/rpc/store/entry/getfilesofentry/{id}', 'StoreController@getFilesOfEntry');
|
||||
Route::get('/api/rpc/store/entry/getentry/{id}/{mode}', 'StoreController@getEntry');
|
||||
Route::get('/api/rpc/store/entry/getentryname/{id}', 'StoreController@getEntryName');
|
||||
Route::get('/api/rpc/store/entry/getentriesincategory/{cat_id}', 'StoreController@getEntriesInCategory');
|
||||
|
|
新しいイシューから参照