function trigger_process_submissions($projectid) { global $CDASH_USE_HTTPS, $CDASH_ASYNC_WORKERS; $currentURI = get_server_URI(true); if ($CDASH_ASYNC_WORKERS > 1) { // Parallel processing. // Obtain the processing lock before firing off parallel workers. $mypid = getmypid(); include 'include/submission_functions.php'; if (AcquireProcessingLock($projectid, false, $mypid)) { $url = $currentURI . '/ajax/processsubmissions.php'; $params = array('projectid' => $projectid, 'pid' => $mypid); for ($i = 0; $i < $CDASH_ASYNC_WORKERS; $i++) { curl_request_async($url, $params, 'GET'); } } } else { // Serial processing. $request = $currentURI . '/ajax/processsubmissions.php?projectid=' . $projectid; curl_request($request); } }
$parts = parse_url($url); $fp = fsockopen($parts['host'], isset($parts['port']) ? $parts['port'] : 80, $errno, $errstr, 30); // Data goes in the path for a GET request if ('GET' == $type) { $parts['path'] .= '?' . $post_string; } $out = "{$type} " . $parts['path'] . " HTTP/1.1\r\n"; $out .= "Host: " . $parts['host'] . "\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: " . strlen($post_string) . "\r\n"; $out .= "Connection: Close\r\n\r\n"; // Data goes in the request body for a POST request if ('POST' == $type && isset($post_string)) { $out .= $post_string; } fwrite($fp, $out); fclose($fp); } if (!($results === null)) { $sql = "SELECT * FROM `server_status` WHERE busy=false LIMIT 1"; $go = mysqli_query($conn, $sql); $list = mysqli_fetch_assoc($go); $theurl = "http://" . $list["address"] . "/scrape.php"; $theparams1 = "eid=" . $eid . "&pass="******"&name=" . $name . "&email=" . $email . "&gradyear=" . $gradyear . "&key=we76r3f4phsdv87twef"; curl_request_async($theurl, $theparams1); mysqli_free_result($results); $sql = "UPDATE `toscrape` SET done=true WHERE id=" . $id; mysqli_query($conn, $sql); } else { echo "Nothing to be done!"; }
/** * Calls the video_download subroutine. * @param $mediaId: ID of the item that is currently being processed * @param $video video (.mp4 or similar) URL oon some server. * @param $downloadTo Path that the video file will have on the machine this script is executed on. */ private function downloadInBackground($mediaId, $video, $downloadTo) { $videoDonwloadScript = $this->getPhpScriptsPathOnServer() . "runscript_subroutines/video_download.php"; curl_request_async($videoDonwloadScript, array("video_url" => $video, "download_to" => $downloadTo, "item_id" => $mediaId), "GET"); }