-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofpic_ajax.php
executable file
·108 lines (60 loc) · 2.42 KB
/
profpic_ajax.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
99
100
101
102
103
104
<?php
require_once('auth.php');
include("connection.php");
include("commonfun.php");
require 'Zebra_Image.php';
include("vcommon.php");
$usern=$_SESSION['SESS_USERNAME'];
if (!empty($_FILES) && $_FILES['file']['error'] === UPLOAD_ERR_OK) {
$check_name= strlen(get_basename($_FILES['file']['tmp_name']));
if($check_name==0 || $check_name>=150){
unset($_FILES);
echo "file name too long";
exit();}
$tempFile = $_FILES['file']['tmp_name']; //3
$filename =$_FILES['file']['name'];
$filename=preg_replace("/[^a-z0-9\.]/", "", strtolower($filename));
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if($ext=="jpg"||$ext=="jpeg"||$ext=="gif"||$ext=="png"){
mkdir("profile_pic/$usern",0760);
mkdir("profile_pic/$usern/thumb",0760);
$today = date("Y-m-d H:i");
$today=base64_encode($today);
$ses_id= session_id();
$today=$today.$ses_id;
$fname="profile_pic/$usern/$today"."_500x500_"."$filename";
$thumb_fname="profile_pic/$usern/thumb/$today"."_60x60_"."$filename";
move_uploaded_file($tempFile,$fname);
// create a new instance of the class
$image = new Zebra_Image();
$realimage = new Zebra_Image();
// indicate a source image
$image->source_path = $fname;
$realimage->source_path = $fname;
// indicate a target image
$image->target_path = $thumb_fname ;
$realimage->target_path = $fname ;
// resize
// and if there is an error, show the error message
if (!$image->resize(60, 60,ZEBRA_IMAGE_CROP_CENTER, -1)) show_error($image->error, $image->source_path, $image->target_path);
if (!$realimage->resize(500,500,ZEBRA_IMAGE_NOT_BOXED, -1)) show_error($realimage->error, $realimage->source_path, $realimage->target_path);
// crop
// and if there is an error, show the error message
if($ext=="jpg"||$ext=="jpeg"||$ext=="gif"){
}
else if($ext=="png"){
}
$sql="update member set picture='$fname',thumbnail='$thumb_fname' where username='$usern'";
$result=mysql_query($sql);
}
else{unset($_FILES);
exit();}
}
/*
//$hint="changepropic";
//$tidu=NULL;
//$qry456="INSERT INTO notification (worker,channel_id,hint,uid) VALUES ('$usern','$tidu','$hint','$uid[0]')";
// $result456=mysql_query($qry456);
}
}*/
?>