|
1
|
|
|
<?php namespace XoopsModules\Gbook; |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
/** |
|
12
|
|
|
* Gbook\Utility Class |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
16
|
|
|
* @author XOOPS Development Team |
|
17
|
|
|
* @package GBook |
|
18
|
|
|
* @since 1.03 |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
//namespace GBook; |
|
23
|
|
|
|
|
24
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
25
|
|
|
use XoopsModules\Gbook; |
|
26
|
|
|
use XoopsModules\Gbook\Common; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class Utility |
|
30
|
|
|
*/ |
|
31
|
|
|
class Utility |
|
32
|
|
|
{ |
|
33
|
|
|
use Common\VersionChecks; //checkVerXoops, checkVerPhp Traits |
|
34
|
|
|
|
|
35
|
|
|
use Common\ServerStats; // getServerStats Trait |
|
36
|
|
|
|
|
37
|
|
|
use Common\FilesManagement; // Files Management Trait |
|
38
|
|
|
|
|
39
|
|
|
//--------------- Custom module methods ----------------------------- |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param $name |
|
43
|
|
|
* @param $value |
|
44
|
|
|
* @return \XoopsFormDhtmlTextArea|\XoopsFormEditor |
|
45
|
|
|
*/ |
|
46
|
|
|
public static function getEditor($name, $value) |
|
47
|
|
|
{ |
|
48
|
|
|
global $xoopsUser, $xoopsModule, $xoopsModuleConfig; |
|
|
|
|
|
|
49
|
|
|
$options = []; |
|
50
|
|
|
$isAdmin = $xoopsUser->isAdmin($xoopsModule->getVar('mid')); |
|
51
|
|
|
|
|
52
|
|
|
if (class_exists('XoopsFormEditor')) { |
|
53
|
|
|
$options['name'] = $name; |
|
54
|
|
|
$options['value'] = $value; |
|
55
|
|
|
$options['rows'] = 5; |
|
56
|
|
|
$options['cols'] = '100%'; |
|
57
|
|
|
$options['width'] = '100%'; |
|
58
|
|
|
$options['height'] = '200px'; |
|
59
|
|
|
if ($isAdmin) { |
|
60
|
|
|
$descEditor = new \XoopsFormEditor(ucfirst($name), $xoopsModuleConfig['editorAdmin'], $options, $nohtml = false, $onfailure = 'textarea'); |
|
|
|
|
|
|
61
|
|
|
} else { |
|
62
|
|
|
$descEditor = new \XoopsFormEditor(ucfirst($name), $xoopsModuleConfig['editorUser'], $options, $nohtml = false, $onfailure = 'textarea'); |
|
63
|
|
|
} |
|
64
|
|
|
} else { |
|
65
|
|
|
$descEditor = new \XoopsFormDhtmlTextArea(ucfirst($name), $name, $value, '100%', '100%'); |
|
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
// $form->addElement($descEditor); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
return $descEditor; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param $nameTmp |
|
75
|
|
|
* @param $emailTmp |
|
76
|
|
|
* @param $urlTmp |
|
77
|
|
|
* @param $messageTmp |
|
78
|
|
|
* @return \XoopsThemeForm |
|
79
|
|
|
*/ |
|
80
|
|
|
public static function getSignForm($nameTmp, $emailTmp, $urlTmp, $messageTmp) |
|
81
|
|
|
{ |
|
82
|
|
|
$name = new \XoopsFormText(_MD_GBOOK_NAME, 'Name', 43, 100, $nameTmp); |
|
|
|
|
|
|
83
|
|
|
$email = new \XoopsFormText(_MD_GBOOK_EMAIL, 'Email', 43, 100, $emailTmp); |
|
84
|
|
|
$url = new \XoopsFormText(_MD_GBOOK_URL, 'URL', 43, 100, $urlTmp); |
|
85
|
|
|
$message = new \XoopsFormTextArea(_MD_GBOOK_MESSAGE, 'Message', $messageTmp); |
|
|
|
|
|
|
86
|
|
|
$submit = new \XoopsFormButton('', 'submit', _MD_GBOOK_SUBMIT, 'submit'); |
|
|
|
|
|
|
87
|
|
|
$gbookform = new \XoopsThemeForm(_MD_GBOOK_SIGN, 'gbookform', 'sign.php'); |
|
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
$gbookform->addElement($name, true); |
|
90
|
|
|
$gbookform->addElement($email); |
|
91
|
|
|
$gbookform->addElement($url); |
|
92
|
|
|
$gbookform->addElement($message, true); |
|
93
|
|
|
$gbookform->addElement(new \XoopsFormCaptcha(), true); |
|
|
|
|
|
|
94
|
|
|
$gbookform->addElement($submit); |
|
95
|
|
|
|
|
96
|
|
|
return $gbookform; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return string |
|
101
|
|
|
*/ |
|
102
|
|
|
public static function gbookIP() |
|
103
|
|
|
{ |
|
104
|
|
|
$ip = 'UNKNOWN'; |
|
105
|
|
|
if (getenv('HTTP_CLIENT_IP')) { |
|
106
|
|
|
$ip = getenv('HTTP_CLIENT_IP'); |
|
107
|
|
|
} else { |
|
108
|
|
|
if (getenv('HTTP_X_FORWARDED_FOR')) { |
|
109
|
|
|
$ip = getenv('HTTP_X_FORWARDED_FOR'); |
|
110
|
|
|
} else { |
|
111
|
|
|
if (getenv('REMOTE_ADDR')) { |
|
112
|
|
|
$ip = getenv('REMOTE_ADDR'); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
return $ip; |
|
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
} |
|
121
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths