Passed
Push — master ( 4eb8b5...c6e41d )
by Michael
07:19 queued 04:35
created
player_stats.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
  */
38 38
 
39 39
 $GLOBALS['xoopsOption']['template_main'] = 'chess_player_stats.tpl';
40
-require __DIR__ . '/header.php';
40
+require __DIR__.'/header.php';
41 41
 
42
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
43
-require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
44
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
45
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
46
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/ratings.php';
42
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
43
+require_once XOOPS_ROOT_PATH.'/class/pagenav.php';
44
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
45
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
46
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/ratings.php';
47 47
 
48 48
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
49 49
 
50 50
 // user input
51
-$player_uid   = (int)($_POST['player_uid'] ?? @$_GET['player_uid']);
51
+$player_uid   = (int) ($_POST['player_uid'] ?? @$_GET['player_uid']);
52 52
 $player_uname = trim(@$_POST['player_uname']); // unsanitized
53
-$cstart       = (int)@$_GET['cstart']; // for page nav: offset of first row of results (challenges) to display (default to 0)
54
-$gstart       = (int)@$_GET['gstart']; // for page nav: offset of first row of results (games) to display (default to 0)
55
-$show_option  = (int)($_POST['show_option'] ?? @$_GET['show_option']);
53
+$cstart       = (int) @$_GET['cstart']; // for page nav: offset of first row of results (challenges) to display (default to 0)
54
+$gstart       = (int) @$_GET['gstart']; // for page nav: offset of first row of results (games) to display (default to 0)
55
+$show_option  = (int) ($_POST['show_option'] ?? @$_GET['show_option']);
56 56
 
57 57
 #var_dump($_REQUEST);#*#DEBUG#
58 58
 
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 
71 71
 // Check that both user ID and username are now defined.
72 72
 if (0 == $player_uid || empty($player_uname)) {
73
-    redirect_header(XOOPS_URL . '/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_PLAYER_NOT_FOUND);
73
+    redirect_header(XOOPS_URL.'/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_PLAYER_NOT_FOUND);
74 74
 }
75 75
 
76 76
 // Display stats
77 77
 chess_player_stats($player_uid, $player_uname, $show_option, $cstart, $gstart);
78 78
 
79
-require_once XOOPS_ROOT_PATH . '/footer.php';
79
+require_once XOOPS_ROOT_PATH.'/footer.php';
80 80
 /**#@-*/
81 81
 
82 82
 /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
     $memberHandler = xoops_getHandler('member');
295 295
 
296
-    $criteria = new \Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN');
296
+    $criteria = new \Criteria('uid', '('.implode(',', array_keys($userids)).')', 'IN');
297 297
 
298 298
     $usernames = $memberHandler->getUserList($criteria);
299 299
 
Please login to merge, or discard this patch.
header.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 /**#@+
36 36
  */
37 37
 
38
-include __DIR__ . '/preloads/autoloader.php';
38
+include __DIR__.'/preloads/autoloader.php';
39 39
 
40
-require dirname(__DIR__, 2) . '/mainfile.php';
41
-require XOOPS_ROOT_PATH . '/header.php';
40
+require dirname(__DIR__, 2).'/mainfile.php';
41
+require XOOPS_ROOT_PATH.'/header.php';
Please login to merge, or discard this patch.
game.php 2 patches
Indentation   +635 added lines, -635 removed lines patch added patch discarded remove patch
@@ -66,402 +66,402 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function chess_game()
68 68
 {
69
-    // user input
69
+	// user input
70 70
 
71
-    $game_id = (int)@$_GET['game_id'];
71
+	$game_id = (int)@$_GET['game_id'];
72 72
 
73
-    $submit_move = isset($_POST['submit_move']);
73
+	$submit_move = isset($_POST['submit_move']);
74 74
 
75
-    $submit_refresh = isset($_POST['submit_refresh']);
75
+	$submit_refresh = isset($_POST['submit_refresh']);
76 76
 
77
-    $move = chess_sanitize(trim(@$_POST['chessmove']), 'A-Za-z0-9=-');
77
+	$move = chess_sanitize(trim(@$_POST['chessmove']), 'A-Za-z0-9=-');
78 78
 
79
-    $movetype = chess_sanitize(@$_POST['movetype']);
79
+	$movetype = chess_sanitize(@$_POST['movetype']);
80 80
 
81
-    $confirm = isset($_POST['confirm']) ? 1 : 0;
81
+	$confirm = isset($_POST['confirm']) ? 1 : 0;
82 82
 
83
-    $move_explain = chess_sanitize(trim(@$_POST['move_explain']), 'A-Za-z0-9 .,;:=()[]*?!-');
83
+	$move_explain = chess_sanitize(trim(@$_POST['move_explain']), 'A-Za-z0-9 .,;:=()[]*?!-');
84 84
 
85
-    $arbiter_explain = chess_sanitize(trim(@$_POST['arbiter_explain']), 'A-Za-z0-9 .,;:=()[]*?!-');
85
+	$arbiter_explain = chess_sanitize(trim(@$_POST['arbiter_explain']), 'A-Za-z0-9 .,;:=()[]*?!-');
86 86
 
87
-    $orientation = chess_sanitize(@$_POST['orientation']);
87
+	$orientation = chess_sanitize(@$_POST['orientation']);
88 88
 
89
-    $show_arbiter_ctrl = isset($_POST['show_arbiter_ctrl']);
89
+	$show_arbiter_ctrl = isset($_POST['show_arbiter_ctrl']);
90 90
 
91
-    $submit_arbitrate = isset($_POST['submit_arbitrate']);
91
+	$submit_arbitrate = isset($_POST['submit_arbitrate']);
92 92
 
93
-    $arbiter_action = chess_sanitize(@$_POST['arbiter_action']);
93
+	$arbiter_action = chess_sanitize(@$_POST['arbiter_action']);
94 94
 
95
-    // If form-submit, check security token.
95
+	// If form-submit, check security token.
96 96
 
97
-    if (($submit_move || $submit_refresh || $submit_arbitrate || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
98
-        redirect_header(
99
-            XOOPS_URL . '/modules/chess/',
100
-            _CHESS_REDIRECT_DELAY_FAILURE,
101
-            _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
102
-        );
103
-    }
97
+	if (($submit_move || $submit_refresh || $submit_arbitrate || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
98
+		redirect_header(
99
+			XOOPS_URL . '/modules/chess/',
100
+			_CHESS_REDIRECT_DELAY_FAILURE,
101
+			_MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
102
+		);
103
+	}
104 104
 
105
-    // Fetch the game data from the database.
105
+	// Fetch the game data from the database.
106 106
 
107
-    $gamedata = chess_get_game($game_id);
107
+	$gamedata = chess_get_game($game_id);
108 108
 
109
-    if (false === $gamedata) {
110
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
111
-    }
109
+	if (false === $gamedata) {
110
+		redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
111
+	}
112 112
 
113
-    $gamedata_updated = false;
113
+	$gamedata_updated = false;
114 114
 
115
-    $move_performed        = false; // status result from move-handler
116
-    $move_result_text      = '';    // text result from move-handler
117
-    $draw_claim_error_text = '';    // text describing invalid draw-claim
118
-    $notify                = '';    // text description of action for notification
119
-    $delete_game           = false;
115
+	$move_performed        = false; // status result from move-handler
116
+	$move_result_text      = '';    // text result from move-handler
117
+	$draw_claim_error_text = '';    // text describing invalid draw-claim
118
+	$notify                = '';    // text description of action for notification
119
+	$delete_game           = false;
120 120
 
121
-    global $xoopsUser;
121
+	global $xoopsUser;
122 122
 
123
-    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
123
+	$uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
124 124
 
125
-    $selfplay = $gamedata['white_uid'] == $gamedata['black_uid'];
125
+	$selfplay = $gamedata['white_uid'] == $gamedata['black_uid'];
126 126
 
127
-    if ($selfplay) {
128
-        if ($uid == $gamedata['white_uid']) {
129
-            $user_color = $gamedata['fen_active_color']; // current user is either player, so consider him active player
130
-        } else {
131
-            $user_color = '';                            // current user is not a player
132
-        }
133
-        // not self-play
134
-    } else {
135
-        if ($uid == $gamedata['white_uid']) {
136
-            $user_color = 'w'; // current user is white
137
-        } elseif ($uid == $gamedata['black_uid']) {
138
-            $user_color = 'b'; // current user is black
139
-        } else {
140
-            $user_color = '';  // current user is not a player
141
-        }
142
-    }
127
+	if ($selfplay) {
128
+		if ($uid == $gamedata['white_uid']) {
129
+			$user_color = $gamedata['fen_active_color']; // current user is either player, so consider him active player
130
+		} else {
131
+			$user_color = '';                            // current user is not a player
132
+		}
133
+		// not self-play
134
+	} else {
135
+		if ($uid == $gamedata['white_uid']) {
136
+			$user_color = 'w'; // current user is white
137
+		} elseif ($uid == $gamedata['black_uid']) {
138
+			$user_color = 'b'; // current user is black
139
+		} else {
140
+			$user_color = '';  // current user is not a player
141
+		}
142
+	}
143 143
 
144
-    // Determine whether current user is a player in the current game, and whether it's his move.
144
+	// Determine whether current user is a player in the current game, and whether it's his move.
145 145
 
146
-    $user_is_player = 'w' == $user_color || 'b' == $user_color;
146
+	$user_is_player = 'w' == $user_color || 'b' == $user_color;
147 147
 
148
-    $user_is_player_to_move = $user_color == $gamedata['fen_active_color'];
148
+	$user_is_player_to_move = $user_color == $gamedata['fen_active_color'];
149 149
 
150
-    $user_color_name = 'w' == $user_color ? _MD_CHESS_WHITE : _MD_CHESS_BLACK;
150
+	$user_color_name = 'w' == $user_color ? _MD_CHESS_WHITE : _MD_CHESS_BLACK;
151 151
 
152
-    if ($submit_move && !$gamedata['suspended']) {
153
-        // If the player has changed his confirm-move preference, it needs to be updated in the database.
152
+	if ($submit_move && !$gamedata['suspended']) {
153
+		// If the player has changed his confirm-move preference, it needs to be updated in the database.
154 154
 
155
-        // For a self-play game, the white and black confirm-move preferences are kept the same, to avoid confusion.
155
+		// For a self-play game, the white and black confirm-move preferences are kept the same, to avoid confusion.
156 156
 
157
-        if ($user_is_player) {
158
-            if ('w' == $user_color && $gamedata['white_confirm'] != $confirm) {
159
-                $gamedata['white_confirm'] = $confirm;
157
+		if ($user_is_player) {
158
+			if ('w' == $user_color && $gamedata['white_confirm'] != $confirm) {
159
+				$gamedata['white_confirm'] = $confirm;
160 160
 
161
-                if ($selfplay) {
162
-                    $gamedata['black_confirm'] = $confirm;
163
-                }
161
+				if ($selfplay) {
162
+					$gamedata['black_confirm'] = $confirm;
163
+				}
164 164
 
165
-                $gamedata_updated = true;
166
-            } elseif ('b' == $user_color && $gamedata['black_confirm'] != $confirm) {
167
-                $gamedata['black_confirm'] = $confirm;
165
+				$gamedata_updated = true;
166
+			} elseif ('b' == $user_color && $gamedata['black_confirm'] != $confirm) {
167
+				$gamedata['black_confirm'] = $confirm;
168 168
 
169
-                if ($selfplay) {
170
-                    $gamedata['white_confirm'] = $confirm;
171
-                }
169
+				if ($selfplay) {
170
+					$gamedata['white_confirm'] = $confirm;
171
+				}
172 172
 
173
-                $gamedata_updated = true;
174
-            }
175
-        }
173
+				$gamedata_updated = true;
174
+			}
175
+		}
176 176
 
177
-        switch ($movetype) {
178
-            default:
179
-            case _CHESS_MOVETYPE_NORMAL:
180
-                if ($user_is_player_to_move && $gamedata['offer_draw'] != $user_color) {
181
-                    [$move_performed, $move_result_text] = chess_move($gamedata, $move);
177
+		switch ($movetype) {
178
+			default:
179
+			case _CHESS_MOVETYPE_NORMAL:
180
+				if ($user_is_player_to_move && $gamedata['offer_draw'] != $user_color) {
181
+					[$move_performed, $move_result_text] = chess_move($gamedata, $move);
182 182
 
183
-                    if ($move_performed) {
184
-                        if ($selfplay) { // If self-play, the current user's color switches.
185
-                            $user_color = $gamedata['fen_active_color'];
186
-                        }
183
+					if ($move_performed) {
184
+						if ($selfplay) { // If self-play, the current user's color switches.
185
+							$user_color = $gamedata['fen_active_color'];
186
+						}
187 187
 
188
-                        $gamedata['offer_draw'] = '';
188
+						$gamedata['offer_draw'] = '';
189 189
 
190
-                        $gamedata_updated = true;
190
+						$gamedata_updated = true;
191 191
 
192
-                        $notify = "$user_color_name: $move";
193
-                    }
194
-                }
195
-                break;
196
-            case _CHESS_MOVETYPE_CLAIM_DRAW_3:
197
-            case _CHESS_MOVETYPE_CLAIM_DRAW_50:
198
-                if ($user_is_player_to_move && $gamedata['offer_draw'] != $user_color) {
199
-                    if (!empty($move)) {
200
-                        [$move_performed, $move_result_text] = chess_move($gamedata, $move);
192
+						$notify = "$user_color_name: $move";
193
+					}
194
+				}
195
+				break;
196
+			case _CHESS_MOVETYPE_CLAIM_DRAW_3:
197
+			case _CHESS_MOVETYPE_CLAIM_DRAW_50:
198
+				if ($user_is_player_to_move && $gamedata['offer_draw'] != $user_color) {
199
+					if (!empty($move)) {
200
+						[$move_performed, $move_result_text] = chess_move($gamedata, $move);
201 201
 
202
-                        #var_dump('chess_game', $move_performed, $move_result_text);#*#DEBUG#
202
+						#var_dump('chess_game', $move_performed, $move_result_text);#*#DEBUG#
203 203
 
204
-                        if ($move_performed) {
205
-                            if ($selfplay) { // If self-play, the current user's color switches.
206
-                                $user_color = $gamedata['fen_active_color'];
207
-                            }
204
+						if ($move_performed) {
205
+							if ($selfplay) { // If self-play, the current user's color switches.
206
+								$user_color = $gamedata['fen_active_color'];
207
+							}
208 208
 
209
-                            $gamedata['offer_draw'] = '';
209
+							$gamedata['offer_draw'] = '';
210 210
 
211
-                            $gamedata_updated = true;
211
+							$gamedata_updated = true;
212 212
 
213
-                            $notify = "$user_color_name: $move";
214
-                        } else {
215
-                            break; // move invalid, so don't bother checking draw-claim
216
-                        }
217
-                    }
213
+							$notify = "$user_color_name: $move";
214
+						} else {
215
+							break; // move invalid, so don't bother checking draw-claim
216
+						}
217
+					}
218 218
 
219
-                    [$draw_claim_valid, $draw_claim_text] = _CHESS_MOVETYPE_CLAIM_DRAW_3 == $movetype ? chess_is_draw_threefold_repetition($gamedata) : chess_is_draw_50_move_rule($gamedata);
219
+					[$draw_claim_valid, $draw_claim_text] = _CHESS_MOVETYPE_CLAIM_DRAW_3 == $movetype ? chess_is_draw_threefold_repetition($gamedata) : chess_is_draw_50_move_rule($gamedata);
220 220
 
221
-                    #var_dump('chess_game', $draw_claim_valid, $draw_claim_text);#*#DEBUG#
221
+					#var_dump('chess_game', $draw_claim_valid, $draw_claim_text);#*#DEBUG#
222 222
 
223
-                    if ($draw_claim_valid) {
224
-                        $gamedata['offer_draw'] = '';
223
+					if ($draw_claim_valid) {
224
+						$gamedata['offer_draw'] = '';
225 225
 
226
-                        $gamedata['pgn_result'] = '1/2-1/2';
226
+						$gamedata['pgn_result'] = '1/2-1/2';
227 227
 
228
-                        $comment = '{' . $draw_claim_text . '}';
228
+						$comment = '{' . $draw_claim_text . '}';
229 229
 
230
-                        $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
230
+						$gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
231 231
 
232
-                        $gamedata_updated = true;
232
+						$gamedata_updated = true;
233 233
 
234
-                        $notify = !empty($move) ? "$user_color_name: $move: $draw_claim_text" : "$user_color_name: $draw_claim_text";
235
-                    } else {
236
-                        $draw_claim_error_text = $draw_claim_text;
237
-                    }
238
-                }
239
-                break;
240
-            case _CHESS_MOVETYPE_RESIGN:
241
-                if ($user_is_player) {
242
-                    $gamedata['offer_draw'] = '';
234
+						$notify = !empty($move) ? "$user_color_name: $move: $draw_claim_text" : "$user_color_name: $draw_claim_text";
235
+					} else {
236
+						$draw_claim_error_text = $draw_claim_text;
237
+					}
238
+				}
239
+				break;
240
+			case _CHESS_MOVETYPE_RESIGN:
241
+				if ($user_is_player) {
242
+					$gamedata['offer_draw'] = '';
243 243
 
244
-                    $gamedata['pgn_result'] = 'w' == $user_color ? '0-1' : '1-0';
244
+					$gamedata['pgn_result'] = 'w' == $user_color ? '0-1' : '1-0';
245 245
 
246
-                    $comment = '{' . $user_color_name . ' ' . _MD_CHESS_RESIGNED . '}';
246
+					$comment = '{' . $user_color_name . ' ' . _MD_CHESS_RESIGNED . '}';
247 247
 
248
-                    $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
248
+					$gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
249 249
 
250
-                    $gamedata_updated = true;
250
+					$gamedata_updated = true;
251 251
 
252
-                    $notify = "$user_color_name " . _MD_CHESS_RESIGNED;
253
-                }
254
-                break;
255
-            case _CHESS_MOVETYPE_OFFER_DRAW:
256
-                if ($user_is_player && empty($gamedata['offer_draw']) && !$selfplay) {
257
-                    $gamedata['offer_draw'] = $user_color;
252
+					$notify = "$user_color_name " . _MD_CHESS_RESIGNED;
253
+				}
254
+				break;
255
+			case _CHESS_MOVETYPE_OFFER_DRAW:
256
+				if ($user_is_player && empty($gamedata['offer_draw']) && !$selfplay) {
257
+					$gamedata['offer_draw'] = $user_color;
258 258
 
259
-                    $gamedata_updated = true;
259
+					$gamedata_updated = true;
260 260
 
261
-                    $notify = "$user_color_name " . _MD_CHESS_OFFERED_DRAW;
262
-                }
263
-                break;
264
-            case _CHESS_MOVETYPE_ACCEPT_DRAW:
265
-                if ($user_is_player && !empty($gamedata['offer_draw']) && $gamedata['offer_draw'] != $user_color && !$selfplay) {
266
-                    $gamedata['offer_draw'] = '';
261
+					$notify = "$user_color_name " . _MD_CHESS_OFFERED_DRAW;
262
+				}
263
+				break;
264
+			case _CHESS_MOVETYPE_ACCEPT_DRAW:
265
+				if ($user_is_player && !empty($gamedata['offer_draw']) && $gamedata['offer_draw'] != $user_color && !$selfplay) {
266
+					$gamedata['offer_draw'] = '';
267 267
 
268
-                    $gamedata['pgn_result'] = '1/2-1/2';
268
+					$gamedata['pgn_result'] = '1/2-1/2';
269 269
 
270
-                    $comment = '{' . _MD_CHESS_DRAW_BY_AGREEMENT . '}';
270
+					$comment = '{' . _MD_CHESS_DRAW_BY_AGREEMENT . '}';
271 271
 
272
-                    $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
272
+					$gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
273 273
 
274
-                    $gamedata_updated = true;
274
+					$gamedata_updated = true;
275 275
 
276
-                    $notify = "$user_color_name " . _MD_CHESS_ACCEPTED_DRAW;
277
-                }
276
+					$notify = "$user_color_name " . _MD_CHESS_ACCEPTED_DRAW;
277
+				}
278 278
 
279
-            // no break
280
-            case _CHESS_MOVETYPE_REJECT_DRAW:
281
-                if ($user_is_player && !empty($gamedata['offer_draw']) && $gamedata['offer_draw'] != $user_color && !$selfplay) {
282
-                    $gamedata['offer_draw'] = '';
279
+			// no break
280
+			case _CHESS_MOVETYPE_REJECT_DRAW:
281
+				if ($user_is_player && !empty($gamedata['offer_draw']) && $gamedata['offer_draw'] != $user_color && !$selfplay) {
282
+					$gamedata['offer_draw'] = '';
283 283
 
284
-                    $gamedata_updated = true;
284
+					$gamedata_updated = true;
285 285
 
286
-                    $notify = "$user_color_name " . _MD_CHESS_REJECTED_DRAW;
287
-                }
288
-                break;
289
-            case _CHESS_MOVETYPE_RESTART:
290
-                if ($user_is_player && $selfplay) {
291
-                    // instantiate a ChessGame to get a "fresh" gamestate
286
+					$notify = "$user_color_name " . _MD_CHESS_REJECTED_DRAW;
287
+				}
288
+				break;
289
+			case _CHESS_MOVETYPE_RESTART:
290
+				if ($user_is_player && $selfplay) {
291
+					// instantiate a ChessGame to get a "fresh" gamestate
292 292
 
293
-                    $chessgame = new Chess\ChessGame($gamedata['pgn_fen']);
293
+					$chessgame = new Chess\ChessGame($gamedata['pgn_fen']);
294 294
 
295
-                    $new_gamestate = $chessgame->gamestate();
295
+					$new_gamestate = $chessgame->gamestate();
296 296
 
297
-                    // update the game data
297
+					// update the game data
298 298
 
299
-                    $gamedata['fen_piece_placement'] = $new_gamestate['fen_piece_placement'];
299
+					$gamedata['fen_piece_placement'] = $new_gamestate['fen_piece_placement'];
300 300
 
301
-                    $gamedata['fen_active_color'] = $new_gamestate['fen_active_color'];
301
+					$gamedata['fen_active_color'] = $new_gamestate['fen_active_color'];
302 302
 
303
-                    $gamedata['fen_castling_availability'] = $new_gamestate['fen_castling_availability'];
303
+					$gamedata['fen_castling_availability'] = $new_gamestate['fen_castling_availability'];
304 304
 
305
-                    $gamedata['fen_en_passant_target_square'] = $new_gamestate['fen_en_passant_target_square'];
305
+					$gamedata['fen_en_passant_target_square'] = $new_gamestate['fen_en_passant_target_square'];
306 306
 
307
-                    $gamedata['fen_halfmove_clock'] = $new_gamestate['fen_halfmove_clock'];
307
+					$gamedata['fen_halfmove_clock'] = $new_gamestate['fen_halfmove_clock'];
308 308
 
309
-                    $gamedata['fen_fullmove_number'] = $new_gamestate['fen_fullmove_number'];
309
+					$gamedata['fen_fullmove_number'] = $new_gamestate['fen_fullmove_number'];
310 310
 
311
-                    $gamedata['pgn_fen'] = $new_gamestate['pgn_fen'];
311
+					$gamedata['pgn_fen'] = $new_gamestate['pgn_fen'];
312 312
 
313
-                    $gamedata['pgn_result'] = $new_gamestate['pgn_result'];
313
+					$gamedata['pgn_result'] = $new_gamestate['pgn_result'];
314 314
 
315
-                    $gamedata['pgn_movetext'] = $new_gamestate['pgn_movetext'];
315
+					$gamedata['pgn_movetext'] = $new_gamestate['pgn_movetext'];
316 316
 
317
-                    // update user color
317
+					// update user color
318 318
 
319
-                    $user_color = $gamedata['fen_active_color'];
319
+					$user_color = $gamedata['fen_active_color'];
320 320
 
321
-                    $gamedata_updated = true;
322
-                }
323
-                break;
324
-            case _CHESS_MOVETYPE_DELETE:
325
-                if ($user_is_player && ($selfplay || chess_can_delete())) {
326
-                    $delete_game = true; // must defer actual deletion until after notifications are sent
327
-                    $notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
328
-                }
329
-                break;
330
-            case _CHESS_MOVETYPE_WANT_ARBITRATION:
331
-                if ($user_is_player) {
332
-                    // Ensure that $move_explain does not contain separator $sep.
321
+					$gamedata_updated = true;
322
+				}
323
+				break;
324
+			case _CHESS_MOVETYPE_DELETE:
325
+				if ($user_is_player && ($selfplay || chess_can_delete())) {
326
+					$delete_game = true; // must defer actual deletion until after notifications are sent
327
+					$notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
328
+				}
329
+				break;
330
+			case _CHESS_MOVETYPE_WANT_ARBITRATION:
331
+				if ($user_is_player) {
332
+					// Ensure that $move_explain does not contain separator $sep.
333 333
 
334
-                    $sep = '|';
334
+					$sep = '|';
335 335
 
336
-                    $move_explain = str_replace($sep, '_', $move_explain);
336
+					$move_explain = str_replace($sep, '_', $move_explain);
337 337
 
338
-                    $gamedata['suspended'] = implode($sep, [date('Y-m-d H:i:s'), $uid, _CHESS_MOVETYPE_WANT_ARBITRATION, $move_explain]);
338
+					$gamedata['suspended'] = implode($sep, [date('Y-m-d H:i:s'), $uid, _CHESS_MOVETYPE_WANT_ARBITRATION, $move_explain]);
339 339
 
340
-                    $gamedata_updated = true;
340
+					$gamedata_updated = true;
341 341
 
342
-                    $notify = "$user_color_name " . _MD_CHESS_RQSTED_ARBT . ' ' . _MD_CHESS_BEEN_SUSPENDED;
343
-                }
344
-                break;
345
-        }
346
-    }
342
+					$notify = "$user_color_name " . _MD_CHESS_RQSTED_ARBT . ' ' . _MD_CHESS_BEEN_SUSPENDED;
343
+				}
344
+				break;
345
+		}
346
+	}
347 347
 
348
-    // If board orientation setting uninitialized or invalid, set it to the appropriate default.
348
+	// If board orientation setting uninitialized or invalid, set it to the appropriate default.
349 349
 
350
-    if (!in_array($orientation, [_CHESS_ORIENTATION_ACTIVE, _CHESS_ORIENTATION_WHITE, _CHESS_ORIENTATION_BLACK])) {
351
-        if ($user_is_player && 'b' == $user_color) {
352
-            $orientation = _CHESS_ORIENTATION_BLACK;
353
-        } else {
354
-            $orientation = _CHESS_ORIENTATION_WHITE;
355
-        }
356
-    }
350
+	if (!in_array($orientation, [_CHESS_ORIENTATION_ACTIVE, _CHESS_ORIENTATION_WHITE, _CHESS_ORIENTATION_BLACK])) {
351
+		if ($user_is_player && 'b' == $user_color) {
352
+			$orientation = _CHESS_ORIENTATION_BLACK;
353
+		} else {
354
+			$orientation = _CHESS_ORIENTATION_WHITE;
355
+		}
356
+	}
357 357
 
358
-    // Determine if user is a valid arbiter.
358
+	// Determine if user is a valid arbiter.
359 359
 
360
-    global $xoopsModule;
360
+	global $xoopsModule;
361 361
 
362
-    $is_arbiter = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'));
362
+	$is_arbiter = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'));
363 363
 
364
-    // If arbiter action was submitted, and user is a valid arbiter, process the action.
364
+	// If arbiter action was submitted, and user is a valid arbiter, process the action.
365 365
 
366
-    if ($submit_arbitrate && $is_arbiter) {
367
-        $username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*';
366
+	if ($submit_arbitrate && $is_arbiter) {
367
+		$username = $xoopsUser ? $xoopsUser->getVar('uname') : '*unknown*';
368 368
 
369
-        switch ($arbiter_action) {
370
-            case _CHESS_ARBITER_RESUME:
371
-                if ($gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
372
-                    $gamedata['suspended'] = '';
369
+		switch ($arbiter_action) {
370
+			case _CHESS_ARBITER_RESUME:
371
+				if ($gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
372
+					$gamedata['suspended'] = '';
373 373
 
374
-                    $gamedata_updated = true;
374
+					$gamedata_updated = true;
375 375
 
376
-                    $notify = eval('return \'' . _MD_CHESS_RESUMED_PLAY . '\';'); // eval references $username
377
-                }
378
-                break;
379
-            case _CHESS_ARBITER_DRAW:
380
-                if ($gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
381
-                    $gamedata['offer_draw'] = '';
376
+					$notify = eval('return \'' . _MD_CHESS_RESUMED_PLAY . '\';'); // eval references $username
377
+				}
378
+				break;
379
+			case _CHESS_ARBITER_DRAW:
380
+				if ($gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
381
+					$gamedata['offer_draw'] = '';
382 382
 
383
-                    $gamedata['pgn_result'] = '1/2-1/2';
383
+					$gamedata['pgn_result'] = '1/2-1/2';
384 384
 
385
-                    $arbiter_explain = str_replace('{', '(', $arbiter_explain);
385
+					$arbiter_explain = str_replace('{', '(', $arbiter_explain);
386 386
 
387
-                    $arbiter_explain = str_replace('}', ')', $arbiter_explain);
387
+					$arbiter_explain = str_replace('}', ')', $arbiter_explain);
388 388
 
389
-                    $comment = '{' . sprintf(_MD_CHESS_DRAW_DECLARED, $arbiter_explain) . '}';
389
+					$comment = '{' . sprintf(_MD_CHESS_DRAW_DECLARED, $arbiter_explain) . '}';
390 390
 
391
-                    $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
391
+					$gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
392 392
 
393
-                    $gamedata['suspended'] = '';
393
+					$gamedata['suspended'] = '';
394 394
 
395
-                    $gamedata_updated = true;
395
+					$gamedata_updated = true;
396 396
 
397
-                    $notify = eval('return \'' . _MD_CHESS_DECLARED_DRAW . '\';'); // eval references $username
398
-                }
399
-                break;
400
-            case _CHESS_ARBITER_DELETE:
401
-                if ($gamedata['suspended']) {
402
-                    $delete_game = true; // must defer actual deletion until after notifications are sent
403
-                    $notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
404
-                }
405
-                break;
406
-            case _CHESS_ARBITER_SUSPEND:
407
-                if (!$gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
408
-                    // Ensure that $arbiter_explain does not contain separator $sep.
397
+					$notify = eval('return \'' . _MD_CHESS_DECLARED_DRAW . '\';'); // eval references $username
398
+				}
399
+				break;
400
+			case _CHESS_ARBITER_DELETE:
401
+				if ($gamedata['suspended']) {
402
+					$delete_game = true; // must defer actual deletion until after notifications are sent
403
+					$notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
404
+				}
405
+				break;
406
+			case _CHESS_ARBITER_SUSPEND:
407
+				if (!$gamedata['suspended'] && '*' == $gamedata['pgn_result']) {
408
+					// Ensure that $arbiter_explain does not contain separator $sep.
409 409
 
410
-                    $sep = '|';
410
+					$sep = '|';
411 411
 
412
-                    $arbiter_explain = str_replace($sep, '_', $arbiter_explain);
412
+					$arbiter_explain = str_replace($sep, '_', $arbiter_explain);
413 413
 
414
-                    $gamedata['suspended'] = implode('|', [date('Y-m-d H:i:s'), $uid, _CHESS_MOVETYPE_ARBITER_SUSPEND, $arbiter_explain]);
414
+					$gamedata['suspended'] = implode('|', [date('Y-m-d H:i:s'), $uid, _CHESS_MOVETYPE_ARBITER_SUSPEND, $arbiter_explain]);
415 415
 
416
-                    $gamedata_updated = true;
416
+					$gamedata_updated = true;
417 417
 
418
-                    $notify = eval('return \'' . _MD_CHESS_SUSPENDED_PLAY . '\';'); // eval references $username
419
-                }
420
-                break;
421
-            default:
422
-                break;
423
-        }
424
-    }
418
+					$notify = eval('return \'' . _MD_CHESS_SUSPENDED_PLAY . '\';'); // eval references $username
419
+				}
420
+				break;
421
+			default:
422
+				break;
423
+		}
424
+	}
425 425
 
426
-    // Store the updated game data in the database.
426
+	// Store the updated game data in the database.
427 427
 
428
-    if ($gamedata_updated) {
429
-        chess_put_game($game_id, $gamedata);
430
-    }
428
+	if ($gamedata_updated) {
429
+		chess_put_game($game_id, $gamedata);
430
+	}
431 431
 
432
-    // Display the (possibly updated) board.
432
+	// Display the (possibly updated) board.
433 433
 
434
-    if (!$delete_game) {
435
-        chess_show_board($gamedata, $orientation, $user_color, $move_performed, $move_result_text, $draw_claim_error_text, $show_arbiter_ctrl && $is_arbiter);
436
-    }
434
+	if (!$delete_game) {
435
+		chess_show_board($gamedata, $orientation, $user_color, $move_performed, $move_result_text, $draw_claim_error_text, $show_arbiter_ctrl && $is_arbiter);
436
+	}
437 437
 
438
-    // If a move (or other action) was made, notify any subscribers.
438
+	// If a move (or other action) was made, notify any subscribers.
439 439
 
440
-    if (!empty($notify)) {
441
-        $notificationHandler = xoops_getHandler('notification');
440
+	if (!empty($notify)) {
441
+		$notificationHandler = xoops_getHandler('notification');
442 442
 
443
-        $notificationHandler->triggerEvent('game', $game_id, 'notify_game_move', ['CHESS_ACTION' => $notify]);
443
+		$notificationHandler->triggerEvent('game', $game_id, 'notify_game_move', ['CHESS_ACTION' => $notify]);
444 444
 
445
-        // admin notifications
445
+		// admin notifications
446 446
 
447
-        if (_CHESS_MOVETYPE_WANT_ARBITRATION == $movetype) {
448
-            $event = 'notify_request_arbitration';
447
+		if (_CHESS_MOVETYPE_WANT_ARBITRATION == $movetype) {
448
+			$event = 'notify_request_arbitration';
449 449
 
450
-            $username = $xoopsUser ? $xoopsUser->getVar('uname') : '(' . _MD_CHESS_UNKNOWN . ')';
450
+			$username = $xoopsUser ? $xoopsUser->getVar('uname') : '(' . _MD_CHESS_UNKNOWN . ')';
451 451
 
452
-            $extra_tags = ['CHESS_REQUESTOR' => $username, 'CHESS_GAME_ID' => $game_id, 'CHESS_EXPLAIN' => $move_explain];
452
+			$extra_tags = ['CHESS_REQUESTOR' => $username, 'CHESS_GAME_ID' => $game_id, 'CHESS_EXPLAIN' => $move_explain];
453 453
 
454
-            $notificationHandler->triggerEvent('global', 0, $event, $extra_tags);
455
-        }
456
-    }
454
+			$notificationHandler->triggerEvent('global', 0, $event, $extra_tags);
455
+		}
456
+	}
457 457
 
458
-    // Handle delete-game action.
458
+	// Handle delete-game action.
459 459
 
460
-    if ($delete_game) {
461
-        chess_delete_game($game_id);
460
+	if ($delete_game) {
461
+		chess_delete_game($game_id);
462 462
 
463
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
464
-    }
463
+		redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
464
+	}
465 465
 }
466 466
 
467 467
 /**
@@ -472,19 +472,19 @@  discard block
 block discarded – undo
472 472
  */
473 473
 function chess_get_game($game_id)
474 474
 {
475
-    global $xoopsDB;
475
+	global $xoopsDB;
476 476
 
477
-    $games_table = $xoopsDB->prefix('chess_games');
477
+	$games_table = $xoopsDB->prefix('chess_games');
478 478
 
479
-    $result = $xoopsDB->query("SELECT * FROM $games_table WHERE game_id = '$game_id'");
479
+	$result = $xoopsDB->query("SELECT * FROM $games_table WHERE game_id = '$game_id'");
480 480
 
481
-    $gamedata = $xoopsDB->fetchArray($result);
481
+	$gamedata = $xoopsDB->fetchArray($result);
482 482
 
483
-    #var_dump('chess_get_game, gamedata', $gamedata);#*#DEBUG#
483
+	#var_dump('chess_get_game, gamedata', $gamedata);#*#DEBUG#
484 484
 
485
-    $xoopsDB->freeRecordSet($result);
485
+	$xoopsDB->freeRecordSet($result);
486 486
 
487
-    return $gamedata;
487
+	return $gamedata;
488 488
 }
489 489
 
490 490
 /**
@@ -495,21 +495,21 @@  discard block
 block discarded – undo
495 495
  */
496 496
 function chess_put_game($game_id, $gamedata)
497 497
 {
498
-    global $xoopsDB;
498
+	global $xoopsDB;
499 499
 
500
-    $myts = MyTextSanitizer::getInstance();
500
+	$myts = MyTextSanitizer::getInstance();
501 501
 
502
-    $suspended_q = $myts->addSlashes($gamedata['suspended']);
502
+	$suspended_q = $myts->addSlashes($gamedata['suspended']);
503 503
 
504
-    $movetext_q = $myts->addSlashes($gamedata['pgn_movetext']);
504
+	$movetext_q = $myts->addSlashes($gamedata['pgn_movetext']);
505 505
 
506
-    $table = $xoopsDB->prefix('chess_games');
506
+	$table = $xoopsDB->prefix('chess_games');
507 507
 
508
-    #echo "updating database table $table<br>\n";#*#DEBUG#
508
+	#echo "updating database table $table<br>\n";#*#DEBUG#
509 509
 
510
-    $xoopsDB->query(
511
-        trim(
512
-            "
510
+	$xoopsDB->query(
511
+		trim(
512
+			"
513 513
         UPDATE $table
514 514
         SET
515 515
             start_date                   = '{$gamedata['start_date']}',
@@ -528,18 +528,18 @@  discard block
 block discarded – undo
528 528
             black_confirm                = '{$gamedata['black_confirm']}'
529 529
         WHERE  game_id = '$game_id'
530 530
     "
531
-        )
532
-    );
531
+		)
532
+	);
533 533
 
534
-    if ($xoopsDB->errno()) {
535
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
536
-    }
534
+	if ($xoopsDB->errno()) {
535
+		trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
536
+	}
537 537
 
538
-    if ('*' != $gamedata['pgn_result'] && '1' == $gamedata['is_rated']) {
539
-        require_once XOOPS_ROOT_PATH . '/modules/chess/include/ratings.php';
538
+	if ('*' != $gamedata['pgn_result'] && '1' == $gamedata['is_rated']) {
539
+		require_once XOOPS_ROOT_PATH . '/modules/chess/include/ratings.php';
540 540
 
541
-        chess_ratings_adj($game_id);
542
-    }
541
+		chess_ratings_adj($game_id);
542
+	}
543 543
 }
544 544
 
545 545
 /**
@@ -549,19 +549,19 @@  discard block
 block discarded – undo
549 549
  */
550 550
 function chess_delete_game($game_id)
551 551
 {
552
-    global $xoopsModule, $xoopsDB;
552
+	global $xoopsModule, $xoopsDB;
553 553
 
554
-    // delete notifications associated with this game
554
+	// delete notifications associated with this game
555 555
 
556
-    xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'game', $game_id);
556
+	xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'game', $game_id);
557 557
 
558
-    $table = $xoopsDB->prefix('chess_games');
558
+	$table = $xoopsDB->prefix('chess_games');
559 559
 
560
-    $xoopsDB->query("DELETE FROM $table WHERE game_id='$game_id'");
560
+	$xoopsDB->query("DELETE FROM $table WHERE game_id='$game_id'");
561 561
 
562
-    if ($xoopsDB->errno()) {
563
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
564
-    }
562
+	if ($xoopsDB->errno()) {
563
+		trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
564
+	}
565 565
 }
566 566
 
567 567
 /**
@@ -575,71 +575,71 @@  discard block
 block discarded – undo
575 575
  */
576 576
 function chess_move(&$gamedata, $move)
577 577
 {
578
-    $gamestate = [
579
-        'fen_piece_placement'          => $gamedata['fen_piece_placement'],
580
-        'fen_active_color'             => $gamedata['fen_active_color'],
581
-        'fen_castling_availability'    => $gamedata['fen_castling_availability'],
582
-        'fen_en_passant_target_square' => $gamedata['fen_en_passant_target_square'],
583
-        'fen_halfmove_clock'           => $gamedata['fen_halfmove_clock'],
584
-        'fen_fullmove_number'          => $gamedata['fen_fullmove_number'],
585
-        'pgn_fen'                      => $gamedata['pgn_fen'],
586
-        'pgn_result'                   => $gamedata['pgn_result'],
587
-        'pgn_movetext'                 => $gamedata['pgn_movetext'],
588
-    ];
578
+	$gamestate = [
579
+		'fen_piece_placement'          => $gamedata['fen_piece_placement'],
580
+		'fen_active_color'             => $gamedata['fen_active_color'],
581
+		'fen_castling_availability'    => $gamedata['fen_castling_availability'],
582
+		'fen_en_passant_target_square' => $gamedata['fen_en_passant_target_square'],
583
+		'fen_halfmove_clock'           => $gamedata['fen_halfmove_clock'],
584
+		'fen_fullmove_number'          => $gamedata['fen_fullmove_number'],
585
+		'pgn_fen'                      => $gamedata['pgn_fen'],
586
+		'pgn_result'                   => $gamedata['pgn_result'],
587
+		'pgn_movetext'                 => $gamedata['pgn_movetext'],
588
+	];
589 589
 
590
-    $chessgame = new Chess\ChessGame($gamestate);
590
+	$chessgame = new Chess\ChessGame($gamestate);
591 591
 
592
-    #echo "Performing move: '$move'<br>\n";#*#DEBUG#
592
+	#echo "Performing move: '$move'<br>\n";#*#DEBUG#
593 593
 
594
-    [$move_performed, $move_result_text] = $chessgame->move($move);
594
+	[$move_performed, $move_result_text] = $chessgame->move($move);
595 595
 
596
-    #echo "Move result: '$move_result_text'<br>\n";#*#DEBUG#
596
+	#echo "Move result: '$move_result_text'<br>\n";#*#DEBUG#
597 597
 
598
-    if ($move_performed) {
599
-        // The move was valid - update the game data.
598
+	if ($move_performed) {
599
+		// The move was valid - update the game data.
600 600
 
601
-        $new_gamestate = $chessgame->gamestate();
601
+		$new_gamestate = $chessgame->gamestate();
602 602
 
603
-        #var_dump('new_gamestate', $new_gamestate);#*#DEBUG#
603
+		#var_dump('new_gamestate', $new_gamestate);#*#DEBUG#
604 604
 
605
-        #*#DEBUG# - start
605
+		#*#DEBUG# - start
606 606
 
607
-        #if ($new_gamestate['fen_castling_availability'] != $gamedata['fen_castling_availability']) {
607
+		#if ($new_gamestate['fen_castling_availability'] != $gamedata['fen_castling_availability']) {
608 608
 
609
-        #    echo "*** castling_availability changed from '{$gamedata['fen_castling_availability']}' to '{$new_gamestate['fen_castling_availability']}' ***<br>\n";
609
+		#    echo "*** castling_availability changed from '{$gamedata['fen_castling_availability']}' to '{$new_gamestate['fen_castling_availability']}' ***<br>\n";
610 610
 
611
-        #}
611
+		#}
612 612
 
613
-        #*#DEBUG# - end
613
+		#*#DEBUG# - end
614 614
 
615
-        $gamedata['fen_piece_placement'] = $new_gamestate['fen_piece_placement'];
615
+		$gamedata['fen_piece_placement'] = $new_gamestate['fen_piece_placement'];
616 616
 
617
-        $gamedata['fen_active_color'] = $new_gamestate['fen_active_color'];
617
+		$gamedata['fen_active_color'] = $new_gamestate['fen_active_color'];
618 618
 
619
-        $gamedata['fen_castling_availability'] = $new_gamestate['fen_castling_availability'];
619
+		$gamedata['fen_castling_availability'] = $new_gamestate['fen_castling_availability'];
620 620
 
621
-        $gamedata['fen_en_passant_target_square'] = $new_gamestate['fen_en_passant_target_square'];
621
+		$gamedata['fen_en_passant_target_square'] = $new_gamestate['fen_en_passant_target_square'];
622 622
 
623
-        $gamedata['fen_halfmove_clock'] = $new_gamestate['fen_halfmove_clock'];
623
+		$gamedata['fen_halfmove_clock'] = $new_gamestate['fen_halfmove_clock'];
624 624
 
625
-        $gamedata['fen_fullmove_number'] = $new_gamestate['fen_fullmove_number'];
625
+		$gamedata['fen_fullmove_number'] = $new_gamestate['fen_fullmove_number'];
626 626
 
627
-        $gamedata['pgn_fen'] = $new_gamestate['pgn_fen'];
627
+		$gamedata['pgn_fen'] = $new_gamestate['pgn_fen'];
628 628
 
629
-        $gamedata['pgn_result'] = $new_gamestate['pgn_result'];
629
+		$gamedata['pgn_result'] = $new_gamestate['pgn_result'];
630 630
 
631
-        $gamedata['pgn_movetext'] = $new_gamestate['pgn_movetext'];
631
+		$gamedata['pgn_movetext'] = $new_gamestate['pgn_movetext'];
632 632
 
633
-        $gamedata['last_date'] = date('Y-m-d H:i:s');
633
+		$gamedata['last_date'] = date('Y-m-d H:i:s');
634 634
 
635
-        // if start_date undefined (first move), initialize it
635
+		// if start_date undefined (first move), initialize it
636 636
 
637
-        if ('0000-00-00 00:00:00' == $gamedata['start_date']) {
638
-            $gamedata['start_date'] = $gamedata['last_date'];
639
-        }
640
-    }
637
+		if ('0000-00-00 00:00:00' == $gamedata['start_date']) {
638
+			$gamedata['start_date'] = $gamedata['last_date'];
639
+		}
640
+	}
641 641
 
642
-    return [$move_performed, $move_result_text];
642
+	return [$move_performed, $move_result_text];
643 643
 }
644 644
 
645 645
 /**
@@ -652,19 +652,19 @@  discard block
 block discarded – undo
652 652
  */
653 653
 function chess_is_draw_50_move_rule($gamedata)
654 654
 {
655
-    #var_dump('gamedata', $gamedata);#*#DEBUG#
655
+	#var_dump('gamedata', $gamedata);#*#DEBUG#
656 656
 
657
-    if ($gamedata['fen_halfmove_clock'] >= 100) {
658
-        $draw_claim_valid = true;
657
+	if ($gamedata['fen_halfmove_clock'] >= 100) {
658
+		$draw_claim_valid = true;
659 659
 
660
-        $draw_claim_text = _MD_CHESS_DRAW_50;
661
-    } else {
662
-        $draw_claim_valid = false;
660
+		$draw_claim_text = _MD_CHESS_DRAW_50;
661
+	} else {
662
+		$draw_claim_valid = false;
663 663
 
664
-        $draw_claim_text = _MD_CHESS_NO_DRAW_50;
665
-    }
664
+		$draw_claim_text = _MD_CHESS_NO_DRAW_50;
665
+	}
666 666
 
667
-    return [$draw_claim_valid, $draw_claim_text];
667
+	return [$draw_claim_valid, $draw_claim_text];
668 668
 }
669 669
 
670 670
 /**
@@ -680,41 +680,41 @@  discard block
 block discarded – undo
680 680
  */
681 681
 function chess_is_draw_threefold_repetition($gamedata)
682 682
 {
683
-    #var_dump('gamedata', $gamedata);#*#DEBUG#
683
+	#var_dump('gamedata', $gamedata);#*#DEBUG#
684 684
 
685
-    // Define this constant as true to output a log file containing a move analysis.
685
+	// Define this constant as true to output a log file containing a move analysis.
686 686
 
687
-    define('CHESS_LOG_3FOLD', false);
687
+	define('CHESS_LOG_3FOLD', false);
688 688
 
689
-    if (CHESS_LOG_3FOLD) {
690
-        $log = [];
691
-    }
689
+	if (CHESS_LOG_3FOLD) {
690
+		$log = [];
691
+	}
692 692
 
693
-    $chessgame = new Chess\ChessGame($gamedata);
693
+	$chessgame = new Chess\ChessGame($gamedata);
694 694
 
695
-    // board position against which to check for repetitions
695
+	// board position against which to check for repetitions
696 696
 
697
-    $last_board_state = "{$gamedata['fen_piece_placement']} {$gamedata['fen_active_color']} {$gamedata['fen_castling_availability']} {$gamedata['fen_en_passant_target_square']}";
697
+	$last_board_state = "{$gamedata['fen_piece_placement']} {$gamedata['fen_active_color']} {$gamedata['fen_castling_availability']} {$gamedata['fen_en_passant_target_square']}";
698 698
 
699
-    $last_move_number = $gamedata['fen_fullmove_number'];
699
+	$last_move_number = $gamedata['fen_fullmove_number'];
700 700
 
701
-    #echo "last_board_state='$last_board_state'<br>\n";#*#DEBUG#
701
+	#echo "last_board_state='$last_board_state'<br>\n";#*#DEBUG#
702 702
 
703
-    if (CHESS_LOG_3FOLD) {
704
-        $log[] = sprintf('%08x %03d%1s %s', crc32($last_board_state), $gamedata['fen_fullmove_number'], $gamedata['fen_active_color'], $last_board_state);
705
-    }
703
+	if (CHESS_LOG_3FOLD) {
704
+		$log[] = sprintf('%08x %03d%1s %s', crc32($last_board_state), $gamedata['fen_fullmove_number'], $gamedata['fen_active_color'], $last_board_state);
705
+	}
706 706
 
707
-    $chessgame = new Chess\ChessGame($gamedata['pgn_fen']);
707
+	$chessgame = new Chess\ChessGame($gamedata['pgn_fen']);
708 708
 
709
-    empty($chessgame->error) or trigger_error('chessgame invalid', E_USER_ERROR);
709
+	empty($chessgame->error) or trigger_error('chessgame invalid', E_USER_ERROR);
710 710
 
711
-    $tmp_gamedata = $chessgame->gamestate();
711
+	$tmp_gamedata = $chessgame->gamestate();
712 712
 
713
-    is_array($tmp_gamedata) or trigger_error('gamestate invalid', E_USER_ERROR);
713
+	is_array($tmp_gamedata) or trigger_error('gamestate invalid', E_USER_ERROR);
714 714
 
715
-    #*#DEBUG# - start
715
+	#*#DEBUG# - start
716 716
 
717
-    /***
717
+	/***
718 718
      * if (function_exists('posix_times')) {
719 719
      * $posix_times = posix_times();
720 720
      * var_dump('posix_times', $posix_times);
@@ -725,92 +725,92 @@  discard block
 block discarded – undo
725 725
      * }
726 726
      ***/
727 727
 
728
-    #*#DEBUG# - end
728
+	#*#DEBUG# - end
729 729
 
730
-    // $repeats is the list of moves for which the board positions are identical.
730
+	// $repeats is the list of moves for which the board positions are identical.
731 731
 
732
-    // For example, '6w' would represent the board position immediately before white's sixth move.
732
+	// For example, '6w' would represent the board position immediately before white's sixth move.
733 733
 
734
-    // The current position is included, since that's the position against which the other positions will be compared.
734
+	// The current position is included, since that's the position against which the other positions will be compared.
735 735
 
736
-    $repeats[] = $gamedata['fen_fullmove_number'] . $gamedata['fen_active_color'];
736
+	$repeats[] = $gamedata['fen_fullmove_number'] . $gamedata['fen_active_color'];
737 737
 
738
-    // Compare initial board position with last board position, unless the move number is the same, meaning that there haven't been any moves.
738
+	// Compare initial board position with last board position, unless the move number is the same, meaning that there haven't been any moves.
739 739
 
740
-    #echo "FEN: '{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']} {$tmp_gamedata['fen_halfmove_clock']} {$tmp_gamedata['fen_fullmove_number']}'<br>\n";#*#DEBUG#
740
+	#echo "FEN: '{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']} {$tmp_gamedata['fen_halfmove_clock']} {$tmp_gamedata['fen_fullmove_number']}'<br>\n";#*#DEBUG#
741 741
 
742
-    $board_state = "{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']}";
742
+	$board_state = "{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']}";
743 743
 
744
-    if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
745
-        $repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
744
+	if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
745
+		$repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
746 746
 
747
-        if (CHESS_LOG_3FOLD) {
748
-            $log[] = sprintf('%08x %03d%1s %s', crc32($board_state), $tmp_gamedata['fen_fullmove_number'], $tmp_gamedata['fen_active_color'], $board_state);
749
-        }
747
+		if (CHESS_LOG_3FOLD) {
748
+			$log[] = sprintf('%08x %03d%1s %s', crc32($board_state), $tmp_gamedata['fen_fullmove_number'], $tmp_gamedata['fen_active_color'], $board_state);
749
+		}
750 750
 
751
-        #*#DEBUG# - start
752
-        /***
751
+		#*#DEBUG# - start
752
+		/***
753 753
          * if (count($repeats) >= 3) {
754 754
          * echo "*** Three repetitions! {$repeats[1]},{$repeats[2]},{$repeats[0]} ***<br>\n";
755 755
          * } elseif (count($repeats) >= 2) {
756 756
          * echo "*** Two repetitions!  {$repeats[1]},{$repeats[0]} ***<br>\n";
757 757
          * }
758 758
          ***/
759
-        #*#DEBUG# - end
760
-    }
759
+		#*#DEBUG# - end
760
+	}
761 761
 
762
-    // Convert pgn_movetext into Nx3 array $movelist.
762
+	// Convert pgn_movetext into Nx3 array $movelist.
763 763
 
764
-    $movelist = chess_make_movelist($gamedata['pgn_movetext']);
764
+	$movelist = chess_make_movelist($gamedata['pgn_movetext']);
765 765
 
766
-    #var_dump('movelist', $movelist);#*#DEBUG#
766
+	#var_dump('movelist', $movelist);#*#DEBUG#
767 767
 
768
-    // Compare board positions after each move with last board position.
768
+	// Compare board positions after each move with last board position.
769 769
 
770
-    foreach ($movelist as $fullmove) {
771
-        #echo "'{$fullmove[0]}' '{$fullmove[1]}' '{$fullmove[2]}'<br>\n";#*#DEBUG#
770
+	foreach ($movelist as $fullmove) {
771
+		#echo "'{$fullmove[0]}' '{$fullmove[1]}' '{$fullmove[2]}'<br>\n";#*#DEBUG#
772 772
 
773
-        if (CHESS_LOG_3FOLD) {
774
-            #$log[] = "'{$fullmove[0]}' '{$fullmove[1]}' '{$fullmove[2]}'";#*#LOG_3FOLD# #*#DEBUG#
775
-        }
773
+		if (CHESS_LOG_3FOLD) {
774
+			#$log[] = "'{$fullmove[0]}' '{$fullmove[1]}' '{$fullmove[2]}'";#*#LOG_3FOLD# #*#DEBUG#
775
+		}
776 776
 
777
-        for ($i = 1; $i <= 2; ++$i) {
778
-            if (!empty($fullmove[$i])) {
779
-                $move = $fullmove[$i];
780
-            } else {
781
-                continue; // $fullmove[$i] can be empty if last move was white's, or if game was setup with black to move first.
782
-            }
777
+		for ($i = 1; $i <= 2; ++$i) {
778
+			if (!empty($fullmove[$i])) {
779
+				$move = $fullmove[$i];
780
+			} else {
781
+				continue; // $fullmove[$i] can be empty if last move was white's, or if game was setup with black to move first.
782
+			}
783 783
 
784
-            // Remove check/checkmate annotation, if present.
784
+			// Remove check/checkmate annotation, if present.
785 785
 
786
-            $move = str_replace('+', '', $move);
786
+			$move = str_replace('+', '', $move);
787 787
 
788
-            $move = str_replace('#', '', $move);
788
+			$move = str_replace('#', '', $move);
789 789
 
790
-            #echo "Performing move: '$move'<br>\n";#*#DEBUG#
790
+			#echo "Performing move: '$move'<br>\n";#*#DEBUG#
791 791
 
792
-            [$tmp_move_performed, $tmp_move_result_text] = $chessgame->move($move);
792
+			[$tmp_move_performed, $tmp_move_result_text] = $chessgame->move($move);
793 793
 
794
-            #echo "Move result: '$tmp_move_result_text'<br>\n";#*#DEBUG#
794
+			#echo "Move result: '$tmp_move_result_text'<br>\n";#*#DEBUG#
795 795
 
796
-            $tmp_move_performed or trigger_error("Failed to perform move $move: $tmp_move_result_text", E_USER_ERROR);
796
+			$tmp_move_performed or trigger_error("Failed to perform move $move: $tmp_move_result_text", E_USER_ERROR);
797 797
 
798
-            $tmp_gamedata = $chessgame->gamestate();
798
+			$tmp_gamedata = $chessgame->gamestate();
799 799
 
800
-            #echo "FEN: '{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']} {$tmp_gamedata['fen_halfmove_clock']} {$tmp_gamedata['fen_fullmove_number']}'<br>\n";#*#DEBUG#
800
+			#echo "FEN: '{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']} {$tmp_gamedata['fen_halfmove_clock']} {$tmp_gamedata['fen_fullmove_number']}'<br>\n";#*#DEBUG#
801 801
 
802
-            $board_state = "{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']}";
802
+			$board_state = "{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']}";
803 803
 
804
-            if (CHESS_LOG_3FOLD) {
805
-                $log[] = sprintf('%08x %03d%1s %s', crc32($board_state), $tmp_gamedata['fen_fullmove_number'], $tmp_gamedata['fen_active_color'], $board_state);
806
-            }
804
+			if (CHESS_LOG_3FOLD) {
805
+				$log[] = sprintf('%08x %03d%1s %s', crc32($board_state), $tmp_gamedata['fen_fullmove_number'], $tmp_gamedata['fen_active_color'], $board_state);
806
+			}
807 807
 
808
-            if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
809
-                $repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
808
+			if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
809
+				$repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
810 810
 
811
-                #*#DEBUG# - start
811
+				#*#DEBUG# - start
812 812
 
813
-                /***
813
+				/***
814 814
                  * if (count($repeats) >= 3) {
815 815
                  * echo "*** Three repetitions! {$repeats[1]},{$repeats[2]},{$repeats[0]} ***<br>\n";
816 816
                  * } elseif (count($repeats) >= 2) {
@@ -818,18 +818,18 @@  discard block
 block discarded – undo
818 818
                  * }
819 819
                  ***/
820 820
 
821
-                #*#DEBUG# - end
821
+				#*#DEBUG# - end
822 822
 
823
-                if (count($repeats) >= 3) {
824
-                    break 2;
825
-                }
826
-            }
827
-        }
828
-    }
823
+				if (count($repeats) >= 3) {
824
+					break 2;
825
+				}
826
+			}
827
+		}
828
+	}
829 829
 
830
-    #*#DEBUG# - start
830
+	#*#DEBUG# - start
831 831
 
832
-    /***
832
+	/***
833 833
      * if (function_exists('posix_times')) {
834 834
      * $posix_times = posix_times();
835 835
      * var_dump('posix_times', $posix_times);
@@ -840,27 +840,27 @@  discard block
 block discarded – undo
840 840
      * }
841 841
      ***/
842 842
 
843
-    #*#DEBUG# - end
843
+	#*#DEBUG# - end
844 844
 
845
-    if (count($repeats) >= 3) {
846
-        $draw_claim_valid = true;
845
+	if (count($repeats) >= 3) {
846
+		$draw_claim_valid = true;
847 847
 
848
-        $draw_claim_text = sprintf(_MD_CHESS_DRAW_3, "{$repeats[1]},{$repeats[2]},{$repeats[0]}");
849
-    } else {
850
-        $draw_claim_valid = false;
848
+		$draw_claim_text = sprintf(_MD_CHESS_DRAW_3, "{$repeats[1]},{$repeats[2]},{$repeats[0]}");
849
+	} else {
850
+		$draw_claim_valid = false;
851 851
 
852
-        $draw_claim_text = _MD_CHESS_NO_DRAW_3;
853
-    }
852
+		$draw_claim_text = _MD_CHESS_NO_DRAW_3;
853
+	}
854 854
 
