-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneratepremium.php
56 lines (43 loc) · 1.53 KB
/
generatepremium.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
<?php
/*
Copyright (C) 2008-2009 Gilles Dubuc (www.kouiskas.com - [email protected])
Generates a premium code manually
*/
require_once(dirname(__FILE__).'/entities/premiumcode.php');
require_once(dirname(__FILE__).'/entities/user.php');
require_once(dirname(__FILE__).'/entities/userlevellist.php');
require_once(dirname(__FILE__).'/utilities/page.php');
require_once(dirname(__FILE__).'/utilities/string.php');
require_once(dirname(__FILE__).'/utilities/ui.php');
require_once(dirname(__FILE__).'/constants.php');
require_once(dirname(__FILE__).'/settings.php');
$user = User::getSessionUser();
$levels = UserLevelList::getByUid($user->getUid());
if (!in_array($USER_LEVEL['ADMINISTRATOR'], $levels)) {
header('Location: '.$PAGE['PREMIUM'].'?lid='.$user->getLid());
exit(0);
}
$page = new Page('PREMIUM', 'HOME', $user);
$page->startHTML();
echo '<div class="hint hintmargin">',
'<div class="hint_title">',
'<translate id="GENERATE_PREMIUM_HINT_TITLE">',
'Generate premium membership code',
'</translate>',
'</div> <!-- hint_title -->',
'</div> <!-- hint -->',
'<form class="generate" method="post">',
'Validity duration (in days): ',
'<input name="duration" value="" type="text" maximum="10" numerical="true" />',
'<input id="generate_submit" type="submit" value="Generate">',
'</form>',
'<div id="code">';
if (isset($_REQUEST['duration'])) {
$duration = 86400 * $_REQUEST['duration'];
$code = new PremiumCode($duration);
echo $code->getDisplayCode();
}
echo '</div> <!-- code -->';
$page->endHTML();
$page->render();
?>