Mercurial > hg > fapweb
annotate print.php @ 1074:48e16e856646
Use long tags.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 17:57:38 +0200 |
parents | 7da8bde9b7be |
children | ebb0afda63c5 |
rev | line source |
---|---|
1074 | 1 <?php |
91
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 |
1072 | 5 // (C) Copyright 2012-2017 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 stSessionEnd(SESS_ADMIN); |
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"); | |
720 | 25 echo |
26 "<h1>Permission denied</h1>\n". | |
27 "<p>You need to be logged in as administrator to access this data.</p>\n". | |
28 "<p><a href=\"admin.php\">Click here for login form</a></p>\n"; | |
122 | 29 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 exit; |
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 |
147 | 33 |
34 // | |
35 // Initialize | |
36 // | |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 if (!stConnectSQLDB()) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 die("Could not connect to SQL database."); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 stReloadSettings(); |
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 |
147 | 45 // |
46 // Handle request | |
47 // | |
380 | 48 switch (stGetRequestItem("type", "", TRUE)) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 { |
512
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
50 case "results": |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
51 header("Content-Type: text/plain"); |
792
b42b23073209
Improve printing of results with more options (in the admin interface).
Matti Hamalainen <ccr@tnsp.org>
parents:
733
diff
changeset
|
52 echo stGetCompoResultsASCIIStr(FALSE, intval(stGetRequestItem("flags", RFLAG_NORMAL))); |
512
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
53 break; |
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
380
diff
changeset
|
54 |
272
cd3283333ec1
Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents:
175
diff
changeset
|
55 case "emails": |
91
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 // Generic e-mail data dump |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 // |
653
5ed91fb08165
Possibly fix an SQL syntax incompability SQLite vs. Postgres.
Matti Hamalainen <ccr@tnsp.org>
parents:
591
diff
changeset
|
59 $sql = "SELECT * FROM attendees WHERE email IS NOT NULL AND email != '' ORDER BY regtime DESC"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
60 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
62 cmPrintPageHeader("E-mails"); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 $out1 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 $out2 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 foreach ($res as $item) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 $out1[] = $item["name"]." <".$item["email"].">"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 $out2[] = $item["email"]; |
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 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
72 echo |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
73 implode(", ", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
74 implode("<br />", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
75 implode(", ", $out2)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
76 implode("<br />", $out2)."<br /><hr />\n"; |
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 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 case "votekeys": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
84 // Print out votekeys as a table |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
86 $sql = "SELECT * FROM votekeys ORDER BY id ASC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
87 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
89 cmPrintPageHeader("Votekeys"); |
122 | 90 $keyLen = stGetSetting("userKeyLength"); |
1020
2a259e243350
Don't use a HTML table for the votekeys.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
91 echo "<div class=\"votekeys\">\n"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
92 foreach ($res as $item) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
93 { |
122 | 94 // This funny code is to ensure that the cells are of uniform width |
1020
2a259e243350
Don't use a HTML table for the votekeys.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
95 printf("<div class=\"votekey\"><span class=\"keyid\">%03d</span> : ". |
2a259e243350
Don't use a HTML table for the votekeys.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
96 "<span class=\"keycode\">%s</span></div>\n", |
122 | 97 $item["id"], |
98 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
|
99 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
100 |
1020
2a259e243350
Don't use a HTML table for the votekeys.
Matti Hamalainen <ccr@tnsp.org>
parents:
1001
diff
changeset
|
101 echo "</div>\n"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
102 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 default: |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 ?> |