/
do.php
115 lines (100 loc) · 2.85 KB
/
do.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
105
106
107
108
109
110
111
112
113
114
115
<?php
include_once('lib/common.function.php' );
if($f=_get('a')){
if($f!='login')check_user();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
if($f=_get('b')){
if($f!='user_add')user_add();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
if($f=_get('c')){
if($f!='logout')logout();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
if($f=_get('d')){
if($f!='comment_add')comment_add();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
if($f=_get('s')){
if($f!='get_search')get_search();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
if($f=_get('s')){
if($f!='get_search')get_search();
if(function_exists ($f)){
call_user_func($f);
}else{
return ajax_echo('no method:'.$f);
}
}
//展示图片
// 连接数据库
$conn=@mysql_connect("localhost","root","") or die(mysql_error());
@mysql_select_db('fat',$conn) or die(mysql_error());
// 判断action
$action = isset($_REQUEST['action'])? $_REQUEST['action'] : '';
if($action=='add'){
$title = $_POST['title'];
$image = mysql_escape_string(file_get_contents($_FILES['photo']['tmp_name']));
$type = $_FILES['photo']['type'];
$sqlstr = "insert into photo(cid,type,title,binarydata) values('1','".$type."','".$title."','".$image."')";
@mysql_query($sqlstr) or die(mysql_error());
header('location:pic.php');
exit();
// 显示图片
}elseif($action=='show'){
$id = isset($_GET['id'])? intval($_GET['id']) : 0;
$sqlstr = "select * from photo where id=$id";
$query = mysql_query($sqlstr) or die(mysql_error());
$thread = mysql_fetch_assoc($query);
if($thread){
header('content-type:'.$thread['type']);
echo $thread['binarydata'];
exit();
}
}
// 判断action
$arti = isset($_REQUEST['arti'])? $_REQUEST['arti'] : '';
//插入图片
if($arti=='add'){
$title = $_POST['title'];
$image = mysql_escape_string(file_get_contents($_FILES['photo']['tmp_name']));
$type = $_FILES['photo']['type'];
$sqlstr = "insert into article(cid,type,title,content,binarydata) values('1','".$type."','".$title."','".$content."','".$image."')";
@mysql_query($sqlstr) or die(mysql_error());
header('location:pic.php');
exit();
// 显示图片
}elseif($arti=='show'){
$id = isset($_GET['id'])? intval($_GET['id']) : 0;
$sqlstr = "select * from article where id=$id";
$query = mysql_query($sqlstr) or die(mysql_error());
$thread = mysql_fetch_assoc($query);
if($thread){
header('content-type:'.$thread['type']);
echo $thread['img'];
exit();
}
}
?>