Passed
Push — 1.10.x ( d9a04b...aeb152 )
by Yannick
123:06 queued 74:04
created
main/auth/cas/logout.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,5 +9,5 @@
 block discarded – undo
9 9
 require_once('authcas.php');
10 10
 global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
11 11
 
12
-phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
12
+phpCAS::client($cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri);
13 13
 phpCAS::logout();
Please login to merge, or discard this patch.
main/auth/cas/authcas.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
     }
42 42
 
43 43
 	if (!is_object($PHPCAS_CLIENT)) {
44
-		phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
44
+		phpCAS::client($cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri);
45 45
 		phpCAS::setNoCasServerValidation();
46 46
 	}
47 47
 	$auth = phpCAS::checkAuthentication();
48 48
 
49 49
 	if ($auth) {
50
-		$login= trim(phpCAS::getUser());
50
+		$login = trim(phpCAS::getUser());
51 51
 		/*
52 52
 		   Get user  attributes. Here are the attributes for crdp platform
53 53
 		   sn => name
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			default:
80 80
 				$status=5; // Student
81 81
 		}*/
82
-		if (!$logout){
82
+		if (!$logout) {
83 83
 		    // get user info from username
84 84
 		    $tab_user_info = api_get_user_info($login);
85 85
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                         $chamilo_user = extldap_get_chamilo_user($ldapuser);
93 93
                         $chamilo_user['user_id'] = $tab_user_info['user_id'];
94 94
                         $chamilo_user['status'] = $tab_user_info['status'];
95
-        				UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ;
95
+        				UserManager::update_user($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null, '');
96 96
 		            }
97 97
 		        }
98 98
 		        return $login;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		            case PLATFORM_AUTH_SOURCE :
106 106
 		                // user will have to modify firstname, lastname, email in chamilo profil edit
107 107
 		                $userdata = get_lang("EditInProfil");
108
-          				UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE);
108
+          				UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '', '', '', '', CAS_AUTH_SOURCE);
109 109
           				$user_added = $login;
110 110
 		                break;
111 111
 		            case LDAP_AUTH_SOURCE :
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @see online_logout()
165 165
  */
166
-function cas_logout($uinfo=null, $location=null)
166
+function cas_logout($uinfo = null, $location = null)
167 167
 {
168 168
     global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
169 169
     global $PHPCAS_CLIENT;
Please login to merge, or discard this patch.
main/auth/cas/logincas.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         $firstpage = $_GET['firstpage'];
40 40
         setcookie("GotoCourse", $firstpage);
41 41
     }
