Passed
Pull Request — master (#5)
by Cody
03:17
created
classes/pref/labels.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -1,286 +1,286 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Labels extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("index", "getlabeltree", "edit");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("index", "getlabeltree", "edit");
6 6
 
7
-		return array_search($method, $csrf_ignored) !== false;
8
-	}
7
+        return array_search($method, $csrf_ignored) !== false;
8
+    }
9 9
 
10
-	public function edit() {
11
-		$label_id = clean($_REQUEST['id']);
10
+    public function edit() {
11
+        $label_id = clean($_REQUEST['id']);
12 12
 
13
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
13
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
14 14
 			id = ? AND owner_uid = ?");
15
-		$sth->execute([$label_id, $_SESSION['uid']]);
15
+        $sth->execute([$label_id, $_SESSION['uid']]);
16 16
 
17
-		if ($line = $sth->fetch()) {
17
+        if ($line = $sth->fetch()) {
18 18
 
19
-			print_hidden("id", "$label_id");
20
-			print_hidden("op", "pref-labels");
21
-			print_hidden("method", "save");
19
+            print_hidden("id", "$label_id");
20
+            print_hidden("op", "pref-labels");
21
+            print_hidden("method", "save");
22 22
 
23
-			print "<form onsubmit='return false;'>";
23
+            print "<form onsubmit='return false;'>";
24 24
 
25
-			print "<header>".__("Caption")."</header>";
25
+            print "<header>".__("Caption")."</header>";
26 26
 
27
-			print "<section>";
27
+            print "<section>";
28 28
 
29
-			$fg_color = $line['fg_color'];
30
-			$bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5';
29
+            $fg_color = $line['fg_color'];
30
+            $bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5';
31 31
 
32
-			print "<input style='font-size : 16px; color : $fg_color; background : $bg_color; transition : background 0.1s linear'
32
+            print "<input style='font-size : 16px; color : $fg_color; background : $bg_color; transition : background 0.1s linear'
33 33
 				id='labelEdit_caption' name='caption' dojoType='dijit.form.ValidationTextBox'
34 34
 				required='true' value=\"".htmlspecialchars($line['caption'])."\">";
35 35
 
36
-			print "</section>";
36
+            print "</section>";
37 37
 
38
-			print "<header>" . __("Colors") . "</header>";
39
-			print "<section>";
38
+            print "<header>" . __("Colors") . "</header>";
39
+            print "<section>";
40 40
 
41
-			print "<table>";
42
-			print "<tr><th style='text-align : left'>".__("Foreground:")."</th><th style='text-align : left'>".__("Background:")."</th></tr>";
43
-			print "<tr><td style='padding-right : 10px'>";
41
+            print "<table>";
42
+            print "<tr><th style='text-align : left'>".__("Foreground:")."</th><th style='text-align : left'>".__("Background:")."</th></tr>";
43
+            print "<tr><td style='padding-right : 10px'>";
44 44
 
45
-			print "<input dojoType='dijit.form.TextBox'
45
+            print "<input dojoType='dijit.form.TextBox'
46 46
 				style='display : none' id='labelEdit_fgColor'
47 47
 				name='fg_color' value='$fg_color'>";
48
-			print "<input dojoType='dijit.form.TextBox'
48
+            print "<input dojoType='dijit.form.TextBox'
49 49
 				style='display : none' id='labelEdit_bgColor'
50 50
 				name='bg_color' value='$bg_color'>";
51 51
 
52
-			print "<div dojoType='dijit.ColorPalette'>
52
+            print "<div dojoType='dijit.ColorPalette'>
53 53
 			<script type='dojo/method' event='onChange' args='fg_color'>
54 54
 				dijit.byId('labelEdit_fgColor').attr('value', fg_color);
55 55
 				dijit.byId('labelEdit_caption').domNode.setStyle({color: fg_color});
56 56
 			</script>
57 57
 			</div>";
58 58
 
59
-			print "</td><td>";
59
+            print "</td><td>";
60 60
 
61
-			print "<div dojoType='dijit.ColorPalette'>
61
+            print "<div dojoType='dijit.ColorPalette'>
62 62
 			<script type='dojo/method' event='onChange' args='bg_color'>
63 63
 				dijit.byId('labelEdit_bgColor').attr('value', bg_color);
64 64
 				dijit.byId('labelEdit_caption').domNode.setStyle({backgroundColor: bg_color});
65 65
 			</script>
66 66
 			</div>";
67 67
 
68
-			print "</td></tr></table>";
69
-			print "</section>";
68
+            print "</td></tr></table>";
69
+            print "</section>";
70 70
 
71
-			print "<footer>";
72
-			print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('labelEditDlg').execute()\">".
73
-				__('Save')."</button>";
74
-			print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('labelEditDlg').hide()\">".
75
-				__('Cancel')."</button>";
76
-			print "</footer>";
71
+            print "<footer>";
72
+            print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('labelEditDlg').execute()\">".
73
+                __('Save')."</button>";
74
+            print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('labelEditDlg').hide()\">".
75
+                __('Cancel')."</button>";
76
+            print "</footer>";
77 77
 
78
-			print "</form>";
79
-		}
80
-	}
78
+            print "</form>";
79
+        }
80
+    }
81 81
 