855
-    if (CHESS_LOG_3FOLD) {
856
-        $logfile = XOOPS_ROOT_PATH . '/cache/' . date('Ymd_His') . '_3fold.log';
855
+	if (CHESS_LOG_3FOLD) {
856
+		$logfile = XOOPS_ROOT_PATH . '/cache/' . date('Ymd_His') . '_3fold.log';
857 857
 
858
-        sort($log);
858
+		sort($log);
859 859
 
860
-        error_log(implode("\n", $log), 3, $logfile);
861
-    }
860
+		error_log(implode("\n", $log), 3, $logfile);
861
+	}
862 862
 
863
-    return [$draw_claim_valid, $draw_claim_text];
863
+	return [$draw_claim_valid, $draw_claim_text];
864 864
 }
865 865
 
866 866
 /**
@@ -871,31 +871,31 @@  discard block
 block discarded – undo
871 871
  */
872 872
 function chess_make_movelist($movetext)
873 873
 {
874
-    $movelist = [];
874
+	$movelist = [];
875 875
 
876
-    $move_tokens = explode(' ', preg_replace('/\{.*\}/', '', $movetext));
876
+	$move_tokens = explode(' ', preg_replace('/\{.*\}/', '', $movetext));
877 877
 
878
-    $index = -1;
878
+	$index = -1;
879 879
 
880
-    while ($move_tokens) {
881
-        $move_token = array_shift($move_tokens);
880
+	while ($move_tokens) {
881
+		$move_token = array_shift($move_tokens);
882 882
 
883
-        if (in_array($move_token, ['1-0', '0-1', '1/2-1/2', '*'])) {
884
-            break;
885
-        } elseif (preg_match('/^\d+(\.|\.\.\.)$/', $move_token, $matches)) {
886
-            ++$index;
883
+		if (in_array($move_token, ['1-0', '0-1', '1/2-1/2', '*'])) {
884
+			break;
885
+		} elseif (preg_match('/^\d+(\.|\.\.\.)$/', $move_token, $matches)) {
886
+			++$index;
887 887
 
888
-            $movelist[$index][] = $move_token;
888
+			$movelist[$index][] = $move_token;
889 889
 
890
-            if ('...' == $matches[1]) { // setup-game with initial black move - add padding for white's move
891
-                $movelist[$index][] = '';
892
-            }
893
-        } else {
894
-            $movelist[$index][] = $move_token;
895
-        }
896
-    }
890
+			if ('...' == $matches[1]) { // setup-game with initial black move - add padding for white's move
891
+				$movelist[$index][] = '';
892
+			}
893
+		} else {
894
+			$movelist[$index][] = $move_token;
895
+		}
896
+	}
897 897
 
898
-    return $movelist;
898
+	return $movelist;
899 899
 }
900 900
 
901 901
 /**
@@ -911,252 +911,252 @@  discard block
 block discarded – undo
911 911
  */
912 912
 function chess_show_board($gamedata, $orientation, $user_color, $move_performed, $move_result_text = '', $draw_claim_error_text = '', $show_arbiter_ctrl = false)
