Passed
Push — master ( 2ecc51...c1b656 )
by Michael
04:26 queued 02:02
created
edit.php 2 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 // If the user is not logged in and anonymous postings are
46 46
 // not allowed, redirect and exit.
47 47
 if (empty($xoopsUser) and !$xoopsModuleConfig['anonpost']) {
48
-    redirect_header(XOOPS_URL . '/user.php', 2, _MD_MUSTREGFIRST);
49
-    exit();
48
+	redirect_header(XOOPS_URL . '/user.php', 2, _MD_MUSTREGFIRST);
49
+	exit();
50 50
 }
51 51
 
52 52
 // Check if user has adminrights or not;
53 53
 if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
54
-    $isadmin = true;
54
+	$isadmin = true;
55 55
 } else {
56
-    $isadmin = false;
56
+	$isadmin = false;
57 57
 }
58 58
 
59 59
 // Get the user ID;
@@ -61,302 +61,302 @@  discard block
 block discarded – undo
61 61
 
62 62
 // If submit data was posted;
63 63
 if (!empty($_POST['submit'])) {
64
-    if (!empty($_POST['itemid'])) {
65
-        $post_itemid = (int)$_POST['itemid'];
66
-    } else {
67
-        redirect_header('index.php', 2, _MD_NOVALIDITEM_IDMISSING);
68
-        exit();
69
-    }
70
-    if (isset($_POST['op'])) {
71
-        $op = $_POST['op'];
72
-    } else {
73
-        $op = '';
74
-    }
75
-    // If option is "submitforapproval" then submit and redirect;
76
-    if ($op === 'submitforapproval') {
77
-        if ($efqListingHandler->updateStatus($post_itemid, '1')) {
78
-            redirect_header('index.php', 2, _MD_SUBMITTED_PUBLICATION);
79
-        } else {
80
-            redirect_header('index.php', 2, _MD_ERROR_NOT_SAVED);
81
-        }
82
-        exit();
83
-    }
84
-    if (!empty($_POST['dirid'])) {
85
-        $post_dirid = (int)$_POST['dirid'];
86
-    } else {
87
-        $post_dirid = 0;
88
-    }
89
-    if (isset($_POST['itemtitle'])) {
90
-        $p_title     = $myts->makeTboxData4Save($_POST['itemtitle']);
91
-        $p_ini_title = $myts->makeTboxData4Save($_POST['ini_itemtitle']);
92
-        // Start uploading up file;
93
-        require_once XOOPS_ROOT_PATH . '/class/uploader.php';
94
-        $uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads', array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/jpg'), 300000, 250, 250);
95
-        $uploader->setPrefix('logo');
96
-        $err    = array();
97
-        $ucount = count($_POST['xoops_upload_file']);
98
-        for ($i = 0; $i < $ucount; ++$i) {
99
-            if ($_POST['xoops_upload_file'][$i] !== '') {
100
-                $medianame = $_POST['xoops_upload_file'][$i];
101
-                if ($uploader->fetchMedia($_POST['xoops_upload_file'][$i])) {
102
-                    if (!$uploader->upload()) {
103
-                        $err[] = $uploader->getErrors();
104
-                    } else {
105
-                        $savedfilename = $uploader->getSavedFileName();
106
-                        $ticket        = uniqid(mt_rand(), 1);
107
-                        //Rename the uploaded file to the same name in a different location that does not have 777 rights or 755.
108
-                        rename('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '', '' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/uploads/' . $savedfilename . '');
109
-                        //Delete the uploaded file from the initial upload folder if it is still present in that folder.
110
-                        if (file_exists('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '')) {
111
-                            unlink('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '');
112
-                        }
113
-                    }
114
-                    if ($p_title != $p_ini_title) {
115
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET logourl = '" . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
116
-                    } else {
117
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\', logourl = \'' . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
118
-                    }
119
-                    $xoopsDB->query($sql) or $eh->show('0013');
120
-                }
121
-            } else {
122
-                if ($p_title != $p_ini_title) {
123
-                    $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\' WHERE itemid = \'' . $post_itemid . '\'';
124
-                }
125
-                $xoopsDB->query($sql) or $eh->show('0013');
126
-            }
127
-        }
128
-    } else {
129
-        redirect_header('index.php', 2, _MD_NOVALIDITEM_TITLEMISSING);
130
-        exit();
131
-    }
132
-    if (isset($_POST['ini_description'])) {
133
-        $p_ini_description = $myts->makeTareaData4Save($_POST['ini_description']);
134
-    } else {
135
-        $p_ini_description = null;
136
-    }
137
-    if (isset($_POST['description'])) {
138
-        $p_description = $myts->makeTareaData4Save($_POST['description']);
139
-    } else {
140
-        $p_description = null;
141
-    }
142
-    if (isset($_POST['description_set'])) {
143
-        if ($_POST['description_set'] == '1') {
144
-            if ($p_ini_description != $p_description) {
145
-                $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid";
146
-                $xoopsDB->query($sql) or $eh->show('0013');
147
-            }
148
-        } elseif ($p_description != null or $p_description !== '') {
149
-            $sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description);
150
-            $xoopsDB->query($sql) or $eh->show('0013');
151
-        }
152
-    }
64
+	if (!empty($_POST['itemid'])) {
65
+		$post_itemid = (int)$_POST['itemid'];
66
+	} else {
67
+		redirect_header('index.php', 2, _MD_NOVALIDITEM_IDMISSING);
68
+		exit();
69
+	}
70
+	if (isset($_POST['op'])) {
71
+		$op = $_POST['op'];
72
+	} else {
73
+		$op = '';
74
+	}
75
+	// If option is "submitforapproval" then submit and redirect;
76
+	if ($op === 'submitforapproval') {
77
+		if ($efqListingHandler->updateStatus($post_itemid, '1')) {
78
+			redirect_header('index.php', 2, _MD_SUBMITTED_PUBLICATION);
79
+		} else {
80
+			redirect_header('index.php', 2, _MD_ERROR_NOT_SAVED);
81
+		}
82
+		exit();
83
+	}
84
+	if (!empty($_POST['dirid'])) {
85
+		$post_dirid = (int)$_POST['dirid'];
86
+	} else {
87
+		$post_dirid = 0;
88
+	}
89
+	if (isset($_POST['itemtitle'])) {
90
+		$p_title     = $myts->makeTboxData4Save($_POST['itemtitle']);
91
+		$p_ini_title = $myts->makeTboxData4Save($_POST['ini_itemtitle']);
92
+		// Start uploading up file;
93
+		require_once XOOPS_ROOT_PATH . '/class/uploader.php';
94
+		$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads', array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/jpg'), 300000, 250, 250);
95
+		$uploader->setPrefix('logo');
96
+		$err    = array();
97
+		$ucount = count($_POST['xoops_upload_file']);
98
+		for ($i = 0; $i < $ucount; ++$i) {
99
+			if ($_POST['xoops_upload_file'][$i] !== '') {
100
+				$medianame = $_POST['xoops_upload_file'][$i];
101
+				if ($uploader->fetchMedia($_POST['xoops_upload_file'][$i])) {
102
+					if (!$uploader->upload()) {
103
+						$err[] = $uploader->getErrors();
104
+					} else {
105
+						$savedfilename = $uploader->getSavedFileName();
106
+						$ticket        = uniqid(mt_rand(), 1);
107
+						//Rename the uploaded file to the same name in a different location that does not have 777 rights or 755.
108
+						rename('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '', '' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/uploads/' . $savedfilename . '');
109
+						//Delete the uploaded file from the initial upload folder if it is still present in that folder.
110
+						if (file_exists('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '')) {
111
+							unlink('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '');
112
+						}
113
+					}
114
+					if ($p_title != $p_ini_title) {
115
+						$sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET logourl = '" . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
116
+					} else {
117
+						$sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\', logourl = \'' . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
118
+					}
119
+					$xoopsDB->query($sql) or $eh->show('0013');
120
+				}
121
+			} else {
122
+				if ($p_title != $p_ini_title) {
123
+					$sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\' WHERE itemid = \'' . $post_itemid . '\'';
124
+				}
125
+				$xoopsDB->query($sql) or $eh->show('0013');
126
+			}
127
+		}
128
+	} else {
129
+		redirect_header('index.php', 2, _MD_NOVALIDITEM_TITLEMISSING);
130
+		exit();
131
+	}
132
+	if (isset($_POST['ini_description'])) {
133
+		$p_ini_description = $myts->makeTareaData4Save($_POST['ini_description']);
134
+	} else {
135
+		$p_ini_description = null;
136
+	}
137
+	if (isset($_POST['description'])) {
138
+		$p_description = $myts->makeTareaData4Save($_POST['description']);
139
+	} else {
140
+		$p_description = null;
141
+	}
142
+	if (isset($_POST['description_set'])) {
143
+		if ($_POST['description_set'] == '1') {
144
+			if ($p_ini_description != $p_description) {
145
+				$sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid";
146
+				$xoopsDB->query($sql) or $eh->show('0013');
147
+			}
148
+		} elseif ($p_description != null or $p_description !== '') {
149
+			$sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description);
150
+			$xoopsDB->query($sql) or $eh->show('0013');
151
+		}
152
+	}
153 153
 
154
-    $linkedcats = $efqListingHandler->getLinkedCatsArray($post_itemid, $post_dirid);
154
+	$linkedcats = $efqListingHandler->getLinkedCatsArray($post_itemid, $post_dirid);
155 155
 
156
-    $allcatsresult = $xoopsDB->query('SELECT cid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\'');
157
-    $numrows       = $xoopsDB->getRowsNum($allcatsresult);
158
-    $count         = 0;
159
-    if ($numrows > 0) {
160
-        while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) {
161
-            if (isset($_POST['selected' . $cid . ''])) {
162
-                if (!in_array($cid, $linkedcats)) {
163
-                    $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq');
164
-                    $sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
165
-                    $xoopsDB->query($sql) or $eh->show('0013');
166
-                }
156
+	$allcatsresult = $xoopsDB->query('SELECT cid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\'');
157
+	$numrows       = $xoopsDB->getRowsNum($allcatsresult);
158
+	$count         = 0;
159
+	if ($numrows > 0) {
160
+		while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) {
161
+			if (isset($_POST['selected' . $cid . ''])) {
162
+				if (!in_array($cid, $linkedcats)) {
163
+					$newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq');
164
+					$sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
165
+					$xoopsDB->query($sql) or $eh->show('0013');
166
+				}
167 167
 
168
-                ++$count;
169
-            } else {
170
-                if (in_array($cid, $linkedcats)) {
171
-                    $sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid);
172
-                    $xoopsDB->query($sql) or $eh->show('0013');
173
-                }
174
-            }
175
-        }
176
-        if ($count == 0) {
177
-            redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORYMATCH);
178
-            exit();
179
-        }
180
-    } else {
181
-        redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORIESAVAILABLE);
182
-        exit();
183
-    }
168
+				++$count;
169
+			} else {
170
+				if (in_array($cid, $linkedcats)) {
171
+					$sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid);
172
+					$xoopsDB->query($sql) or $eh->show('0013');
173
+				}
174
+			}
175
+		}
176
+		if ($count == 0) {
177
+			redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORYMATCH);
178
+			exit();
179
+		}
180
+	} else {
181
+		redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORIESAVAILABLE);
182
+		exit();
183
+	}
184 184
 
