-
Notifications
You must be signed in to change notification settings - Fork 3
/
function.php
98 lines (82 loc) · 2.26 KB
/
function.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
<?php
include "mysqlClass.inc.php";
function user_exist_check ($username, $password,$emailid,$fname,$lname,$answer){
$query = "select * from account where username='$username'";
$result = mysql_query( $query );
if (!$result){
die ("user_exist_check() failed. Could not query the database: <br />". mysql_error());
}
else {
$row = mysql_fetch_assoc($result);
if($row == 0){
$query = "insert into account values ('$username','$password')";
$query1="insert into User(username,email,fname,lname,answer) values('$username','$emailid','$fname','$lname','$answer')";
//echo "insert query:" . $query;
$insert = mysql_query( $query );
$insert1=mysql_query( $query1 );
if($insert && $insert1)
return 1;
else
die ("Could not insert into the table account: <br />". mysql_error());
}
else{
return 2;
}
}
}
function user_pass_check($username, $password)
{
$query = "select * from account where username='$username'";
//echo $query;
$result = mysql_query( $query );
if (!$result)
{
die ("user_pass_check() failed. Could not query the database: <br />". mysql_error());
}
else{
$row = mysql_fetch_row($result);
if($row == 0)
return 1;
else if(strcmp($row[1],$password))
return 2; //wrong password
else
return 0; //Checked.
}
}
function updateMediaTime($mediaid)
{
$query = " update media set lastaccesstime=NOW()
WHERE '$mediaid' = mediaid
";
// Run the query created above on the database through the connection
$result = mysql_query( $query );
if (!$result)
{
die ("updateMediaTime() failed. Could not query the database: <br />". mysql_error());
}
}
function upload_error($result)
{
//view erorr description in http://us2.php.net/manual/en/features.file-upload.errors.php
switch ($result){
case 1:
return "UPLOAD_ERR_INI_SIZE";
case 2:
return "UPLOAD_ERR_FORM_SIZE";
case 3:
return "UPLOAD_ERR_PARTIAL";
case 4:
return "UPLOAD_ERR_NO_FILE";
case 5:
return "File has already been uploaded";
case 6:
return "Failed to move file from temporary directory";
case 7:
return "Upload file failed";
}
}
function other()
{
//You can write your own functions here.
}
?>