Passed
Push — master ( a3c0d0...678db7 )
by Cody
06:27 queued 03:12
created
lib/phpqrcode/qrspec.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -335,10 +335,10 @@
 block discarded – undo
335 335
 
336 336
         // Version information pattern -----------------------------------------
337 337
 
338
-		// Version information pattern (BCH coded).
338
+        // Version information pattern (BCH coded).
339 339
         // See Table 1 in Appendix D (pp.68) of JIS X0510:2004.
340 340
         
341
-		// size: [QRSPEC_VERSION_MAX - 6]
341
+        // size: [QRSPEC_VERSION_MAX - 6]
342 342
 		
343 343
         public static $versionPattern = array(
344 344
             0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d,
Please login to merge, or discard this patch.
lib/phpqrcode/qrmask.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 26
  */
27 27
  
28
-	define('N1', 3);
29
-	define('N2', 3);
30
-	define('N3', 40);
31
-	define('N4', 10);
28
+    define('N1', 3);
29
+    define('N2', 3);
30
+    define('N3', 40);
31
+    define('N4', 10);
32 32
 
33
-	class QRmask {
33
+    class QRmask {
34 34
 	
35
-		public $runLength = array();
35
+        public $runLength = array();
36 36
 		
37
-		//----------------------------------------------------------------------
38
-		public function __construct() 
37
+        //----------------------------------------------------------------------
38
+        public function __construct() 
39 39
         {
40 40
             $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0);
41 41
         }
Please login to merge, or discard this patch.
lib/MiniTemplator.class.php 1 patch
Indentation   +383 added lines, -383 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 * @access public
162 162
 */
163 163
 function __construct() {
164
-   $this->templateValid = false; }
164
+    $this->templateValid = false; }
165 165
 
166 166
 //--- template string handling --------------------------------------------------------------------------------------
167 167
 
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 * @access public
173 173
 */
174 174
 function readTemplateFromFile ($fileName) {
175
-   if (!$this->readFileIntoString($fileName,$s)) {
176
-      $this->triggerError ("Error while reading template file " . $fileName . ".");
177
-      return false; }
178
-   if (!$this->setTemplateString($s)) return false;
179
-   return true; }
175
+    if (!$this->readFileIntoString($fileName,$s)) {
176
+        $this->triggerError ("Error while reading template file " . $fileName . ".");
177
+        return false; }
178
+    if (!$this->setTemplateString($s)) return false;
179
+    return true; }
180 180
 
181 181
 /**
182 182
 * Assigns a new template string.
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 * @access public
186 186
 */
187 187
 function setTemplateString ($templateString) {
188
-   $this->templateValid = false;
189
-   $this->template = $templateString;
190
-   if (!$this->parseTemplate()) return false;
191
-   $this->reset();
192
-   $this->templateValid = true;
193
-   return true; }
188
+    $this->templateValid = false;
189
+    $this->template = $templateString;
190
+    if (!$this->parseTemplate()) return false;
191
+    $this->reset();
192
+    $this->templateValid = true;
193
+    return true; }
194 194
 
195 195
 /**
196 196
 * Loads the template string for a subtemplate (used for the $Include command).
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 * @access private
199 199
 */
200 200
 function loadSubtemplate ($subtemplateName, &$s) {
201
-   $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath,$subtemplateName);
202
-   if (!$this->readFileIntoString($subtemplateFileName,$s)) {
203
-      $this->triggerError ("Error while reading subtemplate file " . $subtemplateFileName . ".");
204
-      return false; }
205
-   return true; }
201
+    $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath,$subtemplateName);
202
+    if (!$this->readFileIntoString($subtemplateFileName,$s)) {
203
+        $this->triggerError ("Error while reading subtemplate file " . $subtemplateFileName . ".");
204
+        return false; }
205
+    return true; }
206 206
 
207 207
 //--- template parsing ----------------------------------------------------------------------------------------------
208 208
 
@@ -212,28 +212,28 @@  discard block
 block discarded – undo
212 212
 * @access private
213 213
 */
214 214
 function parseTemplate() {
215
-   $this->initParsing();
216
-   $this->beginMainBlock();
217
-   if (!$this->parseTemplateCommands()) return false;
218
-   $this->endMainBlock();
219
-   if (!$this->checkBlockDefinitionsComplete()) return false;
220
-   if (!$this->parseTemplateVariables()) return false;
221
-   $this->associateVariablesWithBlocks();
222
-   return true; }
215
+    $this->initParsing();
216
+    $this->beginMainBlock();
217
+    if (!$this->parseTemplateCommands()) return false;
218
+    $this->endMainBlock();
219
+    if (!$this->checkBlockDefinitionsComplete()) return false;
220
+    if (!$this->parseTemplateVariables()) return false;
221
+    $this->associateVariablesWithBlocks();
222
+    return true; }
223 223
 
224 224
 /**
225 225
 * @access private
226 226
 */
227 227
 function initParsing() {
228
-   $this->varTab = array();
229
-   $this->varTabCnt = 0;
230
-   $this->varNameToNoMap = array();
231
-   $this->varRefTab = array();
232
-   $this->varRefTabCnt = 0;
233
-   $this->blockTab = array();
234
-   $this->blockTabCnt = 0;
235
-   $this->blockNameToNoMap = array();
236
-   $this->openBlocksTab = array(); }
228
+    $this->varTab = array();
229
+    $this->varTabCnt = 0;
230
+    $this->varNameToNoMap = array();
231
+    $this->varRefTab = array();
232
+    $this->varRefTabCnt = 0;
233
+    $this->blockTab = array();
234
+    $this->blockTabCnt = 0;
235
+    $this->blockNameToNoMap = array();
236
+    $this->openBlocksTab = array(); }
237 237
 
238 238
 /**
239 239
 * Registers the main block.
@@ -241,27 +241,27 @@  discard block
 block discarded – undo
241 241
 * @access private
242 242
 */
243 243
 function beginMainBlock() {
244
-   $blockNo = 0;
245
-   $this->registerBlock('@@InternalMainBlock@@', $blockNo);
246
-   $bte =& $this->blockTab[$blockNo];
247
-   $bte['tPosBegin'] = 0;
248
-   $bte['tPosContentsBegin'] = 0;
249
-   $bte['nestingLevel'] = 0;
250
-   $bte['parentBlockNo'] = -1;
251
-   $bte['definitionIsOpen'] = true;
252
-   $this->openBlocksTab[0] = $blockNo;
253
-   $this->currentNestingLevel = 1; }
244
+    $blockNo = 0;
245
+    $this->registerBlock('@@InternalMainBlock@@', $blockNo);
246
+    $bte =& $this->blockTab[$blockNo];
247
+    $bte['tPosBegin'] = 0;
248
+    $bte['tPosContentsBegin'] = 0;
249
+    $bte['nestingLevel'] = 0;
250
+    $bte['parentBlockNo'] = -1;
251
+    $bte['definitionIsOpen'] = true;
252
+    $this->openBlocksTab[0] = $blockNo;
253
+    $this->currentNestingLevel = 1; }
254 254
 
255 255
 /**
256 256
 * Completes the main block registration.
257 257
 * @access private
258 258
 */
259 259
 function endMainBlock() {
260
-   $bte =& $this->blockTab[0];
261
-   $bte['tPosContentsEnd'] = strlen($this->template);
262
-   $bte['tPosEnd'] = strlen($this->template);
263
-   $bte['definitionIsOpen'] = false;
264
-   $this->currentNestingLevel -= 1; }
260
+    $bte =& $this->blockTab[0];
261
+    $bte['tPosContentsEnd'] = strlen($this->template);
262
+    $bte['tPosEnd'] = strlen($this->template);
263
+    $bte['definitionIsOpen'] = false;
264
+    $this->currentNestingLevel -= 1; }
265 265
 
266 266
 /**
267 267
 * Parses commands within the template in the format "<!-- $command parameters -->".
@@ -269,46 +269,46 @@  discard block
 block discarded – undo
269 269
 * @access private
270 270
 */
271 271
 function parseTemplateCommands() {
272
-   $p = 0;
273
-   while (true) {
274
-      $p0 = strpos($this->template,'<!--',$p);
275
-      if ($p0 === false) break;
276
-      $p = strpos($this->template,'-->',$p0);
277
-      if ($p === false) {
278
-         $this->triggerError ("Invalid HTML comment in template at offset $p0.");
279
-         return false; }
280
-      $p += 3;
281
-      $cmdL = substr($this->template,$p0+4,$p-$p0-7);
282
-      if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart))
283
-         return false;
284
-      if ($resumeFromStart) $p = $p0; }
285
-   return true; }
272
+    $p = 0;
273
+    while (true) {
274
+        $p0 = strpos($this->template,'<!--',$p);
275
+        if ($p0 === false) break;
276
+        $p = strpos($this->template,'-->',$p0);
277
+        if ($p === false) {
278
+            $this->triggerError ("Invalid HTML comment in template at offset $p0.");
279
+            return false; }
280
+        $p += 3;
281
+        $cmdL = substr($this->template,$p0+4,$p-$p0-7);
282
+        if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart))
283
+            return false;
284
+        if ($resumeFromStart) $p = $p0; }
285
+    return true; }
286 286
 
287 287
 /**
288 288
 * @return boolean  true on success, false on error.
289 289
 * @access private
290 290
 */
291 291
 function processTemplateCommand ($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFromStart) {
292
-   $resumeFromStart = false;
293
-   $p = 0;
294
-   $cmd = '';
295
-   if (!$this->parseWord($cmdL,$p,$cmd)) return true;
296
-   $parms = substr($cmdL,$p);
297
-   switch (strtoupper($cmd)) {
298
-      case '$BEGINBLOCK':
292
+    $resumeFromStart = false;
293
+    $p = 0;
294
+    $cmd = '';
295
+    if (!$this->parseWord($cmdL,$p,$cmd)) return true;
296
+    $parms = substr($cmdL,$p);
297
+    switch (strtoupper($cmd)) {
298
+        case '$BEGINBLOCK':
299 299
          if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
300 300
             return false;
301
-         break;
302
-      case '$ENDBLOCK':
301
+            break;
302
+        case '$ENDBLOCK':
303 303
          if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
304 304
             return false;
305
-         break;
306
-      case '$INCLUDE':
305
+            break;
306
+        case '$INCLUDE':
307 307
          if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
308 308
             return false;
309
-         $resumeFromStart = true;
310
-         break;
311
-      default:
309
+            $resumeFromStart = true;
310
+            break;
311
+        default:
312 312
          if ($cmd{0} == '$' && !(strlen($cmd) >= 2 && $cmd{1} == '{')) {
313 313
             $this->triggerError ("Unknown command \"$cmd\" in template at offset $cmdTPosBegin.");
314 314
             return false; }}
@@ -320,25 +320,25 @@  discard block
 block discarded – undo
320 320
 * @access private
321 321
 */
322 322
 function processBeginBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
323
-   $p = 0;
324
-   if (!$this->parseWord($parms,$p,$blockName)) {
325
-      $this->triggerError ("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin.");
326
-      return false; }
327
-   if (trim(substr($parms,$p)) != '') {
328
-      $this->triggerError ("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin.");
329
-      return false; }
330
-   $this->registerBlock ($blockName, $blockNo);
331
-   $btr =& $this->blockTab[$blockNo];
332
-   $btr['tPosBegin'] = $cmdTPosBegin;
333
-   $btr['tPosContentsBegin'] = $cmdTPosEnd;
334
-   $btr['nestingLevel'] = $this->currentNestingLevel;
335
-   $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel-1];
336
-   $this->openBlocksTab[$this->currentNestingLevel] = $blockNo;
337
-   $this->currentNestingLevel += 1;
338
-   if ($this->currentNestingLevel > $this->maxNestingLevel) {
339
-      $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin.");
340
-      return false; }
341
-   return true; }
323
+    $p = 0;
324
+    if (!$this->parseWord($parms,$p,$blockName)) {
325
+        $this->triggerError ("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin.");
326
+        return false; }
327
+    if (trim(substr($parms,$p)) != '') {
328
+        $this->triggerError ("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin.");
329
+        return false; }
330
+    $this->registerBlock ($blockName, $blockNo);
331
+    $btr =& $this->blockTab[$blockNo];
332
+    $btr['tPosBegin'] = $cmdTPosBegin;
333
+    $btr['tPosContentsBegin'] = $cmdTPosEnd;
334
+    $btr['nestingLevel'] = $this->currentNestingLevel;
335
+    $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel-1];
336
+    $this->openBlocksTab[$this->currentNestingLevel] = $blockNo;
337
+    $this->currentNestingLevel += 1;
338
+    if ($this->currentNestingLevel > $this->maxNestingLevel) {
339
+        $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin.");
340
+        return false; }
341
+    return true; }
342 342
 
