1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00
Oinktube/objects/pluginRunDatabaseScript.json.php
Daniel Neto 6d1e015b61 Update
2024-06-06 10:24:52 -03:00

44 lines
1.4 KiB
PHP

<?php
header('Content-Type: application/json');
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/plugin.php';
if (!User::isAdmin()) {
die('{"error":"' . __("Permission denied") . '"}');
}
if (empty($_POST['name'])) {
die('{"error":"' . __("Name can't be blank") . '"}');
}
ini_set('max_execution_time', 300);
$obj = new stdClass();
$obj->error = true;
$obj->msg = '';
$obj->name = $_POST['name'];
$templine = '';
$fileName = Plugin::getDatabaseFileName($_POST['name']);
$obj->fileName = $fileName;
if ($fileName) {
$lines = file($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)) {
$obj->msg = ('Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />');
die($templine.' '.json_encode($obj));
}
$templine = '';
}
}
$obj->error = false;
$obj->msg = "All queries executed";
} else {
$obj->msg = "File not found";
}
die(json_encode($obj));