-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.php
61 lines (47 loc) · 1.14 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
<?php
DEFINE('USER_IS_FREE', 1);
DEFINE('USER_IS_PREMIUM', 2);
DEFINE('LOGIN_FAIL', 0);
DEFINE('DOWNLOAD_URL', 'download_url');
DEFINE('DOWNLOAD_ERROR', 'download_error');
DEFINE('ERR_NOT_SUPPORT_TYPE', 'err_not_support_type');
DEFINE('ERR_FILE_NO_EXIST', 'err_file_no_exists');
DEFINE('DOWNLOAD_STATION_USER_AGENT', 'synology');
function getParam($num) {
global $argv;
return isset($argv[$num]) ? $argv[$num] : null;
}
$user = getParam(1);
$pass = getParam(2);
$link = getParam(3);
$msg = [
'Running test script',
'-------------------',
"user: {$user}",
"pass: {$pass}",
"link: {$link}"
];
echo implode(PHP_EOL, $msg) . PHP_EOL . PHP_EOL;
require 'webshare.php';
# Client
$client = new SynoFileHostingWebshare($link, $user, $pass);
# Login
echo 'Testing login: ';
$resultMsg = [
0 => 'Failed',
1 => 'Passed - regular',
2 => 'Passed - vip'
];
$result = $client->Verify();
echo $resultMsg[$result] . PHP_EOL;
# Link
echo 'Testing link: ';
$result = $client->GetDownloadInfo();
if (isset($result[DOWNLOAD_URL])) {
echo 'Passed';
} else {
echo 'Failed - ' . $result[DOWNLOAD_ERROR];
}
echo PHP_EOL . PHP_EOL;
# All good
echo 'Done' . PHP_EOL;