343 343
 /**
344 344
 * Processes the $EndBlock command.
@@ -346,47 +346,47 @@  discard block
 block discarded – undo
346 346
 * @access private
347 347
 */
348 348
 function processEndBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
349
-   $p = 0;
350
-   if (!$this->parseWord($parms,$p,$blockName)) {
351
-      $this->triggerError ("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin.");
352
-      return false; }
353
-   if (trim(substr($parms,$p)) != '') {
354
-      $this->triggerError ("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin.");
355
-      return false; }
356
-   if (!$this->lookupBlockName($blockName,$blockNo)) {
357
-      $this->triggerError ("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin.");
358
-      return false; }
359
-   $this->currentNestingLevel -= 1;
360
-   $btr =& $this->blockTab[$blockNo];
361
-   if (!$btr['definitionIsOpen']) {
362
-      $this->triggerError ("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
363
-      return false; }
364
-   if ($btr['nestingLevel'] != $this->currentNestingLevel) {
365
-      $this->triggerError ("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
366
-      return false; }
367
-   $btr['tPosContentsEnd'] = $cmdTPosBegin;
368
-   $btr['tPosEnd'] = $cmdTPosEnd;
369
-   $btr['definitionIsOpen'] = false;
370
-   return true; }
349
+    $p = 0;
350
+    if (!$this->parseWord($parms,$p,$blockName)) {
351
+        $this->triggerError ("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin.");
352
+        return false; }
353
+    if (trim(substr($parms,$p)) != '') {
354
+        $this->triggerError ("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin.");
355
+        return false; }
356
+    if (!$this->lookupBlockName($blockName,$blockNo)) {
357
+        $this->triggerError ("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin.");
358
+        return false; }
359
+    $this->currentNestingLevel -= 1;
360
+    $btr =& $this->blockTab[$blockNo];
361
+    if (!$btr['definitionIsOpen']) {
362
+        $this->triggerError ("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
363
+        return false; }
364
+    if ($btr['nestingLevel'] != $this->currentNestingLevel) {
365
+        $this->triggerError ("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
366
+        return false; }
367
+    $btr['tPosContentsEnd'] = $cmdTPosBegin;
368
+    $btr['tPosEnd'] = $cmdTPosEnd;
369
+    $btr['definitionIsOpen'] = false;
370
+    return true; }
371 371
 
372 372
 /**
373 373
 * @access private
374 374
 */
375 375
 function registerBlock($blockName, &$blockNo) {
376
-   $blockNo = $this->blockTabCnt++;
377
-   $btr =& $this->blockTab[$blockNo];
378
-   $btr = array();
379
-   $btr['blockName'] = $blockName;
380
-   if (!$this->lookupBlockName($blockName,$btr['nextWithSameName']))
381
-      $btr['nextWithSameName'] = -1;
382
-   $btr['definitionIsOpen'] = true;
383
-   $btr['instances'] = 0;
384
-   $btr['firstBlockInstNo'] = -1;
385
-   $btr['lastBlockInstNo'] = -1;
386
-   $btr['blockVarCnt'] = 0;
387
-   $btr['firstVarRefNo'] = -1;
388
-   $btr['blockVarNoToVarNoMap'] = array();
389
-   $this->blockNameToNoMap[strtoupper($blockName)] = $blockNo; }
376
+    $blockNo = $this->blockTabCnt++;
377
+    $btr =& $this->blockTab[$blockNo];
378
+    $btr = array();
379
+    $btr['blockName'] = $blockName;
380
+    if (!$this->lookupBlockName($blockName,$btr['nextWithSameName']))
381
+        $btr['nextWithSameName'] = -1;
382
+    $btr['definitionIsOpen'] = true;
383
+    $btr['instances'] = 0;
384
+    $btr['firstBlockInstNo'] = -1;
385
+    $btr['lastBlockInstNo'] = -1;
386
+    $btr['blockVarCnt'] = 0;
387
+    $btr['firstVarRefNo'] = -1;
388
+    $btr['blockVarNoToVarNoMap'] = array();
389
+    $this->blockNameToNoMap[strtoupper($blockName)] = $blockNo; }
390 390
 
391 391
 /**
392 392
 * Checks that all block definitions are closed.
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
 * @access private
395 395
 */
396 396
 function checkBlockDefinitionsComplete() {
397
-   for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
398
-      $btr =& $this->blockTab[$blockNo];
399
-      if ($btr['definitionIsOpen']) {
400
-         $this->triggerError ("Missing \$EndBlock command in template for block " . $btr['blockName'] . ".");
401
-         return false; }}
402
-   if ($this->currentNestingLevel != 0) {
403
-      $this->triggerError ("Block nesting level error at end of template.");
404
-      return false; }
405
-   return true; }
397
+    for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
398
+        $btr =& $this->blockTab[$blockNo];
399
+        if ($btr['definitionIsOpen']) {
400
+            $this->triggerError ("Missing \$EndBlock command in template for block " . $btr['blockName'] . ".");
401
+            return false; }}
402
+    if ($this->currentNestingLevel != 0) {
403
+        $this->triggerError ("Block nesting level error at end of template.");
404
+        return false; }
405
+    return true; }
406 406
 
407 407
 /**
408 408
 * Processes the $Include command.
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
 * @access private
411 411
 */
412 412
 function processIncludeCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
413
-   $p = 0;
414
-   if (!$this->parseWordOrQuotedString($parms,$p,$subtemplateName)) {
415
-      $this->triggerError ("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin.");
416
-      return false; }
417
-   if (trim(substr($parms,$p)) != '') {
418
-      $this->triggerError ("Extra parameter in \$include command in template at offset $cmdTPosBegin.");
419
-      return false; }
420
-   return $this->insertSubtemplate($subtemplateName,$cmdTPosBegin,$cmdTPosEnd); }
413
+    $p = 0;
414
+    if (!$this->parseWordOrQuotedString($parms,$p,$subtemplateName)) {
415
+        $this->triggerError ("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin.");
416
+        return false; }
417
+    if (trim(substr($parms,$p)) != '') {
418
+        $this->triggerError ("Extra parameter in \$include command in template at offset $cmdTPosBegin.");
419
+        return false; }
420
+    return $this->insertSubtemplate($subtemplateName,$cmdTPosBegin,$cmdTPosEnd); }
421 421
 
422 422
 /**
423 423
 * Processes the $Include command.
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
 * @access private
426 426
 */
427 427
 function insertSubtemplate ($subtemplateName, $tPos1, $tPos2) {
428
-   if (strlen($this->template) > $this->maxInclTemplateSize) {
429
-      $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
430
-      return false; }
431
-   if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false;
432
-   // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator,
433
-   // a table could be used that contains references to the string fragments.)
434
-   $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2);
435
-   return true; }
428
+    if (strlen($this->template) > $this->maxInclTemplateSize) {
429
+        $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
430
+        return false; }
431
+    if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false;
432
+    // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator,
433
+    // a table could be used that contains references to the string fragments.)
434
+    $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2);
435
+    return true; }
436 436
 
437 437
 /**
438 438
 * Parses variable references within the template in the format "${VarName}".
@@ -440,77 +440,77 @@  discard block
 block discarded – undo
440 440
 * @access private
441 441
 */
442 442
 function parseTemplateVariables() {
443
-   $p = 0;
444
-   while (true) {
445
-      $p = strpos($this->template, '${', $p);
446
-      if ($p === false) break;
447
-      $p0 = $p;
448
-      $p = strpos($this->template, '}', $p);
449
-      if ($p === false) {
450
-         $this->triggerError ("Invalid variable reference in template at offset $p0.");
451
-         return false; }
452
-      $p += 1;
453
-      $varName = trim(substr($this->template, $p0+2, $p-$p0-3));
454
-      if (strlen($varName) == 0) {
455
-         $this->triggerError ("Empty variable name in template at offset $p0.");
456
-         return false; }
457
-      $this->registerVariableReference ($varName, $p0, $p); }
458
-   return true; }
443
+    $p = 0;
444
+    while (true) {
445
+        $p = strpos($this->template, '${', $p);
446
+        if ($p === false) break;
447
+        $p0 = $p;
448
+        $p = strpos($this->template, '}', $p);
449
+        if ($p === false) {
450
+            $this->triggerError ("Invalid variable reference in template at offset $p0.");
451
+            return false; }
452
+        $p += 1;
453
+        $varName = trim(substr($this->template, $p0+2, $p-$p0-3));
454
+        if (strlen($varName) == 0) {
455
+            $this->triggerError ("Empty variable name in template at offset $p0.");
456
+            return false; }
457
+        $this->registerVariableReference ($varName, $p0, $p); }
458
+    return true; }
459 459
 
460 460
 /**
461 461
 * @access private
462 462
 */
463 463
 function registerVariableReference ($varName, $tPosBegin, $tPosEnd) {
464
-   if (!$this->lookupVariableName($varName,$varNo))
465
-      $this->registerVariable($varName,$varNo);
466
-   $varRefNo = $this->varRefTabCnt++;
467
-   $vrtr =& $this->varRefTab[$varRefNo];
468
-   $vrtr = array();
469
-   $vrtr['tPosBegin'] = $tPosBegin;
470
-   $vrtr['tPosEnd'] = $tPosEnd;
471
-   $vrtr['varNo'] = $varNo; }
464
+    if (!$this->lookupVariableName($varName,$varNo))
465
+        $this->registerVariable($varName,$varNo);
466
+    $varRefNo = $this->varRefTabCnt++;
467
+    $vrtr =& $this->varRefTab[$varRefNo];
468
+    $vrtr = array();
469
+    $vrtr['tPosBegin'] = $tPosBegin;
470
+    $vrtr['tPosEnd'] = $tPosEnd;
471
+    $vrtr['varNo'] = $varNo; }
472 472
 
473 473
 /**
474 474
 * @access private
475 475
 */
476 476
 function registerVariable ($varName, &$varNo) {
477
-   $varNo = $this->varTabCnt++;
478
-   $vtr =& $this->varTab[$varNo];
479
-   $vtr = array();
480
-   $vtr['varName'] = $varName;
481
-   $vtr['varValue'] = '';
482
-   $this->varNameToNoMap[strtoupper($varName)] = $varNo; }
477
+    $varNo = $this->varTabCnt++;
478
+    $vtr =& $this->varTab[$varNo];
479
+    $vtr = array();
480
+    $vtr['varName'] = $varName;
481
+    $vtr['varValue'] = '';
482
+    $this->varNameToNoMap[strtoupper($varName)] = $varNo; }
483 483
 
484 484
 /**
485 485
 * Associates variable references with blocks.
486 486
 * @access private
487 487
 */
488 488
 function associateVariablesWithBlocks() {
489
-   $varRefNo = 0;
490
-   $activeBlockNo = 0;
491
-   $nextBlockNo = 1;
492
-   while ($varRefNo < $this->varRefTabCnt) {
493
-      $vrtr =& $this->varRefTab[$varRefNo];
494
-      $varRefTPos = $vrtr['tPosBegin'];
495
-      $varNo = $vrtr['varNo'];
496
-      if ($varRefTPos >= $this->blockTab[$activeBlockNo]['tPosEnd']) {
497
-         $activeBlockNo = $this->blockTab[$activeBlockNo]['parentBlockNo'];
498
-         continue; }
499
-      if ($nextBlockNo < $this->blockTabCnt) {
500
-         if ($varRefTPos >= $this->blockTab[$nextBlockNo]['tPosBegin']) {
489
+    $varRefNo = 0;
490
+    $activeBlockNo = 0;
491
+    $nextBlockNo = 1;
492
+    while ($varRefNo < $this->varRefTabCnt) {
493
+        $vrtr =& $this->varRefTab[$varRefNo];
494
+        $varRefTPos = $vrtr['tPosBegin'];
495
+        $varNo = $vrtr['varNo'];
496
+        if ($varRefTPos >= $this->blockTab[$activeBlockNo]['tPosEnd']) {
497
+            $activeBlockNo = $this->blockTab[$activeBlockNo]['parentBlockNo'];
498
+            continue; }
499
+        if ($nextBlockNo < $this->blockTabCnt) {
500
+            if ($varRefTPos >= $this->blockTab[$nextBlockNo]['tPosBegin']) {
501 501
             $activeBlockNo = $nextBlockNo;
502 502
             $nextBlockNo += 1;
503 503
             continue; }}
504
-      $btr =& $this->blockTab[$activeBlockNo];
505
-      if ($varRefTPos < $btr['tPosBegin'])
506
-         $this->programLogicError(1);
507
-      $blockVarNo = $btr['blockVarCnt']++;
508
-      $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo;
509
-      if ($btr['firstVarRefNo'] == -1)
510
-         $btr['firstVarRefNo'] = $varRefNo;
511
-      $vrtr['blockNo'] = $activeBlockNo;
512
-      $vrtr['blockVarNo'] = $blockVarNo;
513
-      $varRefNo += 1; }}
504
+        $btr =& $this->blockTab[$activeBlockNo];
505
+        if ($varRefTPos < $btr['tPosBegin'])
506
+            $this->programLogicError(1);
507
+        $blockVarNo = $btr['blockVarCnt']++;
508
+        $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo;
509
+        if ($btr['firstVarRefNo'] == -1)
510
+            $btr['firstVarRefNo'] = $varRefNo;
511
+        $vrtr['blockNo'] = $activeBlockNo;
512
+        $vrtr['blockVarNo'] = $blockVarNo;
513
+        $varRefNo += 1; }}
514 514
 
515 515
 //--- build up (template variables and blocks) ----------------------------------------------------------------------
516 516
 
@@ -523,15 +523,15 @@  discard block
 block discarded – undo
523 523
 * @access public
524 524
 */
525 525
 function reset() {
526
-   for ($varNo=0; $varNo<$this->varTabCnt; $varNo++)
527
-      $this->varTab[$varNo]['varValue'] = '';
528
-   for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
529
-      $btr =& $this->blockTab[$blockNo];
530
-      $btr['instances'] = 0;
531
-      $btr['firstBlockInstNo'] = -1;
532
-      $btr['lastBlockInstNo'] = -1; }
533
-   $this->blockInstTab = array();
534
-   $this->blockInstTabCnt = 0; }
526
+    for ($varNo=0; $varNo<$this->varTabCnt; $varNo++)
527
+        $this->varTab[$varNo]['varValue'] = '';
528
+    for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
529
+        $btr =& $this->blockTab[$blockNo];
530
+        $btr['instances'] = 0;
531
+        $btr['firstBlockInstNo'] = -1;
532
+        $btr['lastBlockInstNo'] = -1; }
533
+    $this->blockInstTab = array();
534
+    $this->blockInstTabCnt = 0; }
535 535
 
