1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Debug send email

This commit is contained in:
DanieL 2022-07-06 10:34:03 -03:00
parent 48fca62e00
commit 0be817d339
8 changed files with 237 additions and 243 deletions

8
node_modules/.package-lock.json generated vendored
View file

@ -250,6 +250,14 @@
"resolved": "https://registry.npmjs.org/croppie/-/croppie-2.6.5.tgz",
"integrity": "sha512-IlChnVUGG5T3w2gRZIaQgBtlvyuYnlUWs2YZIXXR3H9KrlO1PtBT3j+ykxvy9eZIWhk+V5SpBmhCQz5UXKrEKQ=="
},
"node_modules/dexie": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/dexie/-/dexie-3.2.2.tgz",
"integrity": "sha512-q5dC3HPmir2DERlX+toCBbHQXW5MsyrFqPFcovkH9N2S/UW/H3H5AWAB6iEOExeraAu+j+zRDG+zg/D7YhH0qg==",
"engines": {
"node": ">=6.0"
}
},
"node_modules/dom-walk": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",

View file

@ -504,6 +504,8 @@ function setSiteSendMessage(&$mail) {
$mail->Debugoutput = function ($str, $level) {
_error_log("SMTP ERROR $level; message: $str", AVideoLog::$ERROR);
};
_error_log("Debug enable on the SMTP Email");
}
$mail->SMTPOptions = [
'ssl' => [
@ -523,6 +525,8 @@ function setSiteSendMessage(&$mail) {
_error_log("Sending SendMail Email");
$mail->isSendmail();
}
// do not let the system hang on email send
session_write_close();
}
function array_iunique($array) {

View file

@ -41,6 +41,7 @@ if ($valid) {
$mail->Subject = 'Message From Site ' . $config->getWebSiteTitle() . " ({$_POST['first_name']})";
$mail->msgHTML($msg);
_error_log("Send email now");
//send the message, check for errors
if (!$mail->send()) {
$obj->error = __("Message could not be sent") . " (" . $mail->ErrorInfo.")";

14
package-lock.json generated
View file

@ -10,6 +10,7 @@
"chart.js": "^3.8.0",
"codemirror": "^6.0.1",
"croppie": "^2.6.5",
"dexie": "^3.2.2",
"dom-walk": "^0.1.2",
"fontawesome-free": "^1.0.4",
"infinite-scroll": "^4.0.1",
@ -275,6 +276,14 @@
"resolved": "https://registry.npmjs.org/croppie/-/croppie-2.6.5.tgz",
"integrity": "sha512-IlChnVUGG5T3w2gRZIaQgBtlvyuYnlUWs2YZIXXR3H9KrlO1PtBT3j+ykxvy9eZIWhk+V5SpBmhCQz5UXKrEKQ=="
},
"node_modules/dexie": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/dexie/-/dexie-3.2.2.tgz",
"integrity": "sha512-q5dC3HPmir2DERlX+toCBbHQXW5MsyrFqPFcovkH9N2S/UW/H3H5AWAB6iEOExeraAu+j+zRDG+zg/D7YhH0qg==",
"engines": {
"node": ">=6.0"
}
},
"node_modules/dom-walk": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",
@ -805,6 +814,11 @@
"resolved": "https://registry.npmjs.org/croppie/-/croppie-2.6.5.tgz",
"integrity": "sha512-IlChnVUGG5T3w2gRZIaQgBtlvyuYnlUWs2YZIXXR3H9KrlO1PtBT3j+ykxvy9eZIWhk+V5SpBmhCQz5UXKrEKQ=="
},
"dexie": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/dexie/-/dexie-3.2.2.tgz",
"integrity": "sha512-q5dC3HPmir2DERlX+toCBbHQXW5MsyrFqPFcovkH9N2S/UW/H3H5AWAB6iEOExeraAu+j+zRDG+zg/D7YhH0qg=="
},
"dom-walk": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz",

View file

@ -5,6 +5,7 @@
"chart.js": "^3.8.0",
"codemirror": "^6.0.1",
"croppie": "^2.6.5",
"dexie": "^3.2.2",
"dom-walk": "^0.1.2",
"fontawesome-free": "^1.0.4",
"infinite-scroll": "^4.0.1",

View file