42
-    if (!is_object($PHPCAS_CLIENT) ) {
42
+    if (!is_object($PHPCAS_CLIENT)) {
43 43
         phpCAS::client(
44 44
             $cas_auth_ver,
45 45
             $cas_auth_server,
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-file.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
    *
132 132
    * @public
133 133
    */
134
-  function PGTStorageFile($cas_parent,$format,$path)
134
+  function PGTStorageFile($cas_parent, $format, $path)
135 135
     {
136 136
       phpCAS::traceBegin();
137 137
       // call the ancestor's constructor
138 138
       $this->PGTStorage($cas_parent);
139 139
 
140
-      if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
-      if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
140
+      if (empty($format)) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT;
141
+      if (empty($path)) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH;
142 142
 
143 143
       // check that the path is an absolute path
144
-      if (getenv("OS")=="Windows_NT"){
144
+      if (getenv("OS") == "Windows_NT") {
145 145
       	
146 146
       	 if (!preg_match('`^[a-zA-Z]:`', $path)) {
147 147
 	     	phpCAS::error('an absolute path is needed for PGT storage to file');
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
       else
152 152
       {
153 153
       
154
-      	if ( $path[0] != '/' ) {
154
+      	if ($path[0] != '/') {
155 155
 			phpCAS::error('an absolute path is needed for PGT storage to file');
156 156
       	}
157 157
 
158 158
       	// store the path (with a leading and trailing '/')      
159
-      	$path = preg_replace('|[/]*$|','/',$path);
160
-      	$path = preg_replace('|^[/]*|','/',$path);
159
+      	$path = preg_replace('|[/]*$|', '/', $path);
160
+      	$path = preg_replace('|^[/]*|', '/', $path);
161 161
       }
162 162
       
163 163
       $this->_path = $path;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
     {
187 187
       phpCAS::traceBegin();
188 188
       // if the storage has already been initialized, return immediatly
189
-      if ( $this->isInitialized() )
189
+      if ($this->isInitialized())
190 190
 	return;
191 191
       // call the ancestor's method (mark as initialized)
192 192
       parent::init();
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
    *
223 223
    * @public
224 224
    */
225
-  function write($pgt,$pgt_iou)
225
+  function write($pgt, $pgt_iou)
226 226
     {
227 227
       phpCAS::traceBegin();
228 228
       $fname = $this->getPGTIouFilename($pgt_iou);
229
-      if ( $f=fopen($fname,"w") ) {
230
-	if ( fputs($f,$pgt) === FALSE ) {
229
+      if ($f = fopen($fname, "w")) {
230
+	if (fputs($f, $pgt) === FALSE) {
231 231
 	  phpCAS::error('could not write PGT to `'.$fname.'\'');
232 232
 	}
233 233
 	fclose($f);
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
       phpCAS::traceBegin();
253 253
       $pgt = FALSE;
254 254
       $fname = $this->getPGTIouFilename($pgt_iou);
255
-      if ( !($f=fopen($fname,"r")) ) {
255
+      if (!($f = fopen($fname, "r"))) {
256 256
 	phpCAS::trace('could not open `'.$fname.'\'');
257 257
       } else {
258
-	if ( ($pgt=fgets($f)) === FALSE ) {
258
+	if (($pgt = fgets($f)) === FALSE) {
259 259
 	  phpCAS::trace('could not read PGT from `'.$fname.'\'');
260 260
 	} 
261 261
 	fclose($f);
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-db.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
    * @hideinitializer
58 58
    * @private
59 59
    */
60
-  var $_url='';
60
+  var $_url = '';
61 61
 
62 62
   /**
63 63
    * This method returns the PEAR DB URL to use to connect to the database.
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
    *
160 160
    * @public
161 161
    */
162
-  function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
162
+  function PGTStorageDB($cas_parent, $user, $password, $database_type, $hostname, $port, $database, $table)
163 163
     {
164 164
       phpCAS::traceBegin();
165 165
 
166 166
       // call the ancestor's constructor
167 167
       $this->PGTStorage($cas_parent);
168 168
 
169
-      if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
-      if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
-      if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
-      if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
-      if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
169
+      if (empty($database_type)) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
170
+      if (empty($hostname)) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
171
+      if ($port == 0) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
172
+      if (empty($database)) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
173
+      if (empty($table)) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
174 174
 
175 175
       // build and store the PEAR DB URL
176 176
       $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$hostname.':'.$port.'/'.$database;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     {
193 193
       phpCAS::traceBegin();
194 194
       // if the storage has already been initialized, return immediatly
195
-      if ( $this->isInitialized() )
195
+      if ($this->isInitialized())
196 196
 		return;
197 197
       // call the ancestor's method (mark as initialized)
198 198
       parent::init();
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
       // try to connect to the database
207 207
       $this->_link = DB::connect($this->getURL());
208
-      if ( DB::isError($this->_link) ) {
208
+      if (DB::isError($this->_link)) {
209 209
 	phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
210 210
       }
211 211
       var_dump($this->_link);
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/PGTStorage/pgt-main.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   function PGTStorage($cas_parent)
64 64
     {
65 65
       phpCAS::traceBegin();
66
-      if ( !$cas_parent->isProxy() ) {
66
+      if (!$cas_parent->isProxy()) {
67 67
 	phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy'); 
68 68
       }
69 69
       phpCAS::traceEnd();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
    * @private
108 108
    * @deprecated not used.
109 109
    */
110
-  var $_error_message=FALSE;
110
+  var $_error_message = FALSE;
111 111
 
112 112
   /**
113 113
    * This method sets en error message, which can be read later by 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
    *
186 186
    * @protected
187 187
    */
188
-  function write($pgt,$pgt_iou)
188
+  function write($pgt, $pgt_iou)
189 189
     {
190 190
       phpCAS::error(__CLASS__.'::'.__FUNCTION__.'() should never be called'); 
191 191
     }
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/languages/languages.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 /**
13 13
  * a phpCAS string index
14 14
  */
15
-define("CAS_STR_USING_SERVER",                1);
16
-define("CAS_STR_AUTHENTICATION_WANTED",       2);
17
-define("CAS_STR_LOGOUT",                      3);
15
+define("CAS_STR_USING_SERVER", 1);
16
+define("CAS_STR_AUTHENTICATION_WANTED", 2);
17
+define("CAS_STR_LOGOUT", 3);
18 18
 define("CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED", 4);
19
-define("CAS_STR_AUTHENTICATION_FAILED",       5);
20
-define("CAS_STR_YOU_WERE_NOT_AUTHENTICATED",  6);
21
-define("CAS_STR_SERVICE_UNAVAILABLE",         7);
19
+define("CAS_STR_AUTHENTICATION_FAILED", 5);
20
+define("CAS_STR_YOU_WERE_NOT_AUTHENTICATED", 6);
21
+define("CAS_STR_SERVICE_UNAVAILABLE", 7);
22 22
 //@}
23 23
 
24 24
 ?>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/domxml-php4-to-php5.php 1 patch
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -42,178 +42,178 @@  discard block
 block discarded – undo
42 42
 	http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/
43 43
 */
44 44
 
45
-define('DOMXML_LOAD_PARSING',0);
46
-define('DOMXML_LOAD_VALIDATING',1);
47
-define('DOMXML_LOAD_RECOVERING',2);
48
-define('DOMXML_LOAD_SUBSTITUTE_ENTITIES',4);
45
+define('DOMXML_LOAD_PARSING', 0);
46
+define('DOMXML_LOAD_VALIDATING', 1);
47
+define('DOMXML_LOAD_RECOVERING', 2);
48
+define('DOMXML_LOAD_SUBSTITUTE_ENTITIES', 4);
49 49
 //define('DOMXML_LOAD_COMPLETE_ATTRS',8);
50
-define('DOMXML_LOAD_DONT_KEEP_BLANKS',16);
50
+define('DOMXML_LOAD_DONT_KEEP_BLANKS', 16);
51 51
 
52
-function domxml_new_doc($version) {return new php4DOMDocument();}
53
-function domxml_new_xmldoc($version) {return new php4DOMDocument();}
54
-function domxml_open_file($filename,$mode=DOMXML_LOAD_PARSING,&$error=null)
52
+function domxml_new_doc($version) {return new php4DOMDocument(); }
53
+function domxml_new_xmldoc($version) {return new php4DOMDocument(); }
54
+function domxml_open_file($filename, $mode = DOMXML_LOAD_PARSING, &$error = null)
55 55
 {
56
-	$dom=new php4DOMDocument($mode);
57
-	$errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION');
56
+	$dom = new php4DOMDocument($mode);
57
+	$errorMode = (func_num_args() > 2) && defined('LIBXML_VERSION');
58 58
 	if ($errorMode) libxml_use_internal_errors(true);
59
-	if (!$dom->myDOMNode->load($filename)) $dom=null;
59
+	if (!$dom->myDOMNode->load($filename)) $dom = null;
60 60
 	if ($errorMode)
61 61
 	{
62
-		$error=array_map('_error_report',libxml_get_errors());
62
+		$error = array_map('_error_report', libxml_get_errors());
63 63
 		libxml_clear_errors();
64 64
 	}
65 65
 	return $dom;
66 66
 }
67
-function domxml_open_mem($str,$mode=DOMXML_LOAD_PARSING,&$error=null)
67
+function domxml_open_mem($str, $mode = DOMXML_LOAD_PARSING, &$error = null)
68 68
 {
69
-	$dom=new php4DOMDocument($mode);
70
-	$errorMode=(func_num_args()>2)&&defined('LIBXML_VERSION');
69
+	$dom = new php4DOMDocument($mode);
70
+	$errorMode = (func_num_args() > 2) && defined('LIBXML_VERSION');
71 71
 	if ($errorMode) libxml_use_internal_errors(true);
72
-	if (!$dom->myDOMNode->loadXML($str)) $dom=null;
72
+	if (!$dom->myDOMNode->loadXML($str)) $dom = null;
73 73
 	if ($errorMode)
74 74
 	{
75
-		$error=array_map('_error_report',libxml_get_errors());
75
+		$error = array_map('_error_report', libxml_get_errors());
76 76
 		libxml_clear_errors();
77 77
 	}
78 78
 	return $dom;
79 79
 }
80
-function html_doc($html_doc,$from_file=false)
80
+function html_doc($html_doc, $from_file = false)
81 81
 {
82
-	$dom=new php4DOMDocument();
83
-	if ($from_file) $result=$dom->myDOMNode->loadHTMLFile($html_doc);
84
-	else $result=$dom->myDOMNode->loadHTML($html_doc);
82
+	$dom = new php4DOMDocument();
83
+	if ($from_file) $result = $dom->myDOMNode->loadHTMLFile($html_doc);
84
+	else $result = $dom->myDOMNode->loadHTML($html_doc);
85 85
 	return $result ? $dom : null;
86 86
 }
87
-function html_doc_file($filename) {return html_doc($filename,true);}
88
-function xmldoc($str) {return domxml_open_mem($str);}
89
-function xmldocfile($filename) {return domxml_open_file($filename);}
90
-function xpath_eval($xpath_context,$eval_str,$contextnode=null) {return $xpath_context->xpath_eval($eval_str,$contextnode);}
91
-function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document);}
92
-function xpath_register_ns($xpath_context,$prefix,$namespaceURI) {return $xpath_context->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
93
-function _entityDecode($text) {return html_entity_decode(strtr($text,array('''=>'\'')),ENT_QUOTES,'UTF-8');}
94
-function _error_report($error) {return array('errormessage'=>$error->message,'nodename'=>'','line'=>$error->line,'col'=>$error->column)+($error->file==''?array():array('directory'=>dirname($error->file),'file'=>basename($error->file)));}
87
+function html_doc_file($filename) {return html_doc($filename, true); }
88
+function xmldoc($str) {return domxml_open_mem($str); }
89
+function xmldocfile($filename) {return domxml_open_file($filename); }
90
+function xpath_eval($xpath_context, $eval_str, $contextnode = null) {return $xpath_context->xpath_eval($eval_str, $contextnode); }
91
+function xpath_new_context($dom_document) {return new php4DOMXPath($dom_document); }
92
+function xpath_register_ns($xpath_context, $prefix, $namespaceURI) {return $xpath_context->myDOMXPath->registerNamespace($prefix, $namespaceURI); }
93
+function _entityDecode($text) {return html_entity_decode(strtr($text, array('''=>'\'')), ENT_QUOTES, 'UTF-8'); }
94
+function _error_report($error) {return array('errormessage'=>$error->message, 'nodename'=>'', 'line'=>$error->line, 'col'=>$error->column) + ($error->file == '' ? array() : array('directory'=>dirname($error->file), 'file'=>basename($error->file))); }
95 95
 
96 96
 class php4DOMAttr extends php4DOMNode
97 97
 {
98 98
 	function __get($name)
99 99
 	{
100
-		if ($name==='name') return $this->myDOMNode->name;
100
+		if ($name === 'name') return $this->myDOMNode->name;
101 101
 		else return parent::__get($name);
102 102
 	}
103
-	function name() {return $this->myDOMNode->name;}
103
+	function name() {return $this->myDOMNode->name; }
104 104
 	function set_content($text) {}
105 105
 	//function set_value($content) {return $this->myDOMNode->value=htmlspecialchars($content,ENT_QUOTES);}
106
-	function specified() {return $this->myDOMNode->specified;}
107
-	function value() {return $this->myDOMNode->value;}
106
+	function specified() {return $this->myDOMNode->specified; }
107
+	function value() {return $this->myDOMNode->value; }
108 108
 }
109 109
 
110 110
 class php4DOMDocument extends php4DOMNode
111 111
 {
112
-	function php4DOMDocument($mode=DOMXML_LOAD_PARSING)
112
+	function php4DOMDocument($mode = DOMXML_LOAD_PARSING)
113 113
 	{
114
-		$this->myDOMNode=new DOMDocument();
115
-		$this->myOwnerDocument=$this;
116
-		if ($mode & DOMXML_LOAD_VALIDATING) $this->myDOMNode->validateOnParse=true;
117
-		if ($mode & DOMXML_LOAD_RECOVERING) $this->myDOMNode->recover=true;
118
-		if ($mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) $this->myDOMNode->substituteEntities=true;
119
-		if ($mode & DOMXML_LOAD_DONT_KEEP_BLANKS) $this->myDOMNode->preserveWhiteSpace=false;
114
+		$this->myDOMNode = new DOMDocument();
115
+		$this->myOwnerDocument = $this;
116
+		if ($mode & DOMXML_LOAD_VALIDATING) $this->myDOMNode->validateOnParse = true;
117
+		if ($mode & DOMXML_LOAD_RECOVERING) $this->myDOMNode->recover = true;
118
+		if ($mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) $this->myDOMNode->substituteEntities = true;
119
+		if ($mode & DOMXML_LOAD_DONT_KEEP_BLANKS) $this->myDOMNode->preserveWhiteSpace = false;
120 120
 	}
121 121
 	function add_root($name)
122 122
 	{
123 123
 		if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
124
-		return new php4DOMElement($this->myDOMNode->appendChild($this->myDOMNode->createElement($name)),$this->myOwnerDocument);
124
+		return new php4DOMElement($this->myDOMNode->appendChild($this->myDOMNode->createElement($name)), $this->myOwnerDocument);
125 125
 	}
126
-	function create_attribute($name,$value)
126
+	function create_attribute($name, $value)
127 127
 	{
128
-		$myAttr=$this->myDOMNode->createAttribute($name);
129
-		$myAttr->value=htmlspecialchars($value,ENT_QUOTES);
130
-		return new php4DOMAttr($myAttr,$this);
128
+		$myAttr = $this->myDOMNode->createAttribute($name);
129
+		$myAttr->value = htmlspecialchars($value, ENT_QUOTES);
130
+		return new php4DOMAttr($myAttr, $this);
131 131
 	}
132
-	function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);}
133
-	function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data),$this);}
134
-	function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name),$this);}
135
-	function create_element_ns($uri,$name,$prefix=null)
132
+	function create_cdata_section($content) {return new php4DOMNode($this->myDOMNode->createCDATASection($content), $this); }
133
+	function create_comment($data) {return new php4DOMNode($this->myDOMNode->createComment($data), $this); }
134
+	function create_element($name) {return new php4DOMElement($this->myDOMNode->createElement($name), $this); }
135
+	function create_element_ns($uri, $name, $prefix = null)
136 136
 	{
137
-		if ($prefix==null) $prefix=$this->myDOMNode->lookupPrefix($uri);
138
-		if (($prefix==null)&&(($this->myDOMNode->documentElement==null)||(!$this->myDOMNode->documentElement->isDefaultNamespace($uri)))) $prefix='a'.sprintf('%u',crc32($uri));
139
-		return new php4DOMElement($this->myDOMNode->createElementNS($uri,$prefix==null ? $name : $prefix.':'.$name),$this);
137
+		if ($prefix == null) $prefix = $this->myDOMNode->lookupPrefix($uri);
138
+		if (($prefix == null) && (($this->myDOMNode->documentElement == null) || (!$this->myDOMNode->documentElement->isDefaultNamespace($uri)))) $prefix = 'a'.sprintf('%u', crc32($uri));
139
+		return new php4DOMElement($this->myDOMNode->createElementNS($uri, $prefix == null ? $name : $prefix.':'.$name), $this);
140 140
 	}
141
-	function create_entity_reference($content) {return new php4DOMNode($this->myDOMNode->createEntityReference($content),$this);} //By Walter Ebert 2007-01-22
142
-	function create_processing_instruction($target,$data=''){return new php4DomProcessingInstruction($this->myDOMNode->createProcessingInstruction($target,$data),$this);}
143
-	function create_text_node($content) {return new php4DOMText($this->myDOMNode->createTextNode($content),$this);}
144
-	function document_element() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
145
-	function dump_file($filename,$compressionmode=false,$format=false)
141
+	function create_entity_reference($content) {return new php4DOMNode($this->myDOMNode->createEntityReference($content), $this); } //By Walter Ebert 2007-01-22
142
+	function create_processing_instruction($target, $data = '') {return new php4DomProcessingInstruction($this->myDOMNode->createProcessingInstruction($target, $data), $this); }
143
+	function create_text_node($content) {return new php4DOMText($this->myDOMNode->createTextNode($content), $this); }
144
+	function document_element() {return parent::_newDOMElement($this->myDOMNode->documentElement, $this); }
145
+	function dump_file($filename, $compressionmode = false, $format = false)
146 146
 	{
147
-		$format0=$this->myDOMNode->formatOutput;
148
-		$this->myDOMNode->formatOutput=$format;
149
-		$res=$this->myDOMNode->save($filename);
150
-		$this->myDOMNode->formatOutput=$format0;
147
+		$format0 = $this->myDOMNode->formatOutput;
148
+		$this->myDOMNode->formatOutput = $format;
149
+		$res = $this->myDOMNode->save($filename);
150
+		$this->myDOMNode->formatOutput = $format0;
151 151
 		return $res;
152 152
 	}
153
-	function dump_mem($format=false,$encoding=false)
153
+	function dump_mem($format = false, $encoding = false)
154 154
 	{
155
-		$format0=$this->myDOMNode->formatOutput;
156
-		$this->myDOMNode->formatOutput=$format;
157
-		$encoding0=$this->myDOMNode->encoding;
158
-		if ($encoding) $this->myDOMNode->encoding=$encoding;
159
-		$dump=$this->myDOMNode->saveXML();
160
-		$this->myDOMNode->formatOutput=$format0;
161
-		if ($encoding) $this->myDOMNode->encoding= $encoding0=='' ? 'UTF-8' : $encoding0; //UTF-8 is XML default encoding
155
+		$format0 = $this->myDOMNode->formatOutput;
156
+		$this->myDOMNode->formatOutput = $format;
157
+		$encoding0 = $this->myDOMNode->encoding;
158
+		if ($encoding) $this->myDOMNode->encoding = $encoding;
159
+		$dump = $this->myDOMNode->saveXML();
160
+		$this->myDOMNode->formatOutput = $format0;
161
+		if ($encoding) $this->myDOMNode->encoding = $encoding0 == '' ? 'UTF-8' : $encoding0; //UTF-8 is XML default encoding
162 162
 		return $dump;
163 163
 	}
164 164
 	function free()
165 165
 	{
166 166
 		if ($this->myDOMNode->hasChildNodes()) $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
167
-		$this->myDOMNode=null;
168
-		$this->myOwnerDocument=null;
167
+		$this->myDOMNode = null;
168
+		$this->myOwnerDocument = null;
169 169
 	}
170
-	function get_element_by_id($id) {return parent::_newDOMElement($this->myDOMNode->getElementById($id),$this);}
170
+	function get_element_by_id($id) {return parent::_newDOMElement($this->myDOMNode->getElementById($id), $this); }
171 171
 	function get_elements_by_tagname($name)
172 172
 	{
173
-		$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
174
-		$nodeSet=array();
175
-		$i=0;
173
+		$myDOMNodeList = $this->myDOMNode->getElementsByTagName($name);
174
+		$nodeSet = array();
175
+		$i = 0;
176 176
 		if (isset($myDOMNodeList))
177
-			while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this);
177
+			while ($node = $myDOMNodeList->item($i++)) $nodeSet[] = new php4DOMElement($node, $this);
178 178
 		return $nodeSet;
179 179
 	}
180
-	function html_dump_mem() {return $this->myDOMNode->saveHTML();}
181
-	function root() {return parent::_newDOMElement($this->myDOMNode->documentElement,$this);}
182
-	function xinclude() {return $this->myDOMNode->xinclude();}
183
-	function xpath_new_context() {return new php4DOMXPath($this);}
180
+	function html_dump_mem() {return $this->myDOMNode->saveHTML(); }
181
+	function root() {return parent::_newDOMElement($this->myDOMNode->documentElement, $this); }
182
+	function xinclude() {return $this->myDOMNode->xinclude(); }
183
+	function xpath_new_context() {return new php4DOMXPath($this); }
184 184
 }
185 185
 
186 186
 class php4DOMElement extends php4DOMNode
187 187
 {
188
-	function add_namespace($uri,$prefix)
188
+	function add_namespace($uri, $prefix)
189 189
 	{
190
-		if ($this->myDOMNode->hasAttributeNS('http://www.w3.org/2000/xmlns/',$prefix)) return false;
190
+		if ($this->myDOMNode->hasAttributeNS('http://www.w3.org/2000/xmlns/', $prefix)) return false;
191 191
 		else
192 192
 		{
193
-			$this->myDOMNode->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$prefix,$uri); //By Daniel Walker 2006-09-08
193
+			$this->myDOMNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:'.$prefix, $uri); //By Daniel Walker 2006-09-08
194 194
 			return true;
195 195
 		}
196 196
 	}
197
-	function get_attribute($name) {return $this->myDOMNode->getAttribute($name);}
198
-	function get_attribute_node($name) {return parent::_newDOMElement($this->myDOMNode->getAttributeNode($name),$this->myOwnerDocument);}
197
+	function get_attribute($name) {return $this->myDOMNode->getAttribute($name); }
198
+	function get_attribute_node($name) {return parent::_newDOMElement($this->myDOMNode->getAttributeNode($name), $this->myOwnerDocument); }
199 199
 	function get_elements_by_tagname($name)
200 200
 	{
201
-		$myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
202
-		$nodeSet=array();
203
-		$i=0;
201
+		$myDOMNodeList = $this->myDOMNode->getElementsByTagName($name);
202
+		$nodeSet = array();
203
+		$i = 0;
204 204
 		if (isset($myDOMNodeList))
205
-			while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMElement($node,$this->myOwnerDocument);
205
+			while ($node = $myDOMNodeList->item($i++)) $nodeSet[] = new php4DOMElement($node, $this->myOwnerDocument);
206 206
 		return $nodeSet;
207 207
 	}
208
-	function has_attribute($name) {return $this->myDOMNode->hasAttribute($name);}
209
-	function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name);}
210
-	function set_attribute($name,$value)
208
+	function has_attribute($name) {return $this->myDOMNode->hasAttribute($name); }
209
+	function remove_attribute($name) {return $this->myDOMNode->removeAttribute($name); }
210
+	function set_attribute($name, $value)
211 211
 	{
212 212
 		//return $this->myDOMNode->setAttribute($name,$value); //Does not return a DomAttr
213
-		$myAttr=$this->myDOMNode->ownerDocument->createAttribute($name);
214
-		$myAttr->value=htmlspecialchars($value,ENT_QUOTES); //Entity problem reported by AL-DesignWorks 2007-09-07
213
+		$myAttr = $this->myDOMNode->ownerDocument->createAttribute($name);
214
+		$myAttr->value = htmlspecialchars($value, ENT_QUOTES); //Entity problem reported by AL-DesignWorks 2007-09-07
215 215
 		$this->myDOMNode->setAttributeNode($myAttr);
216
-		return new php4DOMAttr($myAttr,$this->myOwnerDocument);
216
+		return new php4DOMAttr($myAttr, $this->myOwnerDocument);
217 217
 	}
218 218
 	/*function set_attribute_node($attr)
219 219
 	{
@@ -222,186 +222,186 @@  discard block
 block discarded – undo
222 222
 	}*/
223 223
 	function set_name($name)
224 224
 	{
225
-		if ($this->myDOMNode->prefix=='') $newNode=$this->myDOMNode->ownerDocument->createElement($name);
226
-		else $newNode=$this->myDOMNode->ownerDocument->createElementNS($this->myDOMNode->namespaceURI,$this->myDOMNode->prefix.':'.$name);
227
-		$myDOMNodeList=$this->myDOMNode->attributes;
228
-		$i=0;
225
+		if ($this->myDOMNode->prefix == '') $newNode = $this->myDOMNode->ownerDocument->createElement($name);
226
+		else $newNode = $this->myDOMNode->ownerDocument->createElementNS($this->myDOMNode->namespaceURI, $this->myDOMNode->prefix.':'.$name);
227
+		$myDOMNodeList = $this->myDOMNode->attributes;
228
+		$i = 0;
229 229
 		if (isset($myDOMNodeList))
230
-			while ($node=$myDOMNodeList->item($i++))
231
-				if ($node->namespaceURI=='') $newNode->setAttribute($node->name,$node->value);
232
-				else $newNode->setAttributeNS($node->namespaceURI,$node->nodeName,$node->value);
233
-		$myDOMNodeList=$this->myDOMNode->childNodes;
230
+			while ($node = $myDOMNodeList->item($i++))
231
+				if ($node->namespaceURI == '') $newNode->setAttribute($node->name, $node->value);
232
+				else $newNode->setAttributeNS($node->namespaceURI, $node->nodeName, $node->value);
233
+		$myDOMNodeList = $this->myDOMNode->childNodes;
234 234
 		if (isset($myDOMNodeList))
235
-			while ($node=$myDOMNodeList->item(0)) $newNode->appendChild($node);
236
-		$this->myDOMNode->parentNode->replaceChild($newNode,$this->myDOMNode);
237
-		$this->myDOMNode=$newNode;
235
+			while ($node = $myDOMNodeList->item(0)) $newNode->appendChild($node);
236
+		$this->myDOMNode->parentNode->replaceChild($newNode, $this->myDOMNode);
237
+		$this->myDOMNode = $newNode;
238 238
 		return true;
239 239
 	}
240
-	function tagname() {return $this->tagname;}
240
+	function tagname() {return $this->tagname; }
241 241
 }
242 242
 
243 243
 class php4DOMNode
244 244
 {
245 245
 	public $myDOMNode;
246 246
 	public $myOwnerDocument;
247
-	function php4DOMNode($aDomNode,$aOwnerDocument)
247
+	function php4DOMNode($aDomNode, $aOwnerDocument)
248 248
 	{
249
-		$this->myDOMNode=$aDomNode;
250
-		$this->myOwnerDocument=$aOwnerDocument;
249
+		$this->myDOMNode = $aDomNode;
250
+		$this->myOwnerDocument = $aOwnerDocument;
251 251
 	}
252 252
 	function __get($name)
253 253
 	{
254 254
 		switch ($name)
255 255
 		{
256 256
 			case 'type': return $this->myDOMNode->nodeType;
257
-			case 'tagname': return ($this->myDOMNode->nodeType===XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->tagName; //Avoid namespace prefix for DOMElement
257
+			case 'tagname': return ($this->myDOMNode->nodeType === XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->tagName; //Avoid namespace prefix for DOMElement
258 258
 			case 'content': return $this->myDOMNode->textContent;
259 259
 			case 'value': return $this->myDOMNode->value;
260 260
 			default:
261
-				$myErrors=debug_backtrace();
262
-				trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']',E_USER_NOTICE);
261
+				$myErrors = debug_backtrace();
262
+				trigger_error('Undefined property: '.get_class($this).'::$'.$name.' ['.$myErrors[0]['file'].':'.$myErrors[0]['line'].']', E_USER_NOTICE);
263 263
 				return false;
264 264
 		}
265 265
 	}
266
-	function add_child($newnode) {return append_child($newnode);}
267
-	function add_namespace($uri,$prefix) {return false;}
268
-	function append_child($newnode) {return self::_newDOMElement($this->myDOMNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
269
-	function append_sibling($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->appendChild($this->_importNode($newnode)),$this->myOwnerDocument);}
266
+	function add_child($newnode) {return append_child($newnode); }
267
+	function add_namespace($uri, $prefix) {return false; }
268
+	function append_child($newnode) {return self::_newDOMElement($this->myDOMNode->appendChild($this->_importNode($newnode)), $this->myOwnerDocument); }
269
+	function append_sibling($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->appendChild($this->_importNode($newnode)), $this->myOwnerDocument); }
270 270
 	function attributes()
271 271
 	{
272
-		$myDOMNodeList=$this->myDOMNode->attributes;
273
-		if (!(isset($myDOMNodeList)&&$this->myDOMNode->hasAttributes())) return null;
274
-		$nodeSet=array();
275
-		$i=0;
276
-		while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=new php4DOMAttr($node,$this->myOwnerDocument);
272
+		$myDOMNodeList = $this->myDOMNode->attributes;
273
+		if (!(isset($myDOMNodeList) && $this->myDOMNode->hasAttributes())) return null;
274
+		$nodeSet = array();
275
+		$i = 0;
276
+		while ($node = $myDOMNodeList->item($i++)) $nodeSet[] = new php4DOMAttr($node, $this->myOwnerDocument);
277 277
 		return $nodeSet;
278 278
 	}
279 279
 	function child_nodes()
280 280
 	{
281
-		$myDOMNodeList=$this->myDOMNode->childNodes;
282
-		$nodeSet=array();
283
-		$i=0;
281
+		$myDOMNodeList = $this->myDOMNode->childNodes;
282
+		$nodeSet = array();
283
+		$i = 0;
284 284
 		if (isset($myDOMNodeList))
285
-			while ($node=$myDOMNodeList->item($i++)) $nodeSet[]=self::_newDOMElement($node,$this->myOwnerDocument);
285
+			while ($node = $myDOMNodeList->item($i++)) $nodeSet[] = self::_newDOMElement($node, $this->myOwnerDocument);
286 286
 		return $nodeSet;
287 287
 	}
288
-	function children() {return $this->child_nodes();}
289
-	function clone_node($deep=false) {return self::_newDOMElement($this->myDOMNode->cloneNode($deep),$this->myOwnerDocument);}
288
+	function children() {return $this->child_nodes(); }
289
+	function clone_node($deep = false) {return self::_newDOMElement($this->myDOMNode->cloneNode($deep), $this->myOwnerDocument); }
290 290
 	//dump_node($node) should only be called on php4DOMDocument
291
-	function dump_node($node=null) {return $node==null ? $this->myOwnerDocument->myDOMNode->saveXML($this->myDOMNode) : $this->myOwnerDocument->myDOMNode->saveXML($node->myDOMNode);}
292
-	function first_child() {return self::_newDOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);}
293
-	function get_content() {return $this->myDOMNode->textContent;}
294
-	function has_attributes() {return $this->myDOMNode->hasAttributes();}
295
-	function has_child_nodes() {return $this->myDOMNode->hasChildNodes();}
296
-	function insert_before($newnode,$refnode) {return self::_newDOMElement($this->myDOMNode->insertBefore($this->_importNode($newnode),$refnode==null?null:$refnode->myDOMNode),$this->myOwnerDocument);}
297
-	function is_blank_node() {return ($this->myDOMNode->nodeType===XML_TEXT_NODE)&&preg_match('%^\s*$%',$this->myDOMNode->nodeValue);}
298
-	function last_child() {return self::_newDOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);}
299
-	function new_child($name,$content)
291
+	function dump_node($node = null) {return $node == null ? $this->myOwnerDocument->myDOMNode->saveXML($this->myDOMNode) : $this->myOwnerDocument->myDOMNode->saveXML($node->myDOMNode); }
292
+	function first_child() {return self::_newDOMElement($this->myDOMNode->firstChild, $this->myOwnerDocument); }
293
+	function get_content() {return $this->myDOMNode->textContent; }
294
+	function has_attributes() {return $this->myDOMNode->hasAttributes(); }
295
+	function has_child_nodes() {return $this->myDOMNode->hasChildNodes(); }
296
+	function insert_before($newnode, $refnode) {return self::_newDOMElement($this->myDOMNode->insertBefore($this->_importNode($newnode), $refnode == null ? null : $refnode->myDOMNode), $this->myOwnerDocument); }
297
+	function is_blank_node() {return ($this->myDOMNode->nodeType === XML_TEXT_NODE) && preg_match('%^\s*$%', $this->myDOMNode->nodeValue); }
298
+	function last_child() {return self::_newDOMElement($this->myDOMNode->lastChild, $this->myOwnerDocument); }
299
+	function new_child($name, $content)
300 300
 	{
301
-		$mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
301
+		$mySubNode = $this->myDOMNode->ownerDocument->createElement($name);
302 302
 		$mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($content)));
303 303
 		$this->myDOMNode->appendChild($mySubNode);
304
-		return new php4DOMElement($mySubNode,$this->myOwnerDocument);
304
+		return new php4DOMElement($mySubNode, $this->myOwnerDocument);
305 305
 	}
306
-	function next_sibling() {return self::_newDOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);}
307
-	function node_name() {return ($this->myDOMNode->nodeType===XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->nodeName;} //Avoid namespace prefix for DOMElement
308
-	function node_type() {return $this->myDOMNode->nodeType;}
309
-	function node_value() {return $this->myDOMNode->nodeValue;}
310
-	function owner_document() {return $this->myOwnerDocument;}
311
-	function parent_node() {return self::_newDOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);}
312
-	function prefix() {return $this->myDOMNode->prefix;}
313
-	function previous_sibling() {return self::_newDOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);}
314
-	function remove_child($oldchild) {return self::_newDOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode),$this->myOwnerDocument);}
315
-	function replace_child($newnode,$oldnode) {return self::_newDOMElement($this->myDOMNode->replaceChild($this->_importNode($newnode),$oldnode->myDOMNode),$this->myOwnerDocument);}
316
-	function replace_node($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->replaceChild($this->_importNode($newnode),$this->myDOMNode),$this->myOwnerDocument);}
317
-	function set_content($text) {return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($text)));} //Entity problem reported by AL-DesignWorks 2007-09-07
306
+	function next_sibling() {return self::_newDOMElement($this->myDOMNode->nextSibling, $this->myOwnerDocument); }
307
+	function node_name() {return ($this->myDOMNode->nodeType === XML_ELEMENT_NODE) ? $this->myDOMNode->localName : $this->myDOMNode->nodeName; } //Avoid namespace prefix for DOMElement
308
+	function node_type() {return $this->myDOMNode->nodeType; }
309
+	function node_value() {return $this->myDOMNode->nodeValue; }
310
+	function owner_document() {return $this->myOwnerDocument; }
311
+	function parent_node() {return self::_newDOMElement($this->myDOMNode->parentNode, $this->myOwnerDocument); }
312
+	function prefix() {return $this->myDOMNode->prefix; }
313
+	function previous_sibling() {return self::_newDOMElement($this->myDOMNode->previousSibling, $this->myOwnerDocument); }
314
+	function remove_child($oldchild) {return self::_newDOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode), $this->myOwnerDocument); }
315
+	function replace_child($newnode, $oldnode) {return self::_newDOMElement($this->myDOMNode->replaceChild($this->_importNode($newnode), $oldnode->myDOMNode), $this->myOwnerDocument); }
316
+	function replace_node($newnode) {return self::_newDOMElement($this->myDOMNode->parentNode->replaceChild($this->_importNode($newnode), $this->myDOMNode), $this->myOwnerDocument); }
317
+	function set_content($text) {return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode(_entityDecode($text))); } //Entity problem reported by AL-DesignWorks 2007-09-07
318 318
 	//function set_name($name) {return $this->myOwnerDocument->renameNode($this->myDOMNode,$this->myDOMNode->namespaceURI,$name);}
