mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-12 20:02:49 +02:00
Refactoring and renamed vars
This commit is contained in:
+1
-4
@@ -222,10 +222,7 @@ if (!isset(CoreUtilities::$rRequest['update'])) {
|
||||
as XC_VM will have access to it.<br /><br />The script will then loop through all of
|
||||
your previously existing data and alter it to work with XC_VM. No logs will be
|
||||
migrated and some clean up may need to be done post-migration but this tool should
|
||||
help significantly in carrying over your data to your new panel.<br /><br />For
|
||||
instructions visit the <a
|
||||
href="https://xc_vm.com/billing/index.php?rp=/knowledgebase/3">XC_VM FAQ
|
||||
here</a>.<br /><br />Once you're done, refresh the page.
|
||||
help significantly in carrying over your data to your new panel.<br /><br /><br />Once you're done, refresh the page.
|
||||
</div>
|
||||
<?php if (!$rMigrateConnection) { ?>
|
||||
<div class="alert alert-danger mb-4" role="alert">
|
||||
|
||||
+2
-2
@@ -473,9 +473,9 @@ if (posix_getpwuid(posix_geteuid())['name'] == 'xc_vm') {
|
||||
unset($rRow['id']);
|
||||
$rChannels[$rRow['channel_id']] = $rRow;
|
||||
}
|
||||
$rUpdate = $rEPG->parseEPG($rData['epg_id'], $rChannels, (intval($rData['offset']) ?: 0));
|
||||
$UpdateEPG = $rEPG->parseEPG($rData['epg_id'], $rChannels, (intval($rData['offset']) ?: 0));
|
||||
|
||||
foreach ($rUpdate as $rChannelID => $rResults) {
|
||||
foreach ($UpdateEPG as $rChannelID => $rResults) {
|
||||
$rStreamIDs = ($rStreamMap[$rChannelID] ?: array());
|
||||
|
||||
foreach ($rStreamIDs as $rStreamID) {
|
||||
|
||||
+6
-10
@@ -21,22 +21,18 @@ function loadCron() {
|
||||
}
|
||||
$db->query('UPDATE `settings` SET `cc_time` = ?;', time());
|
||||
$db->query('SELECT `id`, `stream_display_name`, `series_no`, `stream_source` FROM `streams` WHERE `type` = 3 AND `series_no` <> 0;');
|
||||
if (0 >= $db->num_rows()) {
|
||||
} else {
|
||||
if ($db->num_rows() > 0) {
|
||||
foreach ($db->get_rows() as $rRow) {
|
||||
$rPlaylist = generateSeriesPlaylist(intval($rRow['series_no']));
|
||||
if (!$rPlaylist['success']) {
|
||||
} else {
|
||||
if ($rPlaylist['success']) {
|
||||
$rSourceArray = json_decode($rRow['stream_source'], true);
|
||||
$rUpdate = false;
|
||||
$UpdateSeries = false;
|
||||
foreach ($rPlaylist['sources'] as $rSource) {
|
||||
if (in_array($rSource, $rSourceArray)) {
|
||||
} else {
|
||||
$rUpdate = true;
|
||||
if (!in_array($rSource, $rSourceArray)) {
|
||||
$UpdateSeries = true;
|
||||
}
|
||||
}
|
||||
if (!$rUpdate) {
|
||||
} else {
|
||||
if ($UpdateSeries) {
|
||||
$db->query('UPDATE `streams` SET `stream_source` = ? WHERE `id` = ?;', json_encode($rPlaylist['sources'], JSON_UNESCAPED_UNICODE), $rRow['id']);
|
||||
echo 'Updated: ' . $rRow['stream_display_name'] . "\n";
|
||||
}
|
||||
|
||||
+14
-19
@@ -822,20 +822,19 @@ function preparecolumn($rValue) {
|
||||
}
|
||||
|
||||
function prepareArray($rArray) {
|
||||
$rUpdate = $rColumns = $rPlaceholder = $rData = array();
|
||||
$UpdateData = $rColumns = $rPlaceholder = $rData = array();
|
||||
|
||||
|
||||
foreach (array_keys($rArray) as $rKey) {
|
||||
$rColumns[] = '`' . preparecolumn($rKey) . '`';
|
||||
$rUpdate[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
$UpdateData[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
}
|
||||
|
||||
foreach (array_values($rArray) as $rValue) {
|
||||
if (is_array($rValue)) {
|
||||
$rValue = json_encode($rValue, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
if (!(is_null($rValue) || strtolower($rValue) == 'null')) {
|
||||
} else {
|
||||
if (is_null($rValue) || strtolower($rValue) == 'null') {
|
||||
$rValue = null;
|
||||
}
|
||||
}
|
||||
@@ -844,7 +843,7 @@ function prepareArray($rArray) {
|
||||
$rData[] = $rValue;
|
||||
}
|
||||
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $rUpdate));
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $UpdateData));
|
||||
}
|
||||
|
||||
function setArgs($rArgs, $rGet = true) {
|
||||
@@ -4296,36 +4295,32 @@ function scanBouquet($rID) {
|
||||
}
|
||||
}
|
||||
|
||||
$rUpdate = array(array(), array(), array(), array());
|
||||
$UpdateData = array(array(), array(), array(), array());
|
||||
|
||||
foreach (json_decode($rBouquet['bouquet_channels'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[0][] = intval($rID);
|
||||
if (0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0])) {
|
||||
$UpdateData[0][] = intval($rID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (json_decode($rBouquet['bouquet_movies'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[1][] = intval($rID);
|
||||
if (0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0])) {
|
||||
$UpdateData[1][] = intval($rID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (json_decode($rBouquet['bouquet_radios'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[2][] = intval($rID);
|
||||
if (0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0])) {
|
||||
$UpdateData[2][] = intval($rID);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (json_decode($rBouquet['bouquet_series'], true) as $rID) {
|
||||
if (!in_array(intval($rID), $rStreamIDs[1])) {
|
||||
} else {
|
||||
$rUpdate[3][] = intval($rID);
|
||||
if (in_array(intval($rID), $rStreamIDs[1])) {
|
||||
$UpdateData[3][] = intval($rID);
|
||||
}
|
||||
}
|
||||
$db->query("UPDATE `bouquets` SET `bouquet_channels` = '[" . implode(',', array_map('intval', $rUpdate[0])) . "]', `bouquet_movies` = '[" . implode(',', array_map('intval', $rUpdate[1])) . "]', `bouquet_radios` = '[" . implode(',', array_map('intval', $rUpdate[2])) . "]', `bouquet_series` = '[" . implode(',', array_map('intval', $rUpdate[3])) . "]' WHERE `id` = ?;", $rBouquet['id']);
|
||||
$db->query("UPDATE `bouquets` SET `bouquet_channels` = '[" . implode(',', array_map('intval', $UpdateData[0])) . "]', `bouquet_movies` = '[" . implode(',', array_map('intval', $UpdateData[1])) . "]', `bouquet_radios` = '[" . implode(',', array_map('intval', $UpdateData[2])) . "]', `bouquet_series` = '[" . implode(',', array_map('intval', $UpdateData[3])) . "]' WHERE `id` = ?;", $rBouquet['id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,11 @@ function loadcli() {
|
||||
$rPHPUpdated = $rUpdated = false;
|
||||
exec('sudo lsb_release -r -s', $osReleaseVersion);
|
||||
$rAPI = json_decode(file_get_contents(($rBaseURL . '?version=' . XC_VM_VERSION . '&ubv=' . floatval($osReleaseVersion[0]) ?: '')), true);
|
||||
if (!is_array($rAPI)) {
|
||||
} else {
|
||||
if (is_array($rAPI)) {
|
||||
foreach ($rAPI['files'] as $rFile) {
|
||||
if (file_exists($rFile['path']) && md5_file($rFile['path']) == $rFile['md5']) {
|
||||
} else {
|
||||
if (!(file_exists($rFile['path']) && md5_file($rFile['path']) == $rFile['md5'])) {
|
||||
$rFolderPath = pathinfo($rFile['path'])['dirname'] . '/';
|
||||
if (file_exists($rFolderPath)) {
|
||||
} else {
|
||||
if (!file_exists($rFolderPath)) {
|
||||
shell_exec('sudo mkdir -p "' . $rFolderPath . '"');
|
||||
}
|
||||
$ch = curl_init();
|
||||
@@ -51,28 +48,24 @@ function loadcli() {
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
|
||||
$rData = curl_exec($ch);
|
||||
$rMD5 = md5($rData);
|
||||
if ($rFile['md5'] != $rMD5) {
|
||||
} else {
|
||||
if ($rFile['md5'] == $rMD5) {
|
||||
echo 'Updated binary: ' . $rFile['path'] . "\n";
|
||||
shell_exec('sudo rm -rf "' . $rFile['path'] . '"');
|
||||
file_put_contents($rFile['path'], $rData);
|
||||
shell_exec('sudo chown xc_vm:xc_vm "' . $rFile['path'] . '"');
|
||||
shell_exec('sudo chmod ' . $rPermissions . ' "' . $rFile['path'] . '"');
|
||||
$rUpdated = true;
|
||||
if (substr(basename($rFile['path']), 0, 3) != 'php') {
|
||||
} else {
|
||||
if (substr(basename($rFile['path']), 0, 3) == 'php') {
|
||||
$rPHPUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$rUpdated) {
|
||||
} else {
|
||||
if ($rUpdated) {
|
||||
shell_exec('sudo chown -R xc_vm:xc_vm "' . $rBaseDir . '"');
|
||||
}
|
||||
if (!$rPHPUpdated) {
|
||||
} else {
|
||||
if ($rPHPUpdated) {
|
||||
$rVersion = (array(72 => '7.2', 74 => '7.4')[CoreUtilities::$rServers[SERVER_ID]['php_version']] ?: '7.4');
|
||||
shell_exec('sudo ln -sfn ' . PHP_BIN . '_' . $rVersion . ' ' . PHP_BIN);
|
||||
shell_exec('sudo ln -sfn ' . BIN_PATH . 'php/sbin/php-fpm_' . $rVersion . ' ' . BIN_PATH . 'php/sbin/php-fpm');
|
||||
@@ -82,8 +75,7 @@ function loadcli() {
|
||||
}
|
||||
function shutdown() {
|
||||
global $db;
|
||||
if (!is_object($db)) {
|
||||
} else {
|
||||
if (is_object($db)) {
|
||||
$db->close_mysql();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ function preparecolumn($rValue) {
|
||||
return strtolower(preg_replace('/[^a-z0-9_]+/i', '', $rValue));
|
||||
}
|
||||
function prepareArray($rArray) {
|
||||
$rUpdate = $rColumns = $rPlaceholder = $rData = array();
|
||||
$UpdateData = $rColumns = $rPlaceholder = $rData = array();
|
||||
foreach (array_keys($rArray) as $rKey) {
|
||||
$rColumns[] = '`' . preparecolumn($rKey) . '`';
|
||||
$rUpdate[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
$UpdateData[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
}
|
||||
foreach (array_values($rArray) as $rValue) {
|
||||
if (!is_array($rValue)) {
|
||||
@@ -46,7 +46,7 @@ function prepareArray($rArray) {
|
||||
$rPlaceholder[] = '?';
|
||||
$rData[] = $rValue;
|
||||
}
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $rUpdate));
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $UpdateData));
|
||||
}
|
||||
function verifyPostTable($rTable, $rData = array(), $rOnlyExisting = false) {
|
||||
global $db;
|
||||
|
||||
@@ -222,10 +222,10 @@ function preparecolumn($rValue) {
|
||||
return strtolower(preg_replace('/[^a-z0-9_]+/i', '', $rValue));
|
||||
}
|
||||
function prepareArray($rArray) {
|
||||
$rUpdate = $rColumns = $rPlaceholder = $rData = array();
|
||||
$UpdateData = $rColumns = $rPlaceholder = $rData = array();
|
||||
foreach (array_keys($rArray) as $rKey) {
|
||||
$rColumns[] = '`' . preparecolumn($rKey) . '`';
|
||||
$rUpdate[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
$UpdateData[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
}
|
||||
foreach (array_values($rArray) as $rValue) {
|
||||
if (!is_array($rValue)) {
|
||||
@@ -235,7 +235,7 @@ function prepareArray($rArray) {
|
||||
$rPlaceholder[] = '?';
|
||||
$rData[] = $rValue;
|
||||
}
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $rUpdate));
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $UpdateData));
|
||||
}
|
||||
function verifyPostTable($rTable, $rData = array(), $rOnlyExisting = false) {
|
||||
global $db;
|
||||
|
||||
@@ -142,32 +142,32 @@ function loadcli() {
|
||||
if (0 >= $db->num_rows()) {
|
||||
} else {
|
||||
foreach ($db->get_rows() as $rBouquet) {
|
||||
$rUpdate = array(array(), array(), array(), array());
|
||||
$UpdateData = array(array(), array(), array(), array());
|
||||
foreach (json_decode($rBouquet['bouquet_channels'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[0][] = intval($rID);
|
||||
$UpdateData[0][] = intval($rID);
|
||||
}
|
||||
}
|
||||
foreach (json_decode($rBouquet['bouquet_movies'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[1][] = intval($rID);
|
||||
$UpdateData[1][] = intval($rID);
|
||||
}
|
||||
}
|
||||
foreach (json_decode($rBouquet['bouquet_radios'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[0]))) {
|
||||
} else {
|
||||
$rUpdate[2][] = intval($rID);
|
||||
$UpdateData[2][] = intval($rID);
|
||||
}
|
||||
}
|
||||
foreach (json_decode($rBouquet['bouquet_series'], true) as $rID) {
|
||||
if (!(0 < intval($rID) && in_array(intval($rID), $rStreamIDs[1]))) {
|
||||
} else {
|
||||
$rUpdate[3][] = intval($rID);
|
||||
$UpdateData[3][] = intval($rID);
|
||||
}
|
||||
}
|
||||
$db->query("UPDATE `bouquets` SET `bouquet_channels` = '[" . implode(',', array_map('intval', $rUpdate[0])) . "]', `bouquet_movies` = '[" . implode(',', array_map('intval', $rUpdate[1])) . "]', `bouquet_radios` = '[" . implode(',', array_map('intval', $rUpdate[2])) . "]', `bouquet_series` = '[" . implode(',', array_map('intval', $rUpdate[3])) . "]' WHERE `id` = ?;", $rBouquet['id']);
|
||||
$db->query("UPDATE `bouquets` SET `bouquet_channels` = '[" . implode(',', array_map('intval', $UpdateData[0])) . "]', `bouquet_movies` = '[" . implode(',', array_map('intval', $UpdateData[1])) . "]', `bouquet_radios` = '[" . implode(',', array_map('intval', $UpdateData[2])) . "]', `bouquet_series` = '[" . implode(',', array_map('intval', $UpdateData[3])) . "]' WHERE `id` = ?;", $rBouquet['id']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -791,10 +791,10 @@ function preparecolumn($rValue) {
|
||||
return strtolower(preg_replace('/[^a-z0-9_]+/i', '', $rValue));
|
||||
}
|
||||
function prepareArray($rArray) {
|
||||
$rUpdate = $rColumns = $rPlaceholder = $rData = array();
|
||||
$UpdateData = $rColumns = $rPlaceholder = $rData = array();
|
||||
foreach (array_keys($rArray) as $rKey) {
|
||||
$rColumns[] = '`' . preparecolumn($rKey) . '`';
|
||||
$rUpdate[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
$UpdateData[] = '`' . preparecolumn($rKey) . '` = ?';
|
||||
}
|
||||
foreach (array_values($rArray) as $rValue) {
|
||||
if (!is_array($rValue)) {
|
||||
@@ -804,7 +804,7 @@ function prepareArray($rArray) {
|
||||
$rPlaceholder[] = '?';
|
||||
$rData[] = $rValue;
|
||||
}
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $rUpdate));
|
||||
return array('placeholder' => implode(',', $rPlaceholder), 'columns' => implode(',', $rColumns), 'data' => $rData, 'update' => implode(',', $UpdateData));
|
||||
}
|
||||
function verifyPostTable($rTable, $rData = array(), $rOnlyExisting = false) {
|
||||
global $db;
|
||||
|
||||
Reference in New Issue
Block a user