-
Notifications
You must be signed in to change notification settings - Fork 11
/
checkout.php
380 lines (321 loc) · 15.8 KB
/
checkout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php
require('sys/bootstrap.php');
$mylist = $_POST;
/* do we have GET parameters? (currently only used for contact) */
$myaction = $_GET;
/* load classes */
require_once($cfg->sys->basepath.'sys/class.CheckoutActions.php');
/* setup methods & objects */
$action = new CheckoutActions($cfg);
if (isset($cfg->dbusers->userlist) && $cfg->dbusers->userlist === true) {
require_once($cfg->sys->basepath.'sys/class.GetUsers.php');
$userHandle = new GetUsers($cfg);
$users = $userHandle->getUsers();
} else {
$users = false;
}
?>
<!doctype html>
<!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
<html class="no-js" lang="en" data-useragent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo strip_tags($cfg->translations['main_tagline'][$cfg->prefs->current_lang]) ?> - <?php echo __('Checkout') ?></title>
<link rel="stylesheet" href="css/foundation.css" />
<link rel="stylesheet" href="css/local.css" />
<link rel="stylesheet" href="css/local-print.css" media="print" />
<link rel="stylesheet" href="css/media.css" />
<link rel="stylesheet" href="css/foundation-icons/foundation-icons.css" />
<script src="js/vendor/modernizr.js"></script>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script src="js/local/simpleCart.custom.js"></script>
<script src="js/vendor/jquery.unveil.min.js"></script>
<script src="js/vendor/jquery.timeago.js"></script>
<script src="js/vendor/jquery.quicksearch.min.js"></script>
<script src="js/vendor/citeproc-js/xmldom.js"></script>
<script src="js/vendor/citeproc-js/citeproc.js"></script>
<script src="js/local/conduit.js"></script>
<script src="js/local/cite.js"></script>
</head>
<body>
<!-- Navigation -->
<nav class="top-bar" data-topbar>
<ul class="title-area">
<!-- Title Area -->
<li class="name">
<h1><a href="index.php"><?php echo $cfg->translations['main_tagline'][$cfg->prefs->current_lang] ?></a></h1>
</li>
<li class="toggle-topbar"><a class="i fi-arrow-left" href="index.php?lang=<?php echo $action->prefs->current_lang ?>"> Back</a></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="divider"></li>
<li><a class="i fi-arrow-left" href="index.php?lang=<?php echo $action->prefs->current_lang ?>"> <?php echo __('Back to journal selection') ?></a></li>
</ul>
</section>
</nav>
<!-- End Top Bar -->
<!-- Contact form (only when called with GET-parameter -->
<?php if($_GET && $_GET['action'] == 'contact') { ?>
<div class="row">
<div class="small-12 columns" style="padding-top:20px">
<h1><?php echo __('Send your feedback to the library') ?></h1>
</div>
</div>
<form name="Feedback" method="post" action="checkout.php">
<div class="row">
<div class="small-12 columns">
<label><?php echo __('Your e-mail') ?>
<?php
// If domain is empty, allow full emails; see also conduit.js
$allowed = ($cfg->mail->domain) ? 'mail_domain' : 'mail_all';
if ($users === false) {
$placeholder = ($cfg->mail->domain) ? __('your username') : __('Your e-mail address');
print '<input name="username" id="'.$allowed.'" placeholder="'.$placeholder.'" type="text"/>';
} else {
print '<select name="username">';
foreach ($users as $name=>$pw) {
print '<option>'.htmlentities($name).'</option>';
}
print' </select>';
}
?>
</label>
<small id="errorUsername" class="error" style="display:none"><?php echo __('Please, choose a name.') ?></small>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<label><?php echo __('Your feedback message') ?>
<textarea name="message" placeholder="<?php echo __('If you have any comments for us please put them here!'); ?>"><?php if (isset($_GET['message'])) { print $_GET['message']; } ?></textarea>
</label>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<!-- flag for POST (first page view contains POST values from cart; BEWARE: sending the form overwrites the values -->
<input type="hidden" name="mailer" value="true"/>
<input type="hidden" name="feedback" value="true"/>
<input type="hidden" name="lang" value="<?php echo $action->prefs->current_lang ?>">
<input class="radius button large right submit" type="submit" value="<?php echo __('Submit') ?>">
</div>
</div>
</form>
<?php } else { ?>
<!-- End Contact form -->
<div class="row" id="actionGreeter">
<div class="small-12 columns" style="padding-top:20px">
<h1><span id="topMenu"><?php echo __('I want to...') ?></span><span id="subMenu"></span></h1>
</div>
</div>
<!-- End Header and Nav -->
<div id="actions" class="row">
<div class="small-12 text-center columns">
<a id="printArticles" href="#" class="radius button large"><i class="fi-print"></i> <?php echo __('View & Print') ?></a>
<!--<a id="saveArticles" href="#" class="radius button large disabled"><i class="fi-save"></i> Save/Export</a>-->
<?php if(empty($_POST['mailer'])) { ?>
<a id="sendArticlesToUser" href="#" class="button radius large mailForm"><i class="fi-mail"></i> <?php echo __('Send to my mailbox') ?></a>
<?php if ($cfg->prefs->allow_ask_pdf) { ?>
<a id="sendArticlesToLib" href="#" class="button radius large mailForm"><i class="fi-mail"></i> <?php echo __('Send to library to get PDFs') ?></a>
<?php } ?>
<?php } else { ?>
<a id="sendDone" href="#" class="radius button large success"><i class="fi-check"></i> <?php echo __('You already sent your files') ?> </a>
<?php } ?>
<a id="resetActions" href="#" class="radius button large reset" style="display:none"><i class="fi-arrow-left"></i> <?php echo __('choose another option') ?></a>
<!--<a id="emptyCart" href="#" class="radius button large alert"><i class="fi-arrows-out"></i> Clear Data and Logout</a>-->
<a id="emptyCartConfirm" class="radius large alert button" data-reveal-id="emptyConfirm"><i class="fi-arrows-out"></i> <?php echo __('Clear Data and Logout') ?></a>
</div>
</div>
<!-- Security confirmation on delete -->
<div id="emptyConfirm" class="reveal-modal" data-reveal>
<h3><?php echo __('Do you really want to empty your basket?') ?></h3>
<a id="emptyCart" href="#" class="radius small alert button close-reveal-modal"><i class="fi-trash"></i> <?php echo __('OK, empty my basket!') ?></a>
<a id="DoNotemptyCartButton" class="radius small success button close-reveal-modal"><i class="fi-trash"></i> <?php echo __('No, keep basket!') ?></a>
</div>
<?php } /* end GET query */ ?>
<div id="emptyCartSuccess" class="row invisible">
<div class="small-12 text-center columns">
<div data-alert class="alert-box success radius">
<i class="fi-check"></i> <?php echo __('Your articles have been successfully deleted! You will automatically be taken to the start page.') ?>
<a href="#" class="close">×</a>
</div>
</div>
</div>
<div id="actionsResultBox">
<!-- Start Mailer Response -->
<?php
$file = '';
if(isset($_POST['mailer']))
{
// looks like we need to initialize PHPMailer
require_once($cfg->sys->basepath.'sys/PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer(true);
//$mail->SMTPDebug = 3; // Enable verbose debug output
if ($cfg->mail->useSMTP) {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $cfg->mail->smtpServer; // Specify main and backup SMTP servers
$mail->Port = $cfg->mail->smtpPort;
if ($cfg->mail->useSMTPAuth) {
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $cfg->mail->smtpUser; // SMTP username
$mail->Password = $cfg->mail->smtpPass; // SMTP password
if (!empty($cfg->mail->smtpSec)) { $mail->SMTPSecure = strtolower($cfg->mail->smtpSec); } // Enable TLS encryption, `ssl` also accepted
}
}
// if we have already sent an e-mail, read again from POST
$file = (empty($file) && isset($_POST['file'])) ? $file = $_POST['file'] : '';
/* pass the PHPMailer object & save the return value (success or failure?) */
/* is it feedback? */
if (isset($_POST['feedback'])) {
$mailerResponse = $action->sendFeedback($mail);
} else {
$mailerResponse = $action->sendArticlesAsMail($file, $mail);
}
/* error handling */
if ($mailerResponse == "OK") {
/* default, everything is alright */
?>
<div class="row">
<div class="small-12 text-center columns">
<div data-alert class="alert-box success radius">
<i class="fi-check"></i> <?php echo __('Your message has been successfully sent!') ?> <a href="#" class="close">×</a>
</div>
</div>
</div>
<?php
} else {
/* something went wrong */
?>
<div id="actions" class="row">
<div class="small-12 text-center columns">
<div data-alert class="alert-box warning radius">
<i class="fi-x"></i> <?php print $mailerResponse;?> <a href="#" class="close">×</a>
</div>
</div>
</div>
<!-- End Mailer Response -->
<!-- Start Mailer -->
<?php
}
} else { /* if no mail has been sent yet */
/* Mailer: show Form */
/* save selection by default */
if (empty($_GET) || (count($_GET) == 1 && isset($_GET['lang']))) { // do not show with any GET parameters
$action->saveArticlesAsCSV($mylist);
}
}
?>
<div id="mailForm" style="display:none">
<form name="Request" method="post" action="checkout.php">
<div class="row sendArticlesToLib sendArticlesToUser">
<?php
// if GetUsers failed or was turned off, allow entering an address
if ($users === false) {
$placeholder = ($cfg->mail->domain) ? __('your username') : __('Your e-mail');
$postfix = ($cfg->mail->domain) ? '@'.$cfg->mail->domain : '';
$coladd = ($cfg->mail->domain) ? 3 : 0;
// If domain is empty, allow full emails; see also conduit.js
$allowed = ($cfg->mail->domain) ? 'mail_domain' : 'mail_all';
echo'
<div class="row collapse">
<label for="'.$allowed.'">'.__('Your e-mail').'</label>
<div class="small-'.(12 - $coladd).' columns">
<input name="username" id="'.$allowed.'" placeholder="'.$placeholder.'" type="text" />
</div>';
// Add the allowed user mailing domain at the end ("employees only")
if ($coladd) {
echo ' <div class="small-'.$coladd.' columns">
<span class="postfix">'.$postfix.'</span>
</div>';
}
echo '</div>';
} else {
print '<select name="username">';
foreach ($users as $name=>$pw) {
print '<option>'.$name.'</option>';
}
print' </select>';
}
?>
</label>
<small id="errorUsername" class="error" style="display:none"><?php echo __('please choose a name') ?></small>
</div>
</div>
<div class="row sendArticlesToUser">
<div class="small-12 columns">
<label><?php echo __('Attach citations?') ?></label><!--<small class="error">beware: experimental feature</small>-->
<input type="radio" id="attachFileEndnote" name="attachFile" value="endnote"><label for="attachFileEndnote">Endnote/Citavi</label>
<!-- <input type="radio" id="attachFileBibTeX" name="attachFile" value="bibtex" disabled="disabled"><label for="attachFileBibTeX">BibTeX</label> -->
<input type="radio" id="attachFileCSV" name="attachFile" value="csv"><label for="attachFileBibTeX">CSV</label>
</div>
</div>
<div class="row sendArticlesToLib">
<div class="small-12 columns">
<label><?php echo __('Your message') ?>
<textarea name="message" placeholder="<?php echo __('if you have any comments for us please put them here!'); ?>"></textarea>
</label>
</div>
</div>
<div class="row sendArticlesToLib sendArticlesToUser">
<div class="small-12 columns">
<!-- flag for POST (first page view contains POST values from cart; BEWARE: sending the form overwrites the values -->
<input type="hidden" name="mailer" value="true"/>
<input type="hidden" name="file" value="<?php print $file; ?>"/>
<input type="hidden" name="lang" value="<?php echo $action->prefs->current_lang ?>"/>
<input type="hidden" name="action" id="cartAction" value=""/><!-- this one is important and is set from conduit.js! -->
<input class="radius button large right submit" type="submit" value="<?php echo __('Submit') ?>">
</div>
</div>
</form>
<!-- End Mailer -->
<!-- Start View -->
<div id="viewBox" class="printArticles" style="display:none">
<div class="row">
<div class="small-12 columns print">
<a href="javascript:window.print();" class="radius button large"><i class="fi-print"></i></a>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<?php if (empty($_GET) || (count($_GET) == 1 && isset($_GET['lang']))) { // do not show with any GET parameters
// if we have already sent an e-mail, read again from POST
if (empty($file)) {$file = $_POST['file'];}
print $action->getArticlesAsHTML($file);
}
?>
</div>
</div>
<!-- start external link -->
<div id="externalPopover" class="reveal-modal" data-reveal="">
<h3><?php echo __('External Source') ?></h3>
<a id="frameBack" class="button round" data-history="0" onclick="if ($(this).data('history') < history.length) history.go(-1)"><i class="fi-arrow-left"></i></a>
<a class="close-reveal-modal button radius">×</a>
<!-- For preventing browser history for the iframe "externalFrame" it is dynamically created in conduit.js -->
</div>
<!-- end external link -->
<!-- End View -->
<!-- Start Save/Export -->
<!-- not in use -->
<!--
<div id="saveDialog" style="display:none">
<div class="row">
<div class="small-12 columns">
</div>
</div>
-->
<!-- End Save/Export -->
</div>
</div>
<script>
$(document).foundation();
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
</script>
<!-- START Kiosk policies -->
<?php echo $cfg->sys->kioskPolicy_HTML ?>
<!-- END Kiosk policies -->
</body>
</html>