-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.php
More file actions
executable file
·77 lines (55 loc) · 1.7 KB
/
func.php
File metadata and controls
executable file
·77 lines (55 loc) · 1.7 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
<?php
if(!defined('FS_ROOT'))
die('access denided (func file)');
/** ФУНКЦИЯ GETVAR */
function getVar(&$varname, $defaultVal = '', $type = ''){
if(!isset($varname))
return $defaultVal;
if(strlen($type))
settype($varname, $type);
return $varname;
}
function href($href){
$href = str_replace('?', '&', $href);
return 'index.php'.(!empty($href) ? '?r='.$href : '');
}
/** RELOAD */
function reload(){
$url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
header('location: '.$url);
exit();
}
/** REDIRECT */
function redirect($href){
header('location: '.href($href));
exit();
}
// ПОЛУЧИТЬ HTML INPUT СОДЕРЖАЩИЙ FORMCODE
function getFormCodeInput(){
if(!isset($_SESSION['su']['userFormChecker']))
$_SESSION['su']['userFormChecker'] = array('current' => 0, 'used' => array());
$_SESSION['su']['userFormChecker']['current']++;
return '<input type="hidden" name="formCode" value="'.$_SESSION['su']['userFormChecker']['current'].'" />';
}
// ПРОВЕРКА ВАЛИДНОСТИ ФОРМЫ
function checkFormDuplication(){
if(isset($_POST['allowDuplication']))
return TRUE;
if(!isset($_POST['formCode'])){
trigger_error('formCode не передан', E_USER_ERROR);
return FALSE;
}
$formcode = (int)$_POST['formCode'];
if(!Config::get('check_form_duplication'))
return TRUE;
if(!$formcode)
return FALSE;
if(!isset($_SESSION['userFormChecker']['used']))
return TRUE;
return !isset($_SESSION['userFormChecker']['used'][$formcode]);
}
// ПОМЕТИТЬ FORMCODE ИСПОЛЬЗОВАННЫМ
function lockFormCode(&$code){
if(Config::get('check_form_duplication') && !empty($code))
$_SESSION['userFormChecker']['used'][$code] = 1;
}