913 913
 {
914
-    global $xoopsTpl;
914
+	global $xoopsTpl;
915 915
 
916
-    $xoopsTpl->assign(
917
-        'xoops_module_header',
918
-        '
916
+	$xoopsTpl->assign(
917
+		'xoops_module_header',
918
+		'
919 919
         <link rel="stylesheet" type="text/css" media="screen" href="' . XOOPS_URL . '/modules/chess/assets/css/style.css">
920 920
     '
921
-    );
921
+	);
922 922
 
923
-    $memberHandler = xoops_getHandler('member');
923
+	$memberHandler = xoops_getHandler('member');
924 924
 
925
-    $white_user = $memberHandler->getUser($gamedata['white_uid']);
925
+	$white_user = $memberHandler->getUser($gamedata['white_uid']);
926 926
 
927
-    $white_username = is_object($white_user) ? $white_user->getVar('uname') : '?';
927
+	$white_username = is_object($white_user) ? $white_user->getVar('uname') : '?';
928 928
 
929
-    $black_user = $memberHandler->getUser($gamedata['black_uid']);
929
+	$black_user = $memberHandler->getUser($gamedata['black_uid']);
930 930
 
931
-    $black_username = is_object($black_user) ? $black_user->getVar('uname') : '?';
931
+	$black_username = is_object($black_user) ? $black_user->getVar('uname') : '?';
932 932
 
933
-    // Determine whether board is flipped (black at bottom) or "normal" (white at bottom).
933
+	// Determine whether board is flipped (black at bottom) or "normal" (white at bottom).
934 934
 
935
-    switch ($orientation) {
936
-        default:
937
-        case _CHESS_ORIENTATION_ACTIVE:
938
-            $flip = 'b' == $gamedata['fen_active_color'];
939
-            break;
940
-        case _CHESS_ORIENTATION_WHITE:
941
-            $flip = false;
942
-            break;
943
-        case _CHESS_ORIENTATION_BLACK:
944
-            $flip = true;
945
-            break;
946
-    }
935
+	switch ($orientation) {
936
+		default:
937
+		case _CHESS_ORIENTATION_ACTIVE:
938
+			$flip = 'b' == $gamedata['fen_active_color'];
939
+			break;
940
+		case _CHESS_ORIENTATION_WHITE:
941
+			$flip = false;
942
+			break;
943
+		case _CHESS_ORIENTATION_BLACK:
944
+			$flip = true;
945
+			break;
946
+	}
947 947
 
948
-    // Convert fen_piece_placement string into 8x8-array $tiles.
948
+	// Convert fen_piece_placement string into 8x8-array $tiles.
949 949
 
950
-    $tiles = [];
950
+	$tiles = [];
951 951
 
952
-    $ranks = explode('/', $gamedata['fen_piece_placement']);
952
+	$ranks = explode('/', $gamedata['fen_piece_placement']);
953 953
 
954
-    if ($flip) {
955
-        $ranks = array_reverse($ranks);
956
-    }
954
+	if ($flip) {
955
+		$ranks = array_reverse($ranks);
956
+	}
957 957
 
958
-    foreach ($ranks as $rank) {
959
-        $expanded_row = preg_replace_callback(
960
-            '/(\d)/',
958
+	foreach ($ranks as $rank) {
959
+		$expanded_row = preg_replace_callback(
960
+			'/(\d)/',
961 961
 
962
-            static function ($matches) {
963
-                return str_repeat('x', $matches[1]);
964
-            },
965
-            $rank
966
-        );
962
+			static function ($matches) {
963
+				return str_repeat('x', $matches[1]);
964
+			},
965
+			$rank
966
+		);
967 967
 
968
-        $rank_tiles = preg_split('//', $expanded_row, -1, PREG_SPLIT_NO_EMPTY);
968
+		$rank_tiles = preg_split('//', $expanded_row, -1, PREG_SPLIT_NO_EMPTY);
969 969
 
970
-        $tiles[] = $flip ? array_reverse($rank_tiles) : $rank_tiles;
971
-    }
970
+		$tiles[] = $flip ? array_reverse($rank_tiles) : $rank_tiles;
971
+	}
972 972
 
973
-    #var_dump('tiles', $tiles);#*#DEBUG#
973
+	#var_dump('tiles', $tiles);#*#DEBUG#
974 974
 
975
-    // Convert pgn_movetext into Nx3 array $movelist.
975
+	// Convert pgn_movetext into Nx3 array $movelist.
976 976
 
977
-    $movelist = chess_make_movelist($gamedata['pgn_movetext']);
977
+	$movelist = chess_make_movelist($gamedata['pgn_movetext']);
978 978
 
979
-    static $file_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
979
+	static $file_labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
980 980
 
981
-    if ($flip) {
982
-        $file_labels = array_reverse($file_labels);
983
-    }
981
+	if ($flip) {
982
+		$file_labels = array_reverse($file_labels);
983
+	}
984 984
 
985
-    $xoopsTpl->assign('chess_gamedata', $gamedata);
985
+	$xoopsTpl->assign('chess_gamedata', $gamedata);
986 986
 
987
-    // comment at end of movetext
987
+	// comment at end of movetext
988 988
 
989
-    if (preg_match('/\{(.*?)\}\s*$/', $gamedata['pgn_movetext'], $matches)) {
990
-        $xoopsTpl->assign('chess_result_comment', $matches[1]);
991
-    } else {
992
-        $xoopsTpl->assign('chess_result_comment', '');
993
-    }
989
+	if (preg_match('/\{(.*?)\}\s*$/', $gamedata['pgn_movetext'], $matches)) {
990
+		$xoopsTpl->assign('chess_result_comment', $matches[1]);
991
+	} else {
992
+		$xoopsTpl->assign('chess_result_comment', '');
993
+	}
994 994
 
995
-    $xoopsTpl->assign('chess_create_date', '0000-00-00 00:00:00' != $gamedata['create_date'] ? strtotime($gamedata['create_date']) : 0);
995
+	$xoopsTpl->assign('chess_create_date', '0000-00-00 00:00:00' != $gamedata['create_date'] ? strtotime($gamedata['create_date']) : 0);
996 996
 
997
-    $xoopsTpl->assign('chess_start_date', '0000-00-00 00:00:00' != $gamedata['start_date'] ? strtotime($gamedata['start_date']) : 0);
997
+	$xoopsTpl->assign('chess_start_date', '0000-00-00 00:00:00' != $gamedata['start_date'] ? strtotime($gamedata['start_date']) : 0);
998 998
 
999
-    $xoopsTpl->assign('chess_last_date', '0000-00-00 00:00:00' != $gamedata['last_date'] ? strtotime($gamedata['last_date']) : 0);
999
+	$xoopsTpl->assign('chess_last_date', '0000-00-00 00:00:00' != $gamedata['last_date'] ? strtotime($gamedata['last_date']) : 0);
1000 1000
 
1001
-    $xoopsTpl->assign('chess_white_user', $white_username);
1001
+	$xoopsTpl->assign('chess_white_user', $white_username);
1002 1002
 
1003
-    $xoopsTpl->assign('chess_black_user', $black_username);
1003
+	$xoopsTpl->assign('chess_black_user', $black_username);
1004 1004
 
1005
-    $xoopsTpl->assign('chess_tiles', $tiles);
1005
+	$xoopsTpl->assign('chess_tiles', $tiles);
1006 1006
 
1007
-    $xoopsTpl->assign('chess_file_labels', $file_labels);
1007
+	$xoopsTpl->assign('chess_file_labels', $file_labels);
1008 1008
 
1009
-    $xoopsTpl->assign(
1010
-        'chess_pgn_string',
1011
-        chess_to_pgn_string(
1012
-            [
1013
-                'event'    => '?',
1014
-                'site'     => $_SERVER['SERVER_NAME'],
1015
-                'datetime' => $gamedata['start_date'],
1016
-                'round'    => '?',
1017
-                'white'    => $white_username,
1018
-                'black'    => $black_username,
1019
-                'result'   => $gamedata['pgn_result'],
1020
-                'setup'    => !empty($gamedata['pgn_fen']) ? 1 : 0,
1021
-                'fen'      => $gamedata['pgn_fen'],
1022
-                'movetext' => $gamedata['pgn_movetext'],
1023
-            ]
1024
-        )
1025
-    );
1009
+	$xoopsTpl->assign(
1010
+		'chess_pgn_string',
1011
+		chess_to_pgn_string(
1012
+			[
1013
+				'event'    => '?',
1014
+				'site'     => $_SERVER['SERVER_NAME'],
1015
+				'datetime' => $gamedata['start_date'],
1016
+				'round'    => '?',
1017
+				'white'    => $white_username,
1018
+				'black'    => $black_username,
1019
+				'result'   => $gamedata['pgn_result'],
1020
+				'setup'    => !empty($gamedata['pgn_fen']) ? 1 : 0,
1021
+				'fen'      => $gamedata['pgn_fen'],
1022
+				'movetext' => $gamedata['pgn_movetext'],
1023
+			]
1024
+		)
1025
+	);
1026 1026
 
1027
-    $xoopsTpl->assign('chess_movelist', $movelist);
1027
+	$xoopsTpl->assign('chess_movelist', $movelist);
1028 1028
 
1029
-    $xoopsTpl->assign('chess_date_format', _MEDIUMDATESTRING);
1029
+	$xoopsTpl->assign('chess_date_format', _MEDIUMDATESTRING);
1030 1030
 
1031
-    #if (empty($move_result_text)) {$move_result_text = 'test';}#*#DEBUG#
1031
+	#if (empty($move_result_text)) {$move_result_text = 'test';}#*#DEBUG#
1032 1032
 
1033
-    $xoopsTpl->assign('chess_move_performed', $move_performed);
1033
+	$xoopsTpl->assign('chess_move_performed', $move_performed);
1034 1034
 
1035
-    $xoopsTpl->assign('chess_move_result', $move_result_text);
1035
+	$xoopsTpl->assign('chess_move_result', $move_result_text);
1036 1036
 
1037
-    $xoopsTpl->assign('chess_draw_claim_error_text', $draw_claim_error_text);
1037
+	$xoopsTpl->assign('chess_draw_claim_error_text', $draw_claim_error_text);
1038 1038
 
1039
-    $xoopsTpl->assign('chess_user_color', $user_color);
1039
+	$xoopsTpl->assign('chess_user_color', $user_color);
1040 1040
 
1041
-    $xoopsTpl->assign('chess_confirm', $gamedata['w' == $user_color ? 'white_confirm' : 'black_confirm']);
1041
+	$xoopsTpl->assign('chess_confirm', $gamedata['w' == $user_color ? 'white_confirm' : 'black_confirm']);
1042 1042
 
1043
-    $xoopsTpl->assign('chess_orientation', $orientation);
1043
+	$xoopsTpl->assign('chess_orientation', $orientation);
1044 1044
 
1045
-    $xoopsTpl->assign('chess_rank_start', $flip ? 1 : 8);
1045
+	$xoopsTpl->assign('chess_rank_start', $flip ? 1 : 8);
1046 1046
 
1047
-    $xoopsTpl->assign('chess_rank_direction', $flip ? 'up' : 'down');
1047
+	$xoopsTpl->assign('chess_rank_direction', $flip ? 'up' : 'down');
1048 1048
 
1049
-    $xoopsTpl->assign('chess_file_start', $flip ? 8 : 1);
1049
+	$xoopsTpl->assign('chess_file_start', $flip ? 8 : 1);
1050 1050
 
1051
-    $xoopsTpl->assign('chess_file_direction', $flip ? 'down' : 'up');
1051
+	$xoopsTpl->assign('chess_file_direction', $flip ? 'down' : 'up');
1052 1052
 
1053
-    static $pieces = [
1054
-        'K' => ['color' => 'w', 'name' => 'wking', 'alt' => _MD_CHESS_ALT_WKING],
1055
-        'Q' => ['color' => 'w', 'name' => 'wqueen', 'alt' => _MD_CHESS_ALT_WQUEEN],
1056
-        'R' => ['color' => 'w', 'name' => 'wrook', 'alt' => _MD_CHESS_ALT_WROOK],
1057
-        'B' => ['color' => 'w', 'name' => 'wbishop', 'alt' => _MD_CHESS_ALT_WBISHOP],
1058
-        'N' => ['color' => 'w', 'name' => 'wknight', 'alt' => _MD_CHESS_ALT_WKNIGHT],
1059
-        'P' => ['color' => 'w', 'name' => 'wpawn', 'alt' => _MD_CHESS_ALT_WPAWN],
1060
-        'k' => ['color' => 'b', 'name' => 'bking', 'alt' => _MD_CHESS_ALT_BKING],
1061
-        'q' => ['color' => 'b', 'name' => 'bqueen', 'alt' => _MD_CHESS_ALT_BQUEEN],
1062
-        'r' => ['color' => 'b', 'name' => 'brook', 'alt' => _MD_CHESS_ALT_BROOK],
1063
-        'b' => ['color' => 'b', 'name' => 'bbishop', 'alt' => _MD_CHESS_ALT_BBISHOP],
1064
-        'n' => ['color' => 'b', 'name' => 'bknight', 'alt' => _MD_CHESS_ALT_BKNIGHT],
1065
-        'p' => ['color' => 'b', 'name' => 'bpawn', 'alt' => _MD_CHESS_ALT_BPAWN],
1066
-        'x' => ['color' => 'x', 'name' => 'empty', 'alt' => _MD_CHESS_ALT_EMPTY],
1067
-    ];
1053
+	static $pieces = [
1054
+		'K' => ['color' => 'w', 'name' => 'wking', 'alt' => _MD_CHESS_ALT_WKING],
1055
+		'Q' => ['color' => 'w', 'name' => 'wqueen', 'alt' => _MD_CHESS_ALT_WQUEEN],
1056
+		'R' => ['color' => 'w', 'name' => 'wrook', 'alt' => _MD_CHESS_ALT_WROOK],
1057
+		'B' => ['color' => 'w', 'name' => 'wbishop', 'alt' => _MD_CHESS_ALT_WBISHOP],
1058
+		'N' => ['color' => 'w', 'name' => 'wknight', 'alt' => _MD_CHESS_ALT_WKNIGHT],
1059
+		'P' => ['color' => 'w', 'name' => 'wpawn', 'alt' => _MD_CHESS_ALT_WPAWN],
1060
+		'k' => ['color' => 'b', 'name' => 'bking', 'alt' => _MD_CHESS_ALT_BKING],
1061
+		'q' => ['color' => 'b', 'name' => 'bqueen', 'alt' => _MD_CHESS_ALT_BQUEEN],
1062
+		'r' => ['color' => 'b', 'name' => 'brook', 'alt' => _MD_CHESS_ALT_BROOK],
1063
+		'b' => ['color' => 'b', 'name' => 'bbishop', 'alt' => _MD_CHESS_ALT_BBISHOP],
1064
+		'n' => ['color' => 'b', 'name' => 'bknight', 'alt' => _MD_CHESS_ALT_BKNIGHT],
1065
+		'p' => ['color' => 'b', 'name' => 'bpawn', 'alt' => _MD_CHESS_ALT_BPAWN],
1066
+		'x' => ['color' => 'x', 'name' => 'empty', 'alt' => _MD_CHESS_ALT_EMPTY],
1067
+	];
1068 1068
 
1069
-    $xoopsTpl->assign('chess_pieces', $pieces);
1069
+	$xoopsTpl->assign('chess_pieces', $pieces);
1070 1070
 
1071
-    $xoopsTpl->assign('chess_show_arbitration_controls', $show_arbiter_ctrl);
1071
+	$xoopsTpl->assign('chess_show_arbitration_controls', $show_arbiter_ctrl);
1072 1072
 
1073
-    if ($show_arbiter_ctrl && $gamedata['suspended']) {
1074
-        [$susp_date, $susp_uid, $susp_type, $susp_explain] = explode('|', $gamedata['suspended']);
1073
+	if ($show_arbiter_ctrl && $gamedata['suspended']) {
1074
+		[$susp_date, $susp_uid, $susp_type, $susp_explain] = explode('|', $gamedata['suspended']);
1075 1075
 
1076
-        switch ($susp_type) {
1077
-            case 'arbiter_suspend':
1078
-                $susp_type_display = _MD_CHESS_SUSP_TYPE_ARBITER;
1079
-                break;
1080
-            case 'want_arbitration':
1081
-                $susp_type_display = _MD_CHESS_SUSP_TYPE_PLAYER;
1082
-                break;
1083
-            default:
1084
-                $susp_type_display = _MD_CHESS_LABEL_ERROR;
1085
-                break;
1086
-        }
1076
+		switch ($susp_type) {
1077
+			case 'arbiter_suspend':
1078
+				$susp_type_display = _MD_CHESS_SUSP_TYPE_ARBITER;
1079
+				break;
1080
+			case 'want_arbitration':
1081
+				$susp_type_display = _MD_CHESS_SUSP_TYPE_PLAYER;
1082
+				break;
1083
+			default:
1084
+				$susp_type_display = _MD_CHESS_LABEL_ERROR;
1085
+				break;
1086
+		}
1087 1087
 
1088
-        $susp_user = $memberHandler->getUser($susp_uid);
1088
+		$susp_user = $memberHandler->getUser($susp_uid);
1089 1089
 
1090
-        $susp_username = is_object($susp_user) ? $susp_user->getVar('uname') : _MD_CHESS_UNKNOWN;
1090
+		$susp_username = is_object($susp_user) ? $susp_user->getVar('uname') : _MD_CHESS_UNKNOWN;
1091 1091
 
1092
-        $suspend_info = [
1093
-            'date'   => strtotime($susp_date),
1094
-            'user'   => $susp_username,
1095
-            'type'   => $susp_type_display,
1096
-            'reason' => $susp_explain,
1097
-        ];
1092
+		$suspend_info = [
1093
+			'date'   => strtotime($susp_date),
1094
+			'user'   => $susp_username,
1095
+			'type'   => $susp_type_display,
1096
+			'reason' => $susp_explain,
1097
+		];
1098 1098
 
1099
-        $xoopsTpl->assign('chess_suspend_info', $suspend_info);
1100
-    }
1099
+		$xoopsTpl->assign('chess_suspend_info', $suspend_info);
1100
+	}
1101 1101
 
1102
-    // Initialize $captured_pieces_all to indicate all pieces captured, then subtract off the pieces remaining on the board.
1102
+	// Initialize $captured_pieces_all to indicate all pieces captured, then subtract off the pieces remaining on the board.
1103 1103
 
1104
-    $captured_pieces_all = [
1105
-        'Q' => 1,
1106
-        'R' => 2,
1107
-        'B' => 2,
1108
-        'N' => 2,
1109
-        'P' => 8,
1110
-        'q' => 1,
1111
-        'r' => 2,
1112
-        'b' => 2,
1113
-        'n' => 2,
1114
-        'p' => 8,
1115
-    ];
1104
+	$captured_pieces_all = [
1105
+		'Q' => 1,
1106
+		'R' => 2,
1107
+		'B' => 2,
1108
+		'N' => 2,
1109
+		'P' => 8,
1110
+		'q' => 1,
1111
+		'r' => 2,
1112
+		'b' => 2,
1113
+		'n' => 2,
1114
+		'p' => 8,
1115
+	];
1116 1116
 
1117
-    for ($i = 0, $iMax = mb_strlen($gamedata['fen_piece_placement']); $i < $iMax; ++$i) {
1118
-        $piece = $gamedata['fen_piece_placement'][$i];
1117
+	for ($i = 0, $iMax = mb_strlen($gamedata['fen_piece_placement']); $i < $iMax; ++$i) {
1118
+		$piece = $gamedata['fen_piece_placement'][$i];
1119 1119
 
1120
-        if (!empty($captured_pieces_all[$piece])) {
1121
-            --$captured_pieces_all[$piece];
1122
-        }
1123
-    }
1120
+		if (!empty($captured_pieces_all[$piece])) {
1121
+			--$captured_pieces_all[$piece];
1122
+		}
1123
+	}
1124 1124
 
1125
-    // Construct lists of white's and black's captured pieces.
1125
+	// Construct lists of white's and black's captured pieces.
1126 1126
 
1127
-    $captured_pieces = ['white' => [], 'black' => []];
1127
+	$captured_pieces = ['white' => [], 'black' => []];
1128 1128
 
1129
-    foreach ($captured_pieces_all as $piece => $count) {
1130
-        if ($count > 0) {
1131
-            if (ctype_upper($piece)) {
1132
-                $captured_pieces['white'] = array_merge($captured_pieces['white'], array_pad([], $count, $piece));
1133
-            } elseif (ctype_lower($piece)) {
1134
-                $captured_pieces['black'] = array_merge($captured_pieces['black'], array_pad([], $count, $piece));
1135
-            }
1136
-        }
1137
-    }
1129
+	foreach ($captured_pieces_all as $piece => $count) {
1130
+		if ($count > 0) {
1131
+			if (ctype_upper($piece)) {
1132
+				$captured_pieces['white'] = array_merge($captured_pieces['white'], array_pad([], $count, $piece));
1133
+			} elseif (ctype_lower($piece)) {
1134
+				$captured_pieces['black'] = array_merge($captured_pieces['black'], array_pad([], $count, $piece));
1135
+			}
1136
+		}
1137
+	}
1138 1138
 
1139
-    #var_dump('captured_pieces_all', $captured_pieces_all);#*#DEBUG#
1139
+	#var_dump('captured_pieces_all', $captured_pieces_all);#*#DEBUG#
1140 1140
 
1141
-    #var_dump('captured_pieces', $captured_pieces);#*#DEBUG#
1141
+	#var_dump('captured_pieces', $captured_pieces);#*#DEBUG#
1142 1142
 
1143
-    $xoopsTpl->assign('chess_captured_pieces', $captured_pieces);
1143
+	$xoopsTpl->assign('chess_captured_pieces', $captured_pieces);
1144 1144
 
1145
-    $xoopsTpl->assign('chess_pawn_promote_choices', 'w' == $gamedata['fen_active_color'] ? ['Q', 'R', 'B', 'N'] : ['q', 'r', 'b', 'n']);
1145
+	$xoopsTpl->assign('chess_pawn_promote_choices', 'w' == $gamedata['fen_active_color'] ? ['Q', 'R', 'B', 'N'] : ['q', 'r', 'b', 'n']);
1146 1146
 
1147
-    $xoopsTpl->assign('chess_allow_delete', chess_can_delete());
1147
+	$xoopsTpl->assign('chess_allow_delete', chess_can_delete());
1148 1148
 
1149
-    // popup window contents for selecting piece to which pawn is promoted
1149
+	// popup window contents for selecting piece to which pawn is promoted
1150 1150
 
1151
-    // (Note that template is compiled here by fetch(), so any template variables it uses must already be defined.)
1151
+	// (Note that template is compiled here by fetch(), so any template variables it uses must already be defined.)
1152 1152
 
1153
-    $xoopsTpl->assign('chess_pawn_promote_popup', $user_color ? $xoopsTpl->fetch('db:chess_game_promote_popup.tpl') : '');
1153
+	$xoopsTpl->assign('chess_pawn_promote_popup', $user_color ? $xoopsTpl->fetch('db:chess_game_promote_popup.tpl') : '');
1154 1154
 
1155
-    $xoopsTpl->assign('chess_ratings_enabled', 'none' != chess_moduleConfig('rating_system'));
1155
+	$xoopsTpl->assign('chess_ratings_enabled', 'none' != chess_moduleConfig('rating_system'));
1156 1156
 
1157
-    // security token
1157
+	// security token
1158 1158
 
1159
-    $xoopsTpl->assign('chess_xoops_request_token', is_object($GLOBALS['xoopsSecurity']) ? $GLOBALS['xoopsSecurity']->getTokenHTML() : '');
1159
+	$xoopsTpl->assign('chess_xoops_request_token', is_object($GLOBALS['xoopsSecurity']) ? $GLOBALS['xoopsSecurity']->getTokenHTML() : '');
1160 1160
 }
