Skip to content

Commit 08e6d0d

Browse files
committed
Fix PHP 8 warnings
1 parent 710075d commit 08e6d0d

4 files changed

Lines changed: 81 additions & 51 deletions

File tree

inc/plugins/google_seo.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,15 @@ function google_seo_dynamic($url)
258258
// This is complicated because of ?page&page=2, page being the thread title.
259259

260260
$query = explode('?', $url);
261-
$query = $query[1];
261+
262+
if(isset($query[1]))
263+
{
264+
$query = $query[1];
265+
}
266+
else
267+
{
268+
$query = false;
269+
}
262270

263271
if($query)
264272
{

inc/plugins/google_seo/plugin.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function google_seo_plugin_info()
6363
if(google_seo_plugin_is_installed() &&
6464
is_array($plugins_cache) &&
6565
is_array($plugins_cache['active']) &&
66-
$plugins_cache['active']['google_seo'])
66+
isset($plugins_cache['active']['google_seo']))
6767
{
6868
$info['description'] = $info['description'].google_seo_plugin_status();
6969
}
@@ -212,6 +212,7 @@ function google_seo_plugin_status()
212212
$success[] = "<a href=\"{$urldb}\">{$lang->googleseo_plugin_url}</a>";
213213

214214
if($settings['google_seo_url_translate'] &&
215+
if(!empty($settings['google_seo_url_translate']) &&
215216
!file_exists(MYBB_ROOT."inc/plugins/google_seo/translate.php"))
216217
{
217218
$warning[] = $lang->googleseo_plugin_url_warn_translate;
@@ -371,6 +372,12 @@ function google_seo_plugin_status()
371372
{
372373
$url = "([^./]+)";
373374
$rule = google_seo_expand($rule, array('url' => $url));
375+
376+
if(!isset($v[4]))
377+
{
378+
$v[4] = '';
379+
}
380+
374381
$rule = "RewriteRule ^{$rule}\$ {$v[1]}?{$v[4]}{$v[2]}=\$1 [L,QSA,NC]";
375382
}
376383

@@ -394,7 +401,7 @@ function google_seo_plugin_status()
394401
}
395402
}
396403

