Completed
Push — master ( 40b7eb...708e0f )
by Christian
07:55
created
html/inc/geoip.inc 5 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -229,6 +229,9 @@  discard block
 block discarded – undo
229 229
   shmop_close ($shmid);
230 230
 }
231 231
 
232
+/**
233
+ * @param GeoIP $gi
234
+ */
232 235
 function _setup_segments($gi){
233 236
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 237
   $gi->record_length = STANDARD_RECORD_LENGTH;
@@ -311,6 +314,10 @@  discard block
 block discarded – undo
311 314
   return $gi;
312 315
 }
313 316
 
317
+/**
318
+ * @param string $filename
319
+ * @param integer $flags
320
+ */
314 321
 function geoip_open($filename, $flags) {
315 322
   $gi = new GeoIP;
316 323
   $gi->flags = $flags;
@@ -419,6 +426,9 @@  discard block
 block discarded – undo
419 426
   return false;
420 427
 }
421 428
 
429
+/**
430
+ * @param integer $ipnum
431
+ */
422 432
 function _get_org($gi,$ipnum){
423 433
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 434
   if ($seek_org == $gi->databaseSegments) {
@@ -443,6 +453,9 @@  discard block
 block discarded – undo
443 453
   return _get_org($gi, $ipnum);
444 454
 }
445 455
 
456
+/**
457
+ * @param integer $ipnum
458
+ */
446 459
 function _get_region($gi,$ipnum){
447 460
   if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448 461
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
Please login to merge, or discard this patch.
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 }
214 214
 function geoip_load_shared_mem ($file) {
215 215
 
216
-  $fp = fopen($file, "rb");
217
-  if (!$fp) {
216
+    $fp = fopen($file, "rb");
217
+    if (!$fp) {
218 218
     print "error opening $file: $php_errormsg\n";
219 219
     exit;
220
-  }
221
-  $s_array = fstat($fp);
222
-  $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
220
+    }
221
+    $s_array = fstat($fp);
222
+    $size = $s_array['size'];
223
+    if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224 224
     shmop_delete ($shmid);
225 225
     shmop_close ($shmid);
226
-  }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
226
+    }
227
+    $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
+    shmop_write ($shmid, fread($fp, $size), 0);
229
+    shmop_close ($shmid);
230 230
 }
231 231
 
232 232
 function _setup_segments($gi){
233
-  $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
-  $gi->record_length = STANDARD_RECORD_LENGTH;
235
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
233
+    $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
+    $gi->record_length = STANDARD_RECORD_LENGTH;
235
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
236 236
     $offset = @shmop_size ($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238 238
         $delim = @shmop_read ($gi->shmid, $offset, 3);
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246 246
             } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+        } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251
-		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
251
+            || ($gi->databaseType == GEOIP_ISP_EDITION)
252
+            || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
253 253
                 $gi->databaseSegments = 0;
254 254
                 $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255 255
                 for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256 256
                     $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
-			($gi->databaseType == GEOIP_ISP_EDITION)) {
260
-	                $gi->record_length = ORG_RECORD_LENGTH;
258
+                if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
+            ($gi->databaseType == GEOIP_ISP_EDITION)) {
260
+                    $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
262 262
             }
263 263
             break;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273
-  } else {
273
+    } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283 283
         else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
284
-	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
284
+        $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285 285
                 }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288
-		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
288
+         ($gi->databaseType == GEOIP_ISP_EDITION) || 
289 289
                  ($gi->databaseType == GEOIP_ASNUM_EDITION)){
290 290
             $gi->databaseSegments = 0;
291 291
             $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292 292
             for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293 293
             $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
294 294
             }
295
-	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
-	    $gi->record_length = ORG_RECORD_LENGTH;
295
+        if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
+        $gi->record_length = ORG_RECORD_LENGTH;
297 297
             }
298 298
         }
299 299
         break;
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305 305
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
306 306
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
307
-         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
307
+            $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309 309
     fseek($gi->filehandle,$filepos,SEEK_SET);
310
-  }
311
-  return $gi;
310
+    }
311
+    return $gi;
312 312
 }
313 313
 
314 314
 function geoip_open($filename, $flags) {
315
-  $gi = new GeoIP;
316
-  $gi->flags = $flags;
317
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
315
+    $gi = new GeoIP;
316
+    $gi->flags = $flags;
317
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
318 318
     $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320 320
     $gi->filehandle = fopen($filename,"rb");
@@ -322,174 +322,174 @@  discard block
 block discarded – undo
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
324 324
     }
325
-  }
325
+    }
326 326
 
327
-  $gi = _setup_segments($gi);
328
-  return $gi;
327
+    $gi = _setup_segments($gi);
328
+    return $gi;
329 329
 }
330 330
 
331 331
 function geoip_close($gi) {
332
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
332
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
333 333
     return true;
334
-  }
334
+    }
335 335
 
336
-  return fclose($gi->filehandle);
336
+    return fclose($gi->filehandle);
337 337
 }
338 338
 
339 339
 function geoip_country_id_by_name($gi, $name) {
340
-  $addr = gethostbyname($name);
341
-  if (!$addr || $addr == $name) {
340
+    $addr = gethostbyname($name);
341
+    if (!$addr || $addr == $name) {
342 342
     return false;
343
-  }
344
-  return geoip_country_id_by_addr($gi, $addr);
343
+    }
344
+    return geoip_country_id_by_addr($gi, $addr);
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
349
-  if ($country_id !== false) {
348
+    $country_id = geoip_country_id_by_name($gi,$name);
349
+    if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351
-  }
352
-  return false;
351
+    }
352
+    return false;
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
357
-  if ($country_id !== false) {
356
+    $country_id = geoip_country_id_by_name($gi,$name);
357
+    if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359
-  }
360
-  return false;
359
+    }
360
+    return false;
361 361
 }
362 362
 
363 363
 function geoip_country_id_by_addr($gi, $addr) {
364
-  $ipnum = ip2long($addr);
365
-  return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
364
+    $ipnum = ip2long($addr);
365
+    return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
370
-  if ($country_id !== false) {
369
+    $country_id = geoip_country_id_by_addr($gi,$addr);
370
+    if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372
-  }
373
-  return false;
372
+    }
373
+    return false;
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
378
-  if ($country_id !== false) {
377
+    $country_id = geoip_country_id_by_addr($gi,$addr);
378
+    if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380
-  }
381
-  return false;
380
+    }
381
+    return false;
382 382
 }
383 383
 
384 384
 function _geoip_seek_country($gi, $ipnum) {
385
-  $offset = 0;
386
-  for ($depth = 31; $depth >= 0; --$depth) {
385
+    $offset = 0;
386
+    for ($depth = 31; $depth >= 0; --$depth) {
387 387
     if ($gi->flags & GEOIP_MEMORY_CACHE) {
388
-      $buf = substr($gi->memory_buffer,
388
+        $buf = substr($gi->memory_buffer,
389 389
                             2 * $gi->record_length * $offset,
390 390
                             2 * $gi->record_length);
391 391
         } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
392
+        $buf = @shmop_read ($gi->shmid, 
393 393
                             2 * $gi->record_length * $offset,
394 394
                             2 * $gi->record_length );
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+        fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+        $buf = fread($gi->filehandle, 2 * $gi->record_length);
399 399
     }
400 400
     $x = array(0,0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402
-      for ($j = 0; $j < $gi->record_length; ++$j) {
402
+        for ($j = 0; $j < $gi->record_length; ++$j) {
403 403
         $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
404
-      }
404
+        }
405 405
     }
406 406
     if ($ipnum & (1 << $depth)) {
407
-      if ($x[1] >= $gi->databaseSegments) {
407
+        if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409
-      }
410
-      $offset = $x[1];
409
+        }
410
+        $offset = $x[1];
411 411
         } else {
412
-      if ($x[0] >= $gi->databaseSegments) {
412
+        if ($x[0] >= $gi->databaseSegments) {
413 413
         return $x[0];
414
-      }
415
-      $offset = $x[0];
414
+        }
415
+        $offset = $x[0];
416
+    }
416 417
     }
417
-  }
418
-  trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
-  return false;
418
+    trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
+    return false;
420 420
 }
421 421
 
422 422
 function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
424
-  if ($seek_org == $gi->databaseSegments) {
423
+    $seek_org = _geoip_seek_country($gi,$ipnum);
424
+    if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426
-  }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
426
+    }
427
+    $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
429 429
     $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432 432
     $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
433
-  }
434
-  $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
-  return $org_buf;
433
+    }
434
+    $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
+    return $org_buf;
436 436
 }
437 437
 
438 438
 function geoip_org_by_addr ($gi,$addr) {
439
-  if ($addr == NULL) {
439
+    if ($addr == NULL) {
440 440
     return 0;
441
-  }
442
-  $ipnum = ip2long($addr);
443
-  return _get_org($gi, $ipnum);
441
+    }
442
+    $ipnum = ip2long($addr);
443
+    return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446 446
 function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
447
+    if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448 448
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449 449
     if ($seek_region >= 1000){
450
-      $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
450
+        $country_code = "US";
451
+        $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454
-      $region = "";
454
+        $region = "";
455 455
     }
456
-  return array ($country_code,$region);
456
+    return array ($country_code,$region);
457 457
     }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 458
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460 460
     if ($seek_region < US_OFFSET){
461
-      $country_code = "";
462
-      $region = "";  
461
+        $country_code = "";
462
+        $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464
-      $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
464
+        $country_code = "US";
465
+        $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467
-      $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
467
+        $country_code = "CA";
468
+        $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470 470
             $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
471
-      $region = "";
471
+        $region = "";
472
+    }
473
+    return array ($country_code,$region);
472 474
     }
