-
Notifications
You must be signed in to change notification settings - Fork 6
/
inc_peers.php
107 lines (82 loc) · 2.62 KB
/
inc_peers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* YaCymin - YaCy Admin and Search
* for PHP5 with cURL
*
* v0.4
*
* Copyright (c) 2010 yacy.net / dulcedo
* URL: http://yacymin.walamt.de
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
peer status overview
*/
// Include the API PHP Library
require 'YaCyAPI4.php';
#include 'JSON.php';
//-----------------------------------------------------
// start the class
$search = new YaCyAPI();
//-----------------------------------------------------
// show overview
echo "<h3><font color=grey> ".date('d-m H:i',time())."</font></h3>";
//-----------------------------------------------------
//
include 'peerlist_inc.php';
if($_GET['first']) #
{
$peerno=0;
$peer=$this_YaCyPeer[$peerno][0];
$port=$this_YaCyPeer[$peerno][1];
$appid=$this_YaCyPeer[$peerno][2];
$name=$this_YaCyPeer[$peerno][3];
$res=$search->setProperties($mypeer,$appid,$name);
$info=$search->ping($peerno);
#$ti1=round(($search->_dur1*1000),0);
#if status!
$mypeer="http://".$peer.":".$port."/";
$command="Network.xml?page=1&ip=";
$results = $search->peerCommandDirect($mypeer,$command,$appid); #direct access via peer-address
//now we have xml, put it in a simple array
$resultarray=xml2array($results); #, $get_attributes = 1, $priority = 'tag');
//get items only
$items=$resultarray['peers']['peer'];
if ($items)
{
echo count($items);
while ($ccount<$_GET['first'])
{
$ccount=$ccount+1;
$peer=$items[$ccount]['address'];
echo "<br>".$ccount."-".$peer;
}
}
}
else
{
$maxpeers=count($this_YaCyPeer)+1; #local inst
for ($peerno=0;$peerno<$maxpeers;$peerno++)
{
$peer=$this_YaCyPeer[$peerno][0];
$port=$this_YaCyPeer[$peerno][1];
$appid=$this_YaCyPeer[$peerno][2];
$name=$this_YaCyPeer[$peerno][3];
#-------------------------------------------------------------------------------
$res=$search->setProperties($peer.":".$port,$appid,$name);
$info=$search->ping();
if ($info['host']) #peer defined?
{
require('inc_onepeer.php');
###########
} # end if peer defined
} #end for peerno
}#ind if param-first
?>