-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun.php
More file actions
56 lines (42 loc) · 1.31 KB
/
Copy pathrun.php
File metadata and controls
56 lines (42 loc) · 1.31 KB
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
<?php
// define a base path
$path = dirname(__FILE__);
$path = realpath($path);
define('_COS_PATH', $path);
include_once "coslib/config.php";
include_once "coslib/mycurl.php";
include_once "coslib/log.php";
include_once "coslib/IP.php";
log::createLog();
$config_file = _COS_PATH . '/config/config.php';
config::loadPHPConfigFile($config_file);
// simple api for getting ip.
$api_ip = config::getMainIni('api_ip');
if (!$api_ip) {
$api_ip = 'https://api.10kilobyte.com/my_ip.php';
}
$my_ip = @file_get_contents($api_ip);
if ($my_ip === false) {
log::error("Could not get your public IP. No check of current DNS settings");
return;
}
if (!IP::isPublic($my_ip)) {
log::error("IP $my_ip is not public");
}
$my_ip = trim($my_ip);
$my_hostnames = config::getMainIni('my_hostnames'); // if more hosts use a comma seperated list
$url = config::getMainIni('api_url');
$url.= "?hostname=$my_hostnames&myip=$my_ip";
$user_agent = "User-Agent: noiphp/0.0.1 dennis.iversen@gmail.com";
$curl = new mycurl($url);
$curl->useAuth(true);
//$curl->setCert(config::getMainIni('cert'));
$email = config::getMainIni('email');
$password = config::getMainIni('password');
$curl->setName($email);
$curl->setPass($password);
$curl->setUserAgent($user_agent);
$curl->createCurl();
$result = $curl->getWebPage();
log::error($result);
die;