473
-  return array ($country_code,$region);
474
-  }
475 475
 }
476 476
 
477 477
 function geoip_region_by_addr ($gi,$addr) {
478
-  if ($addr == NULL) {
478
+    if ($addr == NULL) {
479 479
     return 0;
480
-  }
481
-  $ipnum = ip2long($addr);
482
-  return _get_region($gi, $ipnum);
480
+    }
481
+    $ipnum = ip2long($addr);
482
+    return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485 485
 function getdnsattributes ($l,$ip){
486
-  $r = new Net_DNS_Resolver();
487
-  $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
491
-  $str = $regs[1];
492
-  return $str;
486
+    $r = new Net_DNS_Resolver();
487
+    $r->nameservers = array("ws1.maxmind.com");
488
+    $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
+    $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
+    ereg("\"(.*)\"",$str,$regs);
491
+    $str = $regs[1];
492
+    return $str;
493 493
 }
494 494
 
495 495
 ?>
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
 "VU", "WF", "WS", "YE", "YT", "CS", "ZA", "ZM", "ZR", "ZW", "A1", "A2", "O1"
139 139
 );
140 140
     var $GEOIP_COUNTRY_CODES3 = array(
141
-"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG",
142
-"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
143
-"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC",
144
-"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
145
-"CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
146
-"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
147
-"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM",
148
-"GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO",
149
-"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
150
-"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
151
-"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
152
-"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
153
-"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
154
-"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
155
-"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
156
-"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF",
157
-"TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA",
158
-"UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
159
-        "WLF","WSM","YEM","YT","SCG","ZAF","ZMB","ZR","ZWE","A1","A2","O1"
141
+"", "AP", "EU", "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT", "AGO", "AQ", "ARG",
142
+"ASM", "AUT", "AUS", "ABW", "AZE", "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
143
+"BEN", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BV", "BWA", "BLR", "BLZ", "CAN", "CC",
144
+"COD", "CAF", "COG", "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", "CUB", "CPV",
145
+"CX", "CYP", "CZE", "DEU", "DJI", "DNK", "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH",
146
+"ERI", "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", "FX", "GAB", "GBR", "GRD",
147
+"GEO", "GUF", "GHA", "GIB", "GRL", "GMB", "GIN", "GLP", "GNQ", "GRC", "GS", "GTM", "GUM",
148
+"GNB", "GUY", "HKG", "HM", "HND", "HRV", "HTI", "HUN", "IDN", "IRL", "ISR", "IND", "IO",
149
+"IRQ", "IRN", "ISL", "ITA", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", "COM", "KNA",
150
+"PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU",
151
+"LUX", "LVA", "LBY", "MAR", "MCO", "MDA", "MDG", "MHL", "MKD", "MLI", "MMR", "MNG", "MAC",
152
+"MNP", "MTQ", "MRT", "MSR", "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", "NCL",
153
+"NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", "NRU", "NIU", "NZL", "OMN", "PAN", "PER",
154
+"PYF", "PNG", "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", "PLW", "PRY", "QAT",
155
+"REU", "ROU", "RUS", "RWA", "SAU", "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
156
+"SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV", "SYR", "SWZ", "TCA", "TCD", "TF",
157
+"TGO", "THA", "TJK", "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", "TWN", "TZA",
158
+"UKR", "UGA", "UM", "USA", "URY", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT",
159
+        "WLF", "WSM", "YEM", "YT", "SCG", "ZAF", "ZMB", "ZR", "ZWE", "A1", "A2", "O1"
160 160
     );
161 161
     var $GEOIP_COUNTRY_NAMES = array(
162 162
 "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
209 209
 "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
210 210
 "Serbia and Montenegro", "South Africa", "Zambia", "Zaire", "Zimbabwe",
211
-"Anonymous Proxy","Satellite Provider","Other"
211
+"Anonymous Proxy", "Satellite Provider", "Other"
212 212
 );
213 213
 }
214
-function geoip_load_shared_mem ($file) {
214
+function geoip_load_shared_mem($file) {
215 215
 
216 216
   $fp = fopen($file, "rb");
217 217
   if (!$fp) {
@@ -220,42 +220,42 @@  discard block
 block discarded – undo
220 220
   }
221 221
   $s_array = fstat($fp);
222 222
   $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224
-    shmop_delete ($shmid);
225
-    shmop_close ($shmid);
223
+  if ($shmid = @shmop_open(GEOIP_SHM_KEY, "w", 0, 0)) {
224
+    shmop_delete($shmid);
225
+    shmop_close($shmid);
226 226
   }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
227
+  $shmid = shmop_open(GEOIP_SHM_KEY, "c", 0644, $size);
228
+  shmop_write($shmid, fread($fp, $size), 0);
229
+  shmop_close($shmid);
230 230
 }
231 231
 
232
-function _setup_segments($gi){
232
+function _setup_segments($gi) {
233 233
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 234
   $gi->record_length = STANDARD_RECORD_LENGTH;
235
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
236
-    $offset = @shmop_size ($gi->shmid) - 3;
235
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
236
+    $offset = @shmop_size($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238
-        $delim = @shmop_read ($gi->shmid, $offset, 3);
238
+        $delim = @shmop_read($gi->shmid, $offset, 3);
239 239
         $offset += 3;
240 240
         if ($delim == (chr(255).chr(255).chr(255))) {
241
-            $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
241
+            $gi->databaseType = ord(@shmop_read($gi->shmid, $offset, 1));
242 242
             $offset++;
243 243
 
244
-            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
244
+            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246
-            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
246
+            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251 251
 		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
252
+		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
253 253
                 $gi->databaseSegments = 0;
254
-                $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
-                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256
-                    $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
254
+                $buf = @shmop_read($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
+                for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
256
+                    $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
258
+	            if (($gi->databaseType == GEOIP_ORG_EDITION) ||
259 259
 			($gi->databaseType == GEOIP_ISP_EDITION)) {
260 260
 	                $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
@@ -265,32 +265,32 @@  discard block
 block discarded – undo
265 265
             $offset -= 4;
266 266
         }
267 267
     }
268
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
269
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
270
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
268
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
269
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
270
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273 273
   } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
277
-        $delim = fread($gi->filehandle,3);
278
-        if ($delim == (chr(255).chr(255).chr(255))){
279
-        $gi->databaseType = ord(fread($gi->filehandle,1));
280
-        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
277
+        $delim = fread($gi->filehandle, 3);
278
+        if ($delim == (chr(255).chr(255).chr(255))) {
279
+        $gi->databaseType = ord(fread($gi->filehandle, 1));
280
+        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
283
+        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
284 284
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
285
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 288
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
289
-                 ($gi->databaseType == GEOIP_ASNUM_EDITION)){
289
+                 ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
290 290
             $gi->databaseSegments = 0;
291
-            $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292
-            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293
-            $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
291
+            $buf = fread($gi->filehandle, SEGMENT_RECORD_LENGTH);
292
+            for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
293
+            $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
294 294
             }
295 295
 	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296 296
 	    $gi->record_length = ORG_RECORD_LENGTH;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
         fseek($gi->filehandle, -4, SEEK_CUR);
302 302
         }
303 303
     }
304
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
306
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
304
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
305
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
306
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
307 307
          $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309
-    fseek($gi->filehandle,$filepos,SEEK_SET);
309
+    fseek($gi->filehandle, $filepos, SEEK_SET);
310 310
   }
311 311
   return $gi;
312 312
 }
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 function geoip_open($filename, $flags) {
315 315
   $gi = new GeoIP;
316 316
   $gi->flags = $flags;
317
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
318
-    $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
317
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
318
+    $gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320
-    $gi->filehandle = fopen($filename,"rb");
321
-    if ($gi->flags & GEOIP_MEMORY_CACHE) {
320
+    $gi->filehandle = fopen($filename, "rb");
321
+    if ($gi->flags&GEOIP_MEMORY_CACHE) {
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
324 324
     }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 }
330 330
 
331 331
 function geoip_close($gi) {
332
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
332
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
333 333
     return true;
334 334
   }
335 335
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
348
+  $country_id = geoip_country_id_by_name($gi, $name);
349 349
   if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351 351
   }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
356
+  $country_id = geoip_country_id_by_name($gi, $name);
357 357
   if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359 359
   }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
369
+  $country_id = geoip_country_id_by_addr($gi, $addr);
370 370
   if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372 372
   }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
377
+  $country_id = geoip_country_id_by_addr($gi, $addr);
378 378
   if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380 380
   }
@@ -384,26 +384,26 @@  discard block
 block discarded – undo
