Mercurial > hg > fapweb
annotate print.php @ 591:f7078755dff5
Fix CSS paths for admin and print pages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 17 Oct 2014 15:18:21 +0300 |
parents | ce11ea112a65 |
children | 5ed91fb08165 |
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 // |
571
ce11ea112a65
Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
565
diff
changeset
|
3 // FAPWeb - Simple Web-based Demoparty Management System |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
122
diff
changeset
|
4 // Data printout / hardcopy output module |
565 | 5 // (C) Copyright 2012-2014 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"; |
175
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
8 require_once "mconfig.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
9 require_once "msite.inc.php"; |
8df523e6326a
User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
10 require_once "msession.inc.php"; |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 |
591
f7078755dff5
Fix CSS paths for admin and print pages.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
12 $pageCSS = "css/hardcopy.css"; |
561
6b4cbd590d35
More locale initialization refactoring.
Matti Hamalainen <ccr@tnsp.org>
parents:
512
diff
changeset
|
13 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
14 |
147 | 15 // |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 // Check if we are allowed to execute |
147 | 17 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
18 if (!stCheckHTTPS() || !stAdmSessionAuth(TRUE)) |
91
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 stSetupCacheControl(); |
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 stSessionEnd(SESS_ADMIN); |
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 stSetStatus(404, "Not Found"); |
122 | 25 |
26 cmPrintPageHeader("Error"); | |
27 echo "<h1>Permission denied</h1>\n". | |
28 "<p>You need to be logged in as administrator to access this data.</p>\n". | |
339
9dd87c8de942
Fix a link to the admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
272
diff
changeset
|
29 "<p><a href=\"admin.php\">Click here for login form</a></p>\n"; |
122 | 30 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 exit; |
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 |
147 | 34 |
35 // | |
36 // Initialize | |
37 // | |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 stSetupCacheControl(); |
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 if (!stConnectSQLDB()) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 die("Could not connect to SQL database."); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 stReloadSettings(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
147 | 46 // |
47 // Handle request | |
48 // | |
380 | 49 switch (stGetRequestItem("type", "", TRUE)) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 { |
512
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
51 case "results": |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
52 header("Content-Type: text/plain"); |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
53 echo stGetCompoResultsASCIIStr(TRUE, FALSE); |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
54 break; |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
55 |
272
cd3283333ec1
Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
56 case "emails": |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 // Generic e-mail data dump |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
60 $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
|
61 if (($res = stExecSQL($sql)) !== FALSE) |
91
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 cmPrintPageHeader("E-mails"); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 $out1 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 $out2 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 foreach ($res as $item) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 $out1[] = $item["name"]." <".$item["email"].">"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 $out2[] = $item["email"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
73 echo |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
74 implode(", ", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
75 implode("<br />", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
76 implode(", ", $out2)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
77 implode("<br />", $out2)."<br /><hr />\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
78 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
79 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 case "votekeys": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
85 // Print out votekeys as a table |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
87 $sql = "SELECT * FROM votekeys ORDER BY id ASC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
88 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
90 cmPrintPageHeader("Votekeys"); |
122 | 91 $keyLen = stGetSetting("userKeyLength"); |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
92 echo "<table class=\"votekeys\">\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
93 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
94 foreach ($res as $item) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
95 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
96 if ($index == 0) |
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 |
122 | 99 // This funny code is to ensure that the cells are of uniform width |
100 printf("<td><span class=\"keyid\">%03d</span> : ". | |
101 "<span class=\"keycode\">%s</span></td>\n", | |
102 $item["id"], | |
103 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
|
104 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
105 if ($index++ >= 5) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
106 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
107 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
108 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
109 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
110 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
111 if ($index > 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
112 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
113 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
114 echo "</table>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
115 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 default: |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 ?> |