@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * We use the FlipsideSettings class for a list of sites and settings |
17 | 17 | * about CDNs and minified JS/CSS |
18 | 18 | */ |
19 | -if(isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
|
19 | +if (isset($GLOBALS['FLIPSIDE_SETTINGS_LOC'])) |
|
20 | 20 | { |
21 | 21 | require_once($GLOBALS['FLIPSIDE_SETTINGS_LOC'].'/class.FlipsideSettings.php'); |
22 | 22 | } |
@@ -30,32 +30,32 @@ discard block |
||
30 | 30 | */ |
31 | 31 | require_once('class.WebPage.php'); |
32 | 32 | |
33 | -define('JS_JQUERY', 0); |
|
34 | -define('JS_JQUERY_UI', 1); |
|
35 | -define('JS_BOOTSTRAP', 2); |
|
33 | +define('JS_JQUERY', 0); |
|
34 | +define('JS_JQUERY_UI', 1); |
|
35 | +define('JS_BOOTSTRAP', 2); |
|
36 | 36 | define('JQUERY_VALIDATE', 3); |
37 | -define('JQUERY_TOUCH', 4); |
|
38 | -define('JS_TINYNAV', 5); |
|
37 | +define('JQUERY_TOUCH', 4); |
|
38 | +define('JS_TINYNAV', 5); |
|
39 | 39 | define('JS_BOOTSTRAP_FH', 6); |
40 | 40 | define('JS_BOOTSTRAP_SW', 7); |
41 | -define('JS_DATATABLE', 8); |
|
42 | -define('JS_CHART', 9); |
|
43 | -define('JS_METISMENU', 10); |
|
44 | -define('JS_BOOTBOX', 11); |
|
41 | +define('JS_DATATABLE', 8); |
|
42 | +define('JS_CHART', 9); |
|
43 | +define('JS_METISMENU', 10); |
|
44 | +define('JS_BOOTBOX', 11); |
|
45 | 45 | define('JS_DATATABLE_ODATA', 12); |
46 | -define('JS_CRYPTO_MD5_JS', 13); |
|
47 | -define('JS_JCROP', 14); |
|
48 | -define('JS_TYPEAHEAD', 15); |
|
49 | -define('JS_FLIPSIDE', 20); |
|
50 | -define('JS_LOGIN', 21); |
|
51 | - |
|
52 | -define('CSS_JQUERY_UI', 0); |
|
53 | -define('CSS_BOOTSTRAP', 1); |
|
46 | +define('JS_CRYPTO_MD5_JS', 13); |
|
47 | +define('JS_JCROP', 14); |
|
48 | +define('JS_TYPEAHEAD', 15); |
|
49 | +define('JS_FLIPSIDE', 20); |
|
50 | +define('JS_LOGIN', 21); |
|
51 | + |
|
52 | +define('CSS_JQUERY_UI', 0); |
|
53 | +define('CSS_BOOTSTRAP', 1); |
|
54 | 54 | define('CSS_BOOTSTRAP_FH', 2); |
55 | 55 | define('CSS_BOOTSTRAP_SW', 3); |
56 | -define('CSS_DATATABLE', 4); |
|
57 | -define('CSS_JCROP', 5); |
|
58 | -define('CSS_FONTAWESOME', 6); |
|
56 | +define('CSS_DATATABLE', 4); |
|
57 | +define('CSS_JCROP', 5); |
|
58 | +define('CSS_FONTAWESOME', 6); |
|
59 | 59 | |
60 | 60 | global $jsArray; |
61 | 61 | $jsArray = array( |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @SuppressWarnings("StaticAccess") |
351 | 351 | */ |
352 | - function __construct($title, $header=true) |
|
352 | + function __construct($title, $header = true) |
|
353 | 353 | { |
354 | 354 | parent::__construct($title); |
355 | 355 | $this->setupVars(); |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | $this->notifications = array(); |
362 | 362 | $this->loginUrl = 'login.php'; |
363 | 363 | $this->logoutUrl = 'logout.php'; |
364 | - if(isset(FlipsideSettings::$global)) |
|
364 | + if (isset(FlipsideSettings::$global)) |
|
365 | 365 | { |
366 | - if(isset(FlipsideSettings::$global['login_url'])) |
|
366 | + if (isset(FlipsideSettings::$global['login_url'])) |
|
367 | 367 | { |
368 | 368 | $this->loginUrl = FlipsideSettings::$global['login_url']; |
369 | 369 | } |
370 | - if(isset(FlipsideSettings::$global['logout_url'])) |
|
370 | + if (isset(FlipsideSettings::$global['logout_url'])) |
|
371 | 371 | { |
372 | 372 | $this->logoutUrl = FlipsideSettings::$global['logout_url']; |
373 | 373 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | protected function getSites() |
384 | 384 | { |
385 | - if(isset(FlipsideSettings::$sites)) |
|
385 | + if (isset(FlipsideSettings::$sites)) |
|
386 | 386 | { |
387 | 387 | return FlipsideSettings::$sites; |
388 | 388 | } |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | */ |
399 | 399 | protected function addAllLinks() |
400 | 400 | { |
401 | - if($this->user === false || $this->user === null) |
|
401 | + if ($this->user === false || $this->user === null) |
|
402 | 402 | { |
403 | - if(isset($_SERVER['REQUEST_URI']) && strstr($_SERVER['REQUEST_URI'], 'logout.php') === false) |
|
403 | + if (isset($_SERVER['REQUEST_URI']) && strstr($_SERVER['REQUEST_URI'], 'logout.php') === false) |
|
404 | 404 | { |
405 | 405 | $this->addLink('Login', $this->loginUrl); |
406 | 406 | } |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | */ |
424 | 424 | private function setupVars() |
425 | 425 | { |
426 | - if($this->minified !== null && $this->cdn !== null) return; |
|
426 | + if ($this->minified !== null && $this->cdn !== null) return; |
|
427 | 427 | $this->minified = 'min'; |
428 | 428 | $this->cdn = 'cdn'; |
429 | - if(isset(FlipsideSettings::$global)) |
|
429 | + if (isset(FlipsideSettings::$global)) |
|
430 | 430 | { |
431 | - if(isset(FlipsideSettings::$global['use_minified']) && !FlipsideSettings::$global['use_minified']) |
|
431 | + if (isset(FlipsideSettings::$global['use_minified']) && !FlipsideSettings::$global['use_minified']) |
|
432 | 432 | { |
433 | 433 | $this->minified = 'no'; |
434 | 434 | } |
435 | - if(isset(FlipsideSettings::$global['use_cdn']) && !FlipsideSettings::$global['use_cdn']) |
|
435 | + if (isset(FlipsideSettings::$global['use_cdn']) && !FlipsideSettings::$global['use_cdn']) |
|
436 | 436 | { |
437 | 437 | $this->cdn = 'no'; |
438 | 438 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * |
448 | 448 | * @deprecated 2.0.0 Please use addJSByURI() instead |
449 | 449 | */ |
450 | - function add_js_from_src($src, $async=true) |
|
450 | + function add_js_from_src($src, $async = true) |
|
451 | 451 | { |
452 | 452 | $this->addJSByURI($src, $async); |
453 | 453 | } |
@@ -458,10 +458,10 @@ discard block |
||
458 | 458 | * @param string $uri The webpath to the JavaScript file |
459 | 459 | * @param boolean $async Can the JavaScript be loaded asynchronously? |
460 | 460 | */ |
461 | - public function addJSByURI($uri, $async=true) |
|
461 | + public function addJSByURI($uri, $async = true) |
|
462 | 462 | { |
463 | 463 | $attributes = array('src'=>$uri, 'type'=>'text/javascript'); |
464 | - if($async === true) |
|
464 | + if ($async === true) |
|
465 | 465 | { |
466 | 466 | $attributes['async'] = true; |
467 | 467 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @deprecated 2.0.0 Please use addCSSByURI() instead |
481 | 481 | */ |
482 | - function add_css_from_src($src, $import=false) |
|
482 | + function add_css_from_src($src, $import = false) |
|
483 | 483 | { |
484 | 484 | $this->addCSSByURI($src, $import); |
485 | 485 | } |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | * @param string $src The webpath to the Cascading Style Sheet file |
491 | 491 | * @param boolean $async Can the CSS be loaded asynchronously? |
492 | 492 | */ |
493 | - public function addCSSByURI($uri, $async=false) |
|
493 | + public function addCSSByURI($uri, $async = false) |
|
494 | 494 | { |
495 | 495 | $attributes = array('rel'=>'stylesheet', 'href'=>$uri, 'type'=>'text/css'); |
496 | - if($async === true && $this->importSupport === true) |
|
496 | + if ($async === true && $this->importSupport === true) |
|
497 | 497 | { |
498 | 498 | $attributes['rel'] = 'import'; |
499 | 499 | } |
@@ -509,12 +509,12 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @deprecated 2.0.0 Please use addWellKnownJS() instead |
511 | 511 | */ |
512 | - function addJS($type, $async=true) |
|
512 | + function addJS($type, $async = true) |
|
513 | 513 | { |
514 | 514 | $this->addWellKnownJS($type, $async); |
515 | 515 | } |
516 | 516 | |
517 | - function add_js($type, $async=true) |
|
517 | + function add_js($type, $async = true) |
|
518 | 518 | { |
519 | 519 | $this->addWellKnownJS($type, $async); |
520 | 520 | } |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | * @param string $jsFileID the ID of the JS file |
526 | 526 | * @param boolean $async Can the JS file be loaded asynchronously? |
527 | 527 | */ |
528 | - public function addWellKnownJS($jsFileID, $async=true) |
|
528 | + public function addWellKnownJS($jsFileID, $async = true) |
|
529 | 529 | { |
530 | 530 | global $jsArray; |
531 | 531 | $this->setupVars(); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | * |
542 | 542 | * @deprecated 2.0.0 Please use addWellKnownCSS() instead |
543 | 543 | */ |
544 | - function add_css($type, $import=false) |
|
544 | + function add_css($type, $import = false) |
|
545 | 545 | { |
546 | 546 | $this->addWellKnownCSS($type, $import); |
547 | 547 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @param string $cssFileID the ID of the CSS file |
553 | 553 | * @param boolean $async Can the CSS file be loaded asynchronously? |
554 | 554 | */ |
555 | - public function addWellKnownCSS($cssFileID, $async=true) |
|
555 | + public function addWellKnownCSS($cssFileID, $async = true) |
|
556 | 556 | { |
557 | 557 | global $cssArray; |
558 | 558 | $this->setupVars(); |
@@ -575,16 +575,16 @@ discard block |
||
575 | 575 | $sites = $this->getSites(); |
576 | 576 | $names = array_keys($sites); |
577 | 577 | $ret = ''; |
578 | - foreach($names as $name) |
|
578 | + foreach ($names as $name) |
|
579 | 579 | { |
580 | - $ret.='<li>'.$this->createLink($name, $sites[$name]).'</li>'; |
|
580 | + $ret .= '<li>'.$this->createLink($name, $sites[$name]).'</li>'; |
|
581 | 581 | } |
582 | 582 | return $ret; |
583 | 583 | } |
584 | 584 | |
585 | 585 | protected function getHrefForDropdown(&$link) |
586 | 586 | { |
587 | - if(isset($link['_'])) |
|
587 | + if (isset($link['_'])) |
|
588 | 588 | { |
589 | 589 | $ret = $link['_']; |
590 | 590 | unset($link['_']); |
@@ -597,24 +597,24 @@ discard block |
||
597 | 597 | { |
598 | 598 | $ret = '<li class="dropdown">'; |
599 | 599 | $href = $this->getHrefForDropdown($link); |
600 | - $ret.= '<a href="'.$href.'" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'.$name.' <span class="caret"></span></a>'; |
|
601 | - $ret.='<ul class="dropdown-menu">'; |
|
600 | + $ret .= '<a href="'.$href.'" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">'.$name.' <span class="caret"></span></a>'; |
|
601 | + $ret .= '<ul class="dropdown-menu">'; |
|
602 | 602 | $subNames = array_keys($link); |
603 | - foreach($subNames as $subName) |
|
603 | + foreach ($subNames as $subName) |
|
604 | 604 | { |
605 | - $ret.=$this->getLinkByName($subName, $link); |
|
605 | + $ret .= $this->getLinkByName($subName, $link); |
|
606 | 606 | } |
607 | - $ret.='</ul></li>'; |
|
607 | + $ret .= '</ul></li>'; |
|
608 | 608 | return $ret; |
609 | 609 | } |
610 | 610 | |
611 | 611 | protected function getLinkByName($name, $links) |
612 | 612 | { |
613 | - if(is_array($links[$name])) |
|
613 | + if (is_array($links[$name])) |
|
614 | 614 | { |
615 | 615 | return $this->getDropdown($links[$name], $name); |
616 | 616 | } |
617 | - if($links[$name] === false) |
|
617 | + if ($links[$name] === false) |
|
618 | 618 | { |
619 | 619 | return '<li>'.$name.'</li>'; |
620 | 620 | } |
@@ -625,9 +625,9 @@ discard block |
||
625 | 625 | { |
626 | 626 | $names = array_keys($this->links); |
627 | 627 | $ret = ''; |
628 | - foreach($names as $name) |
|
628 | + foreach ($names as $name) |
|
629 | 629 | { |
630 | - $ret.=$this->getLinkByName($name, $this->links); |
|
630 | + $ret .= $this->getLinkByName($name, $this->links); |
|
631 | 631 | } |
632 | 632 | return $ret; |
633 | 633 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | { |
640 | 640 | $sites = $this->getSiteLinksForHeader(); |
641 | 641 | $links = $this->getLinksMenus(); |
642 | - $header ='<nav class="navbar navbar-default navbar-fixed-top"> |
|
642 | + $header = '<nav class="navbar navbar-default navbar-fixed-top"> |
|
643 | 643 | <div class="container-fluid"> |
644 | 644 | <!-- Brand and toggle get grouped for better mobile display --> |
645 | 645 | <div class="navbar-header"> |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | </div> |
669 | 669 | </nav>'; |
670 | 670 | $this->body = $header.$this->body; |
671 | - $this->body_tags.='style="padding-top: 60px;"'; |
|
671 | + $this->body_tags .= 'style="padding-top: 60px;"'; |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | /** Notification that is green for success */ |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | * |
690 | 690 | * @deprecated 2.0.0 Use the addNotification function instead |
691 | 691 | */ |
692 | - function add_notification($msg, $sev=self::NOTIFICATION_INFO, $dismissible=1) |
|
692 | + function add_notification($msg, $sev = self::NOTIFICATION_INFO, $dismissible = 1) |
|
693 | 693 | { |
694 | 694 | $notice = array('msg'=>$msg, 'sev'=>$sev, 'dismissible'=>$dismissible); |
695 | 695 | array_push($this->notifications, $notice); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * |
705 | 705 | * @deprecated 2.0.0 Use the addNotification function instead |
706 | 706 | */ |
707 | - public function addNotification($message, $severity=self::NOTIFICATION_INFO, $dismissible=true) |
|
707 | + public function addNotification($message, $severity = self::NOTIFICATION_INFO, $dismissible = true) |
|
708 | 708 | { |
709 | 709 | array_push($this->notificatons, array('msg'=>$message, 'sev'=>$severity, 'dismissible'=>$dismissible)); |
710 | 710 | } |
@@ -715,21 +715,21 @@ discard block |
||
715 | 715 | private function renderNotifications() |
716 | 716 | { |
717 | 717 | $count = count($this->notifications); |
718 | - if($count === 0) |
|
718 | + if ($count === 0) |
|
719 | 719 | { |
720 | 720 | return; |
721 | 721 | } |
722 | - for($i = 0; $i < $count; $i++) |
|
722 | + for ($i = 0; $i < $count; $i++) |
|
723 | 723 | { |
724 | 724 | $class = 'alert '.$this->notifications[$i]['sev']; |
725 | 725 | $button = ''; |
726 | - if($this->notifications[$i]['dismissible']) |
|
726 | + if ($this->notifications[$i]['dismissible']) |
|
727 | 727 | { |
728 | 728 | $class .= ' alert-dismissible'; |
729 | 729 | $button = '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'; |
730 | 730 | } |
731 | 731 | $prefix = ''; |
732 | - switch($this->notifications[$i]['sev']) |
|
732 | + switch ($this->notifications[$i]['sev']) |
|
733 | 733 | { |
734 | 734 | case self::NOTIFICATION_INFO: |
735 | 735 | $prefix = '<strong>Notice:</strong> '; |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | break; |
743 | 743 | } |
744 | 744 | $style = ''; |
745 | - if($i+1 < count($this->notifications)) |
|
745 | + if ($i + 1 < count($this->notifications)) |
|
746 | 746 | { |
747 | 747 | //Not the last notification, remove the end margin |
748 | - $style='style="margin: 0px;"'; |
|
748 | + $style = 'style="margin: 0px;"'; |
|
749 | 749 | } |
750 | 750 | $this->body = ' |
751 | 751 | <div class="'.$class.'" role="alert" '.$style.'> |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | */ |
774 | 774 | private function addAnalyticsBlock() |
775 | 775 | { |
776 | - if($this->analytics === false) |
|
776 | + if ($this->analytics === false) |
|
777 | 777 | { |
778 | 778 | return; |
779 | 779 | } |
@@ -795,12 +795,12 @@ discard block |
||
795 | 795 | * @param boolean $header Draw the header |
796 | 796 | * @param boolean $analytics Include analytics on the page |
797 | 797 | */ |
798 | - public function printPage($header=true) |
|
798 | + public function printPage($header = true) |
|
799 | 799 | { |
800 | 800 | $this->renderNotifications(); |
801 | 801 | $this->addNoScript(); |
802 | 802 | $this->addAnalyticsBlock(); |
803 | - if($this->header || $header) |
|
803 | + if ($this->header || $header) |
|
804 | 804 | { |
805 | 805 | $this->addHeader(); |
806 | 806 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | * |
817 | 817 | * @deprecated 1.0.0 Use addLink instead |
818 | 818 | */ |
819 | - function add_link($name, $url=false, $submenu=false) |
|
819 | + function add_link($name, $url = false, $submenu = false) |
|
820 | 820 | { |
821 | 821 | $this->addLink($name, $url, $submenu); |
822 | 822 | } |
@@ -828,9 +828,9 @@ discard block |
||
828 | 828 | * @param false|string $url The URL to link to |
829 | 829 | * @param false|array $subment Any submenu items for the dropdown |
830 | 830 | */ |
831 | - public function addLink($name, $url=false, $submenu=false) |
|
831 | + public function addLink($name, $url = false, $submenu = false) |
|
832 | 832 | { |
833 | - if(is_array($submenu)) |
|
833 | + if (is_array($submenu)) |
|
834 | 834 | { |
835 | 835 | $submenu['_'] = $url; |
836 | 836 | $this->links[$name] = $submenu; |
@@ -852,11 +852,11 @@ discard block |
||
852 | 852 | $authLinks = $auth->getSupplementaryLinks(); |
853 | 853 | $authLinksStr = ''; |
854 | 854 | $count = count($authLinks); |
855 | - for($i = 0; $i < $count; $i++) |
|
855 | + for ($i = 0; $i < $count; $i++) |
|
856 | 856 | { |
857 | 857 | $authLinksStr .= $authLinks[$i]; |
858 | 858 | } |
859 | - if($count > 0) |
|
859 | + if ($count > 0) |
|
860 | 860 | { |
861 | 861 | $authLinksStr = 'Sign in with '.$authLinksStr; |
862 | 862 | } |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once('Autoload.php'); |
3 | -if(!isset($_SESSION) && php_sapi_name() !== 'cli') { session_start(); } |
|
4 | -if(!isset($_SESSION['ip_address']) && isset($_SERVER['REMOTE_ADDR'])) |
|
3 | +if (!isset($_SESSION) && php_sapi_name() !== 'cli') { session_start(); } |
|
4 | +if (!isset($_SESSION['ip_address']) && isset($_SERVER['REMOTE_ADDR'])) |
|
5 | 5 | { |
6 | 6 | $_SESSION['ip_address'] = $_SERVER['REMOTE_ADDR']; |
7 | 7 | } |
8 | -if(!isset($_SESSION['init_time'])) |
|
8 | +if (!isset($_SESSION['init_time'])) |
|
9 | 9 | { |
10 | 10 | $_SESSION['init_time'] = date('c'); |
11 | 11 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | static function getVar($name, $default = false) |
31 | 31 | { |
32 | - if(FlipSession::doesVarExist($name)) |
|
32 | + if (FlipSession::doesVarExist($name)) |
|
33 | 33 | { |
34 | 34 | return $_SESSION[$name]; |
35 | 35 | } |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | */ |
57 | 57 | static function isLoggedIn() |
58 | 58 | { |
59 | - if(isset($_SESSION['flipside_user'])) |
|
59 | + if (isset($_SESSION['flipside_user'])) |
|
60 | 60 | { |
61 | 61 | return true; |
62 | 62 | } |
63 | - else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData'])) |
|
63 | + else if (isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData'])) |
|
64 | 64 | { |
65 | 65 | $auth = AuthProvider::getInstance(); |
66 | 66 | return $auth->isLoggedIn($_SESSION['AuthData'], $_SESSION['AuthMethod']); |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | */ |
79 | 79 | static function getUser() |
80 | 80 | { |
81 | - if(isset($_SESSION['flipside_user'])) |
|
81 | + if (isset($_SESSION['flipside_user'])) |
|
82 | 82 | { |
83 | 83 | return $_SESSION['flipside_user']; |
84 | 84 | } |
85 | - else if(isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData'])) |
|
85 | + else if (isset($_SESSION['AuthMethod']) && isset($_SESSION['AuthData'])) |
|
86 | 86 | { |
87 | 87 | $auth = AuthProvider::getInstance(); |
88 | 88 | $user = $auth->getUser($_SESSION['AuthData'], $_SESSION['AuthMethod']); |
89 | - if($user !== null) |
|
89 | + if ($user !== null) |
|
90 | 90 | { |
91 | 91 | $_SESSION['flipside_user'] = $user; |
92 | 92 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | */ |
116 | 116 | static function getUserEmail() |
117 | 117 | { |
118 | - if(isset($_SESSION['flipside_email'])) |
|
118 | + if (isset($_SESSION['flipside_email'])) |
|
119 | 119 | { |
120 | 120 | return $_SESSION['flipside_email']; |
121 | 121 | } |
122 | 122 | $user = FlipSession::getUser(); |
123 | - if($user === false || $user === null) |
|
123 | + if ($user === false || $user === null) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
127 | - if(isset($user->mail) && isset($user->mail[0])) |
|
127 | + if (isset($user->mail) && isset($user->mail[0])) |
|
128 | 128 | { |
129 | 129 | $_SESSION['flipside_email'] = $user->mail[0]; |
130 | 130 | return $_SESSION['flipside_email']; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | static function end() |
141 | 141 | { |
142 | - if(isset($_SESSION) && !empty($_SESSION)) |
|
142 | + if (isset($_SESSION) && !empty($_SESSION)) |
|
143 | 143 | { |
144 | 144 | $_SESSION = array(); |
145 | 145 | session_destroy(); |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | $res = array(); |
152 | 152 | $offset = 0; |
153 | 153 | $length = strlen($sessionData); |
154 | - while($offset < $length) |
|
154 | + while ($offset < $length) |
|
155 | 155 | { |
156 | 156 | $pos = strpos($sessionData, "|", $offset); |
157 | 157 | $len = $pos - $offset; |
158 | 158 | $name = substr($sessionData, $offset, $len); |
159 | - if($name === false) break; |
|
160 | - $offset += $len+1; |
|
159 | + if ($name === false) break; |
|
160 | + $offset += $len + 1; |
|
161 | 161 | $data = @unserialize(substr($sessionData, $offset)); |
162 | 162 | $res[$name] = $data; |
163 | 163 | $offset += strlen(serialize($data)); |
@@ -170,26 +170,26 @@ discard block |
||
170 | 170 | $res = array(); |
171 | 171 | $sessFiles = scandir(ini_get('session.save_path')); |
172 | 172 | $count = count($sessFiles); |
173 | - for($i = 0; $i < $count; $i++) |
|
173 | + for ($i = 0; $i < $count; $i++) |
|
174 | 174 | { |
175 | - if($sessFiles[$i][0] === '.') |
|
175 | + if ($sessFiles[$i][0] === '.') |
|
176 | 176 | { |
177 | 177 | continue; |
178 | 178 | } |
179 | 179 | $sessionId = substr($sessFiles[$i], 5); |
180 | 180 | $sessionData = file_get_contents(ini_get('session.save_path').'/'.$sessFiles[$i]); |
181 | - if($sessionData === false) |
|
181 | + if ($sessionData === false) |
|
182 | 182 | { |
183 | 183 | array_push($res, array('sid' => $sessionId)); |
184 | 184 | } |
185 | 185 | else |
186 | 186 | { |
187 | 187 | $tmp = FlipSession::unserializePhpSession($sessionData); |
188 | - $tmp['sid' ] = $sessionId; |
|
188 | + $tmp['sid'] = $sessionId; |
|
189 | 189 | array_push($res, $tmp); |
190 | 190 | } |
191 | 191 | } |
192 | - if(count($res) == 0) |
|
192 | + if (count($res) == 0) |
|
193 | 193 | { |
194 | 194 | return false; |
195 | 195 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * @link http://www.php.net/manual/en/class.jsonserializable.php |
11 | 11 | */ |
12 | 12 | |
13 | -if(PHP_VERSION_ID < 50400) |
|
13 | +if (PHP_VERSION_ID < 50400) |
|
14 | 14 | { |
15 | 15 | /** |
16 | 16 | * JsonSerializable interface |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | $this->importSupport = false; |
59 | 59 | |
60 | 60 | $browserName = $this->getBrowserName(); |
61 | - if($browserName === 'IE' && $this->getBrowserMajorVer() <= 7) |
|
61 | + if ($browserName === 'IE' && $this->getBrowserMajorVer() <= 7) |
|
62 | 62 | { |
63 | - header( 'Location: /badbrowser.php' ) ; |
|
63 | + header('Location: /badbrowser.php'); |
|
64 | 64 | } |
65 | - else if($browserName === 'Chrome' && $this->getBrowserMajorVer() >= 36) |
|
65 | + else if ($browserName === 'Chrome' && $this->getBrowserMajorVer() >= 36) |
|
66 | 66 | { |
67 | 67 | $this->importSupport = true; |
68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function getBrowscap() |
79 | 79 | { |
80 | - if(isset($GLOBALS['BROWSCAP_CACHE'])) |
|
80 | + if (isset($GLOBALS['BROWSCAP_CACHE'])) |
|
81 | 81 | { |
82 | 82 | return new Browscap($GLOBALS['BROWSCAP_CACHE']); |
83 | 83 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private function getBrowser() |
91 | 91 | { |
92 | - static $browser;//No accident can arise from depending on an unset variable. |
|
93 | - if(!isset($browser)) |
|
92 | + static $browser; //No accident can arise from depending on an unset variable. |
|
93 | + if (!isset($browser)) |
|
94 | 94 | { |
95 | 95 | $browser = $this->browscap->getBrowser(); |
96 | 96 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | private function getBrowserName() |
104 | 104 | { |
105 | - if(isset($this->browser->Browser)) |
|
105 | + if (isset($this->browser->Browser)) |
|
106 | 106 | { |
107 | 107 | return $this->browser->Browser; |
108 | 108 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | private function getBrowserMajorVer() |
119 | 119 | { |
120 | - if(isset($this->browser->MajorVer)) |
|
120 | + if (isset($this->browser->MajorVer)) |
|
121 | 121 | { |
122 | 122 | return $this->browser->MajorVer; |
123 | 123 | } |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return string The tag as a string |
192 | 192 | */ |
193 | - protected function createOpenTag($tagName, $attribs=array(), $selfClose=false) |
|
193 | + protected function createOpenTag($tagName, $attribs = array(), $selfClose = false) |
|
194 | 194 | { |
195 | 195 | $tag = '<'.$tagName; |
196 | 196 | $attribNames = array_keys($attribs); |
197 | - foreach($attribNames as $attribName) |
|
197 | + foreach ($attribNames as $attribName) |
|
198 | 198 | { |
199 | - $tag.=' '.$attribName; |
|
200 | - if($attribs[$attribName]) |
|
199 | + $tag .= ' '.$attribName; |
|
200 | + if ($attribs[$attribName]) |
|
201 | 201 | { |
202 | - $tag.='="'.$attribs[$attribName].'"'; |
|
202 | + $tag .= '="'.$attribs[$attribName].'"'; |
|
203 | 203 | } |
204 | 204 | } |
205 | - if($selfClose) |
|
205 | + if ($selfClose) |
|
206 | 206 | { |
207 | 207 | return $tag.'/>'; |
208 | 208 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string The link |
231 | 231 | */ |
232 | - public function createLink($linkName, $linkTarget='#') |
|
232 | + public function createLink($linkName, $linkTarget = '#') |
|
233 | 233 | { |
234 | 234 | $startTag = $this->createOpenTag('a', array('href'=>$linkTarget)); |
235 | 235 | $endTag = $this->createCloseTag('a'); |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @param string $prefix The prefix to append to each line |
247 | 247 | */ |
248 | - protected function printIeCompatability($prefix='') |
|
248 | + protected function printIeCompatability($prefix = '') |
|
249 | 249 | { |
250 | 250 | //IE 8 doesn't support HTML 5. Install the shim... |
251 | - if($this->getBrowserMajorVer() < 9) |
|
251 | + if ($this->getBrowserMajorVer() < 9) |
|
252 | 252 | { |
253 | 253 | echo $prefix.'<script src="js/html5.js"></script>'; |
254 | 254 | echo "\n"; |
@@ -263,16 +263,16 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @param string $prefix The prefix to append to each line |
265 | 265 | */ |
266 | - protected function printHead($prefix='') |
|
266 | + protected function printHead($prefix = '') |
|
267 | 267 | { |
268 | 268 | echo $prefix.'<HEAD>'; |
269 | - if($this->getBrowserName() === 'IE') |
|
269 | + if ($this->getBrowserName() === 'IE') |
|
270 | 270 | { |
271 | 271 | $this->printIeCompatability($prefix.$prefix); |
272 | 272 | } |
273 | 273 | echo $prefix.$prefix.'<TITLE>'.$this->title.'</TITLE>'; |
274 | 274 | echo $prefix.$prefix.'<meta name="viewport" content="width=device-width, initial-scale=1.0">'; |
275 | - foreach($this->headTags as $tag) |
|
275 | + foreach ($this->headTags as $tag) |
|
276 | 276 | { |
277 | 277 | echo $prefix.$prefix.$tag."\n"; |
278 | 278 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @param string $prefix The prefix to append to each line |
286 | 286 | */ |
287 | - protected function printBody($prefix='') |
|
287 | + protected function printBody($prefix = '') |
|
288 | 288 | { |
289 | 289 | echo $prefix.'<BODY '.$this->body_tags.'>'; |
290 | 290 | echo $prefix.$prefix.$this->body."\n"; |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | */ |
313 | 313 | public function currentURL() |
314 | 314 | { |
315 | - if(!isset($_SERVER['REQUEST_URI'])) |
|
315 | + if (!isset($_SERVER['REQUEST_URI'])) |
|
316 | 316 | { |
317 | 317 | return ''; |
318 | 318 | } |
319 | 319 | $requestURI = $_SERVER['REQUEST_URI']; |
320 | - if($requestURI[0] === '/') |
|
320 | + if ($requestURI[0] === '/') |
|
321 | 321 | { |
322 | 322 | $requestURI = substr($requestURI, 1); |
323 | 323 | } |
324 | - return 'http'.(isset($_SERVER['HTTPS'])?'s':'').'://'.$_SERVER['HTTP_HOST'].'/'.$requestURI; |
|
324 | + return 'http'.(isset($_SERVER['HTTPS']) ? 's' : '').'://'.$_SERVER['HTTP_HOST'].'/'.$requestURI; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | protected function __construct() |
38 | 38 | { |
39 | 39 | $this->methods = array(); |
40 | - if(isset(FlipsideSettings::$email_providers)) |
|
40 | + if (isset(FlipsideSettings::$email_providers)) |
|
41 | 41 | { |
42 | 42 | $keys = array_keys(FlipsideSettings::$email_providers); |
43 | 43 | $count = count($keys); |
44 | - for($i = 0; $i < $count; $i++) |
|
44 | + for ($i = 0; $i < $count; $i++) |
|
45 | 45 | { |
46 | 46 | $class = $keys[$i]; |
47 | 47 | array_push($this->methods, new $class(FlipsideSettings::$email_providers[$keys[$i]])); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | public function getEmailMethod($methodName) |
60 | 60 | { |
61 | 61 | $count = count($this->methods); |
62 | - for($i = 0; $i < $count; $i++) |
|
62 | + for ($i = 0; $i < $count; $i++) |
|
63 | 63 | { |
64 | - if(strcasecmp(get_class($this->methods[$i]), $methodName) === 0) |
|
64 | + if (strcasecmp(get_class($this->methods[$i]), $methodName) === 0) |
|
65 | 65 | { |
66 | 66 | return $this->methods[$i]; |
67 | 67 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function sendEmail($email, $methodName = false) |
81 | 81 | { |
82 | - if($methodName === false) |
|
82 | + if ($methodName === false) |
|
83 | 83 | { |
84 | 84 | $res = false; |
85 | 85 | $count = count($this->methods); |
86 | - for($i = 0; $i < $count; $i++) |
|
86 | + for ($i = 0; $i < $count; $i++) |
|
87 | 87 | { |
88 | 88 | $res = $this->methods[$i]->sendEmail($email); |
89 | - if($res !== false) |
|
89 | + if ($res !== false) |
|
90 | 90 | { |
91 | 91 | return $res; |
92 | 92 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function getFromAddress() |
64 | 64 | { |
65 | - if($this->sender === false) |
|
65 | + if ($this->sender === false) |
|
66 | 66 | { |
67 | 67 | return 'Burning Flipside <[email protected]>'; |
68 | 68 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getReplyTo() |
108 | 108 | { |
109 | - if($this->replyTo === false) |
|
109 | + if ($this->replyTo === false) |
|
110 | 110 | { |
111 | 111 | return $this->getFromAddress(); |
112 | 112 | } |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * @param string $email The email address to send from |
150 | 150 | * @param string $name The name to associate with the from address |
151 | 151 | */ |
152 | - public function setFromAddress($email, $name=false) |
|
152 | + public function setFromAddress($email, $name = false) |
|
153 | 153 | { |
154 | 154 | $address = $email; |
155 | - if($name !== false) |
|
155 | + if ($name !== false) |
|
156 | 156 | { |
157 | 157 | $address = $name.' <'.$email.'>'; |
158 | 158 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param string $email The email address to send to |
166 | 166 | * @param string $name The name to associate with the address |
167 | 167 | */ |
168 | - public function addToAddress($email, $name=false) |
|
168 | + public function addToAddress($email, $name = false) |
|
169 | 169 | { |
170 | 170 | $this->addAddress($this->to, $email, $name); |
171 | 171 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param string $email The email address to send to |
177 | 177 | * @param string $name The name to associate with the address |
178 | 178 | */ |
179 | - public function addCCAddress($email, $name=false) |
|
179 | + public function addCCAddress($email, $name = false) |
|
180 | 180 | { |
181 | 181 | $this->addAddress($this->cc, $email, $name); |
182 | 182 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @param string $email The email address to send to |
188 | 188 | * @param string $name The name to associate with the address |
189 | 189 | */ |
190 | - public function addBCCAddress($email, $name=false) |
|
190 | + public function addBCCAddress($email, $name = false) |
|
191 | 191 | { |
192 | 192 | $this->addAddress($this->bcc, $email, $name); |
193 | 193 | } |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @param string $email The email address to send to |
200 | 200 | * @param string $name The name to associate with the address |
201 | 201 | */ |
202 | - protected function addAddress(&$list, $email, $name=false) |
|
202 | + protected function addAddress(&$list, $email, $name = false) |
|
203 | 203 | { |
204 | 204 | $address = $email; |
205 | - if($name !== false) |
|
205 | + if ($name !== false) |
|
206 | 206 | { |
207 | 207 | $address = $name.' <'.$email.'>'; |
208 | 208 | } |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | * @param string $email The email address to reply to |
216 | 216 | * @param string $name The name to associate with the from address |
217 | 217 | */ |
218 | - public function setReplyTo($email, $name=false) |
|
218 | + public function setReplyTo($email, $name = false) |
|
219 | 219 | { |
220 | 220 | $address = $email; |
221 | - if($name !== false) |
|
221 | + if ($name !== false) |
|
222 | 222 | { |
223 | 223 | $address = $name.' <'.$email.'>'; |
224 | 224 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function appendToHTMLBody($body) |
264 | 264 | { |
265 | - $this->htmlBody.= $body; |
|
265 | + $this->htmlBody .= $body; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function appendToTextBody($body) |
274 | 274 | { |
275 | - $this->textBody.= $body; |
|
275 | + $this->textBody .= $body; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function addAttachmentFromFile($filename, $name = false) |
297 | 297 | { |
298 | - if($name === false) |
|
298 | + if ($name === false) |
|
299 | 299 | { |
300 | 300 | $name = basename($filename); |
301 | 301 | } |
302 | 302 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
303 | 303 | $mimeType = finfo_file($finfo, $filename); |
304 | - if($mimeType === false) |
|
304 | + if ($mimeType === false) |
|
305 | 305 | { |
306 | 306 | $mimeType = 'application/octet-stream'; |
307 | 307 | } |
308 | - if(file_exists($filename) && is_file($filename) && is_readable($filename)) |
|
308 | + if (file_exists($filename) && is_file($filename) && is_readable($filename)) |
|
309 | 309 | { |
310 | 310 | $this->addAttachmentFromBuffer($name, file_get_contents($filename), $mimeType); |
311 | 311 | } |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | { |
331 | 331 | $boundary = uniqid(rand(), true); |
332 | 332 | $rawMessage = 'To: '.$this->encodeRecipients($this->getToAddresses())."\n"; |
333 | - $rawMessage.= 'From: '.$this->encodeRecipients($this->getFromAddress())."\n"; |
|
334 | - if(!empty($this->cc)) |
|
333 | + $rawMessage .= 'From: '.$this->encodeRecipients($this->getFromAddress())."\n"; |
|
334 | + if (!empty($this->cc)) |
|
335 | 335 | { |
336 | - $rawMessage.= 'CC: '. $this->encodeRecipients($this->getCCAddresses())."\n"; |
|
336 | + $rawMessage .= 'CC: '.$this->encodeRecipients($this->getCCAddresses())."\n"; |
|
337 | 337 | } |
338 | - if(!empty($this->bcc)) |
|
338 | + if (!empty($this->bcc)) |
|
339 | 339 | { |
340 | - $rawMessage.= 'BCC: '. $this->encodeRecipients($this->getBCCAddresses())."\n"; |
|
340 | + $rawMessage .= 'BCC: '.$this->encodeRecipients($this->getBCCAddresses())."\n"; |
|
341 | 341 | } |
342 | 342 | $rawMessage .= 'Subject: '.$this->getSubject()."\n"; |
343 | 343 | $rawMessage .= 'MIME-Version: 1.0'."\n"; |
@@ -345,27 +345,27 @@ discard block |
||
345 | 345 | $rawMessage .= "\n--{$boundary}\n"; |
346 | 346 | $rawMessage .= 'Content-type: Multipart/Alternative; boundary="alt-'.$boundary.'"'."\n"; |
347 | 347 | $textBody = $this->getTextBody(); |
348 | - if($textBody !== false && strlen($textBody) > 0) |
|
348 | + if ($textBody !== false && strlen($textBody) > 0) |
|
349 | 349 | { |
350 | - $rawMessage.= "\n--alt-{$boundary}\n"; |
|
351 | - $rawMessage.= "Content-Type: text/plain\n\n"; |
|
352 | - $rawMessage.= $textBody."\n"; |
|
350 | + $rawMessage .= "\n--alt-{$boundary}\n"; |
|
351 | + $rawMessage .= "Content-Type: text/plain\n\n"; |
|
352 | + $rawMessage .= $textBody."\n"; |
|
353 | 353 | } |
354 | - $htmlBody = $this->getHTMLBody(); |
|
355 | - if($htmlBody !== false && strlen($htmlBody) > 0) |
|
354 | + $htmlBody = $this->getHTMLBody(); |
|
355 | + if ($htmlBody !== false && strlen($htmlBody) > 0) |
|
356 | 356 | { |
357 | 357 | $rawMessage .= "\n--alt-{$boundary}\n"; |
358 | 358 | $rawMessage .= 'Content-Type: text/html; charset="UTF-8"'."\n\n"; |
359 | 359 | $rawMessage .= $htmlBody."\n"; |
360 | 360 | } |
361 | - $rawMessage.= "\n--alt-{$boundary}--\n"; |
|
362 | - foreach($this->attachments as $attachment) |
|
361 | + $rawMessage .= "\n--alt-{$boundary}--\n"; |
|
362 | + foreach ($this->attachments as $attachment) |
|
363 | 363 | { |
364 | - $rawMessage.= "\n--{$boundary}\n"; |
|
365 | - $rawMessage.= 'Content-Type: '. $attachment['mimeType'].'; name="'.$attachment['name']."\"\n"; |
|
366 | - $rawMessage.= 'Content-Disposition: attachment'."\n"; |
|
367 | - $rawMessage.= 'Content-Transfer-Encoding: base64'."\n\n"; |
|
368 | - $rawMessage.= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n"; |
|
364 | + $rawMessage .= "\n--{$boundary}\n"; |
|
365 | + $rawMessage .= 'Content-Type: '.$attachment['mimeType'].'; name="'.$attachment['name']."\"\n"; |
|
366 | + $rawMessage .= 'Content-Disposition: attachment'."\n"; |
|
367 | + $rawMessage .= 'Content-Transfer-Encoding: base64'."\n\n"; |
|
368 | + $rawMessage .= chunk_split(base64_encode($attachment['data']), 76, "\n")."\n"; |
|
369 | 369 | } |
370 | 370 | $rawMessage .= "\n--{$boundary}--\n"; |
371 | 371 | return $rawMessage; |
@@ -380,11 +380,11 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function encodeRecipients($recipient) |
382 | 382 | { |
383 | - if(is_array($recipient)) |
|
383 | + if (is_array($recipient)) |
|
384 | 384 | { |
385 | 385 | return join(', ', array_map(array($this, 'encodeRecipients'), $recipient)); |
386 | 386 | } |
387 | - if(preg_match("/(.*)<(.*)>/", $recipient, $regs)) |
|
387 | + if (preg_match("/(.*)<(.*)>/", $recipient, $regs)) |
|
388 | 388 | { |
389 | 389 | $recipient = '=?UTF-8?B?'.base64_encode($regs[1]).'?= <'.$regs[2].'>'; |
390 | 390 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | public function sendEmail($email) |
29 | 29 | { |
30 | - if($email->hasAttachments()) |
|
30 | + if ($email->hasAttachments()) |
|
31 | 31 | { |
32 | 32 | //Amazeon sendEmail doesn't support attachments. We need to use sendRawEmail |
33 | 33 | $args = array(); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | { |
6 | 6 | public $server; |
7 | 7 | |
8 | - function __construct($array=false, $server=false) |
|
8 | + function __construct($array = false, $server = false) |
|
9 | 9 | { |
10 | 10 | parent::__construct($array); |
11 | 11 | $this->server = $server; |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | $ret = array(); |
17 | 17 | foreach ($this as $key => $value) |
18 | 18 | { |
19 | - if($key === 'server' || $key === 'count') continue; |
|
20 | - if(is_numeric($key)) continue; |
|
21 | - if($key === 'jpegphoto') |
|
19 | + if ($key === 'server' || $key === 'count') continue; |
|
20 | + if (is_numeric($key)) continue; |
|
21 | + if ($key === 'jpegphoto') |
|
22 | 22 | { |
23 | 23 | $ret[$key] = base64_encode($value[0]); |
24 | 24 | continue; |
25 | 25 | } |
26 | - if(is_array($value) && $value['count'] === 1) |
|
26 | + if (is_array($value) && $value['count'] === 1) |
|
27 | 27 | { |
28 | 28 | $ret[$key] = $value[0]; |
29 | 29 | } |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | $search = array_flip($dn ? array('\\', '+', '<', '>', ';', '"', '#') : array('\\', '*', '(', ')', "\x00")); |
18 | 18 | |
19 | 19 | // Process characters to ignore |
20 | - if(is_array($ignore)) |
|
20 | + if (is_array($ignore)) |
|
21 | 21 | { |
22 | 22 | $ignore = array_values($ignore); |
23 | 23 | } |
24 | - for($char = 0; isset($ignore[$char]); $char++) |
|
24 | + for ($char = 0; isset($ignore[$char]); $char++) |
|
25 | 25 | { |
26 | 26 | unset($search[$ignore[$char]]); |
27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // Flip $search back to values and build $replace array |
30 | 30 | $search = array_keys($search); |
31 | 31 | $replace = array(); |
32 | - foreach($search as $char) |
|
32 | + foreach ($search as $char) |
|
33 | 33 | { |
34 | 34 | $replace[] = sprintf('\\%02x', ord($char)); |
35 | 35 | } |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $result = str_replace($search, $replace, $subject); |
39 | 39 | |
40 | 40 | // Encode leading/trailing spaces in DN values |
41 | - if($dn) |
|
41 | + if ($dn) |
|
42 | 42 | { |
43 | - if($result[0] == ' ') |
|
43 | + if ($result[0] == ' ') |
|
44 | 44 | { |
45 | 45 | $result = '\\20'.substr($result, 1); |
46 | 46 | } |
47 | - if($result[strlen($result) - 1] == ' ') |
|
47 | + if ($result[strlen($result) - 1] == ' ') |
|
48 | 48 | { |
49 | 49 | $result = substr($result, 0, -1).'\\20'; |
50 | 50 | } |
@@ -76,29 +76,29 @@ discard block |
||
76 | 76 | $this->ds = ldap_connect($this->connect); |
77 | 77 | } |
78 | 78 | |
79 | - private function getConnectString($name, $proto=false) |
|
79 | + private function getConnectString($name, $proto = false) |
|
80 | 80 | { |
81 | - if(strstr($name, ':') !== false) |
|
81 | + if (strstr($name, ':') !== false) |
|
82 | 82 | { |
83 | 83 | return $name; |
84 | 84 | } |
85 | - if($proto !== 'ldap') |
|
85 | + if ($proto !== 'ldap') |
|
86 | 86 | { |
87 | 87 | return $proto.'://'.$name; |
88 | 88 | } |
89 | 89 | return $name; |
90 | 90 | } |
91 | 91 | |
92 | - function connect($name, $proto=false) |
|
92 | + function connect($name, $proto = false) |
|
93 | 93 | { |
94 | 94 | $connectStr = $this->getConnectString($name, $proto); |
95 | - if($this->ds !== null) |
|
95 | + if ($this->ds !== null) |
|
96 | 96 | { |
97 | 97 | ldap_close($this->ds); |
98 | 98 | } |
99 | 99 | $this->connect = $connectStr; |
100 | 100 | $this->ds = ldap_connect($this->connect); |
101 | - if($this->ds === false) |
|
101 | + if ($this->ds === false) |
|
102 | 102 | { |
103 | 103 | $this->ds = null; |
104 | 104 | return false; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | function disconnect() |
111 | 111 | { |
112 | - if($this->ds !== null) |
|
112 | + if ($this->ds !== null) |
|
113 | 113 | { |
114 | 114 | ldap_close($this->ds); |
115 | 115 | $this->ds = null; |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | $this->connect = false; |
118 | 118 | } |
119 | 119 | |
120 | - function bind($cn=null, $password=null) |
|
120 | + function bind($cn = null, $password = null) |
|
121 | 121 | { |
122 | 122 | $res = false; |
123 | - if($this->ds === null) |
|
123 | + if ($this->ds === null) |
|
124 | 124 | { |
125 | 125 | throw new \Exception('Not connected'); |
126 | 126 | } |
127 | 127 | $this->binder = $cn; |
128 | - if($cn === null || $password === null) |
|
128 | + if ($cn === null || $password === null) |
|
129 | 129 | { |
130 | 130 | return @ldap_bind($this->ds); |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $res = ldap_bind($this->ds, $cn, $password); |
135 | 135 | } |
136 | - catch(\Exception $ex) |
|
136 | + catch (\Exception $ex) |
|
137 | 137 | { |
138 | 138 | $this->ds = ldap_connect($this->connect); |
139 | 139 | $res = @ldap_bind($this->ds, $cn, $password); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | function unbind() |
145 | 145 | { |
146 | - if($this->ds === null) |
|
146 | + if ($this->ds === null) |
|
147 | 147 | { |
148 | 148 | return true; |
149 | 149 | } |
@@ -158,27 +158,27 @@ discard block |
||
158 | 158 | private function _fix_object($object, &$delete = false) |
159 | 159 | { |
160 | 160 | $entity = $object; |
161 | - if(!is_array($object)) |
|
161 | + if (!is_array($object)) |
|
162 | 162 | { |
163 | 163 | $entity = $object->to_array(); |
164 | 164 | } |
165 | 165 | unset($entity['dn']); |
166 | 166 | $keys = array_keys($entity); |
167 | - for($i = 0; $i < count($keys); $i++) |
|
167 | + for ($i = 0; $i < count($keys); $i++) |
|
168 | 168 | { |
169 | - if(is_array($entity[$keys[$i]])) |
|
169 | + if (is_array($entity[$keys[$i]])) |
|
170 | 170 | { |
171 | 171 | $array = $entity[$keys[$i]]; |
172 | 172 | unset($entity[$keys[$i]]); |
173 | - for($j = 0; $j < count($array); $j++) |
|
173 | + for ($j = 0; $j < count($array); $j++) |
|
174 | 174 | { |
175 | - if(isset($array[$j])) |
|
175 | + if (isset($array[$j])) |
|
176 | 176 | { |
177 | 177 | $entity[$keys[$i]][$j] = $array[$j]; |
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
181 | - else if($delete !== false && $entity[$keys[$i]] === null) |
|
181 | + else if ($delete !== false && $entity[$keys[$i]] === null) |
|
182 | 182 | { |
183 | 183 | $delete[$keys[$i]] = array(); |
184 | 184 | unset($entity[$keys[$i]]); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $dn = ldap_escape($object['dn'], true); |
193 | 193 | $entity = $this->_fix_object($object); |
194 | 194 | $ret = ldap_add($this->ds, $dn, $entity); |
195 | - if($ret === false) |
|
195 | + if ($ret === false) |
|
196 | 196 | { |
197 | 197 | throw new \Exception('Failed to create object with dn='.$dn); |
198 | 198 | } |
@@ -201,34 +201,34 @@ discard block |
||
201 | 201 | |
202 | 202 | private function filterToString($filter) |
203 | 203 | { |
204 | - if($filter === false) |
|
204 | + if ($filter === false) |
|
205 | 205 | { |
206 | 206 | return '(objectclass=*)'; |
207 | 207 | } |
208 | - if(is_string($filter)) |
|
208 | + if (is_string($filter)) |
|
209 | 209 | { |
210 | 210 | return $filter; |
211 | 211 | } |
212 | 212 | return $filter->to_ldap_string(); |
213 | 213 | } |
214 | 214 | |
215 | - function read($baseDN, $filter=false, $single=false, $attributes=false) |
|
215 | + function read($baseDN, $filter = false, $single = false, $attributes = false) |
|
216 | 216 | { |
217 | 217 | $filterStr = $this->filterToString($filter); |
218 | - if($this->ds === null) |
|
218 | + if ($this->ds === null) |
|
219 | 219 | { |
220 | 220 | throw new \Exception('Not connected'); |
221 | 221 | } |
222 | 222 | $sr = false; |
223 | 223 | try |
224 | 224 | { |
225 | - if($single === true) |
|
225 | + if ($single === true) |
|
226 | 226 | { |
227 | 227 | $sr = @ldap_read($this->ds, $baseDN, $filterStr); |
228 | 228 | } |
229 | 229 | else |
230 | 230 | { |
231 | - if($attributes !== false) |
|
231 | + if ($attributes !== false) |
|
232 | 232 | { |
233 | 233 | $sr = @ldap_list($this->ds, $baseDN, $filterStr, $attributes); |
234 | 234 | } |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | } |
239 | 239 | } |
240 | 240 | } |
241 | - catch(\Exception $e) |
|
241 | + catch (\Exception $e) |
|
242 | 242 | { |
243 | 243 | throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e); |
244 | 244 | } |
245 | - if($sr === false) |
|
245 | + if ($sr === false) |
|
246 | 246 | { |
247 | 247 | return false; |
248 | 248 | } |
249 | 249 | $res = ldap_get_entries($this->ds, $sr); |
250 | - if(is_array($res)) |
|
250 | + if (is_array($res)) |
|
251 | 251 | { |
252 | 252 | $ldap = $res; |
253 | 253 | $res = array(); |
254 | - for($i = 0; $i < $ldap['count']; $i++) |
|
254 | + for ($i = 0; $i < $ldap['count']; $i++) |
|
255 | 255 | { |
256 | 256 | array_push($res, new LDAPObject($ldap[$i], $this)); |
257 | 257 | } |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | return $res; |
260 | 260 | } |
261 | 261 | |
262 | - function count($baseDN, $filter=false) |
|
262 | + function count($baseDN, $filter = false) |
|
263 | 263 | { |
264 | 264 | $filterStr = $this->filterToString($filter); |
265 | - if($this->ds === null) |
|
265 | + if ($this->ds === null) |
|
266 | 266 | { |
267 | 267 | throw new \Exception('Not connected'); |
268 | 268 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | { |
271 | 271 | $sr = ldap_list($this->ds, $baseDN, $filterStr, array('dn')); |
272 | 272 | } |
273 | - catch(\Exception $e) |
|
273 | + catch (\Exception $e) |
|
274 | 274 | { |
275 | 275 | throw new \Exception($e->getMessage().' '.$filterStr, $e->getCode(), $e); |
276 | 276 | } |
277 | - if($sr === false) |
|
277 | + if ($sr === false) |
|
278 | 278 | { |
279 | 279 | return false; |
280 | 280 | } |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | $dn = ldap_escape($object['dn'], true); |
287 | 287 | $delete = array(); |
288 | 288 | $entity = $this->_fix_object($object, $delete); |
289 | - if(!empty($entity)) |
|
289 | + if (!empty($entity)) |
|
290 | 290 | { |
291 | 291 | $ret = @ldap_mod_replace($this->ds, $dn, $entity); |
292 | - if($ret === false) |
|
292 | + if ($ret === false) |
|
293 | 293 | { |
294 | 294 | throw new \Exception('Failed to update object with dn='.$dn.'('.ldap_errno($this->ds).':'.ldap_error($this->ds).') '.print_r($entity, true)); |
295 | 295 | } |
296 | 296 | } |
297 | - if(!empty($delete)) |
|
297 | + if (!empty($delete)) |
|
298 | 298 | { |
299 | 299 | $ret = @ldap_mod_del($this->ds, $dn, $delete); |
300 | 300 | } |