319
-	function set_namespace($uri,$prefix=null)
319
+	function set_namespace($uri, $prefix = null)
320 320
 	{//Contributions by Daniel Walker 2006-09-08
321
-		$nsprefix=$this->myDOMNode->lookupPrefix($uri);
322
-		if ($nsprefix==null)
321
+		$nsprefix = $this->myDOMNode->lookupPrefix($uri);
322
+		if ($nsprefix == null)
323 323
 		{
324
-			$nsprefix= $prefix==null ? $nsprefix='a'.sprintf('%u',crc32($uri)) : $prefix;
325
-			if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE)
324
+			$nsprefix = $prefix == null ? $nsprefix = 'a'.sprintf('%u', crc32($uri)) : $prefix;
325
+			if ($this->myDOMNode->nodeType === XML_ATTRIBUTE_NODE)
326 326
 			{
327
-				if (($prefix!=null)&&$this->myDOMNode->ownerElement->hasAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)&&
328
-					($this->myDOMNode->ownerElement->getAttributeNS('http://www.w3.org/2000/xmlns/',$nsprefix)!=$uri))
327
+				if (($prefix != null) && $this->myDOMNode->ownerElement->hasAttributeNS('http://www.w3.org/2000/xmlns/', $nsprefix) &&
328
+					($this->myDOMNode->ownerElement->getAttributeNS('http://www.w3.org/2000/xmlns/', $nsprefix) != $uri))
329 329
 				{//Remove namespace
330
-					$parent=$this->myDOMNode->ownerElement;
330
+					$parent = $this->myDOMNode->ownerElement;
331 331
 					$parent->removeAttributeNode($this->myDOMNode);
332
-					$parent->setAttribute($this->myDOMNode->localName,$this->myDOMNode->nodeValue);
333
-					$this->myDOMNode=$parent->getAttributeNode($this->myDOMNode->localName);
332
+					$parent->setAttribute($this->myDOMNode->localName, $this->myDOMNode->nodeValue);
333
+					$this->myDOMNode = $parent->getAttributeNode($this->myDOMNode->localName);
334 334
 					return;
335 335
 				}
336
-				$this->myDOMNode->ownerElement->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:'.$nsprefix,$uri);
336
+				$this->myDOMNode->ownerElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:'.$nsprefix, $uri);
337 337
 			}
338 338
 		}
339
-		if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE)
339
+		if ($this->myDOMNode->nodeType === XML_ATTRIBUTE_NODE)
340 340
 		{
341
-			$parent=$this->myDOMNode->ownerElement;
341
+			$parent = $this->myDOMNode->ownerElement;
342 342
 			$parent->removeAttributeNode($this->myDOMNode);
343
-			$parent->setAttributeNS($uri,$nsprefix.':'.$this->myDOMNode->localName,$this->myDOMNode->nodeValue);
344
-			$this->myDOMNode=$parent->getAttributeNodeNS($uri,$this->myDOMNode->localName);
343
+			$parent->setAttributeNS($uri, $nsprefix.':'.$this->myDOMNode->localName, $this->myDOMNode->nodeValue);
344
+			$this->myDOMNode = $parent->getAttributeNodeNS($uri, $this->myDOMNode->localName);
345 345
 		}
346
-		elseif ($this->myDOMNode->nodeType===XML_ELEMENT_NODE)
346
+		elseif ($this->myDOMNode->nodeType === XML_ELEMENT_NODE)
347 347
 		{
348
-			$NewNode=$this->myDOMNode->ownerDocument->createElementNS($uri,$nsprefix.':'.$this->myDOMNode->localName);
348
+			$NewNode = $this->myDOMNode->ownerDocument->createElementNS($uri, $nsprefix.':'.$this->myDOMNode->localName);
349 349
 			foreach ($this->myDOMNode->attributes as $n) $NewNode->appendChild($n->cloneNode(true));
350 350
 			foreach ($this->myDOMNode->childNodes as $n) $NewNode->appendChild($n->cloneNode(true));
351
-			$xpath=new DOMXPath($this->myDOMNode->ownerDocument);
352
-			$myDOMNodeList=$xpath->query('namespace::*[name()!="xml"]',$this->myDOMNode); //Add old namespaces
353
-			foreach ($myDOMNodeList as $n) $NewNode->setAttributeNS('http://www.w3.org/2000/xmlns/',$n->nodeName,$n->nodeValue); 
354
-			$this->myDOMNode->parentNode->replaceChild($NewNode,$this->myDOMNode);
355
-			$this->myDOMNode=$NewNode;
351
+			$xpath = new DOMXPath($this->myDOMNode->ownerDocument);
352
+			$myDOMNodeList = $xpath->query('namespace::*[name()!="xml"]', $this->myDOMNode); //Add old namespaces
353
+			foreach ($myDOMNodeList as $n) $NewNode->setAttributeNS('http://www.w3.org/2000/xmlns/', $n->nodeName, $n->nodeValue); 
354
+			$this->myDOMNode->parentNode->replaceChild($NewNode, $this->myDOMNode);
355
+			$this->myDOMNode = $NewNode;
356 356
 		}
357 357
 	}
358 358
 	function unlink_node()
359 359
 	{
360
-		if ($this->myDOMNode->parentNode!=null)
360
+		if ($this->myDOMNode->parentNode != null)
361 361
 		{
362
-			if ($this->myDOMNode->nodeType===XML_ATTRIBUTE_NODE) $this->myDOMNode->parentNode->removeAttributeNode($this->myDOMNode);
362
+			if ($this->myDOMNode->nodeType === XML_ATTRIBUTE_NODE) $this->myDOMNode->parentNode->removeAttributeNode($this->myDOMNode);
363 363
 			else $this->myDOMNode->parentNode->removeChild($this->myDOMNode);
364 364
 		}
365 365
 	}
366
-	protected function _importNode($newnode) {return $this->myOwnerDocument===$newnode->myOwnerDocument ? $newnode->myDOMNode : $this->myOwnerDocument->myDOMNode->importNode($newnode->myDOMNode,true);} //To import DOMNode from another DOMDocument
367
-	static function _newDOMElement($aDOMNode,$aOwnerDocument)
366
+	protected function _importNode($newnode) {return $this->myOwnerDocument === $newnode->myOwnerDocument ? $newnode->myDOMNode : $this->myOwnerDocument->myDOMNode->importNode($newnode->myDOMNode, true); } //To import DOMNode from another DOMDocument
367
+	static function _newDOMElement($aDOMNode, $aOwnerDocument)
368 368
 	{//Check the PHP5 DOMNode before creating a new associated PHP4 DOMNode wrapper
369
-		if ($aDOMNode==null) return null;
369
+		if ($aDOMNode == null) return null;
370 370
 		switch ($aDOMNode->nodeType)
371 371
 		{
372
-			case XML_ELEMENT_NODE: return new php4DOMElement($aDOMNode,$aOwnerDocument);
373
-			case XML_TEXT_NODE: return new php4DOMText($aDOMNode,$aOwnerDocument);
374
-			case XML_ATTRIBUTE_NODE: return new php4DOMAttr($aDOMNode,$aOwnerDocument);
375
-			case XML_PI_NODE: return new php4DomProcessingInstruction($aDOMNode,$aOwnerDocument);
376
-			default: return new php4DOMNode($aDOMNode,$aOwnerDocument);
372
+			case XML_ELEMENT_NODE: return new php4DOMElement($aDOMNode, $aOwnerDocument);
373
+			case XML_TEXT_NODE: return new php4DOMText($aDOMNode, $aOwnerDocument);
374
+			case XML_ATTRIBUTE_NODE: return new php4DOMAttr($aDOMNode, $aOwnerDocument);
375
+			case XML_PI_NODE: return new php4DomProcessingInstruction($aDOMNode, $aOwnerDocument);
376
+			default: return new php4DOMNode($aDOMNode, $aOwnerDocument);
377 377
 		}
378 378
 	}
379 379
 }
380 380
 
381 381
 class php4DomProcessingInstruction extends php4DOMNode
