-
Notifications
You must be signed in to change notification settings - Fork 0
/
Response.php
46 lines (36 loc) · 1.37 KB
/
Response.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
<?php
class Response
{
private $authenticate = 1;
private $ornekOutput;
public function __construct()
{
$this->ornekOutput = new \stdClass();
$this->ornekOutput->status = '200';
$this->ornekOutput->message = 'Success';
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="401 Unauthorized"');
header('HTTP/1.0 401 Unauthorized');
$this->authenticate = 0;
$this->ornekOutput->status = '401';
$this->ornekOutput->message = 'Unauthorized';
} else {
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if($username!='ornek' || $password!='ornek'){
header('WWW-Authenticate: Basic realm="401 Unauthorized"');
header('HTTP/1.0 401 Unauthorized');
$this->ornekOutput->status = '401';
$this->ornekOutput->message = 'Unauthorized';
$this->authenticate = 0;
}
}
}
public function ornek($data){
if($this->authenticate == 1){
$this->ornekOutput->name = $data->name." ".$data->second_name;
$this->ornekOutput->phone = $data->phone;
}
return $this->ornekOutput;
}
}