536 536
 /**
537 537
 * Sets a template variable.
@@ -549,13 +549,13 @@  discard block
 block discarded – undo
549 549
 * @access public
550 550
 */
551 551
 function setVariable ($variableName, $variableValue, $isOptional=false) {
552
-   if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
553
-   if (!$this->lookupVariableName($variableName,$varNo)) {
554
-      if ($isOptional) return true;
555
-      $this->triggerError ("Variable \"$variableName\" not defined in template.");
556
-      return false; }
557
-   $this->varTab[$varNo]['varValue'] = $variableValue;
558
-   return true; }
552
+    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
553
+    if (!$this->lookupVariableName($variableName,$varNo)) {
554
+        if ($isOptional) return true;
555
+        $this->triggerError ("Variable \"$variableName\" not defined in template.");
556
+        return false; }
557
+    $this->varTab[$varNo]['varValue'] = $variableValue;
558
+    return true; }
559 559
 
560 560
 /**
561 561
 * Sets a template variable to an escaped string.
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 * @access public
577 577
 */
578 578
 function setVariableEsc ($variableName, $variableValue, $isOptional=false) {
579
-   return $this->setVariable($variableName,htmlspecialchars($variableValue,ENT_QUOTES),$isOptional); }
579
+    return $this->setVariable($variableName,htmlspecialchars($variableValue,ENT_QUOTES),$isOptional); }
580 580
 
581 581
 /**
582 582
 * Checks whether a variable with the specified name exists within the template.
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
 * @access public
587 587
 */
588 588
 function variableExists ($variableName) {
589
-   if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
590
-   return $this->lookupVariableName($variableName,$varNo); }
589
+    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
590
+    return $this->lookupVariableName($variableName,$varNo); }
591 591
 
592 592
 /**
593 593
 * Adds an instance of a template block.
@@ -603,48 +603,48 @@  discard block
 block discarded – undo
603 603
 * @access public
604 604
 */
605 605
 function addBlock($blockName) {
606
-   if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
607
-   if (!$this->lookupBlockName($blockName,$blockNo)) {
608
-      $this->triggerError ("Block \"$blockName\" not defined in template.");
609
-      return false; }
610
-   while ($blockNo != -1) {
611
-      $this->addBlockByNo($blockNo);
612
-      $blockNo = $this->blockTab[$blockNo]['nextWithSameName']; }
613
-   return true; }
606
+    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
607
+    if (!$this->lookupBlockName($blockName,$blockNo)) {
608
+        $this->triggerError ("Block \"$blockName\" not defined in template.");
609
+        return false; }
610
+    while ($blockNo != -1) {
611
+        $this->addBlockByNo($blockNo);
612
+        $blockNo = $this->blockTab[$blockNo]['nextWithSameName']; }
613
+    return true; }
614 614
 
615 615
 /**
616 616
 * @access private
617 617
 */
618 618
 function addBlockByNo ($blockNo) {
619
-   $btr =& $this->blockTab[$blockNo];
620
-   $this->registerBlockInstance ($blockInstNo);
621
-   $bitr =& $this->blockInstTab[$blockInstNo];
622
-   if ($btr['firstBlockInstNo'] == -1)
623
-      $btr['firstBlockInstNo'] = $blockInstNo;
624
-   if ($btr['lastBlockInstNo'] != -1)
625
-      $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo;
626
-         // set forward pointer of chain
627
-   $btr['lastBlockInstNo'] = $blockInstNo;
628
-   $parentBlockNo = $btr['parentBlockNo'];
629
-   $blockVarCnt = $btr['blockVarCnt'];
630
-   $bitr['blockNo'] = $blockNo;
631
-   $bitr['instanceLevel'] = $btr['instances']++;
632
-   if ($parentBlockNo == -1)
633
-      $bitr['parentInstLevel'] = -1;
619
+    $btr =& $this->blockTab[$blockNo];
620
+    $this->registerBlockInstance ($blockInstNo);
621
+    $bitr =& $this->blockInstTab[$blockInstNo];
622
+    if ($btr['firstBlockInstNo'] == -1)
623
+        $btr['firstBlockInstNo'] = $blockInstNo;
624
+    if ($btr['lastBlockInstNo'] != -1)
625
+        $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo;
626
+            // set forward pointer of chain
627
+    $btr['lastBlockInstNo'] = $blockInstNo;
628
+    $parentBlockNo = $btr['parentBlockNo'];
629
+    $blockVarCnt = $btr['blockVarCnt'];
630
+    $bitr['blockNo'] = $blockNo;
631
+    $bitr['instanceLevel'] = $btr['instances']++;
632
+    if ($parentBlockNo == -1)
633
+        $bitr['parentInstLevel'] = -1;
634 634
     else
635
-      $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances'];
636
-   $bitr['nextBlockInstNo'] = -1;
637
-   $bitr['blockVarTab'] = array();
638
-   // copy instance variables for this block
639
-   for ($blockVarNo=0; $blockVarNo<$blockVarCnt; $blockVarNo++) {
640
-      $varNo = $btr['blockVarNoToVarNoMap'][$blockVarNo];
641
-      $bitr['blockVarTab'][$blockVarNo] = $this->varTab[$varNo]['varValue']; }}
635
+        $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances'];
636
+    $bitr['nextBlockInstNo'] = -1;
637
+    $bitr['blockVarTab'] = array();
638
+    // copy instance variables for this block
639
+    for ($blockVarNo=0; $blockVarNo<$blockVarCnt; $blockVarNo++) {
640
+        $varNo = $btr['blockVarNoToVarNoMap'][$blockVarNo];
641
+        $bitr['blockVarTab'][$blockVarNo] = $this->varTab[$varNo]['varValue']; }}
642 642
 
643 643
 /**
644 644
 * @access private
645 645
 */
646 646
 function registerBlockInstance (&$blockInstNo) {
647
-   $blockInstNo = $this->blockInstTabCnt++; }
647
+    $blockInstNo = $this->blockInstTabCnt++; }
648 648
 
649 649
 /**
650 650
 * Checks whether a block with the specified name exists within the template.
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 * @access public
655 655
 */
656 656
 function blockExists ($blockName) {
657
-   if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
658
-   return $this->lookupBlockName($blockName,$blockNo); }
657
+    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
658
+    return $this->lookupBlockName($blockName,$blockNo); }
659 659
 
660 660
 //--- output generation ---------------------------------------------------------------------------------------------
661 661
 
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 * @access public
666 666
 */
667 667
 function generateOutput () {
668
-   $this->outputMode = 0;
669
-   if (!$this->generateOutputPage()) return false;
670
-   return true; }
668
+    $this->outputMode = 0;
669
+    if (!$this->generateOutputPage()) return false;
670
+    return true; }
671 671
 
672 672
 /**
673 673
 * Generates the HTML page and writes it to a file.
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
 * @access public
677 677
 */
678 678
 function generateOutputToFile ($fileName) {
679
-   $fh = fopen($fileName,"wb");
680
-   if ($fh === false) return false;
681
-   $this->outputMode = 1;
682
-   $this->outputFileHandle = $fh;
683
-   $ok = $this->generateOutputPage();
684
-   fclose ($fh);
685
-   return $ok; }
679
+    $fh = fopen($fileName,"wb");
680
+    if ($fh === false) return false;
681
+    $this->outputMode = 1;
682
+    $this->outputFileHandle = $fh;
683
+    $ok = $this->generateOutputPage();
684
+    fclose ($fh);
685
+    return $ok; }
686 686
 
687 687
 /**
688 688
 * Generates the HTML page and writes it to a string.
@@ -692,28 +692,28 @@  discard block
 block discarded – undo
692 692
 * @access public
693 693
 */
694 694
 function generateOutputToString (&$outputString) {
695
-   $outputString = "Error";
696
-   $this->outputMode = 2;
697
-   $this->outputString = "";
698
-   if (!$this->generateOutputPage()) return false;
699
-   $outputString = $this->outputString;
700
-   return true; }
695
+    $outputString = "Error";
696
+    $this->outputMode = 2;
697
+    $this->outputString = "";
698
+    if (!$this->generateOutputPage()) return false;
699
+    $outputString = $this->outputString;
700
+    return true; }
701 701
 
702 702
 /**
703 703
 * @access private
704 704
 * @return boolean  true on success, false on error.
705 705
 */
706 706
 function generateOutputPage() {
707
-   if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
708
-   if ($this->blockTab[0]['instances'] == 0)
709
-      $this->addBlockByNo (0);        // add main block
710
-   for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
711
-       $btr =& $this->blockTab[$blockNo];
712
-       $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; }
713
-   $this->outputError = false;
714
-   $this->writeBlockInstances (0, -1);
715
-   if ($this->outputError) return false;
716
-   return true; }
707
+    if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
708
+    if ($this->blockTab[0]['instances'] == 0)
709
+        $this->addBlockByNo (0);        // add main block
710
+    for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
711
+        $btr =& $this->blockTab[$blockNo];
712
+        $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; }
713
+    $this->outputError = false;
714
+    $this->writeBlockInstances (0, -1);
715
+    if ($this->outputError) return false;
716
+    return true; }
717 717
 
718 718
 /**
719 719
 * Writes all instances of a block that are contained within a specific
@@ -722,64 +722,64 @@  discard block
 block discarded – undo
722 722
 * @access private
723 723
 */
724 724
 function writeBlockInstances ($blockNo, $parentInstLevel) {
725
-   $btr =& $this->blockTab[$blockNo];
726
-   while (!$this->outputError) {
727
-      $blockInstNo = $btr['currBlockInstNo'];
728
-      if ($blockInstNo == -1) break;
729
-      $bitr =& $this->blockInstTab[$blockInstNo];
730
-      if ($bitr['parentInstLevel'] < $parentInstLevel)
731
-         $this->programLogicError (2);
732
-      if ($bitr['parentInstLevel'] > $parentInstLevel) break;
733
-      $this->writeBlockInstance ($blockInstNo);
734
-      $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }}
725
+    $btr =& $this->blockTab[$blockNo];
726
+    while (!$this->outputError) {
727
+        $blockInstNo = $btr['currBlockInstNo'];
728
+        if ($blockInstNo == -1) break;
729
+        $bitr =& $this->blockInstTab[$blockInstNo];
730
+        if ($bitr['parentInstLevel'] < $parentInstLevel)
731
+            $this->programLogicError (2);
732
+        if ($bitr['parentInstLevel'] > $parentInstLevel) break;
733
+        $this->writeBlockInstance ($blockInstNo);
734
+        $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }}
735 735
 
736 736
 /**
737 737
 * @access private
738 738
 */
