root / getAddress.php @ 6ebba44e3bf110d4ce262c25b020719c2f060e94

1
<?php
2
3
/*
4
5
  Copyright (C) 2010, All Rights Reserved.
6
7
  This file is part of RPInventory.
8
9
  RPInventory is free software: you can redistribute it and/or modify
10
  it under the terms of the GNU General Public License as published by
11
  the Free Software Foundation, either version 3 of the License, or
12
  (at your option) any later version.
13
14
  RPInventory is distributed in the hope that it will be useful,
15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
  GNU General Public License for more details.
18
19
  You should have received a copy of the GNU General Public License
20
  along with RPInventory.  If not, see <http://www.gnu.org/licenses/>.
21
22
 */
23
24
require_once('modules/json/JSON.php');
25
require_once("lib/auth.lib.php");   //Session
26
require_once('lib/addresses.lib.php');
27
require_once('lib/borrowers.lib.php');
28
require_once('class/database.class.php');
29
30
// Connect
31
$db = new database();
32
33
//Authenticate
34
$auth = GetAuthority();
35
if($auth < 1)
36
    die("You dont have permission to access this page");
37
38
//JSON data 
39
$data = array("Found" => 'False', "Address" => '', "Address2" => '', "City" => '', "State" => '', "Zipcode" => '', "Phone" => '');
40
41
//GET ID
42
$username = $_GET['username'];
43
44
if( strlen( $username ) == 0)
45
    die("Invalid Username");        
46
47
//Address
48
$borrower_id = getBorrowerId($username, $_SESSION['club'], $db);
49
$address = getAddressFromBorrower($borrower_id, $db);
50
51
if ($address != false)
52
{
53
    $data["Found"] = 'True';
54
55
    if($address->address != NULL)
56
        $data["Address"] = $address->address;
57
58
    if($address->address2 != NULL)
59
        $data["Address2"] = $addres->address2;
60
61
    if($address->city != NULL)
62
        $data["City"] = $address->city;
63
64
    if($address->state != NULL)
65
        $data["State"] = $address->state;
66
67
    if($address->zipcode != NULL)
68
        $data["Zipcode"] = $address->zipcode;
69
70
    if($address->phone != NULL)
71
        $data["Phone"] = $address->phone;
72
}
73
74
$json = new Services_JSON(); 
75
76
$db->close();
77
78
header('X-JSON: ('.$json->encode($data).')');
79
80
?>
81