185
-    // Get all datatypes that can be associated with this listing.
186
-    $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, t.custom ';
187
-    $sql         .= 'FROM '
188
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
189
-                    . ' ic, '
190
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
191
-                    . ' xc, '
192
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
193
-                    . ' f, '
194
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n')
195
-                                       . '_dtypes')
196
-                    . ' t ';
197
-    $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') ';
198
-    $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $post_itemid . '';
199
-    $data_result = $xoopsDB->query($sql) or $eh->show('0013');
200
-    while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $custom) = $xoopsDB->fetchRow($data_result)) {
201
-        if (isset($_POST["$dtypeid"])) {
202
-            if (is_array($_POST["$dtypeid"])) {
203
-                $post_value_array       = $_POST["$dtypeid"];
204
-                $post_value             = '';
205
-                $options_arr            = explode('[|]', $options);
206
-                $options_arr[]          = '-';
207
-                $count_post_value_array = count($post_value_array);
208
-                for ($i = 0; $i < $count_post_value_array; ++$i) {
209
-                    // Check if posted value is in options.
210
-                    if (in_array($post_value_array[$i], $options_arr)) {
211
-                        if ($i == 0) {
212
-                            $post_value = $post_value_array[$i];
213
-                        } else {
214
-                            $post_value .= '|' . $post_value_array[$i];
215
-                        }
216
-                    }
217
-                }
218
-            } else {
219
-                $post_value = $myts->makeTboxData4Save($_POST["$dtypeid"]);
220
-            }
221
-        } else {
222
-            $post_value = '';
223
-        }
224
-        if (isset($_POST['custom' . $dtypeid . ''])) {
225
-            $post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']);
226
-        } else {
227
-            $post_customtitle = '';
228
-        }
229
-        if (isset($_POST['url_title' . $dtypeid . ''])) {
230
-            $post_urltitle = $myts->makeTboxData4Save($_POST['url_title' . $dtypeid . '']);
231
-        } else {
232
-            $post_urltitle = '';
233
-        }
234
-        if (isset($_POST['url_link' . $dtypeid . ''])) {
235
-            $post_urllink = $myts->makeTboxData4Save($_POST['url_link' . $dtypeid . '']);
236
-        } else {
237
-            $post_urllink = '';
238
-        }
239
-        if ($post_urllink !== '') {
240
-            $post_value = $post_urllink . '|' . $post_urltitle;
241
-        }
242
-        if ($itemid == null) {
243
-            //That means there was not any value, so a new record should be added to the data table.
244
-            $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . '_dataid_seq');
245
-            $sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created, customtitle) VALUES (%u, %u, %u, '%s', '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time(), $post_customtitle);
246
-            $xoopsDB->query($sql) or $eh->show('0013');
247
-        } else {
248
-            if ($value != $post_value) {
249
-                $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . " SET value = '$post_value', customtitle = '$post_customtitle' WHERE dtypeid = '$dtypeid' AND itemid = '$post_itemid'";
250
-                $xoopsDB->query($sql) or $eh->show('0013');
251
-            }
252
-        }
253
-    }
254
-    redirect_header("edit.php?item=$post_itemid", 1, _MD_ITEM_UPDATED);
255
-    exit();
185
+	// Get all datatypes that can be associated with this listing.
186
+	$sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, t.custom ';
187
+	$sql         .= 'FROM '
188
+					. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
189
+					. ' ic, '
190
+					. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
191
+					. ' xc, '
192
+					. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
193
+					. ' f, '
194
+					. $xoopsDB->prefix($module->getVar('dirname', 'n')
195
+									   . '_dtypes')
196
+					. ' t ';
197
+	$sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') ';
198
+	$sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $post_itemid . '';
199
+	$data_result = $xoopsDB->query($sql) or $eh->show('0013');
200
+	while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $custom) = $xoopsDB->fetchRow($data_result)) {
201
+		if (isset($_POST["$dtypeid"])) {
202
+			if (is_array($_POST["$dtypeid"])) {
203
+				$post_value_array       = $_POST["$dtypeid"];
204
+				$post_value             = '';
205
+				$options_arr            = explode('[|]', $options);
206
+				$options_arr[]          = '-';
207
+				$count_post_value_array = count($post_value_array);
208
+				for ($i = 0; $i < $count_post_value_array; ++$i) {
209
+					// Check if posted value is in options.
210
+					if (in_array($post_value_array[$i], $options_arr)) {
211
+						if ($i == 0) {
212
+							$post_value = $post_value_array[$i];
213
+						} else {
214
+							$post_value .= '|' . $post_value_array[$i];
215
+						}
216
+					}
217
+				}
218
+			} else {
219
+				$post_value = $myts->makeTboxData4Save($_POST["$dtypeid"]);
220
+			}
221
+		} else {
222
+			$post_value = '';
223
+		}
224
+		if (isset($_POST['custom' . $dtypeid . ''])) {
225
+			$post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']);
226
+		} else {
227
+			$post_customtitle = '';
228
+		}
229
+		if (isset($_POST['url_title' . $dtypeid . ''])) {
230
+			$post_urltitle = $myts->makeTboxData4Save($_POST['url_title' . $dtypeid . '']);
231
+		} else {
232
+			$post_urltitle = '';
233
+		}
234
+		if (isset($_POST['url_link' . $dtypeid . ''])) {
235
+			$post_urllink = $myts->makeTboxData4Save($_POST['url_link' . $dtypeid . '']);
236
+		} else {
237
+			$post_urllink = '';
238
+		}
239
+		if ($post_urllink !== '') {
240
+			$post_value = $post_urllink . '|' . $post_urltitle;
241
+		}
242
+		if ($itemid == null) {
243
+			//That means there was not any value, so a new record should be added to the data table.
244
+			$newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . '_dataid_seq');
245
+			$sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created, customtitle) VALUES (%u, %u, %u, '%s', '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time(), $post_customtitle);
246
+			$xoopsDB->query($sql) or $eh->show('0013');
247
+		} else {
248
+			if ($value != $post_value) {
249
+				$sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . " SET value = '$post_value', customtitle = '$post_customtitle' WHERE dtypeid = '$dtypeid' AND itemid = '$post_itemid'";
250
+				$xoopsDB->query($sql) or $eh->show('0013');
251
+			}
252
+		}
253
+	}
254
+	redirect_header("edit.php?item=$post_itemid", 1, _MD_ITEM_UPDATED);
255
+	exit();
256 256
 } else {
257
-    // Prepare page for showing listing edit form.
258
-    if (!empty($_GET['item'])) {
259
-        $get_itemid = (int)$_GET['item'];
260
-        $get_dirid  = getDirIdFromItem($get_itemid);
261
-    } else {
262
-        redirect_header('index.php', 2, _MD_NOVALIDITEM_GET_IDMISSING);
263
-        exit();
264
-    }
257
+	// Prepare page for showing listing edit form.
258
+	if (!empty($_GET['item'])) {
259
+		$get_itemid = (int)$_GET['item'];
260
+		$get_dirid  = getDirIdFromItem($get_itemid);
261
+	} else {
262
+		redirect_header('index.php', 2, _MD_NOVALIDITEM_GET_IDMISSING);
263
+		exit();
264
+	}
265 265
 
266
-    $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_editlisting.tpl';
267
-    include XOOPS_ROOT_PATH . '/header.php';
268
-    $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
269
-    $xoopsTpl->assign('lang_submit', _SUBMIT);
270
-    $xoopsTpl->assign('lang_cancel', _CANCEL);
266
+	$GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_editlisting.tpl';
267
+	include XOOPS_ROOT_PATH . '/header.php';
268
+	$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
269
+	$xoopsTpl->assign('lang_submit', _SUBMIT);
270
+	$xoopsTpl->assign('lang_cancel', _CANCEL);
271 271
 
272
-    $sql         = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
273
-                   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items')
274
-                   . ' i LEFT JOIN '
275
-                   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text')
276
-                   . ' t ON (i.itemid=t.itemid) WHERE i.itemid='
277
-                   . $get_itemid
278
-                   . '';
279
-    $item_result = $xoopsDB->query($sql);
280
-    $numrows     = $xoopsDB->getRowsNum($item_result);
272
+	$sql         = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
273
+				   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items')
274
+				   . ' i LEFT JOIN '
275
+				   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text')
276
+				   . ' t ON (i.itemid=t.itemid) WHERE i.itemid='
277
+				   . $get_itemid
278
+				   . '';
279
+	$item_result = $xoopsDB->query($sql);
280
+	$numrows     = $xoopsDB->getRowsNum($item_result);
281 281
 
282
-    while (list($itemid, $logourl, $submitter, $status, $created, $itemtitle, $typeid, $description) = $xoopsDB->fetchRow($item_result)) {
283
-        $itemtitle = $myts->htmlSpecialChars($itemtitle);
284
-        // Only the submitter or the admin are allowed edit a listing, so make sure
285
-        // all other users are redirected elsewhere.
286
-        if ($isadmin or $submitter == $userid) {
287
-            if ($status == '0' and $submitter == $userid) {
288
-                // Only the submitter can submit listing for approval when status = 0.
289
-                $submit_for_approval_button = "<form action=\"edit.php\" method=\"post\"><input type=\"hidden\" name=\"op\" value=\"submitforapproval\"><input type=\"hidden\" name=\"user\" value=\"$userid\"><input type=\"hidden\" name=\"itemid\" value=\"$get_itemid\"><input type=\"submit\" name=\"submit\" class=\"formButton\" value=\""
290
-                                              . _MD_PUBLISH_LISTING
291
-                                              . '"></form><br>';
292
-                $xoopsTpl->assign('submitview_button', $submit_for_approval_button);
293
-            } elseif ($xoopsModuleConfig['autoapprove'] == 1) {
294
-                // If status is not 0 and autoapprove is on, the submitter or
295
-                // admin can edit the listing and with the button "view listing"
296
-                // Go to the listing page in 'view' mode.
297
-                $view_button = '<form action="listing.php" method="get"><input type="hidden" name="item" value="' . $itemid . '"><input type="submit" value="' . _MD_VIEWITEM . '"></input></form><br>';
298
-                $xoopsTpl->assign('submitview_button', $view_button);
299
-            } elseif (!$isadmin) {
300
-                // Only admin is allowed to edit a listing after approval (status = 2)
301
-                // in case autoapprove is off.
302
-                redirect_header('listing.php?item=' . $itemid, 2, _MD_ONLYADMIN_ALLOWED_TO_EDIT);
303
-                exit();
304
-            }
305
-            if ($logourl !== '') {
306
-                $picture = "uploads/$logourl";
307
-            } else {
308
-                $picture = 'images/nopicture.gif';
309
-            }
310
-            $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ';
311
-            $sql         .= 'FROM '
312
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
313
-                            . ' ic, '
314
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
315
-                            . ' xc, '
316
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
317
-                            . ' f, '
318
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes')
319
-                            . ' t ';
320
-            $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') ';
321
-            $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . '';
322
-            $data_result = $xoopsDB->query($sql) or $eh->show('0013');
323
-            $numrows     = $xoopsDB->getRowsNum($data_result);
282
+	while (list($itemid, $logourl, $submitter, $status, $created, $itemtitle, $typeid, $description) = $xoopsDB->fetchRow($item_result)) {
283
+		$itemtitle = $myts->htmlSpecialChars($itemtitle);
284
+		// Only the submitter or the admin are allowed edit a listing, so make sure
285
+		// all other users are redirected elsewhere.
286
+		if ($isadmin or $submitter == $userid) {
287
+			if ($status == '0' and $submitter == $userid) {
288
+				// Only the submitter can submit listing for approval when status = 0.
289
+				$submit_for_approval_button = "<form action=\"edit.php\" method=\"post\"><input type=\"hidden\" name=\"op\" value=\"submitforapproval\"><input type=\"hidden\" name=\"user\" value=\"$userid\"><input type=\"hidden\" name=\"itemid\" value=\"$get_itemid\"><input type=\"submit\" name=\"submit\" class=\"formButton\" value=\""
290
+											  . _MD_PUBLISH_LISTING
291
+											  . '"></form><br>';
292
+				$xoopsTpl->assign('submitview_button', $submit_for_approval_button);
293
+			} elseif ($xoopsModuleConfig['autoapprove'] == 1) {
294
+				// If status is not 0 and autoapprove is on, the submitter or
295
+				// admin can edit the listing and with the button "view listing"
296
+				// Go to the listing page in 'view' mode.
297
+				$view_button = '<form action="listing.php" method="get"><input type="hidden" name="item" value="' . $itemid . '"><input type="submit" value="' . _MD_VIEWITEM . '"></input></form><br>';
298
+				$xoopsTpl->assign('submitview_button', $view_button);
299
+			} elseif (!$isadmin) {
300
+				// Only admin is allowed to edit a listing after approval (status = 2)
301
+				// in case autoapprove is off.
302
+				redirect_header('listing.php?item=' . $itemid, 2, _MD_ONLYADMIN_ALLOWED_TO_EDIT);
303
+				exit();
304
+			}
305
+			if ($logourl !== '') {
306
+				$picture = "uploads/$logourl";
307
+			} else {
308
+				$picture = 'images/nopicture.gif';
309
+			}
310
+			$sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ';
311
+			$sql         .= 'FROM '
312
+							. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
313
+							. ' ic, '
314
+							. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
315
+							. ' xc, '
316
+							. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
317
+							. ' f, '
318
+							. $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes')
319
+							. ' t ';
320
+			$sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') ';
321
+			$sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . '';
322
+			$data_result = $xoopsDB->query($sql) or $eh->show('0013');
323
+			$numrows     = $xoopsDB->getRowsNum($data_result);
324 324
 
325
-            ob_start();
326
-            $form = new XoopsThemeForm(_MD_EDITITEM_FORM, 'editform', 'edit.php');
327
-            $form->setExtra('enctype="multipart/form-data"');
328
-            $form->addElement(new XoopsFormText(_MD_TITLE, 'itemtitle', 50, 250, $itemtitle), true);
329
-            //$categories = getCategoriesPaths($get_itemid);
330
-            $categories = getCatSelectArea($get_itemid, $get_dirid);
331
-            $form_cats  = new XoopsFormLabel(_MD_ITEMCATEGORIES, "$categories");
332
-            $form->addElement($form_cats);
333
-            $form->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTION, 'description', $description, 5, 50));
334
-            $form->addElement(new XoopsFormFile(_MD_SELECT_PIC, 'image', 30000));
335
-            $form->addElement(new XoopsFormImage(_MD_CURRENT_PIC, 'current_image', null, "$picture", '', ''));
325
+			ob_start();
326
+			$form = new XoopsThemeForm(_MD_EDITITEM_FORM, 'editform', 'edit.php');
327
+			$form->setExtra('enctype="multipart/form-data"');
328
+			$form->addElement(new XoopsFormText(_MD_TITLE, 'itemtitle', 50, 250, $itemtitle), true);
329
+			//$categories = getCategoriesPaths($get_itemid);
330
+			$categories = getCatSelectArea($get_itemid, $get_dirid);
331
+			$form_cats  = new XoopsFormLabel(_MD_ITEMCATEGORIES, "$categories");
332
+			$form->addElement($form_cats);
333
+			$form->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTION, 'description', $description, 5, 50));
334
+			$form->addElement(new XoopsFormFile(_MD_SELECT_PIC, 'image', 30000));
335
+			$form->addElement(new XoopsFormImage(_MD_CURRENT_PIC, 'current_image', null, "$picture", '', ''));
336 336
 
337
-            while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $xoopsDB->fetchRow($data_result)) {
338
-                $field = $datafieldmanager->createField($title, $dtypeid, $fieldtype, $ext, $options, $value, $custom, $customtitle);
339
-            }
340
-            $form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
341
-            $form->addElement(new XoopsFormHidden('op', 'edit'));
342
-            $form->addElement(new XoopsFormHidden('itemid', $get_itemid));
343
-            $form->addElement(new XoopsFormHidden('dirid', $get_dirid));
344
-            $form->addElement(new XoopsFormHidden('ini_itemtitle', $itemtitle));
337
+			while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $xoopsDB->fetchRow($data_result)) {
338
+				$field = $datafieldmanager->createField($title, $dtypeid, $fieldtype, $ext, $options, $value, $custom, $customtitle);
339
+			}
340
+			$form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
341
+			$form->addElement(new XoopsFormHidden('op', 'edit'));
342
+			$form->addElement(new XoopsFormHidden('itemid', $get_itemid));
343
+			$form->addElement(new XoopsFormHidden('dirid', $get_dirid));
344
+			$form->addElement(new XoopsFormHidden('ini_itemtitle', $itemtitle));
345 345
 
346
-            if ($description != null) {
347
-                $form->addElement(new XoopsFormHidden('ini_description', $description));
348
-            }
349
-            $form->addElement(new XoopsFormHidden('uid', $userid));
350
-            if ($description != null) {
351
-                $form->addElement(new XoopsFormHidden('description_set', '1'));
352
-            } else {
353
-                $form->addElement(new XoopsFormHidden('description_set', '0'));
354
-            }
355
-            $form->display();
356
-            $xoopsTpl->assign('dtypes_form', ob_get_contents());
357
-            ob_end_clean();
358
-        }
359
-    }
346
+			if ($description != null) {
347
+				$form->addElement(new XoopsFormHidden('ini_description', $description));
348
+			}
349
+			$form->addElement(new XoopsFormHidden('uid', $userid));
350
+			if ($description != null) {
351
+				$form->addElement(new XoopsFormHidden('description_set', '1'));
352
+			} else {
353
+				$form->addElement(new XoopsFormHidden('description_set', '0'));
354
+			}
355
+			$form->display();
356
+			$xoopsTpl->assign('dtypes_form', ob_get_contents());
357
+			ob_end_clean();
358
+		}
359
+	}
360 360
 }
361 361
 include XOOPS_ROOT_PATH . '/footer.php';
362 362
 
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
  */
367 367
 function GetLevelid($locdestid)
368 368
 {
369
-    global $xoopsDB;
370
-    $block        = array();
371
-    $myts         = MyTextSanitizer::getInstance();
372
-    $result2      = $xoopsDB->query('SELECT locid, levelid FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
373
-    $num_results2 = $GLOBALS['xoopsDB']->getRowsNum($result2);
374
-    if (!$result2) {
375
-        return 0;
376
-    }
377
-    for ($i = 0; $i < $num_results2; ++$i) {
378
-        $row2    = $GLOBALS['xoopsDB']->fetchBoth($result2);
379
-        $levelid = $row2['levelid'];
380
-    }
369
+	global $xoopsDB;
370
+	$block        = array();
371
+	$myts         = MyTextSanitizer::getInstance();
372
+	$result2      = $xoopsDB->query('SELECT locid, levelid FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
373
+	$num_results2 = $GLOBALS['xoopsDB']->getRowsNum($result2);
374
+	if (!$result2) {
375
+		return 0;
376
+	}
377
+	for ($i = 0; $i < $num_results2; ++$i) {
378
+		$row2    = $GLOBALS['xoopsDB']->fetchBoth($result2);
379
+		$levelid = $row2['levelid'];
380
+	}
381 381
 
382
-    return $levelid;
382
+	return $levelid;
383 383
 }
384 384
 
385 385
 /**
@@ -388,20 +388,20 @@  discard block
 block discarded – undo
388 388
  */
389 389
 function GetLocName($locdestid)
390 390
 {
391
-    global $xoopsDB;
392
-    $block       = array();
393
-    $myts        = MyTextSanitizer::getInstance();
394
-    $result      = $xoopsDB->query('SELECT locid, name FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
395
-    $num_results = $GLOBALS['xoopsDB']->getRowsNum($result);
396
-    if (!$result) {
397
-        return 0;
398
-    }
399
-    for ($i = 0; $i < $num_results; ++$i) {
400
-        $row     = $GLOBALS['xoopsDB']->fetchBoth($result);
401
-        $locname = $myts->htmlSpecialChars($row['name']);
402
-    }
391
+	global $xoopsDB;
392
+	$block       = array();
393
+	$myts        = MyTextSanitizer::getInstance();
394
+	$result      = $xoopsDB->query('SELECT locid, name FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
395
+	$num_results = $GLOBALS['xoopsDB']->getRowsNum($result);
396
+	if (!$result) {
397
+		return 0;
398
+	}
399
+	for ($i = 0; $i < $num_results; ++$i) {
400
+		$row     = $GLOBALS['xoopsDB']->fetchBoth($result);
401
+		$locname = $myts->htmlSpecialChars($row['name']);
402
+	}
403 403
 
404
-    return $locname;
404
+	return $locname;
405 405
 }
406 406
 
407 407
 include XOOPS_ROOT_PATH . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
18 18
  * @author       XOOPS Development Team,
19 19
  */
20 20
 
21
-include __DIR__ . '/header.php';
21
+include __DIR__.'/header.php';
22 22
 $myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object
23
-require_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
24
-require_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php';
25
-require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
26
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
27
-require_once __DIR__ . '/class/class.datafieldmanager.php';
28
-require_once __DIR__ . '/class/class.formimage.php';
29
-require_once __DIR__ . '/class/class.formdate.php';
30
-require_once __DIR__ . '/class/class.image.php';
31
-require_once __DIR__ . '/class/class.efqtree.php';
32
-require_once __DIR__ . '/class/class.listing.php';
23
+require_once XOOPS_ROOT_PATH.'/class/xoopstree.php';
24
+require_once XOOPS_ROOT_PATH.'/class/module.errorhandler.php';
25
+require_once XOOPS_ROOT_PATH.'/include/xoopscodes.php';
26
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
27
+require_once __DIR__.'/class/class.datafieldmanager.php';
28
+require_once __DIR__.'/class/class.formimage.php';
29
+require_once __DIR__.'/class/class.formdate.php';
30
+require_once __DIR__.'/class/class.image.php';
31
+require_once __DIR__.'/class/class.efqtree.php';
32
+require_once __DIR__.'/class/class.listing.php';
33 33
 
34 34
 // Get module directory name;
35 35
 $moddir = $xoopsModule->getVar('dirname');
36 36
 // Prepare two tree classes;
37
-$mytree            = new XoopsTree($xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat'), 'cid', 'pid');
38
-$efqtree           = new efqTree($xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat'), 'cid', 'pid');
37
+$mytree            = new XoopsTree($xoopsDB->prefix($module->getVar('dirname', 'n').'_cat'), 'cid', 'pid');
38
+$efqtree           = new efqTree($xoopsDB->prefix($module->getVar('dirname', 'n').'_cat'), 'cid', 'pid');
39 39
 $efqListing        = new efqListing();
40 40
 $efqListingHandler = new efqListingHandler();
41 41
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 // If the user is not logged in and anonymous postings are
46 46
 // not allowed, redirect and exit.
47 47
 if (empty($xoopsUser) and !$xoopsModuleConfig['anonpost']) {
48
-    redirect_header(XOOPS_URL . '/user.php', 2, _MD_MUSTREGFIRST);
48
+    redirect_header(XOOPS_URL.'/user.php', 2, _MD_MUSTREGFIRST);
49 49
     exit();
50 50
 }
51 51
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 // If submit data was posted;
63 63
 if (!empty($_POST['submit'])) {
64 64
     if (!empty($_POST['itemid'])) {
65
-        $post_itemid = (int)$_POST['itemid'];
65
+        $post_itemid = (int) $_POST['itemid'];
66 66
     } else {
67 67
         redirect_header('index.php', 2, _MD_NOVALIDITEM_IDMISSING);
68 68
         exit();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         exit();
83 83
     }
84 84
     if (!empty($_POST['dirid'])) {
85
-        $post_dirid = (int)$_POST['dirid'];
85
+        $post_dirid = (int) $_POST['dirid'];
86 86
     } else {
87 87
         $post_dirid = 0;
88 88
     }
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
         $p_title     = $myts->makeTboxData4Save($_POST['itemtitle']);
91 91
         $p_ini_title = $myts->makeTboxData4Save($_POST['ini_itemtitle']);
92 92
         // Start uploading up file;
93
-        require_once XOOPS_ROOT_PATH . '/class/uploader.php';
94
-        $uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads', array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/jpg'), 300000, 250, 250);
93
+        require_once XOOPS_ROOT_PATH.'/class/uploader.php';
94
+        $uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/init_uploads', array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/jpg'), 300000, 250, 250);
95 95
         $uploader->setPrefix('logo');
96 96
         $err    = array();
97 97
         $ucount = count($_POST['xoops_upload_file']);
@@ -105,22 +105,22 @@  discard block
 block discarded – undo
105 105
                         $savedfilename = $uploader->getSavedFileName();
106 106
                         $ticket        = uniqid(mt_rand(), 1);
107 107
                         //Rename the uploaded file to the same name in a different location that does not have 777 rights or 755.
108
-                        rename('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '', '' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/uploads/' . $savedfilename . '');
108
+                        rename(''.XOOPS_ROOT_PATH.'/modules/'.$moddir.'/init_uploads/'.$savedfilename.'', ''.XOOPS_ROOT_PATH.'/modules/'.$moddir.'/uploads/'.$savedfilename.'');
109 109
                         //Delete the uploaded file from the initial upload folder if it is still present in that folder.
110
-                        if (file_exists('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '')) {
111
-                            unlink('' . XOOPS_ROOT_PATH . '/modules/' . $moddir . '/init_uploads/' . $savedfilename . '');
110
+                        if (file_exists(''.XOOPS_ROOT_PATH.'/modules/'.$moddir.'/init_uploads/'.$savedfilename.'')) {
111
+                            unlink(''.XOOPS_ROOT_PATH.'/modules/'.$moddir.'/init_uploads/'.$savedfilename.'');
112 112
                         }
113 113
                     }
114 114
                     if ($p_title != $p_ini_title) {
115
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET logourl = '" . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
115
+                        $sql = 'UPDATE '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_items')." SET logourl = '".$savedfilename.'\' WHERE itemid = \''.$post_itemid.'\'';
116 116
                     } else {
117
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\', logourl = \'' . $savedfilename . '\' WHERE itemid = \'' . $post_itemid . '\'';
117
+                        $sql = 'UPDATE '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_items')." SET title = '".$p_title.'\', logourl = \''.$savedfilename.'\' WHERE itemid = \''.$post_itemid.'\'';
118 118
                     }
119 119
                     $xoopsDB->query($sql) or $eh->show('0013');
120 120
                 }
121 121
             } else {
122 122
                 if ($p_title != $p_ini_title) {
123
-                    $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') . " SET title = '" . $p_title . '\' WHERE itemid = \'' . $post_itemid . '\'';
123
+                    $sql = 'UPDATE '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_items')." SET title = '".$p_title.'\' WHERE itemid = \''.$post_itemid.'\'';
124 124
                 }
125 125
                 $xoopsDB->query($sql) or $eh->show('0013');
126 126
             }
@@ -142,60 +142,60 @@  discard block
 block discarded – undo
142 142
     if (isset($_POST['description_set'])) {
143 143
         if ($_POST['description_set'] == '1') {
144 144
             if ($p_ini_description != $p_description) {
145
-                $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid";
145
+                $sql = 'UPDATE '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_item_text')." SET description = '$p_description' WHERE itemid = $post_itemid";
146 146
                 $xoopsDB->query($sql) or $eh->show('0013');
147 147
             }
148 148
         } elseif ($p_description != null or $p_description !== '') {
149
-            $sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description);
149
+            $sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_text'), $post_itemid, $p_description);
150 150
             $xoopsDB->query($sql) or $eh->show('0013');
151 151
         }
152 152
     }
153 153
 
154 154
     $linkedcats = $efqListingHandler->getLinkedCatsArray($post_itemid, $post_dirid);
155 155
 
156
-    $allcatsresult = $xoopsDB->query('SELECT cid FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\'');
156
+    $allcatsresult = $xoopsDB->query('SELECT cid FROM '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_cat')." WHERE dirid='".$post_dirid.'\' AND active=\'1\'');
157 157
     $numrows       = $xoopsDB->getRowsNum($allcatsresult);
158 158
     $count         = 0;
159 159
     if ($numrows > 0) {
160 160
         while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) {
161
-            if (isset($_POST['selected' . $cid . ''])) {
161
+            if (isset($_POST['selected'.$cid.''])) {
162 162
                 if (!in_array($cid, $linkedcats)) {
163
-                    $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq');
164
-                    $sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
163
+                    $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n').'_item_x_cat').'_xid_seq');
164
+                    $sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
165 165
                     $xoopsDB->query($sql) or $eh->show('0013');
166 166
                 }
167 167
 
168 168
                 ++$count;
169 169
             } else {
170 170
                 if (in_array($cid, $linkedcats)) {
171
-                    $sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid);
171
+                    $sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_x_cat'), $cid, $post_itemid);
172 172
                     $xoopsDB->query($sql) or $eh->show('0013');
173 173
                 }
174 174
             }
175 175
         }
176 176
         if ($count == 0) {
177
-            redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORYMATCH);
177
+            redirect_header(XOOPS_URL."/modules/$moddir/submit.php?dirid=".$post_dirid.'', 2, _MD_NOCATEGORYMATCH);
178 178
             exit();
179 179
         }
180 180
     } else {
181
-        redirect_header(XOOPS_URL . "/modules/$moddir/submit.php?dirid=" . $post_dirid . '', 2, _MD_NOCATEGORIESAVAILABLE);
181
+        redirect_header(XOOPS_URL."/modules/$moddir/submit.php?dirid=".$post_dirid.'', 2, _MD_NOCATEGORIESAVAILABLE);
182 182
         exit();
183 183
     }
184 184
 
185 185
     // Get all datatypes that can be associated with this listing.
186
-    $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, t.custom ';
187
-    $sql         .= 'FROM '
188
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
186
+    $sql = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, t.custom ';
187
+    $sql .= 'FROM '
188
+                    . $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_x_cat')
189 189
                     . ' ic, '
190
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
190
+                    . $xoopsDB->prefix($module->getVar('dirname', 'n').'_dtypes_x_cat')
191 191
                     . ' xc, '
192
-                    . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
192
+                    . $xoopsDB->prefix($module->getVar('dirname', 'n').'_fieldtypes')
193 193
                     . ' f, '
194 194
                     . $xoopsDB->prefix($module->getVar('dirname', 'n')
195 195
                                        . '_dtypes')
196 196
                     . ' t ';
197
-    $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') ';
198
-    $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $post_itemid . '';
197
+    $sql         .= 'LEFT JOIN '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_data').' d ON (t.dtypeid=d.dtypeid AND d.itemid='.$post_itemid.') ';
198
+    $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$post_itemid.'';
199 199
     $data_result = $xoopsDB->query($sql) or $eh->show('0013');
200 200
     while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $custom) = $xoopsDB->fetchRow($data_result)) {
201 201
         if (isset($_POST["$dtypeid"])) {
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                         if ($i == 0) {
212 212
                             $post_value = $post_value_array[$i];
213 213
                         } else {
214
-                            $post_value .= '|' . $post_value_array[$i];
214
+                            $post_value .= '|'.$post_value_array[$i];
215 215
                         }
216 216
                     }
217 217
                 }
@@ -221,32 +221,32 @@  discard block
 block discarded – undo
221 221
         } else {
222 222
             $post_value = '';
223 223
         }
224
-        if (isset($_POST['custom' . $dtypeid . ''])) {
225
-            $post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']);
224
+        if (isset($_POST['custom'.$dtypeid.''])) {
225
+            $post_customtitle = $myts->makeTboxData4Save($_POST['custom'.$dtypeid.'']);
226 226
         } else {
227 227
             $post_customtitle = '';
228 228
         }
229
-        if (isset($_POST['url_title' . $dtypeid . ''])) {
230
-            $post_urltitle = $myts->makeTboxData4Save($_POST['url_title' . $dtypeid . '']);
229
+        if (isset($_POST['url_title'.$dtypeid.''])) {
230
+            $post_urltitle = $myts->makeTboxData4Save($_POST['url_title'.$dtypeid.'']);
231 231
         } else {
232 232
             $post_urltitle = '';
233 233
         }
234
-        if (isset($_POST['url_link' . $dtypeid . ''])) {
235
-            $post_urllink = $myts->makeTboxData4Save($_POST['url_link' . $dtypeid . '']);
234
+        if (isset($_POST['url_link'.$dtypeid.''])) {
235
+            $post_urllink = $myts->makeTboxData4Save($_POST['url_link'.$dtypeid.'']);
236 236
         } else {
237 237
             $post_urllink = '';
238 238
         }
239 239
         if ($post_urllink !== '') {
240
-            $post_value = $post_urllink . '|' . $post_urltitle;
240
+            $post_value = $post_urllink.'|'.$post_urltitle;
241 241
         }
242 242
         if ($itemid == null) {
243 243
             //That means there was not any value, so a new record should be added to the data table.
244
-            $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . '_dataid_seq');
245
-            $sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created, customtitle) VALUES (%u, %u, %u, '%s', '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time(), $post_customtitle);
244
+            $newid = $xoopsDB->genId($xoopsDB->prefix($module->getVar('dirname', 'n').'_data').'_dataid_seq');
245
+            $sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created, customtitle) VALUES (%u, %u, %u, '%s', '%s', '%s')", $xoopsDB->prefix($module->getVar('dirname', 'n').'_data'), $newid, $post_itemid, $dtypeid, $post_value, time(), $post_customtitle);
246 246
             $xoopsDB->query($sql) or $eh->show('0013');
247 247
         } else {
248 248
             if ($value != $post_value) {
249
-                $sql = 'UPDATE ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . " SET value = '$post_value', customtitle = '$post_customtitle' WHERE dtypeid = '$dtypeid' AND itemid = '$post_itemid'";
249
+                $sql = 'UPDATE '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_data')." SET value = '$post_value', customtitle = '$post_customtitle' WHERE dtypeid = '$dtypeid' AND itemid = '$post_itemid'";
250 250
                 $xoopsDB->query($sql) or $eh->show('0013');
251 251
             }
252 252
         }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 } else {
257 257
     // Prepare page for showing listing edit form.
258 258
     if (!empty($_GET['item'])) {
259
-        $get_itemid = (int)$_GET['item'];
259
+        $get_itemid = (int) $_GET['item'];
260 260
         $get_dirid  = getDirIdFromItem($get_itemid);
261 261
     } else {
262 262
         redirect_header('index.php', 2, _MD_NOVALIDITEM_GET_IDMISSING);
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
     }
265 265
 
266 266
     $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_editlisting.tpl';
267
-    include XOOPS_ROOT_PATH . '/header.php';
267
+    include XOOPS_ROOT_PATH.'/header.php';
268 268
     $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
269 269
     $xoopsTpl->assign('lang_submit', _SUBMIT);
270 270
     $xoopsTpl->assign('lang_cancel', _CANCEL);
271 271
 
272
-    $sql         = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
273
-                   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items')
272
+    $sql = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
273
+                   . $xoopsDB->prefix($module->getVar('dirname', 'n').'_items')
274 274
                    . ' i LEFT JOIN '
275
-                   . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_text')
275
+                   . $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_text')
276 276
                    . ' t ON (i.itemid=t.itemid) WHERE i.itemid='
277 277
                    . $get_itemid
278 278
                    . '';
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
                 // If status is not 0 and autoapprove is on, the submitter or
295 295
                 // admin can edit the listing and with the button "view listing"
296 296
                 // Go to the listing page in 'view' mode.
297
-                $view_button = '<form action="listing.php" method="get"><input type="hidden" name="item" value="' . $itemid . '"><input type="submit" value="' . _MD_VIEWITEM . '"></input></form><br>';
297
+                $view_button = '<form action="listing.php" method="get"><input type="hidden" name="item" value="'.$itemid.'"><input type="submit" value="'._MD_VIEWITEM.'"></input></form><br>';
298 298
                 $xoopsTpl->assign('submitview_button', $view_button);
299 299
             } elseif (!$isadmin) {
300 300
                 // Only admin is allowed to edit a listing after approval (status = 2)
301 301
                 // in case autoapprove is off.
302
-                redirect_header('listing.php?item=' . $itemid, 2, _MD_ONLYADMIN_ALLOWED_TO_EDIT);
302
+                redirect_header('listing.php?item='.$itemid, 2, _MD_ONLYADMIN_ALLOWED_TO_EDIT);
303 303
                 exit();
304 304
             }
305 305
             if ($logourl !== '') {
@@ -308,17 +308,17 @@  discard block
 block discarded – undo
308 308
                 $picture = 'images/nopicture.gif';
309 309
             }
310 310
             $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ';
311
-            $sql         .= 'FROM '
312
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_item_x_cat')
311
+            $sql .= 'FROM '
312
+                            . $xoopsDB->prefix($module->getVar('dirname', 'n').'_item_x_cat')
313 313
                             . ' ic, '
314
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes_x_cat')
314
+                            . $xoopsDB->prefix($module->getVar('dirname', 'n').'_dtypes_x_cat')
315 315
                             . ' xc, '
316
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_fieldtypes')
316
+                            . $xoopsDB->prefix($module->getVar('dirname', 'n').'_fieldtypes')
317 317
                             . ' f, '
318
-                            . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dtypes')
318
+                            . $xoopsDB->prefix($module->getVar('dirname', 'n').'_dtypes')
319 319
                             . ' t ';
320
-            $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') ';
321
-            $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . '';
320
+            $sql         .= 'LEFT JOIN '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_data').' d ON (t.dtypeid=d.dtypeid AND d.itemid='.$get_itemid.') ';
321
+            $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=".$get_itemid.'';
322 322
             $data_result = $xoopsDB->query($sql) or $eh->show('0013');
323 323
             $numrows     = $xoopsDB->getRowsNum($data_result);
324 324
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         }
359 359
     }
360 360
 }
361
-include XOOPS_ROOT_PATH . '/footer.php';
361
+include XOOPS_ROOT_PATH.'/footer.php';
362 362
 
363 363
 /**
364 364
  * @param $locdestid
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     global $xoopsDB;
370 370
     $block        = array();
371 371
     $myts         = MyTextSanitizer::getInstance();
372
-    $result2      = $xoopsDB->query('SELECT locid, levelid FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
372
+    $result2      = $xoopsDB->query('SELECT locid, levelid FROM '.$xoopsDB->prefix('dst_loc').' WHERE locid = '.$locdestid.'');
373 373
     $num_results2 = $GLOBALS['xoopsDB']->getRowsNum($result2);
374 374
     if (!$result2) {
375 375
         return 0;
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
     global $xoopsDB;
392 392
     $block       = array();
393 393
     $myts        = MyTextSanitizer::getInstance();
394
-    $result      = $xoopsDB->query('SELECT locid, name FROM ' . $xoopsDB->prefix('dst_loc') . ' WHERE locid = ' . $locdestid . '');
394
+    $result      = $xoopsDB->query('SELECT locid, name FROM '.$xoopsDB->prefix('dst_loc').' WHERE locid = '.$locdestid.'');
395 395
     $num_results = $GLOBALS['xoopsDB']->getRowsNum($result);
396 396
     if (!$result) {
397 397
         return 0;
@@ -404,4 +404,4 @@  discard block
 block discarded – undo
404 404
     return $locname;
405 405
 }
406 406
 
407
-include XOOPS_ROOT_PATH . '/footer.php';
407
+include XOOPS_ROOT_PATH.'/footer.php';
Please login to merge, or discard this patch.
blocks/efqdiralpha1_menu.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,33 +32,33 @@  discard block
 block discarded – undo
32 32
 
33 33
 function b_efqdiralpha1_menu_show($options)
34 34
 {
35
-    global $xoopsDB, $xoopsModule, $eh;
36
-    //  $info = __DIR__;
37
-    //  $split = preg_split("#[\\\]#", $info);
38
-    //  $count = count($split) - 2;
39
-    //  $moddir = $split[$count];
40
-    //    $moddir = $xoopsModule->getvar("dirname");
41
-    $dirname       = basename(dirname(__DIR__));
42
-    $moduleHandler = xoops_getHandler('module');
43
-    $module        = $moduleHandler->getByDirname($dirname);
44
-    $moddir        = $module->getvar('dirname');
35
+	global $xoopsDB, $xoopsModule, $eh;
36
+	//  $info = __DIR__;
37
+	//  $split = preg_split("#[\\\]#", $info);
38
+	//  $count = count($split) - 2;
39
+	//  $moddir = $split[$count];
40
+	//    $moddir = $xoopsModule->getvar("dirname");
41
+	$dirname       = basename(dirname(__DIR__));
42
+	$moduleHandler = xoops_getHandler('module');
43
+	$module        = $moduleHandler->getByDirname($dirname);
44
+	$moddir        = $module->getvar('dirname');
45 45
 
46
-    $block                 = array();
47
-    $block['lang_dirmenu'] = _MB_EFQDIR_MENU;
48
-    $block['moddir']       = $moddir;
49
-    $myts                  = MyTextSanitizer::getInstance();
50
-    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
51
-    while ($myrow = $xoopsDB->fetchArray($result)) {
52
-        $directory              = array();
53
-        $name                   = $myts->htmlSpecialChars($myrow['name']);
54
-        $directory['dirid']     = $myrow['dirid'];
55
-        $directory['name']      = $name;
56
-        $directory['descr']     = $myrow['descr'];
57
-        $block['directories'][] = $directory;
58
-    }
59
-    $sublink = array();
46
+	$block                 = array();
47
+	$block['lang_dirmenu'] = _MB_EFQDIR_MENU;
48
+	$block['moddir']       = $moddir;
49
+	$myts                  = MyTextSanitizer::getInstance();
50
+	$result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
51
+	while ($myrow = $xoopsDB->fetchArray($result)) {
52
+		$directory              = array();
53
+		$name                   = $myts->htmlSpecialChars($myrow['name']);
54
+		$directory['dirid']     = $myrow['dirid'];
55
+		$directory['name']      = $name;
56
+		$directory['descr']     = $myrow['descr'];
57
+		$block['directories'][] = $directory;
58
+	}
59
+	$sublink = array();
60 60
 
61
-    return $block;
61
+	return $block;
62 62
 }
63 63
 
64 64
 /**
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function b_efqdiralpha1_menu_edit($options)
69 69
 {
70
-    $form = '' . _MB_EFQDIR_DISP . '&nbsp;';
71
-    $form .= "<input type='hidden' name='options[]' value='";
72
-    if ($options[0] === 'date') {
73
-        $form .= "date'";
74
-    } else {
75
-        $form .= "hits'";
76
-    }
77
-    $form .= '>';
78
-    $form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
79
-    $form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
70
+	$form = '' . _MB_EFQDIR_DISP . '&nbsp;';
71
+	$form .= "<input type='hidden' name='options[]' value='";
72
+	if ($options[0] === 'date') {
73
+		$form .= "date'";
74
+	} else {
75
+		$form .= "hits'";
76
+	}
77
+	$form .= '>';
78
+	$form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
79
+	$form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
80 80
 
81
-    return $form;
81
+	return $form;
82 82
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     $block['lang_dirmenu'] = _MB_EFQDIR_MENU;
48 48
     $block['moddir']       = $moddir;
49 49
     $myts                  = MyTextSanitizer::getInstance();
50
-    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
50
+    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_dir')." WHERE open='1' ORDER BY name") or $eh->show('0013');
51 51
     while ($myrow = $xoopsDB->fetchArray($result)) {
52 52
         $directory              = array();
53 53
         $name                   = $myts->htmlSpecialChars($myrow['name']);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function b_efqdiralpha1_menu_edit($options)
69 69
 {
70
-    $form = '' . _MB_EFQDIR_DISP . '&nbsp;';
70
+    $form = ''._MB_EFQDIR_DISP.'&nbsp;';
71 71
     $form .= "<input type='hidden' name='options[]' value='";
72 72
     if ($options[0] === 'date') {
73 73
         $form .= "date'";
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
         $form .= "hits'";
76 76
     }
77 77
     $form .= '>';
78
-    $form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
79
-    $form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
78
+    $form .= "<input type='text' name='options[]' value='".$options[1].'\'>&nbsp;'._MB_EFQDIR_LISTINGS.'';
79
+    $form .= '&nbsp;<br>'._MB_EFQDIR_CHARS."&nbsp;<input type='text' name='options[]' value='".$options[2].'\'>&nbsp;'._MB_EFQDIR_LENGTH.'';
80 80
 
81 81
     return $form;
82 82
 }
Please login to merge, or discard this patch.
blocks/efqdir_menu.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,38 +32,38 @@  discard block
 block discarded – undo
32 32
 
33 33
 function b_efqdiralpha1_menu_show($options)
34 34
 {
35
-    global $xoopsDB, $xoopsModule, $eh;
36
-    if (isset($xoopsModule)) {
35
+	global $xoopsDB, $xoopsModule, $eh;
36
+	if (isset($xoopsModule)) {
37 37
 
38
-        //$moddir = $xoopsModule->getvar("dirname");
39
-        $moduleDirName       = basename(dirname(__DIR__));
40
-        $moduleHandler = xoops_getHandler('module');
41
-        $module        = $moduleHandler->getByDirname($moduleDirName);
42
-        $moddir        = $module->getvar('dirname');
43
-    } else {
44
-        $info   = __DIR__;
45
-        $split  = preg_split("#[\]#", $info);
46
-        $count  = count($split) - 2;
47
-        $moddir = $split[$count];
48
-    }
49
-    $block                 = array();
50
-    $block['lang_dirmenu'] = _MB_EFQDIR_MENU;
51
-    $block['moddir']       = $moddir;
52
-    $myts                  = MyTextSanitizer::getInstance();
53
-    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
54
-    echo 'test';
55
-    print_r($result);
56
-    while ($myrow = $xoopsDB->fetchArray($result)) {
57
-        $directory              = array();
58
-        $name                   = $myts->htmlSpecialChars($myrow['name']);
59
-        $directory['dirid']     = $myrow['dirid'];
60
-        $directory['name']      = $name;
61
-        $directory['descr']     = $myrow['descr'];
62
-        $block['directories'][] = $directory;
63
-    }
64
-    $sublink = array();
38
+		//$moddir = $xoopsModule->getvar("dirname");
39
+		$moduleDirName       = basename(dirname(__DIR__));
40
+		$moduleHandler = xoops_getHandler('module');
41
+		$module        = $moduleHandler->getByDirname($moduleDirName);
42
+		$moddir        = $module->getvar('dirname');
43
+	} else {
44
+		$info   = __DIR__;
45
+		$split  = preg_split("#[\]#", $info);
46
+		$count  = count($split) - 2;
47
+		$moddir = $split[$count];
48
+	}
49
+	$block                 = array();
50
+	$block['lang_dirmenu'] = _MB_EFQDIR_MENU;
51
+	$block['moddir']       = $moddir;
52
+	$myts                  = MyTextSanitizer::getInstance();
53
+	$result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
54
+	echo 'test';
55
+	print_r($result);
56
+	while ($myrow = $xoopsDB->fetchArray($result)) {
57
+		$directory              = array();
58
+		$name                   = $myts->htmlSpecialChars($myrow['name']);
59
+		$directory['dirid']     = $myrow['dirid'];
60
+		$directory['name']      = $name;
61
+		$directory['descr']     = $myrow['descr'];
62
+		$block['directories'][] = $directory;
63
+	}
64
+	$sublink = array();
65 65
 
66
-    return $block;
66
+	return $block;
67 67
 }
68 68
 
69 69
 /**
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function b_efqdiralpha1_menu_edit($options)
74 74
 {
75
-    $form = '' . _MB_EFQDIR_DISP . '&nbsp;';
76
-    $form .= "<input type='hidden' name='options[]' value='";
77
-    if ($options[0] === 'date') {
78
-        $form .= "date'";
79
-    } else {
80
-        $form .= "hits'";
81
-    }
82
-    $form .= '>';
83
-    $form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
84
-    $form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
75
+	$form = '' . _MB_EFQDIR_DISP . '&nbsp;';
76
+	$form .= "<input type='hidden' name='options[]' value='";
77
+	if ($options[0] === 'date') {
78
+		$form .= "date'";
79
+	} else {
80
+		$form .= "hits'";
81
+	}
82
+	$form .= '>';
83
+	$form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
84
+	$form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
85 85
 
86
-    return $form;
86
+	return $form;
87 87
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     if (isset($xoopsModule)) {
37 37
 
38 38
         //$moddir = $xoopsModule->getvar("dirname");
39
-        $moduleDirName       = basename(dirname(__DIR__));
39
+        $moduleDirName = basename(dirname(__DIR__));
40 40
         $moduleHandler = xoops_getHandler('module');
41 41
         $module        = $moduleHandler->getByDirname($moduleDirName);
42 42
         $moddir        = $module->getvar('dirname');
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     $block['lang_dirmenu'] = _MB_EFQDIR_MENU;
51 51
     $block['moddir']       = $moddir;
52 52
     $myts                  = MyTextSanitizer::getInstance();
53
-    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
53
+    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM '.$xoopsDB->prefix($module->getVar('dirname', 'n').'_dir')." WHERE open='1' ORDER BY name") or $eh->show('0013');
54 54
     echo 'test';
55 55
     print_r($result);
56 56
     while ($myrow = $xoopsDB->fetchArray($result)) {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function b_efqdiralpha1_menu_edit($options)
74 74
 {
75
-    $form = '' . _MB_EFQDIR_DISP . '&nbsp;';
75
+    $form = ''._MB_EFQDIR_DISP.'&nbsp;';
76 76
     $form .= "<input type='hidden' name='options[]' value='";
77 77
     if ($options[0] === 'date') {
78 78
         $form .= "date'";
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
         $form .= "hits'";
81 81
     }
82 82
     $form .= '>';
83
-    $form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
84
-    $form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
83
+    $form .= "<input type='text' name='options[]' value='".$options[1].'\'>&nbsp;'._MB_EFQDIR_LISTINGS.'';
84
+    $form .= '&nbsp;<br>'._MB_EFQDIR_CHARS."&nbsp;<input type='text' name='options[]' value='".$options[2].'\'>&nbsp;'._MB_EFQDIR_LENGTH.'';
85 85
 
86 86
     return $form;
87 87
 }
Please login to merge, or discard this patch.
upgrade/index.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,17 +9,17 @@
 block discarded – undo
9 9
 xoops_cp_header();
10 10
 set_magic_quotes_runtime(1);
11 11
 if (isset($_POST['submit'])) {
12
-    switch ($_POST['submit']) {
13
-        case 'Update':
14
-            require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
15
-            $dbm = new db_manager;
16
-            $dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
17
-            $feedback = $dbm->report();
18
-            echo $feedback;
19
-            echo "<br><br><a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>Proceed</a>";
20
-            xoops_cp_footer();
21
-            exit();
22
-    }
12
+	switch ($_POST['submit']) {
13
+		case 'Update':
14
+			require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
15
+			$dbm = new db_manager;
16
+			$dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
17
+			$feedback = $dbm->report();
18
+			echo $feedback;
19
+			echo "<br><br><a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>Proceed</a>";
20
+			xoops_cp_footer();
21
+			exit();
22
+	}
23 23
 }
24 24
 require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
25 25
 $upgrade_form = new XoopsThemeForm('Upgrade', 'upgradeform', 'index.php');
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,27 +1,27 @@
 block discarded – undo
1 1
 <?php
2
-include __DIR__ . '/../../../include/cp_header.php';
3
-include __DIR__ . '/../include/functions.php';
2
+include __DIR__.'/../../../include/cp_header.php';
3
+include __DIR__.'/../include/functions.php';
4 4
 
5 5
 $filename = 'upgrade_018-019.sql';
6
-require_once __DIR__ . '/class/efqdir_upgrade.php';
6
+require_once __DIR__.'/class/efqdir_upgrade.php';
7 7
 $moddir = $xoopsModule->getVar('dirname');
8
-require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/language/' . $xoopsConfig['language'] . '/install.php';
8
+require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/upgrade/language/'.$xoopsConfig['language'].'/install.php';
9 9
 xoops_cp_header();
10 10
 set_magic_quotes_runtime(1);
11 11
 if (isset($_POST['submit'])) {
12 12
     switch ($_POST['submit']) {
13 13
         case 'Update':
14
-            require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
14
+            require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/upgrade/class/dbmanager.php';
15 15
             $dbm = new db_manager;
16
-            $dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
16
+            $dbm->queryFromFile(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/sql/'.$filename);
17 17
             $feedback = $dbm->report();
18 18
             echo $feedback;
19
-            echo "<br><br><a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>Proceed</a>";
19
+            echo "<br><br><a href='".XOOPS_URL."/modules/system/admin.php?fct=modulesadmin'>Proceed</a>";
20 20
             xoops_cp_footer();
21 21
             exit();
22 22
     }
23 23
 }
24
-require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
24
+require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
25 25
 $upgrade_form = new XoopsThemeForm('Upgrade', 'upgradeform', 'index.php');
26 26
 $upgrade_form->addElement(new XoopsFormButton(_MU_UPDATE, 'submit', 'Update', 'submit'));
27 27
 $upgrade_form->display();
Please login to merge, or discard this patch.
upgrade/language/english/install.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 define('_INSTALL_L0', 'Welcome to the Install Wizard for XOOPS 2.0');
4 4
 define('_INSTALL_L70',
5
-       'Please change the file permission for mainfile.php so that it is writeable by the server (i.e. chmod 777 mainfile.php on a UNIX/LINUX server, or check the properties of the file and make sure the read-only flag is not set on a Windows server ). Reload this page once you have changed the permission setting.');
5
+	   'Please change the file permission for mainfile.php so that it is writeable by the server (i.e. chmod 777 mainfile.php on a UNIX/LINUX server, or check the properties of the file and make sure the read-only flag is not set on a Windows server ). Reload this page once you have changed the permission setting.');
6 6
 //define("_INSTALL_L71","Click on the button below to begin the installation.");
7 7
 define('_INSTALL_L1', 'Open mainfile.php with your text editor and find the following codes on line 31:');
8 8
 define('_INSTALL_L2', 'Now, change this line to:');
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 define('_INSTALL_L45', 'Table %s created.');
72 72
 
73 73
 define('_INSTALL_L46',
74
-       "In order for the modules included in the package to work correctly, the following files must be writeable by the server. Please change the permission setting for these files. (i.e. 'chmod 666 file_name' and 'chmod 777 dir_name' on a UNIX/LINUX server, or check the properties of the file and make sure the read-only flag is not set on a Windows server)");
74
+	   "In order for the modules included in the package to work correctly, the following files must be writeable by the server. Please change the permission setting for these files. (i.e. 'chmod 666 file_name' and 'chmod 777 dir_name' on a UNIX/LINUX server, or check the properties of the file and make sure the read-only flag is not set on a Windows server)");
75 75
 define('_INSTALL_L47', 'Next');
76 76
 
77 77
 define('_INSTALL_L53', 'Please confirm the following submitted data:');
Please login to merge, or discard this patch.
upgrade/class/dbmanager.php 2 patches
Indentation   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -32,275 +32,275 @@
 block discarded – undo
32 32
  **/
33 33
 class db_manager
34 34
 {
35
-    public $s_tables = array();
36
-    public $f_tables = array();
37
-    public $db;
35
+	public $s_tables = array();
36
+	public $f_tables = array();
37
+	public $db;
38 38
 
39
-    /**
40
-     * db_manager constructor.
41
-     */
42
-    public function __construct()
43
-    {
44
-        $this->db = XoopsDatabaseFactory::getDatabase();
45
-        $this->db->setPrefix(XOOPS_DB_PREFIX);
46
-        $this->db->setLogger(XoopsLogger::instance());
47
-    }
39
+	/**
40
+	 * db_manager constructor.
41
+	 */
42
+	public function __construct()
43
+	{
44
+		$this->db = XoopsDatabaseFactory::getDatabase();
45
+		$this->db->setPrefix(XOOPS_DB_PREFIX);
46
+		$this->db->setLogger(XoopsLogger::instance());
47
+	}
48 48
 
49
-    /**
50
-     * @return bool
51
-     */
52
-    public function isConnectable()
53
-    {
54
-        return ($this->db->connect(false) !== false) ? true : false;
55
-    }
49
+	/**
50
+	 * @return bool
51
+	 */
52
+	public function isConnectable()
53
+	{
54
+		return ($this->db->connect(false) !== false) ? true : false;
55
+	}
56 56
 
57
-    /**
58
-     * @return bool
59
-     */
60
-    public function dbExists()
61
-    {
62
-        return ($this->db->connect() !== false) ? true : false;
63
-    }
57
+	/**
58
+	 * @return bool
59
+	 */
60
+	public function dbExists()
61
+	{
62
+		return ($this->db->connect() !== false) ? true : false;
63
+	}
64 64
 
65
-    /**
66
-     * @return bool
67
-     */
68
-    public function createDB()
69
-    {
70
-        $this->db->connect(false);
65
+	/**
66
+	 * @return bool
67
+	 */
68
+	public function createDB()
69
+	{
70
+		$this->db->connect(false);
71 71
 
72
-        $result = $this->db->query('CREATE DATABASE ' . XOOPS_DB_NAME);
72
+		$result = $this->db->query('CREATE DATABASE ' . XOOPS_DB_NAME);
73 73
 
74
-        return ($result !== false) ? true : false;
75
-    }
74
+		return ($result !== false) ? true : false;
75
+	}
76 76
 
77
-    /**
78
-     * @param $sql_file_path
79
-     * @return bool
80
-     */
81
-    public function queryFromFile($sql_file_path)
82
-    {
83
-        global $pieces;
84
-        $tables = array();
77
+	/**
78
+	 * @param $sql_file_path
79
+	 * @return bool
80
+	 */
81
+	public function queryFromFile($sql_file_path)
82
+	{
83
+		global $pieces;
84
+		$tables = array();
85 85
 
86
-        if (!file_exists($sql_file_path)) {
87
-            return false;
88
-        }
89
-        $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
90
-        SqlUtility::splitMySqlFile($pieces, $sql_query);
91
-        $this->db->connect();
92
-        foreach ($pieces as $piece) {
93
-            $piece = trim($piece);
94
-            // [0] contains the prefixed query
95
-            // [4] contains unprefixed table name
96
-            $prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix());
97
-            if ($prefixed_query !== false) {
98
-                $table = $this->db->prefix($prefixed_query[4]);
99
-                if ($prefixed_query[1] === 'CREATE TABLE') {
100
-                    if ($this->db->query($prefixed_query[0]) !== false) {
101
-                        if (!isset($this->s_tables['create'][$table])) {
102
-                            $this->s_tables['create'][$table] = 1;
103
-                        }
104
-                    } else {
105
-                        if (!isset($this->f_tables['create'][$table])) {
106
-                            $this->f_tables['create'][$table] = 1;
107
-                        }
108
-                    }
109
-                } elseif ($prefixed_query[1] === 'INSERT INTO') {
110
-                    if ($this->db->query($prefixed_query[0]) !== false) {
111
-                        if (!isset($this->s_tables['insert'][$table])) {
112
-                            $this->s_tables['insert'][$table] = 1;
113
-                        } else {
114
-                            $this->s_tables['insert'][$table]++;
115
-                        }
116
-                    } else {
117
-                        if (!isset($this->f_tables['insert'][$table])) {
118
-                            $this->f_tables['insert'][$table] = 1;
119
-                        } else {
120
-                            $this->f_tables['insert'][$table]++;
121
-                        }
122
-                    }
123
-                } elseif ($prefixed_query[1] === 'ALTER TABLE') {
124
-                    if ($this->db->query($prefixed_query[0]) !== false) {
125
-                        if (!isset($this->s_tables['alter'][$table])) {
126
-                            $this->s_tables['alter'][$table] = 1;
127
-                        }
128
-                    } else {
129
-                        if (!isset($this->s_tables['alter'][$table])) {
130
-                            $this->f_tables['alter'][$table] = 1;
131
-                        }
132
-                    }
133
-                } elseif ($prefixed_query[1] === 'DROP TABLE') {
134
-                    if ($this->db->query('DROP TABLE ' . $table) !== false) {
135
-                        if (!isset($this->s_tables['drop'][$table])) {
136
-                            $this->s_tables['drop'][$table] = 1;
137
-                        }
138
-                    } else {
139
-                        if (!isset($this->s_tables['drop'][$table])) {
140
-                            $this->f_tables['drop'][$table] = 1;
141
-                        }
142
-                    }
143
-                }
144
-            }
145
-        }
86
+		if (!file_exists($sql_file_path)) {
87
+			return false;
88
+		}
89
+		$sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
90
+		SqlUtility::splitMySqlFile($pieces, $sql_query);
91
+		$this->db->connect();
92
+		foreach ($pieces as $piece) {
93
+			$piece = trim($piece);
94
+			// [0] contains the prefixed query
95
+			// [4] contains unprefixed table name
96
+			$prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix());
97
+			if ($prefixed_query !== false) {
98
+				$table = $this->db->prefix($prefixed_query[4]);
99
+				if ($prefixed_query[1] === 'CREATE TABLE') {
100
+					if ($this->db->query($prefixed_query[0]) !== false) {
101
+						if (!isset($this->s_tables['create'][$table])) {
102
+							$this->s_tables['create'][$table] = 1;
103
+						}
104
+					} else {
105
+						if (!isset($this->f_tables['create'][$table])) {
106
+							$this->f_tables['create'][$table] = 1;
107
+						}
108
+					}
109
+				} elseif ($prefixed_query[1] === 'INSERT INTO') {
110
+					if ($this->db->query($prefixed_query[0]) !== false) {
111
+						if (!isset($this->s_tables['insert'][$table])) {
112
+							$this->s_tables['insert'][$table] = 1;
113
+						} else {
114
+							$this->s_tables['insert'][$table]++;
115
+						}
116
+					} else {
117
+						if (!isset($this->f_tables['insert'][$table])) {
118
+							$this->f_tables['insert'][$table] = 1;
119
+						} else {
120
+							$this->f_tables['insert'][$table]++;
121
+						}
122
+					}
123
+				} elseif ($prefixed_query[1] === 'ALTER TABLE') {
124
+					if ($this->db->query($prefixed_query[0]) !== false) {
125
+						if (!isset($this->s_tables['alter'][$table])) {
126
+							$this->s_tables['alter'][$table] = 1;
127
+						}
128
+					} else {
129
+						if (!isset($this->s_tables['alter'][$table])) {
130
+							$this->f_tables['alter'][$table] = 1;
131
+						}
132
+					}
133
+				} elseif ($prefixed_query[1] === 'DROP TABLE') {
134
+					if ($this->db->query('DROP TABLE ' . $table) !== false) {
135
+						if (!isset($this->s_tables['drop'][$table])) {
136
+							$this->s_tables['drop'][$table] = 1;
137
+						}
138
+					} else {
139
+						if (!isset($this->s_tables['drop'][$table])) {
140
+							$this->f_tables['drop'][$table] = 1;
141
+						}
142
+					}
143
+				}
144
+			}
145
+		}
146 146
 
147
-        return true;
148
-    }
147
+		return true;
148
+	}
149 149
 
150
-    /**
151
-     * @return string
152
-     */
153
-    public function report()
154
-    {
155
-        $content = "<table align='center'><tr><td align='left'>\n";
156
-        if (isset($this->s_tables['create'])) {
157
-            foreach ($this->s_tables['create'] as $key => $val) {
158
-                $content .= sprintf(_INSTALL_L45, "<b>$key</b>") . "<br>\n";
159
-            }
160
-        }
161
-        if (isset($this->s_tables['insert'])) {
162
-            foreach ($this->s_tables['insert'] as $key => $val) {
163
-                $content .= sprintf(_INSTALL_L119, $val, "<b>$key</b>") . "<br>\n";
164
-            }
165
-        }
166
-        if (isset($this->s_tables['alter'])) {
167
-            foreach ($this->s_tables['alter'] as $key => $val) {
168
-                $content .= sprintf(_INSTALL_L133, "<b>$key</b>") . "<br>\n";
169
-            }
170
-        }
171
-        if (isset($this->s_tables['drop'])) {
172
-            foreach ($this->s_tables['drop'] as $key => $val) {
173
-                $content .= sprintf(_INSTALL_L163, "<b>$key</b>") . "<br>\n";
174
-            }
175
-        }
176
-        $content .= "<br>\n";
177
-        if (isset($this->f_tables['create'])) {
178
-            foreach ($this->f_tables['create'] as $key => $val) {
179
-                $content .= sprintf(_INSTALL_L118, "<b>$key</b>") . "<br>\n";
180
-            }
181
-        }
182
-        if (isset($this->f_tables['insert'])) {
183
-            foreach ($this->f_tables['insert'] as $key => $val) {
184
-                $content .= sprintf(_INSTALL_L120, $val, "<b>$key</b>") . "<br>\n";
185
-            }
186
-        }
187
-        if (isset($this->f_tables['alter'])) {
188
-            foreach ($this->f_tables['alter'] as $key => $val) {
189
-                $content .= sprintf(_INSTALL_L134, "<b>$key</b>") . "<br>\n";
190
-            }
191
-        }
192
-        if (isset($this->f_tables['drop'])) {
193
-            foreach ($this->f_tables['drop'] as $key => $val) {
194
-                $content .= sprintf(_INSTALL_L164, "<b>$key</b>") . "<br>\n";
195
-            }
196
-        }
197
-        $content .= "</td></tr></table>\n";
150
+	/**
151
+	 * @return string
152
+	 */
153
+	public function report()
154
+	{
155
+		$content = "<table align='center'><tr><td align='left'>\n";
156
+		if (isset($this->s_tables['create'])) {
157
+			foreach ($this->s_tables['create'] as $key => $val) {
158
+				$content .= sprintf(_INSTALL_L45, "<b>$key</b>") . "<br>\n";
159
+			}
160
+		}
161
+		if (isset($this->s_tables['insert'])) {
162
+			foreach ($this->s_tables['insert'] as $key => $val) {
163
+				$content .= sprintf(_INSTALL_L119, $val, "<b>$key</b>") . "<br>\n";
164
+			}
165
+		}
166
+		if (isset($this->s_tables['alter'])) {
167
+			foreach ($this->s_tables['alter'] as $key => $val) {
168
+				$content .= sprintf(_INSTALL_L133, "<b>$key</b>") . "<br>\n";
169
+			}
170
+		}
171
+		if (isset($this->s_tables['drop'])) {
172
+			foreach ($this->s_tables['drop'] as $key => $val) {
173
+				$content .= sprintf(_INSTALL_L163, "<b>$key</b>") . "<br>\n";
174
+			}
175
+		}
176
+		$content .= "<br>\n";
177
+		if (isset($this->f_tables['create'])) {
178
+			foreach ($this->f_tables['create'] as $key => $val) {
179
+				$content .= sprintf(_INSTALL_L118, "<b>$key</b>") . "<br>\n";
180
+			}
181
+		}
182
+		if (isset($this->f_tables['insert'])) {
183
+			foreach ($this->f_tables['insert'] as $key => $val) {
184
+				$content .= sprintf(_INSTALL_L120, $val, "<b>$key</b>") . "<br>\n";
185
+			}
186
+		}
187
+		if (isset($this->f_tables['alter'])) {
188
+			foreach ($this->f_tables['alter'] as $key => $val) {
189
+				$content .= sprintf(_INSTALL_L134, "<b>$key</b>") . "<br>\n";
190
+			}
191
+		}
192
+		if (isset($this->f_tables['drop'])) {
193
+			foreach ($this->f_tables['drop'] as $key => $val) {
194
+				$content .= sprintf(_INSTALL_L164, "<b>$key</b>") . "<br>\n";
195
+			}
196
+		}
197
+		$content .= "</td></tr></table>\n";
198 198
 
199
-        return $content;
200
-    }
199
+		return $content;
200
+	}
201 201
 
202
-    /**
203
-     * @param $sql
204
-     * @return mixed
205
-     */
206
-    public function query($sql)
207
-    {
208
-        $this->db->connect();
202
+	/**
203
+	 * @param $sql
204
+	 * @return mixed
205
+	 */
206
+	public function query($sql)
207
+	{
208
+		$this->db->connect();
209 209
 
210
-        return $this->db->query($sql);
211
-    }
210
+		return $this->db->query($sql);
211
+	}
212 212
 
213
-    /**
214
-     * @param $table
215
-     * @return mixed
216
-     */
217
-    public function prefix($table)
218
-    {
219
-        $this->db->connect();
213
+	/**
214
+	 * @param $table
215
+	 * @return mixed
216
+	 */
217
+	public function prefix($table)
218
+	{
219
+		$this->db->connect();
220 220
 
221
-        return $this->db->prefix($table);
222
-    }
221
+		return $this->db->prefix($table);
222
+	}
223 223
 
224
-    /**
225
-     * @param $ret
226
-     * @return mixed
227
-     */
228
-    public function fetchArray($ret)
229
-    {
230
-        $this->db->connect();
224
+	/**
225
+	 * @param $ret
226
+	 * @return mixed
227
+	 */
228
+	public function fetchArray($ret)
229
+	{
230
+		$this->db->connect();
231 231
 
232
-        return $this->db->fetchArray($ret);
233
-    }
232
+		return $this->db->fetchArray($ret);
233
+	}
234 234
 