82
-	public function getlabeltree() {
83
-		$root = array();
84
-		$root['id'] = 'root';
85
-		$root['name'] = __('Labels');
86
-		$root['items'] = array();
82
+    public function getlabeltree() {
83
+        $root = array();
84
+        $root['id'] = 'root';
85
+        $root['name'] = __('Labels');
86
+        $root['items'] = array();
87 87
 
88
-		$sth = $this->pdo->prepare("SELECT *
88
+        $sth = $this->pdo->prepare("SELECT *
89 89
 			FROM ttrss_labels2
90 90
 			WHERE owner_uid = ?
91 91
 			ORDER BY caption");
92
-		$sth->execute([$_SESSION['uid']]);
93
-
94
-		while ($line = $sth->fetch()) {
95
-			$label = array();
96
-			$label['id'] = 'LABEL:' . $line['id'];
97
-			$label['bare_id'] = $line['id'];
98
-			$label['name'] = $line['caption'];
99
-			$label['fg_color'] = $line['fg_color'];
100
-			$label['bg_color'] = $line['bg_color'];
101
-			$label['type'] = 'label';
102
-			$label['checkbox'] = false;
103
-
104
-			array_push($root['items'], $label);
105
-		}
106
-
107
-		$fl = array();
108
-		$fl['identifier'] = 'id';
109
-		$fl['label'] = 'name';
110
-		$fl['items'] = array($root);
111
-
112
-		print json_encode($fl);
113
-		return;
114
-	}
115
-
116
-	public function colorset() {
117
-		$kind = clean($_REQUEST["kind"]);
118
-		$ids = explode(',', clean($_REQUEST["ids"]));
119
-		$color = clean($_REQUEST["color"]);
120
-		$fg = clean($_REQUEST["fg"]);
121
-		$bg = clean($_REQUEST["bg"]);
122
-
123
-		foreach ($ids as $id) {
124
-
125
-			if ($kind == "fg" || $kind == "bg") {
126
-				$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
92
+        $sth->execute([$_SESSION['uid']]);
93
+
94
+        while ($line = $sth->fetch()) {
95
+            $label = array();
96
+            $label['id'] = 'LABEL:' . $line['id'];
97
+            $label['bare_id'] = $line['id'];
98
+            $label['name'] = $line['caption'];
99
+            $label['fg_color'] = $line['fg_color'];
100
+            $label['bg_color'] = $line['bg_color'];
101
+            $label['type'] = 'label';
102
+            $label['checkbox'] = false;
103
+
104
+            array_push($root['items'], $label);
105
+        }
106
+
107
+        $fl = array();
108
+        $fl['identifier'] = 'id';
109
+        $fl['label'] = 'name';
110
+        $fl['items'] = array($root);
111
+
112
+        print json_encode($fl);
113
+        return;
114
+    }
115
+
116
+    public function colorset() {
117
+        $kind = clean($_REQUEST["kind"]);
118
+        $ids = explode(',', clean($_REQUEST["ids"]));
119
+        $color = clean($_REQUEST["color"]);
120
+        $fg = clean($_REQUEST["fg"]);
121
+        $bg = clean($_REQUEST["bg"]);
122
+
123
+        foreach ($ids as $id) {
124
+
125
+            if ($kind == "fg" || $kind == "bg") {
126
+                $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
127 127
 					${kind}_color = ? WHERE id = ?
128 128
 					AND owner_uid = ?");
129 129
 
130
-				$sth->execute([$color, $id, $_SESSION['uid']]);
130
+                $sth->execute([$color, $id, $_SESSION['uid']]);
131 131
 
132
-			} else {
132
+            } else {
133 133
 
134
-				$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
134
+                $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
135 135
 					fg_color = ?, bg_color = ? WHERE id = ?
136 136
 					AND owner_uid = ?");
137 137
 
138
-				$sth->execute([$fg, $bg, $id, $_SESSION['uid']]);
139
-			}
138
+                $sth->execute([$fg, $bg, $id, $_SESSION['uid']]);
139
+            }
140 140
 
141
-			/* Remove cached data */
141
+            /* Remove cached data */
142 142
 
143
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
143
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
144 144
 				WHERE owner_uid = ?");
145
-			$sth->execute([$_SESSION['uid']]);
146
-		}
147
-	}
145
+            $sth->execute([$_SESSION['uid']]);
146
+        }
147
+    }
148 148
 
149
-	public function colorreset() {
150
-		$ids = explode(',', clean($_REQUEST["ids"]));
149
+    public function colorreset() {
150
+        $ids = explode(',', clean($_REQUEST["ids"]));
151 151
 
152
-		foreach ($ids as $id) {
153
-			$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
152
+        foreach ($ids as $id) {
153
+            $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
154 154
 				fg_color = '', bg_color = '' WHERE id = ?
155 155
 				AND owner_uid = ?");
156
-			$sth->execute([$id, $_SESSION['uid']]);
156
+            $sth->execute([$id, $_SESSION['uid']]);
157 157
 
158
-			/* Remove cached data */
158
+            /* Remove cached data */
159 159
 
160
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
160
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
161 161
 				WHERE owner_uid = ?");
162
-			$sth->execute([$_SESSION['uid']]);
163
-		}
164
-	}
162
+            $sth->execute([$_SESSION['uid']]);
163
+        }
164
+    }
165 165
 
166
-	public function save() {
166
+    public function save() {
167 167
 
168
-		$id = clean($_REQUEST["id"]);
169
-		$caption = trim(clean($_REQUEST["caption"]));
168
+        $id = clean($_REQUEST["id"]);
169
+        $caption = trim(clean($_REQUEST["caption"]));
170 170
 
171
-		$this->pdo->beginTransaction();
171
+        $this->pdo->beginTransaction();
172 172
 
173
-		$sth = $this->pdo->prepare("SELECT caption FROM ttrss_labels2
173
+        $sth = $this->pdo->prepare("SELECT caption FROM ttrss_labels2
174 174
 			WHERE id = ? AND owner_uid = ?");
175
-		$sth->execute([$id, $_SESSION['uid']]);
175
+        $sth->execute([$id, $_SESSION['uid']]);
176 176
 
177
-		if ($row = $sth->fetch()) {
178
-			$old_caption = $row["caption"];
177
+        if ($row = $sth->fetch()) {
178
+            $old_caption = $row["caption"];
179 179
 
180
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2
180
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2
181 181
 				WHERE caption = ? AND owner_uid = ?");
182
-			$sth->execute([$caption, $_SESSION['uid']]);
182
+            $sth->execute([$caption, $_SESSION['uid']]);
183 183
 
184
-			if (!$sth->fetch()) {
185
-				if ($caption) {
186
-					$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
184
+            if (!$sth->fetch()) {
185
+                if ($caption) {
186
+                    $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
187 187
 						caption = ? WHERE id = ? AND
188 188
 						owner_uid = ?");
189
-					$sth->execute([$caption, $id, $_SESSION['uid']]);
189
+                    $sth->execute([$caption, $id, $_SESSION['uid']]);
190 190
 
191
-					/* Update filters that reference label being renamed */
191
+                    /* Update filters that reference label being renamed */
192 192
 
193
-					$sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions SET
193
+                    $sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions SET
194 194
 						action_param = ? WHERE action_param = ?
195 195
 						AND action_id = 7
196 196
 						AND filter_id IN (SELECT id FROM ttrss_filters2 WHERE owner_uid = ?)");
197 197
 
198
-					$sth->execute([$caption, $old_caption, $_SESSION['uid']]);
198
+                    $sth->execute([$caption, $old_caption, $_SESSION['uid']]);
199 199
 
200
-					print clean($_REQUEST["value"]);
201
-				} else {
202
-					print $old_caption;
203
-				}
204
-			} else {
205
-				print $old_caption;
206
-			}
207
-		}
200
+                    print clean($_REQUEST["value"]);
201
+                } else {
202
+                    print $old_caption;
203
+                }
204
+            } else {
205
+                print $old_caption;
206
+            }
207
+        }
208 208
 
209
-		$this->pdo->commit();
209
+        $this->pdo->commit();
210 210
 
211
-	}
211
+    }
212 212
 
213
-	public function remove() {
213
+    public function remove() {
214 214
 
215
-		$ids = explode(",", clean($_REQUEST["ids"]));
215
+        $ids = explode(",", clean($_REQUEST["ids"]));
216 216
 
217
-		foreach ($ids as $id) {
218
-			Labels::remove($id, $_SESSION["uid"]);
219
-		}
217
+        foreach ($ids as $id) {
218
+            Labels::remove($id, $_SESSION["uid"]);
219
+        }
220 220
 
221
-	}
221
+    }
222 222
 
223
-	public function add() {
224
-		$caption = clean($_REQUEST["caption"]);
225
-		$output = clean($_REQUEST["output"]);
223
+    public function add() {
224
+        $caption = clean($_REQUEST["caption"]);
225
+        $output = clean($_REQUEST["output"]);
226 226
 
227
-		if ($caption) {
227
+        if ($caption) {
228 228
 
229
-			if (Labels::create($caption)) {
230
-				if (!$output) {
231
-					print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
232
-				}
233
-			}
229
+            if (Labels::create($caption)) {
230
+                if (!$output) {
231
+                    print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
232
+                }
233
+            }
234 234
 
235
-			if ($output == "select") {
236
-				header("Content-Type: text/xml");
235
+            if ($output == "select") {
236
+                header("Content-Type: text/xml");
237 237
 
238
-				print "<rpc-reply><payload>";
238
+                print "<rpc-reply><payload>";
239 239
 
240
-				print_label_select("select_label",
241
-					$caption, "");
240
+                print_label_select("select_label",
241
+                    $caption, "");
242 242
 
243
-				print "</payload></rpc-reply>";
244
-			}
245
-		}
243
+                print "</payload></rpc-reply>";
244
+            }
245
+        }
246 246
 
247
-		return;
248
-	}
247
+        return;
248
+    }
249 249
 
250
-	public function index() {
250
+    public function index() {
251 251
 
252
-		print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
253
-		print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
254
-		print "<div dojoType='fox.Toolbar'>";
252
+        print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
253
+        print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
254
+        print "<div dojoType='fox.Toolbar'>";
255 255
 
256
-		print "<div dojoType='fox.form.DropDownButton'>".
257
-				"<span>" . __('Select')."</span>";
258
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
259
-		print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(true)\"
256
+        print "<div dojoType='fox.form.DropDownButton'>".
257
+                "<span>" . __('Select')."</span>";
258
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
259
+        print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(true)\"
260 260
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
261
-		print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(false)\"
261
+        print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(false)\"
262 262
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
263
-		print "</div></div>";
263
+        print "</div></div>";
264 264
 
265
-		print"<button dojoType=\"dijit.form.Button\" onclick=\"CommonDialogs.addLabel()\">".
266
-			__('Create label')."</button dojoType=\"dijit.form.Button\"> ";
265
+        print"<button dojoType=\"dijit.form.Button\" onclick=\"CommonDialogs.addLabel()\">".
266
+            __('Create label')."</button dojoType=\"dijit.form.Button\"> ";
267 267
 
268
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').removeSelected()\">".
269
-			__('Remove')."</button dojoType=\"dijit.form.Button\"> ";
268
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').removeSelected()\">".
269
+            __('Remove')."</button dojoType=\"dijit.form.Button\"> ";
270 270
 
271
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').resetColors()\">".
272
-			__('Clear colors')."</button dojoType=\"dijit.form.Button\">";
271
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').resetColors()\">".
272
+            __('Clear colors')."</button dojoType=\"dijit.form.Button\">";
273 273
 
274 274
 
275
-		print "</div>"; #toolbar
276
-		print "</div>"; #pane
277
-		print "<div style='padding : 0px' dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
275
+        print "</div>"; #toolbar
276
+        print "</div>"; #pane
277
+        print "<div style='padding : 0px' dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
278 278
 
279
-		print "<div id=\"labellistLoading\">
279
+        print "<div id=\"labellistLoading\">
280 280
 		<img src='images/indicator_tiny.gif'>".
281
-		 __("Loading, please wait...")."</div>";
281
+            __("Loading, please wait...")."</div>";
282 282
 
283
-		print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"labelStore\"
283
+        print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"labelStore\"
284 284
 			url=\"backend.php?op=pref-labels&method=getlabeltree\">
285 285
 		</div>
286 286
 		<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"labelModel\" store=\"labelStore\"
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 		</script>
303 303
 		</div>";
304 304
 
305
-		print "</div>"; #pane
305
+        print "</div>"; #pane
306 306
 
307
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
308
-			"hook_prefs_tab", "prefLabels");
307
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
308
+            "hook_prefs_tab", "prefLabels");
309 309
 
310
-		print "</div>"; #container
310
+        print "</div>"; #container
311 311
 
312
-	}
312
+    }
313 313
 }
Please login to merge, or discard this patch.
classes/pref/users.php 1 patch
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -1,130 +1,130 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Users extends Handler_Protected {
3
-		public function before($method) {
4
-			if (parent::before($method)) {
5
-				if ($_SESSION["access_level"] < 10) {
6
-					print __("Your access level is insufficient to open this tab.");
7
-					return false;
8
-				}
9
-				return true;
10
-			}
11
-			return false;
12
-		}
3
+        public function before($method) {
4
+            if (parent::before($method)) {
5
+                if ($_SESSION["access_level"] < 10) {
6
+                    print __("Your access level is insufficient to open this tab.");
7
+                    return false;
8
+                }
9
+                return true;
10
+            }
11
+            return false;
12
+        }
13 13
 
14
-		public function csrf_ignore($method) {
15
-			$csrf_ignored = array("index", "edit", "userdetails");
14
+        public function csrf_ignore($method) {
15
+            $csrf_ignored = array("index", "edit", "userdetails");
16 16
 
17
-			return array_search($method, $csrf_ignored) !== false;
18
-		}
17
+            return array_search($method, $csrf_ignored) !== false;
18
+        }
19 19
 
20
-		public function edit() {
21
-			global $access_level_names;
20
+        public function edit() {
21
+            global $access_level_names;
22 22
 
23
-			print "<form id='user_edit_form' onsubmit='return false' dojoType='dijit.form.Form'>";
23
+            print "<form id='user_edit_form' onsubmit='return false' dojoType='dijit.form.Form'>";
24 24
 
25
-			print '<div dojoType="dijit.layout.TabContainer" style="height : 400px">
25
+            print '<div dojoType="dijit.layout.TabContainer" style="height : 400px">
26 26
         		<div dojoType="dijit.layout.ContentPane" title="'.__('Edit user').'">';
27 27
 
28
-			//print "<form id=\"user_edit_form\" onsubmit='return false' dojoType=\"dijit.form.Form\">";
28
+            //print "<form id=\"user_edit_form\" onsubmit='return false' dojoType=\"dijit.form.Form\">";
29 29
 
30
-			$id = (int) clean($_REQUEST["id"]);
30
+            $id = (int) clean($_REQUEST["id"]);
31 31
 
32
-			print_hidden("id", "$id");
33
-			print_hidden("op", "pref-users");
34
-			print_hidden("method", "editSave");
32
+            print_hidden("id", "$id");
33
+            print_hidden("op", "pref-users");
34
+            print_hidden("method", "editSave");
35 35
 
36
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_users WHERE id = ?");
37
-			$sth->execute([$id]);
36
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_users WHERE id = ?");
37
+            $sth->execute([$id]);
38 38
 
39
-			if ($row = $sth->fetch()) {
39
+            if ($row = $sth->fetch()) {
40 40
 
41
-				$login = $row["login"];
42
-				$access_level = $row["access_level"];
43
-				$email = $row["email"];
41
+                $login = $row["login"];
42
+                $access_level = $row["access_level"];
43
+                $email = $row["email"];
44 44
 
45
-				$sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : "";
45
+                $sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : "";
46 46
 
47
-				print "<header>".__("User")."</header>";
48
-				print "<section>";
47
+                print "<header>".__("User")."</header>";
48
+                print "<section>";
49 49
 
50
-				if ($sel_disabled) {
51
-					print_hidden("login", "$login");
52
-				}
50
+                if ($sel_disabled) {
51
+                    print_hidden("login", "$login");
52
+                }
53 53
 
54
-				print "<fieldset>";
55
-				print "<label>" . __("Login:") . "</label>";
56
-				print "<input style='font-size : 16px'
54
+                print "<fieldset>";
55
+                print "<label>" . __("Login:") . "</label>";
56
+                print "<input style='font-size : 16px'
57 57
 					dojoType='dijit.form.ValidationTextBox' required='1'
58 58
 					$sel_disabled name='login' value=\"$login\">";
59
-				print "</fieldset>";
59
+                print "</fieldset>";
60 60
 
61
-				print "</section>";
61
+                print "</section>";
62 62
 
63
-				print "<header>".__("Authentication")."</header>";
64
-				print "<section>";
63
+                print "<header>".__("Authentication")."</header>";
64
+                print "<section>";
65 65
 
66
-				print "<fieldset>";
66
+                print "<fieldset>";
67 67
 
68
-				print "<label>" . __('Access level: ') . "</label> ";
68
+                print "<label>" . __('Access level: ') . "</label> ";
69 69
 
70
-				if (!$sel_disabled) {
71
-					print_select_hash("access_level", $access_level, $access_level_names,
72
-						"dojoType=\"fox.form.Select\" $sel_disabled");
73
-				} else {
74
-					print_select_hash("", $access_level, $access_level_names,
75
-						"dojoType=\"fox.form.Select\" $sel_disabled");
76
-					print_hidden("access_level", "$access_level");
77
-				}
70
+                if (!$sel_disabled) {
71
+                    print_select_hash("access_level", $access_level, $access_level_names,
72
+                        "dojoType=\"fox.form.Select\" $sel_disabled");
73
+                } else {
74
+                    print_select_hash("", $access_level, $access_level_names,
75
+                        "dojoType=\"fox.form.Select\" $sel_disabled");
76
+                    print_hidden("access_level", "$access_level");
77
+                }
78 78
 
79
-				print "</fieldset>";
80
-				print "<fieldset>";
79
+                print "</fieldset>";
80
+                print "<fieldset>";
81 81
 
82
-				print "<label>" . __("New password:") . "</label> ";
83
-				print "<input dojoType='dijit.form.TextBox' type='password' size='20' placeholder='Change password'
82
+                print "<label>" . __("New password:") . "</label> ";
83
+                print "<input dojoType='dijit.form.TextBox' type='password' size='20' placeholder='Change password'
84 84
 					name='password'>";
85 85
 
86
-				print "</fieldset>";
86
+                print "</fieldset>";
87 87
 
88
-				print "</section>";
88
+                print "</section>";
89 89
 
90
-				print "<header>".__("Options")."</header>";
91
-				print "<section>";
90
+                print "<header>".__("Options")."</header>";
91
+                print "<section>";
92 92
 
93
-				print "<fieldset>";
94
-				print "<label>" . __("E-mail:") . "</label> ";
95
-				print "<input dojoType='dijit.form.TextBox' size='30' name='email'
93
+                print "<fieldset>";
94
+                print "<label>" . __("E-mail:") . "</label> ";
95
+                print "<input dojoType='dijit.form.TextBox' size='30' name='email'
96 96
 					value=\"$email\">";
97
-				print "</fieldset>";
97
+                print "</fieldset>";
98 98
 
99
-				print "</section>";
99
+                print "</section>";
100 100
 
101
-				print "</table>";
101
+                print "</table>";
102 102
 
103
-			}
103
+            }
104 104
 
105
-			print '</div>'; #tab
106
-			print "<div href=\"backend.php?op=pref-users&method=userdetails&id=$id\"
105
+            print '</div>'; #tab
106
+            print "<div href=\"backend.php?op=pref-users&method=userdetails&id=$id\"
107 107
 				dojoType=\"dijit.layout.ContentPane\" title=\"".__('User details')."\">";
108 108
 
109
-			print '</div>';
110
-			print '</div>';
109
+            print '</div>';
110
+            print '</div>';
111 111
 
112
-			print "<footer>
112
+            print "<footer>
113 113
 				<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"dijit.byId('userEditDlg').execute()\">".
114
-				__('Save')."</button>
114
+                __('Save')."</button>
115 115
 				<button dojoType='dijit.form.Button' onclick=\"dijit.byId('userEditDlg').hide()\">".
116
-				__('Cancel')."</button>
116
+                __('Cancel')."</button>
117 117
 				</footer>";
118 118
 
119
-			print "</form>";
119
+            print "</form>";
120 120
 
121
-			return;
122
-		}
121
+            return;
122
+        }
123 123
 
124
-		public function userdetails() {
125
-			$id = (int) clean($_REQUEST["id"]);
124
+        public function userdetails() {
125
+            $id = (int) clean($_REQUEST["id"]);
126 126
 
127
-			$sth = $this->pdo->prepare("SELECT login,
127
+            $sth = $this->pdo->prepare("SELECT login,
128 128
 				".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login,
129 129
 				access_level,
130 130
 				(SELECT COUNT(int_id) FROM ttrss_user_entries
@@ -132,242 +132,242 @@  discard block
 block discarded – undo
132 132
 				".SUBSTRING_FOR_DATE."(created,1,16) AS created
133 133
 				FROM ttrss_users
134 134
 				WHERE id = ?");
135
-			$sth->execute([$id]);
135
+            $sth->execute([$id]);
136 136
 
137
-			if ($row = $sth->fetch()) {
138
-				print "<table width='100%'>";
137
+            if ($row = $sth->fetch()) {
138
+                print "<table width='100%'>";
139 139
 
140
-				$last_login = make_local_datetime(
141
-					$row["last_login"], true);
140
+                $last_login = make_local_datetime(
141
+                    $row["last_login"], true);
142 142
 
143
-				$created = make_local_datetime(
144
-					$row["created"], true);
143
+                $created = make_local_datetime(
144
+                    $row["created"], true);
145 145
 
146
-				$stored_articles = $row["stored_articles"];
146
+                $stored_articles = $row["stored_articles"];
147 147
 
148
-				print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
149
-				print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
148
+                print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
149
+                print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
150 150
 
151
-				$sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds
151
+                $sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds
152 152
 					WHERE owner_uid = ?");
153
-				$sth->execute([$id]);
154
-				$row = $sth->fetch();
155
-				$num_feeds = $row["num_feeds"];
153
+                $sth->execute([$id]);
154
+                $row = $sth->fetch();
155
+                $num_feeds = $row["num_feeds"];
156 156
 
157
-				print "<tr><td>".__('Subscribed feeds count')."</td><td>$num_feeds</td></tr>";
158
-				print "<tr><td>".__('Stored articles')."</td><td>$stored_articles</td></tr>";
157
+                print "<tr><td>".__('Subscribed feeds count')."</td><td>$num_feeds</td></tr>";
158
+                print "<tr><td>".__('Stored articles')."</td><td>$stored_articles</td></tr>";
159 159
 
160
-				print "</table>";
160
+                print "</table>";
161 161
 
162
-				print "<h1>".__('Subscribed feeds')."</h1>";
162
+                print "<h1>".__('Subscribed feeds')."</h1>";
163 163
 
164
-				$sth = $this->pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds
164
+                $sth = $this->pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds
165 165
 					WHERE owner_uid = ? ORDER BY title");
166
-				$sth->execute([$id]);
166
+                $sth->execute([$id]);
167 167
 
168
-				print "<ul class=\"panel panel-scrollable list list-unstyled\">";
168
+                print "<ul class=\"panel panel-scrollable list list-unstyled\">";
169 169
 
170
-				while ($line = $sth->fetch()) {
170
+                while ($line = $sth->fetch()) {
171 171
 
172
-					$icon_file = ICONS_URL."/".$line["id"].".ico";
172
+                    $icon_file = ICONS_URL."/".$line["id"].".ico";
173 173
 
174
-					if (file_exists($icon_file) && filesize($icon_file) > 0) {
175
-						$feed_icon = "<img class=\"icon\" src=\"$icon_file\">";
176
-					} else {
177
-						$feed_icon = "<img class=\"icon\" src=\"images/blank_icon.gif\">";
178
-					}
174
+                    if (file_exists($icon_file) && filesize($icon_file) > 0) {
175
+                        $feed_icon = "<img class=\"icon\" src=\"$icon_file\">";
176
+                    } else {
177
+                        $feed_icon = "<img class=\"icon\" src=\"images/blank_icon.gif\">";
178
+                    }
179 179
 
180
-					print "<li>$feed_icon&nbsp;<a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
180
+                    print "<li>$feed_icon&nbsp;<a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
181 181
 
182
-				}
182
+                }
183 183
 
184
-				print "</ul>";
184
+                print "</ul>";
185 185
 
186 186
 
187
-			} else {
188
-				print "<h1>".__('User not found')."</h1>";
189
-			}
187
+            } else {
188
+                print "<h1>".__('User not found')."</h1>";
189
+            }
190 190
 
191
-		}
191
+        }
192 192
 
193
-		public function editSave() {
194
-			$login = trim(clean($_REQUEST["login"]));
195
-			$uid = clean($_REQUEST["id"]);
196
-			$access_level = (int) clean($_REQUEST["access_level"]);
197
-			$email = trim(clean($_REQUEST["email"]));
198
-			$password = clean($_REQUEST["password"]);
193
+        public function editSave() {
194
+            $login = trim(clean($_REQUEST["login"]));
195
+            $uid = clean($_REQUEST["id"]);
196
+            $access_level = (int) clean($_REQUEST["access_level"]);
197
+            $email = trim(clean($_REQUEST["email"]));
198
+            $password = clean($_REQUEST["password"]);
199 199
 
200
-			if ($password) {
201
-				$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
202
-				$pwd_hash = encrypt_password($password, $salt, true);
203
-				$pass_query_part = "pwd_hash = ".$this->pdo->quote($pwd_hash).",
200
+            if ($password) {
201
+                $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
202
+                $pwd_hash = encrypt_password($password, $salt, true);
203
+                $pass_query_part = "pwd_hash = ".$this->pdo->quote($pwd_hash).",
204 204
 					salt = ".$this->pdo->quote($salt).",";
205
-			} else {
206
-				$pass_query_part = "";
207
-			}
205
+            } else {
206
+                $pass_query_part = "";
207
+            }
208 208
 
209
-			$sth = $this->pdo->prepare("UPDATE ttrss_users SET $pass_query_part login = ?,
209
+            $sth = $this->pdo->prepare("UPDATE ttrss_users SET $pass_query_part login = ?,
210 210
 				access_level = ?, email = ?, otp_enabled = false WHERE id = ?");
211
-			$sth->execute([$login, $access_level, $email, $uid]);
211
+            $sth->execute([$login, $access_level, $email, $uid]);
212 212
 
213
-		}
213
+        }
214 214
 
215
-		public function remove() {
216
-			$ids = explode(",", clean($_REQUEST["ids"]));
215
+        public function remove() {
216
+            $ids = explode(",", clean($_REQUEST["ids"]));
217 217
 
218
-			foreach ($ids as $id) {
219
-				if ($id != $_SESSION["uid"] && $id != 1) {
220
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?");
221
-					$sth->execute([$id]);
218
+            foreach ($ids as $id) {
219
+                if ($id != $_SESSION["uid"] && $id != 1) {
220
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?");
221
+                    $sth->execute([$id]);
222 222
 
223
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?");
224
-					$sth->execute([$id]);
223
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?");
224
+                    $sth->execute([$id]);
225 225
 
226
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?");
227
-					$sth->execute([$id]);
228
-				}
229
-			}
230
-		}
226
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?");
227
+                    $sth->execute([$id]);
228
+                }
229
+            }
230
+        }
231 231
 
232
-		public function add() {
233
-			$login = trim(clean($_REQUEST["login"]));
234
-			$tmp_user_pwd = make_password();
235
-			$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
236
-			$pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
232
+        public function add() {
233
+            $login = trim(clean($_REQUEST["login"]));
234
+            $tmp_user_pwd = make_password();
235
+            $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
236
+            $pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
237 237
 
238
-			if (!$login) return; // no blank usernames
238
+            if (!$login) return; // no blank usernames
239 239
 
240
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
240
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
241 241
 				login = ?");
242
-			$sth->execute([$login]);
242
+            $sth->execute([$login]);
243 243
 
244
-			if (!$sth->fetch()) {
244
+            if (!$sth->fetch()) {
245 245
 
246
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_users
246
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_users
247 247
 					(login,pwd_hash,access_level,last_login,created, salt)
248 248
 					VALUES (?, ?, 0, null, NOW(), ?)");
249
-				$sth->execute([$login, $pwd_hash, $salt]);
249
+                $sth->execute([$login, $pwd_hash, $salt]);
250 250
 
251
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
251
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
252 252
 					login = ? AND pwd_hash = ?");
253
-				$sth->execute([$login, $pwd_hash]);
253
+                $sth->execute([$login, $pwd_hash]);
254 254
 
255
-				if ($row = $sth->fetch()) {
255
+                if ($row = $sth->fetch()) {
256 256
 
257
-					$new_uid = $row['id'];
257
+                    $new_uid = $row['id'];
258 258
 
259
-					print T_sprintf("Added user %s with password %s",
260
-						$login, $tmp_user_pwd);
259
+                    print T_sprintf("Added user %s with password %s",
260
+                        $login, $tmp_user_pwd);
261 261
 
262
-					initialize_user($new_uid);
262
+                    initialize_user($new_uid);
263 263
 
264
-				} else {
264
+                } else {
265 265
 
266
-					print T_sprintf("Could not create user %s", $login);
266
+                    print T_sprintf("Could not create user %s", $login);
267 267
 
268
-				}
269
-			} else {
270
-				print T_sprintf("User %s already exists.", $login);
271
-			}
272
-		}
268
+                }
269
+            } else {
270
+                print T_sprintf("User %s already exists.", $login);
271
+            }
272
+        }
273 273
 
274
-		public static function resetUserPassword($uid, $format_output = false) {
274
+        public static function resetUserPassword($uid, $format_output = false) {
275 275
 
276
-			$pdo = Db::pdo();
276
+            $pdo = Db::pdo();
277 277
 
278
-			$sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
279
-			$sth->execute([$uid]);
278
+            $sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
279
+            $sth->execute([$uid]);
280 280
 
281
-			if ($row = $sth->fetch()) {
281
+            if ($row = $sth->fetch()) {
282 282
 
283
-				$login = $row["login"];
283
+                $login = $row["login"];
284 284
 
285
-				$new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
286
-				$tmp_user_pwd = make_password();
285
+                $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
286
+                $tmp_user_pwd = make_password();
287 287
 
288
-				$pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
288
+                $pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
289 289
 
290
-				$sth = $pdo->prepare("UPDATE ttrss_users
290
+                $sth = $pdo->prepare("UPDATE ttrss_users
291 291
 					  SET pwd_hash = ?, salt = ?, otp_enabled = false
292 292
 					WHERE id = ?");
293
-				$sth->execute([$pwd_hash, $new_salt, $uid]);
293
+                $sth->execute([$pwd_hash, $new_salt, $uid]);
294 294
 
295
-				$message = T_sprintf("Changed password of user %s to %s", "<strong>$login</strong>", "<strong>$tmp_user_pwd</strong>");
295
+                $message = T_sprintf("Changed password of user %s to %s", "<strong>$login</strong>", "<strong>$tmp_user_pwd</strong>");
296 296
 
297
-				if ($format_output)
298
-					print_notice($message);
299
-				else
300
-					print $message;
297
+                if ($format_output)
298
+                    print_notice($message);
299
+                else
300
+                    print $message;
301 301
 
302
-			}
303
-		}
302
+            }
303
+        }
304 304
 
305
-		public function resetPass() {
306
-			$uid = clean($_REQUEST["id"]);
307
-			Pref_Users::resetUserPassword($uid);
308
-		}
305
+        public function resetPass() {
306
+            $uid = clean($_REQUEST["id"]);
307
+            Pref_Users::resetUserPassword($uid);
308
+        }
309 309
 
310
-		public function index() {
310
+        public function index() {
311 311
 
312
-			global $access_level_names;
312
+            global $access_level_names;
313 313
 
314
-			print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
315
-			print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
316
-			print "<div dojoType='fox.Toolbar'>";
314
+            print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
315
+            print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
316
+            print "<div dojoType='fox.Toolbar'>";
317 317
 
318
-			$user_search = trim(clean($_REQUEST["search"]));
318
+            $user_search = trim(clean($_REQUEST["search"]));
319 319
 
320
-			if (array_key_exists("search", $_REQUEST)) {
321
-				$_SESSION["prefs_user_search"] = $user_search;
322
-			} else {
323
-				$user_search = $_SESSION["prefs_user_search"];
324
-			}
320
+            if (array_key_exists("search", $_REQUEST)) {
321
+                $_SESSION["prefs_user_search"] = $user_search;
322
+            } else {
323
+                $user_search = $_SESSION["prefs_user_search"];
324
+            }
325 325
 
326
-			print "<div style='float : right; padding-right : 4px;'>
326
+            print "<div style='float : right; padding-right : 4px;'>
327 327
 				<input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search'
328 328
 					value=\"$user_search\">
329 329
 				<button dojoType='dijit.form.Button' onclick='Users.reload()'>".
330
-					__('Search')."</button>
330
+                    __('Search')."</button>
331 331
 				</div>";
332 332
 
333
-			$sort = clean($_REQUEST["sort"]);
333
+            $sort = clean($_REQUEST["sort"]);
334 334
 
335
-			if (!$sort || $sort == "undefined") {
336
-				$sort = "login";
337
-			}
335
+            if (!$sort || $sort == "undefined") {
336
+                $sort = "login";
337
+            }
338 338
 
339
-			print "<div dojoType='fox.form.DropDownButton'>".
340
-					"<span>" . __('Select')."</span>";
341
-			print "<div dojoType='dijit.Menu' style='display: none'>";
342
-			print "<div onclick=\"Tables.select('prefUserList', true)\"
339
+            print "<div dojoType='fox.form.DropDownButton'>".
340
+                    "<span>" . __('Select')."</span>";
341
+            print "<div dojoType='dijit.Menu' style='display: none'>";
342
+            print "<div onclick=\"Tables.select('prefUserList', true)\"
343 343
 				dojoType='dijit.MenuItem'>".__('All')."</div>";
344
-			print "<div onclick=\"Tables.select('prefUserList', false)\"
344
+            print "<div onclick=\"Tables.select('prefUserList', false)\"
345 345
 				dojoType='dijit.MenuItem'>".__('None')."</div>";
346
-			print "</div></div>";
346
+            print "</div></div>";
347 347
 
348
-			print "<button dojoType='dijit.form.Button' onclick='Users.add()'>".__('Create user')."</button>";
348
+            print "<button dojoType='dijit.form.Button' onclick='Users.add()'>".__('Create user')."</button>";
349 349
 
350
-			print "
350
+            print "
351 351
 				<button dojoType='dijit.form.Button' onclick='Users.editSelected()'>".
352
-				__('Edit')."</button dojoType=\"dijit.form.Button\">
352
+                __('Edit')."</button dojoType=\"dijit.form.Button\">
353 353
 				<button dojoType='dijit.form.Button' onclick='Users.removeSelected()'>".
354
-				__('Remove')."</button dojoType=\"dijit.form.Button\">
354
+                __('Remove')."</button dojoType=\"dijit.form.Button\">
355 355
 				<button dojoType='dijit.form.Button' onclick='Users.resetSelected()'>".
356
-				__('Reset password')."</button dojoType=\"dijit.form.Button\">";
356
+                __('Reset password')."</button dojoType=\"dijit.form.Button\">";
357 357
 
358
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
359
-				"hook_prefs_tab_section", "prefUsersToolbar");
358
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
359
+                "hook_prefs_tab_section", "prefUsersToolbar");
360 360
 
361
-			print "</div>"; #toolbar
362
-			print "</div>"; #pane
363
-			print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
361
+            print "</div>"; #toolbar
362
+            print "</div>"; #pane
363
+            print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
364 364
 
365
-			$sort = $this->validate_field($sort,
366
-				["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
365
+            $sort = $this->validate_field($sort,
366
+                ["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
367 367
 
368
-			if ($sort != "login") $sort = "$sort DESC";
368
+            if ($sort != "login") $sort = "$sort DESC";
369 369
 
370
-			$sth = $this->pdo->prepare("SELECT
370
+            $sth = $this->pdo->prepare("SELECT
371 371
 					tu.id,
372 372
 					login,access_level,email,
373 373
 					".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login,
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 				WHERE
379 379
 					(:search = '' OR login LIKE :search) AND tu.id > 0
380 380
 				ORDER BY $sort");
381
-			$sth->execute([":search" => $user_search ? "%$user_search%" : ""]);
381
+            $sth->execute([":search" => $user_search ? "%$user_search%" : ""]);
382 382
 
383
-			print "<p><table width='100%' cellspacing='0' class='prefUserList' id='prefUserList'>";
383
+            print "<p><table width='100%' cellspacing='0' class='prefUserList' id='prefUserList'>";
384 384
 
385
-			print "<tr class='title'>
385
+            print "<tr class='title'>
386 386
 						<td align='center' width='5%'>&nbsp;</td>
387 387
 						<td width='20%'><a href='#' onclick=\"Users.reload('login')\">".__('Login')."</a></td>
388 388
 						<td width='20%'><a href='#' onclick=\"Users.reload('access_level')\">".__('Access Level')."</a></td>
@@ -390,57 +390,57 @@  discard block
 block discarded – undo
390 390
 						<td width='20%'><a href='#' onclick=\"Users.reload('created')\">".__('Registered')."</a></td>
391 391
 						<td width='20%'><a href='#' onclick=\"Users.reload('last_login')\">".__('Last login')."</a></td></tr>";
392 392
 
393
-			$lnum = 0;
393
+            $lnum = 0;
394 394
 
395
-			while ($line = $sth->fetch()) {
395
+            while ($line = $sth->fetch()) {
396 396
 
397
-				$uid = $line["id"];
397
+                $uid = $line["id"];
398 398
 
399
-				print "<tr data-row-id='$uid' onclick='Users.edit($uid)'>";
399
+                print "<tr data-row-id='$uid' onclick='Users.edit($uid)'>";
400 400
 
401
-				$line["login"] = htmlspecialchars($line["login"]);
402
-				$line["created"] = make_local_datetime($line["created"], false);
403
-				$line["last_login"] = make_local_datetime($line["last_login"], false);
401
+                $line["login"] = htmlspecialchars($line["login"]);
402
+                $line["created"] = make_local_datetime($line["created"], false);
403
+                $line["last_login"] = make_local_datetime($line["last_login"], false);
404 404
 
405
-				print "<td align='center'><input onclick='Tables.onRowChecked(this); event.stopPropagation();'
405
+                print "<td align='center'><input onclick='Tables.onRowChecked(this); event.stopPropagation();'
406 406
 					dojoType='dijit.form.CheckBox' type='checkbox'></td>";
407 407
 
408
-				print "<td title='".__('Click to edit')."'><i class='material-icons'>person</i> " . $line["login"] . "</td>";
408
+                print "<td title='".__('Click to edit')."'><i class='material-icons'>person</i> " . $line["login"] . "</td>";
409 409
 
410
-				print "<td>" .	$access_level_names[$line["access_level"]] . "</td>";
411
-				print "<td>" . $line["num_feeds"] . "</td>";
412
-				print "<td>" . $line["created"] . "</td>";
413
-				print "<td>" . $line["last_login"] . "</td>";
410
+                print "<td>" .	$access_level_names[$line["access_level"]] . "</td>";
411
+                print "<td>" . $line["num_feeds"] . "</td>";
412
+                print "<td>" . $line["created"] . "</td>";
413
+                print "<td>" . $line["last_login"] . "</td>";
414 414
 
415
-				print "</tr>";
415
+                print "</tr>";
416 416
 
417
-				++$lnum;
418
-			}
417
+                ++$lnum;
418
+            }
419 419
 
420
-			print "</table>";
420
+            print "</table>";
421 421
 
422
-			if ($lnum == 0) {
423
-				if (!$user_search) {
424
-					print_warning(__('No users defined.'));
425
-				} else {
426
-					print_warning(__('No matching users found.'));
427
-				}
428
-			}
422
+            if ($lnum == 0) {
423
+                if (!$user_search) {
424
+                    print_warning(__('No users defined.'));
425
+                } else {
426
+                    print_warning(__('No matching users found.'));
427
+                }
428
+            }
429 429
 
430
-			print "</div>"; #pane
430
+            print "</div>"; #pane
431 431
 
432
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
433
-				"hook_prefs_tab", "prefUsers");
432
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
433
+                "hook_prefs_tab", "prefUsers");
434 434
 
435
-			print "</div>"; #container
435
+            print "</div>"; #container
436 436
 
437
-		}
437
+        }
438 438
 
439
-		public function validate_field($string, $allowed, $default = "") {
440
-			if (in_array($string, $allowed))
441
-				return $string;
442
-			else
443
-				return $default;
444
-		}
439
+        public function validate_field($string, $allowed, $default = "") {
440
+            if (in_array($string, $allowed))
441
+                return $string;
442
+            else
443
+                return $default;
444
+        }
445 445
 
446 446
 }
Please login to merge, or discard this patch.
classes/pref/system.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -2,50 +2,50 @@  discard block
 block discarded – undo
2 2
 
3 3
 class Pref_System extends Handler_Protected {
4 4
 
5
-	public function before($method) {
6
-		if (parent::before($method)) {
7
-			if ($_SESSION["access_level"] < 10) {
8
-				print __("Your access level is insufficient to open this tab.");
9
-				return false;
10
-			}
11
-			return true;
12
-		}
13
-		return false;
14
-	}
15
-
16
-	public function csrf_ignore($method) {
17
-		$csrf_ignored = array("index");
18
-
19
-		return array_search($method, $csrf_ignored) !== false;
20
-	}
21
-
22
-	public function clearLog() {
23
-		$this->pdo->query("DELETE FROM ttrss_error_log");
24
-	}
25
-
26
-	public function index() {
27
-
28
-		print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
29
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
5
+    public function before($method) {
6
+        if (parent::before($method)) {
7
+            if ($_SESSION["access_level"] < 10) {
8
+                print __("Your access level is insufficient to open this tab.");
9
+                return false;
10
+            }
11
+            return true;
12
+        }
13
+        return false;
14
+    }
15
+
16
+    public function csrf_ignore($method) {
17
+        $csrf_ignored = array("index");
18
+
19
+        return array_search($method, $csrf_ignored) !== false;
20
+    }
21
+
22
+    public function clearLog() {
23
+        $this->pdo->query("DELETE FROM ttrss_error_log");
24
+    }
25
+
26
+    public function index() {
27
+
28
+        print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
29
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
30 30
 			title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">";
31 31
 
32
-		if (LOG_DESTINATION == "sql") {
32
+        if (LOG_DESTINATION == "sql") {
33 33
 
34
-			$res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
34
+            $res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
35 35
 				created_at, login, context FROM ttrss_error_log
36 36
 				LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
37 37
 				ORDER BY ttrss_error_log.id DESC
38 38
 				LIMIT 100");
39 39
 
40
-			print "<button dojoType=\"dijit.form.Button\"
40
+            print "<button dojoType=\"dijit.form.Button\"
41 41
 				onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> ";
42 42
 
43
-			print "&nbsp;<button dojoType=\"dijit.form.Button\"
43
+            print "&nbsp;<button dojoType=\"dijit.form.Button\"
44 44
 				class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> ";
45 45
 
46
-			print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
46
+            print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
47 47
 
48
-			print "<tr class=\"title\">
48
+            print "<tr class=\"title\">
49 49
 				<td width='5%'>".__("Error")."</td>
50 50
 				<td>".__("Filename")."</td>
51 51
 				<td>".__("Message")."</td>
@@ -53,52 +53,52 @@  discard block
 block discarded – undo
53 53
 				<td width='5%'>".__("Date")."</td>
54 54
 				</tr>";
55 55
 
56
-			while ($line = $res->fetch()) {
57
-				print "<tr>";
56
+            while ($line = $res->fetch()) {
57
+                print "<tr>";
58 58
 
59
-				foreach ($line as $k => $v) {
60
-					$line[$k] = htmlspecialchars($v);
61
-				}
59
+                foreach ($line as $k => $v) {
60
+                    $line[$k] = htmlspecialchars($v);
61
+                }
62 62
 
63
-				print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
64
-				print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
65
-				print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>";
66
-				print "<td class='login'>" . $line["login"] . "</td>";
63
+                print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
64
+                print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
65
+                print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>";
66
+                print "<td class='login'>" . $line["login"] . "</td>";
67 67
 
68
-				print "<td class='timestamp'>" .
69
-					make_local_datetime(
70
-					$line["created_at"], false) . "</td>";
68
+                print "<td class='timestamp'>" .
69
+                    make_local_datetime(
70
+                    $line["created_at"], false) . "</td>";
71 71
 
72
-				print "</tr>";
73
-			}
72
+                print "</tr>";
73
+            }
74 74
 
75
-			print "</table>";
76
-		} else {
75
+            print "</table>";
76
+        } else {
77 77
 
78
-			print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
78
+            print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
79 79
 
80
-		}
80
+        }
81 81
 
82
-		print "</div>";
82
+        print "</div>";
83 83
 
84
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
84
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
85 85
 			title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">";
86 86
 
87
-		ob_start();
88
-		phpinfo();
89
-		$info = ob_get_contents();
90
-		ob_end_clean();
87
+        ob_start();
88
+        phpinfo();
89
+        $info = ob_get_contents();
90
+        ob_end_clean();
91 91
 
92
-		print "<div class='phpinfo'>";
93
-		print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info);
94
-		print "</div>";
92
+        print "<div class='phpinfo'>";
93
+        print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info);
94
+        print "</div>";
95 95
 
96
-		print "</div>";
96
+        print "</div>";
97 97
 
98
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
99
-			"hook_prefs_tab", "prefSystem");
98
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
99
+            "hook_prefs_tab", "prefSystem");
100 100
 
101
-		print "</div>"; #container
102
-	}
101
+        print "</div>"; #container
102
+    }
103 103
 
104 104
 }
Please login to merge, or discard this patch.
classes/dlg.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -1,206 +1,206 @@
 block discarded – undo
1 1
 <?php
2 2
 class Dlg extends Handler_Protected {
3
-	private $param;
3
+    private $param;
4 4
     private $params;
5 5
 
6 6
     function before($method) {
7
-		if (parent::before($method)) {
8
-			header("Content-Type: text/html"); # required for iframe
7
+        if (parent::before($method)) {
8
+            header("Content-Type: text/html"); # required for iframe
9 9
 
10
-			$this->param = $_REQUEST["param"];
11
-			return true;
12
-		}
13
-		return false;
14
-	}
10
+            $this->param = $_REQUEST["param"];
11
+            return true;
12
+        }
13
+        return false;
14
+    }
15 15
 
16
-	public function importOpml() {
17
-		print_notice("If you have imported labels and/or filters, you might need to reload preferences to see your new data.");
16
+    public function importOpml() {
17
+        print_notice("If you have imported labels and/or filters, you might need to reload preferences to see your new data.");
18 18
 
19
-		print "<div class='panel panel-scrollable'>";
19
+        print "<div class='panel panel-scrollable'>";
20 20
 
21
-		$opml = new Opml($_REQUEST);
21
+        $opml = new Opml($_REQUEST);
22 22
 
23
-		$opml->opml_import($_SESSION["uid"]);
23
+        $opml->opml_import($_SESSION["uid"]);
24 24
 
25
-		print "</div>";
25
+        print "</div>";
26 26
 
27
-		print "<footer class='text-center'>";
28
-		print "<button dojoType='dijit.form.Button'
27
+        print "<footer class='text-center'>";
28
+        print "<button dojoType='dijit.form.Button'
29 29
 			onclick=\"dijit.byId('opmlImportDlg').execute()\">".
30
-			__('Close this window')."</button>";
31
-		print "</footer>";
30
+            __('Close this window')."</button>";
31
+        print "</footer>";
32 32
 
33
-		print "</div>";
33
+        print "</div>";
34 34
 
35
-		//return;
36
-	}
35
+        //return;
36
+    }
37 37
 
38
-	public function pubOPMLUrl() {
39
-		$url_path = Opml::opml_publish_url();
38
+    public function pubOPMLUrl() {
39
+        $url_path = Opml::opml_publish_url();
40 40
 
41
-		print "<header>" . __("Your Public OPML URL is:") . "</header>";
41
+        print "<header>" . __("Your Public OPML URL is:") . "</header>";
42 42
 
43
-		print "<section>";
43
+        print "<section>";
44 44
 
45
-		print "<div class='panel text-center'>";
46
-		print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
47
-		print "</div>";
45
+        print "<div class='panel text-center'>";
46
+        print "<a id='pub_opml_url' href='$url_path' target='_blank'>$url_path</a>";
47
+        print "</div>";
48 48
 
49
-		print "</section>";
49
+        print "</section>";
50 50
 
51
-		print "<footer class='text-center'>";
51
+        print "<footer class='text-center'>";
52 52
 
53
-		print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">".
54
-			__('Generate new URL')."</button> ";
53
+        print "<button dojoType='dijit.form.Button' onclick=\"return Helpers.OPML.changeKey()\">".
54
+            __('Generate new URL')."</button> ";
55 55
 
56
-		print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">".
57
-			__('Close this window')."</button>";
56
+        print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">".
57
+            __('Close this window')."</button>";
58 58
 
59
-		print "</footer>";
59
+        print "</footer>";
60 60
 
61
-		//return;
62
-	}
61
+        //return;
62
+    }
63 63
 
64
-	public function explainError() {
65
-		print "<div class=\"errorExplained\">";
64
+    public function explainError() {
65
+        print "<div class=\"errorExplained\">";
66 66
 
67
-		if ($this->param == 1) {
68
-			print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
67
+        if ($this->param == 1) {
68
+            print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
69 69
 
70
-			$stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
70
+            $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
71 71
 
72
-			print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
72
+            print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
73 73
 
74
-		}
74
+        }
75 75
 
76
-		if ($this->param == 3) {
77
-			print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
76
+        if ($this->param == 3) {
77
+            print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
78 78
 
79
-			$stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
79
+            $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
80 80
 
81
-			print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
81
+            print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
82 82
 
83
-		}
83
+        }
84 84
 
85
-		print "</div>";
85
+        print "</div>";
86 86
 
87
-		print "<footer class='text-center'>";
88
-		print "<button onclick=\"return CommonDialogs.closeInfoBox()\">".
89
-			__('Close this window')."</button>";
90
-		print "</footer>";
87
+        print "<footer class='text-center'>";
88
+        print "<button onclick=\"return CommonDialogs.closeInfoBox()\">".
89
+            __('Close this window')."</button>";
90
+        print "</footer>";
91 91
 
92
-		//return;
93
-	}
92
+        //return;
93
+    }
94 94
 
95
-	public function printTagCloud() {
96
-		print "<div class='panel text-center'>";
95
+    public function printTagCloud() {
96
+        print "<div class='panel text-center'>";
97 97
 
98
-		// from here: http://www.roscripts.com/Create_tag_cloud-71.html
98
+        // from here: http://www.roscripts.com/Create_tag_cloud-71.html
99 99
 
100
-		$sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count
100
+        $sth = $this->pdo->prepare("SELECT tag_name, COUNT(post_int_id) AS count
101 101
 			FROM ttrss_tags WHERE owner_uid = ?
102 102
 			GROUP BY tag_name ORDER BY count DESC LIMIT 50");
103
-		$sth->execute([$_SESSION['uid']]);
103
+        $sth->execute([$_SESSION['uid']]);
104 104
 
105
-		$tags = array();
105
+        $tags = array();
106 106
 
107
-		while ($line = $sth->fetch()) {
108
-			$tags[$line["tag_name"]] = $line["count"];
109
-		}
107
+        while ($line = $sth->fetch()) {
108
+            $tags[$line["tag_name"]] = $line["count"];
109
+        }
110 110
 
111 111
         if(count($tags) == 0 ){ return; }
112 112
 
113
-		ksort($tags);
113
+        ksort($tags);
114 114
 
115
-		$max_size = 32; // max font size in pixels
116
-		$min_size = 11; // min font size in pixels
115
+        $max_size = 32; // max font size in pixels
116
+        $min_size = 11; // min font size in pixels
117 117
 
118
-		// largest and smallest array values
119
-		$max_qty = max(array_values($tags));
120
-		$min_qty = min(array_values($tags));
118
+        // largest and smallest array values
119
+        $max_qty = max(array_values($tags));
120
+        $min_qty = min(array_values($tags));
121 121
 
122
-		// find the range of values
123
-		$spread = $max_qty - $min_qty;
124
-		if ($spread == 0) { // we don't want to divide by zero
125
-				$spread = 1;
126
-		}
122
+        // find the range of values
123
+        $spread = $max_qty - $min_qty;
124
+        if ($spread == 0) { // we don't want to divide by zero
125
+                $spread = 1;
126
+        }
127 127
 
128
-		// set the font-size increment
129
-		$step = ($max_size - $min_size) / ($spread);
128
+        // set the font-size increment
129
+        $step = ($max_size - $min_size) / ($spread);
130 130
 
131
-		// loop through the tag array
132
-		foreach ($tags as $key => $value) {
133
-			// calculate font-size
134
-			// find the $value in excess of $min_qty
135
-			// multiply by the font-size increment ($size)
136
-			// and add the $min_size set above
137
-			$size = round($min_size + (($value - $min_qty) * $step));
131
+        // loop through the tag array
132
+        foreach ($tags as $key => $value) {
133
+            // calculate font-size
134
+            // find the $value in excess of $min_qty
135
+            // multiply by the font-size increment ($size)
136
+            // and add the $min_size set above
137
+            $size = round($min_size + (($value - $min_qty) * $step));
138 138
 
139
-			$key_escaped = str_replace("'", "\\'", $key);
139
+            $key_escaped = str_replace("'", "\\'", $key);
140 140
 
141
-			echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " .
142
-				$size . "px\" title=\"$value articles tagged with " .
143
-				$key . '">' . $key . '</a> ';
144
-		}
141
+            echo "<a href=\"#\" onclick=\"Feeds.open({feed:'$key_escaped'}) \" style=\"font-size: " .
142
+                $size . "px\" title=\"$value articles tagged with " .
143
+                $key . '">' . $key . '</a> ';
144
+        }
145 145
 
146 146
 
147 147
 
148
-		print "</div>";
148
+        print "</div>";
149 149
 
150
-		print "<footer class='text-center'>";
151
-		print "<button dojoType='dijit.form.Button'
150
+        print "<footer class='text-center'>";
151
+        print "<button dojoType='dijit.form.Button'
152 152
 			onclick=\"return CommonDialogs.closeInfoBox()\">".
153
-			__('Close this window')."</button>";
154
-		print "</footer>";
153
+            __('Close this window')."</button>";
154
+        print "</footer>";
155 155
 
156
-	}
156
+    }
157 157
 
158
-	public function generatedFeed() {
158
+    public function generatedFeed() {
159 159
 
160
-		$this->params = explode(":", $this->param, 3);
161
-		$feed_id = $this->params[0];
162
-		$is_cat = (bool) $this->params[1];
160
+        $this->params = explode(":", $this->param, 3);
161
+        $feed_id = $this->params[0];
162
+        $is_cat = (bool) $this->params[1];
163 163
 
164
-		$key = Feeds::get_feed_access_key($feed_id, $is_cat);
164
+        $key = Feeds::get_feed_access_key($feed_id, $is_cat);
165 165
 
166
-		$url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
166
+        $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
167 167
 
168
-		$feed_title = Feeds::getFeedTitle($feed_id, $is_cat);
168
+        $feed_title = Feeds::getFeedTitle($feed_id, $is_cat);
169 169
 
170
-		print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>";
170
+        print "<header>".T_sprintf("%s can be accessed via the following secret URL:", $feed_title)."</header>";
171 171
 
172
-		print "<section>";
173
-		print "<div class='panel text-center'>";
174
-		print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
175
-		print "</div>";
176
-		print "</section>";
172
+        print "<section>";
173
+        print "<div class='panel text-center'>";
174
+        print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
175
+        print "</div>";
176
+        print "</section>";
177 177
 
178
-		print "<footer>";
178
+        print "<footer>";
179 179
 
180
-		print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'>
180
+        print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/GeneratedFeeds\")'>
181 181
 			<i class='material-icons'>help</i> ".__("More info...")."</button>";
182 182
 
183
-		print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">".
184
-			__('Generate new URL')."</button> ";
183
+        print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">".
184
+            __('Generate new URL')."</button> ";
185 185
 
186
-		print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">".
187
-			__('Close this window')."</button>";
186
+        print "<button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.closeInfoBox()\">".
187
+            __('Close this window')."</button>";
188 188
 
189
-		print "</footer>";
189
+        print "</footer>";
190 190
 
191
-		//return;
192
-	}
191
+        //return;
192
+    }
193 193
 
194
-	public function defaultPasswordWarning() {
194
+    public function defaultPasswordWarning() {
195 195
 
196
-    	print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication)."));
196
+        print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication)."));
197 197
 
198
-		print "<footer class='text-center'>";
199
-		print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">".
200
-			__('Open Preferences')."</button> ";
201
-		print "<button dojoType='dijit.form.Button'
198
+        print "<footer class='text-center'>";
199
+        print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">".
200
+            __('Open Preferences')."</button> ";
201
+        print "<button dojoType='dijit.form.Button'
202 202
 			onclick=\"return CommonDialogs.closeInfoBox()\">".
203
-			__('Close this window')."</button>";
204
-		print "</footeer>";
205
-	}
203
+            __('Close this window')."</button>";
204
+        print "</footeer>";
205
+    }
206 206
 }
Please login to merge, or discard this patch.
classes/logger/sql.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,45 +1,45 @@
 block discarded – undo
1 1
 <?php
2 2
 class Logger_SQL {
3 3
 
4
-	private $pdo;
4
+    private $pdo;
5 5
 
6
-	public function log_error($errno, $errstr, $file, $line, $context) {
6
+    public function log_error($errno, $errstr, $file, $line, $context) {
7 7
 
8
-		// separate PDO connection object is used for logging
9
-		if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect();
8
+        // separate PDO connection object is used for logging
9
+        if (!$this->pdo) $this->pdo = Db::instance()->pdo_connect();
10 10
 
11
-		if ($this->pdo && get_schema_version() > 117) {
11
+        if ($this->pdo && get_schema_version() > 117) {
12 12
 
13
-			$owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null;
13
+            $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null;
14 14
 
15
-			// limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge
16
-			$context = mb_substr($context, 0, 8192);
15
+            // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge
16
+            $context = mb_substr($context, 0, 8192);
17 17
 
18
-			$server_params = [
19
-				"IP" => "REMOTE_ADDR",
20
-				"Request URI" => "REQUEST_URI",
21
-				"User agent" => "HTTP_USER_AGENT",
22
-			];
18
+            $server_params = [
19
+                "IP" => "REMOTE_ADDR",
20
+                "Request URI" => "REQUEST_URI",
21
+                "User agent" => "HTTP_USER_AGENT",
22
+            ];
23 23
 
24
-			foreach ($server_params as $n => $p) {
25
-				if (isset($_SERVER[$p]))
26
-					$context .= "\n$n: " . $_SERVER[$p];
27
-			}
24
+            foreach ($server_params as $n => $p) {
25
+                if (isset($_SERVER[$p]))
26
+                    $context .= "\n$n: " . $_SERVER[$p];
27
+            }
28 28
 
29
-			// passed error message may contain invalid unicode characters, failing to insert an error here
30
-			// would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc
31
-			$errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8');
32
-			$context = UConverter::transcode($context, 'UTF-8', 'UTF-8');
29
+            // passed error message may contain invalid unicode characters, failing to insert an error here
30
+            // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc
31
+            $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8');
32
+            $context = UConverter::transcode($context, 'UTF-8', 'UTF-8');
33 33
 
34
-			$sth = $this->pdo->prepare("INSERT INTO ttrss_error_log
34
+            $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log
35 35
 				(errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
36 36
 				(?, ?, ?, ?, ?, ?, NOW())");
37
-			$sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]);
37
+            $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]);
38 38
 
39
-			return $sth->rowCount();
40
-		}
39
+            return $sth->rowCount();
40
+        }
41 41
 
42
-		return false;
43
-	}
42
+        return false;
43
+    }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
classes/logger/syslog.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,33 +1,33 @@
 block discarded – undo
1 1
 <?php
2 2
 class Logger_Syslog {
3 3
 
4
-	/**
5
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
6
-	 */
7
-	public function log_error($errno, $errstr, $file, $line, $context) {
4
+    /**
5
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
6
+     */
7
+    public function log_error($errno, $errstr, $file, $line, $context) {
8 8
 
9
-		switch ($errno) {
10
-		case E_ERROR:
11
-		case E_PARSE:
12
-		case E_CORE_ERROR:
13
-		case E_COMPILE_ERROR:
14
-		case E_USER_ERROR:
15
-			$priority = LOG_ERR;
16
-			break;
17
-		case E_WARNING:
18
-		case E_CORE_WARNING:
19
-		case E_COMPILE_WARNING:
20
-		case E_USER_WARNING:
21
-			$priority = LOG_WARNING;
22
-			break;
23
-		default:
24
-			$priority = LOG_INFO;
25
-		}
9
+        switch ($errno) {
10
+        case E_ERROR:
11
+        case E_PARSE:
12
+        case E_CORE_ERROR:
13
+        case E_COMPILE_ERROR:
14
+        case E_USER_ERROR:
15
+            $priority = LOG_ERR;
16
+            break;
17
+        case E_WARNING:
18
+        case E_CORE_WARNING:
19
+        case E_COMPILE_WARNING:
20
+        case E_USER_WARNING:
21
+            $priority = LOG_WARNING;
22
+            break;
23
+        default:
24
+            $priority = LOG_INFO;
25
+        }
26 26
 
27
-		$errname = Logger::$errornames[$errno] . " ($errno)";
27
+        $errname = Logger::$errornames[$errno] . " ($errno)";
28 28
 
29
-		syslog($priority, "[tt-rss] $errname ($file:$line) $errstr");
29
+        syslog($priority, "[tt-rss] $errname ($file:$line) $errstr");
30 30
 
31
-	}
31
+    }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
classes/db/prefs.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Db_Prefs {
3
-	private $pdo;
4
-	private static $instance;
5
-	private $cache;
3
+    private $pdo;
4
+    private static $instance;
5
+    private $cache;
6 6
 
7
-	public function __construct() {
8
-		$this->pdo = Db::pdo();
9
-		$this->cache = array();
7
+    public function __construct() {
8
+        $this->pdo = Db::pdo();
9
+        $this->cache = array();
10 10
 
11
-		if ($_SESSION["uid"]) $this->cache();
12
-	}
11
+        if ($_SESSION["uid"]) $this->cache();
12
+    }
13 13
 
14
-	public static function get() {
15
-		if (self::$instance == null)
16
-			self::$instance = new self();
14
+    public static function get() {
15
+        if (self::$instance == null)
16
+            self::$instance = new self();
17 17
 
18
-		return self::$instance;
19
-	}
18
+        return self::$instance;
19
+    }
20 20
 
21
-	public function cache() {
22
-		$user_id = $_SESSION["uid"];
23
-		@$profile = $_SESSION["profile"];
21
+    public function cache() {
22
+        $user_id = $_SESSION["uid"];
23
+        @$profile = $_SESSION["profile"];
24 24
 
25
-		if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
25
+        if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
26 26
 
27
-		$sth = $this->pdo->prepare("SELECT
27
+        $sth = $this->pdo->prepare("SELECT
28 28
 			value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name
29 29
 			FROM
30 30
 				ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 				owner_uid = :uid AND
36 36
 				ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
37 37
 
38
-		$sth->execute([":profile" => $profile, ":uid" => $user_id]);
38
+        $sth->execute([":profile" => $profile, ":uid" => $user_id]);
39 39
 
40
-		while ($line = $sth->fetch()) {
41
-			if ($user_id == $_SESSION["uid"]) {
42
-				$pref_name = $line["pref_name"];
40
+        while ($line = $sth->fetch()) {
41
+            if ($user_id == $_SESSION["uid"]) {
42
+                $pref_name = $line["pref_name"];
43 43
 
44
-				$this->cache[$pref_name]["type"] = $line["type_name"];
45
-				$this->cache[$pref_name]["value"] = $line["value"];
46
-			}
47
-		}
48
-	}
44
+                $this->cache[$pref_name]["type"] = $line["type_name"];
45
+                $this->cache[$pref_name]["value"] = $line["value"];
46
+            }
47
+        }
48
+    }
49 49
 
50
-	public function read($pref_name, $user_id = false, $die_on_error = false) {
50
+    public function read($pref_name, $user_id = false, $die_on_error = false) {
51 51
 
52
-		if (!$user_id) {
53
-			$user_id = $_SESSION["uid"];
54
-			@$profile = $_SESSION["profile"];
55
-		} else {
56
-			$profile = false;
57
-		}
52
+        if (!$user_id) {
53
+            $user_id = $_SESSION["uid"];
54
+            @$profile = $_SESSION["profile"];
55
+        } else {
56
+            $profile = false;
57
+        }
58 58
 
59
-		if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) {
60
-			$tuple = $this->cache[$pref_name];
61
-			return $this->convert($tuple["value"], $tuple["type"]);
62
-		}
59
+        if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) {
60
+            $tuple = $this->cache[$pref_name];
61
+            return $this->convert($tuple["value"], $tuple["type"]);
62
+        }
63 63
 
64
-		if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
64
+        if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
65 65
 
66
-		$sth = $this->pdo->prepare("SELECT
66
+        $sth = $this->pdo->prepare("SELECT
67 67
 			value,ttrss_prefs_types.type_name as type_name
68 68
 			FROM
69 69
 				ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
@@ -73,96 +73,96 @@  discard block
 block discarded – undo
73 73
 				ttrss_prefs_types.id = type_id AND
74 74
 				owner_uid = :uid AND
75 75
 				ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
76
-		$sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]);
77
-
78
-		if ($row = $sth->fetch()) {
79
-			$value = $row["value"];
80
-			$type_name = $row["type_name"];
81
-
82
-			if ($user_id == $_SESSION["uid"]) {
83
-				$this->cache[$pref_name]["type"] = $type_name;
84
-				$this->cache[$pref_name]["value"] = $value;
85
-			}
86
-
87
-			return $this->convert($value, $type_name);
88
-
89
-		} else if ($die_on_error) {
90
-			user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR);
91
-			return null;
92
-		} else {
93
-			return null;
94
-		}
95
-	}
96
-
97
-	public function convert($value, $type_name) {
98
-		if ($type_name == "bool") {
99
-			return $value == "true";
100
-		} else if ($type_name == "integer") {
101
-			return (int)$value;
102
-		} else {
103
-			return $value;
104
-		}
105
-	}
106
-
107
-	public function write($pref_name, $value, $user_id = false, $strip_tags = true) {
108
-		if ($strip_tags) $value = strip_tags($value);
109
-
110
-		if (!$user_id) {
111
-			$user_id = $_SESSION["uid"];
112
-			@$profile = $_SESSION["profile"];
113
-		} else {
114
-			$profile = null;
115
-		}
116
-
117
-		if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
118
-
119
-		$type_name = "";
120
-		$current_value = "";
121
-
122
-		if (isset($this->cache[$pref_name])) {
123
-			$type_name = $this->cache[$pref_name]["type"];
124
-			$current_value = $this->cache[$pref_name]["value"];
125
-		}
126
-
127
-		if (!$type_name) {
128
-			$sth = $this->pdo->prepare("SELECT type_name
76
+        $sth->execute([":uid" => $user_id, ":profile" => $profile, ":pref_name" => $pref_name]);
77
+
78
+        if ($row = $sth->fetch()) {
79
+            $value = $row["value"];
80
+            $type_name = $row["type_name"];
81
+
82
+            if ($user_id == $_SESSION["uid"]) {
83
+                $this->cache[$pref_name]["type"] = $type_name;
84
+                $this->cache[$pref_name]["value"] = $value;
85
+            }
86
+
87
+            return $this->convert($value, $type_name);
88
+
89
+        } else if ($die_on_error) {
90
+            user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", E_USER_ERROR);
91
+            return null;
92
+        } else {
93
+            return null;
94
+        }
95
+    }
96
+
97
+    public function convert($value, $type_name) {
98
+        if ($type_name == "bool") {
99
+            return $value == "true";
100
+        } else if ($type_name == "integer") {
101
+            return (int)$value;
102
+        } else {
103
+            return $value;
104
+        }
105
+    }
106
+
107
+    public function write($pref_name, $value, $user_id = false, $strip_tags = true) {
108
+        if ($strip_tags) $value = strip_tags($value);
109
+
110
+        if (!$user_id) {
111
+            $user_id = $_SESSION["uid"];
112
+            @$profile = $_SESSION["profile"];
113
+        } else {
114
+            $profile = null;
115
+        }
116
+
117
+        if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
118
+
119
+        $type_name = "";
120
+        $current_value = "";
121
+
122
+        if (isset($this->cache[$pref_name])) {
123
+            $type_name = $this->cache[$pref_name]["type"];
124
+            $current_value = $this->cache[$pref_name]["value"];
125
+        }
126
+
127
+        if (!$type_name) {
128
+            $sth = $this->pdo->prepare("SELECT type_name
129 129
 				FROM ttrss_prefs,ttrss_prefs_types
130 130
 				WHERE pref_name = ? AND type_id = ttrss_prefs_types.id");
131
-			$sth->execute([$pref_name]);
132
-
133
-			if ($row = $sth->fetch())
134
-				$type_name = $row["type_name"];
135
-
136
-		} else if ($current_value == $value) {
137
-			return;
138
-		}
139
-
140
-		if ($type_name) {
141
-			if ($type_name == "bool") {
142
-				if ($value == "1" || $value == "true") {
143
-					$value = "true";
144
-				} else {
145
-					$value = "false";
146
-				}
147
-			} else if ($type_name == "integer") {
148
-				$value = (int)$value;
149
-			}
150
-
151
-			if ($pref_name == 'USER_TIMEZONE' && $value == '') {
152
-				$value = 'UTC';
153
-			}
154
-
155
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET
131
+            $sth->execute([$pref_name]);
132
+
133
+            if ($row = $sth->fetch())
134
+                $type_name = $row["type_name"];
135
+
136
+        } else if ($current_value == $value) {
137
+            return;
138
+        }
139
+
140
+        if ($type_name) {
141
+            if ($type_name == "bool") {
142
+                if ($value == "1" || $value == "true") {
143
+                    $value = "true";
144
+                } else {
145
+                    $value = "false";
146
+                }
147
+            } else if ($type_name == "integer") {
148
+                $value = (int)$value;
149
+            }
150
+
151
+            if ($pref_name == 'USER_TIMEZONE' && $value == '') {
152
+                $value = 'UTC';
153
+            }
154
+
155
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_prefs SET
156 156
 				value = :value WHERE pref_name = :pref_name
157 157
 					AND (profile = :profile OR (:profile IS NULL AND profile IS NULL))
158 158
 					AND owner_uid = :uid");
159 159
 
160
-			$sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]);
160
+            $sth->execute([":pref_name" => $pref_name, ":value" => $value, ":uid" => $user_id, ":profile" => $profile]);
161 161
 
162
-			if ($user_id == $_SESSION["uid"]) {
163
-				$this->cache[$pref_name]["type"] = $type_name;
164
-				$this->cache[$pref_name]["value"] = $value;
165
-			}
166
-		}
167
-	}
162
+            if ($user_id == $_SESSION["uid"]) {
163
+                $this->cache[$pref_name]["type"] = $type_name;
164
+                $this->cache[$pref_name]["value"] = $value;
165
+            }
166
+        }
167
+    }
168 168
 }
Please login to merge, or discard this patch.
classes/db/pgsql.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,91 +1,91 @@
 block discarded – undo
1 1
 <?php
2 2
 class Db_Pgsql implements IDb {
3
-	private $link;
4
-	private $last_error;
3
+    private $link;
4
+    private $last_error;
5 5
 
6
-	public function connect($host, $user, $pass, $db, $port) {
7
-		$string = "dbname=$db user=$user";
6
+    public function connect($host, $user, $pass, $db, $port) {
7
+        $string = "dbname=$db user=$user";
8 8
 
9
-		if ($pass) {
10
-			$string .= " password=$pass";
11
-		}
9
+        if ($pass) {
10
+            $string .= " password=$pass";
11
+        }
12 12
 
13
-		if ($host) {
14
-			$string .= " host=$host";
15
-		}
13
+        if ($host) {
14
+            $string .= " host=$host";
15
+        }
16 16
 
17
-		if (is_numeric($port) && $port > 0) {
18
-			$string = "$string port=" . $port;
19
-		}
17
+        if (is_numeric($port) && $port > 0) {
18
+            $string = "$string port=" . $port;
19
+        }
20 20
 
21
-		$this->link = pg_connect($string);
21
+        $this->link = pg_connect($string);
22 22
 
23
-		if (!$this->link) {
24
-			print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
25
-			exit(102);
26
-		}
23
+        if (!$this->link) {
24
+            print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
25
+            exit(102);
26
+        }
27 27
 
28
-		$this->init();
28
+        $this->init();
29 29
 
30
-		return $this->link;
31
-	}
30
+        return $this->link;
31
+    }
32 32
 
33
-	public function escape_string($s, $strip_tags = true) {
34
-		if ($strip_tags) $s = strip_tags($s);
33
+    public function escape_string($s, $strip_tags = true) {
34
+        if ($strip_tags) $s = strip_tags($s);
35 35
 
36
-		return pg_escape_string($s);
37
-	}
36
+        return pg_escape_string($s);
37
+    }
38 38
 
39
-	public function query($query, $die_on_error = true) {
40
-		$result = @pg_query($this->link, $query);
39
+    public function query($query, $die_on_error = true) {
40
+        $result = @pg_query($this->link, $query);
41 41
 
42
-		if (!$result) {
43
-			$this->last_error = @pg_last_error($this->link);
42
+        if (!$result) {
43
+            $this->last_error = @pg_last_error($this->link);
44 44
 
45
-			@pg_query($this->link, "ROLLBACK");
46
-			$query = htmlspecialchars($query); // just in case
47
-			user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"),
48
-				$die_on_error ? E_USER_ERROR : E_USER_WARNING);
49
-		}
50
-		return $result;
51
-	}
45
+            @pg_query($this->link, "ROLLBACK");
46
+            $query = htmlspecialchars($query); // just in case
47
+            user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"),
48
+                $die_on_error ? E_USER_ERROR : E_USER_WARNING);
49
+        }
50
+        return $result;
51
+    }
52 52
 
53
-	public function fetch_assoc($result) {
54
-		return pg_fetch_assoc($result);
55
-	}
53
+    public function fetch_assoc($result) {
54
+        return pg_fetch_assoc($result);
55
+    }
56 56
 
57 57
 
58
-	public function num_rows($result) {
59
-		return pg_num_rows($result);
60
-	}
58
+    public function num_rows($result) {
59
+        return pg_num_rows($result);
60
+    }
61 61
 
62
-	public function fetch_result($result, $row, $param) {
63
-		return pg_fetch_result($result, $row, $param);
64
-	}
62
+    public function fetch_result($result, $row, $param) {
63
+        return pg_fetch_result($result, $row, $param);
64
+    }
65 65
 
66
-	public function close() {
67
-		return pg_close($this->link);
68
-	}
66
+    public function close() {
67
+        return pg_close($this->link);
68
+    }
69 69
 
70
-	public function affected_rows($result) {
71
-		return pg_affected_rows($result);
72
-	}
70
+    public function affected_rows($result) {
71
+        return pg_affected_rows($result);
72
+    }
73 73
 
74
-	public function last_error() {
75
-		return pg_last_error($this->link);
76
-	}
74
+    public function last_error() {
75
+        return pg_last_error($this->link);
76
+    }
77 77
 
78
-	public function last_query_error() {
79
-		return $this->last_error;
80
-	}
78
+    public function last_query_error() {
79
+        return $this->last_error;
80
+    }
81 81
 
82
-	public function init() {
83
-		$this->query("set client_encoding = 'UTF-8'");
84
-		pg_set_client_encoding("UNICODE");
85
-		$this->query("set datestyle = 'ISO, european'");
86
-		$this->query("set TIME ZONE 0");
87
-		$this->query("set cpu_tuple_cost = 0.5");
82
+    public function init() {
83
+        $this->query("set client_encoding = 'UTF-8'");
84
+        pg_set_client_encoding("UNICODE");
85
+        $this->query("set datestyle = 'ISO, european'");
86
+        $this->query("set TIME ZONE 0");
87
+        $this->query("set cpu_tuple_cost = 0.5");
88 88
 
89
-		return true;
90
-	}
89
+        return true;
90
+    }
91 91
 }
Please login to merge, or discard this patch.
classes/db/mysqli.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -1,85 +1,85 @@
 block discarded – undo
1 1
 <?php
2 2
 class Db_Mysqli implements IDb {
3
-	private $link;
4
-	private $last_error;
5
-
6
-	public function connect($host, $user, $pass, $db, $port) {
7
-		if ($port)
8
-			$this->link = mysqli_connect($host, $user, $pass, $db, $port);
9
-		else
10
-			$this->link = mysqli_connect($host, $user, $pass, $db);
11
-
12
-		if ($this->link) {
13
-			$this->init();
14
-
15
-			return $this->link;
16
-		} else {
17
-			print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error());
18
-			exit(102);
19
-		}
20
-	}
21
-
22
-	public function escape_string($s, $strip_tags = true) {
23
-		if ($strip_tags) $s = strip_tags($s);
24
-
25
-		return mysqli_real_escape_string($this->link, $s);
26
-	}
27
-
28
-	public function query($query, $die_on_error = true) {
29
-		$result = @mysqli_query($this->link, $query);
30
-		if (!$result) {
31
-			$this->last_error = @mysqli_error($this->link);
32
-
33
-			@mysqli_query($this->link, "ROLLBACK");
34
-			user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"),
35
-				$die_on_error ? E_USER_ERROR : E_USER_WARNING);
36
-		}
37
-
38
-		return $result;
39
-	}
40
-
41
-	public function fetch_assoc($result) {
42
-		return mysqli_fetch_assoc($result);
43
-	}
44
-
45
-
46
-	public function num_rows($result) {
47
-		return mysqli_num_rows($result);
48
-	}
49
-
50
-	public function fetch_result($result, $row, $param) {
51
-		if (mysqli_data_seek($result, $row)) {
52
-			$line = mysqli_fetch_assoc($result);
53
-			return $line[$param];
54
-		} else {
55
-			return false;
56
-		}
57
-	}
58
-
59
-	public function close() {
60
-		return mysqli_close($this->link);
61
-	}
62
-
63
-	public function affected_rows($result) {
64
-		return mysqli_affected_rows($this->link);
65
-	}
66
-
67
-	public function last_error() {
68
-		return mysqli_error($this->link);
69
-	}
70
-
71
-	public function last_query_error() {
72
-		return $this->last_error;
73
-	}
74
-
75
-	public function init() {
76
-		$this->query("SET time_zone = '+0:0'");
77
-
78
-		if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
79
-			mysqli_set_charset($this->link, MYSQL_CHARSET);
80
-		}
81
-
82
-		return true;
83
-	}
3
+    private $link;
4
+    private $last_error;
5
+
6
+    public function connect($host, $user, $pass, $db, $port) {
7
+        if ($port)
8
+            $this->link = mysqli_connect($host, $user, $pass, $db, $port);
9
+        else
10
+            $this->link = mysqli_connect($host, $user, $pass, $db);
11
+
12
+        if ($this->link) {
13
+            $this->init();
14
+
15
+            return $this->link;
16
+        } else {
17
+            print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error());
18
+            exit(102);
19
+        }
20
+    }
21
+
22
+    public function escape_string($s, $strip_tags = true) {
23
+        if ($strip_tags) $s = strip_tags($s);
24
+
25
+        return mysqli_real_escape_string($this->link, $s);
26
+    }
27
+
28
+    public function query($query, $die_on_error = true) {
29
+        $result = @mysqli_query($this->link, $query);
30
+        if (!$result) {
31
+            $this->last_error = @mysqli_error($this->link);
32
+
33
+            @mysqli_query($this->link, "ROLLBACK");
34
+            user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"),
35
+                $die_on_error ? E_USER_ERROR : E_USER_WARNING);
36
+        }
37
+
38
+        return $result;
39
+    }
40
+
41
+    public function fetch_assoc($result) {
42
+        return mysqli_fetch_assoc($result);
43
+    }
44
+
45
+
46
+    public function num_rows($result) {
47
+        return mysqli_num_rows($result);
48
+    }
49
+
50
+    public function fetch_result($result, $row, $param) {
51
+        if (mysqli_data_seek($result, $row)) {
52
+            $line = mysqli_fetch_assoc($result);
53
+            return $line[$param];
54
+        } else {
55
+            return false;
56
+        }
57
+    }
58
+
59
+    public function close() {
60
+        return mysqli_close($this->link);
61
+    }
62
+
63
+    public function affected_rows($result) {
64
+        return mysqli_affected_rows($this->link);
65
+    }
66
+
67
+    public function last_error() {
68
+        return mysqli_error($this->link);
69
+    }
70
+
71
+    public function last_query_error() {
72
+        return $this->last_error;
73
+    }
74
+
75
+    public function init() {
76
+        $this->query("SET time_zone = '+0:0'");
77
+
78
+        if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
79
+            mysqli_set_charset($this->link, MYSQL_CHARSET);
80
+        }
81
+
82
+        return true;
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.