torrentpier/library/includes/cron/jobs/demo_mode.php
Roman Kelesidis 9ada2c63b9
Minor improvements (#1480)
* Some enhancements for updates checker

* Updated

* Update updater.php

* Update init_bb.php

* Update CHANGELOG.md

* Update globals.css

* Updated

* Update functions.php

* Update init_bb.php

* Updated

* Updated

* Updated

* Update update_geolite_db.php

* Update update_geolite_db.php

* Update update_geolite_db.php

* Updated

* Update .gitignore

* Update init_bb.php

* Updated

* Update CHANGELOG.md
2024-05-11 00:44:35 +07:00

45 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* TorrentPier Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
set_time_limit(600);
global $cron_runtime_log;
$dump_path = BB_ROOT . 'install/sql/mysql.sql';
if (!IN_DEMO_MODE || !is_file($dump_path) || !is_readable($dump_path)) {
return;
}
// Clean cache & datastore
$datastore->clean();
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
CACHE($cache_name)->rm();
}
// Drop tables & Insert sql dump
$temp_line = '';
foreach (file($dump_path) as $line) {
if (str_starts_with($line, '--') || $line == '') {
continue;
}
$temp_line .= $line;
if (str_ends_with(trim($line), ';')) {
if (!DB()->query($temp_line)) {
$cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Error performing query: " . $temp_line . " | " . DB()->sql_error()['message'];
}
$temp_line = '';
}
}