-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathquery.php
More file actions
executable file
·85 lines (71 loc) · 1.93 KB
/
query.php
File metadata and controls
executable file
·85 lines (71 loc) · 1.93 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
<?php
include('config.php');
include('includes/functions.php');
include('includes/mysql_functions.php');
$sql = "SELECT url, title, clicks, http_code, size, type, modified, crawl_tag, (SELECT count(*) FROM links WHERE `to` = urls.ID) as incoming, (SELECT count(*) FROM links WHERE `to` = urls.ID) as outgoing from urls";
if ($_GET) {
$sql .= " WHERE `crawl_tag` = '$crawl_tag' AND ";
foreach ($_GET as $field=>$value) $sql .= " `$field` = '". urldecode($value) . "'";
} else {
$sql .= " WHERE `crawl_tag` = '$crawl_tag'";
}
$sql .= " LIMIT 300";
$pages = mysql_query($sql);
/**
* Count the number of pages in our dataset
*/
$count = mysql_num_rows($pages);
/**
* Get array of fields by parsing keys of first row array
*
* NOTE TO SELF: There is a better way to do this
*/
$fields = array_keys(mysql_fetch_assoc($pages));
?><table border='1'><?php
/**
* Print the header row and a new line charecter
*/
echo "\t<tr>\r\n";
foreach ($fields as $field) {
echo "\t\t<th>$field</th>\r\n";
}
echo "\t</tr>\r\n";
/**
* When we looped through to grab the field names, we moevd the internal pointer.
* Reset internal pointer so our loop includes the first row
*/
mysql_data_seek($pages,0);
/**
* Loop through the rows (pages)
*/
for ($i=0; $i < $count; $i++) {
echo "\t<tr>\r\n";
/**
* Fetch the row as an associative array
*/
$page = mysql_fetch_assoc($pages);
/**
* Loop through each field within the row
*/
foreach ($page as $key=>$field) {
echo "\t\t<td>";
/**
* If it the 'size', or 'modified' field, make it human readible, otherwise just output
*/
switch($key) {
case 'size':
echo file_size($field);
break;
case 'modified':
if ($field != '') echo date('Y-m-d H:i:s',$field);
break;
default:
echo $field;
break;
} //End switch
echo "</td>\r\n";
} //End Field
echo "\t</tr>\r\n";
} //End Row
?>
</table>