This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * |
||
4 | * @package phpBB Extension - tas2580 Social Media Buttons |
||
5 | * @copyright (c) 2015 tas2580 (https://tas2580.net) |
||
6 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | namespace tas2580\socialbuttons\acp; |
||
11 | |||
12 | class socialbuttons_module |
||
13 | { |
||
14 | public $u_action; |
||
15 | |||
16 | public function main($id, $mode) |
||
0 ignored issues
–
show
|
|||
17 | { |
||
18 | global $config, $user, $template, $request; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
19 | |||
20 | $user->add_lang_ext('tas2580/socialbuttons', 'common'); |
||
21 | $this->tpl_name = 'acp_socialbuttons_body'; |
||
0 ignored issues
–
show
The property
tpl_name does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
22 | $this->page_title = $user->lang('ACP_SOCIALBUTTONS_TITLE'); |
||
0 ignored issues
–
show
The property
page_title does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
23 | |||
24 | add_form_key('acp_socialbuttons'); |
||
25 | |||
26 | // Form is submitted |
||
27 | if ($request->is_set_post('submit')) |
||
28 | { |
||
29 | if (!check_form_key('acp_socialbuttons')) |
||
30 | { |
||
31 | trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); |
||
32 | } |
||
33 | $forums = implode(',', $request->variable('enable_f', array(0))); |
||
34 | $desc_forums = implode(',', $request->variable('enable_og_desc_f', array(0))); |
||
35 | // Set the new settings to config |
||
36 | $config->set('socialbuttons_position', $request->variable('position', 0)); |
||
37 | $config->set('socialbuttons_enable_forums', $forums); |
||
38 | $config->set('socialbuttons_display_on_index', $request->variable('display_on_index', 0)); |
||
39 | $config->set('socialbuttons_enable', $request->variable('enable', 0)); |
||
40 | $config->set('socialbuttons_cachetime', $request->variable('cachetime', 0)); |
||
41 | $config->set('socialbuttons_multiplicator', $request->variable('multiplicator', 1)); |
||
42 | $config->set('socialbuttons_facebook', $request->variable('facebook', 0)); |
||
43 | $config->set('socialbuttons_twitter', $request->variable('twitter', 0)); |
||
44 | $config->set('socialbuttons_google', $request->variable('google', 0)); |
||
45 | $config->set('socialbuttons_linkedin', $request->variable('linkedin', 0)); |
||
46 | $config->set('socialbuttons_style', $request->variable('style', 1)); |
||
47 | $config->set('socialbuttons_showshares', $request->variable('showshares', 0)); |
||
48 | $config->set('socialbuttons_use_seo_urls', $request->variable('use_seo_urls', '')); |
||
49 | $config->set('socialbuttons_enable_og', $request->variable('enable_og', 0)); |
||
50 | $config->set('socialbuttons_enable_og_title', $request->variable('enable_og_title', 0)); |
||
51 | $config->set('socialbuttons_enable_og_desc', $request->variable('enable_og_desc', 0)); |
||
52 | $config->set('socialbuttons_og_image', $request->variable('og_image', '')); |
||
53 | $config->set('socialbuttons_enable_og_desc_forums', $desc_forums); |
||
54 | trigger_error($user->lang('ACP_SAVED') . adm_back_link($this->u_action)); |
||
55 | } |
||
56 | |||
57 | // Send the curent settings to template |
||
58 | $position = isset($config['socialbuttons_position']) ? $config['socialbuttons_position'] : false; |
||
59 | $multiplicator = isset($config['socialbuttons_multiplicator']) ? $config['socialbuttons_multiplicator'] : true; |
||
60 | $style = isset($config['socialbuttons_style']) ? $config['socialbuttons_style'] : true; |
||
61 | $desc_forums = isset($config['socialbuttons_enable_og_desc_forums']) ? explode(',', $config['socialbuttons_enable_og_desc_forums']) : array(); |
||
62 | $forums = isset($config['socialbuttons_enable_forums']) ? explode(',', $config['socialbuttons_enable_forums']) : array(); |
||
63 | |||
64 | $template->assign_vars(array( |
||
65 | 'U_ACTION' => $this->u_action, |
||
66 | 'POSITION_OPTIONS' => $this->position_select($position), |
||
67 | 'MULTIPLICATOR_OPTIONS' => $this->multiplicator_select($multiplicator), |
||
68 | 'BUTTON_STYLES' => $this->button_style($style), |
||
69 | 'S_ENABLE' => isset($config['socialbuttons_enable']) ? $config['socialbuttons_enable'] : false, |
||
70 | 'S_DISPLAY_ON_INDEX' => isset($config['socialbuttons_display_on_index']) ? $config['socialbuttons_display_on_index'] : false, |
||
71 | 'S_USE_SEO_URLS' => isset($config['socialbuttons_use_seo_urls']) ? $config['socialbuttons_use_seo_urls'] : false, |
||
72 | 'S_SHOWSHARES' => isset($config['socialbuttons_showshares']) ? $config['socialbuttons_showshares'] : false, |
||
73 | 'CACHETIME' => isset($config['socialbuttons_cachetime']) ? $config['socialbuttons_cachetime'] : false, |
||
74 | 'S_FACEBOOK' => isset($config['socialbuttons_facebook']) ? $config['socialbuttons_facebook'] : '', |
||
75 | 'S_TWITTER' => isset($config['socialbuttons_twitter']) ? $config['socialbuttons_twitter'] : '', |
||
76 | 'S_GOOGLE' => isset($config['socialbuttons_google']) ? $config['socialbuttons_google'] : '', |
||
77 | 'S_LINKEDIN' => isset($config['socialbuttons_linkedin']) ? $config['socialbuttons_linkedin'] : '', |
||
78 | 'S_ENABLE_OG' => isset($config['socialbuttons_enable_og']) ? $config['socialbuttons_enable_og'] : '', |
||
79 | 'S_ENABLE_OG_TITLE' => isset($config['socialbuttons_enable_og_title']) ? $config['socialbuttons_enable_og_title'] : '', |
||
80 | 'S_ENABLE_OG_DESC' => isset($config['socialbuttons_enable_og_desc']) ? $config['socialbuttons_enable_og_desc'] : '', |
||
81 | 'OG_IMAGE' => isset($config['socialbuttons_og_image']) ? $config['socialbuttons_og_image'] : '', |
||
82 | 'FORUM_DESC_SELECT' => make_forum_select($desc_forums, false, false, true), |
||
83 | 'FORUM_ENABLE_SELECT' => make_forum_select($forums, false, false, true), |
||
84 | )); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Generates a list of styles for the buttons |
||
89 | * |
||
90 | * @global object $phpbb_extension_manager |
||
91 | * @param int $selected |
||
92 | * @return string |
||
93 | */ |
||
94 | private function button_style($selected) |
||
95 | { |
||
96 | global $phpbb_extension_manager; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
97 | $path = $phpbb_extension_manager->get_extension_path('tas2580/socialbuttons', true) . 'images/'; |
||
98 | $return = ''; |
||
99 | for ($i = 1; $i <= 10; $i++) |
||
100 | { |
||
101 | $checked = ($selected == $i) ? ' checked="checked"' : ''; |
||
102 | $return .= '<input type="radio"' . $checked . ' class="radio" id="style" name="style" value="' . $i . '" /> <img align="top" src="' . $path . 'sprite' . $i . '.png" alt="" /><br /><br />'; |
||
103 | } |
||
104 | return $return; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Generates a option list with positions for the buttons |
||
109 | * |
||
110 | * @global object $user |
||
111 | * @param int $selected |
||
112 | * @return string |
||
113 | */ |
||
114 | View Code Duplication | private function position_select($selected) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
115 | { |
||
116 | global $user; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
117 | $return = '<option' . (($selected == 0) ? ' selected="selected"' : '') . ' value="0">' . $user->lang('ACP_POSITION_ALL') . '</option>'; |
||
118 | $return .= '<option' . (($selected == 1) ? ' selected="selected"' : '') . ' value="1">' . $user->lang('ACP_POSITION_TOP') . '</option>'; |
||
119 | $return .= '<option' . (($selected == 2) ? ' selected="selected"' : '') . ' value="2">' . $user->lang('ACP_POSITION_BOTTOM') . '</option>'; |
||
120 | return $return; |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Generates a option list for the cache tine multiplicator |
||
125 | * |
||
126 | * @global object $user |
||
127 | * @param int $selected |
||
128 | * @return string |
||
129 | */ |
||
130 | View Code Duplication | private function multiplicator_select($selected) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
131 | { |
||
132 | global $user; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
133 | $return = '<option' . (($selected == 1) ? ' selected="selected"' : '') . ' value="1">' . $user->lang('ACP_MULTIPLICATOR_SECONDS') . '</option>'; |
||
134 | $return .= '<option' . (($selected == 60) ? ' selected="selected"' : '') . ' value="60">' . $user->lang('ACP_MULTIPLICATOR_MINUTES') . '</option>'; |
||
135 | $return .= '<option' . (($selected == 3600) ? ' selected="selected"' : '') . ' value="3600">' . $user->lang('ACP_MULTIPLICATOR_HOURS') . '</option>'; |
||
136 | return $return; |
||
137 | } |
||
138 | } |
||
139 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.