public function offsetGet($offset, $subset) { $helper = new TaskerHelper(); switch ($offset) { case 'add': Site::$response = $helper->addItem(); break; case 'delete': if (isset($_POST['id'])) { Site::$response = $helper->hideItem($_POST['id']); } break; case 'undo': if (isset($_POST['id'])) { Site::$response = $helper->setItemUndone($_POST['id']); } break; case 'do': if (isset($_POST['id'])) { Site::$response = $helper->setItemDone($_POST['id']); } break; case 'tasks': $list = new Lists(); $list->offsetGet($subset); Site::$response = $this->writeLists(); break; case 'interpret': Site::$response = $this->interpret($_POST['raw']); break; case 'keys': $keys = new Keywords(); Site::$response = $keys->outputAsideGUI(); break; case 'dates': Site::$response = Time::getDates($_POST['dates']); break; case 'date': Site::$response = Time::getDateFromString(Site::$subsection); break; case 'view': $helper->getItem(Site::$subsection); break; case 'update': $helper->getItem(Site::$subsection); break; case 'import': self::getImportInterface(); break; case 'setup': self::setupDB(); break; default: #FB::error($offset, 'OFFSET NOT KNOWN'); self::$keywords = new Keywords(); $list = new Lists(); $list->offsetGet($offset); self::getInterface(); break; } return true; }
public static function removeAll() { self::$jobs = array(); }
public function __construct() { parent::__construct(); }
private function offsetGet() { if (!Auth::$authenticated) { Auth::handleAuth(); return; } switch (Site::$action) { case 'tasks': $tasker = new Tasker(); $tasker->offsetGet(Site::$section, Site::$subsection, Site::$do); //#FB::info($tasker, 'Tasker'); break; case 'api': $request = new RestRequest($_SERVER['REQUEST_URI'], Site::$section); $request->execute(); echo '<pre>' . print_r($request, true) . '</pre>'; break; } }
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); }
function addOneFileToMpdQueue($first = false) { checkForSavePlaylog(); $mpd = new MPD(); $voted = false; $tmp = doShowhighscore(true); if ($tmp !== false && $tmp !== null && count($tmp) >= 1) { $voted = true; } $hn = getNextsongInHighscore(true); if ($hn !== null) { $path = getFilepathForFileid($hn->id); $mpd->cmd('add "' . $path . '"'); $state = getMpdValue("status", "state"); if ($state != "play") { $mpd->cmd("play"); } if ($first) { $timeToAction = intval($hn->length) - 4; } else { $timeTotal = getMpdValue("currentsong", "Time"); $timeCurrent = getMpdCurrentTime(); $timeToAction = intval($hn->length) + (intval($timeTotal) - intval($timeCurrent)) - 4; } Tasker::add($timeToAction, 'addOneFileToMpdQueue'); if ($voted) { $stmt = $GLOBALS["db"]->prepare("UPDATE votes set played=1 WHERE fileid=:fileid"); if (!$stmt->execute(array(":fileid" => $hn->id))) { echo "error"; } $stmt = $GLOBALS["db"]->prepare("INSERT INTO playlog (fileid,date) VALUES (:fileid,NOW())"); if (!$stmt->execute(array(":fileid" => $hn->id))) { echo "error"; } } Tasker::add(5, 'checkForSkipSong'); } else { Tasker::add(5, 'daemonCallInit', array()); } }