annotate print.php @ 565:ed2247111fdd

Bump copyright years.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Mar 2014 17:08:33 +0200
parents 6b4cbd590d35
children ce11ea112a65
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
565
ed2247111fdd Bump copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 561
diff changeset
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
95
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
12 $pageCSS = "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
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
25
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
26 cmPrintPageHeader("Error");
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
27 echo "<h1>Permission denied</h1>\n".
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
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
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
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
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
34
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
35 //
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
36 // Initialize
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
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
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
46 //
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
47 // Handle request
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
48 //
380
0c7b301742bd Oops^2.
Matti Hamalainen <ccr@tnsp.org>
parents: 379
diff changeset
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"]." &lt;".$item["email"]."&gt;";
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
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
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
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
99 // This funny code is to ensure that the cells are of uniform width
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
100 printf("<td><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
101 "<span class=\"keycode\">%s</span></td>\n",
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
102 $item["id"],
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
103 str_repeat("&nbsp;", $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 ?>