YaWK  24.1
Yet another WebKit
loginbox.ajax.php
Go to the documentation of this file.
1 <?php
2 // start a new session
3 session_start();
4 // include required classes
5 require_once '../../../classes/db.php';
6 require_once '../../../classes/sys.php';
7 require_once '../../../classes/user.php';
8 require_once '../../../classes/settings.php';
9 
10 // check if database is set
11 if (!isset($db) || (empty($db)))
12 { // create new db object
13  $db = new \YAWK\db();
14 }
15 
16 // check if user is set
17 if (!isset($user) || (empty($user)))
18 { // create new user object
19  $user = new \YAWK\user($db);
20 }
21 
22 // check username data
23 if (!isset($_POST['user']) || (empty($_POST['user'])))
24 { // name is not set echo false
25  echo "false";
26 }
27 // user is set...
28 else
29 { // check if it is a string
30  if (is_string($_POST['user']))
31  { // email seems to be valid
32  $user = $_POST['user'];
33  // remove html tags
34  $user = strip_tags($user);
35  // quote data
36  $user = $db->quote($user);
37  }
38  else
39  { // name seems to be an invalid data type
40  $result = array('status' => false);
41  header('Content-type: application/json; charset=UTF-8');
42  echo json_encode($result);
43  }
44 }
45 
46 // check password data
47 if (!isset($_POST['password']) || (empty($_POST['password'])))
48 { // email is not set or empty
49  $result = array('status' => false);
50  header('Content-type: application/json; charset=UTF-8');
51  echo json_encode($result);
52 }
53 
54 // password is set
55 else
56  { // validate it
57  if (is_string($_POST['password']))
58  { // password seems to be a string
59  $password = $_POST['password'];
60  // quote data
61  $password = $db->quote($password);
62  // login user and check if login was successful
63  if (\YAWK\user::ajaxLogin($db, $user, $password) == true)
64  { // login successful
65  $result = array('status' => true);
66  header('Content-type: application/json; charset=UTF-8');
67  echo json_encode($result);
68  }
69  else
70  { // login failed
71  $result = array('status' => false);
72  header('Content-type: application/json; charset=UTF-8');
73  echo json_encode($result);
74  }
75  }
76  else
77  { // password is not a string - login failed
78  $result = array('status' => false);
79  header('Content-type: application/json; charset=UTF-8');
80  echo json_encode($result);
81  }
82  }
$result
Definition: email-send.php:137
This class serves methods to create backup from files.
Definition: AdminLTE.php:2