function syncResp($params)
{
    debug("incoming SYNC request");
    $lastSync = xmlrpc_decode($params->getParam(0));
    $nodeData = xmlrpc_decode($params->getParam(1));
    $objects = xmlrpc_decode($params->getParam(2));
    $neighbour = sotf_Neighbour::getById($nodeData['node_id']);
    if (!$neighbour) {
        logError("No access: you are not an allowed neighbour node!");
        return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: you are not an allowed neighbour node!");
    }
    $msg = checkAccess($neighbour);
    if ($msg) {
        logError($msg);
        return new xmlrpcresp(0, XMLRPC_ERR_NO_ACCESS, "No access: {$msg}!");
    }
    $retval = $neighbour->syncResponse($lastSync, $nodeData, $objects);
    // send response
    $retval = xmlrpc_encode($retval);
    return new xmlrpcresp($retval);
}
Example #2
0
}
$smarty->assign("LOCAL_NODE", $localNode->getAll());
// nodes
//$nodes = sotf_Node::countAll();
//$smarty->assign('NODES',$nodeData);
// neighbours
//$neighbours = sotf_Neighbour::listAll();
$nodes = sotf_Node::listAll();
print_r($neighbours);
while (list(, $node) = each($nodes)) {
    $nodeId = $node->get('node_id');
    if ($nodeId == $config['nodeId']) {
        continue;
    }
    $data = $node->getAll();
    $nei = sotf_Neighbour::getById($nodeId);
    if ($nei) {
        $data['neighbour'] = $nei->getAll();
    }
    $data['pending_objects'] = $db->getOne("select count(*) from sotf_object_status where node_id='{$nodeId}'");
    $data['pending_forwards'] = $db->getOne("select count(*) from sotf_to_forward where node_id='{$nodeId}'");
    $neighbors = $data['neighbours'];
    debug("X0", $data['neighbours']);
    $neighbors = str_replace("io", "<->", $neighbors);
    $neighbors = str_replace("i", "<-", $neighbors);
    $neighbors = str_replace("o", "->", $neighbors);
    $data['neighbours'] = explode(',', $neighbors);
    debug("XX", $data['neighbours']);
    $nodeData[] = $data;
}
$smarty->assign('NODES', $nodeData);
 function addToRefreshTable($id, $fromNode = 0)
 {
     global $db;
     $existing = $db->getCol("SELECT node_id FROM sotf_object_status WHERE id='{$id}'");
     $neighbours = sotf_Neighbour::listIds();
     foreach ($neighbours as $nei) {
         if ($this->internalData['node_id'] != $nei && $nei != $fromNode && !in_array($nei, $existing)) {
             $db->query("INSERT INTO sotf_object_status (id, node_id) VALUES('{$id}', {$nei})");
         }
     }
     debug("added to refresh table");
 }
Example #4
0
 CRON</title></head>
