1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00
This commit is contained in:
Daniel Neto 2023-10-20 12:49:45 -03:00
parent 8c27070d24
commit 3b74f82d4b
5 changed files with 46 additions and 18 deletions

View file

@ -11964,3 +11964,15 @@ function secondsToTime($seconds, $precision = '%06.3f') {
$decimal = fmod($seconds, 1); //0.25
return sprintf("%02d:%02d:{$precision}", $hours, $mins, $secs + $decimal);
}
function timeToSecondsInt($hms) {
$a = explode(":", $hms); // split it at the colons
// minutes are worth 60 seconds. Hours are worth 60 minutes.
for ($i = 0; $i < 3; $i++) {
$a[$i] = @intval($a[$i]);
}
$seconds = round((+$a[0]) * 60 * 60 + (+$a[1]) * 60 + (+$a[2]));
return ($seconds);
}

View file

@ -1033,10 +1033,23 @@ if (typeof gtag !== \"function\") {
];
foreach ($arrayTables as $value) {
$sql = "DELETE FROM {$value} WHERE users_id = ?";
// Check if table exists
$checkTableSQL = "SHOW TABLES LIKE '{$value}'";
try {
sqlDAL::writeSql($sql, "i", [$this->id]);
$result = sqlDAL::readSql($checkTableSQL);
$tableExists = (sqlDAL::num_rows($result) > 0);
sqlDAL::close($result); // Make sure to close the result after checking
} catch (Exception $exc) {
$tableExists = false;
}
if ($tableExists) {
$sql = "DELETE FROM {$value} WHERE users_id = ?";
try {
sqlDAL::writeSql($sql, "i", [$this->id]);
} catch (Exception $exc) {
// Handle exception if needed
}
}
}

View file

@ -68,7 +68,7 @@ class Bookmark extends PluginAbstract
}
$result[] = [
'seconds' => timeToSeconds($match[1]),
'seconds' => timeToSecondsInt($match[1]),
'time' => $match[1],
'text' => $match[2]
];

View file

@ -77,20 +77,6 @@ $_page->setExtraScripts(
var allBookmarksArray = [];
var indexEditing = -1;
function secondsToTime(sec) {
var rest = parseInt((sec % 1) * 100);
var date = new Date(null);
date.setSeconds(sec); // specify value for SECONDS here
var timeString = date.toISOString().substr(11, 8);
return (timeString + '.' + rest);
}
function timeToSeconds(hms) {
var a = hms.split(':'); // split it at the colons
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
return (seconds);
}
function getTimeIndex(time) {
for (var i = 0; i < bookmarksArray.length; i++) {
if (bookmarksArray[i].start <= time && bookmarksArray[i].end >= time) {

View file

@ -4036,3 +4036,20 @@ function randomColor() {
var b = Math.floor(Math.random() * 255);
return r + "," + g + "," + b;
}
function secondsToTime(sec) {
var rest = parseInt((sec % 1) * 100);
var date = new Date(null);
date.setSeconds(sec); // specify value for SECONDS here
var timeString = date.toISOString().substr(11, 8);
return (timeString + '.' + rest);
}
function timeToSeconds(hms) {
var a = hms.split(':'); // split it at the colons
// minutes are worth 60 seconds. Hours are worth 60 minutes.
var seconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
return (seconds);
}