397-
if($line)
404+
if(isset($line))
398405
{
399406
$lines[] = $line;
400407
$line = '';
@@ -486,6 +493,8 @@ function google_seo_plugin_status()
486493
$query = $db->simple_select("settinggroups", "gid", "name='google_seo'");
487494
$gid = $db->fetch_field($query, 'gid');
488495

496+
$configure = '';
497+
489498
if($gid)
490499
{
491500
$configure = $PL->url_append('index.php', array(
@@ -501,6 +510,8 @@ function google_seo_plugin_status()
501510
$warning[] = $lang->googleseo_plugin_warn_setting;
502511
}
503512

513+
$status = '';
514+
504515
// Build a list with success, warnings, errors:
505516
if(count($error))
506517
{

inc/plugins/google_seo/redirect.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ function google_seo_redirect_hook()
9393
switch(THIS_SCRIPT)
9494
{
9595
case 'forumdisplay.php':
96-
$fid = (int)$mybb->input['fid'];
97-
$page = (int)$mybb->input['page'];
96+
$fid = (int)$mybb->get_input('fid');
97+
$page = (int)$mybb->get_input('page');
9898

9999
if($fid)
100100
{
@@ -126,29 +126,29 @@ function google_seo_redirect_hook()
126126
case 'showthread.php':
127127
// pid overrules tid, so we must check pid first,
128128
// even at the cost of an additional query.
129-
if((int)$mybb->input['pid'])
129+
if((int)$mybb->get_input('pid'))
130130
{
131-
$tid = google_seo_tid((int)$mybb->input['pid'],
132-
(int)$mybb->input['tid'],
131+
$tid = google_seo_tid((int)$mybb->get_input('pid'),
132+
(int)$mybb->get_input('tid'),
133133
$settings['google_seo_redirect_posts']);
134-
$target = get_post_link((int)$mybb->input['pid'], $tid);
134+
$target = get_post_link((int)$mybb->get_input('pid'), $tid);
135135
$kill['pid'] = '';
136136
$kill['tid'] = '';
137137
$kill['google_seo_thread'] = '';
138138
$kill['google_seo'] = '';
139139
}
140140

141-
else if((int)$mybb->input['tid'])
141+
else if((int)$mybb->get_input('tid'))
142142
{
143-
$target = get_thread_link((int)$mybb->input['tid'],
144-
(int)$mybb->input['page'],
145-
(string)$mybb->input['action']);
143+
$target = get_thread_link((int)$mybb->get_input('tid'),
144+
(int)$mybb->get_input('page'),
145+
(string)$mybb->get_input('action'));
146146
$kill['tid'] = '';
147147
$kill['action'] = '';
148148
$kill['google_seo_thread'] = '';
149149
$kill['google_seo'] = '';
150150

151-
if($mybb->input['page'] != 'last')
151+
if($mybb->get_input('page') != 'last')
152152
{
153153
$kill['page'] = '';
154154
}
@@ -157,9 +157,9 @@ function google_seo_redirect_hook()
157157
break;
158158

159159
case 'announcements.php':
160-
if((int)$mybb->input['aid'])
160+
if((int)$mybb->get_input('aid'))
161161
{
162-
$target = get_announcement_link((int)$mybb->input['aid']);
162+
$target = get_announcement_link((int)$mybb->get_input('aid'));
163163
$kill['aid'] = '';
164164
$kill['google_seo_announcement'] = '';
165165
$kill['google_seo'] = '';
@@ -168,21 +168,21 @@ function google_seo_redirect_hook()
168168
break;
169169

170170
case 'member.php':
171-
if((int)$mybb->input['uid'])
171+
if((int)$mybb->get_input('uid'))
172172
{
173173
if($settings['google_seo_redirect_litespeed']
174-
&& $mybb->input['action'] != 'profile')
174+
&& $mybb->get_input('action') != 'profile')
175175
{
176176
// Work around rewrite bug in LiteSpeed (double action conflict).
177177
break;
178178
}
179179

180-
$target = get_profile_link((int)$mybb->input['uid']);
180+
$target = get_profile_link((int)$mybb->get_input('uid'));
181181
$kill['uid'] = '';
182182
$kill['google_seo_user'] = '';
183183
$kill['google_seo'] = '';
184184

185-
if($mybb->input['action'] == 'profile')
185+
if($mybb->get_input('action') == 'profile')
186186
{
187187
$kill['action'] = '';
188188
}
@@ -191,29 +191,29 @@ function google_seo_redirect_hook()
191191
break;
192192

193193
case 'calendar.php':
194-
if((int)$mybb->input['eid'])
194+
if((int)$mybb->get_input('eid'))
195195
{
196196
if($settings['google_seo_redirect_litespeed']
197-
&& $mybb->input['action'] != 'profile')
197+
&& $mybb->get_input('action') != 'profile')
198198
{
199199
// Work around rewrite bug in LiteSpeed (double action conflict).
200200
break;
201201
}
202202

203-
$target = get_event_link((int)$mybb->input['eid']);
203+
$target = get_event_link((int)$mybb->get_input('eid'));
204204
$kill['eid'] = '';
205205
$kill['google_seo_event'] = '';
206206
$kill['google_seo'] = '';
207207

208-
if($mybb->input['action'] == 'event')
208+
if($mybb->get_input('action') == 'event')
209209
{
210210
$kill['action'] = '';
211211
}
212212
}
213213

214214
else
215215
{
216-
if(!(int)$mybb->input['calendar'])
216+
if(!(int)$mybb->get_input('calendar'))
217217
{
218218
// Special case: Default calendar.
219219
// Code taken from calendar.php
@@ -224,10 +224,10 @@ function google_seo_redirect_hook()
224224
$mybb->input['calendar'] = $cid;
225225
}
226226

227-
if($mybb->input['action'] == "weekview")
227+
if($mybb->get_input('action') == "weekview")
228228
{
229-
$target = get_calendar_week_link((int)$mybb->input['calendar'],
230-
(int)str_replace('n', '-', $mybb->input['week']));
229+
$target = get_calendar_week_link((int)$mybb->get_input('calendar'),
230+
(int)str_replace('n', '-', $mybb->get_input('week')));
231231
$kill['calendar'] = '';
232232
$kill['week'] = '';
233233
$kill['action'] = '';
@@ -237,10 +237,10 @@ function google_seo_redirect_hook()
237237

238238
else
239239
{
240-
$target = get_calendar_link((int)$mybb->input['calendar'],
241-
(int)$mybb->input['year'],
242-
(int)$mybb->input['month'],
243-
(int)$mybb->input['day']);
240+
$target = get_calendar_link((int)$mybb->get_input('calendar'),
241+
(int)$mybb->get_input('year'),
242+
(int)$mybb->get_input('month'),
243+
(int)$mybb->get_input('day'));
244244
$kill['calendar'] = '';
245245
$kill['year'] = '';
246246
$kill['month'] = '';

0 commit comments

Comments
 (0)