<body>
<?php 
debug("--------------- CRON STARTED -----------------------------------");
// this can be long duty!
set_time_limit(18000);
// don't garble reply message with warnings in HTML
//ini_set("display_errors", 0);
//******** Synchronize with network: send new local data and recievie new global data
// get sync stamp and increment it
$syncStamp = $sotfVars->get('sync_stamp', 0);
$syncStamp++;
$sotfVars->set('sync_stamp', $syncStamp);
// sync with all neighbours
$rpc = new rpc_Utils();
$neighbours = sotf_Neighbour::getAll();
if (count($neighbours) > 0) {
    while (list(, $neighbour) = each($neighbours)) {
        $neighbour->sync();
    }
}
//********* IMPORT ARRIVED XBMF
$dirPath = $config['xbmfInDir'];
$dir = dir($dirPath);
while ($entry = $dir->read()) {
    if ($entry != "." && $entry != "..") {
        $currentFile = $dirPath . "/" . $entry;
        if (!is_dir($currentFile)) {
            $XBMF[] = basename($currentFile);
        }
    }
Example #5
0
    $page->addStatusMsg($msg, false);
    $page->redirect("admin.php");
    exit;
}
// generate output
$localNode = sotf_Node::getLocalNode();
if (!$localNode) {
    $localNode = new sotf_Node();
    $localNode->set('node_id', $nodeId);
    $localNode->set('name', $nodeName);
    $localNode->set('url', $rootdir);
    $localNode->create();
}
$smarty->assign("LOCAL_NODE", $localNode->getAll());
// nodes
//$nodes = sotf_Node::countAll();
//$smarty->assign('NODES',$nodeData);
// neighbours
$neighbours = sotf_Neighbour::listAll();
while (list(, $nei) = each($neighbours)) {
    $node = sotf_Node::getNodeById($nei->get('node_id'));
    $data = $nei->getAll();
    if ($node) {
        $data['node'] = $node->getAll();
    }
    $neighbourData[] = $data;
}
$smarty->assign('NEIGHBOURS', $neighbourData);
// user permissions: editors and managers
$smarty->assign('PERMISSIONS', $permissions->listUsersAndPermissionsLocalized('node'));
$page->send();
$page->popup = true;
$page->errorURL = "createNeighbour.php";
if (!hasPerm('node', "change")) {
    raiseError("You have no permission to change node settings!");
}
$url = sotf_Utils::getParameter('url');
$nid = sotf_Utils::getParameter('node_id');
//
$createNew = sotf_Utils::getParameter('create_new_node');
if ($createNew) {
    if (!$url) {
        $page->addStatusMsg('no_url_given');
    } elseif (sotf_Node::getNodeById($nid)) {
        $page->addStatusMsg('node_id_occupied');
    } else {
        $neighbor = new sotf_Neighbour();
        $neighbor->set('node_id', $nid);
        $neighbor->set('use_for_outgoing', 'f');
        $neighbor->set('accept_incoming', 't');
        $neighbor->set('pending_url', $url);
        $neighbor->create();
        $page->redirect("closeAndRefresh.php?anchor=network");
        exit;
    }
    $page->redirect("createNeighbour.php?node_id={$nid}&url=" . urlencode($url) . "#network");
    exit;
}
// generate output
$nodes = sotf_Node::listAll();
$nodeData = array();
while (list(, $node) = each($nodes)) {
 function getNeighbourString()
 {
     $neis = sotf_Neighbour::listAll();
     $first = 1;
     while (list(, $nei) = each($neis)) {
         if ($first) {
             $first = 0;
         } else {
             $retval .= ',';
         }
         $retval .= $nei->get('node_id');
         if ($nei->getBool('accept_incoming')) {
             $retval .= 'i';
         }
         if ($nei->getBool('use_for_outgoing')) {
             $retval .= 'o';
         }
     }
     return $retval;
 }
// -*- tab-width: 3; indent-tabs-mode: 1; -*-
/*  
 * $Id: editNeighbour.php 339 2003-12-03 08:39:25Z andras $
 * Created for the StreamOnTheFly project (IST-2001-32226)
 * Authors: András Micsik, Máté Pataki, Tamás Déri 
 *          at MTA SZTAKI DSD, http://dsd.sztaki.hu
 */
require "init.inc.php";
$smarty->assign('PAGETITLE', $page->getlocalized('AdminPage'));
$page->forceLogin();
$page->popup = true;
$page->errorURL = "editNeighbour.php";
checkPerm('node', "change");
$nid = sotf_Utils::getParameter('nodeid');
$nei = sotf_Neighbour::getById($nid);
if (!$nei) {
    raiseError("No such node: {$nid}");
}
// save changes
if (sotf_Utils::getParameter('save')) {
    $nei->set('use_for_outgoing', sotf_Utils::getParameter('use_out') ? 't' : 'f');
    $nei->set('accept_incoming', sotf_Utils::getParameter('use_in') ? 't' : 'f');
    $nei->update();
    $page->redirect("closeAndRefresh.php?anchor=network");
    exit;
}
// generate output
$node = sotf_Node::getNodeById($nid);
if ($node) {
    $smarty->assign('NODE', $node->getAll());