mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
updatedb
This commit is contained in:
parent
66ddb1c6ab
commit
992d9b1cc8
1 changed files with 54 additions and 0 deletions
54
install/updatedb.php
Normal file
54
install/updatedb.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
//streamer config
|
||||
require_once '../videos/configuration.php';
|
||||
|
||||
if (!isCommandLineInterface()) {
|
||||
return die('Command Line only');
|
||||
}
|
||||
|
||||
set_time_limit(300);
|
||||
ini_set('max_execution_time', 300);
|
||||
|
||||
$updateDir = $global['systemRootPath'] . "updatedb/";
|
||||
$currentVersion = $config->getVersion();
|
||||
|
||||
echo "Searching on ({$updateDir}) for updates greater then {$currentVersion}" . PHP_EOL;
|
||||
global $global;
|
||||
$files1 = scandir($updateDir);
|
||||
$updateFiles = array();
|
||||
foreach ($files1 as $value) {
|
||||
preg_match("/updateDb.v([0-9.]*).sql/", $value, $match);
|
||||
if (!empty($match)) {
|
||||
if (currentVersionLowerThen($match[1], $currentVersion)) {
|
||||
$updateFiles[] = array('filename' => $match[0], 'version' => $match[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($updateFiles)) {
|
||||
echo "No new update files found on ({$updateDir})" . PHP_EOL;
|
||||
}
|
||||
|
||||
foreach ($updateFiles as $value) {
|
||||
echo "Updating version " . $value['version'] . PHP_EOL;
|
||||
|
||||
$lines = file("{$updateDir}{$value['filename']}");
|
||||
foreach ($lines as $line) {
|
||||
if (substr($line, 0, 2) == '--' || $line == '')
|
||||
continue;
|
||||
$templine .= $line;
|
||||
if (substr(trim($line), -1, 1) == ';') {
|
||||
if (!$global['mysqli']->query($templine)) {
|
||||
echo ('Error performing query ' . $templine . ': ' . $global['mysqli']->error . PHP_EOL);
|
||||
echo json_encode($obj);
|
||||
//exit;
|
||||
}
|
||||
$templine = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||
die();
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue