Made sure all SMF settings are prefixed with smf_
Jeremy D

Jeremy D commited on 2012-01-23 18:43:00
Showing 3 changed files, with 34 additions and 18 deletions.

... ...
@@ -99,7 +99,7 @@ class pB
99 99
 		$this->loadGeshi();
100 100
 
101 101
 		// At this point we are ready to go.
102
-		if (pBS::get('use_smf_theme'))
102
+		if (pBS::get('smf_use_theme'))
103 103
 			echo '
104 104
 			<div id="paste_recent" class="alignright">', $this->showRecent(), '</div>';
105 105
 	}
... ...
@@ -152,6 +152,16 @@ class pB
152 152
 		$this->geshi_languages = $languages;
153 153
 	}
154 154
 
155
+	/*
156
+	* Handle a fatal Error
157
+	*/
158
+	public function error($msg)
159
+	{
160
+		// For now.
161
+		debug_print_backtrace();
162
+		exit($msg);
163
+	}
164
+
155 165
 	/*
156 166
 	* Format a URL
157 167
 	* @param $act string The action we want to use
... ...
@@ -222,11 +232,11 @@ class pB
222 232
 
223 233
 		// Trying to save this paste?
224 234
 		if (isset($_POST['save']))
225
-			$errors = $this->makePaste(0);
235
+			$warnings = $this->makePaste(0);
226 236
 
227 237
 		// Show any errors
228
-		if (!empty($errors))
229
-			echo '<div class="error_message">', implode('<br />', $errors), '</div>';
238
+		if (!empty($warnings))
239
+			echo '<div class="error_message">', implode('<br />', $warnings), '</div>';
230 240
 
231 241
 		$this->postForm((!empty($_POST['code']) ? $_POST['code'] : ''));
232 242
 	}
... ...
@@ -284,7 +294,7 @@ class pB
284 294
 
285 295
 		if (!$do_create)
286 296
 		{
287
-			$this->errors[] = 'Missing information (Username/email)';
297
+			$this->warningss[] = 'Missing information (Username/email)';
288 298
 
289 299
 			if (!empty($_POST['view']))
290 300
 				$this->action_view($_POST['view']);
... ...
@@ -446,9 +456,11 @@ class pB
446 456
 		// Get it from the database.
447 457
 		$paste = $this->db->fetchPaste($id);
448 458
 
449
-		if (!$this->usr->is_admin() && !empty($Paste['key']) && (empty($_REQUEST['key']) || $Paste['key'] != $_REQUEST['key']))
450
-			$this->error(pBL('error_no_access'), true);
451
-		elseif ($paste['board_id'] != pBS::get('paste_board'))
459
+		// The fetch threw an error.
460
+		if (isset($paste['error']))
461
+			$this->error($paste['error'], !empty($paste['fatal']) ? true : false);
462
+
463
+		if (!$this->usr->is_admin() && !empty($paste['key']) && (empty($_REQUEST['key']) || $paste['key'] != $_REQUEST['key']))
452 464
 			$this->error(pBL('error_no_access'), true);
453 465
 		elseif (empty($paste['approved']))
454 466
 			$this->error(pBL('error_approval'), true);
... ...
@@ -23,10 +23,10 @@ class pBS
23 23
 
24 24
 	// Where SMF is at.
25 25
 	private static $smf_dir = '../forum/';
26
-	private static $paste_board = 4;
27
-	private static $increase_postcout = true;
28
-	private static $enable_post_approval = false;
29
-	private static $use_smf_theme = false	;
26
+	private static $smf_paste_board = 4;
27
+	private static $smf_increase_postcout = true;
28
+	private static $smf_post_approval = false;
29
+	private static $smf_use_theme = false	;
30 30
 	private static $smf_theme_id = 1;
31 31
 
32 32
 	// The URLs
... ...
@@ -24,7 +24,7 @@ class pDB_smf extends pDB
24 24
 			$_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);
25 25
 
26 26
 		// We need to setup this before we continue
27
-		if (pBS::get('use_smf_theme'))
27
+		if (pBS::get('smf_use_theme'))
28 28
 		{
29 29
 			$ssi_theme = pBS::get('smf_theme_id');
30 30
 			$ssi_layers = array('html', 'body');
... ...
@@ -47,7 +47,7 @@ class pDB_smf extends pDB
47 47
 			ORDER BY id_last_msg DESC
48 48
 			LIMIT {int:limit_recent}',
49 49
 			array(
50
-				'paste_board' => pBS::get('paste_board'),
50
+				'paste_board' => pBS::get('smf_paste_board'),
51 51
 				'limit_recent' => $limit,
52 52
 				));
53 53
 
... ...
@@ -73,12 +73,16 @@ class pDB_smf extends pDB
73 73
 			AND id_board = {int:paste_board}
74 74
 			ORDER BY poster_time DESC',
75 75
 			array(
76
-				'paste_board' => pBS::get('paste_board'),
76
+				'paste_board' => pBS::get('smf_paste_board'),
77 77
 				'id_topic' => $id,
78 78
 				));
79 79
 		$topic = smcFunc::db_fetch_assoc($request);
80 80
 		smcFunc::db_free_result($request);
81 81
 
82
+		// Need to check their access.
83
+		if ($topic['board_id'] != pBS::get('smf_paste_board'))
84
+			return array('error' => pBL('error_no_access'));
85
+
82 86
 		$ops = explode(':v:', $topic['subject']);
83 87
 		unset($ops[0]);
84 88
 
... ...
@@ -146,7 +150,7 @@ class pDB_smf extends pDB
146 150
 		// Options needed for our post.
147 151
 		$topicOptions = array(
148 152
 			'id'		=> (!empty($paste['id']) ? $topic['id'] : 0) ,
149
-			'board'		=> pBS::get('paste_board'),
153
+			'board'		=> pBS::get('smf_paste_board'),
150 154
 			'mark_as_read'	=> false,
151 155
 			);
152 156
 		$posterOptions = array(
... ...
@@ -154,13 +158,13 @@ class pDB_smf extends pDB
154 158
 			'name'		=> $data['name'],
155 159
 			'email'		=> $data['email'],
156 160
 			'ip'		=> userInfo::_()->ip,
157
-			'update_post_count'	=> (pBS::get('increase_postcout') && isset(userInfo::_()->id) ? 1 : 0),
161
+			'update_post_count'	=> (pBS::get('smf_increase_postcout') && isset(userInfo::_()->id) ? 1 : 0),
158 162
 			);
159 163
 		$msgOptions = array(
160 164
 			'id'		=> 0,
161 165
 			'subject'	=> 'Paste-' . time() . ':v:use_geshi-' . (!empty($data['use_geshi']) ? 1 : 0) . ':v:type-' . (!empty($data['language']) ? $data['language'] : 'php') . (!empty($data['key']) ? ':v:p-' . $data['key'] : ''),
162 166
 			'body'		=> htmlspecialchars($data['body']),
163
-			'approved'	=> pBS::get('enable_post_approval') ? 0 : 1,
167
+			'approved'	=> pBS::get('smf_post_approval') ? 0 : 1,
164 168
 			);
165 169
 
166 170
 		// Actually create the paste.
167 171