739 739
 function writeBlockInstance($blockInstNo) {
740
-   $bitr =& $this->blockInstTab[$blockInstNo];
741
-   $blockNo = $bitr['blockNo'];
742
-   $btr =& $this->blockTab[$blockNo];
743
-   $tPos = $btr['tPosContentsBegin'];
744
-   $subBlockNo = $blockNo + 1;
745
-   $varRefNo = $btr['firstVarRefNo'];
746
-   while (!$this->outputError) {
747
-      $tPos2 = $btr['tPosContentsEnd'];
748
-      $kind = 0;                                // assume end-of-block
749
-      if ($varRefNo != -1 && $varRefNo < $this->varRefTabCnt) {  // check for variable reference
750
-         $vrtr =& $this->varRefTab[$varRefNo];
751
-         if ($vrtr['tPosBegin'] < $tPos) {
740
+    $bitr =& $this->blockInstTab[$blockInstNo];
741
+    $blockNo = $bitr['blockNo'];
742
+    $btr =& $this->blockTab[$blockNo];
743
+    $tPos = $btr['tPosContentsBegin'];
744
+    $subBlockNo = $blockNo + 1;
745
+    $varRefNo = $btr['firstVarRefNo'];
746
+    while (!$this->outputError) {
747
+        $tPos2 = $btr['tPosContentsEnd'];
748
+        $kind = 0;                                // assume end-of-block
749
+        if ($varRefNo != -1 && $varRefNo < $this->varRefTabCnt) {  // check for variable reference
750
+            $vrtr =& $this->varRefTab[$varRefNo];
751
+            if ($vrtr['tPosBegin'] < $tPos) {
752 752
             $varRefNo += 1;
753 753
             continue; }
754
-         if ($vrtr['tPosBegin'] < $tPos2) {
754
+            if ($vrtr['tPosBegin'] < $tPos2) {
755 755
             $tPos2 = $vrtr['tPosBegin'];
756 756
             $kind = 1; }}
757
-      if ($subBlockNo < $this->blockTabCnt) {   // check for subblock
758
-         $subBtr =& $this->blockTab[$subBlockNo];
759
-         if ($subBtr['tPosBegin'] < $tPos) {
757
+        if ($subBlockNo < $this->blockTabCnt) {   // check for subblock
758
+            $subBtr =& $this->blockTab[$subBlockNo];
759
+            if ($subBtr['tPosBegin'] < $tPos) {
760 760
             $subBlockNo += 1;
761 761
             continue; }
762
-         if ($subBtr['tPosBegin'] < $tPos2) {
762
+            if ($subBtr['tPosBegin'] < $tPos2) {
763 763
             $tPos2 = $subBtr['tPosBegin'];
764 764
             $kind = 2; }}
765
-      if ($tPos2 > $tPos)
766
-         $this->writeString (substr($this->template,$tPos,$tPos2-$tPos));
767
-      switch ($kind) {
768
-         case 0:         // end of block
765
+        if ($tPos2 > $tPos)
766
+            $this->writeString (substr($this->template,$tPos,$tPos2-$tPos));
767
+        switch ($kind) {
768
+            case 0:         // end of block
769 769
             return;
770
-         case 1:         // variable
770
+            case 1:         // variable
771 771
             $vrtr =& $this->varRefTab[$varRefNo];
772 772
             if ($vrtr['blockNo'] != $blockNo)
773
-               $this->programLogicError (4);
773
+                $this->programLogicError (4);
774 774
             $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']];
775 775
             $this->writeString ($variableValue);
776 776
             $tPos = $vrtr['tPosEnd'];
777 777
             $varRefNo += 1;
778 778
             break;
779
-         case 2:         // sub block
779
+            case 2:         // sub block
780 780
             $subBtr =& $this->blockTab[$subBlockNo];
781 781
             if ($subBtr['parentBlockNo'] != $blockNo)
782
-               $this->programLogicError (3);
782
+                $this->programLogicError (3);
783 783
             $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']);  // recursive call
784 784
             $tPos = $subBtr['tPosEnd'];
785 785
             $subBlockNo += 1;
@@ -789,19 +789,19 @@  discard block
 block discarded – undo
789 789
 * @access private
790 790
 */
791 791
 function writeString ($s) {
792
-   if ($this->outputError) return;
793
-   switch ($this->outputMode) {
794
-      case 0:            // output to PHP output stream
792
+    if ($this->outputError) return;
793
+    switch ($this->outputMode) {
794
+        case 0:            // output to PHP output stream
795 795
          if (!print($s))
796 796
             $this->outputError = true;
797
-         break;
798
-      case 1:            // output to file
797
+            break;
798
+        case 1:            // output to file
799 799
          $rc = fwrite($this->outputFileHandle, $s);
800
-         if ($rc === false) $this->outputError = true;
801
-         break;
802
-      case 2:            // output to string
800
+            if ($rc === false) $this->outputError = true;
801
+            break;
802
+        case 2:            // output to string
803 803
          $this->outputString .= $s;
804
-         break; }}
804
+            break; }}
805 805
 
806 806
 //--- name lookup routines ------------------------------------------------------------------------------------------
807 807
 
@@ -811,10 +811,10 @@  discard block
 block discarded – undo
811 811
 * @access private
812 812
 */
813 813
 function lookupVariableName ($varName, &$varNo) {
814
-   $x =& $this->varNameToNoMap[strtoupper($varName)];
815
-   if (!isset($x)) return false;
816
-   $varNo = $x;
817
-   return true; }
814
+    $x =& $this->varNameToNoMap[strtoupper($varName)];
815
+    if (!isset($x)) return false;
816
+    $varNo = $x;
817
+    return true; }
818 818
 
819 819
 /**
820 820
 * Maps block name to block number.
@@ -824,10 +824,10 @@  discard block
 block discarded – undo
824 824
 * @access private
825 825
 */
826 826
 function lookupBlockName ($blockName, &$blockNo) {
827
-   $x =& $this->blockNameToNoMap[strtoupper($blockName)];
828
-   if (!isset($x)) return false;
829
-   $blockNo = $x;
830
-   return true; }
827
+    $x =& $this->blockNameToNoMap[strtoupper($blockName)];
828
+    if (!isset($x)) return false;
829
+    $blockNo = $x;
830
+    return true; }
831 831
 
832 832
 //--- general utility routines -----------------------------------------------------------------------------------------
833 833
 
@@ -837,86 +837,86 @@  discard block
 block discarded – undo
837 837
 * @access private
838 838
 */
839 839
 function readFileIntoString ($fileName, &$s) {
840
-   if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
841
-      $s = file_get_contents($fileName);
842
-      if ($s === false) return false;
843
-      return true; }
844
-   $fh = fopen($fileName,"rb");
845
-   if ($fh === false) return false;
846
-   $fileSize = filesize($fileName);
847
-   if ($fileSize === false) {fclose ($fh); return false; }
848
-   $s = fread($fh,$fileSize);
849
-   fclose ($fh);
850
-   if (strlen($s) != $fileSize) return false;
851
-   return true; }
840
+    if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
841
+        $s = file_get_contents($fileName);
842
+        if ($s === false) return false;
843
+        return true; }
844
+    $fh = fopen($fileName,"rb");
845
+    if ($fh === false) return false;
846
+    $fileSize = filesize($fileName);
847
+    if ($fileSize === false) {fclose ($fh); return false; }
848
+    $s = fread($fh,$fileSize);
849
+    fclose ($fh);
850
+    if (strlen($s) != $fileSize) return false;
851
+    return true; }
852 852
 
853 853
 /**
854 854
 * @access private
855 855
 * @return boolean  true on success, false when the end of the string is reached.
856 856
 */
857 857
 function parseWord ($s, &$p, &$w) {
858
-   $sLen = strlen($s);
859
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
860
-   if ($p >= $sLen) return false;
861
-   $p0 = $p;
862
-   while ($p < $sLen && ord($s{$p}) > 32) $p++;
863
-   $w = substr($s, $p0, $p - $p0);
864
-   return true; }
858
+    $sLen = strlen($s);
859
+    while ($p < $sLen && ord($s{$p}) <= 32) $p++;
860
+    if ($p >= $sLen) return false;
861
+    $p0 = $p;
862
+    while ($p < $sLen && ord($s{$p}) > 32) $p++;
863
+    $w = substr($s, $p0, $p - $p0);
864
+    return true; }
865 865
 
866 866
 /**
867 867
 * @access private
868 868
 * @return boolean  true on success, false on error.
869 869
 */
870 870
 function parseQuotedString ($s, &$p, &$w) {
871
-   $sLen = strlen($s);
872
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
873
-   if ($p >= $sLen) return false;
874
-   if (substr($s,$p,1) != '"') return false;
875
-   $p++; $p0 = $p;
876
-   while ($p < $sLen && $s{$p} != '"') $p++;
877
-   if ($p >= $sLen) return false;
878
-   $w = substr($s, $p0, $p - $p0);
879
-   $p++;
880
-   return true; }
871
+    $sLen = strlen($s);
872
+    while ($p < $sLen && ord($s{$p}) <= 32) $p++;
873
+    if ($p >= $sLen) return false;
874
+    if (substr($s,$p,1) != '"') return false;
875
+    $p++; $p0 = $p;
876
+    while ($p < $sLen && $s{$p} != '"') $p++;
877
+    if ($p >= $sLen) return false;
878
+    $w = substr($s, $p0, $p - $p0);
879
+    $p++;
880
+    return true; }
881 881
 
882 882
 /**
883 883
 * @access private
884 884
 * @return boolean  true on success, false on error.
885 885
 */
886 886
 function parseWordOrQuotedString ($s, &$p, &$w) {
887
-   $sLen = strlen($s);
888
-   while ($p < $sLen && ord($s{$p}) <= 32) $p++;
889
-   if ($p >= $sLen) return false;
890
-   if (substr($s,$p,1) == '"')
891
-      return $this->parseQuotedString($s,$p,$w);
887
+    $sLen = strlen($s);
888
+    while ($p < $sLen && ord($s{$p}) <= 32) $p++;
889
+    if ($p >= $sLen) return false;
890
+    if (substr($s,$p,1) == '"')
891
+        return $this->parseQuotedString($s,$p,$w);
892 892
     else
893
-      return $this->parseWord($s,$p,$w); }
893
+        return $this->parseWord($s,$p,$w); }
894 894
 
895 895
 /**
896 896
 * Combine two file system paths.
897 897
 * @access private
898 898
 */
899 899
 function combineFileSystemPath ($path1, $path2) {
900
-   if ($path1 == '' || $path2 == '') return $path2;
901
-   $s = $path1;
902
-   if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/";
903
-   if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/')
904
-      $s = $s . substr($path2,1);
900
+    if ($path1 == '' || $path2 == '') return $path2;
901
+    $s = $path1;
902
+    if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/";
903
+    if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/')
904
+        $s = $s . substr($path2,1);
905 905
     else
906
-      $s = $s . $path2;
907
-   return $s; }
906
+        $s = $s . $path2;
907
+    return $s; }
908 908
 
909 909
 /**
910 910
 * @access private
911 911
 */
912 912
 function triggerError ($msg) {
913
-   trigger_error ("MiniTemplator error: $msg", E_USER_ERROR); }
913
+    trigger_error ("MiniTemplator error: $msg", E_USER_ERROR); }
914 914
 
915 915
 /**
916 916
 * @access private
917 917
 */
918 918
 function programLogicError ($errorId) {
919
-   die ("MiniTemplator: Program logic error $errorId.\n"); }
919
+    die ("MiniTemplator: Program logic error $errorId.\n"); }
920 920
 
921 921
 }
922 922
 ?>
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,36 +1,36 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if (file_exists("install") && !file_exists("config.php")) {
3
-		header("Location: install/");
4
-	}
2
+    if (file_exists("install") && !file_exists("config.php")) {
3
+        header("Location: install/");
4
+    }
5 5
 
6
-	if (!file_exists("config.php")) {
7
-		print "<b>Fatal Error</b>: You forgot to copy
6
+    if (!file_exists("config.php")) {
7
+        print "<b>Fatal Error</b>: You forgot to copy
8 8
 		<b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
9
-		exit;
10
-	}
9
+        exit;
10
+    }
11 11
 
12
-	// we need a separate check here because functions.php might get parsed
13
-	// incorrectly before 5.3 because of :: syntax.
14
-	if (version_compare(PHP_VERSION, '5.6.0', '<')) {
15
-		print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\n";
16
-		exit;
17
-	}
12
+    // we need a separate check here because functions.php might get parsed
13
+    // incorrectly before 5.3 because of :: syntax.
14
+    if (version_compare(PHP_VERSION, '5.6.0', '<')) {
15
+        print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\n";
16
+        exit;
17
+    }
18 18
 
19
-	set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
20
-		get_include_path());
19
+    set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
20
+        get_include_path());
21 21
 
22
-	require_once "autoload.php";
23
-	require_once "sessions.php";
24
-	require_once "functions.php";
25
-	require_once "sanity_check.php";
26
-	require_once "config.php";
27
-	require_once "db-prefs.php";
22
+    require_once "autoload.php";
23
+    require_once "sessions.php";
24
+    require_once "functions.php";
25
+    require_once "sanity_check.php";
26
+    require_once "config.php";
27
+    require_once "db-prefs.php";
28 28
 