384 384
 function _geoip_seek_country($gi, $ipnum) {
385 385
   $offset = 0;
386 386
   for ($depth = 31; $depth >= 0; --$depth) {
387
-    if ($gi->flags & GEOIP_MEMORY_CACHE) {
387
+    if ($gi->flags&GEOIP_MEMORY_CACHE) {
388 388
       $buf = substr($gi->memory_buffer,
389
-                            2 * $gi->record_length * $offset,
390
-                            2 * $gi->record_length);
391
-        } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
393
-                            2 * $gi->record_length * $offset,
394
-                            2 * $gi->record_length );
389
+                            2*$gi->record_length*$offset,
390
+                            2*$gi->record_length);
391
+        } elseif ($gi->flags&GEOIP_SHARED_MEMORY) {
392
+      $buf = @shmop_read($gi->shmid, 
393
+                            2*$gi->record_length*$offset,
394
+                            2*$gi->record_length);
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+      fseek($gi->filehandle, 2*$gi->record_length*$offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+      $buf = fread($gi->filehandle, 2*$gi->record_length);
399 399
     }
400
-    $x = array(0,0);
400
+    $x = array(0, 0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402 402
       for ($j = 0; $j < $gi->record_length; ++$j) {
403
-        $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
403
+        $x[$i] += ord($buf[$gi->record_length*$i + $j]) << ($j*8);
404 404
       }
405 405
     }
406
-    if ($ipnum & (1 << $depth)) {
406
+    if ($ipnum&(1 << $depth)) {
407 407
       if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409 409
       }
@@ -419,23 +419,23 @@  discard block
 block discarded – undo
419 419
   return false;
420 420
 }
421 421
 
422
-function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
422
+function _get_org($gi, $ipnum) {
423
+  $seek_org = _geoip_seek_country($gi, $ipnum);
424 424
   if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426 426
   }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
429
-    $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
427
+  $record_pointer = $seek_org + (2*$gi->record_length - 1)*$gi->databaseSegments;
428
+  if ($gi->flags&GEOIP_SHARED_MEMORY) {
429
+    $org_buf = @shmop_read($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432
-    $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
432
+    $org_buf = fread($gi->filehandle, MAX_ORG_RECORD_LENGTH);
433 433
   }
434 434
   $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435 435
   return $org_buf;
436 436
 }
437 437
 
438
-function geoip_org_by_addr ($gi,$addr) {
438
+function geoip_org_by_addr($gi, $addr) {
439 439
   if ($addr == NULL) {
440 440
     return 0;
441 441
   }
@@ -443,38 +443,38 @@  discard block
 block discarded – undo
443 443
   return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446
-function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449
-    if ($seek_region >= 1000){
446
+function _get_region($gi, $ipnum) {
447
+  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
448
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0;
449
+    if ($seek_region >= 1000) {
450 450
       $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
451
+      $region = chr(($seek_region - 1000)/26 + 65).chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454 454
       $region = "";
455 455
     }
456
-  return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
456
+  return array($country_code, $region);
457
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460
-    if ($seek_region < US_OFFSET){
460
+    if ($seek_region < US_OFFSET) {
461 461
       $country_code = "";
462 462
       $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464 464
       $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
465
+      $region = chr(($seek_region - US_OFFSET)/26 + 65).chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467 467
       $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
468
+      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65).chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470
-            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
470
+            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET)/FIPS_RANGE];
471 471
       $region = "";
472 472
     }
473
-  return array ($country_code,$region);
473
+  return array($country_code, $region);
474 474
   }
475 475
 }
476 476
 
477
-function geoip_region_by_addr ($gi,$addr) {
477
+function geoip_region_by_addr($gi, $addr) {
478 478
   if ($addr == NULL) {
479 479
     return 0;
480 480
   }
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
   return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485
-function getdnsattributes ($l,$ip){
485
+function getdnsattributes($l, $ip) {
486 486
   $r = new Net_DNS_Resolver();
487 487
   $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
488
+  $p = $r->search($l.".".$ip.".s.maxmind.com", "TXT", "IN");
489
+  $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
490
+  ereg("\"(.*)\"", $str, $regs);
491 491
   $str = $regs[1];
492 492
   return $str;
493 493
 }
Please login to merge, or discard this patch.
Braces   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
   shmop_close ($shmid);
230 230
 }
231 231
 
232
-function _setup_segments($gi){
232
+function _setup_segments($gi) {
233 233
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 234
   $gi->record_length = STANDARD_RECORD_LENGTH;
235 235
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
@@ -241,18 +241,18 @@  discard block
 block discarded – undo
241 241
             $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
242 242
             $offset++;
243 243
 
244
-            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
244
+            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246
-            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
246
+            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248 248
 	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251 251
 		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
252
+		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
253 253
                 $gi->databaseSegments = 0;
254 254
                 $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
-                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
255
+                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) {
256 256
                     $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
257 257
                 }
258 258
 	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     }
268 268
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
269 269
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
270
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
270
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273 273
   } else {
@@ -275,21 +275,20 @@  discard block
 block discarded – undo
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
277 277
         $delim = fread($gi->filehandle,3);
278
-        if ($delim == (chr(255).chr(255).chr(255))){
278
+        if ($delim == (chr(255).chr(255).chr(255))) {
279 279
         $gi->databaseType = ord(fread($gi->filehandle,1));
280
-        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
280
+        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282
-        }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
282
+        } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
284 283
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
284
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 285
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 286
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 287
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
289
-                 ($gi->databaseType == GEOIP_ASNUM_EDITION)){
288
+                 ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
290 289
             $gi->databaseSegments = 0;
291 290
             $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292
-            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
291
+            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) {
293 292
             $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
294 293
             }
295 294
 	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
@@ -303,7 +302,7 @@  discard block
 block discarded – undo
303 302
     }
304 303
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305 304
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
306
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
305
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
307 306
          $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 307
     }
309 308
     fseek($gi->filehandle,$filepos,SEEK_SET);
@@ -419,7 +418,7 @@  discard block
 block discarded – undo
419 418
   return false;
420 419
 }
421 420
 
