/
license.php
131 lines (106 loc) · 3.32 KB
/
license.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
<?php
/**
* Project: Welcompose
* File: license.php
*
* Copyright (c) 2008-2012 creatics, Olaf Gleba <og@welcompose.de>
*
* Project owner:
* creatics, Olaf Gleba
* 50939 Köln, Germany
* http://www.creatics.de
*
* This file is licensed under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE v3
* http://www.opensource.org/licenses/agpl-v3.html
*
* @author Andreas Ahlenstorf
* @package Welcompose
* @link http://welcompose.de
* @license http://www.opensource.org/licenses/agpl-v3.html GNU AFFERO GENERAL PUBLIC LICENSE v3
*/
// get loader
$path_parts = array(
dirname(__FILE__),
'..',
'core',
'loader.php'
);
$loader_path = implode(DIRECTORY_SEPARATOR, $path_parts);
require($loader_path);
// start base
/* @var $BASE base */
$BASE = load('base:base');
// deregister globals
$deregister_globals_path = dirname(__FILE__).'/../core/includes/deregister_globals.inc.php';
require(Base_Compat::fixDirectorySeparator($deregister_globals_path));
try {
// start output buffering
@ob_start();
// load smarty
$smarty_update_conf = dirname(__FILE__).'/smarty.inc.php';
$BASE->utility->loadSmarty(Base_Compat::fixDirectorySeparator($smarty_update_conf), true);
// load gettext
$gettext_path = dirname(__FILE__).'/../core/includes/gettext.inc.php';
include(Base_Compat::fixDirectorySeparator($gettext_path));
gettextInitSoftware($BASE->_conf['locales']['all']);
// start Base_Session
/* @var $SESSION session */
$SESSION = load('base:session');
// start new HTML_QuickForm
$FORM = $BASE->utility->loadQuickForm('license');
// apply filters to all fields
$FORM->addRecursiveFilter('trim');
// checkbox for confirm_license
$confirm_license = $FORM->addElement('checkbox', 'confirm_license',
array('id' => 'license_confirm_license', 'class' => 'chbx'),
array('label' => gettext('Confirm license'))
);
$confirm_license->addRule('required', gettext('Please confirm the license'));
$confirm_license->addRule('regex', gettext('Field license must be valued by 0 or 1'), WCOM_REGEX_ZERO_OR_ONE);
// submit button
$submit = $FORM->addElement('submit', 'submit',
array('class' => 'submit240nomargin', 'value' => gettext('Next step'))
);
// validate it
if (!$FORM->validate()) {
// render it
$renderer = $BASE->utility->loadQuickFormSmartyRenderer();
// fetch {function} template to set
// required/error markup on each form fields
$BASE->utility->smarty->fetch(dirname(__FILE__).'/quickform.tpl');
// assign the form to smarty
$BASE->utility->smarty->assign('form', $FORM->render($renderer)->toArray());
// display the form
define("WCOM_TEMPLATE_KEY", md5($_SERVER['REQUEST_URI']));
$BASE->utility->smarty->display('license.html', WCOM_TEMPLATE_KEY);
// flush the buffer
@ob_end_flush();
exit;
} else {
// freeze the form
$FORM->toggleFrozen(true);
// save input to session
$_SESSION['update'] = array();
$_SESSION['update']['license_confirm_license'] = true;
// redirect
$SESSION->save();
// clean the buffer
if (!$BASE->debug_enabled()) {
@ob_end_clean();
}
// redirect
header("Location: requirements.php");
exit;
}
} catch (Exception $e) {
// clean the buffer
if (!$BASE->debug_enabled()) {
@ob_end_clean();
}
// raise error
$BASE->error->displayException($e, $BASE->utility->smarty);
$BASE->error->triggerException($e);
// exit
exit;
}
?>