2017-11-21 23:15:32 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
2017-12-18 14:02:24 +00:00
|
|
|
require_once __DIR__ . '/../lib/autoloader.php';
|
2017-11-21 23:15:32 +00:00
|
|
|
|
|
|
|
use \TclUpdates\GotuObject;
|
|
|
|
use \TclUpdates\XmlParser;
|
2017-12-10 23:29:55 +00:00
|
|
|
use \TclUpdates\SQLiteWriter;
|
2017-11-21 23:15:32 +00:00
|
|
|
|
2017-12-18 14:02:24 +00:00
|
|
|
$bkup_dir = __DIR__ . '/../data/';
|
2017-11-21 23:15:32 +00:00
|
|
|
|
|
|
|
$file_list = glob($bkup_dir . '*.xml');
|
2017-12-10 23:29:55 +00:00
|
|
|
$sqlw = new SQLiteWriter();
|
2017-11-21 23:15:32 +00:00
|
|
|
|
|
|
|
foreach ($file_list as $file) {
|
|
|
|
$filename = basename($file);
|
2017-12-15 00:05:07 +00:00
|
|
|
$file_stamp = substr($filename, 0, strpos($filename, '.'));
|
|
|
|
$file_date = gmdate('c', intval($file_stamp));
|
2017-11-21 23:15:32 +00:00
|
|
|
$data = file_get_contents($file);
|
|
|
|
$xp = new XmlParser();
|
|
|
|
$load_ok = $xp->loadXmlFromString($data);
|
|
|
|
if (!$load_ok) {
|
|
|
|
echo 'Could not load ' . $filename . '!' . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!$xp->validateGOTU()) {
|
|
|
|
echo 'XML not valid in ' . $filename . '!' . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
2017-12-16 13:17:18 +00:00
|
|
|
echo 'Processing ' . $filename . ' ...';
|
2017-11-21 23:15:32 +00:00
|
|
|
$g = GotuObject::fromXmlParser($xp);
|
2017-12-15 00:05:07 +00:00
|
|
|
//print_r($g);
|
2017-12-11 00:28:52 +00:00
|
|
|
if ($g->tv) {
|
2017-12-16 13:17:18 +00:00
|
|
|
$result = $sqlw->addGotu($g, $file_date);
|
|
|
|
if ($result !== false) {
|
|
|
|
echo ' added as #' . $result . PHP_EOL;
|
|
|
|
} else {
|
|
|
|
echo ' NOT ADDED.' . PHP_EOL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo ' not a check XML' . PHP_EOL;
|
2017-12-11 00:28:52 +00:00
|
|
|
}
|
2017-11-21 23:15:32 +00:00
|
|
|
}
|