This repository has been archived by the owner on Jan 19, 2024. It is now read-only.
forked from xOneca/amule-ec-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
67 lines (59 loc) · 1.85 KB
/
test.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
<?php
// Purpose: Testing EC Protocol
header('Content-Type: text/plain');
//require_once('include/ecProto.inc.php');
require_once('ecFunctions.php');
$ec = new ecProtocol('127.0.0.1', 4661); // host, port
if($ec->Login('amule-php-remote-test '.rand(1000, 9999), '1.0', '3CA7FA9B6781D94D763D07EBFAA5C515'))
{
// Log in successful.
print("Log in successful.\n");
$downloads = $ec->DownloadsInfoReq();
if(count($downloads))
{
foreach($downloads as $download)
{
print("\n" . $download->name . ":\n");
print('* Gaps: (' . $download->gap_count . ")\n");
print(str_dump($download->gap_status));
print("* Parts:\n". str_dump($download->part_status));
print('* Status: '. $download->status . "\n");
print("* Reqs:\n" . str_dump($download->req_status));
}
}
// print("\n\$downloads object:\n");
// var_dump($downloads);
}
else
{
// Log in faliled.
print("Log in failed. Maybe wrong password?\n");
var_dump($ec->response);
}
// Function to view a string as in an hex viewer
function str_dump($str)
{
$print = array();
$lines = str_split($str, 16);
foreach($lines as $n => $line)
{
$print[$n] = '';
for($i = 0; $i < strlen($line); $i++)
{
$print[$n] .= bin2hex($line[$i]) . ' ';
if(($i+1) % 8 == 0 && $i != 0)
$print[$n] .= ' '; // extra space
}
$print[$n] = sprintf('%- 50s', $print[$n]);
for($i = 0; $i < strlen($line); $i++)
{
if(ord($line[$i]) > 0x1f && ord($line[$i]) < 0x7f)
$print[$n] .= $line[$i];
else
$print[$n] .= '.'; // non-printable char
if(($i+1) % 8 == 0 && $i != 0)
$print[$n] .= ' ';
}
}
return implode("\n", $print) . "\n";
}