235
-    /**
236
-     * @param $table
237
-     * @param $query
238
-     * @return bool
239
-     */
240
-    public function insert($table, $query)
241
-    {
242
-        $this->db->connect();
243
-        $table = $this->db->prefix($table);
244
-        $query = 'INSERT INTO ' . $table . ' ' . $query;
245
-        if (!$this->db->queryF($query)) {
246
-            if (!isset($this->f_tables['insert'][$table])) {
247
-                $this->f_tables['insert'][$table] = 1;
248
-            } else {
249
-                $this->f_tables['insert'][$table]++;
250
-            }
235
+	/**
236
+	 * @param $table
237
+	 * @param $query
238
+	 * @return bool
239
+	 */
240
+	public function insert($table, $query)
241
+	{
242
+		$this->db->connect();
243
+		$table = $this->db->prefix($table);
244
+		$query = 'INSERT INTO ' . $table . ' ' . $query;
245
+		if (!$this->db->queryF($query)) {
246
+			if (!isset($this->f_tables['insert'][$table])) {
247
+				$this->f_tables['insert'][$table] = 1;
248
+			} else {
249
+				$this->f_tables['insert'][$table]++;
250
+			}
251 251
 
252
-            return false;
253
-        } else {
254
-            if (!isset($this->s_tables['insert'][$table])) {
255
-                $this->s_tables['insert'][$table] = 1;
256
-            } else {
257
-                $this->s_tables['insert'][$table]++;
258
-            }
252
+			return false;
253
+		} else {
254
+			if (!isset($this->s_tables['insert'][$table])) {
255
+				$this->s_tables['insert'][$table] = 1;
256
+			} else {
257
+				$this->s_tables['insert'][$table]++;
258
+			}
259 259
 
260
-            return $this->db->getInsertId();
261
-        }
262
-    }
260
+			return $this->db->getInsertId();
261
+		}
262
+	}
263 263
 
264
-    /**
265
-     * @return bool
266
-     */
267
-    public function isError()
268
-    {
269
-        return isset($this->f_tables) ? true : false;
270
-    }
264
+	/**
265
+	 * @return bool
266
+	 */
267
+	public function isError()
268
+	{
269
+		return isset($this->f_tables) ? true : false;
270
+	}
271 271
 
272
-    /**
273
-     * @param $tables
274
-     * @return array
275
-     */
276
-    public function deleteTables($tables)
277
-    {
278
-        global $ct;
279
-        $deleted = array();
280
-        $this->db->connect();
281
-        foreach ($tables as $key => $val) {
282
-            if (!$this->db->query('DROP TABLE ' . $this->db->prefix($key))) {
283
-                $deleted[] = $ct;
284
-            }
285
-        }
272
+	/**
273
+	 * @param $tables
274
+	 * @return array
275
+	 */
276
+	public function deleteTables($tables)
277
+	{
278
+		global $ct;
279
+		$deleted = array();
280
+		$this->db->connect();
281
+		foreach ($tables as $key => $val) {
282
+			if (!$this->db->query('DROP TABLE ' . $this->db->prefix($key))) {
283
+				$deleted[] = $ct;
284
+			}
285
+		}
286 286
 
287
-        return $deleted;
288
-    }
287
+		return $deleted;
288
+	}
289 289
 
290
-    /**
291
-     * @param $table
292
-     * @return bool
293
-     */
294
-    public function tableExists($table)
295
-    {
296
-        $table = trim($table);
297
-        $ret   = false;
298
-        if ($table !== '') {
299
-            $this->db->connect();
300
-            $sql = 'SELECT * FROM ' . $this->db->prefix($table);
301
-            $ret = (false != $this->db->query($sql)) ? true : false;
302
-        }
290
+	/**
291
+	 * @param $table
292
+	 * @return bool
293
+	 */
294
+	public function tableExists($table)
295
+	{
296
+		$table = trim($table);
297
+		$ret   = false;
298
+		if ($table !== '') {
299
+			$this->db->connect();
300
+			$sql = 'SELECT * FROM ' . $this->db->prefix($table);
301
+			$ret = (false != $this->db->query($sql)) ? true : false;
302
+		}
303 303
 
304
-        return $ret;
305
-    }
304
+		return $ret;
305
+	}
306 306
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
  * @author       XOOPS Development Team,
19 19
  */
20 20
 
21
-require_once XOOPS_ROOT_PATH . '/class/logger.php';
22
-require_once XOOPS_ROOT_PATH . '/class/database/databasefactory.php';
23
-require_once XOOPS_ROOT_PATH . '/class/database/' . XOOPS_DB_TYPE . 'database.php';
24
-require_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php';
21
+require_once XOOPS_ROOT_PATH.'/class/logger.php';
22
+require_once XOOPS_ROOT_PATH.'/class/database/databasefactory.php';
23
+require_once XOOPS_ROOT_PATH.'/class/database/'.XOOPS_DB_TYPE.'database.php';
24
+require_once XOOPS_ROOT_PATH.'/class/database/sqlutility.php';
25 25
 
26 26
 /**
27 27
  * database manager for XOOPS installer
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         $this->db->connect(false);
71 71
 
72
-        $result = $this->db->query('CREATE DATABASE ' . XOOPS_DB_NAME);
72
+        $result = $this->db->query('CREATE DATABASE '.XOOPS_DB_NAME);
73 73
 
74 74
         return ($result !== false) ? true : false;
75 75
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                         }
132 132
                     }
133 133
                 } elseif ($prefixed_query[1] === 'DROP TABLE') {
134
-                    if ($this->db->query('DROP TABLE ' . $table) !== false) {
134
+                    if ($this->db->query('DROP TABLE '.$table) !== false) {
135 135
                         if (!isset($this->s_tables['drop'][$table])) {
136 136
                             $this->s_tables['drop'][$table] = 1;
137 137
                         }
@@ -155,43 +155,43 @@  discard block
 block discarded – undo
155 155
         $content = "<table align='center'><tr><td align='left'>\n";
156 156
         if (isset($this->s_tables['create'])) {
157 157
             foreach ($this->s_tables['create'] as $key => $val) {
158
-                $content .= sprintf(_INSTALL_L45, "<b>$key</b>") . "<br>\n";
158
+                $content .= sprintf(_INSTALL_L45, "<b>$key</b>")."<br>\n";
159 159
             }
160 160
         }
161 161
         if (isset($this->s_tables['insert'])) {
162 162
             foreach ($this->s_tables['insert'] as $key => $val) {
163
-                $content .= sprintf(_INSTALL_L119, $val, "<b>$key</b>") . "<br>\n";
163
+                $content .= sprintf(_INSTALL_L119, $val, "<b>$key</b>")."<br>\n";
164 164
             }
165 165
         }
166 166
         if (isset($this->s_tables['alter'])) {
167 167
             foreach ($this->s_tables['alter'] as $key => $val) {
168
-                $content .= sprintf(_INSTALL_L133, "<b>$key</b>") . "<br>\n";
168
+                $content .= sprintf(_INSTALL_L133, "<b>$key</b>")."<br>\n";
169 169
             }
170 170
         }
171 171
         if (isset($this->s_tables['drop'])) {
172 172
             foreach ($this->s_tables['drop'] as $key => $val) {
173
-                $content .= sprintf(_INSTALL_L163, "<b>$key</b>") . "<br>\n";
173
+                $content .= sprintf(_INSTALL_L163, "<b>$key</b>")."<br>\n";
174 174
             }
175 175
         }
176 176
         $content .= "<br>\n";
177 177
         if (isset($this->f_tables['create'])) {
178 178
             foreach ($this->f_tables['create'] as $key => $val) {
179
-                $content .= sprintf(_INSTALL_L118, "<b>$key</b>") . "<br>\n";
179
+                $content .= sprintf(_INSTALL_L118, "<b>$key</b>")."<br>\n";
180 180
             }
181 181
         }
182 182
         if (isset($this->f_tables['insert'])) {
183 183
             foreach ($this->f_tables['insert'] as $key => $val) {
184
-                $content .= sprintf(_INSTALL_L120, $val, "<b>$key</b>") . "<br>\n";
184
+                $content .= sprintf(_INSTALL_L120, $val, "<b>$key</b>")."<br>\n";
185 185
             }
186 186
         }
187 187
         if (isset($this->f_tables['alter'])) {
188 188
             foreach ($this->f_tables['alter'] as $key => $val) {
189
-                $content .= sprintf(_INSTALL_L134, "<b>$key</b>") . "<br>\n";
189
+                $content .= sprintf(_INSTALL_L134, "<b>$key</b>")."<br>\n";
190 190
             }
191 191
         }
192 192
         if (isset($this->f_tables['drop'])) {
193 193
             foreach ($this->f_tables['drop'] as $key => $val) {
194
-                $content .= sprintf(_INSTALL_L164, "<b>$key</b>") . "<br>\n";
194
+                $content .= sprintf(_INSTALL_L164, "<b>$key</b>")."<br>\n";
195 195
             }
196 196
         }
197 197
         $content .= "</td></tr></table>\n";
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
     {
242 242
         $this->db->connect();
243 243
         $table = $this->db->prefix($table);
244
-        $query = 'INSERT INTO ' . $table . ' ' . $query;
244
+        $query = 'INSERT INTO '.$table.' '.$query;
245 245
         if (!$this->db->queryF($query)) {
246 246
             if (!isset($this->f_tables['insert'][$table])) {
247 247
                 $this->f_tables['insert'][$table] = 1;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         $deleted = array();
280 280
         $this->db->connect();
281 281
         foreach ($tables as $key => $val) {
282
-            if (!$this->db->query('DROP TABLE ' . $this->db->prefix($key))) {
282
+            if (!$this->db->query('DROP TABLE '.$this->db->prefix($key))) {
283 283
                 $deleted[] = $ct;
284 284
             }
285 285
         }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $ret   = false;
298 298
         if ($table !== '') {
299 299
             $this->db->connect();
300
-            $sql = 'SELECT * FROM ' . $this->db->prefix($table);
300
+            $sql = 'SELECT * FROM '.$this->db->prefix($table);
301 301
             $ret = (false != $this->db->query($sql)) ? true : false;
302 302
         }
303 303
 
Please login to merge, or discard this patch.
upgrade/class/efqdir_upgrade.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,18 +19,18 @@
 block discarded – undo
19 19
  */
20 20
 class EfqDirUpgrade
21 21
 {
22
-    /**
23
-     * @param string $filename
24
-     * @return string
25
-     */
26
-    public function prepare2upgrade($filename = '')
27
-    {
28
-        global $moddir, $xoopsConfig;
29
-        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
30
-        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/language/' . $xoopsConfig['language'] . '/install.php';
31
-        $dbm = new db_manager;
32
-        $dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
22
+	/**
23
+	 * @param string $filename
24
+	 * @return string
25
+	 */
26
+	public function prepare2upgrade($filename = '')
27
+	{
28
+		global $moddir, $xoopsConfig;
29
+		require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
30
+		require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/language/' . $xoopsConfig['language'] . '/install.php';
31
+		$dbm = new db_manager;
32
+		$dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
33 33
 
34
-        return $dbm->report();
35
-    }
34
+		return $dbm->report();
35
+	}
36 36
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
     public function prepare2upgrade($filename = '')
27 27
     {
28 28
         global $moddir, $xoopsConfig;
29
-        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/class/dbmanager.php';
30
-        require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/upgrade/language/' . $xoopsConfig['language'] . '/install.php';
29
+        require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/upgrade/class/dbmanager.php';
30
+        require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/upgrade/language/'.$xoopsConfig['language'].'/install.php';
31 31
         $dbm = new db_manager;
32
-        $dbm->queryFromFile(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/sql/' . $filename);
32
+        $dbm->queryFromFile(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/sql/'.$filename);
33 33
 
34 34
         return $dbm->report();
35 35
     }
Please login to merge, or discard this patch.