-
Notifications
You must be signed in to change notification settings - Fork 0
/
pleaseNotify.php
71 lines (57 loc) · 1.62 KB
/
pleaseNotify.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
<?php
// Initialize the session
session_start();
define('APP_RAN', '');
// Include files
require_once('config.php');
require_once('Feeds.php');
$rows = array();
$target_dir = dirname(__FILE__).'/';
$feeds = $target_dir.'admin/feeds.csv';
if (file_exists($feeds)) {
$f = fopen($feeds, 'r');
while (($row = fgetcsv($f)) !== false) {
$rows[] = $row;
}
foreach ($rows as $row) {
$feed = $row[0];
$domain = $row[1];
$port = $row[2];
$path = $row[3];
$protocol = $row[4];
$url = 'http://'.$domain.$path;
$host = parse_url(BASE_URL, PHP_URL_HOST);
//$homepath = '/php-mst/notify/notify.php';
$test = strpos($_SERVER['PHP_SELF'], 'pleaseNotify.php');
$cut = substr($_SERVER['PHP_SELF'],0,$test);
$homepath = $cut.'notify/notify.php';
$fields = array(
'domain' => $host,
'port' => '443',
'path' => $homepath,
'registerProcedure' => '',
'protocol' => 'https-post',
'url' => $feed
);
$postdata = http_build_query($fields);
try {
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
$httpReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = curl_exec($ch);
if ($result === false) {
throw new Exception(curl_error($ch), curl_errno($ch));
}
} catch(Exception $e) {
trigger_error(sprintf(
'Curl failed with error #%d: %s',
$e->getCode(), $e->getMessage()),
E_USER_ERROR);
} finally {
curl_close($ch);
}
}
}
?>