422
-function _get_org($gi,$ipnum){
421
+function _get_org($gi,$ipnum) {
423 422
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 423
   if ($seek_org == $gi->databaseSegments) {
425 424
     return NULL;
@@ -443,10 +442,10 @@  discard block
 block discarded – undo
443 442
   return _get_org($gi, $ipnum);
444 443
 }
445 444
 
446
-function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
445
+function _get_region($gi,$ipnum) {
446
+  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
448 447
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449
-    if ($seek_region >= 1000){
448
+    if ($seek_region >= 1000) {
450 449
       $country_code = "US";
451 450
       $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
452 451
     } else {
@@ -454,10 +453,10 @@  discard block
 block discarded – undo
454 453
       $region = "";
455 454
     }
456 455
   return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
456
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 457
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 458
     //print $seek_region;
460
-    if ($seek_region < US_OFFSET){
459
+    if ($seek_region < US_OFFSET) {
461 460
       $country_code = "";
462 461
       $region = "";  
463 462
         } else if ($seek_region < CANADA_OFFSET) {
@@ -482,7 +481,7 @@  discard block
 block discarded – undo
482 481
   return _get_region($gi, $ipnum);
483 482
 }
484 483
 
485
-function getdnsattributes ($l,$ip){
484
+function getdnsattributes ($l,$ip) {
486 485
   $r = new Net_DNS_Resolver();
487 486
   $r->nameservers = array("ws1.maxmind.com");
488 487
   $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 function _get_org($gi,$ipnum){
423 423
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 424
   if ($seek_org == $gi->databaseSegments) {
425
-    return NULL;
425
+    return null;
426 426
   }
427 427
   $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428 428
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 }
437 437
 
438 438
 function geoip_org_by_addr ($gi,$addr) {
439
-  if ($addr == NULL) {
439
+  if ($addr == null) {
440 440
     return 0;
441 441
   }
442 442
   $ipnum = ip2long($addr);
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 }
476 476
 
477 477
 function geoip_region_by_addr ($gi,$addr) {
478
-  if ($addr == NULL) {
478
+  if ($addr == null) {
479 479
     return 0;
480 480
   }
481 481
   $ipnum = ip2long($addr);
Please login to merge, or discard this patch.
html/inc/host.inc 3 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -324,6 +324,11 @@  discard block
 block discarded – undo
324 324
 // so it's OK to show the domain name etc.
325 325
 // If private is false, show the owner's name only if they've given permission
326 326
 //
327
+/**
328
+ * @param integer $i
329
+ * @param boolean $show_owner
330
+ * @param boolean $any_product_name
331
+ */
327 332
 function show_host_row($host, $i, $private, $show_owner, $any_product_name) {
328 333
     $anonymous = false;
329 334
     if (!$private) {
@@ -503,6 +508,9 @@  discard block
 block discarded – undo
503 508
 // that their time intervals are disjoint.
504 509
 // So the CPU/OS checks don't have to be very strict.
505 510
 //
511
+/**
512
+ * @param boolean $show_detail
513
+ */
506 514
 function hosts_compatible($host1, $host2, $show_detail) {
507 515
     // A host is "new" if it has no credit and no results.
508 516
     // Skip disjoint-time check if one host or other is new
@@ -642,6 +650,9 @@  discard block
 block discarded – undo
642 650
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
643 651
 }
644 652
 
653
+/**
654
+ * @param string $sort
655
+ */
645 656
 function link_url_rev($actual_sort, $sort, $rev, $show_all) {
646 657
     if ($actual_sort == $sort) {
647 658
         $rev = 1 - $rev;
@@ -661,6 +672,9 @@  discard block
 block discarded – undo
661 672
     echo "<p>";
662 673
 }
663 674
 
675
+/**
676
+ * @param boolean $any_product_name
677
+ */
664 678
 function user_host_table_start(
665 679
     $private, $sort, $rev, $show_all, $any_product_name
666 680
 ) {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 
33 33
 function sched_log_name($x) {
34 34
     if ($x == 0) return "NO_SUCH_LOG";
35
-    return gmdate('Y-m-d_H/Y-m-d_H:i', $x) . ".txt";
35
+    return gmdate('Y-m-d_H/Y-m-d_H:i', $x).".txt";
36 36
 }
37 37
 
38 38
 function sched_log_link($x) {
39 39
     if (file_exists("sched_logs")) {
40
-        return "<a href=\"../sched_logs/" . sched_log_name($x) . "\">" . time_str($x) . "</a>";
40
+        return "<a href=\"../sched_logs/".sched_log_name($x)."\">".time_str($x)."</a>";
41 41
     } else {
42 42
         return time_str($x);
43 43
     }
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 function location_form($host) {
47 47
     $none = "selected";
48
-    $h=$w=$s=$m="";
48
+    $h = $w = $s = $m = "";
49 49
     if ($host->venue == "home") $h = "selected";
50 50
     if ($host->venue == "work") $w = "selected";
51 51
     if ($host->venue == "school") $s = "selected";
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             row2(tra("Product name"), $host->product_name);
99 99
         }
100 100
         $x = $host->timezone/3600;
101
-        if ($x >= 0) $x="+$x";
101
+        if ($x >= 0) $x = "+$x";
102 102
         row2(tra("Local Standard Time"), tra("UTC %1 hours", $x));
103 103
     } else {
104 104
         $owner = BoincUser::lookup_id($host->userid);
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if ($d[0] == "BOINC") continue;
257 257
         if ($d[0] == "vbox") continue;
258 258
         if ($str) $str .= "<p>";
259
-        if ($d[2]!="" && $d[2]!="1") $str .= "[".$d[2]."] ";
259
+        if ($d[2] != "" && $d[2] != "1") $str .= "[".$d[2]."] ";
260 260
         if ($d[0] == "CUDA") {
261 261
             $str .= "NVIDIA";
262 262
         } else if ($d[0] == "CAL") {
@@ -449,14 +449,14 @@  discard block
 block discarded – undo
449 449
     if ($pos1 === false) return $x;
450 450
     $pos2 = strpos($model, ']');
451 451
     if ($pos2 === false) return $x;
452
-    $a = substr($model, $pos1+1, $pos2-$pos1-1);
452
+    $a = substr($model, $pos1 + 1, $pos2 - $pos1 - 1);
453 453
     $y = explode(" ", $a);
454 454
     if (count($y) == 0) return $x;
455 455
     if ($y[0] == "Family") {
456 456
         $x->info = $a;
457 457
     } else {
458 458
         $x->arch = $y[0];
459
-        $x->info = substr($a, strlen($y[0])+1);
459
+        $x->info = substr($a, strlen($y[0]) + 1);
460 460
     }
461 461
     return $x;
462 462
 }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
     $avg_time = 0;
546 546
 
547 547
     $results = BoincResult::enum("hostid=$hostid order by received_time");
548
-    foreach($results as $result) {
548
+    foreach ($results as $result) {
549 549
         if ($result->granted_credit <= 0) continue;
550 550
         $total += $result->granted_credit;
551 551
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 
639 639
 function link_url($sort, $rev, $show_all) {
640 640
     global $userid;
641
-    $x = $userid ? "&userid=$userid":"";
641
+    $x = $userid ? "&userid=$userid" : "";
642 642
     return "hosts_user.php?sort=$sort&rev=$rev&show_all=$show_all$x";
643 643
 }
644 644
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 }
711 711
 
712 712
 function show_user_hosts($userid, $private, $show_all, $sort, $rev) {
713
-    $desc = false;  // whether the sort order's default is decreasing
713
+    $desc = false; // whether the sort order's default is decreasing
714 714
     switch ($sort) {
715 715
     case "total_credit": $sort_clause = "total_credit"; $desc = true; break;
716 716
     case "expavg_credit": $sort_clause = "expavg_credit"; $desc = true; break;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
     more_or_less($sort, $rev, $show_all);
734 734
 
735 735
     $now = time();
736
-    $old_hosts=0;
736
+    $old_hosts = 0;
737 737
     $i = 1;
738 738
     $hosts = BoincHost::enum("userid=$userid order by $sort_clause");
739 739
     $any_product_name = false;
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
     }
746 746
     user_host_table_start($private, $sort, $rev, $show_all, $any_product_name);
747 747
     foreach ($hosts as $host) {
748
-        $is_old=false;
748
+        $is_old = false;
749 749
         if (($now - $host->rpc_time) > 30*86400) {
750
-            $is_old=true;
750
+            $is_old = true;
751 751
             $old_hosts++;
752 752
         }
753 753
         if (!$show_all && $is_old) continue;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     }
757 757
     end_table();
758 758
 
759
-    if ($old_hosts>0) {
759
+    if ($old_hosts > 0) {
760 760
         more_or_less($sort, $rev, $show_all);
761 761
     }
762 762
 
@@ -776,6 +776,6 @@  discard block
 block discarded – undo
776 776
     }
777 777
 }
778 778
 
779
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
779
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
780 780
 
781 781
 ?>
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
             if ($host->last_ip_addr != $host->external_ip_addr) {
91 91
                 row2(tra("External IP address"), $host->external_ip_addr);
92 92
             }
93
-        } else { 
93
+        } else {
94 94
             row2(tra("IP address"), "<a href=show_host_detail.php?hostid=$host->id&ipprivate=1>".tra("Show IP address")."</a>");
95 95
         }
96 96
         row2(tra("Domain name"), $host->domain_name);
Please login to merge, or discard this patch.
html/inc/news.inc 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -65,6 +65,10 @@
 block discarded – undo
65 65
     return $forum->parent_type == 0 && ($forum->title === $forum_name);
66 66
 }
67 67
 
68
+/**
69
+ * @param integer $start
70
+ * @param integer $count
71
+ */
68 72
 function show_news($start, $count) {
69 73
     $forum = news_forum();
70 74
     if (!$forum) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,5 +118,5 @@
 block discarded – undo
118 118
     ";
119 119
 }
120 120
 
121
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
121
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
122 122
 ?>
Please login to merge, or discard this patch.
html/inc/pm.inc 2 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -27,6 +27,10 @@  discard block
 block discarded – undo
27 27
     echo "</div>\n";
28 28
 }
29 29
 
30
+/**
31
+ * @param null|integer $teamid
32
+ * @param string $error
33
+ */
30 34
 function pm_team_form($user, $teamid, $error=null) {
31 35
     global $bbcode_html, $bbcode_js;
32 36
     $team = BoincTeam::lookup_id($teamid);
@@ -78,6 +82,9 @@  discard block
 block discarded – undo
78 82
     page_tail();
79 83
 }
80 84
 
85
+/**
86
+ * @param string $error
87
+ */
81 88
 function pm_form($replyto, $userid, $error = null) {
82 89
     global $bbcode_html, $bbcode_js;
83 90
     global $g_logged_in_user;
@@ -196,6 +203,9 @@  discard block
 block discarded – undo
196 203
     return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
197 204
 }
198 205
 
206
+/**
207
+ * @param boolean $send_email
208
+ */
199 209
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
200 210
     $sql_subject = BoincDb::escape_string(sanitize_tags($subject));
201 211
     $sql_content = BoincDb::escape_string($content);
@@ -224,6 +234,9 @@  discard block
 block discarded – undo
224 234
     BoincNotify::insert("(userid, create_time, type, opaque) values ($to_user->id, ".time().", ".NOTIFY_PM.", $mid)");
225 235
 }
226 236
 
237
+/**
238
+ * @param integer $duration
239
+ */
227 240
 function pm_count($userid, $duration) {
228 241
     $time = time() - $duration;
229 242
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     echo "</div>\n";
28 28
 }
29 29
 
30
-function pm_team_form($user, $teamid, $error=null) {
30
+function pm_team_form($user, $teamid, $error = null) {
31 31
     global $bbcode_html, $bbcode_js;
32 32
     $team = BoincTeam::lookup_id($teamid);
33 33
     if (!$team) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         error_page("not admin");
38 38
     }
39 39
 
40
-    page_head(tra("Send message to team"),'','','', $bbcode_js);
40
+    page_head(tra("Send message to team"), '', '', '', $bbcode_js);
41 41
 
42 42
     $subject = post_str("subject", true);
43 43
     $content = post_str("content", true);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 function pm_form($replyto, $userid, $error = null) {
82 82
     global $bbcode_html, $bbcode_js;
83 83
     global $g_logged_in_user;
84
-    page_head(tra("Send private message"),'','','', $bbcode_js);
84
+    page_head(tra("Send private message"), '', '', '', $bbcode_js);
85 85
     
86 86
     if (post_str("preview", true) == tra("Preview")) {
87 87
         $content = post_str("content", true);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 function send_pm_notification_email(
164 164
     $logged_in_user, $to_user, $subject, $content
165 165
 ) {
166
-    $message  = "
166
+    $message = "
167 167
 You have received a new private message at ".PROJECT.".
168 168
 
169 169
 From: $logged_in_user->name (ID $logged_in_user->id)
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     $pm = BoincPrivateMessage::lookup_id($notify->opaque);
194 194
     $from_user = BoincUser::lookup_id($pm->senderid);
195 195
     if (!$pm || !$from_user) return null;
196
-    return "<a href=pm.php>".tra("Private message%1 from %2, subject:" , "</a>", $from_user->name )." $pm->subject";
196
+    return "<a href=pm.php>".tra("Private message%1 from %2, subject:", "</a>", $from_user->name)." $pm->subject";
197 197
 }
198 198
 
199 199
 function pm_send_msg($from_user, $to_user, $subject, $content, $send_email) {
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
 
258 258
 function pm_email_remind($user) {
259 259
     if (!$user->prefs->pm_notification) {
260
-        return "<br><small>" .
260
+        return "<br><small>".
261 261
             tra(
262 262
                 "For email notification, %1edit community prefs%2",
263 263
                 '<a href="edit_forum_preferences_form.php">', '</a>'
264
-            ) .
264
+            ).
265 265
             "</small>"
266 266
         ;
267 267
     }
@@ -287,5 +287,5 @@  discard block
 block discarded – undo
287 287
     }
288 288
 }
289 289
 
290
-$cvs_version_tracker[]="\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
290
+$cvs_version_tracker[] = "\$Id: pm.inc 14019 2007-11-01 23:04:39Z davea $";
291 291
 ?>
Please login to merge, or discard this patch.
html/inc/prefs.inc 3 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -291,6 +291,9 @@  discard block
 block discarded – undo
291 291
     return $dp;
292 292
 }
293 293
 
294
+/**
295
+ * @param string $t
296
+ */
294 297
 function group_header($t) {
295 298
     echo "<tr><th class=\"bg-info\">$t</th><td class=\"bg-info\" colspan=4><br></td></tr>\n";
296 299
 }
@@ -413,6 +416,9 @@  discard block
 block discarded – undo
413 416
 
414 417
 // Display all venues as columns next to descriptions
415 418
 //
419
+/**
420
+ * @param stdClass $prefs
421
+ */
416 422
 function prefs_show_columns_global($prefs) {
417 423
     global $cpu_prefs;
418 424
     global $disk_prefs;
@@ -483,6 +489,11 @@  discard block
 block discarded – undo
483 489
     return PROJECT;
484 490
 }
485 491
 
492
+/**
493
+ * @param stdClass $prefs
494
+ * @param string $venue
495
+ * @param string $subset
496
+ */
486 497
 function prefs_display_venue($prefs, $venue, $subset) {
487 498
     global $g_logged_in_user;
488 499
     $tokens = url_tokens($g_logged_in_user->authenticator);
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
     $dp->disk_max_used_pct = parse_config($config, "<default_disk_max_used_pct>");
277 277
     $dp->disk_min_free_gb = parse_config($config, "<default_disk_min_free_gb>");
278 278
     // set some defaults if not found
279
-    if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0;  // no limit
279
+    if (!$dp->disk_max_used_gb) $dp->disk_max_used_gb = 0; // no limit
280 280
     if (!$dp->disk_max_used_pct) $dp->disk_max_used_pct = 90; // 90 percent
281
-    if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1;   // 1 GB
281
+    if (!$dp->disk_min_free_gb) $dp->disk_min_free_gb = 1; // 1 GB
282 282
     // set mininimum free space scheduler allows 
283 283
     // - depends on which scheduler is running
284 284
     $dp->new_sched_flag = 1;
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     global $text;
305 305
     global $venue_name;
306 306
 
307
-    switch($name) {
307
+    switch ($name) {
308 308
     case "venue":
309 309
         if (array_key_exists("name", $attrs)) {
310 310
             $venue_name = $attrs["name"];
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             return;
351 351
         }
352 352
     }
353
-    switch($name) {
353
+    switch ($name) {
354 354
     case "venue":
355 355
         $top_parse_result->$venue_name = $parse_result;
356 356
         $parse_result = $top_parse_result;
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     }
510 510
 }
511 511
 
512
-function print_prefs_display_global($user, $columns=false) {
512
+function print_prefs_display_global($user, $columns = false) {
513 513
     $global_prefs = prefs_parse_global($user->global_prefs);
514 514
 
515 515
     echo tra("These settings apply to all computers using this account except")
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         .tra("Android devices")
520 520
         ."</ul>
521 521
     ";
522
-    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=". (int)!$columns .">".tra("(Switch view)")."</a></font>";
522
+    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=global&cols=".(int)!$columns.">".tra("(Switch view)")."</a></font>";
523 523
     if ($columns) {
524 524
         echo "<h3>".tra("Combined preferences").$switch_link."</h3>";
525 525
         start_table();
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
 // otherwise false
555 555
 //
556 556
 function print_prefs_form(
557
-    $action, $subset, $venue, $user, $prefs, $cols, $error=false,
558
-    $project_error=false
559
-){
557
+    $action, $subset, $venue, $user, $prefs, $cols, $error = false,
558
+    $project_error = false
559
+) {
560 560
     if ($action == "add") {
561 561
         $script = "add_venue.php";
562 562
         $submit_value = tra("Add preferences");
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 //
596 596
 // Functions to display preference subsets as forms
597 597
 //
598
-function prefs_form_global($user, $prefs, $error=false) {
598
+function prefs_form_global($user, $prefs, $error = false) {
599 599
     global $cpu_prefs;
600 600
     global $disk_prefs;
601 601
     global $mem_prefs;
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 //
636 636
 function prefs_form_radio_buttons($name, $yesno) {
637 637
     $rb = tra("yes")." <input type=radio name=$name value=yes "
638
-        .($yesno?"checked":"")
638
+        .($yesno ? "checked" : "")
639 639
         ."> ".tra("no")." <input type=radio name=$name value=no "
640
-        .($yesno?"":"checked")
640
+        .($yesno ? "" : "checked")
641 641
         .">\n";
642 642
     return $rb;
643 643
 }
@@ -656,12 +656,12 @@  discard block
 block discarded – undo
656 656
 }
657 657
 function venue_show($user) {
658 658
     $venue = $user->venue;
659
-    if ($venue =='') $venue = '---';
659
+    if ($venue == '') $venue = '---';
660 660
     tooltip_row2(VENUE_TOOLTIP, VENUE_DESC, $venue);
661 661
 }
662 662
 
663 663
 function venue_form($user) {
664
-    $n=$h=$w=$s=$m='';
664
+    $n = $h = $w = $s = $m = '';
665 665
     if ($user->venue == '') $n = 'selected';
666 666
     if ($user->venue == 'home') $h = 'selected';
667 667
     if ($user->venue == 'work') $w = 'selected';
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 //
718 718
 // convert prefs from structure to XML
719 719
 //
720
-function global_prefs_make_xml($prefs, $primary=true) {
720
+function global_prefs_make_xml($prefs, $primary = true) {
721 721
     global $cpu_prefs;
722 722
     global $disk_prefs;
723 723
     global $mem_prefs;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -556,7 +556,7 @@
 block discarded – undo
556 556
 function print_prefs_form(
557 557
     $action, $subset, $venue, $user, $prefs, $cols, $error=false,
558 558
     $project_error=false
559
-){
559
+) {
560 560
     if ($action == "add") {
561 561
         $script = "add_venue.php";
562 562
         $submit_value = tra("Add preferences");
Please login to merge, or discard this patch.
html/inc/prefs_project.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -241,6 +241,9 @@
 block discarded – undo
241 241
     }
242 242
 }
243 243
 
244
+/**
245
+ * @param boolean $columns
246
+ */
244 247
 function prefs_show_privacy($user, $columns) {
245 248
     global $privacy_pref_descs;
246 249
     if ($columns) {
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 }
69 69
 
70 70
 if ($app_types->cpu) {
71
-    $project_pref_descs[] = new PREF_BOOL (
71
+    $project_pref_descs[] = new PREF_BOOL(
72 72
         tra("Use CPU"),
73 73
         "Request CPU-only tasks from this project.",
74 74
         "no_cpu",
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     );
78 78
 }
79 79
 if ($app_types->ati) {
80
-    $project_pref_descs[] = new PREF_BOOL (
80
+    $project_pref_descs[] = new PREF_BOOL(
81 81
         tra("Use ATI GPU"),
82 82
         "Request ATI GPU tasks from this project.",
83 83
         "no_ati",
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     );
87 87
 }
88 88
 if ($app_types->cuda) {
89
-    $project_pref_descs[] = new PREF_BOOL (
89
+    $project_pref_descs[] = new PREF_BOOL(
90 90
         tra("Use NVIDIA GPU"),
91 91
         "Request NVIDIA GPU tasks from this project.",
92 92
         "no_cuda",
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     );
96 96
 }
97 97
 if ($app_types->intel_gpu) {
98
-    $project_pref_descs[] = new PREF_BOOL (
98
+    $project_pref_descs[] = new PREF_BOOL(
99 99
         tra("Use Intel GPU"),
100 100
         "Request Intel GPU tasks from this project.",
101 101
         "no_intel_gpu",
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     $x = "";
121 121
 }
122 122
 
123
-$privacy_pref_descs = array (
123
+$privacy_pref_descs = array(
124 124
     new PREF_BOOL(
125 125
         tra("Is it OK for %1 and your team (if any) to email you?", PROJECT).$x,
126 126
         "",
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     global $in_project_specific;
153 153
     global $venue_name;
154 154
 
155
-    switch($name) {
155
+    switch ($name) {
156 156
     case "venue":
157 157
         $venue_name = $attrs["name"];
158 158
         $top_parse_result = $parse_result;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         break;
165 165
     default:
166 166
         if ($in_project_specific) {
167
-            $text= $text."<$name>";
167
+            $text = $text."<$name>";
168 168
         } else {
169 169
             $text = "";
170 170
         }
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
     global $venue_name;
180 180
     global $project_pref_descs;
181 181
 
182
-    foreach($project_pref_descs as $p) {
182
+    foreach ($project_pref_descs as $p) {
183 183
         if ($p->xml_parse($parse_result, $name, $text)) {
184 184
             return;
185 185
         }
186 186
     }
187
-    switch($name) {
187
+    switch ($name) {
188 188
     case "venue":
189 189
         $top_parse_result->$venue_name = $parse_result;
190 190
         $parse_result = $top_parse_result;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     return $parse_result;
229 229
 }
230 230
 
231
-function prefs_show_project($prefs, $columns=false) {
231
+function prefs_show_project($prefs, $columns = false) {
232 232
     global $project_pref_descs;
233 233
     if ($columns) {
234 234
         foreach ($project_pref_descs as $p) {
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
     }
255 255
 }
256 256
 
257
-function prefs_show_project_specific($prefs, $columns=false) {
257
+function prefs_show_project_specific($prefs, $columns = false) {
258 258
     if ($columns) {
259 259
         $project_specific_prefs = project_specific_prefs_parse($prefs->project_specific);
260 260
         $project_specific_prefs->home = isset($prefs->home) ? project_specific_prefs_parse($prefs->home->project_specific) : "";
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
     project_specific_prefs_show($project_specific_prefs, $columns);
267 267
 }
268 268
 
269
-function print_prefs_display_project($user, $columns=false) {
269
+function print_prefs_display_project($user, $columns = false) {
270 270
     $project_prefs = prefs_parse_project($user->project_prefs);
271 271
 
272
-    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=". (int)!$columns .">".tra("(Switch View)")."</a></font>";
272
+    $switch_link = " <font size=\"-1\"><a href=prefs.php?subset=project&cols=".(int)!$columns.">".tra("(Switch View)")."</a></font>";
273 273
     if ($columns) {
274 274
         start_table();
275 275
         row_heading(tra("Combined preferences").$switch_link);
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
     }
312 312
 }
313 313
 
314
-function prefs_form_project($prefs, $error=false) {
314
+function prefs_form_project($prefs, $error = false) {
315 315
     global $project_pref_descs;
316 316
     foreach ($project_pref_descs as $p) {
317 317
         $p->show_form_row($prefs, $error);
318 318
     }
319 319
 }
320 320
 
321
-function prefs_form_project_specific($prefs_xml, $error=false) {
321
+function prefs_form_project_specific($prefs_xml, $error = false) {
322 322
     $prefs = project_specific_prefs_parse($prefs_xml);
323 323
     project_specific_prefs_edit($prefs, $error);
324 324
 }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 
358 358
 // given a prefs structure, return the corresponding XML string
359 359
 //
360
-function project_prefs_make_xml($prefs, $primary=true) {
360
+function project_prefs_make_xml($prefs, $primary = true) {
361 361
     global $project_pref_descs;
362 362
     $xml = "";
363 363
     if ($primary) {
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 //
393 393
 function project_prefs_update(&$user, $prefs) {
394 394
     $prefs_xml = BoincDb::escape_string(project_prefs_make_xml($prefs));
395
-    $send_email = $user->send_email?1:0;
396
-    $show_hosts = $user->show_hosts?1:0;
395
+    $send_email = $user->send_email ? 1 : 0;
396
+    $show_hosts = $user->show_hosts ? 1 : 0;
397 397
     $retval = $user->update("project_prefs='$prefs_xml', send_email=$send_email, show_hosts=$show_hosts");
398 398
     if (!$retval) {
399 399
         return 1;
Please login to merge, or discard this patch.
html/inc/prefs_util.inc 2 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -440,6 +440,10 @@  discard block
 block discarded – undo
440 440
     }
441 441
 }
442 442
 
443
+/**
444
+ * @param string $id
445
+ * @param string $d
446
+ */
443 447
 function hour_select($x, $name, $id, $d) {
444 448
     $s = "";
445 449
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
@@ -533,6 +537,9 @@  discard block
 block discarded – undo
533 537
 
534 538
 // display preference subsets as columns
535 539
 //
540
+/**
541
+ * @param string $x
542
+ */
536 543
 function row_top($x) {
537 544
     echo "<tr class=\"bg-primary\"><th width=35%>$x</th>";
538 545
     echo "<th ><b>".tra("Default")."</b></th>
@@ -545,6 +552,13 @@  discard block
 block discarded – undo
545 552
 
546 553
 // row_defs - Display a value for all 4 venues in one row
547 554
 //
555
+/**
556
+ * @param string $pre
557
+ * @param string $item
558
+ * @param string $post
559
+ * @param string $type
560
+ * @param string $tooltip
561
+ */
548 562
 function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
549 563
     $gen = $prefs->$item;
550 564
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
@@ -599,6 +613,9 @@  discard block
 block discarded – undo
599 613
 //
600 614
 // row_links - Display Edit/Add/Remove links for all venues in 1 row
601 615
 //
616
+/**
617
+ * @param string $subset
618
+ */
602 619
 function row_links($subset, $prefs) {
603 620
     global $g_logged_in_user;
604 621
     $tokens = url_tokens($g_logged_in_user->authenticator);
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 }
41 41
 
42 42
 abstract class PREF {
43
-    public $desc;       // short description
44
-    public $tooltip;    // longer description, shown as tooltip
45
-    public $tag;        // the pref's primary XML tag
43
+    public $desc; // short description
44
+    public $tooltip; // longer description, shown as tooltip
45
+    public $tag; // the pref's primary XML tag
46 46
     function __construct($desc, $tooltip, $tag) {
47 47
         $this->desc = $desc;
48 48
         $this->tooltip = $tooltip;
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 
121 121
 class PREF_BOOL extends PREF {
122 122
     public $default;
123
-    public $invert;     // show to user in opposite sense
124
-    function __construct($desc, $tooltip, $tag, $default, $invert=false) {
123
+    public $invert; // show to user in opposite sense
124
+    function __construct($desc, $tooltip, $tag, $default, $invert = false) {
125 125
         $this->default = $default;
126 126
         $this->invert = $invert;
127 127
         parent::__construct($desc, $tooltip, $tag);
128 128
     }
129 129
     function show_value($prefs) {
130 130
         $tag = $this->tag;
131
-        $v = $this->invert?!$prefs->$tag:$prefs->$tag;
131
+        $v = $this->invert ? !$prefs->$tag : $prefs->$tag;
132 132
         echo "<td>".readonly_checkbox($v)."</td>";
133 133
     }
134 134
     function show_form($prefs, $error) {
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         }
141 141
         echo "<td ".VALUE_ATTRS.">"
142 142
             ."<input type=checkbox name=$this->tag "
143
-            . ($checked?"checked":"")
143
+            . ($checked ? "checked" : "")
144 144
             ."></td>
145 145
         ";
146 146
     }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     function xml_string($prefs) {
154 154
         $tag = $this->tag;
155 155
         return "<$tag>"
156
-            .($prefs->$tag?"1":"0")
156
+            .($prefs->$tag ? "1" : "0")
157 157
             ."</$tag>\n";
158 158
     }
159 159
     function xml_parse(&$prefs, $name, $text) {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         // this is the value if they check the box
180 180
     public $scale;
181 181
 
182
-    function __construct($suffix, $min, $max, $default, $scale=1, $default2=0) {
182
+    function __construct($suffix, $min, $max, $default, $scale = 1, $default2 = 0) {
183 183
         $this->suffix = " $suffix";
184 184
         $this->min = $min;
185 185
         $this->max = $max;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $v .= "$this->suffix ";
199 199
         return $v;
200 200
     }
201
-    function form_str($tag, $v, $had_error, $disabled=false, $id=null) {
201
+    function form_str($tag, $v, $had_error, $disabled = false, $id = null) {
202 202
         if (is_numeric($v)) {
203 203
             $v /= $this->scale;
204 204
             if (!$had_error && ($v < $this->min || $v > $this->max)) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             }
207 207
         }
208 208
         if ($disabled) $v = "";
209
-        $i = $id?"id=\"$id\"":"";
209
+        $i = $id ? "id=\"$id\"" : "";
210 210
         return '<input type="text" size="5" class="form-control input-sm" name="'.$tag.'" value="'.$v."\" $disabled $i> &nbsp; $this->suffix ";
211 211
     }
212 212
     function form_convert($in, &$out, &$error) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     function show_form($prefs, $error) {
244 244
         $tag = $this->tag;
245 245
         $had_error = isset($error->$tag);
246
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
246
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
247 247
         echo "<td $attrs>"
248 248
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error)
249 249
             ."</td>
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
     function show_form($prefs, $error) {
325 325
         $tag = $this->tag;
326 326
         $had_error = isset($error->$tag);
327
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
327
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
328 328
         $checkbox_id = $this->tag."_cb";
329 329
         $text_id = $this->tag;
330 330
         $default = $this->num_spec->get_default();
331 331
         $val = $prefs->$tag;
332
-        $c = $val?"checked":"";
333
-        $d = $val?"":"disabled";
332
+        $c = $val ? "checked" : "";
333
+        $d = $val ? "" : "disabled";
334 334
         echo "<td $attrs>"
335 335
             ."<input type=checkbox id=$checkbox_id onClick=\"checkbox_clicked('$checkbox_id', '$text_id', $default)\" $c> &nbsp;"
336 336
             .$this->num_spec->form_str($tag, $prefs->$tag, $had_error, $d, $text_id)
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         $tag = $this->tag;
388 388
         $tag2 = $this->tag2;
389 389
         $had_error = isset($error->$tag) || isset($error->$tag2);
390
-        $attrs = $had_error ?VALUE_ATTRS_ERR:VALUE_ATTRS;
390
+        $attrs = $had_error ? VALUE_ATTRS_ERR : VALUE_ATTRS;
391 391
         $checkbox_id = $this->tag."_cb";
392 392
         $t1_id = $this->tag."_t1";
393 393
         $t2_id = $this->tag."_t2";
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 function hour_select($x, $name, $id, $d) {
444 444
     $s = "";
445 445
     $s .= "<select class=\"selectbox form-control input-sm\" name=$name id=$id $d>\n";
446
-    for ($i=0; $i<24; $i++) {
447
-        $sel = ($x == $i)?"selected":"";
446
+    for ($i = 0; $i < 24; $i++) {
447
+        $sel = ($x == $i) ? "selected" : "";
448 448
         $s .= "<option value=$i $sel> $i:00";
449 449
     }
450 450
     $s .= "</select>\n";
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
 // row_defs - Display a value for all 4 venues in one row
547 547
 //
548
-function row_defs($pre, $item, $post, $type, $prefs, $tooltip=null) {
548
+function row_defs($pre, $item, $post, $type, $prefs, $tooltip = null) {
549 549
     $gen = $prefs->$item;
550 550
     $hom  = (isset($prefs->home) && isset($prefs->home->$item)) ? $prefs->home->$item : "--";
551 551
     $schl = (isset($prefs->school) && isset($prefs->school->$item)) ? $prefs->school->$item : "--";
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
         echo "<tr>";
558 558
     }
559 559
     echo "<td ".NAME_ATTRS.">$pre</td>";
560
-    row_field($gen,  $type);
561
-    row_field($hom,  $type);
560
+    row_field($gen, $type);
561
+    row_field($hom, $type);
562 562
     row_field($schl, $type);
563
-    row_field($wrk,  $type);
563
+    row_field($wrk, $type);
564 564
     echo "<td align=left>$post</td></tr>\n";
565 565
 }
566 566
 
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 function row_field($value, $type) {
571 571
     echo "<td>";
572 572
     $type = $value === "--" ? "--" : $type;
573
-    switch($type) {
573
+    switch ($type) {
574 574
     case "yesno":
575
-        echo $value ?tra("yes"):tra("no");
575
+        echo $value ? tra("yes") : tra("no");
576 576
         break;
577 577
     case "noyes":
578
-        echo $value ?tra("no"):tra("yes");
578
+        echo $value ? tra("no") : tra("yes");
579 579
         break;
580 580
     case "limit":
581 581
         $x = max_bytes_display_mode($value);
582
-        $y = "$x " . BYTE_ABBR;
582
+        $y = "$x ".BYTE_ABBR;
583 583
         echo $x ? "$y" : tra("no limit");
584 584
         break;
585 585
     case "minutes":
Please login to merge, or discard this patch.
html/inc/profile.inc 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -114,6 +114,11 @@
 block discarded – undo
114 114
     return BoincProfile::delete_aux("userid=$user->id");
115 115
 }
116 116
 
117
+/**
118
+ * @param resource $image
119
+ * @param integer $targetWidth
120
+ * @param integer $targetHeight
121
+ */
117 122
 function scale_image(
118 123
     $image, $origWidth, $origHeight, $targetWidth, $targetHeight
119 124
 ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@
 block discarded – undo
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192 192
     if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
193 193
         error_page(
194
-           tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
194
+            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
196 196
     }
197 197
     if (is_banished($user)) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     if (!$user->has_profile) return null;
72 72
     $profile = BoincProfile::lookup("userid=$user->id");
73 73
     if (!$profile->has_picture) return null;
74
-    if (profile_screening() && $profile->verification!=1) return null;
74
+    if (profile_screening() && $profile->verification != 1) return null;
75 75
     return profile_thumb_url($user->id);
76 76
 }
77 77
 
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
         return $image;
126 126
     }
127 127
 
128
-    ($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($origHeight / $targetHeight);
128
+    ($origWidth > $origHeight) ? $scalar = ($origWidth/$targetWidth) : $scalar = ($origHeight/$targetHeight);
129 129
 
130 130
     if ($scalar != 0) {
131
-        $destWidth = $origWidth / $scalar;
132
-        $destHeight = $origHeight / $scalar;
131
+        $destWidth = $origWidth/$scalar;
132
+        $destHeight = $origHeight/$scalar;
133 133
     } else {
134 134
         $destWidth = $origWidth;
135 135
         $destHeight = $origHeight;
136 136
     }
137 137
 
138 138
     $gd_info = gd_info();
139
-    $newGD = (strstr($gd_info["GD Version"], "2.0")!="");
139
+    $newGD = (strstr($gd_info["GD Version"], "2.0") != "");
140 140
     if ($newGD) {
141 141
         // If you are using a modern PHP/GD installation that does
142 142
         // 'truecolor' images, this is what's needed.
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $options->htmlitems = false;
180 180
         $temp = output_transform($profile->response1, $options);
181 181
         $temp = sanitize_tags($temp);
182
-        $description = "(\"" . sub_sentence($temp, ' ', MAX_DESC_LENGTH, true) . "\")";
182
+        $description = "(\"".sub_sentence($temp, ' ', MAX_DESC_LENGTH, true)."\")";
183 183
 
184 184
     }
185 185
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 function check_whether_to_show_profile($user, $logged_in_user) {
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192
-    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
192
+    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit) {
193 193
         error_page(
194 194
            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     //
228 228
     $show_picture = $profile->has_picture;
229 229
     if (profile_screening()) {
230
-        if (!$screen_mode && !$can_edit && $profile->verification!=1) {
230
+        if (!$screen_mode && !$can_edit && $profile->verification != 1) {
231 231
             $show_picture = false;
232 232
         }
233 233
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     // yet verified.  This will tell them if other users can't view it yet, or
244 244
     // if there is a problem with it and they need to replace it.
245 245
     //
246
-    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification!=1) {
246
+    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification != 1) {
247 247
         row1(offensive_profile_warning($profile->verification));
248 248
     }
249 249
 
@@ -276,6 +276,6 @@  discard block
 block discarded – undo
276 276
     }
277 277
 }
278 278
 
279
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
279
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
280 280
 
281 281
 ?>
Please login to merge, or discard this patch.
html/inc/result.inc 3 patches
Doc Comments   +15 added lines patch added patch discarded remove patch
@@ -53,6 +53,9 @@  discard block
 block discarded – undo
53 53
     return $platforms[$id];
54 54
 }
55 55
 
56
+/**
57
+ * @param string $rsc_name
58
+ */
56 59
 function anon_platform_string($result, $rsc_name=null) {
57 60
     $app = get_app($result->appid);
58 61
     $n = $app->user_friendly_name."<br>".  tra("Anonymous platform");
@@ -92,6 +95,9 @@  discard block
 block discarded – undo
92 95
     return "$n v$v $c<br>$platform->name";
93 96
 }
94 97
 
98
+/**
99
+ * @param string $string_to_show
100
+ */
95 101
 function result_granted_credit_string($result, $string_to_show) {
96 102
     if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS && $result->granted_credit > 0) {
97 103
         return $string_to_show;
@@ -356,6 +362,10 @@  discard block
 block discarded – undo
356 362
     return "results.php?$c&amp;offset=$o&amp;show_names=$sn&amp;state=$st&amp;appid=$appid";
357 363
 }
358 364
 
365
+/**
366
+ * @param boolean $show_wu_link
367
+ * @param boolean $show_host_link
368
+ */
359 369
 function result_table_start($show_wu_link, $show_host_link, $info) {
360 370
     start_table('table-striped');
361 371
     $x = array();
@@ -417,6 +427,11 @@  discard block
 block discarded – undo
417 427
     return false;
418 428
 }
419 429
 
430
+/**
431
+ * @param boolean $show_wu_link
432
+ * @param boolean $show_host_link
433
+ * @param boolean $show_name
434
+ */
420 435
 function show_result_row($result, $show_wu_link, $show_host_link, $show_name) {
421 436
     $s = time_str($result->sent_time);
422 437
     // if result has been reported, show the received time,
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
     return $platforms[$id];
54 54
 }
55 55
 
56
-function anon_platform_string($result, $rsc_name=null) {
56
+function anon_platform_string($result, $rsc_name = null) {
57 57
     $app = get_app($result->appid);
58
-    $n = $app->user_friendly_name."<br>".  tra("Anonymous platform");
58
+    $n = $app->user_friendly_name."<br>".tra("Anonymous platform");
59 59
     if ($rsc_name) {
60 60
         $n .= " ($rsc_name)";
61 61
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         return $string_to_show;
98 98
     }
99 99
     if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---";
100
-    switch($result->outcome) {
100
+    switch ($result->outcome) {
101 101
     case RESULT_OUTCOME_SUCCESS:
102 102
         switch ($result->validate_state) {
103 103
         case VALIDATE_STATE_INIT:
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             ) {
213 213
                 return tra("Not started by deadline - canceled");
214 214
             }
215
-            switch($result->client_state) {
215
+            switch ($result->client_state) {
216 216
             case RESULT_FILES_DOWNLOADING: return tra("Error while downloading");
217 217
             case RESULT_FILES_DOWNLOADED:
218 218
             case RESULT_COMPUTE_ERROR: return tra("Error while computing");
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 }
232 232
 
233 233
 function result_server_state_string($result) {
234
-    switch($result->server_state) {
234
+    switch ($result->server_state) {
235 235
     case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive");
236 236
     case RESULT_SERVER_STATE_UNSENT: return tra("Unsent");
237 237
     case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress");
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 }
242 242
 
243 243
 function result_outcome_string($result) {
244
-    switch($result->outcome) {
244
+    switch ($result->outcome) {
245 245
     case RESULT_OUTCOME_INIT: return "---";
246 246
     case RESULT_OUTCOME_SUCCESS: return tra("Success");
247 247
     case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send");
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 }
260 260
 
261 261
 function result_client_state_string($result) {
262
-    switch($result->client_state) {
262
+    switch ($result->client_state) {
263 263
     case RESULT_NEW: return tra("New");
264 264
     case RESULT_FILES_DOWNLOADING: return tra("Downloading");
265 265
     case RESULT_FILES_DOWNLOADED: return tra("Processing");
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 }
278 278
 
279 279
 function validate_state_str($result) {
280
-    switch($result->validate_state) {
280
+    switch ($result->validate_state) {
281 281
     case VALIDATE_STATE_INIT: return tra("Initial");
282 282
     case VALIDATE_STATE_VALID: return tra("Valid");
283 283
     case VALIDATE_STATE_INVALID:
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 }
294 294
 
295 295
 function assimilate_state_str($s) {
296
-    switch($s) {
296
+    switch ($s) {
297 297
     case ASSIMILATE_INIT: return "Initial";
298 298
     case ASSIMILATE_READY: return "Ready to assimilate";
299 299
     case ASSIMILATE_DONE: return "Assimilated";
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 }
303 303
 
304 304
 function file_delete_state_str($s) {
305
-    switch($s) {
305
+    switch ($s) {
306 306
     case FILE_DELETE_INIT: return "Initial";
307 307
     case FILE_DELETE_READY: return "Ready to delete";
308 308
     case FILE_DELETE_DONE: return "Deleted";
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
 }
313 313
 function wu_error_mask_str($s) {
314 314
     $x = "";
315
-    if ($s & WU_ERROR_COULDNT_SEND_RESULT) {
315
+    if ($s&WU_ERROR_COULDNT_SEND_RESULT) {
316 316
         $x = $x." ".tra("Couldn't send result");
317 317
         $s -= WU_ERROR_COULDNT_SEND_RESULT;
318 318
     }
319
-    if ($s & WU_ERROR_TOO_MANY_ERROR_RESULTS) {
319
+    if ($s&WU_ERROR_TOO_MANY_ERROR_RESULTS) {
320 320
         $x = $x." ".tra("Too many errors (may have bug)");
321 321
         $s -= WU_ERROR_TOO_MANY_ERROR_RESULTS;
322 322
     }
323
-    if ($s & WU_ERROR_TOO_MANY_SUCCESS_RESULTS) {
323
+    if ($s&WU_ERROR_TOO_MANY_SUCCESS_RESULTS) {
324 324
         $x = $x." ".tra("Too many results (may be nondeterministic)");
325 325
         $s -= WU_ERROR_TOO_MANY_SUCCESS_RESULTS;
326 326
     }
327
-    if ($s & WU_ERROR_TOO_MANY_TOTAL_RESULTS) {
327
+    if ($s&WU_ERROR_TOO_MANY_TOTAL_RESULTS) {
328 328
         $x = $x." ".tra("Too many total results");
329 329
         $s -= WU_ERROR_TOO_MANY_TOTAL_RESULTS;
330 330
     }
331
-    if ($s & WU_ERROR_CANCELLED) {
331
+    if ($s&WU_ERROR_CANCELLED) {
332 332
         $x = $x." ".tra("WU cancelled");
333 333
         $s -= WU_ERROR_CANCELLED;
334 334
     }
335
-    if ($s & WU_ERROR_NO_CANONICAL_RESULT) {
335
+    if ($s&WU_ERROR_NO_CANONICAL_RESULT) {
336 336
         $x = $x." ".tra("Canonical result is missing");
337 337
         $s -= WU_ERROR_NO_CANONICAL_RESULT;
338 338
     }
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
         $x = $x." ".tra("Unrecognized Error: %1", $s);
341 341
     }
342 342
     if (strlen($x)) {
343
-        $x="<font color=\"#ff3333\">".$x."</font>";
343
+        $x = "<font color=\"#ff3333\">".$x."</font>";
344 344
     } else {
345
-        $x="";
345
+        $x = "";
346 346
     }
347 347
     return $x;
348 348
 }
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
     if ($result->received_time) {
427 427
         $r = time_str($result->received_time);
428 428
     } else if ($result->report_deadline) {
429
-        if ($result->report_deadline>time()) {
430
-            $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>";
429
+        if ($result->report_deadline > time()) {
430
+            $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>";
431 431
         } else {
432
-            $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>";
432
+            $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>";
433 433
         }
434 434
     } else {
435 435
         $r = "---";
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 // @param Integer $dec A signed integer
491 491
 //
492 492
 function int2hex($dec) {
493
-    return "0x".strtoupper(substr(sprintf("%08x",$dec), -8));
493
+    return "0x".strtoupper(substr(sprintf("%08x", $dec), -8));
494 494
 }
495 495
 
496 496
 // Decode a windows error number into semi-human-readable,
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 // @return String A human readable error message
501 501
 // @param Integer $x An error number
502 502
 //
503
-function windows_error_code_str($x){
504
-    $h=int2hex($x);
505
-    switch($h){
503
+function windows_error_code_str($x) {
504
+    $h = int2hex($x);
505
+    switch ($h) {
506 506
     case "0xC0000005": return "STATUS_ACCESS_VIOLATION";
507 507
     case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION";
508 508
     case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO";
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 // @return String A human readable error message
524 524
 // @param Integer $x An error number
525 525
 //
526
-function error_code_str($x){
526
+function error_code_str($x) {
527 527
     // severe Windows error numbers are always large negative integers
528
-    if ($x<-400) return windows_error_code_str($x);
529
-    switch($x){
528
+    if ($x < -400) return windows_error_code_str($x);
529
+    switch ($x) {
530 530
     case 0: return "";
531 531
     case 192: return "EXIT_STATEFILE_WRITE";
532 532
     case 193: return "EXIT_SIGNAL";
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
     return $x." (".int2hex($x).") ".error_code_str($x);
688 688
 }
689 689
 
690
-function show_result($result, $show_outfile_links=false) {
690
+function show_result($result, $show_outfile_links = false) {
691 691
     start_table();
692 692
     row2(tra("Name"), $result->name);
693 693
     row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
     echo "<h3>".tra("Stderr output")."</h3> <pre>"
737 737
         .htmlspecialchars(
738 738
             $result->stderr_out,
739
-            ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0),
739
+            ENT_QUOTES|(defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0),
740 740
             'utf-8'
741 741
         )
742 742
         ."</pre>"
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 
752 752
     $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name');
753 753
 
754
-    for ($i=0; $i<NSTATES; $i++) {
754
+    for ($i = 0; $i < NSTATES; $i++) {
755 755
         $state_count[$i] = 0;
756 756
     }
757 757
     foreach ($apps as $app) {
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
         $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>";
794 794
     }
795 795
     $x .= "<br>".tra("State").": ";
796
-    for ($i=0; $i<NSTATES; $i++) {
796
+    for ($i = 0; $i < NSTATES; $i++) {
797 797
         if ($i) $x .= " &middot; ";
798 798
         if ($info->state == $i) {
799 799
             $x .= $state_name[$i];
@@ -838,6 +838,6 @@  discard block
 block discarded – undo
838 838
     return $x;
839 839
 }
840 840
 
841
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
841
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
842 842
 
843 843
 ?>
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 // @return String A human readable error message
501 501
 // @param Integer $x An error number
502 502
 //
503
-function windows_error_code_str($x){
503
+function windows_error_code_str($x) {
504 504
     $h=int2hex($x);
505
-    switch($h){
505
+    switch($h) {
506 506
     case "0xC0000005": return "STATUS_ACCESS_VIOLATION";
507 507
     case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION";
508 508
     case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO";
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 // @return String A human readable error message
524 524
 // @param Integer $x An error number
525 525
 //
526
-function error_code_str($x){
526
+function error_code_str($x) {
527 527
     // severe Windows error numbers are always large negative integers
528 528
     if ($x<-400) return windows_error_code_str($x);
529
-    switch($x){
529
+    switch($x) {
530 530
     case 0: return "";
531 531
     case 192: return "EXIT_STATEFILE_WRITE";
532 532
     case 193: return "EXIT_SIGNAL";
Please login to merge, or discard this patch.