-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewsupload.php
executable file
·103 lines (83 loc) · 2.42 KB
/
newsupload.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
<?php
session_start();
$postdata = file_get_contents("php://input");
$postimg=json_decode($postdata,true);
$midpath="upimages/".'13'.date('w');
$basename=date("YmdHis").rand(10000,99999);
$marwebpath=dirname(dirname(__FILE__));
if(!file_exists($midpath)){
mkdir($midpath,0774);
chmod($midpath,0774);
mkdir($midpath."/_ico",0774);
chmod($midpath."/_ico",0774);
}
set_time_limit(200);
if(isset($postimg['pngimg'])){
$data = $postimg['pngimg'];
$encodedData = str_replace(' ','+',$data);
$image=base64_decode($encodedData);
$filename=rand(10000,99999)."temp.jpg";
$fp = fopen('tmp/'.$filename, 'w');
if(!$fp){
echo "error|temp dir is not create temp file!";
exit;
}
fwrite($fp, $image);
fclose($fp);
list($width, $height, $type, $attr)=getimagesize("tmp/".$filename);
if($type!=3&&$type!=2&&$type!=1){
echo "error|not png or jpg file to up!";
exit;
}
switch ($type) {
case 1:
$impng = imagecreatefromgif("tmp/".$filename);
break;
case 2:
$impng = imagecreatefromjpeg("tmp/".$filename);
break;
case 3:
$impng = imagecreatefrompng("tmp/".$filename);
break;
}
if(!empty($postimg['orn'])) {
switch($postimg['orn']) {
case 8:
$impng = imagerotate($impng,90,0);
$tor=$height;
$height=$width;
$width=$tor;
break;
case 3:
$impng = imagerotate($impng,180,0);
break;
case 6:
$impng = imagerotate($impng,-90,0);
$tor=$height;
$height=$width;
$width=$tor;
break;
}
}
$extfile=".jpg";
if($type==1){
if (!copy('tmp/'.$filename,$midpath."/".$basename.".gif")) {
echo "error|not move gif file !";
exit;
}
$extfile=".gif";
$im=$impng;
}else{
$im = imagecreatetruecolor($width, $height);
imagecopyresampled($im, $impng, 0, 0, 0, 0, $width, $height, $width,$height);
ImageJpeg($im,$midpath."/".$basename.".jpg",90);
ImageDestroy ($impng);
}
unlink('tmp/'.$filename);
}else{
echo "error|post empty file!";
exit;
}
//////////////////////////////////
echo $imgpic="upimages/13".date("w")."/".$basename.$extfile."|upimages/13".date("w")."/".$basename.$extfile;
?>