@@ -659,8 +659,8 @@ discard block |
||
659 | 659 | * @return void |
660 | 660 | */ |
661 | 661 | public function fetch_available_auth_method_types () { |
662 | - return array("AD", "LDAP", "NetIQ", "Radius", "SAML2"); |
|
663 | - } |
|
662 | + return array("AD", "LDAP", "NetIQ", "Radius", "SAML2"); |
|
663 | + } |
|
664 | 664 | |
665 | 665 | |
666 | 666 | |
@@ -811,9 +811,9 @@ discard block |
||
811 | 811 | |
812 | 812 | |
813 | 813 | /** |
814 | - * @authentication functions |
|
815 | - * ------------------------------- |
|
816 | - */ |
|
814 | + * @authentication functions |
|
815 | + * ------------------------------- |
|
816 | + */ |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * Main function for authenticating users |
@@ -229,13 +229,13 @@ discard block |
||
229 | 229 | // not for api |
230 | 230 | if ($this->api !== true) { |
231 | 231 | //set session name |
232 | - $this->set_session_name(); |
|
232 | + $this->set_session_name (); |
|
233 | 233 | //set debugging |
234 | - $this->set_debugging(); |
|
234 | + $this->set_debugging (); |
|
235 | 235 | //register session |
236 | - session_name($this->sessname); |
|
237 | - if(@$_SESSION===NULL) { |
|
238 | - session_start(); |
|
236 | + session_name ($this->sessname); |
|
237 | + if (@$_SESSION === NULL) { |
|
238 | + session_start (); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return void |
248 | 248 | */ |
249 | 249 | public function destroy_session () { |
250 | - session_destroy(); |
|
250 | + session_destroy (); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | private function set_session_name () { |
260 | - include( dirname(__FILE__).'/../../config.php' ); |
|
261 | - $this->sessname = strlen(@$phpsessname)>0 ? $phpsessname : "phpipam"; |
|
260 | + include(dirname (__FILE__).'/../../config.php'); |
|
261 | + $this->sessname = strlen (@$phpsessname) > 0 ? $phpsessname : "phpipam"; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if ($this->api !== true) { |
273 | 273 | $_SESSION['ipamusername'] = $this->user->username; |
274 | 274 | $_SESSION['ipamlanguage'] = $this->fetch_lang_details (); |
275 | - $_SESSION['lastactive'] = time(); |
|
275 | + $_SESSION['lastactive'] = time (); |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function is_authenticated () { |
301 | 301 | # if checked for subpages first check if $user is array |
302 | - if(!is_array($this->user)) { |
|
303 | - if( isset( $_SESSION['ipamusername'] ) && strlen( @$_SESSION['ipamusername'] )>0 ) { |
|
302 | + if (!is_array ($this->user)) { |
|
303 | + if (isset($_SESSION['ipamusername']) && strlen (@$_SESSION['ipamusername']) > 0) { |
|
304 | 304 | # save username |
305 | 305 | $this->username = $_SESSION['ipamusername']; |
306 | 306 | # check for timeout |
307 | - if($this->timeout == true) { |
|
307 | + if ($this->timeout == true) { |
|
308 | 308 | $this->authenticated = false; |
309 | 309 | } |
310 | 310 | else { |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | $this->fetch_user_details ($this->username); |
313 | 313 | |
314 | 314 | $this->authenticated = true; |
315 | - $this->reset_inactivity_time(); |
|
315 | + $this->reset_inactivity_time (); |
|
316 | 316 | $this->update_activity_time (); |
317 | 317 | # bind language |
318 | - $this->set_ui_language(); |
|
318 | + $this->set_ui_language (); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | else { |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | * @return void |
336 | 336 | */ |
337 | 337 | public function is_admin ($die = true) { |
338 | - if($this->isadmin) { return true; } |
|
338 | + if ($this->isadmin) { return true; } |
|
339 | 339 | else { |
340 | - if($die) { $this->Result->show("danger", _('Administrator level privileges required'), true); } |
|
341 | - else { return false; } |
|
340 | + if ($die) { $this->Result->show ("danger", _ ('Administrator level privileges required'), true); } |
|
341 | + else { return false; } |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
@@ -351,18 +351,18 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function check_user_session ($redirect = true) { |
353 | 353 | # not authenticated |
354 | - if($this->authenticated===false) { |
|
354 | + if ($this->authenticated === false) { |
|
355 | 355 | # set url |
356 | - $url = $this->createURL(); |
|
356 | + $url = $this->createURL (); |
|
357 | 357 | |
358 | 358 | # error print for AJAX |
359 | - if(@$_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest") { |
|
359 | + if (@$_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest") { |
|
360 | 360 | # for AJAX always check origin |
361 | 361 | $this->check_referrer (); |
362 | 362 | # kill session |
363 | 363 | $this->destroy_session (); |
364 | 364 | # error |
365 | - $this->Result->show("danger", _('Please login first')."!<hr><a class='btn btn-sm btn-default' href='".$url.create_link ("login")."'>"._('Login')."</a>", true, true); |
|
365 | + $this->Result->show ("danger", _ ('Please login first')."!<hr><a class='btn btn-sm btn-default' href='".$url.create_link ("login")."'>"._ ('Login')."</a>", true, true); |
|
366 | 366 | die(); |
367 | 367 | } |
368 | 368 | # timeout |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $this->set_redirect_cookie (); |
372 | 372 | # redirect |
373 | 373 | if ($redirect) |
374 | - header("Location:".$url.create_link ("login","timeout")); |
|
374 | + header ("Location:".$url.create_link ("login", "timeout")); |
|
375 | 375 | die(); |
376 | 376 | } |
377 | 377 | else { |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $this->set_redirect_cookie (); |
380 | 380 | # redirect |
381 | 381 | if ($redirect) |
382 | - header("Location:".$url.create_link ("login")); |
|
382 | + header ("Location:".$url.create_link ("login")); |
|
383 | 383 | die(); |
384 | 384 | } |
385 | 385 | } |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | */ |
398 | 398 | private function check_timeout () { |
399 | 399 | //session set |
400 | - if(isset($_SESSION['lastactive'])) { |
|
401 | - if( strlen($this->settings->inactivityTimeout)>0 && (time()-@$_SESSION['lastactive']) > $this->settings->inactivityTimeout) { |
|
400 | + if (isset($_SESSION['lastactive'])) { |
|
401 | + if (strlen ($this->settings->inactivityTimeout) > 0 && (time () - @$_SESSION['lastactive']) > $this->settings->inactivityTimeout) { |
|
402 | 402 | $this->timeout = true; |
403 | 403 | unset($_SESSION['lastactive']); |
404 | 404 | } |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * @return void |
413 | 413 | */ |
414 | 414 | private function reset_inactivity_time () { |
415 | - if($this->timeout!==true) { |
|
416 | - $_SESSION['lastactive'] = time(); |
|
415 | + if ($this->timeout !== true) { |
|
416 | + $_SESSION['lastactive'] = time (); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | */ |
426 | 426 | private function set_redirect_cookie () { |
427 | 427 | # save current redirect vaule |
428 | - if($_SERVER['SCRIPT_URL']!="/login/" && $_SERVER['SCRIPT_URL']!="logout" && $_SERVER['SCRIPT_URL']!="?page=login" && $_SERVER['SCRIPT_URL']!="?page=logout" && $_SERVER['SCRIPT_URL']!="/" && $_SERVER['SCRIPT_URL']!="%2f"); |
|
429 | - setcookie("phpipamredirect", $_SERVER['REQUEST_URI'], time()+10, "/", null, null, true); |
|
428 | + if ($_SERVER['SCRIPT_URL'] != "/login/" && $_SERVER['SCRIPT_URL'] != "logout" && $_SERVER['SCRIPT_URL'] != "?page=login" && $_SERVER['SCRIPT_URL'] != "?page=logout" && $_SERVER['SCRIPT_URL'] != "/" && $_SERVER['SCRIPT_URL'] != "%2f"); |
|
429 | + setcookie ("phpipamredirect", $_SERVER['REQUEST_URI'], time () + 10, "/", null, null, true); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | * @return void |
437 | 437 | */ |
438 | 438 | private function set_ui_language () { |
439 | - if(strlen($_SESSION['ipamlanguage'])>0) { |
|
440 | - putenv("LC_ALL=$_SESSION[ipamlanguage]"); |
|
441 | - setlocale(LC_ALL, $_SESSION['ipamlanguage']); // set language |
|
442 | - bindtextdomain("phpipam", "./functions/locale"); // Specify location of translation tables |
|
443 | - textdomain("phpipam"); // Choose domain |
|
439 | + if (strlen ($_SESSION['ipamlanguage']) > 0) { |
|
440 | + putenv ("LC_ALL=$_SESSION[ipamlanguage]"); |
|
441 | + setlocale (LC_ALL, $_SESSION['ipamlanguage']); // set language |
|
442 | + bindtextdomain ("phpipam", "./functions/locale"); // Specify location of translation tables |
|
443 | + textdomain ("phpipam"); // Choose domain |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | * @return void |
475 | 475 | */ |
476 | 476 | private function csrf_validate_action ($action) { |
477 | - if ($action=="create" || $action=="validate") { return true; } |
|
478 | - else { $this->Result->show("danger", "Invalid CSRF cookie action", true); } |
|
477 | + if ($action == "create" || $action == "validate") { return true; } |
|
478 | + else { $this->Result->show ("danger", "Invalid CSRF cookie action", true); } |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -487,9 +487,9 @@ discard block |
||
487 | 487 | */ |
488 | 488 | private function csrf_cookie_create ($index) { |
489 | 489 | // set cookie suffix |
490 | - $name = is_null($index) ? "csrf_cookie" : "csrf_cookie_".$index; |
|
490 | + $name = is_null ($index) ? "csrf_cookie" : "csrf_cookie_".$index; |
|
491 | 491 | // save cookie |
492 | - $_SESSION[$name] = md5(uniqid(mt_rand(), true)); |
|
492 | + $_SESSION[$name] = md5 (uniqid (mt_rand (), true)); |
|
493 | 493 | // return |
494 | 494 | return $_SESSION[$name]; |
495 | 495 | } |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function csrf_cookie_validate ($index, $value) { |
505 | 505 | // set cookie suffix |
506 | - $name = is_null($index) ? "csrf_cookie" : "csrf_cookie_".$index; |
|
506 | + $name = is_null ($index) ? "csrf_cookie" : "csrf_cookie_".$index; |
|
507 | 507 | // check and return |
508 | 508 | return $_SESSION[$name] == $value ? true : false; |
509 | 509 | } |
@@ -528,32 +528,32 @@ discard block |
||
528 | 528 | */ |
529 | 529 | public function migrate_domain_settings () { |
530 | 530 | # if not already migrated migrate settings! |
531 | - if($this->settings->authmigrated==0) { |
|
531 | + if ($this->settings->authmigrated == 0) { |
|
532 | 532 | # only if AD used |
533 | - if($this->settings->domainAuth!=0) { |
|
533 | + if ($this->settings->domainAuth != 0) { |
|
534 | 534 | # fetch AD settings |
535 | 535 | $err = false; |
536 | - try { $ad = $this->Database->getObject("settingsDomain",1); } |
|
536 | + try { $ad = $this->Database->getObject ("settingsDomain", 1); } |
|
537 | 537 | catch (Exception $e) { $err = true; } |
538 | 538 | |
539 | - if($err === false) { |
|
539 | + if ($err === false) { |
|
540 | 540 | # remove editDate |
541 | 541 | unset($ad->editDate); |
542 | 542 | # save to json array |
543 | - $ad = json_encode($ad); |
|
543 | + $ad = json_encode ($ad); |
|
544 | 544 | # update usersAuthMethod |
545 | - $type = $this->settings->domainAuth==1 ? "AD" : "LDAP"; |
|
545 | + $type = $this->settings->domainAuth == 1 ? "AD" : "LDAP"; |
|
546 | 546 | # update |
547 | 547 | try { |
548 | - $this->Database->insertObject("usersAuthMethod", array("type"=>$type, "params"=>$ad, "description"=>$type." authentication", "protected"=>"No")); |
|
548 | + $this->Database->insertObject ("usersAuthMethod", array ("type"=>$type, "params"=>$ad, "description"=>$type." authentication", "protected"=>"No")); |
|
549 | 549 | } |
550 | 550 | catch (Exception $e) { |
551 | 551 | $err = true; |
552 | 552 | } |
553 | 553 | # set migrated flag |
554 | - if($err === false) { |
|
554 | + if ($err === false) { |
|
555 | 555 | try { |
556 | - $this->Database->updateObject("settings", array("id"=>1,"authmigrated"=>1), 'id'); |
|
556 | + $this->Database->updateObject ("settings", array ("id"=>1, "authmigrated"=>1), 'id'); |
|
557 | 557 | } |
558 | 558 | catch (Exception $e) { |
559 | 559 | // no response on failure |
@@ -573,17 +573,17 @@ discard block |
||
573 | 573 | public function migrate_ldap_settings () { |
574 | 574 | |
575 | 575 | # fetch LDAP settings |
576 | - $ldaps = $this->Database->getObjectsQuery("select * from usersAuthMethod where type = 'LDAP'"); |
|
576 | + $ldaps = $this->Database->getObjectsQuery ("select * from usersAuthMethod where type = 'LDAP'"); |
|
577 | 577 | |
578 | 578 | foreach ($ldaps as $ldapobj) { |
579 | 579 | |
580 | - $ldap = json_decode($ldapobj->params); |
|
580 | + $ldap = json_decode ($ldapobj->params); |
|
581 | 581 | |
582 | - if (!property_exists($ldap, 'ldap_security')) { |
|
582 | + if (!property_exists ($ldap, 'ldap_security')) { |
|
583 | 583 | $ldap->ldap_security = 'none'; |
584 | 584 | } |
585 | 585 | |
586 | - if (property_exists($ldap, 'use_ssl')) { |
|
586 | + if (property_exists ($ldap, 'use_ssl')) { |
|
587 | 587 | |
588 | 588 | if ($ldap->use_ssl == '1') { |
589 | 589 | $ldap->ldap_security = 'ssl'; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | |
593 | 593 | } |
594 | 594 | |
595 | - if (property_exists($ldap, 'use_tls')) { |
|
595 | + if (property_exists ($ldap, 'use_tls')) { |
|
596 | 596 | |
597 | 597 | if ($ldap->use_tls == '1') { |
598 | 598 | $ldap->ldap_security = 'tls'; |
@@ -600,13 +600,13 @@ discard block |
||
600 | 600 | unset($ldap->use_tls); |
601 | 601 | } |
602 | 602 | |
603 | - if (!property_exists($ldap, 'uid_attr')) { |
|
603 | + if (!property_exists ($ldap, 'uid_attr')) { |
|
604 | 604 | $ldap->uid_attr = 'uid'; |
605 | 605 | } |
606 | 606 | |
607 | - $ldapobj->params = json_encode($ldap); |
|
607 | + $ldapobj->params = json_encode ($ldap); |
|
608 | 608 | |
609 | - $this->Database->updateObject("usersAuthMethod", $ldapobj); |
|
609 | + $this->Database->updateObject ("usersAuthMethod", $ldapobj); |
|
610 | 610 | |
611 | 611 | } |
612 | 612 | } |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | * @return void |
631 | 631 | */ |
632 | 632 | private function check_referrer () { |
633 | - if ( ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") && ($_SERVER['HTTP_ORIGIN'] != $_SERVER['HTTP_HOST'] ) ) { |
|
633 | + if (($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") && ($_SERVER['HTTP_ORIGIN'] != $_SERVER['HTTP_HOST'])) { |
|
634 | 634 | # write log and die |
635 | - $this->Log->write ("referrer_check", _('Page not referred properly'), 0 ); |
|
636 | - $this->Result->show ("danger", _('Page not referred properly'), true); |
|
635 | + $this->Log->write ("referrer_check", _ ('Page not referred properly'), 0); |
|
636 | + $this->Result->show ("danger", _ ('Page not referred properly'), true); |
|
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | * @return void |
645 | 645 | */ |
646 | 646 | public function get_default_lang () { |
647 | - try { $lang = $this->Database->findObject("lang","l_id",$this->settings->defaultLang); } |
|
648 | - catch (Exception $e) { $this->debugging ? : $this->Result->show("danger", _("Database error: ").$e->getMessage()); } |
|
647 | + try { $lang = $this->Database->findObject ("lang", "l_id", $this->settings->defaultLang); } |
|
648 | + catch (Exception $e) { $this->debugging ? : $this->Result->show ("danger", _ ("Database error: ").$e->getMessage ()); } |
|
649 | 649 | |
650 | 650 | return $lang; |
651 | 651 | } |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | * @return void |
660 | 660 | */ |
661 | 661 | public function fetch_available_auth_method_types () { |
662 | - return array("AD", "LDAP", "NetIQ", "Radius", "SAML2"); |
|
662 | + return array ("AD", "LDAP", "NetIQ", "Radius", "SAML2"); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | |
@@ -684,26 +684,26 @@ discard block |
||
684 | 684 | */ |
685 | 685 | public function fetch_favourite_subnets () { |
686 | 686 | # none |
687 | - if(strlen($this->user->favourite_subnets)==0) { |
|
687 | + if (strlen ($this->user->favourite_subnets) == 0) { |
|
688 | 688 | return false; |
689 | 689 | } |
690 | 690 | # ok |
691 | 691 | else { |
692 | 692 | # store to array |
693 | - $subnets = explode(";", $this->user->favourite_subnets); |
|
694 | - $subnets = array_filter($subnets); |
|
693 | + $subnets = explode (";", $this->user->favourite_subnets); |
|
694 | + $subnets = array_filter ($subnets); |
|
695 | 695 | |
696 | - if(sizeof($subnets)>0) { |
|
696 | + if (sizeof ($subnets) > 0) { |
|
697 | 697 | // init |
698 | - $fsubnets = array(); |
|
698 | + $fsubnets = array (); |
|
699 | 699 | # fetch details for each subnet |
700 | - foreach($subnets as $id) { |
|
700 | + foreach ($subnets as $id) { |
|
701 | 701 | $query = "select `su`.`id` as `subnetId`,`se`.`id` as `sectionId`, `subnet`, `mask`,`isFull`,`su`.`description`,`se`.`description` as `section`, `vlanId`, `isFolder` |
702 | 702 | from `subnets` as `su`, `sections` as `se` where `su`.`id` = ? and `su`.`sectionId` = `se`.`id` limit 1;"; |
703 | 703 | |
704 | - try { $fsubnet = $this->Database->getObjectQuery($query, array($id)); } |
|
704 | + try { $fsubnet = $this->Database->getObjectQuery ($query, array ($id)); } |
|
705 | 705 | catch (Exception $e) { |
706 | - $this->Result->show("danger", _("Error: ").$e->getMessage()); |
|
706 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage ()); |
|
707 | 707 | return false; |
708 | 708 | } |
709 | 709 | |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | * @param mixed $subnetId |
726 | 726 | * @return void |
727 | 727 | */ |
728 | - public function edit_favourite($action, $subnetId) { |
|
728 | + public function edit_favourite ($action, $subnetId) { |
|
729 | 729 | # execute |
730 | - if($action=="remove") { return $this->remove_favourite ($subnetId); } |
|
731 | - elseif($action=="add") { return $this->add_favourite ($subnetId); } |
|
732 | - else { return false; } |
|
730 | + if ($action == "remove") { return $this->remove_favourite ($subnetId); } |
|
731 | + elseif ($action == "add") { return $this->add_favourite ($subnetId); } |
|
732 | + else { return false; } |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | */ |
742 | 742 | private function remove_favourite ($subnetId) { |
743 | 743 | # set old favourite subnets |
744 | - $old_favourites = explode(";", $this->user->favourite_subnets); |
|
744 | + $old_favourites = explode (";", $this->user->favourite_subnets); |
|
745 | 745 | # set new |
746 | - $new_favourites = implode(";", array_diff($old_favourites, array($subnetId))); |
|
746 | + $new_favourites = implode (";", array_diff ($old_favourites, array ($subnetId))); |
|
747 | 747 | # update |
748 | - try { $this->Database->updateObject("users", array("favourite_subnets"=>$new_favourites, "id"=>$this->user->id), "id"); } |
|
748 | + try { $this->Database->updateObject ("users", array ("favourite_subnets"=>$new_favourites, "id"=>$this->user->id), "id"); } |
|
749 | 749 | catch (Exception $e) { |
750 | 750 | return false; |
751 | 751 | } |
@@ -761,12 +761,12 @@ discard block |
||
761 | 761 | */ |
762 | 762 | private function add_favourite ($subnetId) { |
763 | 763 | # set old favourite subnets |
764 | - $old_favourites = explode(";", $this->user->favourite_subnets); |
|
765 | - $old_favourites = is_array($old_favourites) ? $old_favourites : array(); |
|
764 | + $old_favourites = explode (";", $this->user->favourite_subnets); |
|
765 | + $old_favourites = is_array ($old_favourites) ? $old_favourites : array (); |
|
766 | 766 | # set new |
767 | - $new_favourites = implode(";",array_merge(array($subnetId), $old_favourites)); |
|
767 | + $new_favourites = implode (";", array_merge (array ($subnetId), $old_favourites)); |
|
768 | 768 | # update |
769 | - try { $this->Database->updateObject("users", array("favourite_subnets"=>$new_favourites, "id"=>$this->user->id), "id"); } |
|
769 | + try { $this->Database->updateObject ("users", array ("favourite_subnets"=>$new_favourites, "id"=>$this->user->id), "id"); } |
|
770 | 770 | catch (Exception $e) { |
771 | 771 | return false; |
772 | 772 | } |
@@ -783,10 +783,10 @@ discard block |
||
783 | 783 | public function is_subnet_favourite ($subnetId) { |
784 | 784 | $this->fetch_favourite_subnets (); |
785 | 785 | # check if in array |
786 | - $subnets = explode(";", $this->user->favourite_subnets); |
|
787 | - $subnets = array_filter($subnets); |
|
786 | + $subnets = explode (";", $this->user->favourite_subnets); |
|
787 | + $subnets = array_filter ($subnets); |
|
788 | 788 | # result |
789 | - return in_array($subnetId, $subnets) ? true : false; |
|
789 | + return in_array ($subnetId, $subnets) ? true : false; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -832,15 +832,15 @@ discard block |
||
832 | 832 | # first we need to check if username exists |
833 | 833 | $this->fetch_user_details ($username); |
834 | 834 | # set method type if set, otherwise presume local auth |
835 | - $this->authmethodid = strlen(@$this->user->authMethod)>0 ? $this->user->authMethod : 1; |
|
835 | + $this->authmethodid = strlen (@$this->user->authMethod) > 0 ? $this->user->authMethod : 1; |
|
836 | 836 | |
837 | 837 | # get authentication method details |
838 | 838 | $this->get_auth_method_type (); |
839 | 839 | |
840 | 840 | # authenticate based on name of auth method |
841 | - if(!method_exists($this, $this->authmethodtype)) { |
|
842 | - $this->Log->write ("User login", _('Error: Invalid authentication method'), 2 ); |
|
843 | - $this->Result->show("danger", _("Error: Invalid authentication method"), true); |
|
841 | + if (!method_exists ($this, $this->authmethodtype)) { |
|
842 | + $this->Log->write ("User login", _ ('Error: Invalid authentication method'), 2); |
|
843 | + $this->Result->show ("danger", _ ("Error: Invalid authentication method"), true); |
|
844 | 844 | } |
845 | 845 | else { |
846 | 846 | # set method name variable |
@@ -859,18 +859,18 @@ discard block |
||
859 | 859 | */ |
860 | 860 | private function fetch_user_details ($username) { |
861 | 861 | # only if not already active |
862 | - if(!is_object($this->user)) { |
|
863 | - try { $user = $this->Database->findObject("users", "username", $username); } |
|
864 | - catch (Exception $e) { $this->Result->show("danger", _("Error: ").$e->getMessage(), true);} |
|
862 | + if (!is_object ($this->user)) { |
|
863 | + try { $user = $this->Database->findObject ("users", "username", $username); } |
|
864 | + catch (Exception $e) { $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), true); } |
|
865 | 865 | |
866 | 866 | # if not result return false |
867 | 867 | $usert = (array) $user; |
868 | 868 | |
869 | 869 | # admin? |
870 | - if($user->role == "Administrator") { $this->isadmin = true; } |
|
870 | + if ($user->role == "Administrator") { $this->isadmin = true; } |
|
871 | 871 | |
872 | - if(sizeof($usert)==0) { $this->block_ip (); $this->Log->write ("User login", _('Invalid username'), 2, $username ); $this->Result->show("danger", _("Invalid username or password"), true);} |
|
873 | - else { $this->user = $user; } |
|
872 | + if (sizeof ($usert) == 0) { $this->block_ip (); $this->Log->write ("User login", _ ('Invalid username'), 2, $username); $this->Result->show ("danger", _ ("Invalid username or password"), true); } |
|
873 | + else { $this->user = $user; } |
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
@@ -881,9 +881,9 @@ discard block |
||
881 | 881 | * @return void |
882 | 882 | */ |
883 | 883 | public function fetch_langs () { |
884 | - try { $langs = $this->Database->getObjects("lang", "l_id"); } |
|
884 | + try { $langs = $this->Database->getObjects ("lang", "l_id"); } |
|
885 | 885 | catch (Exception $e) { |
886 | - $this->Result->show("danger", _("Error: ").$e->getMessage()); |
|
886 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage ()); |
|
887 | 887 | return false; |
888 | 888 | } |
889 | 889 | # return |
@@ -898,9 +898,9 @@ discard block |
||
898 | 898 | */ |
899 | 899 | private function fetch_lang_details () { |
900 | 900 | // fetch from db |
901 | - try { $lang = $this->Database->findObject("lang", "l_id", $this->user->lang); } |
|
901 | + try { $lang = $this->Database->findObject ("lang", "l_id", $this->user->lang); } |
|
902 | 902 | catch (Exception $e) { |
903 | - $this->Result->show("danger", _("Error: ").$e->getMessage(), true); |
|
903 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), true); |
|
904 | 904 | return false; |
905 | 905 | } |
906 | 906 | // return code |
@@ -915,16 +915,16 @@ discard block |
||
915 | 915 | */ |
916 | 916 | private function get_auth_method_type () { |
917 | 917 | # for older versions - only local is available! |
918 | - if($this->settings->version=="1.1") { |
|
918 | + if ($this->settings->version == "1.1") { |
|
919 | 919 | $this->authmethodtype = "auth_local"; |
920 | 920 | } |
921 | 921 | else { |
922 | - try { $method = $this->Database->getObject("usersAuthMethod", $this->authmethodid); } |
|
922 | + try { $method = $this->Database->getObject ("usersAuthMethod", $this->authmethodid); } |
|
923 | 923 | catch (Exception $e) { |
924 | - $this->Result->show("danger", _("Error: ").$e->getMessage(), true); |
|
924 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), true); |
|
925 | 925 | } |
926 | 926 | # save method name if existing |
927 | - if($method!==false) { |
|
927 | + if ($method !== false) { |
|
928 | 928 | $this->authmethodtype = "auth_".$method->type; |
929 | 929 | $this->authmethodparams = $method->params; |
930 | 930 | } |
@@ -942,12 +942,12 @@ discard block |
||
942 | 942 | */ |
943 | 943 | private function auth_local ($username, $password) { |
944 | 944 | # auth ok |
945 | - if($this->user->password == crypt($password, $this->user->password)) { |
|
945 | + if ($this->user->password == crypt ($password, $this->user->password)) { |
|
946 | 946 | # save to session |
947 | 947 | $this->write_session_parameters (); |
948 | 948 | |
949 | - $this->Result->show("success", _("Login successful")); |
|
950 | - $this->Log->write( "User login", "User ".$this->user->real_name." logged in", 0, $username ); |
|
949 | + $this->Result->show ("success", _ ("Login successful")); |
|
950 | + $this->Log->write ("User login", "User ".$this->user->real_name." logged in", 0, $username); |
|
951 | 951 | |
952 | 952 | # write last logintime |
953 | 953 | $this->update_login_time (); |
@@ -960,11 +960,11 @@ discard block |
||
960 | 960 | # add blocked count |
961 | 961 | $this->block_ip (); |
962 | 962 | |
963 | - $this->Log->write( "User login", "Invalid username or password", 2, $username ); |
|
963 | + $this->Log->write ("User login", "Invalid username or password", 2, $username); |
|
964 | 964 | |
965 | 965 | # apache |
966 | - if (!empty($_SERVER['PHP_AUTH_USER'])) { $this->show_http_login(); } |
|
967 | - else { $this->Result->show("danger", _("Invalid username or password"), true); } |
|
966 | + if (!empty($_SERVER['PHP_AUTH_USER'])) { $this->show_http_login (); } |
|
967 | + else { $this->Result->show ("danger", _ ("Invalid username or password"), true); } |
|
968 | 968 | } |
969 | 969 | } |
970 | 970 | |
@@ -981,8 +981,8 @@ discard block |
||
981 | 981 | # save to session |
982 | 982 | $this->write_session_parameters (); |
983 | 983 | |
984 | - $this->Result->show("success", _("Login successful")); |
|
985 | - $this->Log->write( "User login", "User ".$this->user->real_name." logged in", 0, $username ); |
|
984 | + $this->Result->show ("success", _ ("Login successful")); |
|
985 | + $this->Log->write ("User login", "User ".$this->user->real_name." logged in", 0, $username); |
|
986 | 986 | |
987 | 987 | # write last logintime |
988 | 988 | $this->update_login_time (); |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * @return void |
999 | 999 | */ |
1000 | 1000 | private function show_http_login () { |
1001 | - header('WWW-Authenticate: Basic realm="phpIPAM authentication"'); |
|
1002 | - header('HTTP/1.0 401 Unauthorized'); |
|
1001 | + header ('WWW-Authenticate: Basic realm="phpIPAM authentication"'); |
|
1002 | + header ('HTTP/1.0 401 Unauthorized'); |
|
1003 | 1003 | echo 'Authentication failed'; |
1004 | 1004 | exit; |
1005 | 1005 | } |
@@ -1016,13 +1016,13 @@ discard block |
||
1016 | 1016 | private function directory_connect ($authparams) { |
1017 | 1017 | |
1018 | 1018 | # adLDAP script |
1019 | - require(dirname(__FILE__) . "/../adLDAP/src/adLDAP.php"); |
|
1019 | + require(dirname (__FILE__)."/../adLDAP/src/adLDAP.php"); |
|
1020 | 1020 | |
1021 | - $dirparams = Array(); |
|
1021 | + $dirparams = Array (); |
|
1022 | 1022 | $dirparams['base_dn'] = @$authparams['base_dn']; |
1023 | 1023 | $dirparams['ad_port'] = @$authparams['ad_port']; |
1024 | 1024 | $dirparams['account_suffix'] = @$authparams['account_suffix']; |
1025 | - $dirparams['domain_controllers'] = explode(";", str_replace(" ", "", $authparams['domain_controllers'])); |
|
1025 | + $dirparams['domain_controllers'] = explode (";", str_replace (" ", "", $authparams['domain_controllers'])); |
|
1026 | 1026 | |
1027 | 1027 | // set ssl and tls separate for ldap and AD |
1028 | 1028 | if ($this->ldap) { |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | // Support the pre-1.2 auth settings as well as the current version |
1034 | 1034 | // TODO: remove legacy support at some point |
1035 | - if ($authparams['ldap_security'] == 'tls' || $authparams['use_tls'] == 1) { $dirparams['use_tls'] = true; } |
|
1036 | - elseif ($authparams['ldap_security'] == 'ssl' || $authparams['use_ssl'] == 1) { $dirparams['use_ssl'] = true; } |
|
1035 | + if ($authparams['ldap_security'] == 'tls' || $authparams['use_tls'] == 1) { $dirparams['use_tls'] = true; } |
|
1036 | + elseif ($authparams['ldap_security'] == 'ssl' || $authparams['use_ssl'] == 1) { $dirparams['use_ssl'] = true; } |
|
1037 | 1037 | |
1038 | 1038 | if (isset($authparams['admin_username']) && isset($authparams['admin_password'])) { |
1039 | 1039 | $dirparams['admin_username'] = $authparams['adminUsername']; |
@@ -1048,11 +1048,11 @@ discard block |
||
1048 | 1048 | # open connection |
1049 | 1049 | try { |
1050 | 1050 | # Initialize adLDAP |
1051 | - $dirconn = new adLDAP($dirparams); |
|
1051 | + $dirconn = new adLDAP ($dirparams); |
|
1052 | 1052 | |
1053 | 1053 | } catch (adLDAPException $e) { |
1054 | - $this->Log->write("Directory connection error", "Failed to connect: " . $e->getMessage(), 2, null); |
|
1055 | - $this->Result->show("danger", _("Error: ") . $e->getMessage(), true); |
|
1054 | + $this->Log->write ("Directory connection error", "Failed to connect: ".$e->getMessage (), 2, null); |
|
1055 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), true); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | return $dirconn; |
@@ -1075,32 +1075,32 @@ discard block |
||
1075 | 1075 | // set method |
1076 | 1076 | $method = $this->ldap ? "LDAP" : "AD"; |
1077 | 1077 | // connect |
1078 | - $adldap = $this->directory_connect($authparams); |
|
1078 | + $adldap = $this->directory_connect ($authparams); |
|
1079 | 1079 | |
1080 | 1080 | # authenticate |
1081 | 1081 | try { |
1082 | - if ($adldap->authenticate($username, $password)) { |
|
1082 | + if ($adldap->authenticate ($username, $password)) { |
|
1083 | 1083 | # save to session |
1084 | - $this->write_session_parameters(); |
|
1084 | + $this->write_session_parameters (); |
|
1085 | 1085 | |
1086 | - $this->Log->write($method . " login", "User " . $this->user->real_name . " logged in via " . $method, 0, $username); |
|
1087 | - $this->Result->show("success", _($method . " Login successful")); |
|
1086 | + $this->Log->write ($method." login", "User ".$this->user->real_name." logged in via ".$method, 0, $username); |
|
1087 | + $this->Result->show ("success", _ ($method." Login successful")); |
|
1088 | 1088 | |
1089 | 1089 | # write last logintime |
1090 | - $this->update_login_time(); |
|
1090 | + $this->update_login_time (); |
|
1091 | 1091 | # remove possible blocked IP |
1092 | - $this->block_remove_entry(); |
|
1092 | + $this->block_remove_entry (); |
|
1093 | 1093 | } # wrong user/pass by default |
1094 | 1094 | else { |
1095 | 1095 | # add blocked count |
1096 | - $this->block_ip(); |
|
1097 | - $this->Log->write($method . " login", "User $username failed to authenticate against " . $method, 1, $username); |
|
1098 | - $this->Result->show("danger", _("Invalid username or password for " . $username ), true); |
|
1096 | + $this->block_ip (); |
|
1097 | + $this->Log->write ($method." login", "User $username failed to authenticate against ".$method, 1, $username); |
|
1098 | + $this->Result->show ("danger", _ ("Invalid username or password for ".$username), true); |
|
1099 | 1099 | |
1100 | 1100 | } |
1101 | 1101 | } catch (adLDAPException $e) { |
1102 | - $this->Log->write("Error", "Something went wrong during auth: " . $e->getMessage(), 2, $username); |
|
1103 | - $this->Result->show("danger", _("Error: ") . $e->getMessage(), true); |
|
1102 | + $this->Log->write ("Error", "Something went wrong during auth: ".$e->getMessage (), 2, $username); |
|
1103 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), true); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | } |
@@ -1116,9 +1116,9 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | private function auth_AD ($username, $password) { |
1118 | 1118 | // parse settings for LDAP connection and store them to array |
1119 | - $authparams = json_decode($this->authmethodparams, true); |
|
1119 | + $authparams = json_decode ($this->authmethodparams, true); |
|
1120 | 1120 | // authenticate |
1121 | - $this->directory_authenticate($authparams, $username, $password); |
|
1121 | + $this->directory_authenticate ($authparams, $username, $password); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | /** |
@@ -1132,17 +1132,17 @@ discard block |
||
1132 | 1132 | */ |
1133 | 1133 | private function auth_LDAP ($username, $password) { |
1134 | 1134 | // parse settings for LDAP connection and store them to array |
1135 | - $authparams = json_decode($this->authmethodparams, true); |
|
1136 | - $this->ldap = true; //set ldap flag |
|
1135 | + $authparams = json_decode ($this->authmethodparams, true); |
|
1136 | + $this->ldap = true; //set ldap flag |
|
1137 | 1137 | |
1138 | 1138 | // set uid |
1139 | - if (!empty($authparams['uid_attr'])) { $udn = $authparams['uid_attr'] . '=' . $username; } |
|
1140 | - else { $udn = 'uid=' . $username; } |
|
1139 | + if (!empty($authparams['uid_attr'])) { $udn = $authparams['uid_attr'].'='.$username; } |
|
1140 | + else { $udn = 'uid='.$username; } |
|
1141 | 1141 | // set DN |
1142 | - if (!empty($authparams['users_base_dn'])) { $udn = $udn . "," . $authparams['users_base_dn']; } |
|
1143 | - else { $udn = $udn . "," . $authparams['base_dn']; } |
|
1142 | + if (!empty($authparams['users_base_dn'])) { $udn = $udn.",".$authparams['users_base_dn']; } |
|
1143 | + else { $udn = $udn.",".$authparams['base_dn']; } |
|
1144 | 1144 | // authenticate |
1145 | - $this->directory_authenticate($authparams, $udn, $password); |
|
1145 | + $this->directory_authenticate ($authparams, $udn, $password); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | /** |
@@ -1168,36 +1168,36 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | private function auth_radius ($username, $password) { |
1170 | 1170 | # decode radius parameters |
1171 | - $params = json_decode($this->authmethodparams); |
|
1171 | + $params = json_decode ($this->authmethodparams); |
|
1172 | 1172 | |
1173 | 1173 | # check for socket support ! |
1174 | - if(!in_array("sockets", get_loaded_extensions())) { |
|
1175 | - $this->Log->write( "Radius login", "php Socket extension missing", 2 ); |
|
1176 | - $this->Result->show("danger", _("php Socket extension missing"), true); |
|
1174 | + if (!in_array ("sockets", get_loaded_extensions ())) { |
|
1175 | + $this->Log->write ("Radius login", "php Socket extension missing", 2); |
|
1176 | + $this->Result->show ("danger", _ ("php Socket extension missing"), true); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | # initialize radius class |
1180 | - require( dirname(__FILE__) . '/class.Radius.php' ); |
|
1180 | + require(dirname (__FILE__).'/class.Radius.php'); |
|
1181 | 1181 | $Radius = new Radius ($params->hostname, $params->secret, $params->suffix, $params->timeout, $params->port); |
1182 | 1182 | //debugging |
1183 | - $this->debugging!==true ? : $Radius->SetDebugMode(TRUE); |
|
1183 | + $this->debugging !== true ? : $Radius->SetDebugMode (TRUE); |
|
1184 | 1184 | |
1185 | 1185 | # authenticate |
1186 | - $auth = $Radius->AccessRequest($username, $password); |
|
1186 | + $auth = $Radius->AccessRequest ($username, $password); |
|
1187 | 1187 | # debug? |
1188 | - if($this->debugging) { |
|
1188 | + if ($this->debugging) { |
|
1189 | 1189 | print "<pre style='width:700px;margin:auto;margin-top:10px;'>"; |
1190 | - print(implode("<br>", $Radius->debug_text)); |
|
1190 | + print(implode ("<br>", $Radius->debug_text)); |
|
1191 | 1191 | print "</pre>"; |
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | # authenticate user |
1195 | - if($auth) { |
|
1195 | + if ($auth) { |
|
1196 | 1196 | # save to session |
1197 | 1197 | $this->write_session_parameters (); |
1198 | 1198 | |
1199 | - $this->Log->write( "Radius login", "User ".$this->user->real_name." logged in via radius", 0, $username ); |
|
1200 | - $this->Result->show("success", _("Radius login successful")); |
|
1199 | + $this->Log->write ("Radius login", "User ".$this->user->real_name." logged in via radius", 0, $username); |
|
1200 | + $this->Result->show ("success", _ ("Radius login successful")); |
|
1201 | 1201 | |
1202 | 1202 | # write last logintime |
1203 | 1203 | $this->update_login_time (); |
@@ -1207,8 +1207,8 @@ discard block |
||
1207 | 1207 | else { |
1208 | 1208 | # add blocked count |
1209 | 1209 | $this->block_ip (); |
1210 | - $this->Log->write( "Radius login", "Failed to authenticate user on radius server", 2, $username ); |
|
1211 | - $this->Result->show("danger", _("Invalid username or password"), true); |
|
1210 | + $this->Log->write ("Radius login", "Failed to authenticate user on radius server", 2, $username); |
|
1211 | + $this->Result->show ("danger", _ ("Invalid username or password"), true); |
|
1212 | 1212 | } |
1213 | 1213 | } |
1214 | 1214 | |
@@ -1244,13 +1244,13 @@ discard block |
||
1244 | 1244 | # initialize salt |
1245 | 1245 | $salt = ""; |
1246 | 1246 | # set possible salt characters in array |
1247 | - $salt_chars = array_merge(range('A','Z'), range('a','z'), range(0,9)); |
|
1247 | + $salt_chars = array_merge (range ('A', 'Z'), range ('a', 'z'), range (0, 9)); |
|
1248 | 1248 | # loop to create salt |
1249 | - for($i=0; $i < 22; $i++) { $salt .= $salt_chars[array_rand($salt_chars)]; } |
|
1249 | + for ($i = 0; $i < 22; $i++) { $salt .= $salt_chars[array_rand ($salt_chars)]; } |
|
1250 | 1250 | # get prefix |
1251 | 1251 | $prefix = $this->detect_crypt_type (); |
1252 | 1252 | # return crypted variable |
1253 | - return crypt($input, $prefix.$salt); |
|
1253 | + return crypt ($input, $prefix.$salt); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
@@ -1260,11 +1260,11 @@ discard block |
||
1260 | 1260 | * @return void |
1261 | 1261 | */ |
1262 | 1262 | private function detect_crypt_type () { |
1263 | - if(CRYPT_SHA512 == 1) { return '$6$rounds=3000$'; } |
|
1264 | - elseif(CRYPT_SHA256 == 1) { return '$5$rounds=3000$'; } |
|
1265 | - elseif(CRYPT_BLOWFISH == 1) { return '$2y$'.str_pad(rand(4,31),2,0, STR_PAD_LEFT).'$'; } |
|
1266 | - elseif(CRYPT_MD5 == 1) { return '$5$rounds=3000$'; } |
|
1267 | - else { $this->Result->show("danger", _("No crypt types supported"), true); } |
|
1263 | + if (CRYPT_SHA512 == 1) { return '$6$rounds=3000$'; } |
|
1264 | + elseif (CRYPT_SHA256 == 1) { return '$5$rounds=3000$'; } |
|
1265 | + elseif (CRYPT_BLOWFISH == 1) { return '$2y$'.str_pad (rand (4, 31), 2, 0, STR_PAD_LEFT).'$'; } |
|
1266 | + elseif (CRYPT_MD5 == 1) { return '$5$rounds=3000$'; } |
|
1267 | + else { $this->Result->show ("danger", _ ("No crypt types supported"), true); } |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1274,11 +1274,11 @@ discard block |
||
1274 | 1274 | * @return void |
1275 | 1275 | */ |
1276 | 1276 | public function return_crypt_type () { |
1277 | - if(CRYPT_SHA512 == 1) { return 'CRYPT_SHA512'; } |
|
1278 | - elseif(CRYPT_SHA256 == 1) { return 'CRYPT_SHA256'; } |
|
1279 | - elseif(CRYPT_BLOWFISH == 1) { return 'CRYPT_BLOWFISH'; } |
|
1280 | - elseif(CRYPT_MD5 == 1) { return 'CRYPT_MD5'; } |
|
1281 | - else { return "No crypt types supported"; } |
|
1277 | + if (CRYPT_SHA512 == 1) { return 'CRYPT_SHA512'; } |
|
1278 | + elseif (CRYPT_SHA256 == 1) { return 'CRYPT_SHA256'; } |
|
1279 | + elseif (CRYPT_BLOWFISH == 1) { return 'CRYPT_BLOWFISH'; } |
|
1280 | + elseif (CRYPT_MD5 == 1) { return 'CRYPT_MD5'; } |
|
1281 | + else { return "No crypt types supported"; } |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | /** |
@@ -1289,10 +1289,10 @@ discard block |
||
1289 | 1289 | * @return void |
1290 | 1290 | */ |
1291 | 1291 | public function update_user_pass ($password) { |
1292 | - try { $this->Database->updateObject("users", array("password"=>$this->crypt_user_pass ($password), "passChange"=>"No", "id"=>$this->user->id), "id"); } |
|
1293 | - catch (Exception $e) { $this->Result->show("danger", $e->getMessage(), true); } |
|
1292 | + try { $this->Database->updateObject ("users", array ("password"=>$this->crypt_user_pass ($password), "passChange"=>"No", "id"=>$this->user->id), "id"); } |
|
1293 | + catch (Exception $e) { $this->Result->show ("danger", $e->getMessage (), true); } |
|
1294 | 1294 | |
1295 | - $this->Result->show("success", "Hi, ".$this->user->real_name.", "._("your password was updated").". <a class='btn btn-sm btn-default' href='".create_link("dashboard")."'>Dashboard</a>", false); |
|
1295 | + $this->Result->show ("success", "Hi, ".$this->user->real_name.", "._ ("your password was updated").". <a class='btn btn-sm btn-default' href='".create_link ("dashboard")."'>Dashboard</a>", false); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | |
@@ -1316,9 +1316,9 @@ discard block |
||
1316 | 1316 | * @param mixed $post //posted user details |
1317 | 1317 | * @return void |
1318 | 1318 | */ |
1319 | - public function self_update($post) { |
|
1319 | + public function self_update ($post) { |
|
1320 | 1320 | # set items to update |
1321 | - $items = array("real_name"=>$post['real_name'], |
|
1321 | + $items = array ("real_name"=>$post['real_name'], |
|
1322 | 1322 | "mailNotify"=>$post['mailNotify'], |
1323 | 1323 | "mailChangelog"=>$post['mailChangelog'], |
1324 | 1324 | "email"=>$post['email'], |
@@ -1326,10 +1326,10 @@ discard block |
||
1326 | 1326 | "id"=>$this->user->id, |
1327 | 1327 | //display |
1328 | 1328 | "compressOverride"=>$post['compressOverride'], |
1329 | - "hideFreeRange"=>$this->verify_checkbox(@$post['hideFreeRange']), |
|
1329 | + "hideFreeRange"=>$this->verify_checkbox (@$post['hideFreeRange']), |
|
1330 | 1330 | "menuType"=>$post['menuType'], |
1331 | 1331 | ); |
1332 | - if(strlen($post['password1'])>0) { |
|
1332 | + if (strlen ($post['password1']) > 0) { |
|
1333 | 1333 | $items['password'] = $this->crypt_user_pass ($post['password1']); |
1334 | 1334 | } |
1335 | 1335 | |
@@ -1337,17 +1337,17 @@ discard block |
||
1337 | 1337 | $log = $this->array_to_log ($post); |
1338 | 1338 | |
1339 | 1339 | # update |
1340 | - try { $this->Database->updateObject("users", $items); } |
|
1340 | + try { $this->Database->updateObject ("users", $items); } |
|
1341 | 1341 | catch (Exception $e) { |
1342 | - $this->Result->show("danger", _("Error: ").$e->getMessage(), false); |
|
1343 | - $this->Log->write( "User self update", "User self update failed!<br>".$log, 2 ); |
|
1342 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false); |
|
1343 | + $this->Log->write ("User self update", "User self update failed!<br>".$log, 2); |
|
1344 | 1344 | return false; |
1345 | 1345 | } |
1346 | 1346 | # update language |
1347 | 1347 | $this->update_session_language (); |
1348 | 1348 | |
1349 | 1349 | # ok, update log table |
1350 | - $this->Log->write( "User self update", "User self update suceeded!", 0 ); |
|
1350 | + $this->Log->write ("User self update", "User self update suceeded!", 0); |
|
1351 | 1351 | return true; |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1360,9 +1360,9 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | public function self_update_widgets ($widgets) { |
1362 | 1362 | # update |
1363 | - try { $this->Database->updateObject("users", array("widgets"=>$widgets, "id"=>$this->user->id)); } |
|
1363 | + try { $this->Database->updateObject ("users", array ("widgets"=>$widgets, "id"=>$this->user->id)); } |
|
1364 | 1364 | catch (Exception $e) { |
1365 | - $this->Result->show("danger", _("Error: ").$e->getMessage(), false); |
|
1365 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false); |
|
1366 | 1366 | return false; |
1367 | 1367 | } |
1368 | 1368 | # ok, update log table |
@@ -1377,11 +1377,11 @@ discard block |
||
1377 | 1377 | */ |
1378 | 1378 | public function update_login_time () { |
1379 | 1379 | # fix for older versions |
1380 | - if($this->settings->version!="1.1") { |
|
1380 | + if ($this->settings->version != "1.1") { |
|
1381 | 1381 | # update |
1382 | - try { $this->Database->updateObject("users", array("lastLogin"=>date("Y-m-d H:i:s"), "id"=>$this->user->id)); } |
|
1382 | + try { $this->Database->updateObject ("users", array ("lastLogin"=>date ("Y-m-d H:i:s"), "id"=>$this->user->id)); } |
|
1383 | 1383 | catch (Exception $e) { |
1384 | - $this->Result->show("danger", _("Error: ").$e->getMessage(), false); |
|
1384 | + $this->Result->show ("danger", _ ("Error: ").$e->getMessage (), false); |
|
1385 | 1385 | return false; |
1386 | 1386 | } |
1387 | 1387 | } |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | */ |
1396 | 1396 | public function update_activity_time () { |
1397 | 1397 | # update |
1398 | - try { $this->Database->updateObject("users", array("lastActivity"=>date("Y-m-d H:i:s"), "id"=>$this->user->id)); } |
|
1398 | + try { $this->Database->updateObject ("users", array ("lastActivity"=>date ("Y-m-d H:i:s"), "id"=>$this->user->id)); } |
|
1399 | 1399 | catch (Exception $e) { } |
1400 | 1400 | } |
1401 | 1401 | |
@@ -1435,14 +1435,14 @@ discard block |
||
1435 | 1435 | $this->purge_blocked_entries (); |
1436 | 1436 | $this->block_get_ip (); |
1437 | 1437 | # set date and query |
1438 | - $now = date("Y-m-d H:i:s", time() - 5*60); |
|
1438 | + $now = date ("Y-m-d H:i:s", time () - 5 * 60); |
|
1439 | 1439 | $query = "select count from `loginAttempts` where `ip` = ? and `datetime` > ?;"; |
1440 | 1440 | # fetch |
1441 | - try { $cnt = $this->Database->getObjectQuery($query, array($this->ip, $now)); } |
|
1442 | - catch (Exception $e) { !$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false); } |
|
1441 | + try { $cnt = $this->Database->getObjectQuery ($query, array ($this->ip, $now)); } |
|
1442 | + catch (Exception $e) { !$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false); } |
|
1443 | 1443 | |
1444 | 1444 | # verify |
1445 | - return @$cnt->count>0 ? $cnt->count : false; |
|
1445 | + return @$cnt->count > 0 ? $cnt->count : false; |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | /** |
@@ -1453,12 +1453,12 @@ discard block |
||
1453 | 1453 | */ |
1454 | 1454 | private function block_ip () { |
1455 | 1455 | # validate IP |
1456 | - if(!filter_var($this->ip, FILTER_VALIDATE_IP)) { return false; } |
|
1456 | + if (!filter_var ($this->ip, FILTER_VALIDATE_IP)) { return false; } |
|
1457 | 1457 | |
1458 | 1458 | # first check if already in |
1459 | - if($this->block_check_ip ()) { $this->block_update_count(); } |
|
1459 | + if ($this->block_check_ip ()) { $this->block_update_count (); } |
|
1460 | 1460 | # if not in add first entry |
1461 | - else { $this->block_add_entry(); } |
|
1461 | + else { $this->block_add_entry (); } |
|
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | /** |
@@ -1470,8 +1470,8 @@ discard block |
||
1470 | 1470 | */ |
1471 | 1471 | private function block_get_ip () { |
1472 | 1472 | # set IP |
1473 | - if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $this->ip = @$_SERVER['HTTP_X_FORWARDED_FOR']; } |
|
1474 | - else { $this->ip = @$_SERVER['REMOTE_ADDR']; } |
|
1473 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $this->ip = @$_SERVER['HTTP_X_FORWARDED_FOR']; } |
|
1474 | + else { $this->ip = @$_SERVER['REMOTE_ADDR']; } |
|
1475 | 1475 | } |
1476 | 1476 | |
1477 | 1477 | /** |
@@ -1482,11 +1482,11 @@ discard block |
||
1482 | 1482 | */ |
1483 | 1483 | private function purge_blocked_entries () { |
1484 | 1484 | # set date 5 min ago and query |
1485 | - $ago = date("Y-m-d H:i:s", time() - 5*60); |
|
1485 | + $ago = date ("Y-m-d H:i:s", time () - 5 * 60); |
|
1486 | 1486 | $query = "delete from `loginAttempts` where `datetime` < ?; "; |
1487 | 1487 | |
1488 | - try { $this->Database->runQuery($query, array($ago)); } |
|
1489 | - catch (Exception $e) { !$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false); } |
|
1488 | + try { $this->Database->runQuery ($query, array ($ago)); } |
|
1489 | + catch (Exception $e) { !$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false); } |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | /** |
@@ -1495,11 +1495,11 @@ discard block |
||
1495 | 1495 | * @access private |
1496 | 1496 | * @return void |
1497 | 1497 | */ |
1498 | - private function block_update_count() { |
|
1498 | + private function block_update_count () { |
|
1499 | 1499 | # query |
1500 | 1500 | $query = "update `loginAttempts` set `count`=`count`+1 where `ip` = ?; "; |
1501 | - try { $this->Database->runQuery($query, array($this->ip)); } |
|
1502 | - catch (Exception $e) { !$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false); } |
|
1501 | + try { $this->Database->runQuery ($query, array ($this->ip)); } |
|
1502 | + catch (Exception $e) { !$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false); } |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | /** |
@@ -1508,9 +1508,9 @@ discard block |
||
1508 | 1508 | * @access private |
1509 | 1509 | * @return void |
1510 | 1510 | */ |
1511 | - private function block_add_entry() { |
|
1512 | - try { $this->Database->insertObject("loginAttempts", array("ip"=>$this->ip, "count"=>1)); } |
|
1513 | - catch (Exception $e) { !$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false); } |
|
1511 | + private function block_add_entry () { |
|
1512 | + try { $this->Database->insertObject ("loginAttempts", array ("ip"=>$this->ip, "count"=>1)); } |
|
1513 | + catch (Exception $e) { !$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false); } |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | /** |
@@ -1519,9 +1519,9 @@ discard block |
||
1519 | 1519 | * @access private |
1520 | 1520 | * @return void |
1521 | 1521 | */ |
1522 | - private function block_remove_entry() { |
|
1523 | - try { $this->Database->deleteRow("loginAttempts", "ip", $this->ip); } |
|
1524 | - catch (Exception $e) { !$this->debugging ? : $this->Result->show("danger", $e->getMessage(), false); } |
|
1522 | + private function block_remove_entry () { |
|
1523 | + try { $this->Database->deleteRow ("loginAttempts", "ip", $this->ip); } |
|
1524 | + catch (Exception $e) { !$this->debugging ? : $this->Result->show ("danger", $e->getMessage (), false); } |
|
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | # verify that user is logged in |
4 | -$User->check_user_session(); |
|
4 | +$User->check_user_session (); |
|
5 | 5 | |
6 | 6 | # fetch all auth methods |
7 | -$all_methods = $Admin->fetch_all_objects("usersAuthMethod"); |
|
7 | +$all_methods = $Admin->fetch_all_objects ("usersAuthMethod"); |
|
8 | 8 | # fetch all parameters for each method |
9 | -$all_method_types = $User->fetch_available_auth_method_types(); |
|
9 | +$all_method_types = $User->fetch_available_auth_method_types (); |
|
10 | 10 | ?> |
11 | 11 | |
12 | 12 | |
13 | -<h4><?php print _("Authentication methods"); ?></h4> |
|
13 | +<h4><?php print _ ("Authentication methods"); ?></h4> |
|
14 | 14 | <hr> |
15 | 15 | |
16 | 16 | <!-- Add new --> |
17 | 17 | <div class="btn-group" style="margin-bottom: 20px;"> |
18 | 18 | <?php |
19 | -foreach($all_method_types as $type) { |
|
20 | - print "<button class='btn btn-sm btn-default editAuthMethod' style='margin-bottom:10px;' data-action='add' data-type='$type'><i class='fa fa-plus'></i> "._("Create new $type authentication")."</button>"; |
|
19 | +foreach ($all_method_types as $type) { |
|
20 | + print "<button class='btn btn-sm btn-default editAuthMethod' style='margin-bottom:10px;' data-action='add' data-type='$type'><i class='fa fa-plus'></i> "._ ("Create new $type authentication")."</button>"; |
|
21 | 21 | } |
22 | 22 | ?> |
23 | 23 | </div> |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | |
28 | 28 | <!-- Headers --> |
29 | 29 | <tr> |
30 | - <th><?php print _('Type'); ?></th> |
|
31 | - <th><?php print _('Description'); ?></th> |
|
32 | - <th><?php print _('Parameters'); ?></th> |
|
33 | - <th><?php print _('Users'); ?></th> |
|
34 | - <th><?php print _('Protected'); ?></th> |
|
30 | + <th><?php print _ ('Type'); ?></th> |
|
31 | + <th><?php print _ ('Description'); ?></th> |
|
32 | + <th><?php print _ ('Parameters'); ?></th> |
|
33 | + <th><?php print _ ('Users'); ?></th> |
|
34 | + <th><?php print _ ('Protected'); ?></th> |
|
35 | 35 | <th></th> |
36 | 36 | </tr> |
37 | 37 | |
38 | 38 | <!-- data --> |
39 | 39 | <?php |
40 | 40 | //loop |
41 | -foreach($all_methods as $method) { |
|
41 | +foreach ($all_methods as $method) { |
|
42 | 42 | //set protected |
43 | - $protected_class = $method->protected=="yes" ? "danger" : ""; |
|
43 | + $protected_class = $method->protected == "yes" ? "danger" : ""; |
|
44 | 44 | |
45 | 45 | //number of users |
46 | - $user_num = $Database->numObjectsFilter("users", "authMethod", $method->id); |
|
46 | + $user_num = $Database->numObjectsFilter ("users", "authMethod", $method->id); |
|
47 | 47 | |
48 | 48 | print "<tr>"; |
49 | 49 | print " <td>$method->type</td>"; |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | //parameters |
52 | 52 | print " <td>"; |
53 | 53 | print " <span class='text-muted'>"; |
54 | - if(strlen($method->params)>0) { |
|
55 | - $params = json_decode($method->params); |
|
56 | - foreach($params as $key=>$parameter) { |
|
54 | + if (strlen ($method->params) > 0) { |
|
55 | + $params = json_decode ($method->params); |
|
56 | + foreach ($params as $key=>$parameter) { |
|
57 | 57 | // mask user/pass |
58 | - if($key=="adminPassword") { $parameter = "********"; } |
|
58 | + if ($key == "adminPassword") { $parameter = "********"; } |
|
59 | 59 | |
60 | 60 | print $key." => ".$parameter."<br>"; |
61 | 61 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | print " <td class='$protected_class'>$user_num</td>"; |
69 | 69 | print " <td class='$protected_class'>$method->protected</td>"; |
70 | 70 | //actions |
71 | - $disabled = $method->type=="local" ? "disabled" : ""; |
|
71 | + $disabled = $method->type == "local" ? "disabled" : ""; |
|
72 | 72 | print " <td class='actions'>"; |
73 | 73 | print " <div class='btn-group'>"; |
74 | 74 | print " <button class='btn btn-xs btn-default editAuthMethod' data-id='$method->id' data-action='edit' data-type='$method->type' rel='tooltip' title='Edit'><i class='fa fa-pencil'></i></button>"; |
@@ -84,19 +84,19 @@ discard block |
||
84 | 84 | |
85 | 85 | <hr> |
86 | 86 | <div class="alert alert-info alert-absolute" style="margin-top:30px;"> |
87 | - <?php print _("Here you can set different authentication methods for your users."); ?> |
|
87 | + <?php print _ ("Here you can set different authentication methods for your users."); ?> |
|
88 | 88 | <hr> |
89 | - <?php print _("phpIPAM currently supports 7 methods for authentication:"); ?> |
|
89 | + <?php print _ ("phpIPAM currently supports 7 methods for authentication:"); ?> |
|
90 | 90 | <ul> |
91 | - <li><?php print _("Local authentication"); ?></li> |
|
92 | - <li><?php print _("Apache authentication"); ?></li> |
|
93 | - <li><?php print _("AD (Active Directory) authentication"); ?></li> |
|
94 | - <li><?php print _("LDAP authentication"); ?></li> |
|
95 | - <li><?php print _("NetIQ authentication"); ?></li> |
|
96 | - <li><?php print _("Radius authentication"); ?></li> |
|
97 | - <li><?php print _("SAMLv2 authentication"); ?></li> |
|
91 | + <li><?php print _ ("Local authentication"); ?></li> |
|
92 | + <li><?php print _ ("Apache authentication"); ?></li> |
|
93 | + <li><?php print _ ("AD (Active Directory) authentication"); ?></li> |
|
94 | + <li><?php print _ ("LDAP authentication"); ?></li> |
|
95 | + <li><?php print _ ("NetIQ authentication"); ?></li> |
|
96 | + <li><?php print _ ("Radius authentication"); ?></li> |
|
97 | + <li><?php print _ ("SAMLv2 authentication"); ?></li> |
|
98 | 98 | </ul> |
99 | 99 | <br> |
100 | - <?php print _("For AD/LDAP/NetIQ connection phpipam is using adLDAP, for documentation please check ")."<a href='http://adldap.sourceforge.net/'>adLDAP</a><br><br>"; ?> |
|
101 | - <?php print _('First create new user under user management with <u>same username as on AD</u> and set authention type to one of available methods.')."<br>"._('Also set proper permissions - group membership for new user'); ?> |
|
100 | + <?php print _ ("For AD/LDAP/NetIQ connection phpipam is using adLDAP, for documentation please check ")."<a href='http://adldap.sourceforge.net/'>adLDAP</a><br><br>"; ?> |
|
101 | + <?php print _ ('First create new user under user management with <u>same username as on AD</u> and set authention type to one of available methods.')."<br>"._ ('Also set proper permissions - group membership for new user'); ?> |
|
102 | 102 | </div> |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | |
10 | 10 | # ID must be numeric */ |
11 | 11 | if($_POST['action']!="add") { |
12 | - if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
12 | + if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
13 | 13 | |
14 | - # feth method settings |
|
15 | - $method_settings = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['id']); |
|
16 | - $method_settings->params = json_decode($method_settings->params); |
|
14 | + # feth method settings |
|
15 | + $method_settings = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['id']); |
|
16 | + $method_settings->params = json_decode($method_settings->params); |
|
17 | 17 | } |
18 | 18 | else { |
19 | - $method_settings = new StdClass (); |
|
20 | - # set default values |
|
19 | + $method_settings = new StdClass (); |
|
20 | + # set default values |
|
21 | 21 | $method_settings->params->idpissuer = ""; |
22 | - $method_settings->params->idplogin = ""; |
|
23 | - $method_settings->params->idplogout = ""; |
|
24 | - $method_settings->params->idpcertfingerprint = ""; |
|
25 | - $method_settings->params->idpcertalgorithm = "sha1"; |
|
26 | - //$method_settings->params->timeout = 2; |
|
22 | + $method_settings->params->idplogin = ""; |
|
23 | + $method_settings->params->idplogout = ""; |
|
24 | + $method_settings->params->idpcertfingerprint = ""; |
|
25 | + $method_settings->params->idpcertalgorithm = "sha1"; |
|
26 | + //$method_settings->params->timeout = 2; |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | <td> |
124 | 124 | <select name="idpcertalgorithm" class="form-control input-w-auto"> |
125 | 125 | <?php |
126 | - $values = array("sha1","sha256", "sha384", "sha512"); |
|
127 | - foreach($values as $v) { |
|
128 | - if($v==@$method_settings->params->idpcertalgorithm) { print "<option value='$v' selected=selected>$v</option>"; } |
|
129 | - else { print "<option value='$v' >$v</option>"; } |
|
130 | - } |
|
131 | - ?> |
|
126 | + $values = array("sha1","sha256", "sha384", "sha512"); |
|
127 | + foreach($values as $v) { |
|
128 | + if($v==@$method_settings->params->idpcertalgorithm) { print "<option value='$v' selected=selected>$v</option>"; } |
|
129 | + else { print "<option value='$v' >$v</option>"; } |
|
130 | + } |
|
131 | + ?> |
|
132 | 132 | </select> |
133 | 133 | </td> |
134 | 134 | <td class="base_dn info2"> |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | </form> |
141 | 141 | |
142 | 142 | <?php |
143 | - # check for support |
|
144 | - if(!in_array("xml", get_loaded_extensions())) { |
|
145 | - $Log->write( "SAML2 login", "php xml extension missing!", 2 ); |
|
146 | - $Result->show("danger", _("php XML extension missing!"), false); |
|
147 | - } |
|
148 | - if(!in_array("date", get_loaded_extensions())) { |
|
149 | - $Log->write( "SAML2 login", "php date extension missing!", 2 ); |
|
150 | - $Result->show("danger", _("php Date extension missing!"), false); |
|
151 | - } |
|
152 | - if(!in_array("zlib", get_loaded_extensions())) { |
|
153 | - $Log->write( "SAML2 login", "php zlib extension missing!", 2 ); |
|
154 | - $Result->show("danger", _("php zlib extension missing!"), false); |
|
155 | - } |
|
156 | - if(!in_array("openssl", get_loaded_extensions())) { |
|
157 | - $Log->write( "SAML2 login", "php openssl extension missing!", 2 ); |
|
158 | - $Result->show("danger", _("php openssl extension missing!"), false); |
|
159 | - } |
|
160 | - if(!in_array("mcrypt", get_loaded_extensions())) { |
|
161 | - $Log->write( "SAML2 login", "php mcrypt extension missing!", 2 ); |
|
162 | - $Result->show("danger", _("php mcrypt extension missing!"), false); |
|
163 | - } |
|
164 | - if(!in_array("gettext", get_loaded_extensions())) { |
|
165 | - $Log->write( "SAML2 login", "php gettext extension missing!", 2 ); |
|
166 | - $Result->show("danger", _("php gettext extension missing!"), false); |
|
167 | - } |
|
168 | - ?> |
|
143 | + # check for support |
|
144 | + if(!in_array("xml", get_loaded_extensions())) { |
|
145 | + $Log->write( "SAML2 login", "php xml extension missing!", 2 ); |
|
146 | + $Result->show("danger", _("php XML extension missing!"), false); |
|
147 | + } |
|
148 | + if(!in_array("date", get_loaded_extensions())) { |
|
149 | + $Log->write( "SAML2 login", "php date extension missing!", 2 ); |
|
150 | + $Result->show("danger", _("php Date extension missing!"), false); |
|
151 | + } |
|
152 | + if(!in_array("zlib", get_loaded_extensions())) { |
|
153 | + $Log->write( "SAML2 login", "php zlib extension missing!", 2 ); |
|
154 | + $Result->show("danger", _("php zlib extension missing!"), false); |
|
155 | + } |
|
156 | + if(!in_array("openssl", get_loaded_extensions())) { |
|
157 | + $Log->write( "SAML2 login", "php openssl extension missing!", 2 ); |
|
158 | + $Result->show("danger", _("php openssl extension missing!"), false); |
|
159 | + } |
|
160 | + if(!in_array("mcrypt", get_loaded_extensions())) { |
|
161 | + $Log->write( "SAML2 login", "php mcrypt extension missing!", 2 ); |
|
162 | + $Result->show("danger", _("php mcrypt extension missing!"), false); |
|
163 | + } |
|
164 | + if(!in_array("gettext", get_loaded_extensions())) { |
|
165 | + $Log->write( "SAML2 login", "php gettext extension missing!", 2 ); |
|
166 | + $Result->show("danger", _("php gettext extension missing!"), false); |
|
167 | + } |
|
168 | + ?> |
|
169 | 169 | </div> |
170 | 170 | |
171 | 171 | |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | </div> |
178 | 178 | |
179 | 179 | <?php |
180 | - # check for mathing users |
|
181 | - if($_POST['action']=="delete") { |
|
182 | - $users = $Admin->fetch_multiple_objects ("users", "authMethod", @$method_settings->id); |
|
183 | - if($users!==false) { |
|
184 | - $Result->show("warning", sizeof($users)._(" users have this method for logging in. They will be reset to local auth!"), false); |
|
185 | - } |
|
186 | - } |
|
187 | - ?> |
|
180 | + # check for mathing users |
|
181 | + if($_POST['action']=="delete") { |
|
182 | + $users = $Admin->fetch_multiple_objects ("users", "authMethod", @$method_settings->id); |
|
183 | + if($users!==false) { |
|
184 | + $Result->show("warning", sizeof($users)._(" users have this method for logging in. They will be reset to local auth!"), false); |
|
185 | + } |
|
186 | + } |
|
187 | + ?> |
|
188 | 188 | |
189 | 189 | <!-- Result --> |
190 | 190 | <div class="editAuthMethodResult"></div> |
@@ -5,15 +5,15 @@ discard block |
||
5 | 5 | *****************/ |
6 | 6 | |
7 | 7 | # verify that user is logged in |
8 | -$User->check_user_session(); |
|
8 | +$User->check_user_session (); |
|
9 | 9 | |
10 | 10 | # ID must be numeric */ |
11 | -if($_POST['action']!="add") { |
|
12 | - if(!is_numeric($_POST['id'])) { $Result->show("danger", _("Invalid ID"), true, true); } |
|
11 | +if ($_POST['action'] != "add") { |
|
12 | + if (!is_numeric ($_POST['id'])) { $Result->show ("danger", _ ("Invalid ID"), true, true); } |
|
13 | 13 | |
14 | 14 | # feth method settings |
15 | 15 | $method_settings = $Admin->fetch_object ("usersAuthMethod", "id", $_POST['id']); |
16 | - $method_settings->params = json_decode($method_settings->params); |
|
16 | + $method_settings->params = json_decode ($method_settings->params); |
|
17 | 17 | } |
18 | 18 | else { |
19 | 19 | $method_settings = new StdClass (); |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | # set delete flag |
31 | -$delete = $_POST['action']=="delete" ? "disabled" : ""; |
|
31 | +$delete = $_POST['action'] == "delete" ? "disabled" : ""; |
|
32 | 32 | ?> |
33 | 33 | |
34 | 34 | <!-- header --> |
35 | -<div class="pHeader"><?php print _('SAML2 connection settings'); ?></div> |
|
35 | +<div class="pHeader"><?php print _ ('SAML2 connection settings'); ?></div> |
|
36 | 36 | |
37 | 37 | <!-- content --> |
38 | 38 | <div class="pContent"> |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | <!-- description --> |
44 | 44 | <tr> |
45 | - <td><?php print _('Description'); ?></td> |
|
45 | + <td><?php print _ ('Description'); ?></td> |
|
46 | 46 | <td> |
47 | 47 | <input type="text" name="description" class="form-control input-sm" value="<?php print @$method_settings->description; ?>" <?php print $delete; ?>> |
48 | 48 | </td> |
49 | 49 | <td class="base_dn info2"> |
50 | - <?php print _('Set name for authentication method'); ?> |
|
50 | + <?php print _ ('Set name for authentication method'); ?> |
|
51 | 51 | </td> |
52 | 52 | </tr> |
53 | 53 | |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | |
58 | 58 | <!-- SSL --> |
59 | 59 | <tr> |
60 | - <td><?php print _('Use advanced settings'); ?></td> |
|
60 | + <td><?php print _ ('Use advanced settings'); ?></td> |
|
61 | 61 | <td> |
62 | 62 | <select name="advanced" class="form-control input-sm input-w-auto" <?php print $delete; ?>> |
63 | - <option value="0" <?php if(@$method_settings->params->advanced == 0) { print 'selected'; } ?>><?php print _('false'); ?></option> |
|
64 | - <option value="1" <?php if(@$method_settings->params->advanced == 1) { print 'selected'; } ?>><?php print _('true'); ?></option> |
|
63 | + <option value="0" <?php if (@$method_settings->params->advanced == 0) { print 'selected'; } ?>><?php print _ ('false'); ?></option> |
|
64 | + <option value="1" <?php if (@$method_settings->params->advanced == 1) { print 'selected'; } ?>><?php print _ ('true'); ?></option> |
|
65 | 65 | </select> |
66 | 66 | </td> |
67 | 67 | <td class="info2"> |
68 | - <?php print _('Use Onelogin php-saml settings.php configuration'); ?><br> |
|
68 | + <?php print _ ('Use Onelogin php-saml settings.php configuration'); ?><br> |
|
69 | 69 | </td> |
70 | 70 | </tr> |
71 | 71 | <tr> |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | <!-- Idp issuer --> |
76 | 76 | <tr> |
77 | - <td><?php print _('IDP issuer'); ?></td> |
|
77 | + <td><?php print _ ('IDP issuer'); ?></td> |
|
78 | 78 | <td> |
79 | 79 | <input type="text" name="idpissuer" class="form-control input-sm" value="<?php print @$method_settings->params->idpissuer; ?>" <?php print $delete; ?>> |
80 | 80 | <input type="hidden" name="type" value="SAML2"> |
@@ -83,56 +83,56 @@ discard block |
||
83 | 83 | <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
84 | 84 | </td> |
85 | 85 | <td class="base_dn info2"> |
86 | - <?php print _('Enter idp issuer'); ?> |
|
86 | + <?php print _ ('Enter idp issuer'); ?> |
|
87 | 87 | </td> |
88 | 88 | </tr> |
89 | 89 | |
90 | 90 | <!-- Idp login --> |
91 | 91 | <tr> |
92 | - <td><?php print _('IDP login url'); ?></td> |
|
92 | + <td><?php print _ ('IDP login url'); ?></td> |
|
93 | 93 | <td> |
94 | 94 | <input type="text" name="idplogin" class="form-control input-sm" value="<?php print @$method_settings->params->idplogin; ?>" <?php print $delete; ?>> |
95 | 95 | </td> |
96 | 96 | <td class="base_dn info2"> |
97 | - <?php print _('Enter IDP login url'); ?> |
|
97 | + <?php print _ ('Enter IDP login url'); ?> |
|
98 | 98 | </td> |
99 | 99 | </tr> |
100 | 100 | <!-- Idp logout --> |
101 | 101 | <tr> |
102 | - <td><?php print _('IDP logout url'); ?></td> |
|
102 | + <td><?php print _ ('IDP logout url'); ?></td> |
|
103 | 103 | <td> |
104 | 104 | <input type="text" name="idplogout" class="form-control input-sm" value="<?php print @$method_settings->params->idplogout; ?>" <?php print $delete; ?>> |
105 | 105 | </td> |
106 | 106 | <td class="base_dn info2"> |
107 | - <?php print _('Enter IDP logout url'); ?> |
|
107 | + <?php print _ ('Enter IDP logout url'); ?> |
|
108 | 108 | </td> |
109 | 109 | </tr> |
110 | 110 | <!-- Idp cert fingerprint --> |
111 | 111 | <tr> |
112 | - <td><?php print _('IDP cert fingerprint'); ?></td> |
|
112 | + <td><?php print _ ('IDP cert fingerprint'); ?></td> |
|
113 | 113 | <td> |
114 | 114 | <input type="text" name="idpcertfingerprint" class="form-control input-sm" value="<?php print @$method_settings->params->idpcertfingerprint; ?>" <?php print $delete; ?>> |
115 | 115 | </td> |
116 | 116 | <td class="base_dn info2"> |
117 | - <?php print _('Enter IDP X509 certificate fingerprint'); ?> |
|
117 | + <?php print _ ('Enter IDP X509 certificate fingerprint'); ?> |
|
118 | 118 | </td> |
119 | 119 | </tr> |
120 | 120 | <!-- Idp cert algorithm --> |
121 | 121 | <tr> |
122 | - <td><?php print _('IDP cert algorithm'); ?></td> |
|
122 | + <td><?php print _ ('IDP cert algorithm'); ?></td> |
|
123 | 123 | <td> |
124 | 124 | <select name="idpcertalgorithm" class="form-control input-w-auto"> |
125 | 125 | <?php |
126 | - $values = array("sha1","sha256", "sha384", "sha512"); |
|
127 | - foreach($values as $v) { |
|
128 | - if($v==@$method_settings->params->idpcertalgorithm) { print "<option value='$v' selected=selected>$v</option>"; } |
|
129 | - else { print "<option value='$v' >$v</option>"; } |
|
126 | + $values = array ("sha1", "sha256", "sha384", "sha512"); |
|
127 | + foreach ($values as $v) { |
|
128 | + if ($v == @$method_settings->params->idpcertalgorithm) { print "<option value='$v' selected=selected>$v</option>"; } |
|
129 | + else { print "<option value='$v' >$v</option>"; } |
|
130 | 130 | } |
131 | 131 | ?> |
132 | 132 | </select> |
133 | 133 | </td> |
134 | 134 | <td class="base_dn info2"> |
135 | - <?php print _('Enter IDP X509 certificate algorithm'); ?> |
|
135 | + <?php print _ ('Enter IDP X509 certificate algorithm'); ?> |
|
136 | 136 | </td> |
137 | 137 | </tr> |
138 | 138 | |
@@ -141,29 +141,29 @@ discard block |
||
141 | 141 | |
142 | 142 | <?php |
143 | 143 | # check for support |
144 | - if(!in_array("xml", get_loaded_extensions())) { |
|
145 | - $Log->write( "SAML2 login", "php xml extension missing!", 2 ); |
|
146 | - $Result->show("danger", _("php XML extension missing!"), false); |
|
144 | + if (!in_array ("xml", get_loaded_extensions ())) { |
|
145 | + $Log->write ("SAML2 login", "php xml extension missing!", 2); |
|
146 | + $Result->show ("danger", _ ("php XML extension missing!"), false); |
|
147 | 147 | } |
148 | - if(!in_array("date", get_loaded_extensions())) { |
|
149 | - $Log->write( "SAML2 login", "php date extension missing!", 2 ); |
|
150 | - $Result->show("danger", _("php Date extension missing!"), false); |
|
148 | + if (!in_array ("date", get_loaded_extensions ())) { |
|
149 | + $Log->write ("SAML2 login", "php date extension missing!", 2); |
|
150 | + $Result->show ("danger", _ ("php Date extension missing!"), false); |
|
151 | 151 | } |
152 | - if(!in_array("zlib", get_loaded_extensions())) { |
|
153 | - $Log->write( "SAML2 login", "php zlib extension missing!", 2 ); |
|
154 | - $Result->show("danger", _("php zlib extension missing!"), false); |
|
152 | + if (!in_array ("zlib", get_loaded_extensions ())) { |
|
153 | + $Log->write ("SAML2 login", "php zlib extension missing!", 2); |
|
154 | + $Result->show ("danger", _ ("php zlib extension missing!"), false); |
|
155 | 155 | } |
156 | - if(!in_array("openssl", get_loaded_extensions())) { |
|
157 | - $Log->write( "SAML2 login", "php openssl extension missing!", 2 ); |
|
158 | - $Result->show("danger", _("php openssl extension missing!"), false); |
|
156 | + if (!in_array ("openssl", get_loaded_extensions ())) { |
|
157 | + $Log->write ("SAML2 login", "php openssl extension missing!", 2); |
|
158 | + $Result->show ("danger", _ ("php openssl extension missing!"), false); |
|
159 | 159 | } |
160 | - if(!in_array("mcrypt", get_loaded_extensions())) { |
|
161 | - $Log->write( "SAML2 login", "php mcrypt extension missing!", 2 ); |
|
162 | - $Result->show("danger", _("php mcrypt extension missing!"), false); |
|
160 | + if (!in_array ("mcrypt", get_loaded_extensions ())) { |
|
161 | + $Log->write ("SAML2 login", "php mcrypt extension missing!", 2); |
|
162 | + $Result->show ("danger", _ ("php mcrypt extension missing!"), false); |
|
163 | 163 | } |
164 | - if(!in_array("gettext", get_loaded_extensions())) { |
|
165 | - $Log->write( "SAML2 login", "php gettext extension missing!", 2 ); |
|
166 | - $Result->show("danger", _("php gettext extension missing!"), false); |
|
164 | + if (!in_array ("gettext", get_loaded_extensions ())) { |
|
165 | + $Log->write ("SAML2 login", "php gettext extension missing!", 2); |
|
166 | + $Result->show ("danger", _ ("php gettext extension missing!"), false); |
|
167 | 167 | } |
168 | 168 | ?> |
169 | 169 | </div> |
@@ -172,16 +172,16 @@ discard block |
||
172 | 172 | <!-- footer --> |
173 | 173 | <div class="pFooter"> |
174 | 174 | <div class="btn-group"> |
175 | - <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
|
176 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editAuthMethodSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
175 | + <button class="btn btn-sm btn-default hidePopups"><?php print _ ('Cancel'); ?></button> |
|
176 | + <button class="btn btn-sm btn-default <?php if ($_POST['action'] == "delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editAuthMethodSubmit"><i class="fa <?php if ($_POST['action'] == "add") { print "fa-plus"; } else if ($_POST['action'] == "delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords (_ ($_POST['action'])); ?></button> |
|
177 | 177 | </div> |
178 | 178 | |
179 | 179 | <?php |
180 | 180 | # check for mathing users |
181 | - if($_POST['action']=="delete") { |
|
181 | + if ($_POST['action'] == "delete") { |
|
182 | 182 | $users = $Admin->fetch_multiple_objects ("users", "authMethod", @$method_settings->id); |
183 | - if($users!==false) { |
|
184 | - $Result->show("warning", sizeof($users)._(" users have this method for logging in. They will be reset to local auth!"), false); |
|
183 | + if ($users !== false) { |
|
184 | + $Result->show ("warning", sizeof ($users)._ (" users have this method for logging in. They will be reset to local auth!"), false); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | ?> |
@@ -174,7 +174,10 @@ |
||
174 | 174 | <div class="pFooter"> |
175 | 175 | <div class="btn-group"> |
176 | 176 | <button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button> |
177 | - <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editAuthMethodSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
177 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } |
|
178 | +else { print "btn-success"; } ?>" id="editAuthMethodSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } |
|
179 | +else if ($_POST['action']=="delete") { print "fa-trash-o"; } |
|
180 | +else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
|
178 | 181 | </div> |
179 | 182 | |
180 | 183 | <?php |
@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | // http auth |
6 | 6 | if( !empty($_SERVER['PHP_AUTH_USER']) ) { |
7 | 7 | // try to authenticate |
8 | - $User->authenticate ($_SERVER['PHP_AUTH_USER'], ''); |
|
9 | - // Redirect user where he came from, if unknown go to dashboard. |
|
10 | - if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
11 | - else { header("Location: ".create_link("dashboard")); } |
|
12 | - exit(); |
|
8 | + $User->authenticate ($_SERVER['PHP_AUTH_USER'], ''); |
|
9 | + // Redirect user where he came from, if unknown go to dashboard. |
|
10 | + if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
11 | + else { header("Location: ".create_link("dashboard")); } |
|
12 | + exit(); |
|
13 | 13 | } |
14 | 14 | ?> |
15 | 15 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | <!-- logo --> |
83 | 83 | <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12"> |
84 | 84 | <?php |
85 | - if(file_exists( "css/1.2/images/logo/logo.png")) { |
|
86 | - print "<img style='width:220px;margin:10px;margin-top:20px;' src='css/1.2/images/logo/logo.png'>"; |
|
87 | - } |
|
85 | + if(file_exists( "css/1.2/images/logo/logo.png")) { |
|
86 | + print "<img style='width:220px;margin:10px;margin-top:20px;' src='css/1.2/images/logo/logo.png'>"; |
|
87 | + } |
|
88 | 88 | ?> |
89 | 89 | </div> |
90 | 90 | <!-- title --> |
@@ -103,48 +103,48 @@ discard block |
||
103 | 103 | <div class="container-fluid" id="mainContainer"> |
104 | 104 | |
105 | 105 | <?php |
106 | - # set default language |
|
107 | - if(isset($User->settings->defaultLang) && !is_null($User->settings->defaultLang) ) { |
|
108 | - # get language |
|
109 | - $lang = $User->get_default_lang(); |
|
110 | - |
|
111 | - putenv("LC_ALL=".$lang->l_code); |
|
112 | - setlocale(LC_ALL, $lang->l_code); // set language |
|
113 | - bindtextdomain("phpipam", "./functions/locale"); // Specify location of translation tables |
|
114 | - textdomain("phpipam"); // Choose domain |
|
115 | - } |
|
116 | - ?> |
|
106 | + # set default language |
|
107 | + if(isset($User->settings->defaultLang) && !is_null($User->settings->defaultLang) ) { |
|
108 | + # get language |
|
109 | + $lang = $User->get_default_lang(); |
|
110 | + |
|
111 | + putenv("LC_ALL=".$lang->l_code); |
|
112 | + setlocale(LC_ALL, $lang->l_code); // set language |
|
113 | + bindtextdomain("phpipam", "./functions/locale"); // Specify location of translation tables |
|
114 | + textdomain("phpipam"); // Choose domain |
|
115 | + } |
|
116 | + ?> |
|
117 | 117 | |
118 | 118 | <?php |
119 | - # include proper subpage |
|
120 | - if($_GET['page'] == "login") { include_once('login_form.php'); } |
|
121 | - else if ($_GET['page'] == "request_ip") { include_once('request_ip_form.php'); } |
|
122 | - else { $_GET['subnetId'] = "404"; print "<div id='error'>"; include_once('app/error.php'); print "</div>"; } |
|
123 | - ?> |
|
119 | + # include proper subpage |
|
120 | + if($_GET['page'] == "login") { include_once('login_form.php'); } |
|
121 | + else if ($_GET['page'] == "request_ip") { include_once('request_ip_form.php'); } |
|
122 | + else { $_GET['subnetId'] = "404"; print "<div id='error'>"; include_once('app/error.php'); print "</div>"; } |
|
123 | + ?> |
|
124 | 124 | |
125 | 125 | <!-- login response --> |
126 | 126 | <div id="loginCheck"> |
127 | 127 | <?php |
128 | - # deauthenticate user |
|
129 | - if ( $User->is_authenticated()===true ) { |
|
130 | - # print result |
|
131 | - if($_GET['section']=="timeout") { $Result->show("success", _('You session has timed out')); } |
|
132 | - else { $Result->show("success", _('You have logged out')); } |
|
133 | - |
|
134 | - # write log |
|
135 | - $Log->write( "User logged out", "User $User->username has logged out", 0, $User->username ); |
|
136 | - |
|
137 | - # destroy session |
|
138 | - $User->destroy_session(); |
|
139 | - } |
|
128 | + # deauthenticate user |
|
129 | + if ( $User->is_authenticated()===true ) { |
|
130 | + # print result |
|
131 | + if($_GET['section']=="timeout") { $Result->show("success", _('You session has timed out')); } |
|
132 | + else { $Result->show("success", _('You have logged out')); } |
|
133 | + |
|
134 | + # write log |
|
135 | + $Log->write( "User logged out", "User $User->username has logged out", 0, $User->username ); |
|
136 | + |
|
137 | + # destroy session |
|
138 | + $User->destroy_session(); |
|
139 | + } |
|
140 | 140 | |
141 | - //check if SAML2 login is possible |
|
142 | - $saml2settings=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
|
143 | - if($saml2settings!=false){ |
|
144 | - $Result->show("success", _('You can login with SAML2 <a href="'.$Tools->createURL().'/saml2">here</a>')); |
|
145 | - } |
|
141 | + //check if SAML2 login is possible |
|
142 | + $saml2settings=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
|
143 | + if($saml2settings!=false){ |
|
144 | + $Result->show("success", _('You can login with SAML2 <a href="'.$Tools->createURL().'/saml2">here</a>')); |
|
145 | + } |
|
146 | 146 | |
147 | - ?> |
|
147 | + ?> |
|
148 | 148 | </div> |
149 | 149 | |
150 | 150 | </div> |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | # verify php build |
3 | -include('functions/checks/check_php_build.php'); # check for support for PHP modules and database connection |
|
3 | +include('functions/checks/check_php_build.php'); # check for support for PHP modules and database connection |
|
4 | 4 | |
5 | 5 | // http auth |
6 | -if( !empty($_SERVER['PHP_AUTH_USER']) ) { |
|
6 | +if (!empty($_SERVER['PHP_AUTH_USER'])) { |
|
7 | 7 | // try to authenticate |
8 | 8 | $User->authenticate ($_SERVER['PHP_AUTH_USER'], ''); |
9 | 9 | // Redirect user where he came from, if unknown go to dashboard. |
10 | - if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
11 | - else { header("Location: ".create_link("dashboard")); } |
|
10 | + if (isset($_COOKIE['phpipamredirect'])) { header ("Location: ".$_COOKIE['phpipamredirect']); } |
|
11 | + else { header ("Location: ".create_link ("dashboard")); } |
|
12 | 12 | exit(); |
13 | 13 | } |
14 | 14 | ?> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <div class="jqueryError"> |
66 | 66 | <div class='alert alert-danger' style="width:400px;margin:auto">jQuery error!</div> |
67 | 67 | <div class="jqueryErrorText"></div><br> |
68 | - <a href="<?php print create_link(null); ?>" class="btn btn-sm btn-default" id="hideError" style="margin-top:0px;">Hide</a> |
|
68 | + <a href="<?php print create_link (null); ?>" class="btn btn-sm btn-default" id="hideError" style="margin-top:0px;">Hide</a> |
|
69 | 69 | </div> |
70 | 70 | |
71 | 71 | <!-- Popups --> |
@@ -75,14 +75,14 @@ discard block |
||
75 | 75 | <div id="popup" class="popup popup_w700"></div> |
76 | 76 | |
77 | 77 | <!-- loader --> |
78 | -<div class="loading"><?php print _('Loading');?>...<br><i class="fa fa-spinner fa-spin"></i></div> |
|
78 | +<div class="loading"><?php print _ ('Loading'); ?>...<br><i class="fa fa-spinner fa-spin"></i></div> |
|
79 | 79 | |
80 | 80 | <!-- header --> |
81 | 81 | <div class="row header-install" id="header"> |
82 | 82 | <!-- logo --> |
83 | 83 | <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12"> |
84 | 84 | <?php |
85 | - if(file_exists( "css/1.2/images/logo/logo.png")) { |
|
85 | + if (file_exists ("css/1.2/images/logo/logo.png")) { |
|
86 | 86 | print "<img style='width:220px;margin:10px;margin-top:20px;' src='css/1.2/images/logo/logo.png'>"; |
87 | 87 | } |
88 | 88 | ?> |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | <!-- title --> |
91 | 91 | <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12"> |
92 | 92 | <div class="hero-unit" style="padding:20px;margin-bottom:10px;margin-top: 10px;"> |
93 | - <a href="<?php print create_link(null); ?>"><?php print $User->settings->siteTitle;?></a> |
|
94 | - <p class="muted"><?php print _("Login"); ?></p> |
|
93 | + <a href="<?php print create_link (null); ?>"><?php print $User->settings->siteTitle; ?></a> |
|
94 | + <p class="muted"><?php print _ ("Login"); ?></p> |
|
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | <div class="col-lg-3 col-md-3 hidden-sm hidden-xs"> |
@@ -104,44 +104,44 @@ discard block |
||
104 | 104 | |
105 | 105 | <?php |
106 | 106 | # set default language |
107 | - if(isset($User->settings->defaultLang) && !is_null($User->settings->defaultLang) ) { |
|
107 | + if (isset($User->settings->defaultLang) && !is_null ($User->settings->defaultLang)) { |
|
108 | 108 | # get language |
109 | - $lang = $User->get_default_lang(); |
|
109 | + $lang = $User->get_default_lang (); |
|
110 | 110 | |
111 | - putenv("LC_ALL=".$lang->l_code); |
|
112 | - setlocale(LC_ALL, $lang->l_code); // set language |
|
113 | - bindtextdomain("phpipam", "./functions/locale"); // Specify location of translation tables |
|
114 | - textdomain("phpipam"); // Choose domain |
|
111 | + putenv ("LC_ALL=".$lang->l_code); |
|
112 | + setlocale (LC_ALL, $lang->l_code); // set language |
|
113 | + bindtextdomain ("phpipam", "./functions/locale"); // Specify location of translation tables |
|
114 | + textdomain ("phpipam"); // Choose domain |
|
115 | 115 | } |
116 | 116 | ?> |
117 | 117 | |
118 | 118 | <?php |
119 | 119 | # include proper subpage |
120 | - if($_GET['page'] == "login") { include_once('login_form.php'); } |
|
121 | - else if ($_GET['page'] == "request_ip") { include_once('request_ip_form.php'); } |
|
122 | - else { $_GET['subnetId'] = "404"; print "<div id='error'>"; include_once('app/error.php'); print "</div>"; } |
|
120 | + if ($_GET['page'] == "login") { include_once('login_form.php'); } |
|
121 | + else if ($_GET['page'] == "request_ip") { include_once('request_ip_form.php'); } |
|
122 | + else { $_GET['subnetId'] = "404"; print "<div id='error'>"; include_once('app/error.php'); print "</div>"; } |
|
123 | 123 | ?> |
124 | 124 | |
125 | 125 | <!-- login response --> |
126 | 126 | <div id="loginCheck"> |
127 | 127 | <?php |
128 | 128 | # deauthenticate user |
129 | - if ( $User->is_authenticated()===true ) { |
|
129 | + if ($User->is_authenticated () === true) { |
|
130 | 130 | # print result |
131 | - if($_GET['section']=="timeout") { $Result->show("success", _('You session has timed out')); } |
|
132 | - else { $Result->show("success", _('You have logged out')); } |
|
131 | + if ($_GET['section'] == "timeout") { $Result->show ("success", _ ('You session has timed out')); } |
|
132 | + else { $Result->show ("success", _ ('You have logged out')); } |
|
133 | 133 | |
134 | 134 | # write log |
135 | - $Log->write( "User logged out", "User $User->username has logged out", 0, $User->username ); |
|
135 | + $Log->write ("User logged out", "User $User->username has logged out", 0, $User->username); |
|
136 | 136 | |
137 | 137 | # destroy session |
138 | - $User->destroy_session(); |
|
138 | + $User->destroy_session (); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | //check if SAML2 login is possible |
142 | - $saml2settings=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
|
143 | - if($saml2settings!=false){ |
|
144 | - $Result->show("success", _('You can login with SAML2 <a href="'.$Tools->createURL().'/saml2">here</a>')); |
|
142 | + $saml2settings = $Tools->fetch_object ("usersAuthMethod", "type", "SAML2"); |
|
143 | + if ($saml2settings != false) { |
|
144 | + $Result->show ("success", _ ('You can login with SAML2 <a href="'.$Tools->createURL ().'/saml2">here</a>')); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | ?> |
@@ -140,7 +140,7 @@ |
||
140 | 140 | |
141 | 141 | //check if SAML2 login is possible |
142 | 142 | $saml2settings=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
143 | - if($saml2settings!=false){ |
|
143 | + if($saml2settings!=false) { |
|
144 | 144 | $Result->show("success", _('You can login with SAML2 <a href="'.$Tools->createURL().'/saml2">here</a>')); |
145 | 145 | } |
146 | 146 |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | $params=json_decode($dbobj->params); |
15 | 15 | //if using advanced settings, instantiate without db settings |
16 | 16 | if($params->advanced=="1"){ |
17 | - $auth = new OneLogin_Saml2_Auth(); |
|
17 | + $auth = new OneLogin_Saml2_Auth(); |
|
18 | 18 | }else{ |
19 | 19 | |
20 | - $settings = array ( |
|
20 | + $settings = array ( |
|
21 | 21 | 'sp' => array ( |
22 | 22 | 'entityId' => $Tools->createURL(), |
23 | 23 | 'assertionConsumerService' => array ( |
@@ -37,45 +37,45 @@ discard block |
||
37 | 37 | 'url' => $params->idplogout, |
38 | 38 | ), |
39 | 39 | 'certFingerprint' => $params->idpcertfingerprint, |
40 | - 'certFingerprintAlgorithm' => $params->idpcertalgorithm, |
|
40 | + 'certFingerprintAlgorithm' => $params->idpcertalgorithm, |
|
41 | 41 | ), |
42 | 42 | ); |
43 | - $auth = new OneLogin_Saml2_Auth($settings); |
|
43 | + $auth = new OneLogin_Saml2_Auth($settings); |
|
44 | 44 | } |
45 | 45 | //if SAMLResponse is not in the request, create an authnrequest and send it to the idp |
46 | 46 | if(!isset($_POST["SAMLResponse"])){ |
47 | - $ssoBuiltUrl = $auth->login(null, array(), false, false, true); |
|
48 | - $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); |
|
49 | - header('Pragma: no-cache'); |
|
50 | - header('Cache-Control: no-cache, must-revalidate'); |
|
51 | - header('Location: ' . $ssoBuiltUrl); |
|
52 | - exit(); |
|
47 | + $ssoBuiltUrl = $auth->login(null, array(), false, false, true); |
|
48 | + $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); |
|
49 | + header('Pragma: no-cache'); |
|
50 | + header('Cache-Control: no-cache, must-revalidate'); |
|
51 | + header('Location: ' . $ssoBuiltUrl); |
|
52 | + exit(); |
|
53 | 53 | }else{ |
54 | 54 | //process the authentication response |
55 | - if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { |
|
56 | - $requestID = $_SESSION['AuthNRequestID']; |
|
57 | - } else { |
|
58 | - $requestID = null; |
|
59 | - } |
|
55 | + if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { |
|
56 | + $requestID = $_SESSION['AuthNRequestID']; |
|
57 | + } else { |
|
58 | + $requestID = null; |
|
59 | + } |
|
60 | 60 | |
61 | - $auth->processResponse($requestID); |
|
61 | + $auth->processResponse($requestID); |
|
62 | 62 | |
63 | - $errors = $auth->getErrors(); |
|
63 | + $errors = $auth->getErrors(); |
|
64 | 64 | |
65 | - if (!empty($errors)) { |
|
66 | - print_r('<p>'.implode(', ', $errors).'</p>'); |
|
67 | - exit(); |
|
68 | - } |
|
65 | + if (!empty($errors)) { |
|
66 | + print_r('<p>'.implode(', ', $errors).'</p>'); |
|
67 | + exit(); |
|
68 | + } |
|
69 | 69 | |
70 | - if (!$auth->isAuthenticated()) { |
|
71 | - echo "<p>Not authenticated</p>"; |
|
72 | - exit(); |
|
73 | - } |
|
70 | + if (!$auth->isAuthenticated()) { |
|
71 | + echo "<p>Not authenticated</p>"; |
|
72 | + exit(); |
|
73 | + } |
|
74 | 74 | |
75 | - // try to authenticate in phpipam |
|
76 | - $User->authenticate ($auth->getNameId(), ''); |
|
77 | - // Redirect user where he came from, if unknown go to dashboard. |
|
78 | - if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
79 | - else { header("Location: ".create_link("dashboard")); } |
|
75 | + // try to authenticate in phpipam |
|
76 | + $User->authenticate ($auth->getNameId(), ''); |
|
77 | + // Redirect user where he came from, if unknown go to dashboard. |
|
78 | + if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
79 | + else { header("Location: ".create_link("dashboard")); } |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | # verify php build |
3 | -include('functions/checks/check_php_build.php'); # check for support for PHP modules and database connection |
|
4 | -define("TOOLKIT_PATH", '/var/www/html/phpipam/functions/php-saml/'); |
|
5 | -require_once(TOOLKIT_PATH . '_toolkit_loader.php'); // We load the SAML2 lib |
|
3 | +include('functions/checks/check_php_build.php'); # check for support for PHP modules and database connection |
|
4 | +define ("TOOLKIT_PATH", '/var/www/html/phpipam/functions/php-saml/'); |
|
5 | +require_once(TOOLKIT_PATH.'_toolkit_loader.php'); // We load the SAML2 lib |
|
6 | 6 | |
7 | 7 | //get SAML2 settings from db |
8 | -$dbobj=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
|
9 | -if(!$dbobj){ |
|
8 | +$dbobj = $Tools->fetch_object ("usersAuthMethod", "type", "SAML2"); |
|
9 | +if (!$dbobj) { |
|
10 | 10 | echo "SAML settings not found in database"; |
11 | 11 | die(); |
12 | 12 | } |
13 | 13 | //decode authentication module params |
14 | -$params=json_decode($dbobj->params); |
|
14 | +$params = json_decode ($dbobj->params); |
|
15 | 15 | //if using advanced settings, instantiate without db settings |
16 | -if($params->advanced=="1"){ |
|
17 | - $auth = new OneLogin_Saml2_Auth(); |
|
18 | -}else{ |
|
16 | +if ($params->advanced == "1") { |
|
17 | + $auth = new OneLogin_Saml2_Auth (); |
|
18 | +} else { |
|
19 | 19 | |
20 | 20 | $settings = array ( |
21 | 21 | 'sp' => array ( |
22 | - 'entityId' => $Tools->createURL(), |
|
22 | + 'entityId' => $Tools->createURL (), |
|
23 | 23 | 'assertionConsumerService' => array ( |
24 | - 'url' => $Tools->createURL()."/saml2", |
|
24 | + 'url' => $Tools->createURL ()."/saml2", |
|
25 | 25 | ), |
26 | 26 | 'singleLogoutService' => array ( |
27 | - 'url' => $Tools->createURL(), |
|
27 | + 'url' => $Tools->createURL (), |
|
28 | 28 | ), |
29 | 29 | 'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified', |
30 | 30 | ), |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | 'certFingerprintAlgorithm' => $params->idpcertalgorithm, |
41 | 41 | ), |
42 | 42 | ); |
43 | - $auth = new OneLogin_Saml2_Auth($settings); |
|
43 | + $auth = new OneLogin_Saml2_Auth ($settings); |
|
44 | 44 | } |
45 | 45 | //if SAMLResponse is not in the request, create an authnrequest and send it to the idp |
46 | -if(!isset($_POST["SAMLResponse"])){ |
|
47 | - $ssoBuiltUrl = $auth->login(null, array(), false, false, true); |
|
48 | - $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); |
|
49 | - header('Pragma: no-cache'); |
|
50 | - header('Cache-Control: no-cache, must-revalidate'); |
|
51 | - header('Location: ' . $ssoBuiltUrl); |
|
46 | +if (!isset($_POST["SAMLResponse"])) { |
|
47 | + $ssoBuiltUrl = $auth->login (null, array (), false, false, true); |
|
48 | + $_SESSION['AuthNRequestID'] = $auth->getLastRequestID (); |
|
49 | + header ('Pragma: no-cache'); |
|
50 | + header ('Cache-Control: no-cache, must-revalidate'); |
|
51 | + header ('Location: '.$ssoBuiltUrl); |
|
52 | 52 | exit(); |
53 | -}else{ |
|
53 | +} else { |
|
54 | 54 | //process the authentication response |
55 | 55 | if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { |
56 | 56 | $requestID = $_SESSION['AuthNRequestID']; |
@@ -58,24 +58,24 @@ discard block |
||
58 | 58 | $requestID = null; |
59 | 59 | } |
60 | 60 | |
61 | - $auth->processResponse($requestID); |
|
61 | + $auth->processResponse ($requestID); |
|
62 | 62 | |
63 | - $errors = $auth->getErrors(); |
|
63 | + $errors = $auth->getErrors (); |
|
64 | 64 | |
65 | 65 | if (!empty($errors)) { |
66 | - print_r('<p>'.implode(', ', $errors).'</p>'); |
|
66 | + print_r ('<p>'.implode (', ', $errors).'</p>'); |
|
67 | 67 | exit(); |
68 | 68 | } |
69 | 69 | |
70 | - if (!$auth->isAuthenticated()) { |
|
70 | + if (!$auth->isAuthenticated ()) { |
|
71 | 71 | echo "<p>Not authenticated</p>"; |
72 | 72 | exit(); |
73 | 73 | } |
74 | 74 | |
75 | 75 | // try to authenticate in phpipam |
76 | - $User->authenticate ($auth->getNameId(), ''); |
|
76 | + $User->authenticate ($auth->getNameId (), ''); |
|
77 | 77 | // Redirect user where he came from, if unknown go to dashboard. |
78 | - if( isset($_COOKIE['phpipamredirect']) ) { header("Location: ".$_COOKIE['phpipamredirect']); } |
|
79 | - else { header("Location: ".create_link("dashboard")); } |
|
78 | + if (isset($_COOKIE['phpipamredirect'])) { header ("Location: ".$_COOKIE['phpipamredirect']); } |
|
79 | + else { header ("Location: ".create_link ("dashboard")); } |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -6,16 +6,17 @@ discard block |
||
6 | 6 | |
7 | 7 | //get SAML2 settings from db |
8 | 8 | $dbobj=$Tools->fetch_object("usersAuthMethod", "type", "SAML2"); |
9 | -if(!$dbobj){ |
|
9 | +if(!$dbobj) { |
|
10 | 10 | echo "SAML settings not found in database"; |
11 | 11 | die(); |
12 | 12 | } |
13 | 13 | //decode authentication module params |
14 | 14 | $params=json_decode($dbobj->params); |
15 | 15 | //if using advanced settings, instantiate without db settings |
16 | -if($params->advanced=="1"){ |
|
16 | +if($params->advanced=="1") { |
|
17 | 17 | $auth = new OneLogin_Saml2_Auth(); |
18 | -}else{ |
|
18 | +} |
|
19 | +else { |
|
19 | 20 | |
20 | 21 | $settings = array ( |
21 | 22 | 'sp' => array ( |
@@ -43,18 +44,20 @@ discard block |
||
43 | 44 | $auth = new OneLogin_Saml2_Auth($settings); |
44 | 45 | } |
45 | 46 | //if SAMLResponse is not in the request, create an authnrequest and send it to the idp |
46 | -if(!isset($_POST["SAMLResponse"])){ |
|
47 | +if(!isset($_POST["SAMLResponse"])) { |
|
47 | 48 | $ssoBuiltUrl = $auth->login(null, array(), false, false, true); |
48 | 49 | $_SESSION['AuthNRequestID'] = $auth->getLastRequestID(); |
49 | 50 | header('Pragma: no-cache'); |
50 | 51 | header('Cache-Control: no-cache, must-revalidate'); |
51 | 52 | header('Location: ' . $ssoBuiltUrl); |
52 | 53 | exit(); |
53 | -}else{ |
|
54 | +} |
|
55 | +else { |
|
54 | 56 | //process the authentication response |
55 | 57 | if (isset($_SESSION) && isset($_SESSION['AuthNRequestID'])) { |
56 | 58 | $requestID = $_SESSION['AuthNRequestID']; |
57 | - } else { |
|
59 | + } |
|
60 | + else { |
|
58 | 61 | $requestID = null; |
59 | 62 | } |
60 | 63 |