Mercurial > hg > fapweb
annotate print.php @ 95:d9de08fb5b28
Work on hardcopy/votekey list printing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 18 Oct 2013 20:29:24 +0300 |
parents | b58a36f4821e |
children | 7d9e8c82e744 |
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 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 // Printing / hardcopy output helper module |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 $sessionType = "admin"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 require "mconfig.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 require "msite.inc.php"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
8 require "mcommon.inc.php"; |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 require "msession.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
11 $pageCSS = "hardcopy.css"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
12 |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 // Check if we are allowed to execute |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
14 if (!stCheckHTTPS() || !stAdmSessionAuth(TRUE)) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 stSetupCacheControl(); |
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 stSessionEnd(SESS_ADMIN); |
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 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 exit; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 // Initiate SQL database connection |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 if (!stConnectSQLDB()) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 die("Could not connect to SQL database."); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 // Fetch non-"hardcoded" settings from SQL database |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 stReloadSettings(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 if (stChkRequestItem("type")) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 $type = $_REQUEST["type"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 switch ($type) |
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 case "email": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 // Generic e-mail data dump |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
42 $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
|
43 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
45 cmPrintPageHeader("E-mails"); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 $out1 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 $out2 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 foreach ($res as $item) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 $out1[] = $item["name"]." <".$item["email"].">"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 $out2[] = $item["email"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
55 echo |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
56 implode(", ", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
57 implode("<br />", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
58 implode(", ", $out2)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
59 implode("<br />", $out2)."<br /><hr />\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
60 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
61 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 case "votekeys": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
67 // Print out votekeys as a table |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
69 $sql = "SELECT * FROM votekeys ORDER BY id ASC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
70 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
72 cmPrintPageHeader("Votekeys"); |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
73 $keyLen = stGetSetting(""); |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
74 echo "<table class=\"votekeys\">\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
75 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
76 foreach ($res as $item) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
77 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
78 if ($index == 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
79 echo "<tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
80 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
81 printf("<td><span class=\"keyid\">%03d</span> : <span class=\"keycode\">%-".$keyLen."s</span></td>\n", |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
82 $item["id"], $item["key"]); |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
83 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
84 if ($index++ >= 5) |
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 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
87 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
88 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
89 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
90 if ($index > 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
91 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
92 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
93 echo "</table>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
94 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 default: |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 ?> |