1161 1161
 
1162 1162
 ?>
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
  */
43 43
 
44 44
 $GLOBALS['xoopsOption']['template_main'] = 'chess_game_main.tpl';
45
-require __DIR__ . '/header.php';
45
+require __DIR__.'/header.php';
46 46
 
47
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
47
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
48 48
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
49
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
50
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
49
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
50
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
51 51
 
52 52
 chess_game();
53 53
 
54
-require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
55
-require_once XOOPS_ROOT_PATH . '/footer.php';
54
+require_once XOOPS_ROOT_PATH.'/include/comment_view.php';
55
+require_once XOOPS_ROOT_PATH.'/footer.php';
56 56
 /**#@-*/
57 57
 
58 58
 /**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 {
69 69
     // user input
70 70
 
71
-    $game_id = (int)@$_GET['game_id'];
71
+    $game_id = (int) @$_GET['game_id'];
72 72
 
73 73
     $submit_move = isset($_POST['submit_move']);
74 74
 
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 
97 97
     if (($submit_move || $submit_refresh || $submit_arbitrate || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
98 98
         redirect_header(
99
-            XOOPS_URL . '/modules/chess/',
99
+            XOOPS_URL.'/modules/chess/',
100 100
             _CHESS_REDIRECT_DELAY_FAILURE,
101
-            _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
101
+            _MD_CHESS_TOKEN_ERROR.'<br>'.implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
102 102
         );
103 103
     }
104 104
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
     $gamedata = chess_get_game($game_id);
108 108
 
109 109
     if (false === $gamedata) {
110
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
110
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
111 111
     }
112 112
 
113 113
     $gamedata_updated = false;
114 114
 
115 115
     $move_performed        = false; // status result from move-handler
116
-    $move_result_text      = '';    // text result from move-handler
117
-    $draw_claim_error_text = '';    // text describing invalid draw-claim
118
-    $notify                = '';    // text description of action for notification
116
+    $move_result_text      = ''; // text result from move-handler
117
+    $draw_claim_error_text = ''; // text describing invalid draw-claim
118
+    $notify                = ''; // text description of action for notification
119 119
     $delete_game           = false;
120 120
 
121 121
     global $xoopsUser;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if ($uid == $gamedata['white_uid']) {
129 129
             $user_color = $gamedata['fen_active_color']; // current user is either player, so consider him active player
130 130
         } else {
131
-            $user_color = '';                            // current user is not a player
131
+            $user_color = ''; // current user is not a player
132 132
         }
133 133
         // not self-play
134 134
     } else {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         } elseif ($uid == $gamedata['black_uid']) {
138 138
             $user_color = 'b'; // current user is black
139 139
         } else {
140
-            $user_color = '';  // current user is not a player
140
+            $user_color = ''; // current user is not a player
141 141
         }
142 142
     }
143 143
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
                         $gamedata['pgn_result'] = '1/2-1/2';
227 227
 
228
-                        $comment = '{' . $draw_claim_text . '}';
228
+                        $comment = '{'.$draw_claim_text.'}';
229 229
 
230 230
                         $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
231 231
 
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 
244 244
                     $gamedata['pgn_result'] = 'w' == $user_color ? '0-1' : '1-0';
245 245
 
246
-                    $comment = '{' . $user_color_name . ' ' . _MD_CHESS_RESIGNED . '}';
246
+                    $comment = '{'.$user_color_name.' '._MD_CHESS_RESIGNED.'}';
247 247
 
248 248
                     $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
249 249
 
250 250
                     $gamedata_updated = true;
251 251
 
252
-                    $notify = "$user_color_name " . _MD_CHESS_RESIGNED;
252
+                    $notify = "$user_color_name "._MD_CHESS_RESIGNED;
253 253
                 }
254 254
                 break;
255 255
             case _CHESS_MOVETYPE_OFFER_DRAW:
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
                     $gamedata_updated = true;
260 260
 
261
-                    $notify = "$user_color_name " . _MD_CHESS_OFFERED_DRAW;
261
+                    $notify = "$user_color_name "._MD_CHESS_OFFERED_DRAW;
262 262
                 }
263 263
                 break;
264 264
             case _CHESS_MOVETYPE_ACCEPT_DRAW:
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 
268 268
                     $gamedata['pgn_result'] = '1/2-1/2';
269 269
 
270
-                    $comment = '{' . _MD_CHESS_DRAW_BY_AGREEMENT . '}';
270
+                    $comment = '{'._MD_CHESS_DRAW_BY_AGREEMENT.'}';
271 271
 
272 272
                     $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
273 273
 
274 274
                     $gamedata_updated = true;
275 275
 
276
-                    $notify = "$user_color_name " . _MD_CHESS_ACCEPTED_DRAW;
276
+                    $notify = "$user_color_name "._MD_CHESS_ACCEPTED_DRAW;
277 277
                 }
278 278
 
279 279
             // no break
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
                     $gamedata_updated = true;
285 285
 
286
-                    $notify = "$user_color_name " . _MD_CHESS_REJECTED_DRAW;
286
+                    $notify = "$user_color_name "._MD_CHESS_REJECTED_DRAW;
287 287
                 }
288 288
                 break;
289 289
             case _CHESS_MOVETYPE_RESTART:
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             case _CHESS_MOVETYPE_DELETE:
325 325
                 if ($user_is_player && ($selfplay || chess_can_delete())) {
326 326
                     $delete_game = true; // must defer actual deletion until after notifications are sent
327
-                    $notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
327
+                    $notify      = eval('return \''._MD_CHESS_DELETED_GAME.'\';'); // eval references $username
328 328
                 }
329 329
                 break;
330 330
             case _CHESS_MOVETYPE_WANT_ARBITRATION:
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
                     $gamedata_updated = true;
341 341
 
342
-                    $notify = "$user_color_name " . _MD_CHESS_RQSTED_ARBT . ' ' . _MD_CHESS_BEEN_SUSPENDED;
342
+                    $notify = "$user_color_name "._MD_CHESS_RQSTED_ARBT.' '._MD_CHESS_BEEN_SUSPENDED;
343 343
                 }
344 344
                 break;
345 345
         }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
                     $gamedata_updated = true;
375 375
 
376
-                    $notify = eval('return \'' . _MD_CHESS_RESUMED_PLAY . '\';'); // eval references $username
376
+                    $notify = eval('return \''._MD_CHESS_RESUMED_PLAY.'\';'); // eval references $username
377 377
                 }
378 378
                 break;
379 379
             case _CHESS_ARBITER_DRAW:
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
                     $arbiter_explain = str_replace('}', ')', $arbiter_explain);
388 388
 
389
-                    $comment = '{' . sprintf(_MD_CHESS_DRAW_DECLARED, $arbiter_explain) . '}';
389
+                    $comment = '{'.sprintf(_MD_CHESS_DRAW_DECLARED, $arbiter_explain).'}';
390 390
 
391 391
                     $gamedata['pgn_movetext'] = str_replace('*', "{$gamedata['pgn_result']} $comment", $gamedata['pgn_movetext']);
392 392
 
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 
395 395
                     $gamedata_updated = true;
396 396
 
397
-                    $notify = eval('return \'' . _MD_CHESS_DECLARED_DRAW . '\';'); // eval references $username
397
+                    $notify = eval('return \''._MD_CHESS_DECLARED_DRAW.'\';'); // eval references $username
398 398
                 }
399 399
                 break;
400 400
             case _CHESS_ARBITER_DELETE:
401 401
                 if ($gamedata['suspended']) {
402 402
                     $delete_game = true; // must defer actual deletion until after notifications are sent
403
-                    $notify      = eval('return \'' . _MD_CHESS_DELETED_GAME . '\';'); // eval references $username
403
+                    $notify      = eval('return \''._MD_CHESS_DELETED_GAME.'\';'); // eval references $username
404 404
                 }
405 405
                 break;
406 406
             case _CHESS_ARBITER_SUSPEND:
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 
416 416
                     $gamedata_updated = true;
417 417
 
418
-                    $notify = eval('return \'' . _MD_CHESS_SUSPENDED_PLAY . '\';'); // eval references $username
418
+                    $notify = eval('return \''._MD_CHESS_SUSPENDED_PLAY.'\';'); // eval references $username
419 419
                 }
420 420
                 break;
421 421
             default:
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
         if (_CHESS_MOVETYPE_WANT_ARBITRATION == $movetype) {
448 448
             $event = 'notify_request_arbitration';
449 449
 
450
-            $username = $xoopsUser ? $xoopsUser->getVar('uname') : '(' . _MD_CHESS_UNKNOWN . ')';
450
+            $username = $xoopsUser ? $xoopsUser->getVar('uname') : '('._MD_CHESS_UNKNOWN.')';
451 451
 
452 452
             $extra_tags = ['CHESS_REQUESTOR' => $username, 'CHESS_GAME_ID' => $game_id, 'CHESS_EXPLAIN' => $move_explain];
453 453
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
     if ($delete_game) {
461 461
         chess_delete_game($game_id);
462 462
 
463
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
463
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
464 464
     }
465 465
 }
466 466
 
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
     );
533 533
 
534 534
     if ($xoopsDB->errno()) {
535
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
535
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
536 536
     }
537 537
 
538 538
     if ('*' != $gamedata['pgn_result'] && '1' == $gamedata['is_rated']) {
539
-        require_once XOOPS_ROOT_PATH . '/modules/chess/include/ratings.php';
539
+        require_once XOOPS_ROOT_PATH.'/modules/chess/include/ratings.php';
540 540
 
541 541
         chess_ratings_adj($game_id);
542 542
     }
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
     $xoopsDB->query("DELETE FROM $table WHERE game_id='$game_id'");
561 561
 
562 562
     if ($xoopsDB->errno()) {
563
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
563
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
564 564
     }
565 565
 }
566 566
 
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 
734 734
     // The current position is included, since that's the position against which the other positions will be compared.
735 735
 
736
-    $repeats[] = $gamedata['fen_fullmove_number'] . $gamedata['fen_active_color'];
736
+    $repeats[] = $gamedata['fen_fullmove_number'].$gamedata['fen_active_color'];
737 737
 
738 738
     // Compare initial board position with last board position, unless the move number is the same, meaning that there haven't been any moves.
739 739
 
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
     $board_state = "{$tmp_gamedata['fen_piece_placement']} {$tmp_gamedata['fen_active_color']} {$tmp_gamedata['fen_castling_availability']} {$tmp_gamedata['fen_en_passant_target_square']}";
743 743
 
744 744
     if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
745
-        $repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
745
+        $repeats[] = $tmp_gamedata['fen_fullmove_number'].$tmp_gamedata['fen_active_color'];
746 746
 
747 747
         if (CHESS_LOG_3FOLD) {
748 748
             $log[] = sprintf('%08x %03d%1s %s', crc32($board_state), $tmp_gamedata['fen_fullmove_number'], $tmp_gamedata['fen_active_color'], $board_state);
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
             }
807 807
 
808 808
             if ($tmp_gamedata['fen_fullmove_number'] != $last_move_number && $board_state == $last_board_state) {
809
-                $repeats[] = $tmp_gamedata['fen_fullmove_number'] . $tmp_gamedata['fen_active_color'];
809
+                $repeats[] = $tmp_gamedata['fen_fullmove_number'].$tmp_gamedata['fen_active_color'];
810 810
 
811 811
                 #*#DEBUG# - start
812 812
 
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
     }
854 854
 
855 855
     if (CHESS_LOG_3FOLD) {
856
-        $logfile = XOOPS_ROOT_PATH . '/cache/' . date('Ymd_His') . '_3fold.log';
856
+        $logfile = XOOPS_ROOT_PATH.'/cache/'.date('Ymd_His').'_3fold.log';
857 857
 
858 858
         sort($log);
859 859
 
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
     $xoopsTpl->assign(
917 917
         'xoops_module_header',
918 918
         '
919
-        <link rel="stylesheet" type="text/css" media="screen" href="' . XOOPS_URL . '/modules/chess/assets/css/style.css">
919
+        <link rel="stylesheet" type="text/css" media="screen" href="' . XOOPS_URL.'/modules/chess/assets/css/style.css">
920 920
     '
921 921
     );
922 922
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         $expanded_row = preg_replace_callback(
960 960
             '/(\d)/',
961 961
 
962
-            static function ($matches) {
962
+            static function($matches) {
963 963
                 return str_repeat('x', $matches[1]);
964 964
             },
965 965
             $rank
Please login to merge, or discard this patch.
help.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
  */
