-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.php
74 lines (61 loc) · 1.76 KB
/
common.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
<?php
include_once "mysql.php";
class User {
public $username = '';
public $password = '';
public $userid = '';
public $name;
function __construct($u,$p,$conn) {
$this->username = $conn->real_escape_string($u);
$this->password = $conn->real_escape_string($p);
$this->userid='';
}
function login($conn) {
$username = $conn->real_escape_string($this->username);
$password = $conn->real_escape_string($this->password);
$q = $conn->query("SELECT id,password,name FROM users WHERE username = '$username' LIMIT 1");
if ($q->num_rows == 0) {
return 1;
}
else {
$r = mysqli_fetch_assoc($q);
if (password_verify($password, $r['password'])) {
//$hash = password_hash($passwordFromPost, PASSWORD_BCRYPT, $options);
$this->name = $r['name'];
$this->userid = $r['id'];
return 0;
}
else {
return 1;
}
}
}
}
class File {
private $arr = ['doc','docx','xls','xlsx','pdf','ppt','pptx', 'rtf', 'txt','csv', 'pps','xml','mp3', 'mp4','wma','mkv','jpg','png', 'bmp'];
public $originalname = '';
public $filesize = '';
public $servername = '';
public $error = 0;
function __construct($f, $conn) {
$this->originalname = $conn->real_ecape_string($f['name']);
$this->filesize = $conn->real_ecape_string($f['size']);
$this->servername = $f['tmp_name'];
if ($this->filesize < 5) { $error = 4; }
if (!$this->validType()) {
{ $error = 5; }
}
}
function getType() {
$temp = explode('.', $this->originalname);
if (count($temp) <= 1) {
return "wrongEXT";
}
return $temp[count($temp)-1];
}
function validType() {
if (!in_array($this->getType(), arr)) return false;
else return true;
}
}
?>