diff --git a/src/controllers/JobsController.php b/src/controllers/JobsController.php
index 428186663..3ab323b22 100644
--- a/src/controllers/JobsController.php
+++ b/src/controllers/JobsController.php
@@ -61,7 +61,9 @@ class JobsController extends Controller implements CrawlConstants,
/* do a quick test to see if this is a request seems like
from a legitimate machine
*/
- if (!$this->checkRequest()) {return; }
+ if (!$this->checkRequest()) {
+ return;
+ }
$activity = (isset($_REQUEST['a'])) ? $_REQUEST['a'] : false;
if (in_array($activity, $this->activities)) {
$this->call($activity);
diff --git a/src/executables/MediaUpdater.php b/src/executables/MediaUpdater.php
index 8eb9ec604..7c40c2474 100644
--- a/src/executables/MediaUpdater.php
+++ b/src/executables/MediaUpdater.php
@@ -135,7 +135,7 @@ class MediaUpdater implements CrawlConstants
public function loop()
{
L\crawlLog("In Media Update Loop");
- L\crawlLog("PHP Version is use:" . phpversion());
+ L\crawlLog("PHP Version is use: " . phpversion());
$info[self::STATUS] = self::CONTINUE_STATE;
$local_archives = [""];
while (CrawlDaemon::processHandler()) {
@@ -163,12 +163,9 @@ class MediaUpdater implements CrawlConstants
{
L\crawlLog("Checking Name Server for Media Updater properties...");
$current_machine = MediaJob::getCurrentMachine();
- $pre_properties = MediaJob::execNameServer(
+ $properties = MediaJob::execNameServer(
"getUpdateProperties");
- $properties = [];
- if (isset($pre_properties[0][self::PAGE])) {
- $properties =
- unserialize(L\webdecode($pre_properties[0][self::PAGE]));
+ if ($properties) {
if (isset($properties['MEDIA_MODE'])) {
$this->media_mode = $properties['MEDIA_MODE'];
L\crawlLog("...Setting media mode to: " .
diff --git a/src/index.php b/src/index.php
index c16d30ae3..fe19de5d3 100755
--- a/src/index.php
+++ b/src/index.php
@@ -46,6 +46,7 @@ use seekquarry\yioop\library as L;
*/
function bootstrap()
{
+ error_log("yo".$_REQUEST['a']);
/**
* For error function and yioop constants
*/
diff --git a/src/library/media_jobs/MediaJob.php b/src/library/media_jobs/MediaJob.php
index cc8e9736f..afde9db85 100644
--- a/src/library/media_jobs/MediaJob.php
+++ b/src/library/media_jobs/MediaJob.php
@@ -103,27 +103,16 @@ class MediaJob implements CrawlConstants, MediaConstants
if (!$is_name_server || ($is_name_server &&
$this->name_server_does_slave_tasks)) {
L\crawlLog("--Checking for $job_name tasks to do");
- $response = $this->execNameServer("getTasks");
- $tasks = false;
- if (isset($response[0][CrawlConstants::PAGE])) {
- $this->tasks = unserialize(L\webdecode(
- $response[0][CrawlConstants::PAGE]));
- }
+ $this->tasks = $this->execNameServer("getTasks");
if ($this->tasks) {
L\crawlLog("--Executing tasks for job $job_name");
$results = $this->doTasks($this->tasks);
if ($results) {
L\crawlLog("--Sending task results for job $job_name".
" to name server");
- $response =
- $this->execNameServer("putTasks",
- $results);
- if (isset($response[0][CrawlConstants::PAGE])) {
- $response = unserialize(L\webdecode(
- $response[0][CrawlConstants::PAGE]));
- if (is_array($response)) {
- $response = print_r($response, true);
- }
+ $response = $this->execNameServer("putTasks", $results);
+ if (is_array($response)) {
+ $response = print_r($response, true);
}
L\crawlLog("--Name server response was:\n" . $response);
}
@@ -189,30 +178,34 @@ class MediaJob implements CrawlConstants, MediaConstants
* machine
* @return array a list of outputs from each machine that was called.
*/
- public static function execNameServer($command, $arg = null)
+ public static function execNameServer($command, $args = null)
{
$time = time();
$session = md5($time . C\AUTH_KEY);
$query = "c=jobs&a=$command&time=$time&session=$session";
- if ($arg != null) {
- $arg = L\webencode(serialize($arg));
- $query .= "&arg=$arg";
+ if ($args != null) {
+ $args = L\webencode(serialize($args));
+ $query .= "&args=$args";
}
$job_name = self::getJobName();
if($job_name) {
$query .= "&job=$job_name";
}
- $sites = [];
- $post_data = [];
$current_machine = self::getCurrentmachine();
- $sites[0][CrawlConstants::URL] = C\NAME_SERVER;
- $post_data[0] = $query."&machine_id=" . L\webencode($current_machine);
+ $post_data = $query."&machine_id=" . L\webencode($current_machine);
L\crawlLog("Contacting Name server...".
"The url, '?', and first 256 bytes of posted query are:\n" .
- C\NAME_SERVER . "?" . substr($post_data[0], 0, 256));
- $outputs = FetchUrl::getPages($sites, false, 0, null, self::URL,
- self::PAGE, true, $post_data);
- return $outputs;
+ C\NAME_SERVER . "?" . substr($post_data, 0, 256));
+ L\crawlLog("Will send: " . strlen($post_data) . " bytes");
+ $response = FetchUrl::getPage(C\NAME_SERVER, $post_data);
+ $output = false;
+ $data_len = 0;
+ if ($response) {
+ $data_len = strlen($response);
+ $output = unserialize(L\webdecode($response));
+ }
+ L\crawlLog("Response received: " . $data_len . " bytes");
+ return $output;
}
/**
*
diff --git a/src/library/media_jobs/VideoConvertJob.php b/src/library/media_jobs/VideoConvertJob.php
index 16a13b206..8bd241c8a 100644
--- a/src/library/media_jobs/VideoConvertJob.php
+++ b/src/library/media_jobs/VideoConvertJob.php
@@ -124,9 +124,10 @@ class VideoConvertJob extends MediaJob
strlen($convert_path) + 1);
/* Upload the file to the server */
$file_data = file_get_contents($files[0]);
- $upload_task['data'] = L\webencode($file_data);
- $upload_task['file_name'] = L\webencode($converted_file_name);
- $upload_task['folder_name'] = L\webencode($folder_name);
+ $upload_task['data'] = $file_data;
+ $upload_task['file_name'] = $converted_file_name;
+ $upload_task['folder_name'] = $folder_name;
+ L\crawlLog("Bundling upload data");
return $upload_task;
}
} else {
@@ -166,7 +167,7 @@ class VideoConvertJob extends MediaJob
$extension = "." . UrlParser::getDocumentType($file_name, "");
$new_name = substr($file_name, 0, -strlen($extension));
$ffmpeg = C\FFMPEG." -i \"$file_path/$file_name\" ".
- " -acodec copy -f segment -segment_time 300 ".
+ " -acodec copy -f segment -segment_time 150 ".
"-vcodec copy -reset_timestamps 1 -map 0 ".
"\"$destination_directory/%d$new_name$extension\"";
L\crawlLog($ffmpeg);
@@ -372,7 +373,7 @@ class VideoConvertJob extends MediaJob
*/
public function putTasks($machine_id, $data)
{
- if (!isset($data['data']) || !isset($data['folder_name'])||
+ if (!isset($data['data']) || !isset($data['folder_name']) ||
!isset($data['file_name'])) {
return "Missing parameters in upload message";
}
@@ -393,7 +394,7 @@ class VideoConvertJob extends MediaJob
return "";
}
$upload_flag = false;
- if (file_exists($converted_folder."/".$folder_name)){
+ if (file_exists($converted_folder . "/" . $folder_name)){
if (file_exists($upload_path)){
return "Video file had already been uploaded!";
} else {