annotate print.php @ 175:8df523e6326a

User require_once instead of require.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 Nov 2013 10:27:57 +0200
parents 63c840590476
children cd3283333ec1
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
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";
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";
174
63c840590476 Move common code from mcommon.inc.php to msitegen module.
Matti Hamalainen <ccr@tnsp.org>
parents: 147
diff changeset
13 cmLocaleInit();
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".
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
29 "<p><a href=\"admin\">Click here for login form</a></p>\n";
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 //
91af5b225fd6 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
49 switch (stGetRequestItem("type"))
91
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 case "email":
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 //
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 // Generic e-mail data dump
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 $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
56 if (($res = stExecSQL($sql)) !== FALSE)
91
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 {
95
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
58 cmPrintPageHeader("E-mails");
91
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 $out1 = array();
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 $out2 = array();
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 foreach ($res as $item)
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 {
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 $out1[] = $item["name"]." &lt;".$item["email"]."&gt;";
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 $out2[] = $item["email"];
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
95
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
68 echo
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
69 implode(", ", $out1)."<br /><hr /><br />\n".
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
70 implode("<br />", $out1)."<br /><hr /><br />\n".
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
71 implode(", ", $out2)."<br /><hr /><br />\n".
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
72 implode("<br />", $out2)."<br /><hr />\n";
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
73
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
74 cmPrintPageFooter();
91
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 }
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 break;
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 case "votekeys":
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 // Print out votekeys as a table
91
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 //
95
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
82 $sql = "SELECT * FROM votekeys ORDER BY id ASC";
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
83 if (($res = stExecSQL($sql)) !== FALSE)
91
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 cmPrintPageHeader("Votekeys");
122
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
86 $keyLen = stGetSetting("userKeyLength");
95
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
87 echo "<table class=\"votekeys\">\n";
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
88 $index = 0;
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
89 foreach ($res as $item)
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
90 {
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
91 if ($index == 0)
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
92 echo "<tr>\n";
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
93
122
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
94 // 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
95 printf("<td><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
96 "<span class=\"keycode\">%s</span></td>\n",
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
97 $item["id"],
7d9e8c82e744 Work on votekey printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 95
diff changeset
98 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
99
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
100 if ($index++ >= 5)
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
101 {
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 $index = 0;
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 }
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
106 if ($index > 0)
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
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
109 echo "</table>\n";
d9de08fb5b28 Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
110 cmPrintPageFooter();
91
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 }
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 break;
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 default:
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 stSetStatus(404, "Not Found");
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 break;
b58a36f4821e Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 }
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 ?>