mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 19:37:23 +08:00
update exam progress seed bonus
This commit is contained in:
+2
-2
@@ -32,13 +32,13 @@ class Exam extends NexusModel
|
||||
const INDEX_UPLOADED = 1;
|
||||
const INDEX_SEED_TIME_AVERAGE = 2;
|
||||
const INDEX_DOWNLOADED = 3;
|
||||
const INDEX_BONUS = 4;
|
||||
const INDEX_SEED_BONUS = 4;
|
||||
|
||||
public static $indexes = [
|
||||
self::INDEX_UPLOADED => ['name' => 'Uploaded', 'unit' => 'GB'],
|
||||
self::INDEX_SEED_TIME_AVERAGE => ['name' => 'Seed time average', 'unit' => 'Hour'],
|
||||
self::INDEX_DOWNLOADED => ['name' => 'Downloaded', 'unit' => 'GB'],
|
||||
self::INDEX_BONUS => ['name' => 'Bonus', 'unit' => ''],
|
||||
self::INDEX_SEED_BONUS => ['name' => 'Seed bonus', 'unit' => ''],
|
||||
];
|
||||
|
||||
const FILTER_USER_CLASS = 'classes';
|
||||
|
||||
@@ -262,9 +262,12 @@ class ExamRepository extends BaseRepository
|
||||
$indexes = collect($exam->indexes)->keyBy('index');
|
||||
do_log("examUser: " . $examUser->toJson() . ", indexes: " . $indexes->toJson());
|
||||
|
||||
$torrentFields = ['id', 'visible', 'banned'];
|
||||
$torrent = Torrent::query()->findOrFail($torrentId, $torrentFields);
|
||||
$torrent->checkIsNormal($torrentFields);
|
||||
if (!isset($indexAndValue[Exam::INDEX_SEED_BONUS])) {
|
||||
//seed bonus is relative to user all torrents, not single one, torrentId = 0
|
||||
$torrentFields = ['id', 'visible', 'banned'];
|
||||
$torrent = Torrent::query()->findOrFail($torrentId, $torrentFields);
|
||||
$torrent->checkIsNormal($torrentFields);
|
||||
}
|
||||
|
||||
$insert = [];
|
||||
foreach ($indexAndValue as $indexId => $value) {
|
||||
|
||||
@@ -29,12 +29,12 @@ class ToolRepository extends BaseRepository
|
||||
'tar --exclude=vendor --exclude=.git -czf %s -C %s %s',
|
||||
$filename, dirname($webRoot), $dirName
|
||||
);
|
||||
$result = exec($command, $output, $resultCode);
|
||||
$result = exec($command, $output, $result_code);
|
||||
do_log(sprintf(
|
||||
"command: %s, output: %s, resultCode: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $resultCode, $result, $filename
|
||||
"command: %s, output: %s, result_code: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $result_code, $result, $filename
|
||||
));
|
||||
return compact('result', 'filename');
|
||||
return compact('result_code', 'filename');
|
||||
}
|
||||
|
||||
public function backupDatabase()
|
||||
@@ -46,22 +46,22 @@ class ToolRepository extends BaseRepository
|
||||
'mysqldump --user=%s --password=%s --port=%s --single-transaction --databases %s >> %s',
|
||||
$config['username'], $config['password'], $config['port'], $config['database'], $filename,
|
||||
);
|
||||
$result = exec($command, $output, $resultCode);
|
||||
$result = exec($command, $output, $result_code);
|
||||
do_log(sprintf(
|
||||
"command: %s, output: %s, resultCode: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $resultCode, $result, $filename
|
||||
"command: %s, output: %s, result_code: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $result_code, $result, $filename
|
||||
));
|
||||
return compact('result', 'filename');
|
||||
return compact('result_code', 'filename');
|
||||
}
|
||||
|
||||
public function backupAll()
|
||||
{
|
||||
$backupWeb = $this->backupWebRoot();
|
||||
if ($backupWeb['result'] != 0) {
|
||||
if ($backupWeb['result_code'] != 0) {
|
||||
throw new \RuntimeException("backup web fail: " . json_encode($backupWeb));
|
||||
}
|
||||
$backupDatabase = $this->backupDatabase();
|
||||
if ($backupDatabase['result'] != 0) {
|
||||
if ($backupDatabase['result_code'] != 0) {
|
||||
throw new \RuntimeException("backup database fail: " . json_encode($backupDatabase));
|
||||
}
|
||||
$filename = sprintf('%s/%s.%s.tar.gz', sys_get_temp_dir(), basename(base_path()), date('Ymd.His'));
|
||||
@@ -71,12 +71,12 @@ class ToolRepository extends BaseRepository
|
||||
dirname($backupWeb['filename']), basename($backupWeb['filename']),
|
||||
dirname($backupDatabase['filename']), basename($backupDatabase['filename'])
|
||||
);
|
||||
$result = exec($command, $output, $resultCode);
|
||||
$result = exec($command, $output, $result_code);
|
||||
do_log(sprintf(
|
||||
"command: %s, output: %s, resultCode: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $resultCode, $result, $filename
|
||||
"command: %s, output: %s, result_code: %s, result: %s, filename: %s",
|
||||
$command, json_encode($output), $result_code, $result, $filename
|
||||
));
|
||||
return compact('result', 'filename');
|
||||
return compact('result_code', 'filename');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -194,6 +194,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
$valuethree = $logofpointone / ($nzero_bonus - 1);
|
||||
$timenow = TIMENOW;
|
||||
$sectoweek = 7*24*60*60;
|
||||
$examRep = new \App\Repositories\ExamRepository();
|
||||
while ($arr = mysql_fetch_assoc($res)) //loop for different users
|
||||
{
|
||||
$A = 0;
|
||||
@@ -215,6 +216,8 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
if ($is_donor == 'yes' && $donortimes_bonus > 0)
|
||||
$all_bonus = $all_bonus * $donortimes_bonus;
|
||||
KPS("+",$all_bonus,$arr["userid"]);
|
||||
//update exam progress
|
||||
$examRep->addProgress($arr["userid"], 0, [\App\Models\Exam::INDEX_SEED_BONUS => $all_bonus]);
|
||||
}
|
||||
}
|
||||
$log = 'calculate seeding bonus';
|
||||
@@ -523,7 +526,7 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
while ($arr = mysql_fetch_assoc($res))
|
||||
{
|
||||
$dt = sqlesc(date("Y-m-d H:i:s"));
|
||||
$subject = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_vip_status_removed']);
|
||||
$subject = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_vip_status_removed']);
|
||||
$msg = sqlesc($lang_cleanup_target[get_user_lang($arr['id'])]['msg_vip_status_removed_body']);
|
||||
///---AUTOSYSTEM MODCOMMENT---//
|
||||
$modcomment = htmlspecialchars($arr["modcomment"]);
|
||||
@@ -650,10 +653,10 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
//die("s" . $arr['id']);
|
||||
$res2 = sql_query("SELECT SUM(seedtime) as st, SUM(leechtime) as lt FROM snatched where userid = " . $arr['id'] . " LIMIT 1") or sqlerr(__FILE__, __LINE__);
|
||||
$arr2 = mysql_fetch_assoc($res2) or sqlerr(__FILE__, __LINE__);
|
||||
|
||||
|
||||
//die("ss" . $arr2['st']);
|
||||
//die("sss" . "UPDATE users SET seedtime = " . $arr2['st'] . ", leechtime = " . $arr2['lt'] . " WHERE id = " . $arr['id']);
|
||||
|
||||
|
||||
sql_query("UPDATE users SET seedtime = " . intval($arr2['st']) . ", leechtime = " . intval($arr2['lt']) . " WHERE id = " . $arr['id']) or sqlerr(__FILE__, __LINE__);
|
||||
}
|
||||
$log = "update total seeding and leeching time of users";
|
||||
|
||||
+3
-1
@@ -39,6 +39,8 @@ if ($showaudiocodec) $audiocodecs = searchbox_item_list("audiocodecs");
|
||||
}
|
||||
stdhead($lang_getrss['head_rss_feeds']);
|
||||
|
||||
$query = [];
|
||||
$query[] = "passkey=" . $CURUSER['passkey'];
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$allowed_showrows=array('10','20','30','40','50');
|
||||
$link = get_protocol_prefix(). $BASEURL ."/torrentrss.php";
|
||||
@@ -322,7 +324,7 @@ print($categories);
|
||||
</select></td></tr>
|
||||
<tr><td class="rowhead"><?php echo $lang_getrss['row_keyword']?></td>
|
||||
<td class="rowfollow" align="left">
|
||||
<input type="text" name="search" style="width: 200px;" /> <?php echo $lang_getrss['text_with']?>
|
||||
<input type="text" name="search" style="width: 200px;" /> <?php echo $lang_getrss['text_with']?>
|
||||
<select name="search_mode" style="width: 60px;">
|
||||
<option value="0"><?php echo $lang_getrss['select_and'] ?></option>
|
||||
<option value="1" selected="selected"><?php echo $lang_getrss['select_or'] ?></option>
|
||||
|
||||
@@ -7,7 +7,7 @@ return [
|
||||
'index_text_' . \App\Models\Exam::INDEX_UPLOADED => 'Uploaded',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => 'Seed time average',
|
||||
'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => 'Downloaded',
|
||||
'index_text_' . \App\Models\Exam::INDEX_BONUS => 'Bonus',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => 'Seed bonus',
|
||||
'require_value' => 'Require',
|
||||
'current_value' => 'Current',
|
||||
'result' => 'Result',
|
||||
|
||||
@@ -7,7 +7,7 @@ return [
|
||||
'index_text_' . \App\Models\Exam::INDEX_UPLOADED => '上传量',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => '平均做种时间',
|
||||
'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => '下载量',
|
||||
'index_text_' . \App\Models\Exam::INDEX_BONUS => '魔力',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做种魔力',
|
||||
'require_value' => '要求',
|
||||
'current_value' => '当前',
|
||||
'result' => '结果',
|
||||
|
||||
@@ -7,7 +7,7 @@ return [
|
||||
'index_text_' . \App\Models\Exam::INDEX_UPLOADED => '上傳量',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_TIME_AVERAGE => '平均做種時間',
|
||||
'index_text_' . \App\Models\Exam::INDEX_DOWNLOADED => '下載量',
|
||||
'index_text_' . \App\Models\Exam::INDEX_BONUS => '魔力',
|
||||
'index_text_' . \App\Models\Exam::INDEX_SEED_BONUS => '做種魔力',
|
||||
'require_value' => '要求',
|
||||
'current_value' => '當前',
|
||||
'result' => '結果',
|
||||
|
||||
Reference in New Issue
Block a user