Skip to content

Commit 52d583d

Browse files
committed
Improvements to the code
1 parent b7351b5 commit 52d583d

16 files changed

Lines changed: 52 additions & 54 deletions

File tree

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Build Status](https://api.travis-ci.org/onelogin/php-saml.png?branch=master)](http://travis-ci.org/onelogin/php-saml) [![Coverage Status](https://coveralls.io/repos/onelogin/php-saml/badge.png)](https://coveralls.io/r/onelogin/php-saml) [![License](https://poser.pugx.org/onelogin/php-saml/license.png)](https://packagist.org/packages/onelogin/php-saml)
44

5-
Add SAML support to your PHP softwares using this library.
6-
Forget those complicated libraries and use that open source library provided
5+
Add SAML support to your PHP software using this library.
6+
Forget those complicated libraries and use this open source library provided
77
and supported by OneLogin Inc.
88

99

@@ -688,7 +688,7 @@ unset($_SESSION['AuthNRequestID']);
688688
$errors = $auth->getErrors();
689689

690690
if (!empty($errors)) {
691-
print_r('<p>'.implode(', ', $errors).'</p>');
691+
echo '<p>' . implode(', ', $errors) . '</p>';
692692
exit();
693693
}
694694

@@ -712,8 +712,8 @@ $nameId = $_SESSION['samlNameId'];
712712
echo '<h1>Identified user: '. htmlentities($nameId) .'</h1>';
713713

714714
if (!empty($attributes)) {
715-
echo '<h2>'._('User attributes:').'</h2>';
716-
echo '<table><thead><th>'._('Name').'</th><th>'._('Values').'</th></thead><tbody>';
715+
echo '<h2>' . _('User attributes:') . '</h2>';
716+
echo '<table><thead><th>' . _('Name') . '</th><th>' . _('Values') . '</th></thead><tbody>';
717717
foreach ($attributes as $attributeName => $attributeValues) {
718718
echo '<tr><td>' . htmlentities($attributeName) . '</td><td><ul>';
719719
foreach ($attributeValues as $attributeValue) {
@@ -827,9 +827,9 @@ $auth->processSLO(false, $requestID);
827827
$errors = $auth->getErrors();
828828

829829
if (empty($errors)) {
830-
print_r('Sucessfully logged out');
830+
echo 'Sucessfully logged out';
831831
} else {
832-
print_r(implode(', ', $errors));
832+
echo implode(', ', $errors);
833833
}
834834
```
835835

@@ -971,7 +971,7 @@ if (isset($_SESSION['samlNameIdFormat'])) {
971971
$nameIdFormat = $_SESSION['samlNameIdFormat'];
972972
}
973973
$auth->logout($returnTo, $paramters, $nameId, $sessionIndex, false, $nameIdFormat);
974-
```
974+
```
975975

976976
If a match on the future LogoutResponse ID and the LogoutRequest ID to be sent is required, that LogoutRequest ID must to be extracted and stored.
977977

@@ -999,8 +999,7 @@ session_start(); // Initialize the session, we do that because
999999
// Note that processResponse and processSLO
10001000
// methods could manipulate/close that session
10011001

1002-
require_once dirname(dirname(__FILE__)).'/_toolkit_loader.php'; // Load Saml2 and
1003-
// external libs
1002+
require_once dirname(__DIR__) . '/_toolkit_loader.php'; // Load Saml2 and xmlseclibs
10041003
require_once 'settings.php'; // Load the setting info as an Array
10051004

10061005
$auth = new OneLogin_Saml2_Auth($settingsInfo); // Initialize the SP SAML instance
@@ -1021,11 +1020,11 @@ if (isset($_GET['sso'])) { // SSO action. Will send an AuthNRequest to the I
10211020
// that could took place during the process
10221021

10231022
if (!empty($errors)) {
1024-
print_r('<p>'.implode(', ', $errors).'</p>');
1023+
echo '<p>' . implode(', ', $errors) . '</p>';
10251024
}
10261025
// This check if the response was
10271026
if (!$auth->isAuthenticated()) { // sucessfully validated and the user
1028-
echo "<p>Not authenticated</p>"; // data retrieved or not
1027+
echo '<p>Not authenticated</p>'; // data retrieved or not
10291028
exit();
10301029
}
10311030

@@ -1037,9 +1036,9 @@ if (isset($_GET['sso'])) { // SSO action. Will send an AuthNRequest to the I
10371036
$auth->processSLO(); // Process the Logout Request & Logout Response
10381037
$errors = $auth->getErrors(); // Retrieves possible validation errors
10391038
if (empty($errors)) {
1040-
print_r('<p>Sucessfully logged out</p>');
1039+
echo '<p>Sucessfully logged out</p>';
10411040
} else {
1042-
print_r('<p>'.implode(', ', $errors).'</p>');
1041+
echo '<p>' . implode(', ', $errors) . '</p>';
10431042
}
10441043
}
10451044

_toolkit_loader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
// Create an __autoload function
3+
// Create an __autoload function
44
// (can conflicts other autoloaders)
55
// http://php.net/manual/en/language.oop5.autoload.php
66

@@ -21,7 +21,7 @@
2121

2222

2323
// Load php-saml
24-
$libDir = dirname(__FILE__) . '/lib/Saml2/';
24+
$libDir = __DIR__ . '/lib/Saml2/';
2525

2626
$folderInfo = scandir($libDir);
2727

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "OneLogin PHP SAML Toolkit",
44
"license": "MIT",
55
"version": "3.0.0",
6-
"homepage": "https://onelogin.zendesk.com/hc/en-us/sections/200245634-SAML-Toolkits",
6+
"homepage": "https://developers.onelogin.com/saml/php",
77
"keywords": ["saml", "saml2", "onelogin"],
88
"autoload": {
99
"classmap": [

demo1/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
session_start();
88

9-
require_once dirname(dirname(__FILE__)).'/_toolkit_loader.php';
9+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1010

1111
require_once 'settings.php';
1212

@@ -65,11 +65,11 @@
6565
$errors = $auth->getErrors();
6666

6767
if (!empty($errors)) {
68-
print_r('<p>'.implode(', ', $errors).'</p>');
68+
echo '<p>' . implode(', ', $errors) . '</p>';
6969
}
7070

7171
if (!$auth->isAuthenticated()) {
72-
echo "<p>Not authenticated</p>";
72+
echo '<p>Not authenticated</p>';
7373
exit();
7474
}
7575

@@ -91,9 +91,9 @@
9191
$auth->processSLO(false, $requestID);
9292
$errors = $auth->getErrors();
9393
if (empty($errors)) {
94-
print_r('<p>Sucessfully logged out</p>');
94+
echo '<p>Sucessfully logged out</p>';
9595
} else {
96-
print_r('<p>'.implode(', ', $errors).'</p>');
96+
echo '<p>' . implode(', ', $errors) . '</p>';
9797
}
9898
}
9999

demo1/metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SAML Metadata view
55
*/
66

7-
require_once dirname(dirname(__FILE__)).'/_toolkit_loader.php';
7+
require_once dirname(__DIR__).'/_toolkit_loader.php';
88

99
require_once 'settings.php' ;
1010

demo2/consume.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
error_reporting(E_ALL);
1111

12-
require_once '../_toolkit_loader.php';
12+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1313

1414
try {
1515
if (isset($_POST['SAMLResponse'])) {

demo2/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
session_start();
1212

13-
require_once '../_toolkit_loader.php';
13+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1414

1515
if (!isset($_SESSION['samlUserdata'])) {
1616
$settings = new OneLogin_Saml2_Settings();

demo2/metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
error_reporting(E_ALL);
1010

11-
require_once '../_toolkit_loader.php';
11+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1212

1313
header('Content-Type: text/xml');
1414

demo2/slo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
session_start();
1010

11-
require_once '../_toolkit_loader.php';
11+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1212

1313
$samlSettings = new OneLogin_Saml2_Settings();
1414

demo2/sso.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
session_start();
1212

13-
require_once '../_toolkit_loader.php';
13+
require_once dirname(__DIR__).'/_toolkit_loader.php';
1414

1515
$auth = new OneLogin_Saml2_Auth();
1616

0 commit comments

Comments
 (0)