1 | <?php
|
---|
2 | {
|
---|
3 | function PrintForm()
|
---|
4 | {
|
---|
5 | if (empty($_GET["fTable"]))
|
---|
6 | {
|
---|
7 | printf("ERROR - No table selected.\n");
|
---|
8 | return;
|
---|
9 | }
|
---|
10 | }
|
---|
11 |
|
---|
12 | function PrintPage($html, $host, $user, $pw, $db, $limits, $rms)
|
---|
13 | {
|
---|
14 | if (empty($_GET["fTable"]))
|
---|
15 | {
|
---|
16 | printf("ERROR - No table selected.\n");
|
---|
17 | return;
|
---|
18 |
|
---|
19 | }
|
---|
20 |
|
---|
21 | $db_id = mysql_connect($host, $user, $pw);
|
---|
22 | if ($db_id==FALSE)
|
---|
23 | {
|
---|
24 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
25 | die("");
|
---|
26 | }
|
---|
27 | mysql_select_db($db);
|
---|
28 |
|
---|
29 | $fromtable=$_GET["fTable"];
|
---|
30 | $query0 = "SELECT SQL_CALC_FOUND_ROWS * FROM " . $fromtable;
|
---|
31 | if (!empty($_GET["fSortBy"]))
|
---|
32 | {
|
---|
33 | $val=substr($_GET["fSortBy"], 0, -1);
|
---|
34 | $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
|
---|
35 | if (substr($_GET["fSortBy"], -1)=="-")
|
---|
36 | $query0 .= "DESC";
|
---|
37 | }
|
---|
38 |
|
---|
39 |
|
---|
40 | $result0 = mysql_query($query0, $db_id);
|
---|
41 | $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
|
---|
42 |
|
---|
43 | if ($result0)
|
---|
44 | {
|
---|
45 | if ($html=="1")
|
---|
46 | {
|
---|
47 | $alias = array
|
---|
48 | (
|
---|
49 | );
|
---|
50 | $rightalign = array
|
---|
51 | (
|
---|
52 | );
|
---|
53 | PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
|
---|
54 | }
|
---|
55 | else
|
---|
56 | PrintText($result0);
|
---|
57 |
|
---|
58 | mysql_free_result($result0);
|
---|
59 | mysql_free_result($result1);
|
---|
60 | }
|
---|
61 | mysql_close($db_id);
|
---|
62 |
|
---|
63 | if ($html=="1")
|
---|
64 | PrintSubmittedQuery($query0, $db, "old");
|
---|
65 | }
|
---|
66 |
|
---|
67 | include ("include.php");
|
---|
68 | include ("db.php");
|
---|
69 | include ("magicdefs.php");
|
---|
70 |
|
---|
71 | ini_set("display_errors", "On");
|
---|
72 | ini_set("mysql.trace_mode", "On");
|
---|
73 |
|
---|
74 | if (!empty($_GET["fSendTxt"]))
|
---|
75 | {
|
---|
76 | header("Content-type: application/octet");
|
---|
77 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
78 |
|
---|
79 | PrintPage("0", $host, $user, $pw, $db, "", "");
|
---|
80 | }
|
---|
81 | else
|
---|
82 | {
|
---|
83 | echo (file_get_contents("index-header.html"));
|
---|
84 |
|
---|
85 | $environment = sizeof($_GET);
|
---|
86 |
|
---|
87 | PrintForm($_GET);
|
---|
88 |
|
---|
89 | if ($environment==0)
|
---|
90 | printf("No query submitted yet.<BR>");
|
---|
91 | else
|
---|
92 | PrintPage("1", $host, $user, $pw, $db, "", "");
|
---|
93 |
|
---|
94 | echo (file_get_contents("index-footer.html"));
|
---|
95 | }
|
---|
96 |
|
---|
97 | ini_set("display_errors", "Off");
|
---|
98 | ini_set("mysql.trace_mode", "Off");
|
---|
99 | }
|
---|
100 | ?>
|
---|