function forwardObjects()
 {
     global $db, $config;
     global $page;
     if (!$console && $this->getBool('use_for_outgoing')) {
         debug("node {$this->id} is not used for outgoing sync");
         return;
     }
     debug("FORWARDING TO ", $this->get("node_id"));
     $rpc = new rpc_Utils();
     if ($config['debug']) {
         $rpc->debug = true;
     }
     $timestamp = $db->getTimestampTz();
     $remoteId = $this->get('node_id');
     $url = $this->get('url');
     // remove trailing '/'
     while (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     // calculate chunking
     $thisChunk = 1;
     // do XML-RPC conversation
     $objectsSent = 0;
     $more = sotf_NodeObject::countForwardObjects($remoteId);
     if (!$more) {
         debug("No new objects to send");
     }
     while ($more) {
         $db->begin(true);
         $modifiedObjects = sotf_NodeObject::getForwardObjects($remoteId, $this->objectsPerRPCRequest);
         $more = sotf_NodeObject::countForwardObjects($remoteId);
         $chunkInfo = array('this_chunk' => $thisChunk, 'from_node' => $config['nodeId'], 'objects_remaining' => $more);
         debug("chunk info", $chunkInfo);
         debug("number of sent objects", count($modifiedObjects));
         $objectsSent = $objectsSent + count($modifiedObjects);
         $objs = array($chunkInfo, $modifiedObjects);
         $response = $rpc->call($url . "/xmlrpcServer.php/forward/{$thisChunk}", 'sotf.forward', $objs);
         // error handling
         if (is_null($response)) {
             $db->rollback();
             return;
         }
         $db->commit();
         $replyInfo = $response[0];
         debug("replyInfo", $replyInfo);
         $thisChunk++;
     }
     debug("total number of objects sent", $objectsSent);
     //$this->log($console, "number of updated objects: " .count($updatedObjects));
 }
 function sync($console = false)
 {
     global $db, $page, $config;
     $remoteId = $this->get('node_id');
     if (!$console && $this->get('use_for_outgoing') != 't') {
         debug("node {$remoteId} is not used for outgoing sync");
         return;
     }
     debug("SYNCing with ", $this->get("node_id"));
     $rpc = new rpc_Utils();
     if ($config['debug']) {
         $rpc->debug = true;
     }
     $timestamp = $db->getTimestampTz();
     $url = $this->getUrl();
     // remove trailing '/'
     while (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     // collect local data to send
     $localNode = sotf_Node::getLocalNode();
     // check if url is correct...
     if ($localNode->get('url') != $config['rootUrl']) {
         $localNode->set('url', $config['rootUrl']);
         $localNode->update();
     }
     //debug("localNode", $localNode);
     //debug("neighbour", $this);
     $localNodeData = $localNode->getAll();
     // calculate chunking
     $thisChunk = 1;
     // do XML-RPC conversation
     $objectsSent = 0;
     $more = sotf_NodeObject::countModifiedObjects($remoteId);
     if (!$more) {
         debug("No new objects to send");
     }
     while ($more) {
         $db->begin(true);
         $modifiedObjects = sotf_NodeObject::getModifiedObjects($remoteId, $this->objectsPerRPCRequest);
         $remaining = sotf_NodeObject::countModifiedObjects($remoteId);
         if (count($modifiedObjects) == 0 && $remaining > 0) {
             logError("DATA integrity problem", "{$remaining} objects remained in sotf_object_status after sync");
         }
         if ($remaining == 0 || count($modifiedObjects) == 0) {
             $more = false;
         } else {
             $more = true;
         }
         $chunkInfo = array('this_chunk' => $thisChunk, 'node' => $localNodeData, 'objects_remaining' => $remaining);
         debug("chunk info", $chunkInfo);
         debug("number of sent objects", count($modifiedObjects));
         $objectsSent = $objectsSent + count($modifiedObjects);
         $objs = array($chunkInfo, $modifiedObjects);
         $response = $rpc->call($url . "/xmlrpcServer.php/sync/{$thisChunk}", 'sotf.sync', $objs);
         // error handling
         $replyInfo = $response[0];
         debug("replyInfo", $replyInfo);
         if (is_null($response) || $replyInfo['error']) {
             $this->set('errors', $this->get('errors') + 1);
             $this->update();
             $db->rollback();
             return;
         }
         $db->commit();
         // save received data
         $thisChunk++;
     }
     debug("total number of objects sent", $objectsSent);
     //$this->log($console, "number of updated objects: " .count($updatedObjects));
     // save node and neighbour stats
     if ($error) {
         $this->set('errors', $this->get('errors') + 1);
     } else {
         $this->set('success', $this->get('success') + 1);
     }
     $this->set('last_sync_out', $timestamp);
     $localNode->set('last_sync_out', $timestamp);
     // take out from pending nodes
     if ($this->get('pending_url')) {
         $remoteNode = sotf_Node::getNodeById($remoteId);
         // TODO: problem is that if this is first sync or one-way connection, then object fro remote node may not exist
         if ($remoteNode) {
             $this->set('pending_url', '');
         }
         $localNode->set('neighbours', $this->getNeighbourString());
     }
     $this->update();
     $localNode->update();
 }
 function getStreamInfo($streamData)
 {
     global $config, $db;
     if ($config['httpStreaming']) {
         // no stream info...
         return;
     } elseif ($config['tamburineURL']) {
         $rpc = new rpc_Utils();
         //$rpc->debug = true;
         $response = $rpc->callTamburine('getpls', $streamData['pid']);
         if (is_null($response)) {
             logError("no reply from tamburine server");
         } else {
             $offset = $response[2];
             $filename = $response[2 + $offset];
             //debug("response", $response);
             //debug("fname", $filename);
         }
     } elseif ($config['tamburineCMD']) {
         // streaming with tbrcmd
         $cmd = $config['tamburineCMD'] . " getpls " . $streamData['pid'] . " 2>&1";
         exec($cmd, $output, $retval);
         debug("cmd", $cmd);
         //debug("output", $output);
         //debug("retval", $retval);
         foreach ($output as $line) {
             if (preg_match('/\\-\\>(\\/\\S+)\\s*$/', $line, $mm)) {
                 $filename = $mm[1];
                 break;
             }
         }
     }
     if ($filename) {
         $prg = sotf_Programme::getPrgFromFilename($filename);
         if (is_object($prg)) {
             return array('name' => $prg->get('title'), 'url' => $config['localPrefix'] . "/get.php/" . $prg->id);
         } else {
             return array('name' => $prg);
         }
     } else {
         debug("Could not get stream info");
         // TODO: stop stream!
     }
 }
 function startStreaming()
 {
     global $config, $tamburine;
     if (!$this->localPlaylist) {
         $this->makeLocalPlaylist();
     }
     if ($config['tamburineURL']) {
         // tamburine-based streaming
         if ($_SESSION['playlist_id']) {
             //TODO? kill old stream
         }
         $rpc = new rpc_Utils();
         //$rpc->debug = true;
         $response = $rpc->call($config['tamburineURL'], 'setpls', $this->localPlaylist);
         if (is_null($response)) {
             debug("no reply from tamburine server");
         } else {
             $this->url = $response[0];
             $id = $response[1];
             $_SESSION['playlist_id'] = $id;
         }
     } else {
         // command-line streaming
         $this->url = 'http://' . $config['iceServer'] . ':' . $config['icePort'] . '/' . $this->getTmpId() . "\n";
         //$url = preg_replace('/^.*\/repository/', 'http://sotf2.dsd.sztaki.hu/node/repository', $filepath);
         // TODO: calculate bitrate from all files...
         $bitrate = $this->audioFiles[0]['bitrate'];
         if (!$bitrate) {
             $bitrate = 24;
         }
         $this->cmdStart($this->localPlaylist, $this->getTmpId(), $bitrate);
         //$this->cmdStart2($bitrate);
     }
 }
示例#5
0
        $contents .= fread($handle, 8192);
        //debug("received", strlen($data));
    }
    fclose($handle);
    $tmpFile = tempnam($config['tmpDir'], 'logo_u');
    debug("received logo from", $url);
    debug("tmpfile", $tmpFile);
    sotf_Utils::save($tmpFile, $contents);
    chmod($tmpFile, 0660);
    exec("/usr/bin/convert {$tmpFile} -resize 100x36 " . $config['tmpDir'] . "/test.png 2>&1", $output, $retval);
    debug("retval", $retval);
    debug("output", $output);
}
exit;
require_once $config['classdir'] . "/rpc_Utils.class.php";
$rpc = new rpc_Utils();
$rpc->debug = true;
//$response = $rpc->callTamburine('version', '');
//$response = $rpc->callTamburine('setpls', array('/home/micsik/ok.mp3', '/home/micsik/china.mp3'));
$response = $rpc->callTamburine('getpls', 1);
//$response = $rpc->callTamburine('quit', 1);
dump($response, "RESPONSE");
exit;
$prg = $repository->getObject('005pr27');
dump($prg->getCreatorNames());
exit;
/* 
   [id3v1] => Array
        (
            [title] => Wissen aktuell
            [artist] => Oe1
 function runQuery($query)
 {
     global $sotfSite;
     $rpc = new rpc_Utils();
     $url = $sotfSite . "xmlrpcServer.php";
     $objs = array($query);
     return $rpc->call($url, 'portal.query', $objs);
 }
 function sync($console = false)
 {
     global $sotfVars;
     // tunable things
     $objectsPerRPCRequest = 100;
     global $page;
     if (!$console && $this->getBool('use_for_outgoing')) {
         debug("node {$this->id} is not used for outgoing sync");
         return;
     }
     debug("SYNCing with ", $this->get("node_id"));
     $rpc = new rpc_Utils();
     if ($config['debug']) {
         $rpc->debug = true;
     }
     $timestamp = $this->db->getTimestampTz();
     $remoteId = $this->get('node_id');
     $url = $this->getUrl();
     // remove trailing '/'
     while (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     // collect local data to send
     $localNode = sotf_Node::getLocalNode();
     //debug("localNode", $localNode);
     debug("neighbour", $this);
     $localNodeData = $localNode->getAll();
     // check if url is correct...
     $localNodeData['url'] = $config['rootUrl'];
     // calculate chunking
     $currentStamp = $sotfVars->get('sync_stamp', 0);
     $lastSyncStamp = $this->lastSyncStamp();
     $count = sotf_NodeObject::countModifiedObjects($remoteId, $lastSyncStamp);
     $numChunks = ceil($count / $objectsPerRPCRequest);
     if ($numChunks == 0) {
         $numChunks = 1;
     }
     $thisChunk = 1;
     $chunkInfo = array("old_stamp" => $lastSyncStamp, "current_stamp" => $currentStamp, "num_chunks" => $numChunks, 'this_chunk' => $thisChunk);
     debug("1st chunk info", $chunkInfo);
     // do XML-RPC conversation
     $objectsSent = 0;
     $objectsReceived = 0;
     while ($thisChunk <= $numChunks) {
         if ($thisChunk == $numChunks) {
             // last chunk: no limits
             $objectsPerRPCRequest = 100 * $objectsPerRPCRequest;
         }
         $modifiedObjects = sotf_NodeObject::getModifiedObjects($remoteId, $lastSyncStamp, $objectsSent + 1, $objectsPerRPCRequest);
         $chunkInfo['this_chunk'] = $thisChunk;
         debug("chunk info", $chunkInfo);
         //debug("number of sent objects", count($modifiedObjects));
         $objectsSent = $objectsSent + count($modifiedObjects);
         $objs = array($chunkInfo, $localNodeData, $modifiedObjects);
         $response = $rpc->call($url . '/xmlrpcServer.php', 'sotf.sync', $objs);
         // error handling
         if (is_null($response)) {
             $this->set('errors', $this->get('errors') + 1);
             $this->update();
             return;
         }
         // save received data
         $chunkInfo = $response[0];
         $newObjects = $response[1];
         $objectsReceived = $objectsReceived + count($newObjects);
         debug("number of received objects", count($newObjects));
         if (count($newObjects) > 0) {
             $updatedObjects = sotf_NodeObject::saveModifiedObjects($newObjects);
         }
         $thisChunk++;
     }
     debug("total number of objects sent", $objectsSent);
     debug("total number of objects received", $objectsReceived);
     //$this->log($console, "number of updated objects: " .count($updatedObjects));
     // save last_sync
     $this->set('success', $this->get('success') + 1);
     $this->set('last_sync_out', $timestamp);
     $this->saveSyncStatus($timestamp, $currentStamp);
     // send receipt of successful sync??
 }
示例#8
0
<?php

require "init.inc.php";
require_once $config['classdir'] . "/rpc_Utils.class.php";
$rpc = new rpc_Utils();
$rpc->debug = true;
//$response = $rpc->call($config['rootUrl'] . "/xmlrpcServer.php", 'sotf.cv.listnames', '');
$response = $rpc->call($config['rootUrl'] . "/xmlrpcServer.php", 'sotf.cv.get', array('topics', 1, 'fr'));
print "<pre>";
print_r($response);
print "</pre>";
/*
$tree = $repository->getTree(1, 'en');

print "<pre>";
print_r($tree);
print "</pre>";

exit;
*/
/*
require_once($config['classdir'] . "/rpc_Utils.class.php");

$rpc = new rpc_Utils;
$rpc->debug = true;
$response = $rpc->call($config['tamburineURL'], 'version', '');
*/
/*
require_once($config['classdir'] . '/unpackXML.class.php');

$myPack = new unpackXML($config['basedir'] . "/metasample.txt");