38 38
 
39 39
 $GLOBALS['xoopsOption']['template_main'] = 'chess_help.tpl';
40
-require __DIR__ . '/header.php';
40
+require __DIR__.'/header.php';
41 41
 
42 42
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
43
-require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/functions.php';
44
-if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/help.php')) {
45
-    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/help.php';
43
+require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/functions.php';
44
+if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/help.php')) {
45
+    require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/help.php';
46 46
 } else {
47
-    require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/help.php';
47
+    require_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/english/help.php';
48 48
 }
49 49
 
50 50
 $rating_system          = chess_moduleConfig('rating_system');
51
-$rating_system_des_name = '_HE_CHESS_RATINGS_' . mb_strtoupper($rating_system);
51
+$rating_system_des_name = '_HE_CHESS_RATINGS_'.mb_strtoupper($rating_system);
52 52
 if (defined($rating_system_des_name)) {
53 53
     $rating_system_des = constant($rating_system_des_name);
54 54
 } else {
@@ -64,6 +64,6 @@  discard block
 block discarded – undo
64 64
 $xoopsTpl->assign('chess_allow_delete', chess_can_delete());
65 65
 $xoopsTpl->assign('chess_is_admin', is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid')));
66 66
 
67
-require_once XOOPS_ROOT_PATH . '/footer.php';
67
+require_once XOOPS_ROOT_PATH.'/footer.php';
68 68
 
69 69
 /**#@-*/
Please login to merge, or discard this patch.
create.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -47,24 +47,24 @@  discard block
 block discarded – undo
47 47
 /**#@+
48 48
  */
49 49
 
50
-require __DIR__ . '/header.php';
50
+require __DIR__.'/header.php';
51 51
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
52 52
 
53
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
54
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
55
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
53
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
54
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
55
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
56 56
 
57 57
 #var_dump($_REQUEST);#*#DEBUG#
58 58
 
59 59
 if (!chess_can_play()) {
60
-    redirect_header(XOOPS_URL . '/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM);
60
+    redirect_header(XOOPS_URL.'/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM);
61 61
 }
62 62
 
63 63
 // user input
64 64
 //$gametype          = chess_sanitize(@$_POST['gametype']);
65 65
 //$opponent          = chess_sanitize(trim(@$_POST['opponent']), _CHESS_USERNAME_ALLOWED_CHARACTERS);
66 66
 $gametype     = Request::getCmd('gametype', '', 'POST');
67
-$opponent     = preg_replace('/[^' . _CHESS_USERNAME_ALLOWED_CHARACTERS . ']/i', '', Request::getString('opponent', '', 'POST'));
67
+$opponent     = preg_replace('/[^'._CHESS_USERNAME_ALLOWED_CHARACTERS.']/i', '', Request::getString('opponent', '', 'POST'));
68 68
 $opponent     = trim($opponent);
69 69
 $opponent_uid      = !empty($opponent) ? chess_opponent_uid($opponent) : 0;
70 70
 //$fen               = chess_moduleConfig('allow_setup') ? chess_sanitize(trim(@$_POST['fen']), 'A-Za-z0-9 /-') : '';
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 // If form-submit, check security token.
90 90
 if (($submit_challenge1 || $submit_challenge2 || $submit_challenge3 || $submit_accept || $submit_delete || $show_arbiter_ctrl) && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
91 91
     redirect_header(
92
-        XOOPS_URL . '/modules/chess/',
92
+        XOOPS_URL.'/modules/chess/',
93 93
         _CHESS_REDIRECT_DELAY_FAILURE,
94
-        _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
94
+        _MD_CHESS_TOKEN_ERROR.'<br>'.implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
95 95
     );
96 96
 }
97 97
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 $is_arbiter = is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'));
107 107
 
108 108
 if ($cancel_challenge1) {
109
-    redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK);
109
+    redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK);
110 110
 } elseif ($cancel_challenge2) {
111 111
     chess_show_create_form1($gametype);
112 112
 } elseif ($cancel_challenge3) {
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
         chess_show_create_form1($gametype, $fen);
117 117
     }
118 118
 } elseif ($cancel_accept) {
119
-    redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK);
119
+    redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _TAKINGBACK);
120 120
 } elseif ($submit_challenge1) {
121 121
     $fen_error = chess_fen_error($fen);
122 122
 
123 123
     if (!empty($fen_error)) {
124
-        chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID . ': ' . $fen_error);
124
+        chess_show_create_form1($gametype, $fen, _MD_CHESS_FEN_INVALID.': '.$fen_error);
125 125
     } elseif (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) {
126 126
         chess_show_create_form2($gametype, $fen);
127 127
     } else {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     if (_CHESS_GAMETYPE_OPEN == $gametype) {
146 146
         chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move);
147 147
 
148
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
148
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
149 149
     } elseif (_CHESS_GAMETYPE_USER == $gametype) {
150 150
         if (empty($opponent)) {
151 151
             chess_show_create_form2($gametype, $fen, $coloroption, $opponent_uid, $rated, _MD_CHESS_OPPONENT_MISSING);
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
         } else {
157 157
             chess_create_challenge($gametype, $fen, $coloroption, $rated, $notify_accept, $notify_move, $opponent_uid);
158 158
 
159
-            redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
159
+            redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
160 160
         }
161 161
     } elseif (_CHESS_GAMETYPE_SELF == $gametype) {
162 162
         $game_id = chess_create_game($uid, $uid, $fen, $rated);
163 163
 
164
-        redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
164
+        redirect_header(XOOPS_URL."/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
165 165
     } else {
166 166
         chess_show_create_form1($gametype, $fen, _MD_CHESS_GAMETYPE_INVALID);
167 167
     }
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
         if ($is_arbiter || chess_is_challenger($challenge_id)) {
173 173
             chess_delete_challenge($challenge_id);
174 174
 
175
-            redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
175
+            redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_DELETED);
176 176
         } else {
177
-            redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM);
177
+            redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _NOPERM);
178 178
         }
179 179
     } else {
180 180
         chess_show_delete_form($challenge_id, $show_arbiter_ctrl && $is_arbiter, _MD_CHESS_NO_CONFIRM_DELETE);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     chess_show_create_form1($gametype);
190 190
 }
191 191
 
192
-require_once XOOPS_ROOT_PATH . '/footer.php';
192
+require_once XOOPS_ROOT_PATH.'/footer.php';
193 193
 /**#@-*/
194 194
 
195 195
 /**
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
     $form = new XoopsThemeForm(_MD_CHESS_CREATE_FORM, 'create_form1', 'create.php', 'post', true);
205 205
 
206 206
     if ($error_msg) {
207
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>'));
207
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.': ', '<div class="errorMsg">'.$error_msg.'</div>'));
208 208
     }
209 209
 
210
-    $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE . ':', 'gametype', $gametype, 1, false);
210
+    $menu_gametype = new XoopsFormSelect(_MD_CHESS_LABEL_GAMETYPE.':', 'gametype', $gametype, 1, false);
211 211
 
212 212
     $menu_gametype->addOption(_CHESS_GAMETYPE_OPEN, _MD_CHESS_MENU_GAMETYPE_OPEN);
213 213
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
         $form->addElement(new XoopsFormLabel('', _MD_CHESS_LABEL_FEN_EXPLAIN));
224 224
 
225
-        $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP . ':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen));
225
+        $form->addElement(new XoopsFormText(_MD_CHESS_LABEL_FEN_SETUP.':', 'fen', 80, _CHESS_TEXTBOX_FEN_MAXLEN, $fen));
226 226
     }
227 227
 
228 228
     $form->addElement(new XoopsFormLabel('&nbsp;', '&nbsp;'));
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     $form->addElement(new XoopsFormHidden('fen', $fen));
258 258
 
259 259
     if ($error_msg) {
260
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ':', '<div class="errorMsg">' . $error_msg . '</div>'));
260
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.':', '<div class="errorMsg">'.$error_msg.'</div>'));
261 261
     }
262 262
 
263 263
     $memberHandler = xoops_getHandler('member');
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
     if (_CHESS_GAMETYPE_USER == $gametype) {
270 270
         $form->addElement(
271 271
             new XoopsFormText(
272
-                _MD_CHESS_LABEL_OPPONENT . ':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username
272
+                _MD_CHESS_LABEL_OPPONENT.':', 'opponent', _CHESS_TEXTBOX_OPPONENT_SIZE, _CHESS_TEXTBOX_OPPONENT_MAXLEN, $opponent_username
273 273
             )
274 274
         );
275 275
     }
276 276
 
277
-    $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', $coloroption);
277
+    $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR.':', 'coloroption', $coloroption);
278 278
 
279 279
     $radio_color->addOption(_CHESS_COLOROPTION_OPPONENT, _MD_CHESS_RADIO_COLOR_OPPONENT);
280 280
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     if ('none' !== chess_moduleConfig('rating_system')) {
290 290
         if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) {
291 291
             if (chess_moduleConfig('allow_unrated_games')) {
292
-                $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME . ':', 'rated', $rated);
292
+                $radio_rated = new XoopsFormRadio(_MD_CHESS_RATED_GAME.':', 'rated', $rated);
293 293
 
294 294
                 $radio_rated->addOption(1, _YES);
295 295
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 
345 345
     $form->addElement(new XoopsFormHidden('rated', $rated));
346 346
 
347
-    $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">' . _MD_CHESS_GAME_CONFIRM . '</div>'));
347
+    $form->addElement(new XoopsFormLabel('', '<div class="confirmMsg">'._MD_CHESS_GAME_CONFIRM.'</div>'));
348 348
 
349 349
     switch ($gametype) {
350 350
         case _CHESS_GAMETYPE_OPEN:
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
             break;
362 362
     }
363 363
 
364
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype));
364
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype));
365 365
 
366 366
     if (!empty($fen)) {
367
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $fen));
367
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $fen));
368 368
     }
369 369
 
370 370
     if (_CHESS_GAMETYPE_USER == $gametype) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
         $opponent_username = is_object($opponent_user) ? $opponent_user->getVar('uname') : '';
376 376
 
377
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $opponent_username));
377
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT.':', $opponent_username));
378 378
     }
379 379
 
380 380
     if (_CHESS_GAMETYPE_OPEN == $gametype || _CHESS_GAMETYPE_USER == $gametype) {
@@ -396,10 +396,10 @@  discard block
 block discarded – undo
396 396
                 break;
397 397
         }
398 398
 
399
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption));
399
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption));
400 400
 
401 401
         if ('none' != chess_moduleConfig('rating_system')) {
402
-            $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $rated ? _YES : _NO));
402
+            $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $rated ? _YES : _NO));
403 403
         }
404 404
 
405 405
         // Determine whether current user is subscribed to receive a notification when his challenge is accepted.
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
     );
469 469
 
470 470
     if ($xoopsDB->getRowsNum($result) < 1) {
471
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
471
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
472 472
     }
473 473
 
474 474
     $row = $xoopsDB->fetchArray($result);
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 
480 480
     $form->addElement(new XoopsFormHidden('challenge_id', $challenge_id));
481 481
 
482
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm')));
482
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED.':', formatTimestamp($row['create_date'], 'm')));
483 483
 
484 484
     $memberHandler = xoops_getHandler('member');
485 485
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         case _CHESS_GAMETYPE_USER:
491 491
             $player2_user     = $memberHandler->getUser($row['player2_uid']);
492 492
             $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?';
493
-            $label_gametype   = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username;
493
+            $label_gametype   = _MD_CHESS_LABEL_GAMETYPE_USER.': '.$player2_username;
494 494
             break;
495 495
         case _CHESS_GAMETYPE_SELF:
496 496
             $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             break;
501 501
     }
502 502
 
503
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype));
503
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype));
504 504
 
505 505
     $player1_user = $memberHandler->getUser($row['player1_uid']);
506 506
 
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
 
509 509
     $form->addElement(
510 510
         new XoopsFormLabel(
511
-            _MD_CHESS_LABEL_CHALLENGER . ':', "<a href='" . XOOPS_URL . "/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>"
511
+            _MD_CHESS_LABEL_CHALLENGER.':', "<a href='".XOOPS_URL."/modules/chess/player_stats.php?player_uid={$row['player1_uid']}'>$player1_username</a>"
512 512
         )
513 513
     );
514 514
 
515 515
     $player2_username = $xoopsUser ? $xoopsUser->getVar('uname') : '?';
516 516
 
517
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT . ':', $player2_username));
517
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_OPPONENT.':', $player2_username));
518 518
 
519 519
     if (!empty($row['fen'])) {
520
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen']));
520
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $row['fen']));
521 521
     }
522 522
 
523 523
     if (_CHESS_COLOROPTION_OPPONENT == $row['color_option']) {
524
-        $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR . ':', 'coloroption', _CHESS_COLOROPTION_RANDOM);
524
+        $radio_color = new XoopsFormRadio(_MD_CHESS_LABEL_COLOR.':', 'coloroption', _CHESS_COLOROPTION_RANDOM);
525 525
 
526 526
         $radio_color->addOption(_CHESS_COLOROPTION_RANDOM, _MD_CHESS_RADIO_COLOR_RANDOM);
527 527
 
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
                 break;
547 547
         }
548 548
 
549
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption));
549
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption));
550 550
     }
551 551
 
552 552
     if ('none' != chess_moduleConfig('rating_system')) {
553
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO));
553
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $row['is_rated'] ? _YES : _NO));
554 554
     }
555 555
 
556 556
     // Display notification-subscribe checkbox, initially checked.
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
     );
599 599
 
600 600
     if ($xoopsDB->getRowsNum($result) < 1) {
601
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
601
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
602 602
     }
603 603
 
604 604
     $row = $xoopsDB->fetchArray($result);
@@ -614,10 +614,10 @@  discard block
 block discarded – undo
614 614
     }
615 615
 
616 616
     if ($error_msg) {
617
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR . ': ', '<div class="errorMsg">' . $error_msg . '</div>'));
617
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_ERROR.': ', '<div class="errorMsg">'.$error_msg.'</div>'));
618 618
     }
619 619
 
620
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED . ':', formatTimestamp($row['create_date'], 'm')));
620
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_DATE_CREATED.':', formatTimestamp($row['create_date'], 'm')));
621 621
 
622 622
     $memberHandler = xoops_getHandler('member');
623 623
 
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
         case _CHESS_GAMETYPE_USER:
629 629
             $player2_user     = $memberHandler->getUser($row['player2_uid']);
630 630
             $player2_username = is_object($player2_user) ? $player2_user->getVar('uname') : '?';
631
-            $label_gametype   = _MD_CHESS_LABEL_GAMETYPE_USER . ': ' . $player2_username;
631
+            $label_gametype   = _MD_CHESS_LABEL_GAMETYPE_USER.': '.$player2_username;
632 632
             break;
633 633
         case _CHESS_GAMETYPE_SELF:
634 634
             $label_gametype = _MD_CHESS_LABEL_GAMETYPE_SELF;
@@ -638,16 +638,16 @@  discard block
 block discarded – undo
638 638
             break;
639 639
     }
640 640
 
641
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE . ':', $label_gametype));
641
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_GAMETYPE.':', $label_gametype));
642 642
 
643 643
     $player1_user = $memberHandler->getUser($row['player1_uid']);
644 644
 
645 645
     $player1_username = is_object($player1_user) ? $player1_user->getVar('uname') : '?';
646 646
 
647
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER . ':', $player1_username));
647
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_CHALLENGER.':', $player1_username));
648 648
 
649 649
     if (!empty($row['fen'])) {
650
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP . ':', $row['fen']));
650
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_FEN_SETUP.':', $row['fen']));
651 651
     }
652 652
 
653 653
     switch ($row['color_option']) {
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
             break;
669 669
     }
670 670
 
671
-    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR . ':', $label_coloroption));
671
+    $form->addElement(new XoopsFormLabel(_MD_CHESS_LABEL_COLOR.':', $label_coloroption));
672 672
 
673 673
     if ('none' != chess_moduleConfig('rating_system')) {
674
-        $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME . ':', $row['is_rated'] ? _YES : _NO));
674
+        $form->addElement(new XoopsFormLabel(_MD_CHESS_RATED_GAME.':', $row['is_rated'] ? _YES : _NO));
675 675
     }
676 676
 
677 677
     // Display confirm-delete checkbox, initially unchecked.
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     );
719 719
 
720 720
     if ($xoopsDB->getRowsNum($result) < 1) {
721
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
721
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
722 722
     }
723 723
 
724 724
     $row = $xoopsDB->fetchArray($result);
@@ -728,9 +728,9 @@  discard block
 block discarded – undo
728 728
     $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
729 729
 
730 730
     if (_CHESS_GAMETYPE_USER == $row['game_type'] && $uid != $row['player2_uid']) {
731
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2);
731
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_WRONG_PLAYER2);
732 732
     } elseif ($uid == $row['player1_uid']) {
733
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2);
733
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_SAME_PLAYER2);
734 734
     }
735 735
 
736 736
     switch ($row['color_option']) {
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
     $xoopsDB->query("DELETE FROM $challenges_table WHERE challenge_id = '$challenge_id'");
784 784
 
785 785
     if ($xoopsDB->errno()) {
786
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
786
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
787 787
     }
788 788
 
789 789
     // Notify player 1 that his challenge has been accepted (if he has subscribed to the notification).
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
     $notificationHandler->triggerEvent('global', 0, 'notify_accept_challenge', $extra_tags, [$row['player1_uid']]);
798 798
 
799
-    redirect_header(XOOPS_URL . "/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
799
+    redirect_header(XOOPS_URL."/modules/chess/game.php?game_id=$game_id", _CHESS_REDIRECT_DELAY_SUCCESS, _MD_CHESS_GAME_CREATED);
800 800
 }
801 801
 
802 802
 /**
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
     $result = $xoopsDB->query("SELECT player1_uid FROM $challenges_table WHERE challenge_id = '$challenge_id'");
815 815
 
816 816
     if ($xoopsDB->getRowsNum($result) < 1) {
817
-        redirect_header(XOOPS_URL . '/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
817
+        redirect_header(XOOPS_URL.'/modules/chess/', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_GAME_NOT_FOUND);
818 818
     }
819 819
 
820 820
     $row = $xoopsDB->fetchArray($result);
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
     );
876 876
 
877 877
     if ($xoopsDB->errno()) {
878
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
878
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
879 879
     }
880 880
 
881 881
     $challenge_id = $xoopsDB->getInsertId();
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
     $xoopsDB->query("DELETE FROM $table WHERE challenge_id='$challenge_id'");
918 918
 
919 919
     if ($xoopsDB->errno()) {
920
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
920
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
921 921
     }
922 922
 }
923 923
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
     );
984 984
 
985 985
     if ($xoopsDB->errno()) {
986
-        trigger_error($xoopsDB->errno() . ':' . $xoopsDB->error(), E_USER_ERROR);
986
+        trigger_error($xoopsDB->errno().':'.$xoopsDB->error(), E_USER_ERROR);
987 987
     }
988 988
 
989 989
     $game_id = $xoopsDB->getInsertId();
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
  */
