<?php if (isset($_POST['type'])) { switch ($_POST['type']) { case "bible": if (isset($_POST['extra'])) { $extra = $_POST['extra']; getBible($extra); } break; case "progress": getProgress(); break; } } function getBible($extra) { $user = $extra['user']; echo "\n <div class=\"content-block\">\n <div class=\"content-block-inner\">\n <p>Username: {$user}</p>\n <p>Extra: {$extra}</p>\n </div>\n </div>\n "; } /** Usage Guide: * Data Syntax: * { 'type': "bible/progress", 'extra': { 'user': *, ... } } **/
/** progress process and process comments */ include_once "conn.php"; include_once "progressDB.php"; $action = $_REQUEST["action"]; $res = ""; switch ($action) { case "addProgress": $res = addProgress($_REQUEST); break; case "deleteProgress": $res = deleteProgress($_REQUEST["id"]); break; case "deleteProgressByProjectId": $res = deleteProgressByProjectId($_REQUEST["projectId"]); break; case "editProgress": $res = editProgress($_REQUEST); break; case "getProgress": $res = getProgress($_REQUEST["id"]); break; case "getProgressByProjectId": $res = getProgressByProjectId($_REQUEST["projectId"]); break; default: throw new Exception("unknown action:" . $action); } echo json_encode($res);
ON UserData.id=UserGroups.userid AND UserData.name=? GROUP BY Channels.id'; $stmt = $mysqli->prepare($sql); $stmt->bind_param('s', $username); $stmt->execute(); $stmt->store_result(); $channels = array(); $channel = get_result($stmt); while ($stmt->fetch()) { $channels[] = $channel; $channel = get_result($stmt); } $stmt->free_result(); $stmt->close(); echo json_encode(array('username' => $username, 'channels' => $channels, 'progress' => getProgress($username))); } else { echo "{\"error\":404}"; } break; case 'POST': $group = json_decode(file_get_contents("php://input"), true); break; } exit; //Check if the current user owns this profile //yes: display private profile //no: display public profile //Private Profile /* Query all Groups of this user SELECT UserGroups.groupid, Groups.name, UserGroups.admin FROM UserGroups JOIN Groups ON UserGroups.groupid=Groups.id WHERE UserGroups.userid=8
->addArgument('-vf', 'scale=1280:720') ->addArgument('-codec:a', 'aac') ->addArgument('-b:a', '128k') ->addArgument('-movflags', 'faststart') ->addArgument('~/Videos/php-out.mp4'); */ $command = $builder->build(true, '/tmp/ffmpeg_log'); var_dump($command); $descriptorspec = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $proc = proc_open($command, $descriptorspec, $pipes); $proc_details = proc_get_status($proc); $pid = $proc_details['pid']; echo $pid; while (proc_get_status($proc)) { $status = proc_get_status($proc); echo getProgress() . "\n"; if (!$status['running']) { return; } sleep(5); } function getProgress() { $content = @file_get_contents('/tmp/ffmpeg_log'); if ($content) { //get duration of source preg_match("/Duration: (.*?), start:/", $content, $matches); $rawDuration = $matches[1]; //rawDuration is in 00:00:00.00 format. This converts it to seconds. $ar = array_reverse(explode(":", $rawDuration)); $duration = floatval($ar[0]);