@ -30,7 +30,7 @@ class NextButton extends PluginAbstract {
public function getHeadCode() {
global $global, $autoPlayVideo;
if (!empty($autoPlayVideo['url'])) {
$css = '<link href="' .getCDN() . 'plugin/NextButton/style.css" rel="stylesheet" type="text/css"/>';
$css = '<link href="' .getURL('plugin/NextButton/style.css') . '" rel="stylesheet" type="text/css"/>';
$css .= '<style></style>';
return $css;
}
@ -44,7 +44,7 @@ class NextButton extends PluginAbstract {
$tmp = "mainVideo";
}
$js = '<script>var autoPlayVideoURL="'.$autoPlayVideo['url'].'"; var videoJsId = "'.$tmp.'";</script>';
$js .= '<script src="' .getCDN() . 'plugin/NextButton/script.js" type="text/javascript"></script>';
$js .= '<script src="' .getURL('plugin/NextButton/script.js') . '" type="text/javascript"></script>';
return $js;
}

View file

@ -3,21 +3,33 @@ let offlineDb;
let offlineDbIsReady;
offlineDbIsReady = false;
function downloadOfflineVideo(source) {
async function downloadOfflineVideo(source) {
var src = $(source).attr("src");
var type = $(source).attr("type");
var resolution = $(source).attr("res");
const objectStore = offlineDb.transaction('videos_os').objectStore('videos_os');
const offlineDbRequest = objectStore.get(getOfflineVideosIDKey(mediaId, resolution));
offlineDbRequest.addEventListener('success', () => {
// If the result exists in the database (is not undefined)
if (offlineDbRequest.result) {
console.log('taking videos from IofflineDb', offlineDbRequest.result.video_type, offlineDbRequest.result.resolution);
displayVideo(offlineDbRequest.result.fileBlob, offlineDbRequest.result.video_type, offlineDbRequest.result.resolution);
getOfflineVideo(mediaId, resolution).then(function (video) {
if (video) {
console.log('downloadOfflineVideo', video);
displayVideo(video.fileBlob, video.video_type, video.resolution);
resolve(video);
} else {
// Fetch the videos from the network
fetchVideoFromNetwork(src, type, resolution);
return fetchVideoFromNetwork(src, type, resolution);
}
}).catch(function (e) {
console.log("Error: " + (e.stack || e));
reject(e);
});
}
async function getOfflineVideo(videos_id, resolution) {
return offlineDbRequest.transaction('r', [offlineDbRequest.offline_videos], async () => {
const video = await db.offline_videos.get({
videos_id_resolution: getOfflineVideosIDKey(videos_id, resolution),
videos_id: videos_id,
resolution: resolution});
return video;
});
}
@ -25,15 +37,15 @@ function getOneOfflineVideoSource() {
var first = false;
var video480 = false;
$("#mainVideo source").each(function (index) {
if(empty(first)){
if (empty(first)) {
first = $(this);
}
var resolution = $(this).attr("res");
if(resolution == 480){
if (resolution == 480) {
video480 = $(this);
}
});
if(!empty(video480)){
if (!empty(video480)) {
console.log('getOneOfflineVideoSource 480p video found', video480);
return video480;
}
@ -41,30 +53,15 @@ function getOneOfflineVideoSource() {
return first;
}
function downloadOneOfflineVideo() {
async function downloadOneOfflineVideo() {
var source = getOneOfflineVideoSource();
if(!empty(source)){
downloadOfflineVideo(source);
return true;
if (!empty(source)) {
return await downloadOfflineVideo(source);
}
return false;
reject(false);
}
// Define the fetchVideoFromNetwork() function
async function fetchVideoFromNetwork(src, type, resolution) {
// Fetch the MP4 and WebM versions of the video using the fetch() function,
// then expose their response bodies as blobs
//const fileBlob = fetch(src).then(response => response.blob());
if (empty(mediaId)) {
avideoToastError('Video Not detected');
return false;
}
if (!offlineDbIsReady) {
avideoToastError('Database is not ready');
return false;
}
console.log('fetching videos from network', src, type, resolution);
// Step 1: start the fetch and obtain a reader
@ -94,13 +91,8 @@ async function fetchVideoFromNetwork(src, type, resolution) {
}
let fileBlob = new Blob(chunks);
// Only run the next code when both promises have fulfilled
Promise.all([src, fileBlob, type, contentLength, resolution]).then(values => {
console.log('fetching videos from network complete', src, type, resolution);
displayVideo(values[1], type, resolution);
storeOfflineVideo(src, values[1], type, contentLength, mediaId, resolution);
});
displayVideo(fileBlob, type, resolution);
return await storeOfflineVideo(src, fileBlob, type, contentLength, mediaId, resolution);
}
function getOfflineVideosIDKey(videos_id, resolution) {
@ -108,13 +100,9 @@ function getOfflineVideosIDKey(videos_id, resolution) {
return videos_id + '_' + resolution;
}
// Define the storeOfflineVideo() function
function storeOfflineVideo(src, fileBlob, type, contentLength, videos_id, resolution) {
async function storeOfflineVideo(src, fileBlob, type, contentLength, videos_id, resolution) {
videos_id = parseInt(videos_id);
// Open transaction, get object store; make it a readwrite so we can write to the IofflineDb
const objectStore = offlineDb.transaction(['videos_os'], 'readwrite').objectStore('videos_os');
// Create a record to add to the IofflineDb
const record = {
return await offlineDbRequest.offline_videos.put({
src: src,
fileBlob: fileBlob,
video_type: type,
@ -124,47 +112,13 @@ function storeOfflineVideo(src, fileBlob, type, contentLength, videos_id, resolu
videos_id_resolution: getOfflineVideosIDKey(videos_id, resolution),
created: new Date().getTime(),
modified: new Date().getTime()
}
console.log('storeOfflineVideo', videos_id, resolution);
// Add the record to the IofflineDb using add()
const offlineDbRequest = objectStore.add(record);
offlineDbRequest.addEventListener('success', () => console.log('Record addition attempt finished'));
offlineDbRequest.addEventListener('error', () => console.error(offlineDbRequest.error));
});
}
function deleteOfflineVideo(videos_id, resolution) {
videos_id = parseInt(videos_id);
// Open transaction, get object store; make it a readwrite so we can write to the IofflineDb
const objectStore = offlineDb.transaction(['videos_os'], 'readwrite').objectStore('videos_os');
// Add the record to the IofflineDb using add()
var myIndex = objectStore.index('videos_id');
var getAllRequest = myIndex.getAll(IDBKeyRange.only(videos_id));
var videos_id_resolution = getOfflineVideosIDKey(videos_id, resolution);
getAllRequest.onsuccess = function () {
for (var item in getAllRequest.result) {
var video = getAllRequest.result[item];
if(videos_id_resolution === video.videos_id_resolution){
const offlineDbRequest = objectStore.deleteObjectStore(video);
offlineDbRequest.addEventListener('success', () => console.log('Record deleted attempt finished'));
offlineDbRequest.addEventListener('error', () => console.error(offlineDbRequest.error));
}
}
console.log(getAllRequest.result);
}
}
function getAllOfflineVideo(videos_id) {
videos_id = parseInt(videos_id);
// Open transaction, get object store; make it a readwrite so we can write to the IofflineDb
const objectStore = offlineDb.transaction(['videos_os'], 'readwrite').objectStore('videos_os');
// Add the record to the IofflineDb using add()
var myIndex = objectStore.index('videos_id');
var getAllRequest = myIndex.getAll(IDBKeyRange.only(videos_id));
getAllRequest.onsuccess = function () {
console.log(getAllRequest.result);
}
return offlineDbRequest.offline_videos.delete(videos_id_resolution);
}
function displayVideo(fileBlob, type, resolution) {
@ -179,28 +133,7 @@ function displayVideo(fileBlob, type, resolution) {
$("#mainVideo").append(source);
}
// Open our database; it is created if it doesn't already exist
// (see upgradeneeded below)
const offlineDbRequest = window.indexedDB.open(offlineVideoDbName, 1);
// error handler signifies that the database didn't open successfully
offlineDbRequest.addEventListener('error', () => console.error('Database failed to open'));
// success handler signifies that the database opened successfully
offlineDbRequest.addEventListener('success', () => {
console.log('Database opened succesfully');
// Store the opened database object in the offlineDb variable. This is used a lot below
offlineDb = offlineDbRequest.result;
offlineDbIsReady = true;
});
// Setup the database tables if this has not already been done
offlineDbRequest.addEventListener('upgradeneeded', e => {
// Grab a reference to the opened database
const offlineDb = e.target.result;
// Create an objectStore to store our videos in (basically like a single table)
// including a auto-incrementing key
const objectStore = offlineDb.createObjectStore('videos_os', {keyPath: 'videos_id_resolution'});
objectStore.createIndex('videos_id', 'videos_id', {unique: false});
console.log('Database setup complete');
var offlineDbRequest = new Dexie(offlineVideoDbName);
offlineDbRequest.version(1).stores({
offline_videos: "videos_id_resolution,*videos_id"
});

View file

@ -34,10 +34,31 @@ $sources = getVideosURL_V2($video['filename']);
?>
</head>
<body>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container-fluid">
<h1><?php echo $video['title']; ?></h1>
<h2><?php echo humanFileSize($video['filesize']); ?></h2>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Home</a></li>
<li><a data-toggle="tab" href="#menu1">Menu 1</a></li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>HOME</h3>
<p>Some content.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Menu 1</h3>
<p>Some content in menu 1.</p>
</div>
</div>
<div class="row">
<?php
foreach ($sources as $key => $value) {
@ -46,16 +67,21 @@ $sources = getVideosURL_V2($video['filename']);
<div class="col-sm-3">
<div class="panel panel-default" id="videos_offline_<?php echo $videos_id; ?>_<?php echo $matches[1]; ?>">
<div class="panel-heading">
<button class="btn btn-danger" onclick="_deleteOfflineVideo(<?php echo json_encode($matches[1]); ?>);">
<?php echo __('Delete'); ?>
<button class="btn btn-danger" onclick='_deleteOfflineVideo(<?php echo json_encode($matches[1]); ?>);'>
<i class="fas fa-trash"></i> <?php echo __('Delete'); ?>
</button>
<button class="btn btn-success" onclick="_downloadOfflineVideo(<?php echo json_encode($value['url']); ?>, <?php echo json_encode($matches[1]); ?>);">
<?php echo __('Download'); ?>
<button class="btn btn-warning" onclick='_downloadOfflineVideo(<?php echo json_encode($value['url']); ?>, <?php echo json_encode($matches[1]); ?>);'>
<i class="fas fa-download"></i> <?php echo __('Download'); ?>
</button>
<button class="btn btn-success" onclick='_updateVideo(<?php echo json_encode($videos_id); ?>);'>
<i class="fas fa-sync"></i> <?php echo __('Renew'); ?>
</button>
</div>
<div class="panel-body">
Resolution: <?php echo $matches[1]; ?>p<br>
Size: <?php echo humanFileSize(filesize($value['path'])); ?>
</div>
<div class="panel-footer">
<?php echo humanFileSize(filesize($value['path'])); ?>
</div>
</div>
</div>
@ -69,38 +95,45 @@ $sources = getVideosURL_V2($video['filename']);
</div>
</div>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script>
const offlineVideoDbName = 'videos_offlineDb_<?php echo User::getId(); ?>';
var mediaId = <?php echo $videos_id; ?>;
</script>
<script src="<?php echo getURL('plugin/PlayerSkins/offlineVideo.js'); ?>"></script>
<script src="<?php echo getURL('node_modules/dexie/dist/dexie.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo getURL('plugin/PlayerSkins/offlineVideo.js'); ?>" type="text/javascript"></script>
<script>
$(document).ready(function () {
listAllOfflineVideo();
});
function listAllOfflineVideo() {
videos_id = <?php echo $videos_id; ?>;
// Open transaction, get object store; make it a readwrite so we can write to the IofflineDb
const objectStore = offlineDb.transaction(['videos_os'], 'readwrite').objectStore('videos_os');
// Add the record to the IofflineDb using add()
var myIndex = objectStore.index('videos_id');
var getAllRequest = myIndex.getAll(IDBKeyRange.only(videos_id));
getAllRequest.onsuccess = function () {
for (var item in getAllRequest.result) {
var video = getAllRequest.result[item];
var elemSelector = '#videos_offline_'+video.videos_id_resolution;
var collection = offlineDbRequest.offline_videos.where('videos_id').equals(videos_id);
$('.panel').removeClass('panel-success');
$('.panel').addClass('panel-default');
collection.each(function (video) {
var elemSelector = '#videos_offline_' + video.videos_id_resolution;
$(elemSelector).removeClass('panel-default');
$(elemSelector).addClass('panel-success');
});
}
console.log(getAllRequest.result);
}
}
function _downloadOfflineVideo(resolution){
deleteOfflineVideo(<?php echo $videos_id; ?>, resolution);
async function _downloadOfflineVideo(src, resolution) {
return await fetchVideoFromNetwork(src, 'video/mp4', resolution).then(function (video) {
console.log("_downloadOfflineVideo: ", video);
listAllOfflineVideo();
}).catch(function (e) {
console.log("_downloadOfflineVideo Error: ", e);
});
}
function _deleteOfflineVideo(resolution){
fetchVideoFromNetwork(src, 'video/mp4', resolution);
function _deleteOfflineVideo(resolution) {
return deleteOfflineVideo(<?php echo $videos_id; ?>, resolution).then((video) => {
console.log('_deleteOfflineVideo', video);
listAllOfflineVideo();
});
}
</script>
<?php