/
search.php
114 lines (91 loc) · 3.4 KB
/
search.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
108
109
110
111
112
113
114
<?php
include "/var/www/html/system/common.php";
include "config.php";
//echo "HERE:" . isset($_POST['pubcode']) . "<br />"
if(isset($_POST['pubcode']))
{
$pubcode = $_POST['pubcode'];
$encypubcode = encrypt($pubcode,$Salt);
//echo $pubcode;
$pubcode = $pubcode - 0;
//echo is_numeric($pubcode);
if(is_numeric($pubcode))
{
$authStore = "authlog.txt";
$fh = fopen($authStore, 'r');
$AccessList = fread($fh, filesize($authStore));
$AccessList = str_replace("\r","",$AccessList);
$AccessList = json_decode($AccessList);
fclose ($fh);
$NewAuth = '{"IP":"' . $_SERVER['HTTP_REFERER'] . '","PubCode":"' . $encypubcode . '"}';
$AddAuth = json_decode($NewAuth);
array_push($AccessList,$AddAuth);
$NewAuthListJSON = json_encode($AccessList);
$fh = fopen($authStore, "w");
if($fh==false) { die("unable to create file"); }
fputs($fh,$NewAuthListJSON,strlen($NewAuthListJSON));
fclose ($fh);
header ("Location:" . $_SERVER['HTTP_REFERER']);
}
}
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$authStore = "authlog.txt";
$fh = fopen($authStore, 'r');
$AccessList = fread($fh, filesize($authStore));
$AccessList = str_replace("\r","",$AccessList);
$AccessList = json_decode($AccessList);
fclose ($fh);
$found = 0;
$pubcode = "test";
foreach ($AccessList as $key => $value) {
//echo $value->IP . " = " . $_SERVER['HTTP_REFERER'] . "<br />";
if ($value->IP == $_SERVER['HTTP_REFERER']) {
$found = 1;
$pubcode = decrypt($value->PubCode,$Salt);
$publishercode = $pubcode;
}
}
if($found!=1)
{
echo $_GET['jsoncallback'] . '({"auth":"0"})';
}
else
{
date_default_timezone_set("America/Los_Angeles");
$ThisPage = $_SERVER['PHP_SELF'];
$ThisURL = $_SERVER['REQUEST_URI'];
$ThisHost = $_SERVER['HTTP_HOST'];
include "config.php";
include "/var/www/html/system/class-citygrid-places.php";
include "/var/www/html/system/class-citygrid-advertising.php";
include "/var/www/html/system/class-utility.php";
// what
if(isset($_REQUEST['what'])){ $what = $_REQUEST['what'];} elseif(isset($_POST['what'])){$what = $_POST['what']; } else { $what=''; }
// type
if(isset($_REQUEST['type'])){ $type = $_REQUEST['type'];} elseif(isset($_POST['type'])){$type = $_POST['type']; } else { $type=''; }
// where
if(isset($_REQUEST['where'])){ $where = $_REQUEST['where'];} elseif(isset($_POST['where'])){$where = $_POST['where']; } else { $where=$Site_Where; }
// page
if(isset($_REQUEST['page'])){ $page = $_REQUEST['page'];} elseif(isset($_POST['page'])){$page = $_POST['page']; } else { $page=1; }
// rpp
if(isset($_REQUEST['rpp'])){ $rpp = $_REQUEST['rpp'];} elseif(isset($_POST['rpp'])){$rpp = $_POST['rpp']; } else { $rpp=10; }
// sort
if(isset($_REQUEST['sort'])){ $sort = $_REQUEST['sort'];} elseif(isset($_POST['sort'])){$sort = $_POST['sort']; } else { $sort='dist'; }
$max = 2;
$format='json';
$placement=null;
$has_offers=false;
$histograms=false;
$i=null;
$type=null;
$format='json';
//Get All Active APIs
$citygrid = new citygridplaces($publishercode);
$search = $citygrid->srch_places_where($what,$type,$where,$page,$rpp,$sort,$format,$placement,$has_offers,$histograms,$i);
$search = json_encode($search);
echo $_GET['jsoncallback'] . '(' . $search . ')';
//echo $_GET['jsoncallback'] . '({"auth":"' . $_SERVER['HTTP_REFERER'] . '"})';
}
?>