Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/WWBN/AVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed May 16, 2022
2 parents 7e9fc5c + 786ada3 commit 3745120
Show file tree
Hide file tree
Showing 62 changed files with 8,675 additions and 6,202 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
# schedule:
# - cron: '35 2 * * 1'

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Validate/Lint

on: [push, pull_request]

permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.operating-system }}
Expand Down
749 changes: 375 additions & 374 deletions .htaccess

Large diffs are not rendered by default.

151 changes: 81 additions & 70 deletions admin/health_check.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<?php
function _isAPPInstalled($appName){

function _isAPPInstalled($appName) {
$appName = preg_replace('/[^a-z0-9_-]/i', '', $appName);
return trim(shell_exec("which {$appName}"));
}

//socket


// live


// max upload size max file size
// crontabs

$phpExtensions = [];
$phpExtensions[] = ['pdo_mysql'];
Expand All @@ -37,7 +35,6 @@ function _isAPPInstalled($appName){
$linuxApps[] = ['sshpass', 'https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin#the-process-with-rsync-support-hls'];
$linuxApps[] = ['apache2'];


$messages = ['Server' => [], 'PHP' => [], 'Apache' => []];
$version = phpversion();
$phpMinVersion = '7.3.0';
Expand Down Expand Up @@ -69,7 +66,7 @@ function _isAPPInstalled($appName){
$XSendFile = url_get_contents($XSendFileURL);
$XSendFileOriginal = file_get_contents($XSendFilePath);
//var_dump($XSendFileURL, $XSendFilePath, $XSendFile, $XSendFileOriginal);exit;
if($XSendFile===$XSendFileOriginal){
if ($XSendFile === $XSendFileOriginal) {
$messages['Apache'][] = "XSendFIle is enabled";
} else {
$messages['Apache'][] = ["XSendFIle is not enabled", 'https://github.com/WWBN/AVideo/wiki/Install-Apache-XSendFIle'];
Expand Down Expand Up @@ -101,6 +98,20 @@ function _isAPPInstalled($appName){
$messages['Apache'][] = [$value[0], 'We could not check your installed modules. We recommend you to use apache as a module NOT as a FPM'];
}
}
/*
if(_isSocketPresentOnCrontab()){
$messages['Server'][] = "Socket is installed on your crontab";
}else{
$messages['Server'][] = ["Socket is NOT installed on your crontab, open your terminal and type 'crontab -e', than add the code: ", "@reboot sleep 60;nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &"];
}
if(_isSchedulerPresentOnCrontab()){
$messages['Server'][] = "Scheduler plugin is installed on your crontab";
}else{
$messages['Server'][] = ["Scheduler plugin is NOT installed on your crontab, open your terminal and type 'crontab -e', than add the code: ", "* * * * * php {$global['systemRootPath']}plugin/Scheduler/run.php"];
}
*
*/

foreach ($linuxApps as $value) {
$response = _isAPPInstalled($value[0]);
Expand Down Expand Up @@ -171,7 +182,7 @@ function _isAPPInstalled($appName){
</style>
<div class="panel panel-default" id="healthCheck">
<div class="panel-heading">
<?php echo '<h1>' . PHP_OS . '</h1>'; ?>
<?php echo '<h1>' . PHP_OS . '</h1>'; ?>
</div>
<div class="panel-body">

Expand All @@ -184,48 +195,48 @@ function _isAPPInstalled($appName){
</div>
<div class="panel-body">
<div class="row">
<?php
$count = 0;
foreach ($messages['Server'] as $value) {
$count++;
if (is_array($value)) {
?>
<?php
$count = 0;
foreach ($messages['Server'] as $value) {
$count++;
if (is_array($value)) {
?>
<div class="col-lg-4 col-md-6 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
} ?>
}
}
?>
</div>
</div>
<?php
} else {
?>
<?php
} else {
?>
<div class="col-lg-4 col-md-6 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value; ?>
<i class="fas fa-check"></i> <?php echo $value; ?>
</div>
</div>
<?php
}
if ($count % 2 === 0) {
echo '<div class="clearfix visible-md"></div>';
}
if ($count % 3 === 0) {
echo '<div class="clearfix visible-lg"></div>';
}
}
?>
<?php
}
if ($count % 2 === 0) {
echo '<div class="clearfix visible-md"></div>';
}
if ($count % 3 === 0) {
echo '<div class="clearfix visible-lg"></div>';
}
}
?>
</div>
</div>
</div>
Expand All @@ -238,40 +249,40 @@ function _isAPPInstalled($appName){
</div>
<div class="panel-body">
<div class="row">
<?php
foreach ($messages['PHP'] as $value) {
if (is_array($value)) {
?>
<?php
foreach ($messages['PHP'] as $value) {
if (is_array($value)) {
?>
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
} ?>
}
}
?>
</div>
</div>
<?php
} else {
?>
<?php
} else {
?>
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value; ?>
<i class="fas fa-check"></i> <?php echo $value; ?>
</div>
</div>
<?php
}
}
?>
<?php
}
}
?>
</div>
</div>
</div>
Expand All @@ -284,40 +295,40 @@ function _isAPPInstalled($appName){
</div>
<div class="panel-body">
<div class="row">
<?php
foreach ($messages['Apache'] as $value) {
if (is_array($value)) {
?>
<?php
foreach ($messages['Apache'] as $value) {
if (is_array($value)) {
?>
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
} ?>
}
}
?>
</div>
</div>
<?php
} else {
?>
<?php
} else {
?>
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value; ?>
<i class="fas fa-check"></i> <?php echo $value; ?>
</div>
</div>
<?php
}
}
?>
<?php
}
}
?>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion feed/mrss.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<?php echo $enclosure; ?>
<pubDate><?php echo date('r', strtotime($row['created'])); ?></pubDate>
<guid isPermaLink="true"><?php echo Video::getLinkToVideo($row['id'], $row['clean_title'], false, "permalink"); ?></guid>
<media:category><?php echo $row["category"]; ?></media:category>
<media:category><?php echo htmlspecialchars($row["category"]); ?></media:category>
<media:content url="<?php echo $videoSource; ?>" fileSize="<?php echo $video["filesize"]; ?>" bitrate="128"
type="<?php echo mime_content_type_per_filename($videoSource); ?>" expression="full"
duration="<?php echo durationToSeconds($row['duration']); ?>">
Expand Down
7 changes: 7 additions & 0 deletions install/checkMaxOpenFiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$cmd = 'ps aux | grep YPTSocket';
exec($cmd);

