function checkForSkipSong() { Tasker::add(5, 'checkForSkipSong'); $timeTotal = intval(getMpdValue("currentsong", "Time")); $timeCurrent = intval(getMpdCurrentTime()); if ($timeTotal - $timeCurrent < 10) { return; } $c = getMpdCurrentSong(); if ($c === null || $c === false) { return; } if (!isset($c["fileinfos"])) { return; } if (!isset($c["fileinfos"]->id)) { return; } $fileid = $c["fileinfos"]->id; $skip = false; $stmt = $GLOBALS["db"]->prepare("SELECT COUNT(*) as count FROM voteforskip WHERE fileid=:fileid AND DATE>DATE_SUB(NOW(),INTERVAL :seconds SECOND)"); if ($stmt->execute(array(":fileid" => $fileid, ":seconds" => $timeCurrent))) { $row = $stmt->fetchObject(); if ($row->count >= $GLOBALS["voteskipcount"]) { $skip = true; } } if ($skip) { $stmt = $GLOBALS["db"]->prepare("DELETE FROM voteforskip"); $stmt->execute(); daemonCallInit(); } }
require "includes/functions.php"; require "includes/tasker.php"; if (count(getopt("h::")) > 0) { echo "Parameters are:\n"; echo "-h Help\n"; echo "-f Scan filesystem\n"; echo "-p Scan playlists\n"; echo "(no parameters) Run daemon\n"; die; } if (count(getopt("f::")) > 0) { scanF(); die; } if (count(getopt("p::")) > 0) { scanP(); die; } echo "Parameters are:\n"; echo "-h Help\n"; echo "-f Scan filesystem\n"; echo "-p Scan playlists\n"; echo "(no parameters) Run daemon\n"; echo "\nrunning daemon\n"; // do Init daemonCallInit(); //periodically call Tasker::doWork() while (true) { Tasker::doWork(); sleep(1); }