Completed
Push — 1.10.x ( 181e18...3b3cbc )
by Angel Fernando Quiroz
104:16 queued 53:32
created
main/auth/ldap/authldap.php 4 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 require 'ldap_var.inc.php';
68 68
 /**
69 69
  *    Check login and password with LDAP
70
- *    @return true when login & password both OK, false otherwise
70
+ *    @return boolean when login & password both OK, false otherwise
71 71
  *    @author Roan Embrechts (based on code from Universit� Jean Monet)
72 72
  */
73 73
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 } // end of check
306 306
 /**
307 307
  * Set the protocol version with version from config file (enables LDAP version 3)
308
- * @param    resource    The LDAP connexion resource, passed by reference.
308
+ * @param    resource    resource LDAP connexion resource, passed by reference.
309 309
  * @return    void
310 310
  */
311 311
 function ldap_set_version(&$resource) {
@@ -323,6 +323,7 @@  discard block
 block discarded – undo
323 323
  * Handle bind (whether authenticated or not)
324 324
  * @param    resource    The LDAP handler to which we are connecting (by reference)
325 325
  * @param    resource    The LDAP bind handler we will be modifying
326
+ * @param boolean $ldap_bind
326 327
  * @return    boolean        Status of the bind assignment. True for success, false for failure.
327 328
  */
328 329
 function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
     // res=-1 -> the user does not exist in the ldap database
79 79
     // res=1 -> invalid password (user does exist)
80 80
 
81
-    if ($res==1) { //WRONG PASSWORD
81
+    if ($res == 1) { //WRONG PASSWORD
82 82
         //$errorMessage = "LDAP User or password incorrect, try again.<br />";
83 83
         if (isset($log)) unset($log); if (isset($uid)) unset($uid);
84 84
         $loginLdapSucces = false;
85 85
     }
86
-    if ($res==-1) { //WRONG USERNAME
86
+    if ($res == -1) { //WRONG USERNAME
87 87
         //$errorMessage =  "LDAP User or password incorrect, try again.<br />";
88 88
         $login_ldap_success = false;
89 89
     }
90
-    if ($res==0) { //LOGIN & PASSWORD OK - SUCCES
90
+    if ($res == 0) { //LOGIN & PASSWORD OK - SUCCES
91 91
         //$errorMessage = "Successful login w/ LDAP.<br>";
92 92
         $login_ldap_success = true;
93 93
     }
@@ -103,30 +103,30 @@  discard block
 block discarded – undo
103 103
  *    @author Stefan De Wannemacker
104 104
  *    @author Roan Embrechts
105 105
  */
106
-function ldap_find_user_info ($login) {
106
+function ldap_find_user_info($login) {
107 107
     //error_log('Entering ldap_find_user_info('.$login.')',0);
108 108
     global $ldap_host, $ldap_port, $ldap_basedn, $ldap_rdn, $ldap_pass, $ldap_search_dn;
109 109
     // basic sequence with LDAP is connect, bind, search,
110 110
     // interpret search result, close connection
111 111
 
112 112
     //echo "Connecting ...";
113
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
113
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
114 114
     ldap_set_version($ldap_connect);
115 115
     if ($ldap_connect) {
116 116
         //echo " Connect to LDAP server successful ";
117 117
         //echo "Binding ...";
118 118
         $ldap_bind = false;
119
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
119
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
120 120
         if ($ldap_bind_res) {
121 121
             //echo " LDAP bind successful... ";
122 122
             //echo " Searching for uid... ";
123 123
             // Search surname entry
124 124
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
125 125
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
126
-            if(!empty($ldap_search_dn)) {
127
-                $sr=ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
126
+            if (!empty($ldap_search_dn)) {
127
+                $sr = ldap_search($ldap_connect, $ldap_search_dn, "uid=$login");
128 128
             } else {
129
-                $sr=ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
129
+                $sr = ldap_search($ldap_connect, $ldap_basedn, "uid=$login");
130 130
             }
131 131
             //echo " Search result is ".$sr;
132 132
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
@@ -177,25 +177,25 @@  discard block
 block discarded – undo
177 177
     $password1  = $ldap_pass_placeholder;
178 178
     $official_code = '';
179 179
 
180
-    define ("STUDENT",5);
181
-    define ("COURSEMANAGER",1);
180
+    define("STUDENT", 5);
181
+    define("COURSEMANAGER", 1);
182 182
 
183 183
     $tutor_field = api_get_setting('ldap_filled_tutor_field');
184 184
     $tutor_value = api_get_setting('ldap_filled_tutor_field_value');
185
-    if(empty($tutor_field)) {
185
+    if (empty($tutor_field)) {
186 186
         $status = STUDENT;
187 187
     } else {
188
-        if(empty($tutor_value)) {
188
+        if (empty($tutor_value)) {
189 189
             //in this case, we are assuming that the admin didn't give a criteria
190 190
             // so that if the field is not empty, it is a tutor
191
-            if(!empty($info_array[$tutor_field])) {
191
+            if (!empty($info_array[$tutor_field])) {
192 192
                 $status = COURSEMANAGER;
193 193
             } else {
194 194
                 $status = STUDENT;
195 195
             }
196 196
         } else {
197 197
             //the tutor_value is filled, so we need to check the contents of the LDAP field
198
-            if (is_array($info_array[$tutor_field]) && in_array($tutor_value,$info_array[$tutor_field])) {
198
+            if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) {
199 199
                 $status = COURSEMANAGER;
200 200
             } else {
201 201
                 $status = STUDENT;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     if (empty($language)) { $language = 'english'; }
213 213
     $_userId = UserManager::create_user($prenom, $nom, $status,
214 214
                      $email, $uname, $password, $official_code,
215
-                     $language,'', '', 'ldap');
215
+                     $language, '', '', 'ldap');
216 216
 
217 217
     //echo "new user added to Chamilo, id = $_userId";
218 218
 
@@ -246,58 +246,58 @@  discard block
 block discarded – undo
246 246
  * @param string password given by user
247 247
  * @return int 0 if authentication succeeded, 1 if password was incorrect, -1 if it didn't belong to LDAP
248 248
  */
249
-function ldap_authentication_check ($uname, $passwd) {
249
+function ldap_authentication_check($uname, $passwd) {
250 250
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
251
-    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2,$ldap_rdn,$ldap_pass;
251
+    global $ldap_host, $ldap_port, $ldap_basedn, $ldap_host2, $ldap_port2, $ldap_rdn, $ldap_pass;
252 252
     //error_log('Entering ldap_authentication_check('.$uname.','.$passwd.')',0);
253 253
     // Establish anonymous connection with LDAP server
254 254
     // Etablissement de la connexion anonyme avec le serveur LDAP
255
-    $ds=ldap_connect($ldap_host,$ldap_port);
255
+    $ds = ldap_connect($ldap_host, $ldap_port);
256 256
     ldap_set_version($ds);
257 257
 
258 258
     $test_bind = false;
259
-    $test_bind_res = ldap_handle_bind($ds,$test_bind);
259
+    $test_bind_res = ldap_handle_bind($ds, $test_bind);
260 260
     //if problem, use the replica
261
-    if ($test_bind_res===false) {
262
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
261
+    if ($test_bind_res === false) {
262
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
263 263
         ldap_set_version($ds);
264 264
     } else {
265 265
         //error_log('Connected to server '.$ldap_host);
266 266
     }
267
-    if ($ds!==false) {
267
+    if ($ds !== false) {
268 268
         //Creation of filter containing values input by the user
269 269
         // Here it might be necessary to use $filter="(samaccountName=$uname)"; - see http://support.chamilo.org/issues/4675
270
-        $filter="(uid=$uname)";
270
+        $filter = "(uid=$uname)";
271 271
         // Open anonymous LDAP connection
272
-        $result=false;
273
-        $ldap_bind_res = ldap_handle_bind($ds,$result);
272
+        $result = false;
273
+        $ldap_bind_res = ldap_handle_bind($ds, $result);
274 274
 	// Executing the search with the $filter parametr
275 275
         //error_log('Searching for '.$filter.' on LDAP server',0);
276
-        $sr=ldap_search($ds,$ldap_basedn,$filter);
276
+        $sr = ldap_search($ds, $ldap_basedn, $filter);
277 277
         $info = ldap_get_entries($ds, $sr);
278
-        $dn=($info[0]["dn"]);
278
+        $dn = ($info[0]["dn"]);
279 279
         // debug !!    echo"<br> dn = $dn<br> pass = $passwd<br>";
280 280
         // closing 1st connection
281 281
         ldap_close($ds);
282 282
     }
283 283
 
284 284
     // test the Distinguish Name from the 1st connection
285
-    if ($dn=="") {
286
-        return (-1);        // doesn't belong to the addressbook
285
+    if ($dn == "") {
286
+        return (-1); // doesn't belong to the addressbook
287 287
     }
288 288
     //bug ldap.. if password empty, return 1!
289
-    if ($passwd=="") {
289
+    if ($passwd == "") {
290 290
         return(1);
291 291
     }
292 292
     // Opening 2nd LDAP connection : Connection user for password check
293
-    $ds=ldap_connect($ldap_host,$ldap_port);
293
+    $ds = ldap_connect($ldap_host, $ldap_port);
294 294
     ldap_set_version($ds);
295 295
     if (!$test_bind) {
296
-        $ds=ldap_connect($ldap_host2,$ldap_port2);
296
+        $ds = ldap_connect($ldap_host2, $ldap_port2);
297 297
         ldap_set_version($ds);
298 298
     }
299 299
     // return in case of wrong password connection error
300
-    if (@ldap_bind( $ds, $dn , $passwd) === false) {
300
+    if (@ldap_bind($ds, $dn, $passwd) === false) {
301 301
         return (1); // invalid password
302 302
     } else {// connection successfull
303 303
         return (0);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 function ldap_set_version(&$resource) {
312 312
     //error_log('Entering ldap_set_version(&$resource)',0);
313 313
     global $ldap_version;
314
-    if ($ldap_version>2) {
314
+    if ($ldap_version > 2) {
315 315
         if (ldap_set_option($resource, LDAP_OPT_PROTOCOL_VERSION, 3)) {
316 316
             //ok - don't do anything
317 317
         } else {
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
  * @param    resource    The LDAP bind handler we will be modifying
326 326
  * @return    boolean        Status of the bind assignment. True for success, false for failure.
327 327
  */
328
-function ldap_handle_bind(&$ldap_handler,&$ldap_bind) {
328
+function ldap_handle_bind(&$ldap_handler, &$ldap_bind) {
329 329
     //error_log('Entering ldap_handle_bind(&$ldap_handler,&$ldap_bind)',0);
330
-    global $ldap_rdn,$ldap_pass, $extldap_config;
330
+    global $ldap_rdn, $ldap_pass, $extldap_config;
331 331
     $ldap_rdn = $extldap_config['admin_dn'];
332 332
     $ldap_pass = $extldap_config['admin_password'];
333 333
     if (!empty($ldap_rdn) and !empty($ldap_pass)) {
334 334
         //error_log('Trying authenticated login :'.$ldap_rdn.'/'.$ldap_pass,0);
335
-        $ldap_bind = ldap_bind($ldap_handler,$ldap_rdn,$ldap_pass);
335
+        $ldap_bind = ldap_bind($ldap_handler, $ldap_rdn, $ldap_pass);
336 336
         if (!$ldap_bind) {
337 337
             //error_log('Authenticated login failed',0);
338 338
             //try in anonymous mode, you never know...
@@ -358,40 +358,40 @@  discard block
 block discarded – undo
358 358
 
359 359
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn, $extldap_user_correspondance;
360 360
 
361
-    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])): '';
361
+    $keyword_firstname = isset($_GET['keyword_firstname']) ? trim(Database::escape_string($_GET['keyword_firstname'])) : '';
362 362
     $keyword_lastname = isset($_GET['keyword_lastname']) ? trim(Database::escape_string($_GET['keyword_lastname'])) : '';
363 363
     $keyword_username = isset($_GET['keyword_username']) ? trim(Database::escape_string($_GET['keyword_username'])) : '';
364 364
     $keyword_type = isset($_GET['keyword_type']) ? Database::escape_string($_GET['keyword_type']) : '';
365 365
 
366
-    $ldap_query=array();
366
+    $ldap_query = array();
367 367
 
368 368
     if ($keyword_username != "") {
369 369
         $ldap_query[] = str_replace('%username%', $keyword_username, $ldap_search_dn);
370 370
     } else {
371
-        if ($keyword_lastname!=""){
372
-            $ldap_query[]="(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
371
+        if ($keyword_lastname != "") {
372
+            $ldap_query[] = "(".$extldap_user_correspondance['lastname']."=".$keyword_lastname."*)";
373 373
         }
374
-        if ($keyword_firstname!="") {
375
-            $ldap_query[]="(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
374
+        if ($keyword_firstname != "") {
375
+            $ldap_query[] = "(".$extldap_user_correspondance['firstname']."=".$keyword_firstname."*)";
376 376
         }
377 377
     }
378
-    if ($keyword_type !="" && $keyword_type !="all") {
379
-        $ldap_query[]="(employeeType=".$keyword_type.")";
378
+    if ($keyword_type != "" && $keyword_type != "all") {
379
+        $ldap_query[] = "(employeeType=".$keyword_type.")";
380 380
     }
381 381
 
382
-    if (count($ldap_query)>1){
383
-        $str_query.="(& ";
384
-        foreach ($ldap_query as $query){
385
-            $str_query.=" $query";
382
+    if (count($ldap_query) > 1) {
383
+        $str_query .= "(& ";
384
+        foreach ($ldap_query as $query) {
385
+            $str_query .= " $query";
386 386
         }
387
-        $str_query.=" )";
387
+        $str_query .= " )";
388 388
     } else {
389
-        $str_query= count($ldap_query) > 0 ? $ldap_query[0] : null;
389
+        $str_query = count($ldap_query) > 0 ? $ldap_query[0] : null;
390 390
     }
391 391
 
392 392
     $ds = ldap_connect($ldap_host, $ldap_port);
393 393
     ldap_set_version($ds);
394
-    if ($ds && count($ldap_query)>0) {
394
+    if ($ds && count($ldap_query) > 0) {
395 395
         $r = false;
396 396
         $res = ldap_handle_bind($ds, $r);
397 397
         //$sr = ldap_search($ds, "ou=test-ou,$ldap_basedn", $str_query);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         return $info;
402 402
 
403 403
     } else {
404
-        if (count($ldap_query)!=0)
404
+        if (count($ldap_query) != 0)
405 405
             Display :: display_error_message(get_lang('LDAPConnectionError'));
406 406
         return array();
407 407
     }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
  */
415 415
 function ldap_get_number_of_users() {
416 416
     $info = ldap_get_users();
417
-    if (count($info)>0) {
417
+    if (count($info) > 0) {
418 418
         return $info['count'];
419 419
     } else {
420 420
         return 0;
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
     $is_western_name_order = api_is_western_name_order();
435 435
     if (isset($_GET['submit'])) {
436 436
         $info = ldap_get_users();
437
-        if ($info['count']>0) {
438
-            for ($key = 0; $key < $info["count"]; $key ++) {
439
-                $user=array();
437
+        if ($info['count'] > 0) {
438
+            for ($key = 0; $key < $info["count"]; $key++) {
439
+                $user = array();
440 440
                 // Get uid from dn
441 441
                 //YW: this might be a variation between LDAP 2 and LDAP 3, but in LDAP 3, the uid is in
442 442
                 //the corresponding index of the array
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
  * @return string Some HTML-code with modify-buttons
471 471
  * @author    Mustapha Alouani
472 472
  */
473
-function modify_filter($user_id,$url_params, $row) {
474
-    $query_string="id[]=".$row[0];
475
-    if (!empty($_GET['id_session'])){
473
+function modify_filter($user_id, $url_params, $row) {
474
+    $query_string = "id[]=".$row[0];
475
+    if (!empty($_GET['id_session'])) {
476 476
         $query_string .= '&amp;id_session='.Security::remove_XSS($_GET['id_session']);
477 477
     }
478 478
     //$url_params_id="id=".$row[0];
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     $firstname = api_convert_encoding($data['cn'][0], api_get_system_encoding(), 'UTF-8');
498 498
     $email = $data['mail'][0];
499 499
     // Get uid from dn
500
-    $dn_array=ldap_explode_dn($data['dn'],1);
500
+    $dn_array = ldap_explode_dn($data['dn'], 1);
501 501
     $username = $dn_array[0]; // uid is first key
502 502
     $outab[] = $data['edupersonprimaryaffiliation'][0]; // Here, "student"
503 503
     //$val = ldap_get_values_len($ds, $entry, "userPassword");
@@ -505,29 +505,29 @@  discard block
 block discarded – undo
505 505
     //$password = $val[0];
506 506
     // TODO the password, if encrypted at the source, will be encrypted twice, which makes it useless. Try to fix that.
507 507
     $password = $data['userPassword'][0];
508
-    $structure=$data['edupersonprimaryorgunitdn'][0];
509
-    $array_structure=explode(",", $structure);
510
-    $array_val=explode("=", $array_structure[0]);
511
-    $etape=$array_val[1];
512
-    $array_val=explode("=", $array_structure[1]);
513
-    $annee=$array_val[1];
508
+    $structure = $data['edupersonprimaryorgunitdn'][0];
509
+    $array_structure = explode(",", $structure);
510
+    $array_val = explode("=", $array_structure[0]);
511
+    $etape = $array_val[1];
512
+    $array_val = explode("=", $array_structure[1]);
513
+    $annee = $array_val[1];
514 514
     // To ease management, we add the step-year (etape-annee) code
515
-    $official_code=$etape."-".$annee;
516
-    $auth_source='ldap';
515
+    $official_code = $etape."-".$annee;
516
+    $auth_source = 'ldap';
517 517
     // No expiration date for students (recover from LDAP's shadow expiry)
518
-    $expiration_date='0000-00-00 00:00:00';
519
-    $active=1;
520
-    if(empty($status)){$status = 5;}
521
-    if(empty($phone)){$phone = '';}
522
-    if(empty($picture_uri)){$picture_uri = '';}
518
+    $expiration_date = '0000-00-00 00:00:00';
519
+    $active = 1;
520
+    if (empty($status)) {$status = 5; }
521
+    if (empty($phone)) {$phone = ''; }
522
+    if (empty($picture_uri)) {$picture_uri = ''; }
523 523
     // Adding user
524 524
     $user_id = 0;
525 525
     if (UserManager::is_username_available($username)) {
526
-        $user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
526
+        $user_id = UserManager::create_user($firstname, $lastname, $status, $email, $username, $password, $official_code, api_get_setting('platformLanguage'), $phone, $picture_uri, $auth_source, $expiration_date, $active);
527 527
     } else {
528 528
         if ($update_if_exists) {
529 529
             $user = api_get_user_info($username);
530
-            $user_id=$user['user_id'];
530
+            $user_id = $user['user_id'];
531 531
             UserManager::update_user($user_id, $firstname, $lastname, $username, null, null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active);
532 532
         }
533 533
     }
@@ -544,21 +544,21 @@  discard block
 block discarded – undo
544 544
 
545 545
     // Database Table Definitions
546 546
     $tbl_session                        = Database::get_main_table(TABLE_MAIN_SESSION);
547
-    $tbl_session_rel_class                = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
547
+    $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
548 548
     $tbl_session_rel_course                = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
549 549
     $tbl_session_rel_course_rel_user    = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
550 550
     $tbl_course                            = Database::get_main_table(TABLE_MAIN_COURSE);
551 551
     $tbl_user                            = Database::get_main_table(TABLE_MAIN_USER);
552 552
     $tbl_session_rel_user                = Database::get_main_table(TABLE_MAIN_SESSION_USER);
553
-    $tbl_class                            = Database::get_main_table(TABLE_MAIN_CLASS);
554
-    $tbl_class_user                        = Database::get_main_table(TABLE_MAIN_CLASS_USER);
553
+    $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
554
+    $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
555 555
 
556 556
     $id_session = (int) $id_session;
557 557
     // Once users are imported in the users base, we can assign them to the session
558
-    $result=Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
559
-    $CourseList=array();
560
-    while ($row=Database::fetch_array($result)) {
561
-        $CourseList[]=$row['c_id'];
558
+    $result = Database::query("SELECT c_id FROM $tbl_session_rel_course WHERE session_id ='$id_session'");
559
+    $CourseList = array();
560
+    while ($row = Database::fetch_array($result)) {
561
+        $CourseList[] = $row['c_id'];
562 562
     }
563 563
     foreach ($CourseList as $enreg_course) {
564 564
         foreach ($UserList as $enreg_user) {
@@ -569,21 +569,21 @@  discard block
 block discarded – undo
569 569
               "('$id_session','$enreg_course','$enreg_user')");
570 570
         }
571 571
         $sql = "SELECT COUNT(user_id) as nbUsers ".
572
-               " FROM $tbl_session_rel_course_rel_user " .
572
+               " FROM $tbl_session_rel_course_rel_user ".
573 573
                " WHERE session_id='$id_session' ".
574 574
                " AND c_id='$enreg_course'";
575 575
         $rs = Database::query($sql);
576 576
         list($nbr_users) = Database::fetch_array($rs);
577 577
         Database::query("UPDATE $tbl_session_rel_course  ".
578
-               " SET nbr_users=$nbr_users " .
578
+               " SET nbr_users=$nbr_users ".
579 579
                " WHERE session_id='$id_session' ".
580 580
                " AND c_id='$enreg_course'");
581 581
     }
582 582
     foreach ($UserList as $enreg_user) {
583 583
         $enreg_user = (int) $enreg_user;
584 584
         Database::query("INSERT IGNORE INTO $tbl_session_rel_user ".
585
-               " (session_id, user_id, registered_at) " .
586
-               " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')");
585
+               " (session_id, user_id, registered_at) ".
586
+               " VALUES('$id_session','$enreg_user', '".api_get_utc_datetime()."')");
587 587
     }
588 588
     // We update the number of users in the session
589 589
     $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ".
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 function syncro_users() {
599 599
     global $ldap_basedn, $ldap_host, $ldap_port, $ldap_rdn, $ldap_pass, $ldap_search_dn;
600 600
     echo "Connecting ...";
601
-    $ldap_connect = ldap_connect( $ldap_host, $ldap_port);
601
+    $ldap_connect = ldap_connect($ldap_host, $ldap_port);
602 602
     ldap_set_version($ldap_connect);
603 603
     if ($ldap_connect) {
604 604
         //echo " Connect to LDAP server successful ";
605 605
         //echo "Binding ...";
606 606
         $ldap_bind = false;
607
-        $ldap_bind_res = ldap_handle_bind($ldap_connect,$ldap_bind);
607
+        $ldap_bind_res = ldap_handle_bind($ldap_connect, $ldap_bind);
608 608
         if ($ldap_bind_res) {
609 609
             //echo " LDAP bind successful... ";
610 610
             //echo " Searching for uid... ";
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
             //OLD: $sr=ldap_search($ldapconnect,"dc=rug, dc=ac, dc=be", "uid=$login");
613 613
             //echo "<p> ldapDc = '$LDAPbasedn' </p>";
614 614
             $all_user_query = "uid=*";
615
-            if(!empty($ldap_search_dn)) {
615
+            if (!empty($ldap_search_dn)) {
616 616
                 $sr = ldap_search($ldap_connect, $ldap_search_dn, $all_user_query);
617 617
             } else {
618 618
                 $sr = ldap_search($ldap_connect, $ldap_basedn, $all_user_query);
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
             //echo " Number of entries returned is ".ldap_count_entries($ldapconnect,$sr);
621 621
             //echo " Getting entries ...";
622 622
             $info = ldap_get_entries($ldap_connect, $sr);
623
-            for ($key = 0; $key < $info['count']; $key ++) {
623
+            for ($key = 0; $key < $info['count']; $key++) {
624 624
                 $user_id = ldap_add_user_by_array($info[$key], false);
625 625
                 if ($user_id) {
626 626
                     echo "User #$user_id created ";
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,12 @@  discard block
 block discarded – undo
80 80
 
81 81
     if ($res==1) { //WRONG PASSWORD
82 82
         //$errorMessage = "LDAP User or password incorrect, try again.<br />";
83
-        if (isset($log)) unset($log); if (isset($uid)) unset($uid);
83
+        if (isset($log)) {
84
+            unset($log);
85
+        }
86
+        if (isset($uid)) {
87
+            unset($uid);
88
+        }
84 89
         $loginLdapSucces = false;
85 90
     }
86 91
     if ($res==-1) { //WRONG USERNAME
@@ -401,8 +406,9 @@  discard block
 block discarded – undo
401 406
         return $info;
402 407
 
403 408
     } else {
404
-        if (count($ldap_query)!=0)
405
-            Display :: display_error_message(get_lang('LDAPConnectionError'));
409
+        if (count($ldap_query)!=0) {
410
+                    Display :: display_error_message(get_lang('LDAPConnectionError'));
411
+        }
406 412
         return array();
407 413
     }
408 414
 }
Please login to merge, or discard this patch.
Indentation   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -46,10 +46,9 @@  discard block
 block discarded – undo
46 46
     - Universite Jean Monet (J Dubois / Michel Courbon)
47 47
     - Michel Panckoucke for reporting and fixing a bug
48 48
     - Patrick Cool: fixing security hole
49
-
50
-    *    @author Roan Embrechts
51
-    *    @version 3.0
52
-    *    @package chamilo.auth.ldap
49
+ *    @author Roan Embrechts
50
+ *    @version 3.0
51
+ *    @package chamilo.auth.ldap
53 52
  * Note:
54 53
  * If you are using a firewall, you might need to check port 389 is open in
55 54
  * order for Chamilo to communicate with the LDAP server.
@@ -211,8 +210,8 @@  discard block
 block discarded – undo
211 210
     $language = api_get_setting('platformLanguage');
212 211
     if (empty($language)) { $language = 'english'; }
213 212
     $_userId = UserManager::create_user($prenom, $nom, $status,
214
-                     $email, $uname, $password, $official_code,
215
-                     $language,'', '', 'ldap');
213
+                        $email, $uname, $password, $official_code,
214
+                        $language,'', '', 'ldap');
216 215
 
217 216
     //echo "new user added to Chamilo, id = $_userId";
218 217
 
@@ -271,7 +270,7 @@  discard block
 block discarded – undo
271 270
         // Open anonymous LDAP connection
272 271
         $result=false;
273 272
         $ldap_bind_res = ldap_handle_bind($ds,$result);
274
-	// Executing the search with the $filter parametr
273
+    // Executing the search with the $filter parametr
275 274
         //error_log('Searching for '.$filter.' on LDAP server',0);
276 275
         $sr=ldap_search($ds,$ldap_basedn,$filter);
277 276
         $info = ldap_get_entries($ds, $sr);
@@ -564,35 +563,35 @@  discard block
 block discarded – undo
564 563
         foreach ($UserList as $enreg_user) {
565 564
             $enreg_user = (int) $enreg_user;
566 565
             Database::query("INSERT IGNORE ".
567
-              " INTO $tbl_session_rel_course_rel_user ".
568
-              "(session_id,c_id,user_id) VALUES ".
569
-              "('$id_session','$enreg_course','$enreg_user')");
566
+                " INTO $tbl_session_rel_course_rel_user ".
567
+                "(session_id,c_id,user_id) VALUES ".
568
+                "('$id_session','$enreg_course','$enreg_user')");
570 569
         }
571 570
         $sql = "SELECT COUNT(user_id) as nbUsers ".
572
-               " FROM $tbl_session_rel_course_rel_user " .
573
-               " WHERE session_id='$id_session' ".
574
-               " AND c_id='$enreg_course'";
571
+                " FROM $tbl_session_rel_course_rel_user " .
572
+                " WHERE session_id='$id_session' ".
573
+                " AND c_id='$enreg_course'";
575 574
         $rs = Database::query($sql);
576 575
         list($nbr_users) = Database::fetch_array($rs);
577 576
         Database::query("UPDATE $tbl_session_rel_course  ".
578
-               " SET nbr_users=$nbr_users " .
579
-               " WHERE session_id='$id_session' ".
580
-               " AND c_id='$enreg_course'");
577
+                " SET nbr_users=$nbr_users " .
578
+                " WHERE session_id='$id_session' ".
579
+                " AND c_id='$enreg_course'");
581 580
     }
582 581
     foreach ($UserList as $enreg_user) {
583 582
         $enreg_user = (int) $enreg_user;
584 583
         Database::query("INSERT IGNORE INTO $tbl_session_rel_user ".
585
-               " (session_id, user_id, registered_at) " .
586
-               " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')");
584
+                " (session_id, user_id, registered_at) " .
585
+                " VALUES('$id_session','$enreg_user', '" . api_get_utc_datetime() . "')");
587 586
     }
588 587
     // We update the number of users in the session
589 588
     $sql = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_user ".
590
-           " WHERE session_id='$id_session' ".
591
-           " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." ";
589
+            " WHERE session_id='$id_session' ".
590
+            " AND relation_type<>".SESSION_RELATION_TYPE_RRHH." ";
592 591
     $rs = Database::query($sql);
593 592
     list($nbr_users) = Database::fetch_array($rs);
594 593
     Database::query("UPDATE $tbl_session SET nbr_users=$nbr_users ".
595
-           " WHERE id='$id_session'");
594
+            " WHERE id='$id_session'");
596 595
 }
597 596
 
598 597
 function syncro_users() {
Please login to merge, or discard this patch.
main/auth/openid/login.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -337,6 +337,7 @@
 block discarded – undo
337 337
 
338 338
 /**
339 339
  * Make a HTTP request - This function has been copied straight over from Drupal 6 code (drupal_http_request)
340
+ * @param string $data
340 341
  */
341 342
 function openid_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
342 343
     $result = new stdClass();
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 /**
14 14
  * Initialisation
15 15
  */
16
-require_once api_get_path(CONFIGURATION_PATH) . 'auth.conf.php';
16
+require_once api_get_path(CONFIGURATION_PATH).'auth.conf.php';
17 17
 
18 18
 require_once 'openid.lib.php';
19 19
 require_once 'xrds.lib.php';
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     // Now that there is an association created, move on
69 69
     // to request authentication from the IdP
70 70
     $identity = (!empty($services[0]['delegate'])) ? $services[0]['delegate'] : $claimed_id;
71
-    if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 . '/server', $services[0]['types'])) {
71
+    if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0.'/server', $services[0]['types'])) {
72 72
         $identity = 'http://openid.net/identifier_select/2.0';
73 73
     }
74 74
     $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     $xrds_url = $claimed_id;
128 128
     if (_openid_is_xri($claimed_id)) {
129
-        $xrds_url = 'http://xri.net/' . $claimed_id;
129
+        $xrds_url = 'http://xri.net/'.$claimed_id;
130 130
     }
131 131
     $url = @parse_url($xrds_url);
132 132
     if ($url['scheme'] == 'http' || $url['scheme'] == 'https') {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     //@todo Remove Old Associations:
192 192
     $openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION);
193 193
     $sql = "DELETE FROM $openid_association
194
-            WHERE created + expires_in < '" . api_get_utc_datetime() . "'";
194
+            WHERE created + expires_in < '".api_get_utc_datetime()."'";
195 195
     Database::query($sql);
196 196
 
197 197
     // Check to see if we have an association for this IdP already
@@ -347,17 +347,17 @@  discard block
 block discarded – undo
347 347
     switch ($uri['scheme']) {
348 348
         case 'http':
349 349
             $port = isset($uri['port']) ? $uri['port'] : 80;
350
-            $host = $uri['host'] . ($port != 80 ? ':' . $port : '');
350
+            $host = $uri['host'].($port != 80 ? ':'.$port : '');
351 351
             $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
352 352
             break;
353 353
         case 'https':
354 354
             // Note: Only works for PHP 4.3 compiled with OpenSSL.
355 355
             $port = isset($uri['port']) ? $uri['port'] : 443;
356
-            $host = $uri['host'] . ($port != 443 ? ':' . $port : '');
357
-            $fp = @fsockopen('ssl://' . $uri['host'], $port, $errno, $errstr, 20);
356
+            $host = $uri['host'].($port != 443 ? ':'.$port : '');
357
+            $fp = @fsockopen('ssl://'.$uri['host'], $port, $errno, $errstr, 20);
358 358
             break;
359 359
         default:
360
-            $result->error = 'invalid schema ' . $uri['scheme'];
360
+            $result->error = 'invalid schema '.$uri['scheme'];
361 361
             return $result;
362 362
     }
363 363
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
     // Construct the path to act on.
374 374
     $path = isset($uri['path']) ? $uri['path'] : '/';
375 375
     if (isset($uri['query'])) {
376
-        $path .= '?' . $uri['query'];
376
+        $path .= '?'.$uri['query'];
377 377
     }
378 378
 
379 379
     // Create HTTP request.
@@ -383,23 +383,23 @@  discard block
 block discarded – undo
383 383
         // host that do not take into account the port number.
384 384
         'Host' => "Host: $host",
385 385
         'User-Agent' => 'User-Agent: Chamilo (+http://www.chamilo.org/)',
386
-        'Content-Length' => 'Content-Length: ' . strlen($data)
386
+        'Content-Length' => 'Content-Length: '.strlen($data)
387 387
     );
388 388
 
389 389
     // If the server url has a user then attempt to use basic authentication
390 390
     if (isset($uri['user'])) {
391
-        $defaults['Authorization'] = 'Authorization: Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : ''));
391
+        $defaults['Authorization'] = 'Authorization: Basic '.base64_encode($uri['user'].(!empty($uri['pass']) ? ":".$uri['pass'] : ''));
392 392
     }
393 393
 
394 394
     foreach ($headers as $header => $value) {
395
-        $defaults[$header] = $header . ': ' . $value;
395
+        $defaults[$header] = $header.': '.$value;
396 396
     }
397 397
 
398
-    $request = $method . ' ' . $path . " HTTP/1.0\r\n";
398
+    $request = $method.' '.$path." HTTP/1.0\r\n";
399 399
     $request .= implode("\r\n", $defaults);
400 400
     $request .= "\r\n\r\n";
401 401
     if ($data) {
402
-        $request .= $data . "\r\n";
402
+        $request .= $data."\r\n";
403 403
     }
404 404
     $result->request = $request;
405 405
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         if (isset($result->headers[$header]) && $header == 'Set-Cookie') {
426 426
             // RFC 2109: the Set-Cookie response header comprises the token Set-
427 427
             // Cookie:, followed by a comma-separated list of one or more cookies.
428
-            $result->headers[$header] .= ',' . trim($value);
428
+            $result->headers[$header] .= ','.trim($value);
429 429
         } else {
430 430
             $result->headers[$header] = trim($value);
431 431
         }
Please login to merge, or discard this patch.
main/auth/openid/openid.lib.php 3 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -121,6 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 /**
123 123
  * Encode a message from _openid_create_message for HTTP Post
124
+ * @param null|string $message
124 125
  */
125 126
 function _openid_encode_message($message) {
126 127
     $encoded_message = '';
@@ -173,6 +174,7 @@  discard block
 block discarded – undo
173 174
 
174 175
 /**
175 176
  * Pull the href attribute out of an html link element.
177
+ * @param string $rel
176 178
  */
177 179
 function _openid_link_href($rel, $html) {
178 180
     $rel = preg_quote($rel);
@@ -186,6 +188,7 @@  discard block
 block discarded – undo
186 188
 
187 189
 /**
188 190
  * Pull the http-equiv attribute out of an html meta element
191
+ * @param string $equiv
189 192
  */
190 193
 function _openid_meta_httpequiv($equiv, $html) {
191 194
     preg_match('|<meta\s+http-equiv=["\']' . $equiv . '["\'](.*)/?>|iU', $html, $matches);
@@ -221,6 +224,10 @@  discard block
 block discarded – undo
221 224
     return base64_encode($signature);
222 225
 }
223 226
 
227
+/**
228
+ * @param string $key
229
+ * @param null|string $text
230
+ */
224 231
 function _openid_hmac($key, $text) {
225 232
     if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
226 233
         $key = _openid_sha1($key, true);
@@ -256,6 +263,9 @@  discard block
 block discarded – undo
256 263
     return base64_encode(_openid_dh_long_to_binary($str));
257 264
 }
258 265
 
266
+/**
267
+ * @param string $str
268
+ */
259 269
 function _openid_dh_binary_to_long($str) {
260 270
     $bytes = array_merge(unpack('C*', $str));
261 271
 
@@ -297,6 +307,9 @@  discard block
 block discarded – undo
297 307
     return $string;
298 308
 }
299 309
 
310
+/**
311
+ * @param string $secret
312
+ */
300 313
 function _openid_dh_xorsecret($shared, $secret) {
301 314
     $dh_shared_str = _openid_dh_long_to_binary($shared);
302 315
     $sha1_dh_shared = _openid_sha1($dh_shared_str);
@@ -308,6 +321,9 @@  discard block
 block discarded – undo
308 321
     return $xsecret;
309 322
 }
310 323
 
324
+/**
325
+ * @param string $stop
326
+ */
311 327
 function _openid_dh_rand($stop) {
312 328
     static $duplicate_cache = array();
313 329
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
  * Code
10 10
  */
11 11
 // Diffie-Hellman Key Exchange Default Value.
12
-define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801' .
13
-        '966915404479707795314057629378541917580651227423698188993727816152646631' .
14
-        '438561595825688188889951272158842675419950341258706556549803580104870537' .
15
-        '681476726513255747040765857479291291572334510643245094715007229621094194' .
12
+define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801'.
13
+        '966915404479707795314057629378541917580651227423698188993727816152646631'.
14
+        '438561595825688188889951272158842675419950341258706556549803580104870537'.
15
+        '681476726513255747040765857479291291572334510643245094715007229621094194'.
16 16
         '349783925984760375594985848253359305585439638443');
17 17
 
18 18
 // Constants for Diffie-Hellman key exchange computations.
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 function openid_redirect_http($url, $message) {
33 33
     $query = array();
34 34
     foreach ($message as $key => $val) {
35
-        $query[] = $key . '=' . urlencode($val);
35
+        $query[] = $key.'='.urlencode($val);
36 36
     }
37 37
     $sep = (strpos($url, '?') === FALSE) ? '?' : '&';
38
-    header('Location: ' . $url . $sep . implode('&', $query), TRUE, 302);
38
+    header('Location: '.$url.$sep.implode('&', $query), TRUE, 302);
39 39
     //exit;
40 40
 }
41 41
 
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
  * This function should be deprecated for 1.8.6.2 needs documentation
45 45
  */
46 46
 function openid_redirect($url, $message) {
47
-    $output = '<html><head><title>' . get_lang('OpenIDRedirect') . "</title></head>\n<body>";
48
-    $output .= '<form method="post" action="' . $url . '" id="openid-redirect-form">';
47
+    $output = '<html><head><title>'.get_lang('OpenIDRedirect')."</title></head>\n<body>";
48
+    $output .= '<form method="post" action="'.$url.'" id="openid-redirect-form">';
49 49
     foreach ($message as $key => $value) {
50
-        $output .='<input type="hidden" name="' . $key . '" value="' . $value . '">';
50
+        $output .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
51 51
     }
52
-    $output .= '<noscript><input type="submit" name="submit" value="' . get_lang('Send') . '"/></noscript>';
52
+    $output .= '<noscript><input type="submit" name="submit" value="'.get_lang('Send').'"/></noscript>';
53 53
     $output .= '</form>';
54 54
     $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';
55 55
     $output .= "</body></html>";
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $normalized_url = $url;
95 95
 
96 96
     if (stristr($url, '://') === FALSE) {
97
-        $normalized_url = 'http://' . $url;
97
+        $normalized_url = 'http://'.$url;
98 98
     }
99 99
 
100 100
     if (substr_count($normalized_url, '/') < 3) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
             if ($encoded_message != '') {
134 134
                 $encoded_message .= '&';
135 135
             }
136
-            $encoded_message .= rawurlencode(trim($parts[0])) . '=' . rawurlencode(trim($parts[1]));
136
+            $encoded_message .= rawurlencode(trim($parts[0])).'='.rawurlencode(trim($parts[1]));
137 137
         }
138 138
     }
139 139
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  */
165 165
 function _openid_nonce() {
166 166
     // YYYY-MM-DDThh:mm:ssTZD UTC, plus some optional extra unique chars
167
-    return gmstrftime('%Y-%m-%dT%H:%M:%S%Z') .
168
-            chr(mt_rand(0, 25) + 65) .
169
-            chr(mt_rand(0, 25) + 65) .
170
-            chr(mt_rand(0, 25) + 65) .
167
+    return gmstrftime('%Y-%m-%dT%H:%M:%S%Z').
168
+            chr(mt_rand(0, 25) + 65).
169
+            chr(mt_rand(0, 25) + 65).
170
+            chr(mt_rand(0, 25) + 65).
171 171
             chr(mt_rand(0, 25) + 65);
172 172
 }
173 173
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
  */
177 177
 function _openid_link_href($rel, $html) {
178 178
     $rel = preg_quote($rel);
179
-    preg_match('|<link\s+rel=["\'](.*)' . $rel . '(.*)["\'](.*)/?>|iU', $html, $matches);
179
+    preg_match('|<link\s+rel=["\'](.*)'.$rel.'(.*)["\'](.*)/?>|iU', $html, $matches);
180 180
     if (isset($matches[3])) {
181 181
         preg_match('|href=["\']([^"]+)["\']|iU', $matches[0], $href);
182 182
         return trim($href[1]);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
  * Pull the http-equiv attribute out of an html meta element
189 189
  */
190 190
 function _openid_meta_httpequiv($equiv, $html) {
191
-    preg_match('|<meta\s+http-equiv=["\']' . $equiv . '["\'](.*)/?>|iU', $html, $matches);
191
+    preg_match('|<meta\s+http-equiv=["\']'.$equiv.'["\'](.*)/?>|iU', $html, $matches);
192 192
     if (isset($matches[1])) {
193 193
         preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content);
194 194
         return $content[1];
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
     $sign_data = array();
210 210
 
211 211
     foreach ($keys_to_sign as $key) {
212
-        if (isset($message_array['openid.' . $key])) {
213
-            $sign_data[$key] = $message_array['openid.' . $key];
212
+        if (isset($message_array['openid.'.$key])) {
213
+            $sign_data[$key] = $message_array['openid.'.$key];
214 214
         }
215 215
     }
216 216
 
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
     $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
230 230
     $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
231 231
     $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
232
-    $hash1 = _openid_sha1(($key ^ $ipad) . $text, true);
233
-    $hmac = _openid_sha1(($key ^ $opad) . $hash1, true);
232
+    $hash1 = _openid_sha1(($key ^ $ipad).$text, true);
233
+    $hmac = _openid_sha1(($key ^ $opad).$hash1, true);
234 234
 
235 235
     return $hmac;
236 236
 }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     }
338 338
 
339 339
     do {
340
-        $bytes = "\x00" . _openid_get_bytes($nbytes);
340
+        $bytes = "\x00"._openid_get_bytes($nbytes);
341 341
         $n = _openid_dh_binary_to_long($bytes);
342 342
         // Keep looping if this value is in the low duplicated range.
343 343
     } while (bccomp($n, $duplicate) < 0);
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@
 block discarded – undo
61 61
  */
62 62
 function _openid_is_xri($identifier) {
63 63
     $firstchar = substr($identifier, 0, 1);
64
-    if ($firstchar == "@" || $firstchar == "=")
65
-        return TRUE;
64
+    if ($firstchar == "@" || $firstchar == "=") {
65
+            return TRUE;
66
+    }
66 67
 
67 68
     if (stristr($identifier, 'xri://') !== FALSE) {
68 69
         return TRUE;
Please login to merge, or discard this patch.
main/auth/shibboleth/app/model/shibboleth_store.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
     /**
19 19
      *
20
-     * @return ShibbolethData 
20
+     * @return ShibbolethStore 
21 21
      */
22 22
     public static function instance()
23 23
     {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -168,12 +168,10 @@
 block discarded – undo
168 168
                 if (empty($result))
169 169
                 {
170 170
                     $result = $default;
171
-                }
172
-                else if (count($result) == 1)
171
+                } else if (count($result) == 1)
173 172
                 {
174 173
                     $result = reset($result);
175
-                }
176
-                else
174
+                } else
177 175
                 {
178 176
                     $result = $result;
179 177
                 }
Please login to merge, or discard this patch.
main/auth/shibboleth/app/model/user.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@
 block discarded – undo
56 56
         return $this->get(array('shibb_unique_id' => $id));
57 57
     }
58 58
     
59
+    /**
60
+     * @param string $id
61
+     */
59 62
     public function shibboleth_id_exists($id)
60 63
     {
61 64
         return $this->exist(array('shibb_unique_id' => $id));
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 namespace Shibboleth;
4 4
 
5
-require_once dirname(__FILE__) . '/scaffold/user.class.php';
5
+require_once dirname(__FILE__).'/scaffold/user.class.php';
6 6
 
7 7
 /**
8 8
  * A Chamilo user. Model for the User table.
Please login to merge, or discard this patch.
main/auth/shibboleth/app/shibboleth.class.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
     /**
130 130
      *
131
-     * @param ShibbolethUser $user
131
+     * @param ShibbolethUser $shibb_user
132 132
      */
133 133
     public static function save($shibb_user)
134 134
     {
@@ -230,6 +230,7 @@  discard block
 block discarded – undo
230 230
      * Sends an email to the Chamilo and Shibboleth administrators in the name
231 231
      * of the logged-in user.
232 232
      *
233
+     * @param string $subject
233 234
      */
234 235
     public static function email_admin($subject, $message)
235 236
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,14 +78,14 @@
 block discarded – undo
78 78
 
79 79
     public static function sys_path()
80 80
     {
81
-        $path = dirname(__FILE__) . '/../';
81
+        $path = dirname(__FILE__).'/../';
82 82
         return $path;
83 83
     }
84 84
 
85 85
     public static function url($path = '')
86 86
     {
87 87
         $result = api_get_path('WEB_PATH');
88
-        $result .= '/main/auth/shibboleth/' . $path;
88
+        $result .= '/main/auth/shibboleth/'.$path;
89 89
         return $result;
90 90
     }
91 91
 
Please login to merge, or discard this patch.
main/auth/shibboleth/db/shibboleth_upgrade.class.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * Creates the 'shibb_unique_id' field in the table 'user' of the main Chamilo database if it doesn't exist yet
36 36
      *
37 37
      * @author Nicolas Rod
38
-     * @return void
38
+     * @return false|null
39 39
      */
40 40
     public static function create_shibb_unique_id_field_if_missing()
41 41
     {
Please login to merge, or discard this patch.
main/auth/shibboleth/lib/store.class.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -346,6 +346,9 @@
 block discarded – undo
346 346
         return $result;
347 347
     }
348 348
 
349
+    /**
350
+     * @param string $sql
351
+     */
349 352
     protected function execute($sql)
350 353
     {
351 354
         return Database::query($sql, null, __FILE__);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 
247 247
         $db_name = $this->get_db_name($object);
248 248
         $sql = "INSERT INTO `{$db_name}`.`{$this->table_name}` ";
249
-        $sql .= ' (' . join(', ', $keys) . ') ';
249
+        $sql .= ' ('.join(', ', $keys).') ';
250 250
         $sql .= 'VALUES';
251
-        $sql .= ' (' . join(', ', $values) . ') ';
251
+        $sql .= ' ('.join(', ', $values).') ';
252 252
 
253 253
         $result = $this->execute($sql);
254 254
         if ($result)
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         $items = array();
296 296
         foreach ($args as $key => $val)
297 297
         {
298
-            $items[] = $key . ' = ' . $this->format_value($val);
298
+            $items[] = $key.' = '.$this->format_value($val);
299 299
         }
300 300
         return implode(' AND ', $items);
301 301
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -107,8 +107,7 @@  discard block
 block discarded – undo
107 107
         if ($this->is_new($object))
108 108
         {
109 109
             $result = $this->insert($object);
110
-        }
111
-        else
110
+        } else
112 111
         {
113 112
             $result = $this->update($object);
114 113
         }
@@ -257,8 +256,7 @@  discard block
 block discarded – undo
257 256
             $object->{$this->id_name} = $id;
258 257
             $object->{db_name} = $db_name;
259 258
             return $id;
260
-        }
261
-        else
259
+        } else
262 260
         {
263 261
             return false;
264 262
         }
@@ -278,16 +276,13 @@  discard block
 block discarded – undo
278 276
                     return '';
279 277
                 }
280 278
                 $args = array($this->pk_name, $arg);
281
-            }
282
-            else if (is_string($arg))
279
+            } else if (is_string($arg))
283 280
             {
284 281
                 return $arg;
285
-            }
286
-            else if (is_array($arg))
282
+            } else if (is_array($arg))
287 283
             {
288 284
                 $args = $arg;
289
-            }
290
-            else
285
+            } else
291 286
             {
292 287
                 return $arg;
293 288
             }
@@ -309,17 +304,14 @@  discard block
 block discarded – undo
309 304
         if (is_bool($var))
310 305
         {
311 306
             return $value ? '1' : '0';
312
-        }
313
-        else if (is_numeric($value))
307
+        } else if (is_numeric($value))
314 308
         {
315 309
             return empty($value) ? '0' : $value;
316
-        }
317
-        else if (is_string($value))
310
+        } else if (is_string($value))
318 311
         {
319 312
             $value = mysql_escape_string($value);
320 313
             return "'$value'";
321
-        }
322
-        else
314
+        } else
323 315
         {
324 316
             return $value;
325 317
         }
Please login to merge, or discard this patch.
main/auth/sso/sso.Drupal.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 
91 91
     /**
92 92
      * Validates the received active connection data with the database
93
-     * @return	bool	Return the loginFailed variable value to local.inc.php
93
+     * @return	null|false	Return the loginFailed variable value to local.inc.php
94 94
      */
95 95
     public function check_user()
96 96
     {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class ssoDrupal
24 24
 {
25
-    public $protocol;   // 'http://',
26
-    public $domain;     // 'localhost/project/drupal',
27
-    public $auth_uri;   // '/?q=user',
25
+    public $protocol; // 'http://',
26
+    public $domain; // 'localhost/project/drupal',
27
+    public $auth_uri; // '/?q=user',
28 28
     public $deauth_uri; // '/?q=logout',
29
-    public $referer;    // http://my.chamilo.com/main/auth/profile.php
29
+    public $referer; // http://my.chamilo.com/main/auth/profile.php
30 30
 
31 31
     /**
32 32
      * Instanciates the object, initializing all relevant URL strings
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
                     && ($sso['username'] == $uData['username'])) {
124 124
 
125 125
                     //Check if the account is active (not locked)
126
-                    if ($uData['active']=='1') {
126
+                    if ($uData['active'] == '1') {
127 127
                         // check if the expiration date has not been reached
128
-                        if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date']=='0000-00-00 00:00:00') {
128
+                        if (empty($uData['expiration_date']) OR $uData['expiration_date'] > date('Y-m-d H:i:s') OR $uData['expiration_date'] == '0000-00-00 00:00:00') {
129 129
 
130 130
                             //If Multiple URL is enabled
131 131
                             if (api_get_multiple_access_url()) {
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
                                             // the user credentials are OK, which
159 159
                                             // should be protection enough
160 160
                                             // against evil URL spoofing...
161
-                                            $sso_target = api_get_path(WEB_PATH) . base64_decode($sso['ruri']);
161
+                                            $sso_target = api_get_path(WEB_PATH).base64_decode($sso['ruri']);
162 162
                                         } else {
163
-                                            $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH) . 'index.php';
163
+                                            $sso_target = isset($sso['target']) ? $sso['target'] : api_get_path(WEB_PATH).'index.php';
164 164
                                         }
165
-                                        header('Location: '. $sso_target);
165
+                                        header('Location: '.$sso_target);
166 166
                                         exit;
167 167
                                     } else {
168 168
                                         // user does not have permission for this site
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
         // If this is an administrator, allow him to make some changes in
280 280
         // the Chamilo profile
281 281
         if ($asAdmin && api_is_platform_admin(true)) {
282
-            return api_get_path(WEB_CODE_PATH) . "admin/user_edit.php?user_id=$userId";
282
+            return api_get_path(WEB_CODE_PATH)."admin/user_edit.php?user_id=$userId";
283 283
         }
284 284
         // If the user doesn't match a Drupal user, give the normal profile
285 285
         // link
286 286
         if ($drupalUserIdData === false) {
287
-            return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
287
+            return api_get_path(WEB_CODE_PATH).'auth/profile.php';
288 288
         }
289 289
         // In all other cases, generate a link to the Drupal profile edition
290 290
         $drupalUserId = $drupalUserIdData['value'];
Please login to merge, or discard this patch.