29
-	if (!init_plugins()) return;
29
+    if (!init_plugins()) return;
30 30
 
31
-	login_sequence();
31
+    login_sequence();
32 32
 
33
-	header('Content-Type: text/html; charset=utf-8');
33
+    header('Content-Type: text/html; charset=utf-8');
34 34
 
35 35
 ?>
36 36
 <!DOCTYPE html>
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
     <meta name="viewport" content="initial-scale=1,width=device-width" />
41 41
 
42 42
 	<?php if ($_SESSION["uid"]) {
43
-		$theme = get_pref("USER_CSS_THEME", false, false);
44
-		if ($theme && theme_exists("$theme")) {
45
-			echo stylesheet_tag(get_theme_path($theme), 'theme_css');
46
-		}
47
-	}
43
+        $theme = get_pref("USER_CSS_THEME", false, false);
44
+        if ($theme && theme_exists("$theme")) {
45
+            echo stylesheet_tag(get_theme_path($theme), 'theme_css');
46
+        }
47
+    }
48 48
 
49
-	print_user_stylesheet()
49
+    print_user_stylesheet()
50 50
 
51
-	?>
51
+    ?>
52 52
 	<style type="text/css">
53 53
 	<?php
54
-		foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
55
-			if (method_exists($p, "get_css")) {
56
-				echo $p->get_css();
57
-			}
58
-		}
59
-	?>
54
+        foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
55
+            if (method_exists($p, "get_css")) {
56
+                echo $p->get_css();
57
+            }
58
+        }
59
+    ?>
60 60
 	</style>
61 61
 
62 62
 	<link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 	</script>
74 74
 
75 75
 	<?php
76
-	foreach (array("lib/prototype.js",
77
-				"lib/scriptaculous/scriptaculous.js?load=effects,controls",
78
-				"lib/dojo/dojo.js",
79
-				"lib/dojo/tt-rss-layer.js",
80
-				"js/tt-rss.js",
81
-				"js/common.js",
82
-				"errors.php?mode=js") as $jsfile) {
76
+    foreach (array("lib/prototype.js",
77
+                "lib/scriptaculous/scriptaculous.js?load=effects,controls",
78
+                "lib/dojo/dojo.js",
79
+                "lib/dojo/tt-rss-layer.js",
80
+                "js/tt-rss.js",
81
+                "js/common.js",
82
+                "errors.php?mode=js") as $jsfile) {
83 83
 
84
-		echo javascript_tag($jsfile);
84
+        echo javascript_tag($jsfile);
85 85
 
86
-	} ?>
86
+    } ?>
87 87
 
88 88
 	<script type="text/javascript">
89 89
 		require({cache:{}});
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 
92 92
 	<script type="text/javascript">
93 93
 	<?php
94
-		foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
95
-			if (method_exists($p, "get_js")) {
96
-			    $script = $p->get_js();
94
+        foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
95
+            if (method_exists($p, "get_js")) {
96
+                $script = $p->get_js();
97 97
 
98
-			    if ($script) {
99
-					echo "try {
98
+                if ($script) {
99
+                    echo "try {
100 100
 					    $script
101 101
 					} catch (e) {
102 102
                         console.warn('failed to initialize plugin JS: $n', e);
103 103
                     }";
104
-				}
105
-			}
106
-		}
104
+                }
105
+            }
106
+        }
107 107
 
108
-		init_js_translations();
109
-	?>
108
+        init_js_translations();
109
+    ?>
110 110
 	</script>
111 111
 
112 112
 	<style type="text/css">
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
             <img src='images/indicator_tiny.gif'/>
147 147
             <?php echo  __("Loading, please wait..."); ?></div>
148 148
         <?php
149
-          foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) {
149
+            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) {
150 150
             echo $p->hook_feed_tree();
151
-          }
151
+            }
152 152
         ?>
153 153
         <div id="feedTree"></div>
154 154
     </div>
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
                 <?php
223 223
                     foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
224
-                         echo $p->hook_toolbar_button();
224
+                            echo $p->hook_toolbar_button();
225 225
                     }
226 226
                 ?>
227 227
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
                         <?php
245 245
                             foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
246
-                             echo $p->hook_action_item();
246
+                                echo $p->hook_action_item();
247 247
                             }
248 248
                         ?>
249 249
 
Please login to merge, or discard this patch.
prefs.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,29 +1,29 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if (file_exists("install") && !file_exists("config.php")) {
3
-		header("Location: install/");
4
-	}
2
+    if (file_exists("install") && !file_exists("config.php")) {
3
+        header("Location: install/");
4
+    }
5 5
 
6
-	set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
7
-		get_include_path());
6
+    set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
7
+        get_include_path());
8 8
 
9
-	if (!file_exists("config.php")) {
10
-		print "<b>Fatal Error</b>: You forgot to copy
9
+    if (!file_exists("config.php")) {
10
+        print "<b>Fatal Error</b>: You forgot to copy
11 11
 		<b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
12
-		exit;
13
-	}
12
+        exit;
13
+    }
14 14
 
15
-	require_once "autoload.php";
16
-	require_once "sessions.php";
17
-	require_once "functions.php";
18
-	require_once "sanity_check.php";
19
-	require_once "config.php";
20
-	require_once "db-prefs.php";
15
+    require_once "autoload.php";
16
+    require_once "sessions.php";
17
+    require_once "functions.php";
18
+    require_once "sanity_check.php";
19
+    require_once "config.php";
20
+    require_once "db-prefs.php";
21 21
 
22
-	if (!init_plugins()) return;
22
+    if (!init_plugins()) return;
23 23
 
24
-	login_sequence();
24
+    login_sequence();
25 25
 
26
-	header('Content-Type: text/html; charset=utf-8');
26
+    header('Content-Type: text/html; charset=utf-8');
27 27
 ?>
28 28
 <!DOCTYPE html>
29 29
 <html>
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
     <meta name="viewport" content="initial-scale=1,width=device-width" />
33 33
 
34 34
 	<?php if ($_SESSION["uid"]) {
35
-		$theme = get_pref("USER_CSS_THEME", false, false);
36
-		if ($theme && theme_exists("$theme")) {
37
-			echo stylesheet_tag(get_theme_path($theme), 'theme_css');
38
-		}
39
-	}
40
-	?>
35
+        $theme = get_pref("USER_CSS_THEME", false, false);
36
+        if ($theme && theme_exists("$theme")) {
37
+            echo stylesheet_tag(get_theme_path($theme), 'theme_css');
38
+        }
39
+    }
40
+    ?>
41 41
 
42 42
 	<?php print_user_stylesheet() ?>
43 43
 
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 	</script>
57 57
 
58 58
 	<?php
59
-	foreach (array("lib/prototype.js",
60
-				"lib/scriptaculous/scriptaculous.js?load=effects,controls",
61
-				"lib/dojo/dojo.js",
62
-				"lib/dojo/tt-rss-layer.js",
63
-				"js/common.js",
64
-				"js/prefs.js",
65
-				"errors.php?mode=js") as $jsfile) {
59
+    foreach (array("lib/prototype.js",
60
+                "lib/scriptaculous/scriptaculous.js?load=effects,controls",
61
+                "lib/dojo/dojo.js",
62
+                "lib/dojo/tt-rss-layer.js",
63
+                "js/common.js",
64
+                "js/prefs.js",
65
+                "errors.php?mode=js") as $jsfile) {
66 66
 
67
-		echo javascript_tag($jsfile);
67
+        echo javascript_tag($jsfile);
68 68
 
69
-	} ?>
69
+    } ?>
70 70
 
71 71
     <script type="text/javascript">
72 72
 		require({cache:{}});
@@ -74,22 +74,22 @@  discard block
 block discarded – undo
74 74
 
75 75
 	<script type="text/javascript">
76 76
 	<?php
77
-		foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
78
-			if (method_exists($p, "get_prefs_js")) {
79
-				$script = $p->get_prefs_js();
77
+        foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
78
+            if (method_exists($p, "get_prefs_js")) {
79
+                $script = $p->get_prefs_js();
80 80
 
81
-				if ($script) {
82
-					echo "try {
81
+                if ($script) {
82
+                    echo "try {
83 83
 					    $script
84 84
 					} catch (e) {
85 85
                         console.warn('failed to initialize plugin JS: $n', e);
86 86
                     }";
87
-				}
88
-			}
89
-		}
87
+                }
88
+            }
89
+        }
90 90
 
91
-		init_js_translations();
92
-	?>
91
+        init_js_translations();
92
+    ?>
93 93
 	</script>
94 94
 
95 95
 	<style type="text/css">
Please login to merge, or discard this patch.
classes/rpc.php 1 patch
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -1,435 +1,435 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class RPC extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("sanitycheck", "completelabels", "saveprofile");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("sanitycheck", "completelabels", "saveprofile");
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 setprofile() {
11
-		$_SESSION["profile"] = (int) clean($_REQUEST["id"]);
10
+    public function setprofile() {
11
+        $_SESSION["profile"] = (int) clean($_REQUEST["id"]);
12 12
 
13
-		// default value
14
-		if (!$_SESSION["profile"]) $_SESSION["profile"] = null;
15
-	}
13
+        // default value
14
+        if (!$_SESSION["profile"]) $_SESSION["profile"] = null;
15
+    }
16 16
 
