-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunks.php
72 lines (58 loc) · 1.68 KB
/
chunks.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TouchDevelop Queries results</title>
<link rel="stylesheet" href="css/style.css?v=1.0">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<?php
include_once 'lib/sqlFormatter.php';
include_once('api/config.php');
include_once('api/functions.php');
include_once('api/queries_list.php');
error_reporting(E_ALL);
$script_url = basename($_SERVER['PHP_SELF']);
$query = "select count(*) cnt, s.name, s.script_id,
group_concat(c.content SEPARATOR '\n<br />') chunks
from scripts_chunks sc
join chunks c on c.id = sc.chunk_id
join scripts s on s.id = sc.script_id
group by sc.script_id
having cnt > 3
ORDER BY `cnt` ASC";
//print_r($query);
//$url_field_names = array('tutorial_url', 'source_url');
print '<div class="sql">' . SqlFormatter::format( $query ) . '</div>';
$res = mysql_query($query);
$cols_count = mysql_num_fields($res);
$rows_count = mysql_num_rows($res);
$row_count = 0 ;
$fields = mysql_num_fields($res);
if($rows_count == 0) {
print "<h3>EMPTY</h3>";
} else {
print '<table border="1">';
for ($i=0; $i < $fields; $i++) {
print "<th>".mysql_field_name($res, $i)."</th>";
}
while( $row = mysql_fetch_row($res) ) {
echo "<tr>";
for ($f=0; $f < $cols_count; $f++) {
if(strpos($row[$f], "http://") === FALSE) {
echo "<td>{$row[$f]}</td>";
} else {
echo "<td><a href=\"{$row[$f]}\" target=\"_blank\">{$row[$f]}</a></td>";
}
}
echo "</tr>\n";
}
print "</table>";
}
print "<br />";
?>
</body>
</html>