This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathold.index.php
103 lines (78 loc) · 2.86 KB
/
old.index.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
require_once("../includes/config.php");
require_once("../includes/functions.php");
db_connect();
require_login();
$WORKING_DIR = '../';
if (file_exists("../".get_phurl_option('theme_path') . "header.php")) {
include ("../".get_phurl_option('theme_path') . "header.php");
} else {
die ("<h2>Could not load theme</h2>");
}
print_errors();
$delete_id = (int) @$_GET['delete_id'];
if ($delete_id > 0) {
mysql_query("DELETE FROM ".DB_PREFIX."urls WHERE id = '$delete_id'") or db_die(__FILE__, __LINE__, mysql_error());
}
$page = (int) @$_GET['page'];
if ($page < 1) {
$page = 1;
}
$db_query = "1 AND ";
$search_alias = mysql_real_escape_string(@$_GET['search_alias']);
$search_url = mysql_real_escape_string(@$_GET['search_url']);
if (!empty($search_alias)) {
$db_query .= "(code = '$search_alias' OR alias = '$search_alias') AND ";
}
if (!empty($search_url)) {
$db_query .= "url LIKE '%$search_url%' AND ";
}
$db_query = substr($db_query, 0, -5);
$db_result = mysql_query("SELECT COUNT(id) FROM ".DB_PREFIX."urls WHERE $db_query") or db_die(__FILE__, __LINE__, mysql_error());
$db_row = mysql_fetch_row($db_result);
$db_count = (int) $db_row[0];
$db_start = ($page - 1) * 25;
$db_pages = ceil($db_count / 25);
$db_result = mysql_query("SELECT * FROM ".DB_PREFIX."urls WHERE $db_query ORDER BY date_added DESC LIMIT $db_start, 25") or db_die(__FILE__, __LINE__, mysql_error());
echo "<table id=\"url_list\">\n";
echo "<tr>\n".
"<td><u>ID</td></u>\n".
"<td><u>Code</u></td>\n".
"<td><u>Alias</u></td>\n".
"<td><u>Long URL</u></td>\n".
"<td><u>Date Added</u></td>\n".
"<td><u>Delete</u></td>\n".
"</tr>\n";
while ($db_row = mysql_fetch_assoc($db_result)) {
$db_row = array_filter($db_row, "stripslashes");
extract($db_row, EXTR_OVERWRITE|EXTR_PREFIX_ALL, "u");
if (empty($u_alias)) {
$u_alias = "";
}
echo
"<tr>\n".
"<td>$u_id</td>\n".
"<td>$u_code</td>\n".
"<td>" . htmlentities($u_alias) . "</td>\n".
"<td>" . htmlentities($u_url) . "</td>\n".
"<td>$u_date_added</td>\n".
"<td><a href=\"javascript:delete_url($u_id);\">Delete</a></td>\n".
"</tr>\n";
unset($u_id, $u_code, $u_alias, $u_url, $u_date_added);
}
echo "</table>\n";
if ($db_count > 25) {
echo "<p>\n";
if ($page > 1) {
echo "<a href=\"index.php?page=".($page - 1)."\">« Prev</a> ";
}
if ($page < $db_pages) {
echo "<a href=\"index.php?page=".($page + 1)."\">Next »</a>";
}
echo "</p>\n";
}
if (file_exists("../".get_phurl_option('theme_path') . "footer.php")) {
include ("../".get_phurl_option('theme_path') . "footer.php");
} else {
die ("<h2>Could not load theme</h2>");
}