17
-	public function remprofiles() {
18
-		$ids = explode(",", trim(clean($_REQUEST["ids"])));
17
+    public function remprofiles() {
18
+        $ids = explode(",", trim(clean($_REQUEST["ids"])));
19 19
 
20
-		foreach ($ids as $id) {
21
-			if ($_SESSION["profile"] != $id) {
22
-				$sth = $this->pdo->prepare("DELETE FROM ttrss_settings_profiles WHERE id = ? AND
20
+        foreach ($ids as $id) {
21
+            if ($_SESSION["profile"] != $id) {
22
+                $sth = $this->pdo->prepare("DELETE FROM ttrss_settings_profiles WHERE id = ? AND
23 23
 							owner_uid = ?");
24
-				$sth->execute([$id, $_SESSION['uid']]);
25
-			}
26
-		}
27
-	}
24
+                $sth->execute([$id, $_SESSION['uid']]);
25
+            }
26
+        }
27
+    }
28 28
 
29
-	// Silent
30
-	public function addprofile() {
31
-		$title = trim(clean($_REQUEST["title"]));
29
+    // Silent
30
+    public function addprofile() {
31
+        $title = trim(clean($_REQUEST["title"]));
32 32
 
33
-		if ($title) {
34
-			$this->pdo->beginTransaction();
33
+        if ($title) {
34
+            $this->pdo->beginTransaction();
35 35
 
36
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
36
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
37 37
 				WHERE title = ? AND owner_uid = ?");
38
-			$sth->execute([$title, $_SESSION['uid']]);
38
+            $sth->execute([$title, $_SESSION['uid']]);
39 39
 
40
-			if (!$sth->fetch()) {
40
+            if (!$sth->fetch()) {
41 41
 
42
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_settings_profiles (title, owner_uid)
42
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_settings_profiles (title, owner_uid)
43 43
 							VALUES (?, ?)");
44 44
 
45
-				$sth->execute([$title, $_SESSION['uid']]);
45
+                $sth->execute([$title, $_SESSION['uid']]);
46 46
 
47
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE
47
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles WHERE
48 48
 					title = ? AND owner_uid = ?");
49
-				$sth->execute([$title, $_SESSION['uid']]);
49
+                $sth->execute([$title, $_SESSION['uid']]);
50 50
 
51
-				if ($row = $sth->fetch()) {
52
-					$profile_id = $row['id'];
51
+                if ($row = $sth->fetch()) {
52
+                    $profile_id = $row['id'];
53 53
 
54
-					if ($profile_id) {
55
-						initialize_user_prefs($_SESSION["uid"], $profile_id);
56
-					}
57
-				}
58
-			}
54
+                    if ($profile_id) {
55
+                        initialize_user_prefs($_SESSION["uid"], $profile_id);
56
+                    }
57
+                }
58
+            }
59 59
 
60
-			$this->pdo->commit();
61
-		}
62
-	}
60
+            $this->pdo->commit();
61
+        }
62
+    }
63 63
 
64
-	public function saveprofile() {
65
-		$id = clean($_REQUEST["id"]);
66
-		$title = trim(clean($_REQUEST["value"]));
64
+    public function saveprofile() {
65
+        $id = clean($_REQUEST["id"]);
66
+        $title = trim(clean($_REQUEST["value"]));
67 67
 
68
-		if ($id == 0) {
69
-			print __("Default profile");
70
-			return;
71
-		}
68
+        if ($id == 0) {
69
+            print __("Default profile");
70
+            return;
71
+        }
72 72
 
73
-		if ($title) {
74
-			$sth = $this->pdo->prepare("UPDATE ttrss_settings_profiles
73
+        if ($title) {
74
+            $sth = $this->pdo->prepare("UPDATE ttrss_settings_profiles
75 75
 				SET title = ? WHERE id = ? AND
76 76
 					owner_uid = ?");
77 77
 
78
-			$sth->execute([$title, $id, $_SESSION['uid']]);
79
-			print $title;
80
-		}
81
-	}
78
+            $sth->execute([$title, $id, $_SESSION['uid']]);
79
+            print $title;
80
+        }
81
+    }
82 82
 
83
-	// Silent
84
-	public function remarchive() {
85
-		$ids = explode(",", clean($_REQUEST["ids"]));
83
+    // Silent
84
+    public function remarchive() {
85
+        $ids = explode(",", clean($_REQUEST["ids"]));
86 86
 
87
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_archived_feeds WHERE
87
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_archived_feeds WHERE
88 88
 		  		(SELECT COUNT(*) FROM ttrss_user_entries
89 89
 					WHERE orig_feed_id = :id) = 0 AND
90 90
 						id = :id AND owner_uid = :uid");
91 91
 
92
-		foreach ($ids as $id) {
93
-			$sth->execute([":id" => $id, ":uid" => $_SESSION['uid']]);
94
-		}
95
-	}
92
+        foreach ($ids as $id) {
93
+            $sth->execute([":id" => $id, ":uid" => $_SESSION['uid']]);
94
+        }
95
+    }
96 96
 
97
-	public function addfeed() {
98
-		$feed = clean($_REQUEST['feed']);
99
-		$cat = clean($_REQUEST['cat']);
100
-		$need_auth = isset($_REQUEST['need_auth']);
101
-		$login = $need_auth ? clean($_REQUEST['login']) : '';
102
-		$pass = $need_auth ? trim(clean($_REQUEST['pass'])) : '';
97
+    public function addfeed() {
98
+        $feed = clean($_REQUEST['feed']);
99
+        $cat = clean($_REQUEST['cat']);
100
+        $need_auth = isset($_REQUEST['need_auth']);
101
+        $login = $need_auth ? clean($_REQUEST['login']) : '';
102
+        $pass = $need_auth ? trim(clean($_REQUEST['pass'])) : '';
103 103
 
104
-		$rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass);
104
+        $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass);
105 105
 
106
-		print json_encode(array("result" => $rc));
107
-	}
106
+        print json_encode(array("result" => $rc));
107
+    }
108 108
 
109
-	public function togglepref() {
110
-		$key = clean($_REQUEST["key"]);
111
-		set_pref($key, !get_pref($key));
112
-		$value = get_pref($key);
109
+    public function togglepref() {
110
+        $key = clean($_REQUEST["key"]);
111
+        set_pref($key, !get_pref($key));
112
+        $value = get_pref($key);
113 113
 
114
-		print json_encode(array("param" =>$key, "value" => $value));
115
-	}
114
+        print json_encode(array("param" =>$key, "value" => $value));
115
+    }
116 116
 
117
-	public function setpref() {
118
-		// set_pref escapes input, so no need to double escape it here
119
-		$key = clean($_REQUEST['key']);
120
-		$value = $_REQUEST['value'];
117
+    public function setpref() {
118
+        // set_pref escapes input, so no need to double escape it here
119
+        $key = clean($_REQUEST['key']);
120
+        $value = $_REQUEST['value'];
121 121
 
122
-		set_pref($key, $value, false, $key != 'USER_STYLESHEET');
122
+        set_pref($key, $value, false, $key != 'USER_STYLESHEET');
123 123
 
124
-		print json_encode(array("param" =>$key, "value" => $value));
125
-	}
124
+        print json_encode(array("param" =>$key, "value" => $value));
125
+    }
126 126
 
127
-	public function mark() {
128
-		$mark = clean($_REQUEST["mark"]);
129
-		$id = clean($_REQUEST["id"]);
127
+    public function mark() {
128
+        $mark = clean($_REQUEST["mark"]);
129
+        $id = clean($_REQUEST["id"]);
130 130
 
131
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET marked = ?,
131
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET marked = ?,
132 132
 					last_marked = NOW()
133 133
 					WHERE ref_id = ? AND owner_uid = ?");
134 134
 
135
-		$sth->execute([$mark, $id, $_SESSION['uid']]);
135
+        $sth->execute([$mark, $id, $_SESSION['uid']]);
136 136
 
137
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
138
-	}
137
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
138
+    }
139 139
 
140
-	public function delete() {
141
-		$ids = explode(",", clean($_REQUEST["ids"]));
142
-		$ids_qmarks = arr_qmarks($ids);
140
+    public function delete() {
141
+        $ids = explode(",", clean($_REQUEST["ids"]));
142
+        $ids_qmarks = arr_qmarks($ids);
143 143
 
144
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_user_entries
144
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_user_entries
145 145
 			WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
146
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
146
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
147 147
 
148
-		Article::purge_orphans();
148
+        Article::purge_orphans();
149 149
 
150
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
151
-	}
150
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
151
+    }
152 152
 
153
-	public function unarchive() {
154
-		$ids = explode(",", clean($_REQUEST["ids"]));
153
+    public function unarchive() {
154
+        $ids = explode(",", clean($_REQUEST["ids"]));
155 155
 
156
-		foreach ($ids as $id) {
157
-			$this->pdo->beginTransaction();
156
+        foreach ($ids as $id) {
157
+            $this->pdo->beginTransaction();
158 158
 
159
-			$sth = $this->pdo->prepare("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
159
+            $sth = $this->pdo->prepare("SELECT feed_url,site_url,title FROM ttrss_archived_feeds
160 160
 				WHERE id = (SELECT orig_feed_id FROM ttrss_user_entries WHERE ref_id = :id
161 161
 				AND owner_uid = :uid) AND owner_uid = :uid");
162
-			$sth->execute([":uid" => $_SESSION['uid'], ":id" => $id]);
162
+            $sth->execute([":uid" => $_SESSION['uid'], ":id" => $id]);
163 163
 
164
-			if ($row = $sth->fetch()) {
165
-				$feed_url = $row['feed_url'];
166
-				$site_url = $row['site_url'];
167
-				$title = $row['title'];
164
+            if ($row = $sth->fetch()) {
165
+                $feed_url = $row['feed_url'];
166
+                $site_url = $row['site_url'];
167
+                $title = $row['title'];
168 168
 
169
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
169
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
170 170
 					AND owner_uid = ?");
171
-				$sth->execute([$feed_url, $_SESSION['uid']]);
171
+                $sth->execute([$feed_url, $_SESSION['uid']]);
172 172
 
173
-				if ($row = $sth->fetch()) {
174
-					$feed_id = $row["id"];
175
-				} else {
176
-					if (!$title) $title = '[Unknown]';
173
+                if ($row = $sth->fetch()) {
174
+                    $feed_id = $row["id"];
175
+                } else {
176
+                    if (!$title) $title = '[Unknown]';
177 177
 
178
-					$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
178
+                    $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
179 179
 							(owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method)
180 180
 							VALUES (?, ?, ?, ?, NULL, '', '', 0)");
181
-					$sth->execute([$_SESSION['uid'], $feed_url, $site_url, $title]);
181
+                    $sth->execute([$_SESSION['uid'], $feed_url, $site_url, $title]);
182 182
 
183
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
183
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ?
184 184
 						AND owner_uid = ?");
185
-					$sth->execute([$feed_url, $_SESSION['uid']]);
185
+                    $sth->execute([$feed_url, $_SESSION['uid']]);
186 186
 
187
-					if ($row = $sth->fetch()) {
188
-						$feed_id = $row['id'];
189
-					}
190
-				}
187
+                    if ($row = $sth->fetch()) {
188
+                        $feed_id = $row['id'];
189
+                    }
190
+                }
191 191
 
192
-				if ($feed_id) {
193
-					$sth = $this->pdo->prepare("UPDATE ttrss_user_entries
192
+                if ($feed_id) {
193
+                    $sth = $this->pdo->prepare("UPDATE ttrss_user_entries
194 194
 						SET feed_id = ?, orig_feed_id = NULL
195 195
 						WHERE ref_id = ? AND owner_uid = ?");
196
-					$sth->execute([$feed_id, $id, $_SESSION['uid']]);
197
-				}
198
-			}
196
+                    $sth->execute([$feed_id, $id, $_SESSION['uid']]);
197
+                }
198
+            }
199 199
 
200
-			$this->pdo->commit();
201
-		}
200
+            $this->pdo->commit();
201
+        }
202 202
 
203
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
204
-	}
203
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
204
+    }
205 205
 
206
-	public function archive() {
207
-		$ids = explode(",", clean($_REQUEST["ids"]));
206
+    public function archive() {
207
+        $ids = explode(",", clean($_REQUEST["ids"]));
208 208
 
209
-		foreach ($ids as $id) {
210
-			$this->archive_article($id, $_SESSION["uid"]);
211
-		}
209
+        foreach ($ids as $id) {
210
+            $this->archive_article($id, $_SESSION["uid"]);
211
+        }
212 212
 
213
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
214
-	}
213
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
214
+    }
215 215
 
216
-	private function archive_article($id, $owner_uid) {
217
-		$this->pdo->beginTransaction();
216
+    private function archive_article($id, $owner_uid) {
217
+        $this->pdo->beginTransaction();
218 218
 
219
-		if (!$owner_uid) $owner_uid = $_SESSION['uid'];
219
+        if (!$owner_uid) $owner_uid = $_SESSION['uid'];
220 220
 
221
-		$sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries
221
+        $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries
222 222
 			WHERE ref_id = ? AND owner_uid = ?");
223
-		$sth->execute([$id, $owner_uid]);
223
+        $sth->execute([$id, $owner_uid]);
224 224
 
225
-		if ($row = $sth->fetch()) {
225
+        if ($row = $sth->fetch()) {
226 226
 
227
-			/* prepare the archived table */
227
+            /* prepare the archived table */
228 228
 
229
-			$feed_id = (int) $row['feed_id'];
229
+            $feed_id = (int) $row['feed_id'];
230 230
 
231
-			if ($feed_id) {
232
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_archived_feeds
231
+            if ($feed_id) {
232
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_archived_feeds
233 233
 					WHERE id = ? AND owner_uid = ?");
234
-				$sth->execute([$feed_id, $owner_uid]);
234
+                $sth->execute([$feed_id, $owner_uid]);
235 235
 
236
-				if ($row = $sth->fetch()) {
237
-					$new_feed_id = $row['id'];
238
-				} else {
239
-					$row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch();
240
-					$new_feed_id = (int)$row['id'] + 1;
236
+                if ($row = $sth->fetch()) {
237
+                    $new_feed_id = $row['id'];
238
+                } else {
239
+                    $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch();
240
+                    $new_feed_id = (int)$row['id'] + 1;
241 241
 
242
-					$sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds
242
+                    $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds
243 243
 						(id, owner_uid, title, feed_url, site_url, created)
244 244
 							SELECT ?, owner_uid, title, feed_url, site_url, NOW() from ttrss_feeds
245 245
 							  	WHERE id = ?");
246 246
 
247
-					$sth->execute([$new_feed_id, $feed_id]);
248
-				}
247
+                    $sth->execute([$new_feed_id, $feed_id]);
248
+                }
249 249
 
250
-				$sth = $this->pdo->prepare("UPDATE ttrss_user_entries
250
+                $sth = $this->pdo->prepare("UPDATE ttrss_user_entries
251 251
 					SET orig_feed_id = ?, feed_id = NULL
252 252
 					WHERE ref_id = ? AND owner_uid = ?");
253
-				$sth->execute([$new_feed_id, $id, $owner_uid]);
254
-			}
255
-		}
253
+                $sth->execute([$new_feed_id, $id, $owner_uid]);
254
+            }
255
+        }
256 256
 
257
-		$this->pdo->commit();
258
-	}
257
+        $this->pdo->commit();
258
+    }
259 259
 
260
-	public function publ() {
261
-		$pub = clean($_REQUEST["pub"]);
262
-		$id = clean($_REQUEST["id"]);
260
+    public function publ() {
261
+        $pub = clean($_REQUEST["pub"]);
262
+        $id = clean($_REQUEST["id"]);
263 263
 
264
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
264
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
265 265
 			published = ?, last_published = NOW()
266 266
 			WHERE ref_id = ? AND owner_uid = ?");
267 267
 
268
-		$sth->execute([$pub, $id, $_SESSION['uid']]);
268
+        $sth->execute([$pub, $id, $_SESSION['uid']]);
269 269
 
270
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
271
-	}
270
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
271
+    }
272 272
 
273
-	public function getAllCounters() {
274
-		@$seq = (int) $_REQUEST['seq'];
273
+    public function getAllCounters() {
274
+        @$seq = (int) $_REQUEST['seq'];
275 275
 
276
-		$reply = [
277
-			'counters' => Counters::getAllCounters(),
278
-			'seq' => $seq
279
-		];
276
+        $reply = [
277
+            'counters' => Counters::getAllCounters(),
278
+            'seq' => $seq
279
+        ];
280 280
 
281
-		if ($seq % 2 == 0)
282
-			$reply['runtime-info'] = make_runtime_info();
281
+        if ($seq % 2 == 0)
282
+            $reply['runtime-info'] = make_runtime_info();
283 283
 
284
-		print json_encode($reply);
285
-	}
284
+        print json_encode($reply);
285
+    }
286 286
 
287
-	/* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
288
-	public function catchupSelected() {
289
-		$ids = explode(",", clean($_REQUEST["ids"]));
290
-		$cmode = (int)clean($_REQUEST["cmode"]);
287
+    /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */
288
+    public function catchupSelected() {
289
+        $ids = explode(",", clean($_REQUEST["ids"]));
290
+        $cmode = (int)clean($_REQUEST["cmode"]);
291 291
 
292
-		Article::catchupArticlesById($ids, $cmode);
292
+        Article::catchupArticlesById($ids, $cmode);
293 293
 
294
-		print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
295
-	}
294
+        print json_encode(array("message" => "UPDATE_COUNTERS", "ids" => $ids));
295
+    }
296 296
 
297
-	public function markSelected() {
298
-		$ids = explode(",", clean($_REQUEST["ids"]));
299
-		$cmode = (int)clean($_REQUEST["cmode"]);
297
+    public function markSelected() {
298
+        $ids = explode(",", clean($_REQUEST["ids"]));
299
+        $cmode = (int)clean($_REQUEST["cmode"]);
300 300
 
301
-		$this->markArticlesById($ids, $cmode);
301
+        $this->markArticlesById($ids, $cmode);
302 302
 
303
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
304
-	}
303
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
304
+    }
305 305
 
306
-	public function publishSelected() {
307
-		$ids = explode(",", clean($_REQUEST["ids"]));
308
-		$cmode = (int)clean($_REQUEST["cmode"]);
306
+    public function publishSelected() {
307
+        $ids = explode(",", clean($_REQUEST["ids"]));
308
+        $cmode = (int)clean($_REQUEST["cmode"]);
309 309
 
310
-		$this->publishArticlesById($ids, $cmode);
310
+        $this->publishArticlesById($ids, $cmode);
311 311
 
312
-		print json_encode(array("message" => "UPDATE_COUNTERS"));
313
-	}
312
+        print json_encode(array("message" => "UPDATE_COUNTERS"));
313
+    }
314 314
 
315
-	public function sanityCheck() {
316
-		$_SESSION["hasAudio"] = clean($_REQUEST["hasAudio"]) === "true";
317
-		$_SESSION["hasSandbox"] = clean($_REQUEST["hasSandbox"]) === "true";
318
-		$_SESSION["hasMp3"] = clean($_REQUEST["hasMp3"]) === "true";
319
-		$_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]);
315
+    public function sanityCheck() {
316
+        $_SESSION["hasAudio"] = clean($_REQUEST["hasAudio"]) === "true";
317
+        $_SESSION["hasSandbox"] = clean($_REQUEST["hasSandbox"]) === "true";
318
+        $_SESSION["hasMp3"] = clean($_REQUEST["hasMp3"]) === "true";
319
+        $_SESSION["clientTzOffset"] = clean($_REQUEST["clientTzOffset"]);
320 320
 
321
-		$reply = array();
321
+        $reply = array();
322 322
 
323
-		$reply['error'] = sanity_check();
323
+        $reply['error'] = sanity_check();
324 324
 
325
-		if ($reply['error']['code'] == 0) {
326
-			$reply['init-params'] = make_init_params();
327
-			$reply['runtime-info'] = make_runtime_info();
328
-		}
325
+        if ($reply['error']['code'] == 0) {
326
+            $reply['init-params'] = make_init_params();
327
+            $reply['runtime-info'] = make_runtime_info();
328
+        }
329 329
 
330
-		print json_encode($reply);
331
-	}
330
+        print json_encode($reply);
331
+    }
332 332
 
333
-	public function completeLabels() {
334
-		$search = clean($_REQUEST["search"]);
333
+    public function completeLabels() {
334
+        $search = clean($_REQUEST["search"]);
335 335
 
336
-		$sth = $this->pdo->prepare("SELECT DISTINCT caption FROM
336
+        $sth = $this->pdo->prepare("SELECT DISTINCT caption FROM
337 337
 				ttrss_labels2
338 338
 				WHERE owner_uid = ? AND
339 339
 				LOWER(caption) LIKE LOWER(?) ORDER BY caption
340 340
 				LIMIT 5");
341
-		$sth->execute([$_SESSION['uid'], "%$search%"]);
341
+        $sth->execute([$_SESSION['uid'], "%$search%"]);
342 342
 
343
-		print "<ul>";
344
-		while ($line = $sth->fetch()) {
345
-			print "<li>" . $line["caption"] . "</li>";
346
-		}
347
-		print "</ul>";
348
-	}
343
+        print "<ul>";
344
+        while ($line = $sth->fetch()) {
345
+            print "<li>" . $line["caption"] . "</li>";
346
+        }
347
+        print "</ul>";
348
+    }
349 349
 
350
-	// Silent
351
-	public function massSubscribe() {
350
+    // Silent
351
+    public function massSubscribe() {
352 352
 
353
-		$payload = json_decode(clean($_REQUEST["payload"]), false);
354
-		$mode = clean($_REQUEST["mode"]);
353
+        $payload = json_decode(clean($_REQUEST["payload"]), false);
354
+        $mode = clean($_REQUEST["mode"]);
355 355
 
356
-		if (!$payload || !is_array($payload)) return;
356
+        if (!$payload || !is_array($payload)) return;
357 357
 
358
-		if ($mode == 1) {
359
-			foreach ($payload as $feed) {
358
+        if ($mode == 1) {
359
+            foreach ($payload as $feed) {
360 360
 
361
-				$title = $feed[0];
362
-				$feed_url = $feed[1];
361
+                $title = $feed[0];
362
+                $feed_url = $feed[1];
363 363
 
364
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
364
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
365 365
 					feed_url = ? AND owner_uid = ?");
366
-				$sth->execute([$feed_url, $_SESSION['uid']]);
366
+                $sth->execute([$feed_url, $_SESSION['uid']]);
367 367
 
368
-				if (!$sth->fetch()) {
369
-					$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
368
+                if (!$sth->fetch()) {
369
+                    $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
370 370
 									(owner_uid,feed_url,title,cat_id,site_url)
371 371
 									VALUES (?, ?, ?, NULL, '')");
372 372
 
373
-					$sth->execute([$_SESSION['uid'], $feed_url, $title]);
374
-				}
375
-			}
376
-		} else if ($mode == 2) {
377
-			// feed archive
378
-			foreach ($payload as $id) {
379
-				$sth = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
373
+                    $sth->execute([$_SESSION['uid'], $feed_url, $title]);
374
+                }
375
+            }
376
+        } else if ($mode == 2) {
377
+            // feed archive
378
+            foreach ($payload as $id) {
379
+                $sth = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds
380 380
 					WHERE id = ? AND owner_uid = ?");
381
-				$sth->execute([$id, $_SESSION['uid']]);
381
+                $sth->execute([$id, $_SESSION['uid']]);
382 382
 
383
-				if ($row = $sth->fetch()) {
384
-					$site_url = $row['site_url'];
385
-					$feed_url = $row['feed_url'];
386
-					$title = $row['title'];
383
+                if ($row = $sth->fetch()) {
384
+                    $site_url = $row['site_url'];
385
+                    $feed_url = $row['feed_url'];
386
+                    $title = $row['title'];
387 387
 
388
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
388
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
389 389
 						feed_url = ? AND owner_uid = ?");
390
-					$sth->execute([$feed_url, $_SESSION['uid']]);
390
+                    $sth->execute([$feed_url, $_SESSION['uid']]);
391 391
 
392
-					if (!$sth->fetch()) {
393
-						$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
392
+                    if (!$sth->fetch()) {
393
+                        $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
394 394
 								(owner_uid,feed_url,title,cat_id,site_url)
395 395
 									VALUES (?, ?, ?, NULL, ?)");
396 396
 
397
-						$sth->execute([$_SESSION['uid'], $feed_url, $title, $site_url]);
398
-					}
399
-				}
400
-			}
401
-		}
402
-	}
397
+                        $sth->execute([$_SESSION['uid'], $feed_url, $title, $site_url]);
398
+                    }
399
+                }
400
+            }
401
+        }
402
+    }
403 403
 
404
-	public function catchupFeed() {
405
-		$feed_id = clean($_REQUEST['feed_id']);
406
-		$is_cat = clean($_REQUEST['is_cat']) == "true";
407
-		$mode = clean($_REQUEST['mode']);
408
-		$search_query = clean($_REQUEST['search_query']);
409
-		$search_lang = clean($_REQUEST['search_lang']);
404
+    public function catchupFeed() {
405
+        $feed_id = clean($_REQUEST['feed_id']);
406
+        $is_cat = clean($_REQUEST['is_cat']) == "true";
407
+        $mode = clean($_REQUEST['mode']);
408
+        $search_query = clean($_REQUEST['search_query']);
409
+        $search_lang = clean($_REQUEST['search_lang']);
410 410
 
411
-		Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]);
411
+        Feeds::catchup_feed($feed_id, $is_cat, false, $mode, [$search_query, $search_lang]);
412 412
 
413
-		// return counters here synchronously so that frontend can figure out next unread feed properly
414
-		print json_encode(['counters' => Counters::getAllCounters()]);
413
+        // return counters here synchronously so that frontend can figure out next unread feed properly
414
+        print json_encode(['counters' => Counters::getAllCounters()]);
415 415
 
416
-		//print json_encode(array("message" => "UPDATE_COUNTERS"));
417
-	}
416
+        //print json_encode(array("message" => "UPDATE_COUNTERS"));
417
+    }
418 418
 
419
-	public function setpanelmode() {
420
-		$wide = (int) clean($_REQUEST["wide"]);
419
+    public function setpanelmode() {
420
+        $wide = (int) clean($_REQUEST["wide"]);
421 421
 
422
-		setcookie("ttrss_widescreen", $wide,
423
-			time() + COOKIE_LIFETIME_LONG);
422
+        setcookie("ttrss_widescreen", $wide,
423
+            time() + COOKIE_LIFETIME_LONG);
424 424
 
425
-		print json_encode(array("wide" => $wide));
426
-	}
425
+        print json_encode(array("wide" => $wide));
426
+    }
427 427
 
428
-	public static function updaterandomfeed_real() {
428
+    public static function updaterandomfeed_real() {
429 429
 
430
-		// Test if the feed need a update (update interval exceded).
431
-		if (DB_TYPE == "pgsql") {
432
-			$update_limit_qpart = "AND ((
430
+        // Test if the feed need a update (update interval exceded).
431
+        if (DB_TYPE == "pgsql") {
432
+            $update_limit_qpart = "AND ((
433 433
 					ttrss_feeds.update_interval = 0
434 434
 					AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL)
435 435
 				) OR (
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
 					AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL)
438 438
 				) OR ttrss_feeds.last_updated IS NULL
439 439
 				OR last_updated = '1970-01-01 00:00:00')";
440
-		} else {
441
-			$update_limit_qpart = "AND ((
440
+        } else {
441
+            $update_limit_qpart = "AND ((
442 442
 					ttrss_feeds.update_interval = 0
443 443
 					AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE)
444 444
 				) OR (
@@ -446,28 +446,28 @@  discard block
 block discarded – undo
446 446
 					AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE)
447 447
 				) OR ttrss_feeds.last_updated IS NULL
448 448
 				OR last_updated = '1970-01-01 00:00:00')";
449
-		}
449
+        }
450 450
 
