12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- exit;
- require_once __DIR__.'/../../main/inc/global.inc.php';
- opcache_reset();
- $maxSeconds = 5 * 60 * 60;
- $valueToUpdate = 1 * 60 * 60;
- $limit = 10;
- $sendMessage = true;
- $userId = 1;
- $update = false;
- $sql = "SELECT iid, total_time FROM c_lp_item_view
- WHERE total_time > $maxSeconds
- order by total_time desc
- LIMIT $limit
- ";
- $result = Database::query($sql);
- $log = '';
- while ($row = Database::fetch_array($result, 'ASSOC')) {
- $id = $row['iid'];
- $oldTotalTime = $row['total_time'];
- $sql = "UPDATE c_lp_item_view SET total_time = '$valueToUpdate' WHERE iid = $id;";
-
- if ($update) {
- Database::query($sql);
- }
- $oldTotalTime = round($oldTotalTime / 3600, 2);
- $report = "Previous total_time : ".$oldTotalTime." hours";
- $report .= PHP_EOL;
- $report .= "New total_time: $valueToUpdate";
- $report .= PHP_EOL;
- $report .= $sql;
- $report .= PHP_EOL;
- $report .= PHP_EOL;
- $log .= $report;
- echo $report;
- }
- if ($sendMessage && !empty($log)) {
- $log = nl2br($log);
- MessageManager::send_message_simple(
- $userId,
- 'LP time abusive fixes',
- $log,
- 1
- );
- }
|