40 40
 
41 41
 $GLOBALS['xoopsOption']['template_main'] = 'chess_games.tpl';
42
-require __DIR__ . '/header.php';
42
+require __DIR__.'/header.php';
43 43
 
44
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
45
-require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
46
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
47
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
44
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
45
+require_once XOOPS_ROOT_PATH.'/class/pagenav.php';
46
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
47
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
48 48
 
49 49
 #var_dump($_REQUEST);#*#DEBUG#
50 50
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
     $memberHandler = xoops_getHandler('member');
262 262
 
263
-    $criteria = new \Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN');
263
+    $criteria = new \Criteria('uid', '('.implode(',', array_keys($userids)).')', 'IN');
264 264
 
265 265
     $usernames = $memberHandler->getUserList($criteria);
266 266
 
@@ -352,4 +352,4 @@  discard block
 block discarded – undo
352 352
      * $clist = $configHandler->getConfigList(18);
353 353
      * var_dump('clist', $clist);
354 354
      ***/
355
-include_once XOOPS_ROOT_PATH . '/footer.php';
355
+include_once XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.
ratings.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 // check whether the rating feature is enabled
49 49
 if ('none' == chess_moduleConfig('rating_system')) {
50
-    redirect_header(XOOPS_URL . '/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_RATINGS_OFF);
50
+	redirect_header(XOOPS_URL . '/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_RATINGS_OFF);
51 51
 }
52 52
 
53 53
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
 // If form-submit, check security token.
63 63
 if ($submit_recalc_ratings && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
64
-    redirect_header(
65
-        XOOPS_URL . '/modules/chess/ratings.php',
66
-        _CHESS_REDIRECT_DELAY_FAILURE,
67
-        _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
68
-    );
64
+	redirect_header(
65
+		XOOPS_URL . '/modules/chess/ratings.php',
66
+		_CHESS_REDIRECT_DELAY_FAILURE,
67
+		_MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
68
+	);
69 69
 }
70 70
 
71 71
 $msg       = '';
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 
74 74
 // If arbiter requested recalculation of ratings, do it.
75 75
 if ($submit_recalc_ratings && is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
76
-    if ($confirm_recalc_ratings) {
77
-        chess_recalc_ratings();
76
+	if ($confirm_recalc_ratings) {
77
+		chess_recalc_ratings();
78 78
 
79
-        $msg = _MD_CHESS_RECALC_DONE;
79
+		$msg = _MD_CHESS_RECALC_DONE;
80 80
 
81
-        $msg_class = 'resultMsg';
82
-    } else {
83
-        $msg = _MD_CHESS_RECALC_NOT_DONE;
81
+		$msg_class = 'resultMsg';
82
+	} else {
83
+		$msg = _MD_CHESS_RECALC_NOT_DONE;
84 84
 
85
-        $msg_class = 'errorMsg';
86
-    }
85
+		$msg_class = 'errorMsg';
86
+	}
87 87
 }
88 88
 
89 89
 // Display the ratings.
@@ -101,119 +101,119 @@  discard block
 block discarded – undo
101 101
  */
102 102
 function chess_ratings($start = 0, $msg = '', $msg_class = 'errorMsg')
103 103
 {
104
-    global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsTpl;
104
+	global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsTpl;
105 105
 
106
-    // Display ratings.
106
+	// Display ratings.
107 107
 
108
-    // Get maximum number of items to display on a page, and constrain it to a reasonable value.
108
+	// Get maximum number of items to display on a page, and constrain it to a reasonable value.
109 109
 
110
-    $max_items_to_display = chess_moduleConfig('max_items');
110
+	$max_items_to_display = chess_moduleConfig('max_items');
111 111
 
112
-    $max_items_to_display = min(max($max_items_to_display, 1), 1000);
112
+	$max_items_to_display = min(max($max_items_to_display, 1), 1000);
113 113
 
114
-    $games_table = $xoopsDB->prefix('chess_games');
114
+	$games_table = $xoopsDB->prefix('chess_games');
115 115
 
116
-    $ratings_table = $xoopsDB->prefix('chess_ratings');
116
+	$ratings_table = $xoopsDB->prefix('chess_ratings');
117 117
 
118
-    // Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
118
+	// Two queries are performed, one without a limit clause to count the total number of rows for the page navigator,
119 119
 
120
-    // and one with a limit clause to get the data for display on the current page.
120
+	// and one with a limit clause to get the data for display on the current page.
121 121
 
122
-    // SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
122
+	// SQL_CALC_FOUND_ROWS and FOUND_ROWS(), available in MySQL 4.0.0, provide a more efficient way of doing this.
123 123
 
124
-    $result = $xoopsDB->query(
125
-        "
124
+	$result = $xoopsDB->query(
125
+		"
126 126
         SELECT    COUNT(*)
127 127
         FROM      $ratings_table AS p
128 128
     "
129
-    );
129
+	);
130 130
 
131
-    [$num_items] = $xoopsDB->fetchRow($result);
131
+	[$num_items] = $xoopsDB->fetchRow($result);
132 132
 
133
-    $xoopsDB->freeRecordSet($result);
133
+	$xoopsDB->freeRecordSet($result);
134 134
 
135
-    $pagenav = new XoopsPageNav($num_items, $max_items_to_display, $start, 'start');
135
+	$pagenav = new XoopsPageNav($num_items, $max_items_to_display, $start, 'start');
136 136
 
137
-    $result = $xoopsDB->query(
138
-        "
137
+	$result = $xoopsDB->query(
138
+		"
139 139
         SELECT    player_uid, rating, (games_won+games_lost+games_drawn) AS games_played
140 140
         FROM      $ratings_table
141 141
         ORDER BY  rating DESC, player_uid ASC
142 142
         LIMIT     $start, $max_items_to_display
143 143
     "
144
-    );
144
+	);
145 145
 
146
-    // user IDs that will require mapping to usernames
146
+	// user IDs that will require mapping to usernames
147 147
 
148
-    $userids = [];
148
+	$userids = [];
149 149
 
150
-    $players = [];
150
+	$players = [];
151 151
 
152
-    while (false !== ($row = $xoopsDB->fetchArray($result))) {
153
-        // save user IDs that will require mapping to usernames
152
+	while (false !== ($row = $xoopsDB->fetchArray($result))) {
153
+		// save user IDs that will require mapping to usernames
154 154
 
155
-        $userids[] = $row['player_uid'];
155
+		$userids[] = $row['player_uid'];
156 156
 
157
-        $players[] = [
158
-            'player_uid'   => $row['player_uid'],
159
-            'rating'       => $row['rating'],
160
-            'games_played' => $row['games_played'],
161
-        ];
162
-    }
157
+		$players[] = [
158
+			'player_uid'   => $row['player_uid'],
159
+			'rating'       => $row['rating'],
160
+			'games_played' => $row['games_played'],
161
+		];
162
+	}
163 163
 
164
-    $xoopsDB->freeRecordSet($result);
164
+	$xoopsDB->freeRecordSet($result);
165 165
 
166
-    // get mapping of user IDs to usernames
166
+	// get mapping of user IDs to usernames
167 167
 
168
-    $memberHandler = xoops_getHandler('member');
168
+	$memberHandler = xoops_getHandler('member');
169 169
 
170
-    $criteria = new \Criteria('uid', '(' . implode(',', $userids) . ')', 'IN');
170
+	$criteria = new \Criteria('uid', '(' . implode(',', $userids) . ')', 'IN');
171 171
 
172
-    $usernames = $memberHandler->getUserList($criteria);
172
+	$usernames = $memberHandler->getUserList($criteria);
173 173
 
174
-    // add usernames to $players
174
+	// add usernames to $players
175 175
 
176
-    foreach ($players as $k => $player) {
177
-        $players[$k]['player_uname'] = $usernames[$player['player_uid']] ?? '?';
178
-    }
176
+	foreach ($players as $k => $player) {
177
+		$players[$k]['player_uname'] = $usernames[$player['player_uid']] ?? '?';
178
+	}
179 179
 
180
-    // Display form for arbiter to recalculate ratings.
180
+	// Display form for arbiter to recalculate ratings.
181 181
 
182
-    if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
183
-        // security token added below
182
+	if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
183
+		// security token added below
184 184
 
185
-        $form = new XoopsThemeForm(_MD_CHESS_RECALC_RATINGS, 'form1', 'ratings.php');
185
+		$form = new XoopsThemeForm(_MD_CHESS_RECALC_RATINGS, 'form1', 'ratings.php');
186 186
 
187
-        // checkbox (initially unchecked)
187
+		// checkbox (initially unchecked)
188 188
 
189
-        $checked_value = 1;
189
+		$checked_value = 1;
190 190
 
191
-        $checkbox_confirm_recalc_ratings = new XoopsFormCheckBox('', 'confirm_recalc_ratings', !$checked_value);
191
+		$checkbox_confirm_recalc_ratings = new XoopsFormCheckBox('', 'confirm_recalc_ratings', !$checked_value);
192 192
 
193
-        $checkbox_confirm_recalc_ratings->addOption($checked_value, _MD_CHESS_RECALC_CONFIRM);
193
+		$checkbox_confirm_recalc_ratings->addOption($checked_value, _MD_CHESS_RECALC_CONFIRM);
194 194
 
195
-        $form->addElement($checkbox_confirm_recalc_ratings);
195
+		$form->addElement($checkbox_confirm_recalc_ratings);
196 196
 
197
-        $form->addElement(new XoopsFormButton('', 'submit_recalc_ratings', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
197
+		$form->addElement(new XoopsFormButton('', 'submit_recalc_ratings', _MD_CHESS_SUBMIT_BUTTON, 'submit'));
198 198
 
199
-        $form->assign($xoopsTpl);
199
+		$form->assign($xoopsTpl);
200 200
 
201
-        // security token
201
+		// security token
202 202
 
203
-        // This method is used because form is templated.
203
+		// This method is used because form is templated.
204 204
 
205
-        $xoopsTpl->assign('chess_xoops_request_token', is_object($GLOBALS['xoopsSecurity']) ? $GLOBALS['xoopsSecurity']->getTokenHTML() : '');
206
-    }
205
+		$xoopsTpl->assign('chess_xoops_request_token', is_object($GLOBALS['xoopsSecurity']) ? $GLOBALS['xoopsSecurity']->getTokenHTML() : '');
206
+	}
207 207
 
208
-    // Template variables
208
+	// Template variables
209 209
 
210
-    $xoopsTpl->assign('chess_provisional_games', chess_ratings_num_provisional_games());
210
+	$xoopsTpl->assign('chess_provisional_games', chess_ratings_num_provisional_games());
211 211
 
212
-    $xoopsTpl->assign('chess_msg', $msg);
212
+	$xoopsTpl->assign('chess_msg', $msg);
213 213
 
214
-    $xoopsTpl->assign('chess_msg_class', $msg_class);
214
+	$xoopsTpl->assign('chess_msg_class', $msg_class);
215 215
 
216
-    $xoopsTpl->assign('chess_players_pagenav', $pagenav->renderNav());
216
+	$xoopsTpl->assign('chess_players_pagenav', $pagenav->renderNav());
217 217
 
218
-    $xoopsTpl->assign('chess_players', $players);
218
+	$xoopsTpl->assign('chess_players', $players);
219 219
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
  */
38 38
 
39 39
 $GLOBALS['xoopsOption']['template_main'] = 'chess_ratings.tpl';
40
-require __DIR__ . '/header.php';
40
+require __DIR__.'/header.php';
41 41
 
42
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
43
-require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
44
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/constants.inc.php';
45
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/functions.php';
46
-require_once XOOPS_ROOT_PATH . '/modules/chess/include/ratings.php';
42
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
43
+require_once XOOPS_ROOT_PATH.'/class/pagenav.php';
44
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/constants.inc.php';
45
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/functions.php';
46
+require_once XOOPS_ROOT_PATH.'/modules/chess/include/ratings.php';
47 47
 
48 48
 // check whether the rating feature is enabled
49 49
 if ('none' == chess_moduleConfig('rating_system')) {
50
-    redirect_header(XOOPS_URL . '/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_RATINGS_OFF);
50
+    redirect_header(XOOPS_URL.'/modules/chess/index.php', _CHESS_REDIRECT_DELAY_FAILURE, _MD_CHESS_RATINGS_OFF);
51 51
 }
52 52
 
53 53
 $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; // disable caching
54 54
 
55 55
 // user input
56 56
 $submit_recalc_ratings  = isset($_POST['submit_recalc_ratings']);
57
-$confirm_recalc_ratings = (int)@$_POST['confirm_recalc_ratings'];
58
-$start                  = (int)@$_GET['start']; // for page nav: offset of first row of results to display (default to 0)
57
+$confirm_recalc_ratings = (int) @$_POST['confirm_recalc_ratings'];
58
+$start                  = (int) @$_GET['start']; // for page nav: offset of first row of results to display (default to 0)
59 59
 
60 60
 #var_dump($_REQUEST);#*#DEBUG#
61 61
 
62 62
 // If form-submit, check security token.
63 63
 if ($submit_recalc_ratings && is_object($GLOBALS['xoopsSecurity']) && !$GLOBALS['xoopsSecurity']->check()) {
64 64
     redirect_header(
65
-        XOOPS_URL . '/modules/chess/ratings.php',
65
+        XOOPS_URL.'/modules/chess/ratings.php',
66 66
         _CHESS_REDIRECT_DELAY_FAILURE,
67
-        _MD_CHESS_TOKEN_ERROR . '<br>' . implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
67
+        _MD_CHESS_TOKEN_ERROR.'<br>'.implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())
68 68
     );
69 69
 }
70 70
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 // Display the ratings.
90 90
 chess_ratings($start, $msg, $msg_class);
91 91
 
92
-require_once XOOPS_ROOT_PATH . '/footer.php';
92
+require_once XOOPS_ROOT_PATH.'/footer.php';
93 93
 /**#@-*/
94 94
 
95 95
 /**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
     $memberHandler = xoops_getHandler('member');
169 169
 
170
-    $criteria = new \Criteria('uid', '(' . implode(',', $userids) . ')', 'IN');
170
+    $criteria = new \Criteria('uid', '('.implode(',', $userids).')', 'IN');
171 171
 
172 172
     $usernames = $memberHandler->getUserList($criteria);
173 173
 
Please login to merge, or discard this patch.