File:
1.19.1b/server/web/nodeside.push.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeNATS
4:
5: FreeNATS is (C) Copyright 2008 PurplePixie Systems
6:
7: FreeNATS is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeNATS is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeNATS. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freenats
21: -------------------------------------------------------------- */
22: require("include.php");
23: $NATS->Start();
24:
25: // From Client - nodeid, nodekey, xml
26: // From Server - REMOTE_ADDR
27: $nodeid=$_REQUEST['nodeid'];
28: $nodekey=$_REQUEST['nodekey'];
29: $xml=$_REQUEST['xml'];
30: $remoteip=$_SERVER['REMOTE_ADDR'];
31:
32: $q="SELECT nskey,nsenabled,nspushenabled,nspuship FROM fnnode WHERE nodeid=\"".ss($nodeid)."\"";
33: $r=$NATS->DB->Query($q);
34: if (!$node=$NATS->DB->Fetch_Array($r))
35: {
36: echo "Invalid nodeid";
37: exit();
38: }
39: if ($node['nsenabled']!=1)
40: {
41: echo "Nodeside Disabled for Node";
42: exit();
43: }
44: if ($node['nspushenabled']!=1)
45: {
46: echo "Nodeside Push Disabled for Node";
47: exit();
48: }
49: if ( ($node['nspuship']!="") && ($node['nspuship'] != $remoteip) )
50: {
51: echo "Remote IP Not Allowed for Push";
52: exit();
53: }
54: if ( ($node['nskey']!="") && ($node['nskey'] != $nodekey) )
55: {
56: echo "Nodekey Failure";
57: exit();
58: }
59:
60: // Got here so ok!
61:
62: $xmlobj=new TNodeXML();
63:
64: $xmlobj->Parse($xml);
65:
66: if ($xmlobj->Error()!="")
67: {
68: echo "XML Error: ".$xmlobj->Error();
69: exit();
70: }
71:
72: $eventdata=array("nodeid"=>$nodeid);
73: $NATS->EventHandler("nodeside_push",$eventdata);
74:
75: $NATS->Nodeside_Process($nodeid,$xmlobj);
76:
77: $uq="UPDATE fnnode SET nsfreshpush=1,nslastx=".time()." WHERE nodeid=\"".ss($nodeid)."\"";
78: $NATS->DB->Query($uq);
79:
80: echo "1";
81: $NATS->Stop();
82: exit();
83: ?>