-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
178 lines (154 loc) · 3.85 KB
/
admin.php
File metadata and controls
178 lines (154 loc) · 3.85 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
session_start();
if($_SESSION['email']==null)
header('Location:admin_signin.html');
$DB_Username="admin";
$DB_Password="asdfg";
$DB_Name="Photos";
mysql_connect('127.0.0.1',$DB_Username,$DB_Password);
@mysql_select_db($DB_Name) or die( "Unable to select database");
?>
<html>
<head>
<title>Hello <?php echo $_SESSION['email'] ?></title>
<link href="CSS/mainstyle.css" rel="stylesheet" type="text/css">
<style>
div.addgif{
/*padding:15px;*/
margin: 15px;
}
div.allgif{
margin: 15px;
}
h2{
margin-left:0;
}
table{
margin:0 0 150px 0;
}
tr.header{
text-align:center;
}
td{
margin 10px;
padding:0 10px;
border:solid 1px #CCC;
}
img.thumb{
width:60;
height:30;
overflow:hidden;
}
</style>
</head>
<body>
<div class="main">
<div class="background">
<div class="cover">
</div>
<div class="all_menu">
<a class="menu" href="admin.php">Admin</a>
<a class="menu" href="download.php">Download</a>
<a class="menu" href="showsearch.php">Show Search</a>
<a class="menu" href="index.php">Reaction Site</a>
</div>
<div class="addgif">
<form action="PHP/addgif.php" method="post" enctype="multipart/form-data">
<h2>Name</h2>
<input type="text" name="Name">
<h2>URL</h2>
<input type="text" name="URL">
<input type="file" name="file" id="file" onchange="alert(this.files[0].size/1000 + 'KB')"><br>
<h2>Tags: Saperate tags with "," </h2>
<input type="text" name="Tags"><br>
<input type="submit" name="submit" value="Submit" >
</form>
</div>
<?php
if(isset($_GET['top']))
{
$top=htmlspecialchars(mysql_real_escape_string(stripslashes(intval($_GET['top']))));
$Id=htmlspecialchars(mysql_real_escape_string(stripslashes(intval($_GET['id']))));
if($top==1)
$query = "UPDATE data SET Top = 0 WHERE Id = " . $Id .";";
else
$query = "UPDATE data SET Top = 1 WHERE Id = " . $Id .";";
mysql_query($query);
}
$sql = "SELECT count(*) FROM data where top=1;";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$top_rows = $row[0];
$query = "SELECT * FROM data ORDER BY Date DESC;";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
?>
<div class="allgif">
<h2>All Gif: number of record "<?php echo "$num\" and Top \"$top_rows" ?>"</h2>
<form action="PHP/delgif.php" method="post">
<input type="submit" value="Delete" />
<table>
<tr class="header">
<td></td>
<td><h2>Id</h2></td>
<td><h2>Name</h2></td>
<td><h2>Views</h2></td>
<td><h2>Tags</h2></td>
<td><h2>Date</h2></td>
<td><h2>Admin</h2></td>
<td><h2>Image</h2></td>
<td><h2>Top</h2></td>
</tr>
<?php
while($num>$i){
$Id=mysql_result($result,$i,"Id");
$Name=mysql_result($result,$i,"Name");
$Views=mysql_result($result,$i,"Views");
$Date=mysql_result($result,$i,"Date");
$Admin=mysql_result($result,$i,"Admin");
$path=mysql_result($result,$i,"Path");
$top=mysql_result($result,$i,"Top");
$newpath=explode("/",$path);
$newpath="admin/".$newpath[1];
echo "<tr>";
echo "<td><input type='checkbox' name='del[]' value='$Id!$path'/></td>";
echo "<td>$Id</td>";
echo "<td>$Name</td>";
echo "<td>$Views</td>";
$sql = "SELECT Tag from tags WHERE Id = $Id;";
$res = mysql_query($sql);
$row = mysql_fetch_row($res);
$num1=mysql_num_rows($res);
$j=0;
echo "<td>";
while($num1>$j)
{
$Tag=mysql_result($res,$j,"Tag");
if($num1==$j+1)//to store the tag without the last char "coma"
{
echo "$Tag";
break;
}
echo "$Tag, ";
$j++;
}
echo "</td>";
echo "<td>$Date</td>";
echo "<td>$Admin</td>";
echo "<td><a href=\"index.php?id=$Id\" target=\"_blank\"><img src='$newpath' class='thumb'></td></a>";
if($top=='1')
echo "<td><a href='admin.php?id=$Id&top=1'>Yes</a></td>";
else
echo "<td><a href='admin.php?id=$Id&top=0'>No</a></td>";
echo "</tr>";
$i++;
}
?>
</form>
</table>
</div>
</div>
</div>
</body>
</html>