451
-		// Test if feed is currently being updated by another process.
452
-		if (DB_TYPE == "pgsql") {
453
-			$updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
454
-		} else {
455
-			$updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
456
-		}
451
+        // Test if feed is currently being updated by another process.
452
+        if (DB_TYPE == "pgsql") {
453
+            $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
454
+        } else {
455
+            $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
456
+        }
457 457
 
458
-		$random_qpart = sql_random_function();
458
+        $random_qpart = sql_random_function();
459 459
 
460
-		$pdo = Db::pdo();
460
+        $pdo = Db::pdo();
461 461
 
462
-		// we could be invoked from public.php with no active session
463
-		if ($_SESSION["uid"]) {
464
-			$owner_check_qpart = "AND ttrss_feeds.owner_uid = ".$pdo->quote($_SESSION["uid"]);
465
-		} else {
466
-			$owner_check_qpart = "";
467
-		}
462
+        // we could be invoked from public.php with no active session
463
+        if ($_SESSION["uid"]) {
464
+            $owner_check_qpart = "AND ttrss_feeds.owner_uid = ".$pdo->quote($_SESSION["uid"]);
465
+        } else {
466
+            $owner_check_qpart = "";
467
+        }
468 468
 
469
-		// We search for feed needing update.
470
-		$res = $pdo->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
469
+        // We search for feed needing update.
470
+        $res = $pdo->query("SELECT ttrss_feeds.feed_url,ttrss_feeds.id
471 471
 			FROM
472 472
 				ttrss_feeds, ttrss_users, ttrss_user_prefs
473 473
 			WHERE
@@ -479,139 +479,139 @@  discard block
 block discarded – undo
479 479
 				$updstart_thresh_qpart
480 480
 			ORDER BY $random_qpart LIMIT 30");
481 481
 
482
-		$num_updated = 0;
482
+        $num_updated = 0;
483 483
 
484
-		$tstart = time();
484
+        $tstart = time();
485 485
 
486
-		while ($line = $res->fetch()) {
487
-			$feed_id = $line["id"];
486
+        while ($line = $res->fetch()) {
487
+            $feed_id = $line["id"];
488 488
 
489
-			if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
490
-				RSSUtils::update_rss_feed($feed_id, true);
491
-				++$num_updated;
492
-			} else {
493
-				break;
494
-			}
495
-		}
489
+            if (time() - $tstart < ini_get("max_execution_time") * 0.7) {
490
+                RSSUtils::update_rss_feed($feed_id, true);
491
+                ++$num_updated;
492
+            } else {
493
+                break;
494
+            }
495
+        }
496 496
 