382 382
 {
383
-	function data() {return $this->myDOMNode->data;}
384
-	function target() {return $this->myDOMNode->target;}
383
+	function data() {return $this->myDOMNode->data; }
384
+	function target() {return $this->myDOMNode->target; }
385 385
 }
386 386
 
387 387
 class php4DOMText extends php4DOMNode
388 388
 {
389 389
 	function __get($name)
390 390
 	{
391
-		if ($name==='tagname') return '#text';
391
+		if ($name === 'tagname') return '#text';
392 392
 		else return parent::__get($name);
393 393
 	}
394
-	function tagname() {return '#text';}
395
-	function set_content($text) {$this->myDOMNode->nodeValue=$text; return true;}
394
+	function tagname() {return '#text'; }
395
+	function set_content($text) {$this->myDOMNode->nodeValue = $text; return true; }
396 396
 }
397 397
 
398 398
 if (!defined('XPATH_NODESET'))
399 399
 {
400
-	define('XPATH_UNDEFINED',0);
401
-	define('XPATH_NODESET',1);
402
-	define('XPATH_BOOLEAN',2);
403
-	define('XPATH_NUMBER',3);
404
-	define('XPATH_STRING',4);
400
+	define('XPATH_UNDEFINED', 0);
401
+	define('XPATH_NODESET', 1);
402
+	define('XPATH_BOOLEAN', 2);
403
+	define('XPATH_NUMBER', 3);
404
+	define('XPATH_STRING', 4);
405 405
 	/*define('XPATH_POINT',5);
406 406
 	define('XPATH_RANGE',6);
407 407
 	define('XPATH_LOCATIONSET',7);
@@ -413,36 +413,36 @@  discard block
 block discarded – undo
413 413
 {
414 414
 	private $myDOMNodelist;
415 415
 	public $nodeset;
416
-	public $type=XPATH_UNDEFINED;
416
+	public $type = XPATH_UNDEFINED;
417 417
 	public $value;
418
-	function php4DOMNodelist($aDOMNodelist,$aOwnerDocument)
418
+	function php4DOMNodelist($aDOMNodelist, $aOwnerDocument)
419 419
 	{
420 420
 		if (!isset($aDOMNodelist)) return; 
421
-		elseif (is_object($aDOMNodelist)||is_array($aDOMNodelist))
421
+		elseif (is_object($aDOMNodelist) || is_array($aDOMNodelist))
422 422
 		{
423
-			if ($aDOMNodelist->length>0)
423
+			if ($aDOMNodelist->length > 0)
424 424
 			{
425
-				$this->myDOMNodelist=$aDOMNodelist;
426
-				$this->nodeset=array();
427
-				$this->type=XPATH_NODESET;
428
-				$i=0;
429
-				while ($node=$this->myDOMNodelist->item($i++)) $this->nodeset[]=php4DOMNode::_newDOMElement($node,$aOwnerDocument);
425
+				$this->myDOMNodelist = $aDOMNodelist;
426
+				$this->nodeset = array();
427
+				$this->type = XPATH_NODESET;
428
+				$i = 0;
429
+				while ($node = $this->myDOMNodelist->item($i++)) $this->nodeset[] = php4DOMNode::_newDOMElement($node, $aOwnerDocument);
430 430
 			}
431 431
 		}
432
-		elseif (is_int($aDOMNodelist)||is_float($aDOMNodelist))
432
+		elseif (is_int($aDOMNodelist) || is_float($aDOMNodelist))
433 433
 		{
434
-			$this->type=XPATH_NUMBER;
435
-			$this->value=$aDOMNodelist;
434
+			$this->type = XPATH_NUMBER;
435
+			$this->value = $aDOMNodelist;
436 436
 		}
437 437
 		elseif (is_bool($aDOMNodelist))
438 438
 		{
439
-			$this->type=XPATH_BOOLEAN;
440
-			$this->value=$aDOMNodelist;
439
+			$this->type = XPATH_BOOLEAN;
440
+			$this->value = $aDOMNodelist;
441 441
 		}
442 442
 		elseif (is_string($aDOMNodelist))
443 443
 		{
444
-			$this->type=XPATH_STRING;
445
-			$this->value=$aDOMNodelist;
444
+			$this->type = XPATH_STRING;
445
+			$this->value = $aDOMNodelist;
446 446
 		}
447 447
 	}
448 448
 }
@@ -454,46 +454,46 @@  discard block
 block discarded – undo
454 454
 	function php4DOMXPath($dom_document)
455 455
 	{
456 456
 		//TODO: If $dom_document is a DomElement, make that default $contextnode and modify XPath. Ex: '/test'
457
-		$this->myOwnerDocument=$dom_document->myOwnerDocument;
458
-		$this->myDOMXPath=new DOMXPath($this->myOwnerDocument->myDOMNode);
457
+		$this->myOwnerDocument = $dom_document->myOwnerDocument;
458
+		$this->myDOMXPath = new DOMXPath($this->myOwnerDocument->myDOMNode);
459 459
 	}
460
-	function xpath_eval($eval_str,$contextnode=null)
460
+	function xpath_eval($eval_str, $contextnode = null)
461 461
 	{
462
-		if (method_exists($this->myDOMXPath,'evaluate')) $xp=isset($contextnode) ? $this->myDOMXPath->evaluate($eval_str,$contextnode->myDOMNode) : $this->myDOMXPath->evaluate($eval_str);
463
-		else $xp=isset($contextnode) ? $this->myDOMXPath->query($eval_str,$contextnode->myDOMNode) : $this->myDOMXPath->query($eval_str);
464
-		$xp=new php4DOMNodelist($xp,$this->myOwnerDocument);
465
-		return ($xp->type===XPATH_UNDEFINED) ? false : $xp;
462
+		if (method_exists($this->myDOMXPath, 'evaluate')) $xp = isset($contextnode) ? $this->myDOMXPath->evaluate($eval_str, $contextnode->myDOMNode) : $this->myDOMXPath->evaluate($eval_str);
463
+		else $xp = isset($contextnode) ? $this->myDOMXPath->query($eval_str, $contextnode->myDOMNode) : $this->myDOMXPath->query($eval_str);
464
+		$xp = new php4DOMNodelist($xp, $this->myOwnerDocument);
465
+		return ($xp->type === XPATH_UNDEFINED) ? false : $xp;
466 466
 	}
467
-	function xpath_register_ns($prefix,$namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);}
467
+	function xpath_register_ns($prefix, $namespaceURI) {return $this->myDOMXPath->registerNamespace($prefix, $namespaceURI); }
468 468
 }
469 469
 
470 470
 if (extension_loaded('xsl'))
471 471
 {//See also: http://alexandre.alapetite.net/doc-alex/xslt-php4-php5/
472
-	function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));}
473
-	function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document);}
474
-	function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile));}
472
+	function domxml_xslt_stylesheet($xslstring) {return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring)); }
473
+	function domxml_xslt_stylesheet_doc($dom_document) {return new php4DomXsltStylesheet($dom_document); }
474
+	function domxml_xslt_stylesheet_file($xslfile) {return new php4DomXsltStylesheet(DOMDocument::load($xslfile)); }
475 475
 	class php4DomXsltStylesheet
476 476
 	{
477 477
 		private $myxsltProcessor;
478 478
 		function php4DomXsltStylesheet($dom_document)
479 479
 		{
480
-			$this->myxsltProcessor=new xsltProcessor();
480
+			$this->myxsltProcessor = new xsltProcessor();
481 481
 			$this->myxsltProcessor->importStyleSheet($dom_document);
482 482
 		}
483
-		function process($dom_document,$xslt_parameters=array(),$param_is_xpath=false)
483
+		function process($dom_document, $xslt_parameters = array(), $param_is_xpath = false)
484 484
 		{
485
-			foreach ($xslt_parameters as $param=>$value) $this->myxsltProcessor->setParameter('',$param,$value);
486
-			$myphp4DOMDocument=new php4DOMDocument();
487
-			$myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
485
+			foreach ($xslt_parameters as $param=>$value) $this->myxsltProcessor->setParameter('', $param, $value);
486
+			$myphp4DOMDocument = new php4DOMDocument();
487
+			$myphp4DOMDocument->myDOMNode = $this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
488 488
 			return $myphp4DOMDocument;
489 489
 		}
490
-		function result_dump_file($dom_document,$filename)
490
+		function result_dump_file($dom_document, $filename)
491 491
 		{
492
-			$html=$dom_document->myDOMNode->saveHTML();
493
-			file_put_contents($filename,$html);
492
+			$html = $dom_document->myDOMNode->saveHTML();
493
+			file_put_contents($filename, $html);
494 494
 			return $html;
495 495
 		}
496
-		function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML();}
496
+		function result_dump_mem($dom_document) {return $dom_document->myDOMNode->saveHTML(); }
497 497
 	}
498 498
 }
499 499
 ?>
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS/client.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	function HTMLFilterOutput($str)
82 82
 		{
83
-		$str = str_replace('__CAS_VERSION__',$this->getServerVersion(),$str);
84
-		$str = str_replace('__PHPCAS_VERSION__',phpCAS::getVersion(),$str);
85
-		$str = str_replace('__SERVER_BASE_URL__',$this->getServerBaseURL(),$str);
83
+		$str = str_replace('__CAS_VERSION__', $this->getServerVersion(), $str);
84
+		$str = str_replace('__PHPCAS_VERSION__', phpCAS::getVersion(), $str);
85
+		$str = str_replace('__SERVER_BASE_URL__', $this->getServerBaseURL(), $str);
86 86
 		echo $str;
87 87
 		}
88 88
 	
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	function printHTMLFooter()
137 137
 		{
138 138
 		$this->HTMLFilterOutput(empty($this->_output_footer)
139
-			?('<hr><address>phpCAS __PHPCAS_VERSION__ '.$this->getString(CAS_STR_USING_SERVER).' <a href="__SERVER_BASE_URL__">__SERVER_BASE_URL__</a> (CAS __CAS_VERSION__)</a></address></body></html>')
139
+			? ('<hr><address>phpCAS __PHPCAS_VERSION__ '.$this->getString(CAS_STR_USING_SERVER).' <a href="__SERVER_BASE_URL__">__SERVER_BASE_URL__</a> (CAS __CAS_VERSION__)</a></address></body></html>')
140 140
 					:$this->_output_footer);
141 141
 		}
142 142
 	
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	function getLang()
195 195
 		{
196
-		if ( empty($this->_lang) )
196
+		if (empty($this->_lang))
197 197
 			$this->setLang(PHPCAS_LANG_DEFAULT);
198 198
 		return $this->_lang;
199 199
 		}
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		// call CASclient::getLang() to be sure the language is initialized
224 224
 		$this->getLang();
225 225
 		
226
-		if ( !isset($this->_strings[$str]) ) {
227
-			trigger_error('string `'.$str.'\' not defined for language `'.$this->getLang().'\'',E_USER_ERROR);
226
+		if (!isset($this->_strings[$str])) {
227
+			trigger_error('string `'.$str.'\' not defined for language `'.$this->getLang().'\'', E_USER_ERROR);
228 228
 		}
229 229
 		return $this->_strings[$str];
230 230
 		}
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		// include the corresponding language file
244 244
 		include_once(dirname(__FILE__).'/languages/'.$lang.'.php');
245 245
 		
246
-		if ( !is_array($this->_strings) ) {
247
-			trigger_error('language `'.$lang.'\' is not implemented',E_USER_ERROR);
246
+		if (!is_array($this->_strings)) {
247
+			trigger_error('language `'.$lang.'\' is not implemented', E_USER_ERROR);
248 248
 		}
249 249
 		$this->_lang = $lang;
250 250
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	function getServerBaseURL()
332 332
 		{ 
333 333
 		// the URL is build only when needed
334
-		if ( empty($this->_server['base_url']) ) {
334
+		if (empty($this->_server['base_url'])) {
335 335
 			$this->_server['base_url'] = 'https://'
336 336
 				.$this->getServerHostname()
337 337
 				.':'
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
 	 * @return a URL.
351 351
 	 * @private
352 352
 	 */
353
-	function getServerLoginURL($gateway=false,$renew=false) {
353
+	function getServerLoginURL($gateway = false, $renew = false) {
354 354
 		phpCAS::traceBegin();
355 355
 		// the URL is build only when needed
356
-		if ( empty($this->_server['login_url']) ) {
356
+		if (empty($this->_server['login_url'])) {
357 357
 			$this->_server['login_url'] = $this->getServerBaseURL();
358 358
 			$this->_server['login_url'] .= 'login?service=';
359 359
 			// $this->_server['login_url'] .= preg_replace('/&/','%26',$this->getURL());
360 360
 			$this->_server['login_url'] .= urlencode($this->getURL());
361
-			if($renew) {
361
+			if ($renew) {
362 362
 				// It is recommended that when the "renew" parameter is set, its value be "true"
363 363
 				$this->_server['login_url'] .= '&renew=true';
364 364
 			} elseif ($gateway) {
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	function getServerServiceValidateURL()
427 427
 		{ 
428 428
 		// the URL is build only when needed
429
-		if ( empty($this->_server['service_validate_url']) ) {
429
+		if (empty($this->_server['service_validate_url'])) {
430 430
 			switch ($this->getServerVersion()) {
431 431
 				case CAS_VERSION_1_0:
432 432
 					$this->_server['service_validate_url'] = $this->getServerBaseURL().'validate';
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		{
449 449
 		phpCAS::traceBegin();
450 450
 		// the URL is build only when needed
451
-		if ( empty($this->_server['saml_validate_url']) ) {
451
+		if (empty($this->_server['saml_validate_url'])) {
452 452
 			switch ($this->getServerVersion()) {
453 453
 				case SAML_VERSION_1_1:
454 454
 					$this->_server['saml_validate_url'] = $this->getServerBaseURL().'samlValidate';
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	function getServerProxyValidateURL()
467 467
 		{ 
468 468
 		// the URL is build only when needed
469
-		if ( empty($this->_server['proxy_validate_url']) ) {
469
+		if (empty($this->_server['proxy_validate_url'])) {
470 470
 			switch ($this->getServerVersion()) {
471 471
 				case CAS_VERSION_1_0:
472 472
 					$this->_server['proxy_validate_url'] = '';
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	function getServerProxyURL()
489 489
 		{ 
490 490
 		// the URL is build only when needed
491
-		if ( empty($this->_server['proxy_url']) ) {
491
+		if (empty($this->_server['proxy_url'])) {
492 492
 			switch ($this->getServerVersion()) {
493 493
 				case CAS_VERSION_1_0:
494 494
 					$this->_server['proxy_url'] = '';
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 	function getServerLogoutURL()
510 510
 		{ 
511 511
 		// the URL is build only when needed
512
-		if ( empty($this->_server['logout_url']) ) {
512
+		if (empty($this->_server['logout_url'])) {
513 513
 			$this->_server['logout_url'] = $this->getServerBaseURL().'logout';
514 514
 		}
515 515
 		return $this->_server['logout_url']; 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	function isHttps() {
548 548
 		//if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ) {
549 549
 		//0.4.24 by Hinnack
550
-		if ( isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
550
+		if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
551 551
 			return true;
552 552
 		} else {
553 553
 			return false;
@@ -582,45 +582,45 @@  discard block
 block discarded – undo
582 582
 		phpCAS::traceBegin();
583 583
 		
584 584
 		// the redirect header() call and DOM parsing code from domxml-php4-php5.php won't work in PHP4 compatibility mode
585
-		if (version_compare(PHP_VERSION,'5','>=') && ini_get('zend.ze1_compatibility_mode')) {
585
+		if (version_compare(PHP_VERSION, '5', '>=') && ini_get('zend.ze1_compatibility_mode')) {
586 586
 			phpCAS::error('phpCAS cannot support zend.ze1_compatibility_mode. Sorry.');
587 587
 		}
588 588
 		// skip Session Handling for logout requests and if don't want it'
589 589
 		if ($start_session && !$this->isLogoutRequest()) {
590 590
 			phpCAS::trace("Starting session handling");
591 591
 			// Check for Tickets from the CAS server
592
-			if (empty($_GET['ticket'])){
592
+			if (empty($_GET['ticket'])) {
593 593
 				phpCAS::trace("No ticket found");
594 594
 				// only create a session if necessary
595 595
 				if (!session_id()) {
596 596
 					phpCAS::trace("No session found, creating new session");
597 597
 					session_start();
598 598
 				}
599
-			}else{
599
+			} else {
600 600
 				phpCAS::trace("Ticket found");
601 601
 				// We have to copy any old data before renaming the session
602 602
 				if (session_id()) {
603 603
 					phpCAS::trace("Old active session found, saving old data and destroying session");
604 604
 					$old_session = $_SESSION;
605 605
 					session_destroy();	
606
-				}else{
606
+				} else {
607 607
 					session_start();
608 608
 					phpCAS::trace("Starting possible old session to copy variables");
609 609
 					$old_session = $_SESSION;
610 610
 					session_destroy();	
611 611
 				}
612 612
 				// set up a new session, of name based on the ticket
613
-				$session_id = preg_replace('/[^\w]/','',$_GET['ticket']);
614
-				phpCAS::LOG("Session ID: " . $session_id);
613
+				$session_id = preg_replace('/[^\w]/', '', $_GET['ticket']);
614
+				phpCAS::LOG("Session ID: ".$session_id);
615 615
 				session_id($session_id);
616 616
 				session_start();
617 617
 				// restore old session vars
618
-				if(isset($old_session)){
618
+				if (isset($old_session)) {
619 619
 					phpCAS::trace("Restoring old session vars");
620 620
 					$_SESSION = $old_session;
621 621
 				}
622 622
 			}
623
-		}else{
623
+		} else {
624 624
 			phpCAS::trace("Skipping session creation");
625 625
 		}
626 626
 		
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 		//check version
632 632
 		switch ($server_version) {
633 633
 			case CAS_VERSION_1_0:
634
-				if ( $this->isProxy() )
634
+				if ($this->isProxy())
635 635
 					phpCAS::error('CAS proxies are not supported in CAS '
636 636
 						.$server_version);
637 637
 				break;
@@ -648,35 +648,35 @@  discard block
 block discarded – undo
648 648
 		$this->_server['version'] = $server_version;
649 649
 		
650 650
 		// check hostname
651
-		if ( empty($server_hostname) 
652
-				|| !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/',$server_hostname) ) {
651
+		if (empty($server_hostname) 
652
+				|| !preg_match('/[\.\d\-abcdefghijklmnopqrstuvwxyz]*/', $server_hostname)) {
653 653
 			phpCAS::error('bad CAS server hostname (`'.$server_hostname.'\')');
654 654
 		}
655 655
 		$this->_server['hostname'] = $server_hostname;
656 656
 		
657 657
 		// check port
658
-		if ( $server_port == 0 
659
-			|| !is_int($server_port) ) {
658
+		if ($server_port == 0 
659
+			|| !is_int($server_port)) {
660 660
 			phpCAS::error('bad CAS server port (`'.$server_hostname.'\')');
661 661
 		}
662 662
 		$this->_server['port'] = $server_port;
663 663
 		
664 664
 		// check URI
665
-		if ( !preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/',$server_uri) ) {
665
+		if (!preg_match('/[\.\d\-_abcdefghijklmnopqrstuvwxyz\/]*/', $server_uri)) {
666 666
 			phpCAS::error('bad CAS server URI (`'.$server_uri.'\')');
667 667
 		}
668 668
 		// add leading and trailing `/' and remove doubles      
669
-		$server_uri = preg_replace('/\/\//','/','/'.$server_uri.'/');
669
+		$server_uri = preg_replace('/\/\//', '/', '/'.$server_uri.'/');
670 670
 		$this->_server['uri'] = $server_uri;
671 671
 		
672 672
 		// set to callback mode if PgtIou and PgtId CGI GET parameters are provided 
673
-		if ( $this->isProxy() ) {
674
-			$this->setCallbackMode(!empty($_GET['pgtIou'])&&!empty($_GET['pgtId']));
673
+		if ($this->isProxy()) {
674
+			$this->setCallbackMode(!empty($_GET['pgtIou']) && !empty($_GET['pgtId']));
675 675
 		}
676 676
 		
677
-		if ( $this->isCallbackMode() ) {
677
+		if ($this->isCallbackMode()) {
678 678
 			//callback mode: check that phpCAS is secured
679
-			if ( !$this->isHttps() ) {
679
+			if (!$this->isHttps()) {
680 680
 				phpCAS::error('CAS proxies must be secured to use phpCAS; PGT\'s will not be received from the CAS server');
681 681
 			}
682 682
 		} else {
@@ -684,33 +684,33 @@  discard block
 block discarded – undo
684 684
 			$ticket = (isset($_GET['ticket']) ? $_GET['ticket'] : null);
685 685
 			switch ($this->getServerVersion()) {
686 686
 				case CAS_VERSION_1_0: // check for a Service Ticket
687
-					if( preg_match('/^ST-/',$ticket) ) {
687
+					if (preg_match('/^ST-/', $ticket)) {
688 688
 						phpCAS::trace('ST \''.$ticket.'\' found');
689 689
 						//ST present
690 690
 						$this->setST($ticket);
691 691
 						//ticket has been taken into account, unset it to hide it to applications
692 692
 						unset($_GET['ticket']);
693
-					} else if ( !empty($ticket) ) {
693
+					} else if (!empty($ticket)) {
694 694
 						//ill-formed ticket, halt
695 695
 						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
696 696
 					}
697 697
 					break;
698 698
 				case CAS_VERSION_2_0: // check for a Service or Proxy Ticket
699
-					if( preg_match('/^[SP]T-/',$ticket) ) {
699
+					if (preg_match('/^[SP]T-/', $ticket)) {
700 700
 						phpCAS::trace('ST or PT \''.$ticket.'\' found');
701 701
 						$this->setPT($ticket);
702 702
 						unset($_GET['ticket']);
703
-					} else if ( !empty($ticket) ) {
703
+					} else if (!empty($ticket)) {
704 704
 						//ill-formed ticket, halt
705 705
 						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
706 706
 					} 
707 707
 					break;
708 708
 				case SAML_VERSION_1_1: // SAML just does Service Tickets
709
-					if( preg_match('/^[SP]T-/',$ticket) ) {
709
+					if (preg_match('/^[SP]T-/', $ticket)) {
710 710
 						phpCAS::trace('SA \''.$ticket.'\' found');
711 711
 						$this->setSA($ticket);
712 712
 						unset($_GET['ticket']);
713
-					} else if ( !empty($ticket) ) {
713
+					} else if (!empty($ticket)) {
714 714
 						//ill-formed ticket, halt
715 715
 						phpCAS::error('ill-formed ticket found in the URL (ticket=`'.htmlentities($ticket).'\')');
716 716
 					}
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 	 */
764 764
 	function getUser()
765 765
 		{
766
-		if ( empty($this->_user) ) {
766
+		if (empty($this->_user)) {
767 767
 			phpCAS::error('this method should be used only after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()');
768 768
 		}
769 769
 		return $this->_user;
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 		{ $this->_attributes = $attributes; }
791 791
 	
792 792
 	function getAttributes() {
793
-		if ( empty($this->_user) ) { // if no user is set, there shouldn't be any attributes also...
793
+		if (empty($this->_user)) { // if no user is set, there shouldn't be any attributes also...
794 794
 			phpCAS::error('this method should be used only after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()');
795 795
 		}
796 796
 		return $this->_attributes;
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 	function hasAttribute($key)
803 803
 		{ return (is_array($this->_attributes) && array_key_exists($key, $this->_attributes)); }
804 804
 	
805
-	function getAttribute($key)	{
806
-		if($this->hasAttribute($key)) {
805
+	function getAttribute($key) {
806
+		if ($this->hasAttribute($key)) {
807 807
 			return $this->_attributes[$key];
808 808
 		}
809 809
 	}
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 	 * If not, redirect to CAS
815 815
 	 * @public
816 816
 	 */
817
-	function renewAuthentication(){
817
+	function renewAuthentication() {
818 818
 		phpCAS::traceBegin();
819 819
 		// Either way, the user is authenticated by CAS
820
-		if( isset( $_SESSION['phpCAS']['auth_checked'] ) )
820
+		if (isset($_SESSION['phpCAS']['auth_checked']))
821 821
 			unset($_SESSION['phpCAS']['auth_checked']);
822
-		if ( $this->isAuthenticated() ) {
822
+		if ($this->isAuthenticated()) {
823 823
 			phpCAS::trace('user already authenticated; renew');
824
-			$this->redirectToCas(false,true);
824
+			$this->redirectToCas(false, true);
825 825
 		} else {
826 826
 			$this->redirectToCas();
827 827
 		}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		{
839 839
 		phpCAS::traceBegin();
840 840
 		
841
-		if ( $this->isAuthenticated() ) {
841
+		if ($this->isAuthenticated()) {
842 842
 			// the user is authenticated, nothing to be done.
843 843
 			phpCAS::trace('no need to authenticate');
844 844
 			$res = TRUE;
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 	function checkAuthentication()
884 884
 		{
885 885
 		phpCAS::traceBegin();
886
-		if ( $this->isAuthenticated() ) {
886
+		if ($this->isAuthenticated()) {
887 887
             phpCAS::trace('user is authenticated');
888 888
 			$res = TRUE;
889 889
 		} else if (isset($_SESSION['phpCAS']['auth_checked'])) {
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 			//	    // never reached
898 898
 			//	    $res = FALSE;
899 899
 			// avoid a check against CAS on every request
900
-			if (! isset($_SESSION['phpCAS']['unauth_count']) )
900
+			if (!isset($_SESSION['phpCAS']['unauth_count']))
901 901
 				$_SESSION['phpCAS']['unauth_count'] = -2; // uninitialized
902 902
 			
903 903
 			if (($_SESSION['phpCAS']['unauth_count'] != -2 && $this->_cache_times_for_auth_recheck == -1) 
@@ -943,43 +943,43 @@  discard block
 block discarded – undo
943 943
 		$res = FALSE;
944 944
 		$validate_url = '';
945 945
 		
946
-		if ( $this->wasPreviouslyAuthenticated() ) {
946
+		if ($this->wasPreviouslyAuthenticated()) {
947 947
 			// the user has already (previously during the session) been
948 948
 			// authenticated, nothing to be done.
949 949
 			phpCAS::trace('user was already authenticated, no need to look for tickets');
950 950
 			$res = TRUE;
951 951
 		}
952 952
 		else {
953
-			if ( $this->hasST() ) {
953
+			if ($this->hasST()) {
954 954
 				// if a Service Ticket was given, validate it
955 955
 				phpCAS::trace('ST `'.$this->getST().'\' is present');
956
-				$this->validateST($validate_url,$text_response,$tree_response); // if it fails, it halts
956
+				$this->validateST($validate_url, $text_response, $tree_response); // if it fails, it halts
957 957
 				phpCAS::trace('ST `'.$this->getST().'\' was validated');
958
-				if ( $this->isProxy() ) {
959
-					$this->validatePGT($validate_url,$text_response,$tree_response); // idem
958
+				if ($this->isProxy()) {
959
+					$this->validatePGT($validate_url, $text_response, $tree_response); // idem
960 960
 					phpCAS::trace('PGT `'.$this->getPGT().'\' was validated');
961 961
 					$_SESSION['phpCAS']['pgt'] = $this->getPGT();
962 962
 				}
963 963
 				$_SESSION['phpCAS']['user'] = $this->getUser();
964 964
 				$res = TRUE;
965 965
 			}
966
-			elseif ( $this->hasPT() ) {
966
+			elseif ($this->hasPT()) {
967 967
 				// if a Proxy Ticket was given, validate it
968 968
 				phpCAS::trace('PT `'.$this->getPT().'\' is present');
969
-				$this->validatePT($validate_url,$text_response,$tree_response); // note: if it fails, it halts
969
+				$this->validatePT($validate_url, $text_response, $tree_response); // note: if it fails, it halts
970 970
 				phpCAS::trace('PT `'.$this->getPT().'\' was validated');
971
-				if ( $this->isProxy() ) {
972
-					$this->validatePGT($validate_url,$text_response,$tree_response); // idem
971
+				if ($this->isProxy()) {
972
+					$this->validatePGT($validate_url, $text_response, $tree_response); // idem
973 973
 					phpCAS::trace('PGT `'.$this->getPGT().'\' was validated');
974 974
 					$_SESSION['phpCAS']['pgt'] = $this->getPGT();
975 975
 				}
976 976
 				$_SESSION['phpCAS']['user'] = $this->getUser();
977 977
 				$res = TRUE;
978 978
 			}
979
-			elseif ( $this->hasSA() ) {
979
+			elseif ($this->hasSA()) {
980 980
 				// if we have a SAML ticket, validate it.
981 981
 				phpCAS::trace('SA `'.$this->getSA().'\' is present');
982
-				$this->validateSA($validate_url,$text_response,$tree_response); // if it fails, it halts
982
+				$this->validateSA($validate_url, $text_response, $tree_response); // if it fails, it halts
983 983
 				phpCAS::trace('SA `'.$this->getSA().'\' was validated');
984 984
 				$_SESSION['phpCAS']['user'] = $this->getUser();
985 985
 				$_SESSION['phpCAS']['attributes'] = $this->getAttributes();
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 				// if called with a ticket parameter, we need to redirect to the app without the ticket so that CAS-ification is transparent to the browser (for later POSTS)
994 994
 				// most of the checks and errors should have been made now, so we're safe for redirect without masking error messages.
995 995
 				header('Location: '.$this->getURL());
996
-				phpCAS::log( "Prepare redirect to : ".$this->getURL() );
996
+				phpCAS::log("Prepare redirect to : ".$this->getURL());
997 997
 			}
998 998
 		}
999 999
 		
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 * @return true if authenticated based soley on $_SESSION variable
1007 1007
 	 * @since 0.4.22 by Brendan Arnold
1008 1008
 	 */
1009
-	function isSessionAuthenticated ()
1009
+	function isSessionAuthenticated()
1010 1010
 		{
1011 1011
 		return !empty($_SESSION['phpCAS']['user']);
1012 1012
 		}
@@ -1025,28 +1025,28 @@  discard block
 block discarded – undo
1025 1025
 		{
1026 1026
 		phpCAS::traceBegin();
1027 1027
 		
1028
-		if ( $this->isCallbackMode() ) {
1028
+		if ($this->isCallbackMode()) {
1029 1029
 			$this->callback();
1030 1030
 		}
1031 1031
 		
1032 1032
 		$auth = FALSE;
1033 1033
 		
1034
-		if ( $this->isProxy() ) {
1034
+		if ($this->isProxy()) {
1035 1035
 			// CAS proxy: username and PGT must be present
1036
-			if ( $this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt']) ) {
1036
+			if ($this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt'])) {
1037 1037
 				// authentication already done
1038 1038
 				$this->setUser($_SESSION['phpCAS']['user']);
1039 1039
 				$this->setPGT($_SESSION['phpCAS']['pgt']);
1040 1040
 				phpCAS::trace('user = `'.$_SESSION['phpCAS']['user'].'\', PGT = `'.$_SESSION['phpCAS']['pgt'].'\''); 
1041 1041
 				$auth = TRUE;
1042
-			} elseif ( $this->isSessionAuthenticated() && empty($_SESSION['phpCAS']['pgt']) ) {
1042
+			} elseif ($this->isSessionAuthenticated() && empty($_SESSION['phpCAS']['pgt'])) {
1043 1043
 				// these two variables should be empty or not empty at the same time
1044 1044
 				phpCAS::trace('username found (`'.$_SESSION['phpCAS']['user'].'\') but PGT is empty');
1045 1045
 				// unset all tickets to enforce authentication
1046 1046
 				unset($_SESSION['phpCAS']);
1047 1047
 				$this->setST('');
1048 1048
 				$this->setPT('');
1049
-			} elseif ( !$this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt']) ) {
1049
+			} elseif (!$this->isSessionAuthenticated() && !empty($_SESSION['phpCAS']['pgt'])) {
1050 1050
 				// these two variables should be empty or not empty at the same time
1051 1051
 				phpCAS::trace('PGT found (`'.$_SESSION['phpCAS']['pgt'].'\') but username is empty'); 
1052 1052
 				// unset all tickets to enforce authentication
@@ -1058,10 +1058,10 @@  discard block
 block discarded – undo
1058 1058
 			}
1059 1059
 		} else {
1060 1060
 			// `simple' CAS client (not a proxy): username must be present
1061
-			if ( $this->isSessionAuthenticated() ) {
1061
+			if ($this->isSessionAuthenticated()) {
1062 1062
 				// authentication already done
1063 1063
 				$this->setUser($_SESSION['phpCAS']['user']);
1064
-				if(isset($_SESSION['phpCAS']['attributes'])){
1064
+				if (isset($_SESSION['phpCAS']['attributes'])) {
1065 1065
 					$this->setAttributes($_SESSION['phpCAS']['attributes']);
1066 1066
 				}
1067 1067
 				phpCAS::trace('user = `'.$_SESSION['phpCAS']['user'].'\''); 
@@ -1082,15 +1082,15 @@  discard block
 block discarded – undo
1082 1082
 	 * @param $renew true to force the authentication with the CAS server
1083 1083
 	 * @public
1084 1084
 	 */
1085
-	function redirectToCas($gateway=false,$renew=false){
1085
+	function redirectToCas($gateway = false, $renew = false) {
1086 1086
 		phpCAS::traceBegin();
1087
-		$cas_url = $this->getServerLoginURL($gateway,$renew);
1087
+		$cas_url = $this->getServerLoginURL($gateway, $renew);
1088 1088
 		header('Location: '.$cas_url);
1089
-		phpCAS::log( "Redirect to : ".$cas_url );
1089
+		phpCAS::log("Redirect to : ".$cas_url);
1090 1090
 		
1091 1091
 		$this->printHTMLHeader($this->getString(CAS_STR_AUTHENTICATION_WANTED));
1092 1092
 		
1093
-		printf('<p>'.$this->getString(CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED).'</p>',$cas_url);
1093
+		printf('<p>'.$this->getString(CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED).'</p>', $cas_url);
1094 1094
 		$this->printHTMLFooter();
1095 1095
 		
1096 1096
 		phpCAS::traceExit();
@@ -1108,20 +1108,20 @@  discard block
 block discarded – undo
1108 1108
 		$cas_url = $this->getServerLogoutURL();
1109 1109
 		$paramSeparator = '?';
1110 1110
 		if (isset($params['url'])) {
1111
-			$cas_url = $cas_url . $paramSeparator . "url=" . urlencode($params['url']); 
1111
+			$cas_url = $cas_url.$paramSeparator."url=".urlencode($params['url']); 
1112 1112
 			$paramSeparator = '&';
1113 1113
 		}
1114 1114
 		if (isset($params['service'])) {
1115
-			$cas_url = $cas_url . $paramSeparator . "service=" . urlencode($params['service']); 
1115
+			$cas_url = $cas_url.$paramSeparator."service=".urlencode($params['service']); 
1116 1116
 		}
1117 1117
 		header('Location: '.$cas_url);
1118
-		phpCAS::log( "Prepare redirect to : ".$cas_url );
1118
+		phpCAS::log("Prepare redirect to : ".$cas_url);
1119 1119
 		
1120 1120
 		session_unset();
1121 1121
 		session_destroy();
1122 1122
 		
1123 1123
 		$this->printHTMLHeader($this->getString(CAS_STR_LOGOUT));
1124
-		printf('<p>'.$this->getString(CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED).'</p>',$cas_url);
1124
+		printf('<p>'.$this->getString(CAS_STR_SHOULD_HAVE_BEEN_REDIRECTED).'</p>', $cas_url);
1125 1125
 		$this->printHTMLFooter();
1126 1126
 		
1127 1127
 		phpCAS::traceExit();
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 	 * By default, only the CAs server (declared in the constructor) will be allowed.
1152 1152
 	 * @public
1153 1153
 	 */
1154
-	function handleLogoutRequests($check_client=true, $allowed_clients=false) {
1154
+	function handleLogoutRequests($check_client = true, $allowed_clients = false) {
1155 1155
 		phpCAS::traceBegin();
1156 1156
 		if (!$this->isLogoutRequest()) {
1157 1157
 			phpCAS::log("Not a logout request");
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 		phpCAS::log("SAML REQUEST: ".$_POST['logoutRequest']);
1163 1163
 		if ($check_client) {
1164 1164
 			if (!$allowed_clients) {
1165
-				$allowed_clients = array( $this->getServerHostname() ); 
1165
+				$allowed_clients = array($this->getServerHostname()); 
1166 1166
 			}
1167 1167
 			$client_ip = $_SERVER['REMOTE_ADDR'];
1168 1168
 			$client = gethostbyaddr($client_ip);
@@ -1188,21 +1188,21 @@  discard block
 block discarded – undo
1188 1188
 		}
1189 1189
 		// Extract the ticket from the SAML Request
1190 1190
 		preg_match("|<samlp:SessionIndex>(.*)</samlp:SessionIndex>|", $_POST['logoutRequest'], $tick, PREG_OFFSET_CAPTURE, 3);
1191
-		$wrappedSamlSessionIndex = preg_replace('|<samlp:SessionIndex>|','',$tick[0][0]);
1192
-		$ticket2logout = preg_replace('|</samlp:SessionIndex>|','',$wrappedSamlSessionIndex);
1191
+		$wrappedSamlSessionIndex = preg_replace('|<samlp:SessionIndex>|', '', $tick[0][0]);
1192
+		$ticket2logout = preg_replace('|</samlp:SessionIndex>|', '', $wrappedSamlSessionIndex);
1193 1193
 		phpCAS::log("Ticket to logout: ".$ticket2logout);
1194
-		$session_id = preg_replace('/[^\w]/','',$ticket2logout);
1194
+		$session_id = preg_replace('/[^\w]/', '', $ticket2logout);
1195 1195
 		phpCAS::log("Session id: ".$session_id);
1196 1196
 		
1197 1197
 		// destroy a possible application session created before phpcas
1198
-		if(session_id()){
1198
+		if (session_id()) {
1199 1199
 			session_unset();
1200 1200
 			session_destroy();
1201 1201
 		}
1202 1202
 		// fix session ID
1203 1203
 		session_id($session_id);
1204
-		$_COOKIE[session_name()]=$session_id;
1205
-		$_GET[session_name()]=$session_id;
1204
+		$_COOKIE[session_name()] = $session_id;
1205
+		$_GET[session_name()] = $session_id;
1206 1206
 		
1207 1207
 		// Overwrite session
1208 1208
 		session_start();	
@@ -1338,18 +1338,18 @@  discard block
 block discarded – undo
1338 1338
 	 *
1339 1339
 	 * @private
1340 1340
 	 */
1341
-	function validateST($validate_url,&$text_response,&$tree_response)
1341
+	function validateST($validate_url, &$text_response, &$tree_response)
1342 1342
 		{
1343 1343
 		phpCAS::traceBegin();
1344 1344
 		// build the URL to validate the ticket
1345 1345
 		$validate_url = $this->getServerServiceValidateURL().'&ticket='.$this->getST();
1346
-		if ( $this->isProxy() ) {
1346
+		if ($this->isProxy()) {
1347 1347
 			// pass the callback url for CAS proxies
1348 1348
 			$validate_url .= '&pgtUrl='.$this->getCallbackURL();
1349 1349
 		}
1350 1350
 		
1351 1351
 		// open and read the URL
1352
-		if ( !$this->readURL($validate_url,''/*cookies*/,$headers,$text_response,$err_msg) ) {
1352
+		if (!$this->readURL($validate_url, ''/*cookies*/, $headers, $text_response, $err_msg)) {
1353 1353
 			phpCAS::trace('could not open URL \''.$validate_url.'\' to validate ('.$err_msg.')');
1354 1354
 			$this->authError('ST not validated',
1355 1355
 				$validate_url,
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
 		// analyze the result depending on the version
1360 1360
 		switch ($this->getServerVersion()) {
1361 1361
 			case CAS_VERSION_1_0:
1362
-				if (preg_match('/^no\n/',$text_response)) {
1362
+				if (preg_match('/^no\n/', $text_response)) {
1363 1363
 					phpCAS::trace('ST has not been validated');
1364 1364
 					$this->authError('ST not validated',
1365 1365
 						$validate_url,
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
 						FALSE/*$bad_response*/,
1368 1368
 						$text_response);
1369 1369
 				}
1370
-				if (!preg_match('/^yes\n/',$text_response)) {
1370
+				if (!preg_match('/^yes\n/', $text_response)) {
1371 1371
 					phpCAS::trace('ill-formed response');
1372 1372
 					$this->authError('ST not validated',
1373 1373
 						$validate_url,
@@ -1376,12 +1376,12 @@  discard block
 block discarded – undo
1376 1376
 						$text_response);
1377 1377
 				}
1378 1378
 				// ST has been validated, extract the user name
1379
-				$arr = preg_split('/\n/',$text_response);
1379
+				$arr = preg_split('/\n/', $text_response);
1380 1380
 				$this->setUser(trim($arr[1]));
1381 1381
 				break;
1382 1382
 			case CAS_VERSION_2_0:
1383 1383
 				// read the response of the CAS server into a DOM object
1384
-				if ( !($dom = domxml_open_mem($text_response))) {
1384
+				if (!($dom = domxml_open_mem($text_response))) {
1385 1385
 					phpCAS::trace('domxml_open_mem() failed');
1386 1386
 					$this->authError('ST not validated',
1387 1387
 						$validate_url,
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 						$text_response);
1391 1391
 				}
1392 1392
 				// read the root node of the XML tree
1393
-				if ( !($tree_response = $dom->document_element()) ) {
1393
+				if (!($tree_response = $dom->document_element())) {
1394 1394
 					phpCAS::trace('document_element() failed');
1395 1395
 					$this->authError('ST not validated',
1396 1396
 						$validate_url,
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 						$text_response);
1400 1400
 				}
1401 1401
 				// insure that tag name is 'serviceResponse'
1402
-				if ( $tree_response->node_name() != 'serviceResponse' ) {
1402
+				if ($tree_response->node_name() != 'serviceResponse') {
1403 1403
 					phpCAS::trace('bad XML root node (should be `serviceResponse\' instead of `'.$tree_response->node_name().'\'');
1404 1404
 					$this->authError('ST not validated',
1405 1405
 						$validate_url,
@@ -1407,9 +1407,9 @@  discard block
 block discarded – undo
1407 1407
 						TRUE/*$bad_response*/,
1408 1408
 						$text_response);
1409 1409
 				}
1410
-				if ( sizeof($success_elements = $tree_response->get_elements_by_tagname("authenticationSuccess")) != 0) {
1410
+				if (sizeof($success_elements = $tree_response->get_elements_by_tagname("authenticationSuccess")) != 0) {
1411 1411
 					// authentication succeded, extract the user name
1412
-					if ( sizeof($user_elements = $success_elements[0]->get_elements_by_tagname("user")) == 0) {
1412
+					if (sizeof($user_elements = $success_elements[0]->get_elements_by_tagname("user")) == 0) {
1413 1413
 						phpCAS::trace('<authenticationSuccess> found, but no <user>');
1414 1414
 						$this->authError('ST not validated',
1415 1415
 							$validate_url,
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
 					phpCAS::trace('user = `'.$user);
1422 1422
 					$this->setUser($user);
1423 1423
 					
1424
-				} else if ( sizeof($failure_elements = $tree_response->get_elements_by_tagname("authenticationFailure")) != 0) {
1424
+				} else if (sizeof($failure_elements = $tree_response->get_elements_by_tagname("authenticationFailure")) != 0) {
1425 1425
 					phpCAS::trace('<authenticationFailure> found');
1426 1426
 					// authentication failed, extract the error code and message
1427 1427
 					$this->authError('ST not validated',
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 	 *
1469 1469
 	 * @private
1470 1470
 	 */
1471
-	function validateSA($validate_url,&$text_response,&$tree_response)
1471
+	function validateSA($validate_url, &$text_response, &$tree_response)
1472 1472
 		{
1473 1473
 		phpCAS::traceBegin();
1474 1474
 		
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 		$validate_url = $this->getServerSamlValidateURL();
1477 1477
 		
1478 1478
 		// open and read the URL
1479
-		if ( !$this->readURL($validate_url,''/*cookies*/,$headers,$text_response,$err_msg) ) {
1479
+		if (!$this->readURL($validate_url, ''/*cookies*/, $headers, $text_response, $err_msg)) {
1480 1480
 			phpCAS::trace('could not open URL \''.$validate_url.'\' to validate ('.$err_msg.')');
1481 1481
 			$this->authError('SA not validated', $validate_url, TRUE/*$no_response*/);
1482 1482
 		}
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
 			case SAML_VERSION_1_1:
1489 1489
 				
1490 1490
 				// read the response of the CAS server into a DOM object
1491
-				if ( !($dom = domxml_open_mem($text_response))) {
1491
+				if (!($dom = domxml_open_mem($text_response))) {
1492 1492
 					phpCAS::trace('domxml_open_mem() failed');
1493 1493
 					$this->authError('SA not validated',
1494 1494
 						$validate_url,
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 						$text_response);
1498 1498
 				}
1499 1499
 				// read the root node of the XML tree
1500
-				if ( !($tree_response = $dom->document_element()) ) {
1500
+				if (!($tree_response = $dom->document_element())) {
1501 1501
 					phpCAS::trace('document_element() failed');
1502 1502
 					$this->authError('SA not validated',
1503 1503
 						$validate_url,
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 						$text_response);
1507 1507
 				}
1508 1508
 				// insure that tag name is 'Envelope'
1509
-				if ( $tree_response->node_name() != 'Envelope' ) {
1509
+				if ($tree_response->node_name() != 'Envelope') {
1510 1510
 					phpCAS::trace('bad XML root node (should be `Envelope\' instead of `'.$tree_response->node_name().'\'');
1511 1511
 					$this->authError('SA not validated',
1512 1512
 						$validate_url,
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 						$text_response);
1516 1516
 				}
1517 1517
 				// check for the NameIdentifier tag in the SAML response
1518
-				if ( sizeof($success_elements = $tree_response->get_elements_by_tagname("NameIdentifier")) != 0) {
1518
+				if (sizeof($success_elements = $tree_response->get_elements_by_tagname("NameIdentifier")) != 0) {
1519 1519
 					phpCAS::trace('NameIdentifier found');
1520 1520
 					$user = trim($success_elements[0]->get_content());
1521 1521
 					phpCAS::trace('user = `'.$user.'`');
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
 		$result = FALSE;
1554 1554
 		
1555 1555
 		if (isset($_SESSION[SAML_ATTRIBUTES])) {
1556
-			phpCAS::trace("session attrs already set.");  //testbml - do we care?
1556
+			phpCAS::trace("session attrs already set."); //testbml - do we care?
1557 1557
 		}
1558 1558
 		
1559 1559
 		$attr_array = array();
@@ -1565,21 +1565,21 @@  discard block
 block discarded – undo
1565 1565
 			$nodelist = $xPath->xpath_eval("//saml:Attribute");
1566 1566
 			$attrs = $nodelist->nodeset;
1567 1567
 			phpCAS::trace($text_response);
1568
-			foreach($attrs as $attr){
1568
+			foreach ($attrs as $attr) {
1569 1569
 				$xres = $xPath->xpath_eval("saml:AttributeValue", $attr);
1570 1570
 				$name = $attr->get_attribute("AttributeName");
1571 1571
 				$value_array = array();
1572
-				foreach($xres->nodeset as $node){
1572
+				foreach ($xres->nodeset as $node) {
1573 1573
 					$value_array[] = $node->get_content();
1574 1574
 					
1575 1575
 				}
1576
-				phpCAS::trace("* " . $name . "=" . $value_array);
1576
+				phpCAS::trace("* ".$name."=".$value_array);
1577 1577
 				$attr_array[$name] = $value_array;
1578 1578
 			}
1579 1579
 			$_SESSION[SAML_ATTRIBUTES] = $attr_array;
1580 1580
 			// UGent addition...
1581
-			foreach($attr_array as $attr_key => $attr_value) {
1582
-				if(count($attr_value) > 1) {
1581
+			foreach ($attr_array as $attr_key => $attr_value) {
1582
+				if (count($attr_value) > 1) {
1583 1583
 					$this->_attributes[$attr_key] = $attr_value;
1584 1584
 				}
1585 1585
 				else {
@@ -1741,14 +1741,14 @@  discard block
 block discarded – undo
1741 1741
 	function getCallbackURL()
1742 1742
 		{
1743 1743
 		// the URL is built when needed only
1744
-		if ( empty($this->_callback_url) ) {
1744
+		if (empty($this->_callback_url)) {
1745 1745
 			$final_uri = '';
1746 1746
 			// remove the ticket if present in the URL
1747 1747
 			$final_uri = 'https://';
1748 1748
 			/* replaced by Julien Marchal - v0.4.6
1749 1749
 			 * $this->uri .= $_SERVER['SERVER_NAME'];
1750 1750
 			 */
1751
-			if(empty($_SERVER['HTTP_X_FORWARDED_SERVER'])){
1751
+			if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
1752 1752
 				/* replaced by teedog - v0.4.12
1753 1753
 				 * $final_uri .= $_SERVER['SERVER_NAME'];
1754 1754
 				 */
@@ -1760,13 +1760,13 @@  discard block
 block discarded – undo
1760 1760
 			} else {
1761 1761
 				$final_uri .= $_SERVER['HTTP_X_FORWARDED_SERVER'];
1762 1762
 			}
1763
-			if ( ($this->isHttps() && $_SERVER['SERVER_PORT']!=443)
1764
-					|| (!$this->isHttps() && $_SERVER['SERVER_PORT']!=80) ) {
1763
+			if (($this->isHttps() && $_SERVER['SERVER_PORT'] != 443)
1764
+					|| (!$this->isHttps() && $_SERVER['SERVER_PORT'] != 80)) {
1765 1765
 				$final_uri .= ':';
1766 1766
 				$final_uri .= $_SERVER['SERVER_PORT'];
1767 1767
 			}
1768 1768
 			$request_uri = $_SERVER['REQUEST_URI'];
1769
-			$request_uri = preg_replace('/\?.*$/','',$request_uri);
1769
+			$request_uri = preg_replace('/\?.*$/', '', $request_uri);
1770 1770
 			$final_uri .= $request_uri;
1771 1771
 			$this->setCallbackURL($final_uri);
1772 1772
 		}
@@ -1799,7 +1799,7 @@  discard block
 block discarded – undo
1799 1799
 		$pgt = $_GET['pgtId'];
1800 1800
 		phpCAS::trace('Storing PGT `'.$pgt.'\' (id=`'.$pgt_iou.'\')');
1801 1801
 		echo '<p>Storing PGT `'.$pgt.'\' (id=`'.$pgt_iou.'\').</p>';
1802
-		$this->storePGT($pgt,$pgt_iou);
1802
+		$this->storePGT($pgt, $pgt_iou);
1803 1803
 		$this->printHTMLFooter();
1804 1804
 		phpCAS::traceExit();
1805 1805
 		exit();
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 	function initPGTStorage()
1835 1835
 		{
1836 1836
 		// if no SetPGTStorageXxx() has been used, default to file
1837
-		if ( !is_object($this->_pgt_storage) ) {
1837
+		if (!is_object($this->_pgt_storage)) {
1838 1838
 			$this->setPGTStorageFile();
1839 1839
 		}
1840 1840
 		
@@ -1850,12 +1850,12 @@  discard block
 block discarded – undo
1850 1850
 	 *
1851 1851
 	 * @private
1852 1852
 	 */
1853
-	function storePGT($pgt,$pgt_iou)
1853
+	function storePGT($pgt, $pgt_iou)
1854 1854
 		{
1855 1855
 		// ensure that storage is initialized
1856 1856
 		$this->initPGTStorage();
1857 1857
 		// writes the PGT
1858
-		$this->_pgt_storage->write($pgt,$pgt_iou);
1858
+		$this->_pgt_storage->write($pgt, $pgt_iou);
1859 1859
 		}
1860 1860
 	
1861 1861
 	/**
@@ -1884,16 +1884,16 @@  discard block
 block discarded – undo
1884 1884
 	 *
1885 1885
 	 * @public
1886 1886
 	 */
1887
-	function setPGTStorageFile($format='',
1888
-		$path='')
1887
+	function setPGTStorageFile($format = '',
1888
+		$path = '')
1889 1889
 		{
1890 1890
 		// check that the storage has not already been set
1891
-		if ( is_object($this->_pgt_storage) ) {
1891
+		if (is_object($this->_pgt_storage)) {
1892 1892
 			phpCAS::error('PGT storage already defined');
1893 1893
 		}
1894 1894
 		
1895 1895
 		// create the storage object
1896
-		$this->_pgt_storage = new PGTStorageFile($this,$format,$path);
1896
+		$this->_pgt_storage = new PGTStorageFile($this, $format, $path);
1897 1897
 		}
1898 1898
 	
1899 1899
 	/**
@@ -1922,15 +1922,15 @@  discard block
 block discarded – undo
1922 1922
 							 $table)
1923 1923
 		{
1924 1924
 		// check that the storage has not already been set
1925
-		if ( is_object($this->_pgt_storage) ) {
1925
+		if (is_object($this->_pgt_storage)) {
1926 1926
 			phpCAS::error('PGT storage already defined');
1927 1927
 		}
1928 1928
 		
1929 1929
 		// warn the user that he should use file storage...
1930
-		trigger_error('PGT storage into database is an experimental feature, use at your own risk',E_USER_WARNING);
1930
+		trigger_error('PGT storage into database is an experimental feature, use at your own risk', E_USER_WARNING);
1931 1931
 		
1932 1932
 		// create the storage object
1933
-		$this->_pgt_storage = new PGTStorageDB($this,$user,$password,$database_type,$hostname,$port,$database,$table);
1933
+		$this->_pgt_storage = new PGTStorageDB($this, $user, $password, $database_type, $hostname, $port, $database, $table);
1934 1934
 		}
1935 1935
 	
1936 1936
 	// ########################################################################
@@ -1949,11 +1949,11 @@  discard block
 block discarded – undo
1949 1949
 	 *
1950 1950
 	 * @private
1951 1951
 	 */
1952
-	function validatePGT(&$validate_url,$text_response,$tree_response)
1952
+	function validatePGT(&$validate_url, $text_response, $tree_response)
1953 1953
 		{
1954 1954
 		// here cannot use phpCAS::traceBegin(); alongside domxml-php4-to-php5.php
1955 1955
 		phpCAS::log('start validatePGT()');
1956
-		if ( sizeof($arr = $tree_response->get_elements_by_tagname("proxyGrantingTicket")) == 0) {
1956
+		if (sizeof($arr = $tree_response->get_elements_by_tagname("proxyGrantingTicket")) == 0) {
1957 1957
 			phpCAS::trace('<proxyGrantingTicket> not found');
1958 1958
 			// authentication succeded, but no PGT Iou was transmitted
1959 1959
 			$this->authError('Ticket validated but no PGT Iou transmitted',
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 			// PGT Iou transmitted, extract it
1966 1966
 			$pgt_iou = trim($arr[0]->get_content());
1967 1967
 			$pgt = $this->loadPGT($pgt_iou);
1968
-			if ( $pgt == FALSE ) {
1968
+			if ($pgt == FALSE) {
1969 1969
 				phpCAS::trace('could not load PGT');
1970 1970
 				$this->authError('PGT Iou was transmitted but PGT could not be retrieved',
1971 1971
 					$validate_url,
@@ -1995,7 +1995,7 @@  discard block
 block discarded – undo
1995 1995
 	 *
1996 1996
 	 * @private
1997 1997
 	 */
1998
-	function retrievePT($target_service,&$err_code,&$err_msg)
1998
+	function retrievePT($target_service, &$err_code, &$err_msg)
1999 1999
 		{
2000 2000
 		phpCAS::traceBegin();
2001 2001
 		
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
 		$cas_url = $this->getServerProxyURL().'?targetService='.urlencode($target_service).'&pgt='.$this->getPGT();
2011 2011
 		
2012 2012
 		// open and read the URL
2013
-		if ( !$this->readURL($cas_url,''/*cookies*/,$headers,$cas_response,$err_msg) ) {
2013
+		if (!$this->readURL($cas_url, ''/*cookies*/, $headers, $cas_response, $err_msg)) {
2014 2014
 			phpCAS::trace('could not open URL \''.$cas_url.'\' to validate ('.$err_msg.')');
2015 2015
 			$err_code = PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE;
2016 2016
 			$err_msg = 'could not retrieve PT (no response from the CAS server)';
@@ -2020,38 +2020,38 @@  discard block
 block discarded – undo
2020 2020
 		
2021 2021
 		$bad_response = FALSE;
2022 2022
 		
2023
-		if ( !$bad_response ) {
2023
+		if (!$bad_response) {
2024 2024
 			// read the response of the CAS server into a DOM object
2025
-			if ( !($dom = @domxml_open_mem($cas_response))) {
2025
+			if (!($dom = @domxml_open_mem($cas_response))) {
2026 2026
 				phpCAS::trace('domxml_open_mem() failed');
2027 2027
 				// read failed
2028 2028
 				$bad_response = TRUE;
2029 2029
 			} 
2030 2030
 		}
2031 2031
 		
2032
-		if ( !$bad_response ) {
2032
+		if (!$bad_response) {
2033 2033
 			// read the root node of the XML tree
2034
-			if ( !($root = $dom->document_element()) ) {
2034
+			if (!($root = $dom->document_element())) {
2035 2035
 				phpCAS::trace('document_element() failed');
2036 2036
 				// read failed
2037 2037
 				$bad_response = TRUE;
2038 2038
 			} 
2039 2039
 		}
2040 2040
 		
2041
-		if ( !$bad_response ) {
2041
+		if (!$bad_response) {
2042 2042
 			// insure that tag name is 'serviceResponse'
2043
-			if ( $root->node_name() != 'serviceResponse' ) {
2043
+			if ($root->node_name() != 'serviceResponse') {
2044 2044
 				phpCAS::trace('node_name() failed');
2045 2045
 				// bad root node
2046 2046
 				$bad_response = TRUE;
2047 2047
 			} 
2048 2048
 		}
2049 2049
 		
2050
-		if ( !$bad_response ) {
2050
+		if (!$bad_response) {
2051 2051
 			// look for a proxySuccess tag
2052
-			if ( sizeof($arr = $root->get_elements_by_tagname("proxySuccess")) != 0) {
2052
+			if (sizeof($arr = $root->get_elements_by_tagname("proxySuccess")) != 0) {
2053 2053
 				// authentication succeded, look for a proxyTicket tag
2054
-				if ( sizeof($arr = $root->get_elements_by_tagname("proxyTicket")) != 0) {
2054
+				if (sizeof($arr = $root->get_elements_by_tagname("proxyTicket")) != 0) {
2055 2055
 					$err_code = PHPCAS_SERVICE_OK;
2056 2056
 					$err_msg = '';
2057 2057
 					phpCAS::trace('original PT: '.trim($arr[0]->get_content()));
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 				}
2064 2064
 			} 
2065 2065
 			// look for a proxyFailure tag
2066
-			else if ( sizeof($arr = $root->get_elements_by_tagname("proxyFailure")) != 0) {
2066
+			else if (sizeof($arr = $root->get_elements_by_tagname("proxyFailure")) != 0) {
2067 2067
 				// authentication failed, extract the error
2068 2068
 				$err_code = PHPCAS_SERVICE_PT_FAILURE;
2069 2069
 				$err_msg = 'PT retrieving failed (code=`'
@@ -2105,7 +2105,7 @@  discard block
 block discarded – undo
2105 2105
 	 *
2106 2106
 	 * @private
2107 2107
 	 */
2108
-	function readURL($url,$cookies,&$headers,&$body,&$err_msg)
2108
+	function readURL($url, $cookies, &$headers, &$body, &$err_msg)
2109 2109
 		{
2110 2110
 		phpCAS::traceBegin();
2111 2111
 		$headers = '';
@@ -2117,7 +2117,7 @@  discard block
 block discarded – undo
2117 2117
 		// initialize the CURL session
2118 2118
 		$ch = curl_init($url);
2119 2119
 		
2120
-		if (version_compare(PHP_VERSION,'5.1.3','>=')) {
2120
+		if (version_compare(PHP_VERSION, '5.1.3', '>=')) {
2121 2121
 			//only avaible in php5
2122 2122
 			curl_setopt_array($ch, $this->_curl_options);
2123 2123
 		} else {
@@ -2137,7 +2137,7 @@  discard block
 block discarded – undo
2137 2137
 			curl_setopt($ch, CURLOPT_CAINFO, $this->_cas_server_ca_cert);
2138 2138
 			curl_setopt($ch, CURLOPT_VERBOSE, '1');
2139 2139
 			phpCAS::trace('CURL: Set all required opts for mutual authentication ------');
2140
-		} else if ($this->_cas_server_cert != '' ) {
2140
+		} else if ($this->_cas_server_cert != '') {
2141 2141
 			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
2142 2142
 			curl_setopt($ch, CURLOPT_SSLCERT, $this->_cas_server_cert);
2143 2143
 		} else if ($this->_cas_server_ca_cert != '') {
@@ -2154,12 +2154,12 @@  discard block
 block discarded – undo
2154 2154
 		$this->_curl_headers = array(); // empty the headers array
2155 2155
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, '_curl_read_headers'));
2156 2156
 		// add cookies headers
2157
-		if ( is_array($cookies) ) {
2158
-			curl_setopt($ch,CURLOPT_COOKIE,implode(';',$cookies));
2157
+		if (is_array($cookies)) {
2158
+			curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookies));
2159 2159
 		}
2160 2160
 		// add extra stuff if SAML
2161 2161
 		if ($this->hasSA()) {
2162
-			$more_headers = array ("soapaction: http://www.oasis-open.org/committees/security",
2162
+			$more_headers = array("soapaction: http://www.oasis-open.org/committees/security",
2163 2163
 				"cache-control: no-cache",
2164 2164
 				"pragma: no-cache",
2165 2165
 				"accept: text/xml",
@@ -2173,18 +2173,18 @@  discard block
 block discarded – undo
2173 2173
 			curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
2174 2174
 		}
2175 2175
 		// perform the query
2176
-		$buf = curl_exec ($ch);
2176
+		$buf = curl_exec($ch);
2177 2177
 		//phpCAS::trace('CURL: Call completed. Response body is: \''.$buf.'\'');
2178
-		if ( $buf === FALSE ) {
2178
+		if ($buf === FALSE) {
2179 2179
 			phpCAS::trace('curl_exec() failed');
2180 2180
 			$err_msg = 'CURL error #'.curl_errno($ch).': '.curl_error($ch);
2181 2181
 			//phpCAS::trace('curl error: '.$err_msg);
2182 2182
 			// close the CURL session
2183
-			curl_close ($ch);
2183
+			curl_close($ch);
2184 2184
 			$res = FALSE;
2185 2185
 		} else {
2186 2186
 			// close the CURL session
2187
-			curl_close ($ch);
2187
+			curl_close($ch);
2188 2188
 			
2189 2189
 			$headers = $this->_curl_headers;
2190 2190
 			$body = $buf;
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 		$sa = $this->getSA();
2210 2210
 		//phpCAS::trace("SA: ".$sa);
2211 2211
 		
2212
-		$body=SAML_SOAP_ENV.SAML_SOAP_BODY.SAMLP_REQUEST.SAML_ASSERTION_ARTIFACT.$sa.SAML_ASSERTION_ARTIFACT_CLOSE.SAMLP_REQUEST_CLOSE.SAML_SOAP_BODY_CLOSE.SAML_SOAP_ENV_CLOSE;
2212
+		$body = SAML_SOAP_ENV.SAML_SOAP_BODY.SAMLP_REQUEST.SAML_ASSERTION_ARTIFACT.$sa.SAML_ASSERTION_ARTIFACT_CLOSE.SAMLP_REQUEST_CLOSE.SAML_SOAP_BODY_CLOSE.SAML_SOAP_ENV_CLOSE;
2213 2213
 		
2214 2214
 		phpCAS::traceEnd($body);
2215 2215
 		return ($body);
@@ -2240,36 +2240,36 @@  discard block
 block discarded – undo
2240 2240
 	 *
2241 2241
 	 * @public
2242 2242
 	 */
2243
-	function serviceWeb($url,&$err_code,&$output)
2243
+	function serviceWeb($url, &$err_code, &$output)
2244 2244
 		{
2245 2245
 		phpCAS::traceBegin();
2246 2246
 		// at first retrieve a PT
2247
-		$pt = $this->retrievePT($url,$err_code,$output);
2247
+		$pt = $this->retrievePT($url, $err_code, $output);
2248 2248
 		
2249 2249
 		$res = TRUE;
2250 2250
 		
2251 2251
 		// test if PT was retrieved correctly
2252
-		if ( !$pt ) {
2252
+		if (!$pt) {
2253 2253
 			// note: $err_code and $err_msg are filled by CASClient::retrievePT()
2254 2254
 			phpCAS::trace('PT was not retrieved correctly');
2255 2255
 			$res = FALSE;
2256 2256
 		} else {
2257 2257
 			// add cookies if necessary
2258
-			if ( is_array($_SESSION['phpCAS']['services'][$url]['cookies']) ) {
2259
-				foreach ( $_SESSION['phpCAS']['services'][$url]['cookies'] as $name => $val ) { 
2258
+			if (is_array($_SESSION['phpCAS']['services'][$url]['cookies'])) {
2259
+				foreach ($_SESSION['phpCAS']['services'][$url]['cookies'] as $name => $val) { 
2260 2260
 					$cookies[] = $name.'='.$val;
2261 2261
 				}
2262 2262
 			}
2263 2263
 			
2264 2264
 			// build the URL including the PT
2265
-			if ( strstr($url,'?') === FALSE ) {
2265
+			if (strstr($url, '?') === FALSE) {
2266 2266
 				$service_url = $url.'?ticket='.$pt;
2267 2267
 			} else {
2268 2268
 				$service_url = $url.'&ticket='.$pt;
2269 2269
 			}
2270 2270
 			
2271 2271
 			phpCAS::trace('reading URL`'.$service_url.'\'');
2272
-			if ( !$this->readURL($service_url,$cookies,$headers,$output,$err_msg) ) {
2272
+			if (!$this->readURL($service_url, $cookies, $headers, $output, $err_msg)) {
2273 2273
 				phpCAS::trace('could not read URL`'.$service_url.'\'');
2274 2274
 				$err_code = PHPCAS_SERVICE_NOT_AVAILABLE;
2275 2275
 				// give an error message
@@ -2280,15 +2280,15 @@  discard block
 block discarded – undo
2280 2280
 			} else {
2281 2281
 				// URL has been fetched, extract the cookies
2282 2282
 				phpCAS::trace('URL`'.$service_url.'\' has been read, storing cookies:');
2283
-				foreach ( $headers as $header ) {
2283
+				foreach ($headers as $header) {
2284 2284
 					// test if the header is a cookie
2285
-					if ( preg_match('/^Set-Cookie:/',$header) ) {
2285
+					if (preg_match('/^Set-Cookie:/', $header)) {
2286 2286
 						// the header is a cookie, remove the beginning
2287
-						$header_val = preg_replace('/^Set-Cookie: */','',$header);
2287
+						$header_val = preg_replace('/^Set-Cookie: */', '', $header);
2288 2288
 						// extract interesting information
2289
-						$name_val = strtok($header_val,'; ');
2289
+						$name_val = strtok($header_val, '; ');
2290 2290
 						// extract the name and the value of the cookie
2291
-						$cookie_name = strtok($name_val,'=');
2291
+						$cookie_name = strtok($name_val, '=');
2292 2292
 						$cookie_val = strtok('=');
2293 2293
 						// store the cookie 
2294 2294
 						$_SESSION['phpCAS']['services'][$url]['cookies'][$cookie_name] = $cookie_val;
@@ -2321,28 +2321,28 @@  discard block
 block discarded – undo
2321 2321
 	 *
2322 2322
 	 * @public
2323 2323
 	 */
2324
-	function serviceMail($url,$service,$flags,&$err_code,&$err_msg,&$pt)
2324
+	function serviceMail($url, $service, $flags, &$err_code, &$err_msg, &$pt)
2325 2325
 		{
2326 2326
 		phpCAS::traceBegin();
2327 2327
 		// at first retrieve a PT
2328
-		$pt = $this->retrievePT($service,$err_code,$output);
2328
+		$pt = $this->retrievePT($service, $err_code, $output);
2329 2329
 		
2330 2330
 		$stream = FALSE;
2331 2331
 		
2332 2332
 		// test if PT was retrieved correctly
2333
-		if ( !$pt ) {
2333
+		if (!$pt) {
2334 2334
 			// note: $err_code and $err_msg are filled by CASClient::retrievePT()
2335 2335
 			phpCAS::trace('PT was not retrieved correctly');
2336 2336
 		} else {
2337 2337
 			phpCAS::trace('opening IMAP URL `'.$url.'\'...');
2338
-			$stream = @imap_open($url,$this->getUser(),$pt,$flags);
2339
-			if ( !$stream ) {
2338
+			$stream = @imap_open($url, $this->getUser(), $pt, $flags);
2339
+			if (!$stream) {
2340 2340
 				phpCAS::trace('could not open URL');
2341 2341
 				$err_code = PHPCAS_SERVICE_NOT_AVAILABLE;
2342 2342
 				// give an error message
2343 2343
 				$err_msg = sprintf($this->getString(CAS_STR_SERVICE_UNAVAILABLE),
2344 2344
 					$service_url,
2345
-					var_export(imap_errors(),TRUE));
2345
+					var_export(imap_errors(), TRUE));
2346 2346
 				$pt = FALSE;
2347 2347
 				$stream = FALSE;
2348 2348
 			} else {
@@ -2446,19 +2446,19 @@  discard block
 block discarded – undo
2446 2446
 	 *
2447 2447
 	 * @private
2448 2448
 	 */
2449
-	function validatePT(&$validate_url,&$text_response,&$tree_response)
2449
+	function validatePT(&$validate_url, &$text_response, &$tree_response)
2450 2450
 		{
2451 2451
 		phpCAS::traceBegin();
2452 2452
 		// build the URL to validate the ticket
2453 2453
 		$validate_url = $this->getServerProxyValidateURL().'&ticket='.$this->getPT();
2454 2454
 		
2455
-		if ( $this->isProxy() ) {
2455
+		if ($this->isProxy()) {
2456 2456
 			// pass the callback url for CAS proxies
2457 2457
 			$validate_url .= '&pgtUrl='.$this->getCallbackURL();
2458 2458
 		}
2459 2459
 		
2460 2460
 		// open and read the URL
2461
-		if ( !$this->readURL($validate_url,''/*cookies*/,$headers,$text_response,$err_msg) ) {
2461
+		if (!$this->readURL($validate_url, ''/*cookies*/, $headers, $text_response, $err_msg)) {
2462 2462
 			phpCAS::trace('could not open URL \''.$validate_url.'\' to validate ('.$err_msg.')');
2463 2463
 			$this->authError('PT not validated',
2464 2464
 				$validate_url,
@@ -2466,7 +2466,7 @@  discard block
 block discarded – undo
2466 2466
 		}
2467 2467
 		
2468 2468
 		// read the response of the CAS server into a DOM object
2469
-		if ( !($dom = domxml_open_mem($text_response))) {
2469
+		if (!($dom = domxml_open_mem($text_response))) {
2470 2470
 			// read failed
2471 2471
 			$this->authError('PT not validated',
2472 2472
 				$validate_url,
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 				$text_response);
2476 2476
 		}
2477 2477
 		// read the root node of the XML tree
2478
-		if ( !($tree_response = $dom->document_element()) ) {
2478
+		if (!($tree_response = $dom->document_element())) {
2479 2479
 			// read failed
2480 2480
 			$this->authError('PT not validated',
2481 2481
 				$validate_url,
@@ -2484,7 +2484,7 @@  discard block
 block discarded – undo
2484 2484
 				$text_response);
2485 2485
 		}
2486 2486
 		// insure that tag name is 'serviceResponse'
2487
-		if ( $tree_response->node_name() != 'serviceResponse' ) {
2487
+		if ($tree_response->node_name() != 'serviceResponse') {
2488 2488
 			// bad root node
2489 2489
 			$this->authError('PT not validated',
2490 2490
 				$validate_url,
@@ -2492,9 +2492,9 @@  discard block
 block discarded – undo
2492 2492
 				TRUE/*$bad_response*/,
2493 2493
 				$text_response);
2494 2494
 		}
2495
-		if ( sizeof($arr = $tree_response->get_elements_by_tagname("authenticationSuccess")) != 0) {
2495
+		if (sizeof($arr = $tree_response->get_elements_by_tagname("authenticationSuccess")) != 0) {
2496 2496
 			// authentication succeded, extract the user name
2497
-			if ( sizeof($arr = $tree_response->get_elements_by_tagname("user")) == 0) {
2497
+			if (sizeof($arr = $tree_response->get_elements_by_tagname("user")) == 0) {
2498 2498
 				// no user specified => error
2499 2499
 				$this->authError('PT not validated',
2500 2500
 					$validate_url,
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 			}
2505 2505
 			$this->setUser(trim($arr[0]->get_content()));
2506 2506
 			
2507
-		} else if ( sizeof($arr = $tree_response->get_elements_by_tagname("authenticationFailure")) != 0) {
2507
+		} else if (sizeof($arr = $tree_response->get_elements_by_tagname("authenticationFailure")) != 0) {
2508 2508
 			// authentication succeded, extract the error code and message
2509 2509
 			$this->authError('PT not validated',
2510 2510
 				$validate_url,
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 		{
2565 2565
 		phpCAS::traceBegin();
2566 2566
 		// the URL is built when needed only
2567
-		if ( empty($this->_url) ) {
2567
+		if (empty($this->_url)) {
2568 2568
 			$final_uri = '';
2569 2569
 			// remove the ticket if present in the URL
2570 2570
 			$final_uri = ($this->isHttps()) ? 'https' : 'http';
@@ -2572,7 +2572,7 @@  discard block
 block discarded – undo
2572 2572
 			/* replaced by Julien Marchal - v0.4.6
2573 2573
 			 * $this->_url .= $_SERVER['SERVER_NAME'];
2574 2574
 			 */
2575
-			if(empty($_SERVER['HTTP_X_FORWARDED_SERVER'])){
2575
+			if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
2576 2576
 				/* replaced by teedog - v0.4.12
2577 2577
 				 * $this->_url .= $_SERVER['SERVER_NAME'];
2578 2578
 				 */
@@ -2586,8 +2586,8 @@  discard block
 block discarded – undo
2586 2586
 			}
2587 2587
 			$final_uri .= $server_name;
2588 2588
 			if (!strpos($server_name, ':')) {
2589
-				if ( ($this->isHttps() && $_SERVER['SERVER_PORT']!=443)
2590
-						|| (!$this->isHttps() && $_SERVER['SERVER_PORT']!=80) ) {
2589
+				if (($this->isHttps() && $_SERVER['SERVER_PORT'] != 443)
2590
+						|| (!$this->isHttps() && $_SERVER['SERVER_PORT'] != 80)) {
2591 2591
 					$final_uri .= ':';
2592 2592
 					$final_uri .= $_SERVER['SERVER_PORT'];
2593 2593
 				}
@@ -2598,11 +2598,11 @@  discard block
 block discarded – undo
2598 2598
 			
2599 2599
 			if (isset($request_uri[1]) && $request_uri[1])
2600 2600
 			{
2601
-				$query_string	= $this->removeParameterFromQueryString('ticket', $request_uri[1]);
2601
+				$query_string = $this->removeParameterFromQueryString('ticket', $request_uri[1]);
2602 2602
 				
2603 2603
 				// If the query string still has anything left, append it to the final URI
2604 2604
 				if ($query_string !== '')
2605
-					$final_uri	.= "?$query_string";
2605
+					$final_uri .= "?$query_string";
2606 2606
 				
2607 2607
 			}
2608 2608
 			
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
 	 */
2627 2627
 	function removeParameterFromQueryString($parameterName, $queryString)
2628 2628
 	{
2629
-		$parameterName	= preg_quote($parameterName);
2629
+		$parameterName = preg_quote($parameterName);
2630 2630
 		return preg_replace("/&$parameterName(=[^&]*)?|^$parameterName(=[^&]*)?&?/", '', $queryString);
2631 2631
 	}
2632 2632
 
@@ -2661,18 +2661,18 @@  discard block
 block discarded – undo
2661 2661
 	 *
2662 2662
 	 * @private
2663 2663
 	 */
2664
-	function authError($failure,$cas_url,$no_response,$bad_response='',$cas_response='',$err_code='',$err_msg='')
2664
+	function authError($failure, $cas_url, $no_response, $bad_response = '', $cas_response = '', $err_code = '', $err_msg = '')
2665 2665
 		{
2666 2666
 		phpCAS::traceBegin();
2667 2667
 		
2668 2668
 		$this->printHTMLHeader($this->getString(CAS_STR_AUTHENTICATION_FAILED));
2669
-		printf($this->getString(CAS_STR_YOU_WERE_NOT_AUTHENTICATED),htmlentities($this->getURL()),$_SERVER['SERVER_ADMIN']);
2669
+		printf($this->getString(CAS_STR_YOU_WERE_NOT_AUTHENTICATED), htmlentities($this->getURL()), $_SERVER['SERVER_ADMIN']);
2670 2670
 		phpCAS::trace('CAS URL: '.$cas_url);
2671 2671
 		phpCAS::trace('Authentication failure: '.$failure);
2672
-		if ( $no_response ) {
2672
+		if ($no_response) {
2673 2673
 			phpCAS::trace('Reason: no response from the CAS server');
2674 2674
 		} else {
2675
-			if ( $bad_response ) {
2675
+			if ($bad_response) {
2676 2676
 				phpCAS::trace('Reason: bad response from the CAS server');
2677 2677
 			} else {
2678 2678
 				switch ($this->getServerVersion()) {
@@ -2680,7 +2680,7 @@  discard block
 block discarded – undo
2680 2680
 						phpCAS::trace('Reason: CAS error');
2681 2681
 						break;
2682 2682
 					case CAS_VERSION_2_0:
2683
-						if ( empty($err_code) )
2683
+						if (empty($err_code))
2684 2684
 							phpCAS::trace('Reason: no CAS error');
2685 2685
 						else
2686 2686
 							phpCAS::trace('Reason: ['.$err_code.'] CAS error: '.$err_msg);
Please login to merge, or discard this patch.