Mercurial > hg > fapweb
annotate print.php @ 136:aeebfedb5709
Add some copyright headers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 22:04:22 +0300 |
parents | 7d9e8c82e744 |
children | 91af5b225fd6 |
rev | line source |
---|---|
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 <? |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 // |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
122
diff
changeset
|
3 // FAPWeb Simple Demoparty System |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
122
diff
changeset
|
4 // Data printout / hardcopy output module |
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
122
diff
changeset
|
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 $sessionType = "admin"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 require "mconfig.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 require "msite.inc.php"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
10 require "mcommon.inc.php"; |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 require "msession.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
13 $pageCSS = "hardcopy.css"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
14 |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 // Check if we are allowed to execute |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
16 if (!stCheckHTTPS() || !stAdmSessionAuth(TRUE)) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 stSessionEnd(SESS_ADMIN); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 stSetStatus(404, "Not Found"); |
122 | 23 |
24 cmPrintPageHeader("Error"); | |
25 echo "<h1>Permission denied</h1>\n". | |
26 "<p>You need to be logged in as administrator to access this data.</p>\n". | |
27 "<p><a href=\"admin\">Click here for login form</a></p>\n"; | |
28 cmPrintPageFooter(); | |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 exit; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 // Initiate SQL database connection |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 if (!stConnectSQLDB()) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 die("Could not connect to SQL database."); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 // Fetch non-"hardcoded" settings from SQL database |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 stReloadSettings(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 if (stChkRequestItem("type")) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 $type = $_REQUEST["type"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 switch ($type) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 case "email": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 // Generic e-mail data dump |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
50 $sql = "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
51 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
53 cmPrintPageHeader("E-mails"); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 $out1 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 $out2 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 foreach ($res as $item) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 $out1[] = $item["name"]." <".$item["email"].">"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 $out2[] = $item["email"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
63 echo |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
64 implode(", ", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
65 implode("<br />", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
66 implode(", ", $out2)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
67 implode("<br />", $out2)."<br /><hr />\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
68 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
69 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 case "votekeys": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
75 // Print out votekeys as a table |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
77 $sql = "SELECT * FROM votekeys ORDER BY id ASC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
78 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
80 cmPrintPageHeader("Votekeys"); |
122 | 81 $keyLen = stGetSetting("userKeyLength"); |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
82 echo "<table class=\"votekeys\">\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
83 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
84 foreach ($res as $item) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
85 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
86 if ($index == 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
87 echo "<tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
88 |
122 | 89 // This funny code is to ensure that the cells are of uniform width |
90 printf("<td><span class=\"keyid\">%03d</span> : ". | |
91 "<span class=\"keycode\">%s</span></td>\n", | |
92 $item["id"], | |
93 str_repeat(" ", $keyLen - strlen($item["key"])).$item["key"]); | |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
94 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
95 if ($index++ >= 5) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
96 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
97 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
98 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
99 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
100 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
101 if ($index > 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
102 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
103 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
104 echo "</table>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
105 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 default: |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 ?> |