497
-		// Purge orphans and cleanup tags
498
-		Article::purge_orphans();
499
-		//cleanup_tags(14, 50000);
497
+        // Purge orphans and cleanup tags
498
+        Article::purge_orphans();
499
+        //cleanup_tags(14, 50000);
500 500
 
501
-		if ($num_updated > 0) {
502
-			print json_encode(array("message" => "UPDATE_COUNTERS",
503
-				"num_updated" => $num_updated));
504
-		} else {
505
-			print json_encode(array("message" => "NOTHING_TO_UPDATE"));
506
-		}
501
+        if ($num_updated > 0) {
502
+            print json_encode(array("message" => "UPDATE_COUNTERS",
503
+                "num_updated" => $num_updated));
504
+        } else {
505
+            print json_encode(array("message" => "NOTHING_TO_UPDATE"));
506
+        }
507 507
 
508
-	}
508
+    }
509 509
 
510
-	public function updaterandomfeed() {
511
-		RPC::updaterandomfeed_real();
512
-	}
510
+    public function updaterandomfeed() {
511
+        RPC::updaterandomfeed_real();
512
+    }
513 513
 
514
-	private function markArticlesById($ids, $cmode) {
514
+    private function markArticlesById($ids, $cmode) {
515 515
 
516
-		$ids_qmarks = arr_qmarks($ids);
516
+        $ids_qmarks = arr_qmarks($ids);
517 517
 
518
-		if ($cmode == 0) {
519
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
518
+        if ($cmode == 0) {
519
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
520 520
 				marked = false, last_marked = NOW()
521 521
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
522
-		} else if ($cmode == 1) {
523
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
522
+        } else if ($cmode == 1) {
523
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
524 524
 				marked = true, last_marked = NOW()
525 525
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
526
-		} else {
527
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
526
+        } else {
527
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
528 528
 				marked = NOT marked,last_marked = NOW()
529 529
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
530
-		}
530
+        }
531 531
 
532
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
533
-	}
532
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
533
+    }
534 534
 
535
-	private function publishArticlesById($ids, $cmode) {
535
+    private function publishArticlesById($ids, $cmode) {
536 536
 
537
-		$ids_qmarks = arr_qmarks($ids);
537
+        $ids_qmarks = arr_qmarks($ids);
538 538
 
539
-		if ($cmode == 0) {
540
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
539
+        if ($cmode == 0) {
540
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
541 541
 				published = false, last_published = NOW()
542 542
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
543
-		} else if ($cmode == 1) {
544
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
543
+        } else if ($cmode == 1) {
544
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
545 545
 				published = true, last_published = NOW()
546 546
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
547
-		} else {
548
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
547
+        } else {
548
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET
549 549
 				published = NOT published,last_published = NOW()
550 550
 					WHERE ref_id IN ($ids_qmarks) AND owner_uid = ?");
551
-		}
551
+        }
552 552
 
553
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
554
-	}
553
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
554
+    }
555 555
 
556
-	public function getlinktitlebyid() {
557
-		$id = clean($_REQUEST['id']);
556
+    public function getlinktitlebyid() {
557
+        $id = clean($_REQUEST['id']);
558 558
 
559
-		$sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries
559
+        $sth = $this->pdo->prepare("SELECT link, title FROM ttrss_entries, ttrss_user_entries
560 560
 			WHERE ref_id = ? AND ref_id = id AND owner_uid = ?");
561
-		$sth->execute([$id, $_SESSION['uid']]);
561
+        $sth->execute([$id, $_SESSION['uid']]);
562 562
 
563
-		if ($row = $sth->fetch()) {
564
-			$link = $row['link'];
565
-			$title = $row['title'];
563
+        if ($row = $sth->fetch()) {
564
+            $link = $row['link'];
565
+            $title = $row['title'];
566 566
 
567
-			echo json_encode(array("link" => $link, "title" => $title));
568
-		} else {
569
-			echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
570
-		}
571
-	}
567
+            echo json_encode(array("link" => $link, "title" => $title));
568
+        } else {
569
+            echo json_encode(array("error" => "ARTICLE_NOT_FOUND"));
570
+        }
571
+    }
572 572
 
573
-	public function log() {
574
-		$msg = clean($_REQUEST['msg']);
575
-		$file = clean_filename($_REQUEST['file']);
576
-		$line = (int) clean($_REQUEST['line']);
577
-		$context = clean($_REQUEST['context']);
573
+    public function log() {
574
+        $msg = clean($_REQUEST['msg']);
575
+        $file = clean_filename($_REQUEST['file']);
576
+        $line = (int) clean($_REQUEST['line']);
577
+        $context = clean($_REQUEST['context']);
578 578
 
579
-		if ($msg) {
580
-			Logger::get()->log_error(E_USER_WARNING,
581
-				$msg, 'client-js:' . $file, $line, $context);
579
+        if ($msg) {
580
+            Logger::get()->log_error(E_USER_WARNING,
581
+                $msg, 'client-js:' . $file, $line, $context);
582 582
 
583
-			echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
584
-		} else {
585
-			echo json_encode(array("error" => "MESSAGE_NOT_FOUND"));
586
-		}
583
+            echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
584
+        } else {
585
+            echo json_encode(array("error" => "MESSAGE_NOT_FOUND"));
586
+        }
587 587
 
588
-	}
588
+    }
589 589
 
590
-	public function checkforupdates() {
591
-		$rv = [];
590
+    public function checkforupdates() {
591
+        $rv = [];
592 592
 
593
-		$git_timestamp = false;
594
-		$git_commit = false;
593
+        $git_timestamp = false;
594
+        $git_commit = false;
595 595
 
596
-		get_version($git_commit, $git_timestamp);
596
+        get_version($git_commit, $git_timestamp);
597 597
 
598
-		if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) {
599
-			$content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]);
598
+        if (CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) {
599
+            $content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]);
600 600
 
601
-			if ($content) {
602
-				$content = json_decode($content, true);
601
+            if ($content) {
602
+                $content = json_decode($content, true);
603 603
 
604
-				if ($content && isset($content["changeset"])) {
605
-					if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
606
-						$git_commit != $content["changeset"]["id"]) {
604
+                if ($content && isset($content["changeset"])) {
605
+                    if ($git_timestamp < (int)$content["changeset"]["timestamp"] &&
606
+                        $git_commit != $content["changeset"]["id"]) {
607 607
 
608
-						$rv = $content["changeset"];
609
-					}
610
-				}
611
-			}
612
-		}
608
+                        $rv = $content["changeset"];
609
+                    }
610
+                }
611
+            }
612
+        }
613 613
 
614
-		print json_encode($rv);
615
-	}
614
+        print json_encode($rv);
615
+    }
616 616
 
617 617
 }
Please login to merge, or discard this patch.
classes/mailer.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@
 block discarded – undo
1 1
 <?php
2 2
 class Mailer {
3
-	// TODO: support HTML mail (i.e. MIME messages)
3
+    // TODO: support HTML mail (i.e. MIME messages)
4 4
 
5
-	private $last_error = "Unable to send mail: check local configuration.";
5
+    private $last_error = "Unable to send mail: check local configuration.";
6 6
 
7
-	public function mail($params) {
7
+    public function mail($params) {
8 8
 
9
-		$to_name = $params["to_name"];
10
-		$to_address = $params["to_address"];
11
-		$subject = $params["subject"];
12
-		$message = $params["message"];
13
-		$from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME;
14
-		$from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS;
9
+        $to_name = $params["to_name"];
10
+        $to_address = $params["to_address"];
11
+        $subject = $params["subject"];
12
+        $message = $params["message"];
13
+        $from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME;
14
+        $from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS;
15 15
 
16
-		$additional_headers = $params["headers"] ? $params["headers"] : [];
16
+        $additional_headers = $params["headers"] ? $params["headers"] : [];
17 17
 
18
-		$from_combined = $from_name ? "$from_name <$from_address>" : $from_address;
19
-		$to_combined = $to_name ? "$to_name <$to_address>" : $to_address;
18
+        $from_combined = $from_name ? "$from_name <$from_address>" : $from_address;
19
+        $to_combined = $to_name ? "$to_name <$to_address>" : $to_address;
20 20
 
21
-		if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL)
22
-			Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message");
21
+        if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL)
22
+            Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message");
23 23
 
24
-		// HOOK_SEND_MAIL plugin instructions:
25
-		// 1. return 1 or true if mail is handled
26
-		// 2. return -1 if there's been a fatal error and no further action is allowed
27
-		// 3. any other return value will allow cycling to the next handler and, eventually, to default mail() function
28
-		// 4. set error message if needed via passed Mailer instance function set_error()
24
+        // HOOK_SEND_MAIL plugin instructions:
25
+        // 1. return 1 or true if mail is handled
26
+        // 2. return -1 if there's been a fatal error and no further action is allowed
27
+        // 3. any other return value will allow cycling to the next handler and, eventually, to default mail() function
28
+        // 4. set error message if needed via passed Mailer instance function set_error()
29 29
 
30
-		foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) {
31
-			$rc = $p->hook_send_mail($this, $params);
30
+        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) {
31
+            $rc = $p->hook_send_mail($this, $params);
32 32
 
33
-			if ($rc == 1)
34
-				return $rc;
33
+            if ($rc == 1)
34
+                return $rc;
35 35
 
36
-			if ($rc == -1)
37
-				return 0;
38
-		}
36
+            if ($rc == -1)
37
+                return 0;
38
+        }
39 39
 
40
-		$headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ];
40
+        $headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ];
41 41
 
42
-		return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers)));
43
-	}
42
+        return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers)));
43
+    }
44 44
 
45
-	public function set_error($message) {
46
-		$this->last_error = $message;
47
-	}
45
+    public function set_error($message) {
46
+        $this->last_error = $message;
47
+    }
48 48
 
49
-	public function error() {
50
-		return $this->last_error;
51
-	}
49
+    public function error() {
50
+        return $this->last_error;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
classes/feeditem.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 abstract class FeedItem {
3
-	abstract function get_id();
4
-	abstract function get_date();
5
-	abstract function get_link();
6
-	abstract function get_title();
7
-	abstract function get_description();
8
-	abstract function get_content();
9
-	abstract function get_comments_url();
10
-	abstract function get_comments_count();
11
-	abstract function get_categories();
12
-	abstract function get_enclosures();
13
-	abstract function get_author();
14
-	abstract function get_language();
3
+    abstract function get_id();
4
+    abstract function get_date();
5
+    abstract function get_link();
6
+    abstract function get_title();
7
+    abstract function get_description();
8
+    abstract function get_content();
9
+    abstract function get_comments_url();
10
+    abstract function get_comments_count();
11
+    abstract function get_categories();
12
+    abstract function get_enclosures();
13
+    abstract function get_author();
14
+    abstract function get_language();
15 15
 }
16 16
 
Please login to merge, or discard this patch.
classes/ihandler.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 interface IHandler {
3
-	public function csrf_ignore($method);
4
-	public function before($method);
5
-	public function after();
3
+    public function csrf_ignore($method);
4
+    public function before($method);
5
+    public function after();
6 6
 }
Please login to merge, or discard this patch.