$cmd = 'cat /proc/56529/limits | grep open';
exec($cmd);
15 changes: 15 additions & 0 deletions install/mysqlDump.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
//streamer config
require_once '../videos/configuration.php';

if (!isCommandLineInterface()) {
return die('Command Line only');
}

ob_end_flush();

$file = Video::getStoragePath().'mysqldump-'.date('YmdHis').'.sql';

passthru("mysqldump --opt -u '{$mysqlUser}' -p'{$mysqlPass}' -h {$mysqlHost} {$mysqlDatabase} > {$file}");

echo PHP_EOL."Dump file created at {$file}".PHP_EOL;
67 changes: 67 additions & 0 deletions install/mysqlRestore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

//streamer config
$global['createDatabase'] = 1;
$doNotIncludeConfig = 1;
require_once '../videos/configuration.php';

$global['mysqli'] = new mysqli($mysqlHost, $mysqlUser, $mysqlPass, '', @$mysqlPort);
$createSQL = "CREATE DATABASE IF NOT EXISTS {$mysqlDatabase};";
$global['mysqli']->query($createSQL);
$global['mysqli']->select_db($mysqlDatabase);

if (php_sapi_name() !== 'cli') {
return die('Command Line only');
}

ob_end_flush();

$globPattern = "{$global['systemRootPath']}videos/mysqldump-*.sql";
echo "Searching [{$globPattern}]" . PHP_EOL;
$glob = glob($globPattern);
foreach ($glob as $key => $file) {
echo "($key) {$file}" . PHP_EOL;
}

echo "Type the number of what file you want to restore or just press enter to get the latest" . PHP_EOL;
$option = trim(readline(""));

if ($option === '') {
$filename = end($glob);
} else {
$option = intval($option);
$filename = $glob[$option];
}

echo 'We will make a backup first ...' . PHP_EOL;

$file = "{$global['systemRootPath']}videos/" . 'mysqlBackupBeforeRestore-' . date('YmdHis') . '.sql';
passthru("mysqldump --opt -u '{$mysqlUser}' -p'{$mysqlPass}' -h {$mysqlHost} {$mysqlDatabase} > {$file}");
echo PHP_EOL . "Backup file created at {$file}" . PHP_EOL;

executeFile($filename);

function executeFile($filename) {
global $global;
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line) {
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
continue;

// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';') {
// Perform the query
if (!$global['mysqli']->query($templine)) {
echo ('sqlDAL::executeFile ' . $filename . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />');
}
// Reset temp variable to empty
$templine = '';
}
}
}
Loading

0 comments on commit 3745120

Please sign in to comment.