This repository was archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.php
More file actions
90 lines (77 loc) · 3.01 KB
/
client.php
File metadata and controls
90 lines (77 loc) · 3.01 KB
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
<?php
/**
* Client page
*
* @copyright The ImpressCMS Project
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @since 1.0
* @author Phoenyx <phoenyx@impresscms.de>
* @package banners
* @version $Id$
*/
/**
* edit a client
*
* @param int $banner_id Bannerid to be edited
* @param bool $hideForm hide the form by default
* @global object $banners_client_handler client handler
* @global object $icmsTpl template ojbect
*/
function editclient($client_id = 0, $hideForm = FALSE) {
global $banners_client_handler, $icmsTpl;
$clientObj = $banners_client_handler->get($client_id);
$clientObj->setVar('uid', icms::$user->getVar('uid'));
$clientObj->setVar('email', icms::$user->getVar('email'));
$clientObj->hideFieldFromForm(array('uid', 'since', 'active'));
$sform = $clientObj->getForm('', 'addclient');
$sform->assign($icmsTpl, 'banners_clientform');
$icmsTpl->assign('lang_clientform_title', _MD_BANNERS_CLIENT_CREATE);
$icmsTpl->assign('hideForm', $hideForm);
}
include_once 'header.php';
if (!is_object(icms::$user)) redirect_header(icms_getPreviousPage(ICMS_URL), 3, _NOPERM);
$xoopsOption['template_main'] = 'banners_client.html';
include_once ICMS_ROOT_PATH . '/header.php';
// check if a client is assigned to the current user
$banners_client_handler = icms_getModuleHandler('client', basename(dirname(__FILE__)), 'banners');
$client_id = $banners_client_handler->getUserClientId();
if ($client_id !== FALSE && $client_id > 0) {
$clientObj = $banners_client_handler->get($client_id);
if ($clientObj->getVar('active')) {
header("location: banner.php");
exit();
} else {
redirect_header(ICMS_URL, 3, _MD_BANNERS_CLIENT_NOTACTIVE);
}
}
/** Use a naming convention that indicates the source of the content of the variable */
$clean_op = '';
if (isset($_GET['op'])) $clean_op = $_GET['op'];
if (isset($_POST['op'])) $clean_op = $_POST['op'];
/** Create a whitelist of valid values, be sure to use appropriate types for each value
* Be sure to include a value for no parameter, if you have a default condition
*/
$valid_op = array ('addclient', '');
/** Only proceed if the supplied operation is a valid operation */
if (in_array($clean_op, $valid_op, TRUE)) {
switch ($clean_op) {
case 'addclient':
$controller = new icms_ipf_Controller($banners_client_handler);
$clientObj = $controller->storeFromDefaultForm(_MD_BANNERS_CLIENT_CREATED, _MD_BANNERS_CLIENT_MODIFIED, NULL);
// overwrite some data to make sure the user hasn't manipulated it in the source and store the object again
$clientObj->setVar('uid', icms::$user->getVar('uid'));
$clientObj->setVar('since', time());
$clientObj->setVar('active', 0);
$clientObj->store();
// send email to webmaster
$clientObj->notifyWebmaster();
redirect_header(ICMS_URL, 3, _MD_BANNERS_CLIENT_CREATED);
break;
default:
editclient(0);
}
} else {
header("location: " . BANNERS_URL);
exit();
}
include_once 'footer.php';