@@ -124,7 +124,7 @@ |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | - * @param $variable |
|
127 | + * @param string $variable |
|
128 | 128 | * @return mixed |
129 | 129 | */ |
130 | 130 | public function getConfigurationValue($variable) |
@@ -204,7 +204,6 @@ discard block |
||
204 | 204 | * lock = the user can no longer use this account |
205 | 205 | * @author Patrick Cool <[email protected]>, Ghent University |
206 | 206 | * @param int $active the current state of the account |
207 | - * @param int $user_id The user id |
|
208 | 207 | * @param string $url_params |
209 | 208 | * @return string Some HTML-code with the lock/unlock button |
210 | 209 | */ |
@@ -236,7 +235,7 @@ discard block |
||
236 | 235 | * @author Patrick Cool <[email protected]>, Ghent University |
237 | 236 | * @param int $status, do we want to lock the user ($status=lock) or unlock it ($status=unlock) |
238 | 237 | * @param int $user_id The user id |
239 | - * @return language variable |
|
238 | + * @return string|null variable |
|
240 | 239 | */ |
241 | 240 | function lock_unlock_user($status, $user_id) { |
242 | 241 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
@@ -117,14 +117,12 @@ |
||
117 | 117 | // Loops while the current group is a subgroup |
118 | 118 | while (isset($groupRelations[$id]['group_id'])) { |
119 | 119 | $name = $name ? |
120 | - $groupRelations[$id]['name'] . " > " . $name : |
|
121 | - $groupRelations[$id]['name']; |
|
120 | + $groupRelations[$id]['name']." > ".$name : $groupRelations[$id]['name']; |
|
122 | 121 | $id = $groupRelations[$id]['group_id']; |
123 | 122 | } |
124 | 123 | // The base group |
125 | 124 | $name = $name ? |
126 | - $groupRelations[$id]['name'] . " > " . $name : |
|
127 | - $groupRelations[$id]['name']; |
|
125 | + $groupRelations[$id]['name']." > ".$name : $groupRelations[$id]['name']; |
|
128 | 126 | $group[3] = $status[$group[3]]; |
129 | 127 | $group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/group_view.php?id='.$group['0'].'">'.$name.'</a>'; |
130 | 128 | $groups[] = $group; |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * display the edit and delete icons in the sortable table |
908 | 908 | * |
909 | 909 | * @param integer $id the id of the template |
910 | - * @return html code for the link to edit and delete the template |
|
910 | + * @return string code for the link to edit and delete the template |
|
911 | 911 | * |
912 | 912 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
913 | 913 | * @version August 2008 |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | * Display the image of the template in the sortable table |
924 | 924 | * |
925 | 925 | * @param string $image the image |
926 | - * @return html code for the image |
|
926 | + * @return string code for the image |
|
927 | 927 | * |
928 | 928 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
929 | 929 | * @version August 2008 |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | /** |
1121 | 1121 | * Returns an array containing the list of options used to populate the gradebook_number_decimals variable |
1122 | 1122 | * This function is called through a call_user_func() in the generate_settings_form function. |
1123 | - * @return array List of gradebook_number_decimals options |
|
1123 | + * @return string[] List of gradebook_number_decimals options |
|
1124 | 1124 | * |
1125 | 1125 | * @author Guillaume Viguier <[email protected]> |
1126 | 1126 | */ |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | //Plugins NOT installed |
131 | 131 | echo Display::page_subheader(get_lang('Plugins')); |
132 | - echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token=' . $token . '">'; |
|
132 | + echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'&sec_token='.$token.'">'; |
|
133 | 133 | echo '<table class="data_table">'; |
134 | 134 | echo '<tr>'; |
135 | 135 | echo '<th width="20px">'; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | $plugin_list = array(); |
143 | 143 | $my_plugin_list = $plugin_obj->get_plugin_regions(); |
144 | - foreach($my_plugin_list as $plugin_item) { |
|
144 | + foreach ($my_plugin_list as $plugin_item) { |
|
145 | 145 | $plugin_list[$plugin_item] = $plugin_item; |
146 | 146 | } |
147 | 147 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | if (file_exists(api_get_path(SYS_PLUGIN_PATH).$plugin.'/readme.txt')) { |
181 | 181 | echo Display::url( |
182 | 182 | "<em class='fa fa-file-text-o'></em> readme.txt", |
183 | - api_get_path(WEB_PLUGIN_PATH) . $plugin . "/readme.txt", |
|
183 | + api_get_path(WEB_PLUGIN_PATH).$plugin."/readme.txt", |
|
184 | 184 | [ |
185 | 185 | 'class' => 'btn btn-default ajax', |
186 | 186 | 'data-title' => $plugin_info['title'], |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $show_name = ucwords(str_replace('_', ' ', $style_dir)); |
323 | 323 | |
324 | 324 | if ($is_style_changeable) { |
325 | - $list_of_names[$style_dir] = $show_name; |
|
325 | + $list_of_names[$style_dir] = $show_name; |
|
326 | 326 | } |
327 | 327 | $counter++; |
328 | 328 | } |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | if (is_dir($dir)) { |
354 | 354 | $zip = new PclZip($arch); |
355 | 355 | // Remove path prefix except the style name and put file on disk |
356 | - $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir))); |
|
356 | + $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir, 0, -strlen($safe_style_dir))); |
|
357 | 357 | //@TODO: use more generic script to download. |
358 | - $str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">'.get_lang('ClickHereToDownloadTheFile').'</a>'; |
|
358 | + $str = '<a class="btn btn-primary btn-large" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch).'">'.get_lang('ClickHereToDownloadTheFile').'</a>'; |
|
359 | 359 | Display::display_normal_message($str, false); |
360 | 360 | } else { |
361 | 361 | Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning')); |
@@ -371,15 +371,15 @@ discard block |
||
371 | 371 | |
372 | 372 | $logoForm->addHtml(Display::return_message(sprintf(get_lang('TheLogoMustBeSizeXAndFormatY'), '250 x 70', 'PNG'), 'info')); |
373 | 373 | |
374 | - $dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $selected . '/images/'; |
|
375 | - $url = api_get_path(WEB_CSS_PATH).'themes/' . $selected . '/images/'; |
|
374 | + $dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/'.$selected.'/images/'; |
|
375 | + $url = api_get_path(WEB_CSS_PATH).'themes/'.$selected.'/images/'; |
|
376 | 376 | $logoFileName = 'header-logo.png'; |
377 | 377 | $newLogoFileName = 'header-logo-custom.png'; |
378 | 378 | |
379 | 379 | if (is_file($dir.$newLogoFileName)) { |
380 | - $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $newLogoFileName .'?'. time() . '">'); |
|
380 | + $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'.$url.$newLogoFileName.'?'.time().'">'); |
|
381 | 381 | } else { |
382 | - $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $logoFileName .'?'. time() . '">'); |
|
382 | + $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'.$url.$logoFileName.'?'.time().'">'); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | $logoForm->addFile('new_logo', get_lang('UpdateLogo')); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $imageInfo = getimagesize($_FILES['new_logo']['tmp_name']); |
404 | 404 | $width = $imageInfo[0]; |
405 | 405 | $height = $imageInfo[1]; |
406 | - if ($width <= 250 && $height <= 70 ) { |
|
406 | + if ($width <= 250 && $height <= 70) { |
|
407 | 407 | if (is_file($dir.$newLogoFileName)) { |
408 | 408 | unlink($dir.$newLogoFileName); |
409 | 409 | } |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | }); |
448 | 448 | </script>'; |
449 | 449 | echo Display::tabs( |
450 | - array(get_lang('Update'),get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')), |
|
450 | + array(get_lang('Update'), get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')), |
|
451 | 451 | array($form_change->return_form(), $logoForm->return_form(), $form->return_form()) |
452 | 452 | ); |
453 | 453 | } else { |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | if (!empty($areas_to_installed)) { |
623 | 623 | $plugin_obj->remove_all_regions($plugin); |
624 | 624 | foreach ($areas_to_installed as $region) { |
625 | - if (!empty($region) && $region != '-1' ) { |
|
625 | + if (!empty($region) && $region != '-1') { |
|
626 | 626 | $plugin_obj->add_to_region($plugin, $region); |
627 | 627 | } |
628 | 628 | } |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | $values = api_get_settings_options('search_enabled'); |
715 | 715 | $form->addElement('header', null, get_lang('SearchEnabledTitle')); |
716 | 716 | |
717 | - $group = array (); |
|
717 | + $group = array(); |
|
718 | 718 | if (is_array($values)) { |
719 | 719 | foreach ($values as $key => $value) { |
720 | 720 | $element = & $form->createElement('radio', 'search_enabled', '', get_lang($value['display_text']), $value['value']); |
@@ -740,12 +740,12 @@ discard block |
||
740 | 740 | |
741 | 741 | if ($search_enabled == 'true') { |
742 | 742 | $values = api_get_settings_options('search_show_unlinked_results'); |
743 | - $group = array (); |
|
743 | + $group = array(); |
|
744 | 744 | foreach ($values as $key => $value) { |
745 | 745 | $element = & $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']); |
746 | 746 | $group[] = $element; |
747 | 747 | } |
748 | - $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), '', false); |
|
748 | + $form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'), get_lang('SearchShowUnlinkedResultsComment')), '', false); |
|
749 | 749 | $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results'); |
750 | 750 | |
751 | 751 | $sf_values = array(); |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | $sf_values[$sf['code']] = $sf['name']; |
754 | 754 | } |
755 | 755 | $group = array(); |
756 | - $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment')); |
|
756 | + $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment')); |
|
757 | 757 | if (empty($sf_values)) { |
758 | 758 | $form->addElement('html', get_lang('SearchPrefilterPrefix').$url); |
759 | 759 | } else { |
@@ -820,10 +820,10 @@ discard block |
||
820 | 820 | $dir_is_writable = Display::return_icon('bullet_red.png', get_lang('Error')); |
821 | 821 | } |
822 | 822 | |
823 | - $data[] = array(get_lang('XapianModuleInstalled'),$xapian_loaded); |
|
824 | - $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path,$dir_exists); |
|
825 | - $data[] = array(get_lang('IsWritable').' - '.$xapian_path,$dir_is_writable); |
|
826 | - $data[] = array(get_lang('SpecificSearchFieldsAvailable') ,$specific_fields_exists); |
|
823 | + $data[] = array(get_lang('XapianModuleInstalled'), $xapian_loaded); |
|
824 | + $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path, $dir_exists); |
|
825 | + $data[] = array(get_lang('IsWritable').' - '.$xapian_path, $dir_is_writable); |
|
826 | + $data[] = array(get_lang('SpecificSearchFieldsAvailable'), $specific_fields_exists); |
|
827 | 827 | |
828 | 828 | echo Display::tag('h3', get_lang('Settings')); |
829 | 829 | $table = new SortableTableFromArray($data); |
@@ -833,16 +833,16 @@ discard block |
||
833 | 833 | |
834 | 834 | //@todo windows support |
835 | 835 | if (api_is_windows_os() == false) { |
836 | - $list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv'); |
|
836 | + $list_of_programs = array('pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv'); |
|
837 | 837 | |
838 | - foreach($list_of_programs as $program) { |
|
838 | + foreach ($list_of_programs as $program) { |
|
839 | 839 | $output = $ret_val = null; |
840 | 840 | exec("which $program", $output, $ret_val); |
841 | 841 | $icon = Display::return_icon('bullet_red.png', get_lang('NotInstalled')); |
842 | 842 | if (!empty($output[0])) { |
843 | 843 | $icon = Display::return_icon('bullet_green.png', get_lang('Installed')); |
844 | 844 | } |
845 | - $data2[]= array($program, $output[0], $icon); |
|
845 | + $data2[] = array($program, $output[0], $icon); |
|
846 | 846 | } |
847 | 847 | echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles')); |
848 | 848 | $table = new SortableTableFromArray($data2); |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | if ($action != 'add') { |
875 | 875 | echo '<div class="actions" style="margin-left: 1px;">'; |
876 | 876 | echo '<a href="settings.php?category=Templates&action=add">'. |
877 | - Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
877 | + Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
878 | 878 | echo '</div>'; |
879 | 879 | } |
880 | 880 | |
@@ -993,8 +993,8 @@ discard block |
||
993 | 993 | * @since Dokeos 1.8.6 |
994 | 994 | */ |
995 | 995 | function actions_filter($id) { |
996 | - $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; |
|
997 | - $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'; |
|
996 | + $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; |
|
997 | + $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; |
|
998 | 998 | return $return; |
999 | 999 | } |
1000 | 1000 | |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | $form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400')); |
1045 | 1045 | |
1046 | 1046 | // Setting the form elements: the form to upload an image to be used with the template. |
1047 | - $form->addElement('file','template_image',get_lang('Image'),''); |
|
1047 | + $form->addElement('file', 'template_image', get_lang('Image'), ''); |
|
1048 | 1048 | |
1049 | 1049 | // Setting the form elements: a little bit information about the template image. |
1050 | 1050 | $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | // Store the information in the database (as insert or as update). |
1123 | 1123 | $table_system_template = Database :: get_main_table('system_template'); |
1124 | 1124 | if ($_GET['action'] == 'add') { |
1125 | - $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); |
|
1125 | + $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); |
|
1126 | 1126 | $params = [ |
1127 | 1127 | 'title' => $values['title'], |
1128 | 1128 | 'content' => $content_template, |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | |
1133 | 1133 | // Display a feedback message. |
1134 | 1134 | Display::display_confirmation_message(get_lang('TemplateAdded')); |
1135 | - echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1135 | + echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1136 | 1136 | } else { |
1137 | 1137 | $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>'; |
1138 | 1138 | $sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."', content = '".$content_template."'"; |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | display_templates(); |
1151 | 1151 | } else { |
1152 | 1152 | $token = Security::get_token(); |
1153 | - $form->addElement('hidden','sec_token'); |
|
1153 | + $form->addElement('hidden', 'sec_token'); |
|
1154 | 1154 | $form->setConstants(array('sec_token' => $token)); |
1155 | 1155 | // Display the form. |
1156 | 1156 | $form->display(); |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | $form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category'])); |
1252 | 1252 | |
1253 | - $form->addElement('hidden', 'search_field', (!empty($_GET['search_field'])?Security::remove_XSS($_GET['search_field']):null)); |
|
1253 | + $form->addElement('hidden', 'search_field', (!empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null)); |
|
1254 | 1254 | |
1255 | 1255 | $url_id = api_get_current_access_url_id(); |
1256 | 1256 | |
@@ -1317,9 +1317,9 @@ discard block |
||
1317 | 1317 | if (empty($row['category'])) |
1318 | 1318 | $row['category'] = 0; |
1319 | 1319 | |
1320 | - if (is_array($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ])) { |
|
1320 | + if (is_array($settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']])) { |
|
1321 | 1321 | // We are sure that the other site have a selected value. |
1322 | - if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '') |
|
1322 | + if ($settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value'] != '') |
|
1323 | 1323 | $row['selected_value'] = $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']]['selected_value']; |
1324 | 1324 | } |
1325 | 1325 | // There is no else{} statement because we load the default $row['selected_value'] of the main Chamilo site. |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | array('maxlength' => '8') |
1341 | 1341 | ); |
1342 | 1342 | $form->applyFilter($row['variable'], 'html_filter'); |
1343 | - $default_values[$row['variable']] = round($row['selected_value']/1024/1024, 1); |
|
1343 | + $default_values[$row['variable']] = round($row['selected_value'] / 1024 / 1024, 1); |
|
1344 | 1344 | } elseif ($row['variable'] == 'account_valid_duration') { |
1345 | 1345 | $form->addElement( |
1346 | 1346 | 'text', |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | ), |
1369 | 1369 | $hideme |
1370 | 1370 | ); |
1371 | - $form->applyFilter($row['variable'],'html_filter'); |
|
1371 | + $form->applyFilter($row['variable'], 'html_filter'); |
|
1372 | 1372 | $default_values[$row['variable']] = $row['selected_value']; |
1373 | 1373 | } |
1374 | 1374 | break; |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | if (file_exists($file)) { |
1380 | 1380 | $value = file_get_contents($file); |
1381 | 1381 | } |
1382 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1382 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1383 | 1383 | $default_values[$row['variable']] = $value; |
1384 | 1384 | } elseif ($row['variable'] == 'footer_extra_content') { |
1385 | 1385 | $file = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt'; |
@@ -1387,16 +1387,16 @@ discard block |
||
1387 | 1387 | if (file_exists($file)) { |
1388 | 1388 | $value = file_get_contents($file); |
1389 | 1389 | } |
1390 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1390 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1391 | 1391 | $default_values[$row['variable']] = $value; |
1392 | 1392 | } else { |
1393 | - $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10'), $hideme); |
|
1393 | + $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('rows'=>'10'), $hideme); |
|
1394 | 1394 | $default_values[$row['variable']] = $row['selected_value']; |
1395 | 1395 | } |
1396 | 1396 | break; |
1397 | 1397 | case 'radio': |
1398 | 1398 | $values = api_get_settings_options($row['variable']); |
1399 | - $group = array (); |
|
1399 | + $group = array(); |
|
1400 | 1400 | if (is_array($values)) { |
1401 | 1401 | foreach ($values as $key => $value) { |
1402 | 1402 | $element = &$form->createElement( |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | WHERE variable='".$row['variable']."' AND access_url = 1"; |
1428 | 1428 | |
1429 | 1429 | $result = Database::query($sql); |
1430 | - $group = array (); |
|
1430 | + $group = array(); |
|
1431 | 1431 | while ($rowkeys = Database::fetch_array($result)) { |
1432 | 1432 | // Profile tab option should be hidden when the social tool is enabled. |
1433 | 1433 | if (api_get_setting('allow_social_tool') == 'true') { |
@@ -1499,10 +1499,10 @@ discard block |
||
1499 | 1499 | |
1500 | 1500 | switch ($row['variable']) { |
1501 | 1501 | case 'pdf_export_watermark_enable': |
1502 | - $url = PDF::get_watermark(null); |
|
1502 | + $url = PDF::get_watermark(null); |
|
1503 | 1503 | |
1504 | 1504 | if ($url != false) { |
1505 | - $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png',get_lang('DelImage')).'</a>'; |
|
1505 | + $delete_url = '<a href="?delete_watermark">'.get_lang('DelImage').' '.Display::return_icon('delete.png', get_lang('DelImage')).'</a>'; |
|
1506 | 1506 | $form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="'.$url.'" style="margin-bottom:10px;" />'.$delete_url.'</div>'); |
1507 | 1507 | } |
1508 | 1508 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @param string ISO code (fr_FR, ...) |
29 | 29 | * @param int Whether the sublanguage is published (0=unpublished, 1=published) |
30 | 30 | * @param int ID del idioma padre |
31 | - * @return int New sub language ID or false on error |
|
31 | + * @return false|string New sub language ID or false on error |
|
32 | 32 | */ |
33 | 33 | function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) { |
34 | 34 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | $tool_name = get_lang('CreateSubLanguage'); |
19 | 19 | |
20 | 20 | // setting breadcrumbs |
21 | -$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
22 | -$interbreadcrumb[] = array ('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
|
21 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
22 | +$interbreadcrumb[] = array('url' => 'languages.php', 'name' => get_lang('PlatformLanguages')); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Add sub-language |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param int ID del idioma padre |
31 | 31 | * @return int New sub language ID or false on error |
32 | 32 | */ |
33 | -function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) { |
|
33 | +function add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id) { |
|
34 | 34 | $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
35 | 35 | $original_name = Database::escape_string($original_name); |
36 | 36 | $english_name = Database::escape_string($english_name); |
@@ -61,41 +61,41 @@ discard block |
||
61 | 61 | * @todo This function is not transaction-safe and should probably be included |
62 | 62 | * inside the add_sub_language function. |
63 | 63 | */ |
64 | -function check_if_language_exist ($original_name, $english_name, $isocode, $sublanguage_available) { |
|
65 | - $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | - $sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | - $sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
64 | +function check_if_language_exist($original_name, $english_name, $isocode, $sublanguage_available) { |
|
65 | + $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE); |
|
66 | + $sql_original_name = 'SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" '; |
|
67 | + $sql_english_name = 'SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" '; |
|
68 | 68 | //$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" '; |
69 | - $rs_original_name=Database::query($sql_original_name); |
|
70 | - $rs_english_name=Database::query($sql_english_name); |
|
69 | + $rs_original_name = Database::query($sql_original_name); |
|
70 | + $rs_english_name = Database::query($sql_english_name); |
|
71 | 71 | //$rs_isocode=Database::query($sql_isocode); |
72 | - $count_original_name=Database::result($rs_original_name,0,'count_original_name'); |
|
73 | - $count_english_name=Database::result($rs_english_name,0,'count_english_name'); |
|
72 | + $count_original_name = Database::result($rs_original_name, 0, 'count_original_name'); |
|
73 | + $count_english_name = Database::result($rs_english_name, 0, 'count_english_name'); |
|
74 | 74 | //$count_isocode=Database::result($rs_isocode,0,'count_isocode'); |
75 | - $has_error=false; |
|
76 | - $message_information=array(); |
|
75 | + $has_error = false; |
|
76 | + $message_information = array(); |
|
77 | 77 | |
78 | - if ($count_original_name==1) { |
|
79 | - $has_error=true; |
|
80 | - $message_information['original_name']=true; |
|
78 | + if ($count_original_name == 1) { |
|
79 | + $has_error = true; |
|
80 | + $message_information['original_name'] = true; |
|
81 | 81 | } |
82 | - if ($count_english_name==1) { |
|
83 | - $has_error=true; |
|
84 | - $message_information['english_name']=true; |
|
82 | + if ($count_english_name == 1) { |
|
83 | + $has_error = true; |
|
84 | + $message_information['english_name'] = true; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $iso_list = api_get_platform_isocodes(); |
88 | 88 | $iso_list = array_values($iso_list); |
89 | 89 | |
90 | 90 | if (!in_array($isocode, $iso_list)) { |
91 | - $has_error=true; |
|
92 | - $message_information['isocode']=true; |
|
91 | + $has_error = true; |
|
92 | + $message_information['isocode'] = true; |
|
93 | 93 | } |
94 | - if ($has_error===true) { |
|
95 | - $message_information['execute_add']=false; |
|
94 | + if ($has_error === true) { |
|
95 | + $message_information['execute_add'] = false; |
|
96 | 96 | } |
97 | - if ($has_error===false) { |
|
98 | - $message_information['execute_add']=true; |
|
97 | + if ($has_error === false) { |
|
98 | + $message_information['execute_add'] = true; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $message_information; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return bool |
109 | 109 | * @todo deprecate this function and use the static method directly |
110 | 110 | */ |
111 | -function check_if_exist_language_by_id ($language_id) { |
|
111 | +function check_if_exist_language_by_id($language_id) { |
|
112 | 112 | return SubLanguageManager::check_if_exist_language_by_id($language_id); |
113 | 113 | } |
114 | 114 | /** |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * @param int Language ID of the presumed parent |
117 | 117 | * @return bool True if this language has children, false otherwise |
118 | 118 | */ |
119 | -function ckeck_if_is_parent_of_sub_language ($parent_id) { |
|
120 | - $sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | - $rs=Database::query($sql); |
|
122 | - if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) { |
|
119 | +function ckeck_if_is_parent_of_sub_language($parent_id) { |
|
120 | + $sql = 'SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).''; |
|
121 | + $rs = Database::query($sql); |
|
122 | + if (Database::num_rows($rs) > 0 && Database::result($rs, 0, 'count') == 1) { |
|
123 | 123 | return true; |
124 | 124 | } else { |
125 | 125 | return false; |
@@ -131,117 +131,117 @@ discard block |
||
131 | 131 | * @param int Child language ID |
132 | 132 | * @return array |
133 | 133 | */ |
134 | -function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id) { |
|
135 | - return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id); |
|
134 | +function allow_get_all_information_of_sub_language($parent_id, $sub_language_id) { |
|
135 | + return SubLanguageManager::get_all_information_of_sub_language($parent_id, $sub_language_id); |
|
136 | 136 | } |
137 | 137 | /*end declare functions*/ |
138 | 138 | |
139 | 139 | //add data |
140 | 140 | |
141 | -if (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id']))) { |
|
142 | - $language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | - if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) { |
|
144 | - $sub_language_id=$_GET['sub_language_id']; |
|
145 | - $sub_language_id_exist=true; |
|
141 | +if (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id']))) { |
|
142 | + $language_name = SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']); |
|
143 | + if (check_if_exist_language_by_id($_GET['sub_language_id']) === true) { |
|
144 | + $sub_language_id = $_GET['sub_language_id']; |
|
145 | + $sub_language_id_exist = true; |
|
146 | 146 | } else { |
147 | - $sub_language_id_exist=false; |
|
147 | + $sub_language_id_exist = false; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
151 | 151 | $language_details = array(); |
152 | -$language_name=''; |
|
153 | -if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
|
152 | +$language_name = ''; |
|
153 | +if (isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) { |
|
154 | 154 | $language_details = SubLanguageManager::get_all_information_of_language($_GET['id']); |
155 | 155 | $language_name = $language_details['original_name']; |
156 | - if (check_if_exist_language_by_id ($_GET['id'])===true) { |
|
157 | - $parent_id=$_GET['id']; |
|
158 | - $language_id_exist=true; |
|
156 | + if (check_if_exist_language_by_id($_GET['id']) === true) { |
|
157 | + $parent_id = $_GET['id']; |
|
158 | + $language_id_exist = true; |
|
159 | 159 | } else { |
160 | - $language_id_exist=false; |
|
160 | + $language_id_exist = false; |
|
161 | 161 | } |
162 | 162 | } else { |
163 | - $language_id_exist=false; |
|
163 | + $language_id_exist = false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | //removed and register |
167 | 167 | |
168 | -if ((isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id'])))) { |
|
169 | - if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) { |
|
170 | - $get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']); |
|
171 | - $original_name=$get_all_information['original_name']; |
|
172 | - $english_name=$get_all_information['english_name']; |
|
173 | - $isocode=$get_all_information['isocode']; |
|
168 | +if ((isset($_GET['id']) && $_GET['id'] == strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id'] == strval(intval($_GET['sub_language_id'])))) { |
|
169 | + if (check_if_exist_language_by_id($_GET['id']) === true && check_if_exist_language_by_id($_GET['sub_language_id']) === true) { |
|
170 | + $get_all_information = allow_get_all_information_of_sub_language($_GET['id'], $_GET['sub_language_id']); |
|
171 | + $original_name = $get_all_information['original_name']; |
|
172 | + $english_name = $get_all_information['english_name']; |
|
173 | + $isocode = $get_all_information['isocode']; |
|
174 | 174 | |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | -$language_name=get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
|
178 | +$language_name = get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )'; |
|
179 | 179 | |
180 | -if (ckeck_if_is_parent_of_sub_language($parent_id)===true && isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
181 | - $language_name=get_lang('DeleteSubLanguage'); |
|
180 | +if (ckeck_if_is_parent_of_sub_language($parent_id) === true && isset($_GET['action']) && $_GET['action'] == 'deletesublanguage') { |
|
181 | + $language_name = get_lang('DeleteSubLanguage'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $msg = ''; |
185 | 185 | |
186 | 186 | if (isset($_POST['SubmitAddNewLanguage'])) { |
187 | - $original_name=$_POST['original_name']; |
|
188 | - $english_name=$_POST['english_name']; |
|
189 | - $isocode=$_POST['isocode']; |
|
190 | - $english_name=str_replace(' ','_',$english_name); |
|
191 | - $isocode=str_replace(' ','_',$isocode); |
|
187 | + $original_name = $_POST['original_name']; |
|
188 | + $english_name = $_POST['english_name']; |
|
189 | + $isocode = $_POST['isocode']; |
|
190 | + $english_name = str_replace(' ', '_', $english_name); |
|
191 | + $isocode = str_replace(' ', '_', $isocode); |
|
192 | 192 | |
193 | - $sublanguage_available=$_POST['sub_language_is_visible']; |
|
194 | - $check_information=array(); |
|
195 | - $check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available); |
|
193 | + $sublanguage_available = $_POST['sub_language_is_visible']; |
|
194 | + $check_information = array(); |
|
195 | + $check_information = check_if_language_exist($original_name, $english_name, $isocode, $sublanguage_available); |
|
196 | 196 | foreach ($check_information as $index_information => $value_information) { |
197 | - $allow_insert_info=false; |
|
198 | - if ($index_information=='original_name') { |
|
199 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error'); |
|
197 | + $allow_insert_info = false; |
|
198 | + if ($index_information == 'original_name') { |
|
199 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')', 'error'); |
|
200 | 200 | } |
201 | - if ($index_information=='english_name') { |
|
202 | - $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error'); |
|
201 | + if ($index_information == 'english_name') { |
|
202 | + $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')', 'error'); |
|
203 | 203 | } |
204 | - if ($index_information=='isocode') { |
|
205 | - $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error'); |
|
204 | + if ($index_information == 'isocode') { |
|
205 | + $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'', 'error'); |
|
206 | 206 | } |
207 | - if ($index_information=='execute_add' && $value_information===true) { |
|
208 | - $allow_insert_info=true; |
|
207 | + if ($index_information == 'execute_add' && $value_information === true) { |
|
208 | + $allow_insert_info = true; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) { |
|
213 | - if ($allow_insert_info===true && $language_id_exist===true) { |
|
214 | - $english_name=str_replace(' ','_',$english_name); |
|
212 | + if (strlen($original_name) > 0 && strlen($english_name) > 0 && strlen($isocode) > 0) { |
|
213 | + if ($allow_insert_info === true && $language_id_exist === true) { |
|
214 | + $english_name = str_replace(' ', '_', $english_name); |
|
215 | 215 | //Fixes BT#1636 |
216 | - $english_name=api_strtolower($english_name); |
|
216 | + $english_name = api_strtolower($english_name); |
|
217 | 217 | |
218 | - $isocode=str_replace(' ','_',$isocode); |
|
219 | - $str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
218 | + $isocode = str_replace(' ', '_', $isocode); |
|
219 | + $str_info = '<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode; |
|
220 | 220 | |
221 | - $mkdir_result=SubLanguageManager::add_language_directory($english_name); |
|
221 | + $mkdir_result = SubLanguageManager::add_language_directory($english_name); |
|
222 | 222 | if ($mkdir_result) { |
223 | - $sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id); |
|
223 | + $sl_id = add_sub_language($original_name, $english_name, $isocode, $sublanguage_available, $parent_id); |
|
224 | 224 | if ($sl_id === false) { |
225 | 225 | SubLanguageManager::remove_language_directory($english_name); |
226 | - $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
226 | + $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'), 'error'); |
|
227 | 227 | } else { |
228 | 228 | // Here we build the confirmation message and we send the user to the sub language terms definition page, using a little hack - see #3712 |
229 | - $_SESSION['msg'] = Display::return_message(get_lang('TheNewSubLanguageHasBeenAdded').$str_info.'confirm',false); |
|
229 | + $_SESSION['msg'] = Display::return_message(get_lang('TheNewSubLanguageHasBeenAdded').$str_info.'confirm', false); |
|
230 | 230 | unset($interbreadcrumb); |
231 | 231 | $_GET['sub_language_id'] = $_REQUEST['sub_language_id'] = $sl_id; |
232 | 232 | require 'sub_language.php'; |
233 | 233 | exit(); |
234 | 234 | } |
235 | 235 | } else { |
236 | - $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error'); |
|
236 | + $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'), 'error'); |
|
237 | 237 | } |
238 | 238 | } else { |
239 | - if ($language_id_exist===false) { |
|
240 | - $msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error'); |
|
239 | + if ($language_id_exist === false) { |
|
240 | + $msg .= Display::return_message(get_lang('LanguageParentNotExist'), 'error'); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } else { |
244 | - $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'),'error'); |
|
244 | + $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error'); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | if (isset($_POST['SubmitAddDeleteLanguage'])) { |
253 | 253 | $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']); |
254 | - if ($rs===true) { |
|
254 | + if ($rs === true) { |
|
255 | 255 | Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved')); |
256 | 256 | } else { |
257 | 257 | Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved')); |
@@ -259,14 +259,14 @@ discard block |
||
259 | 259 | } |
260 | 260 | // ckeck_if_is_parent_of_sub_language($parent_id)===false |
261 | 261 | // |
262 | -if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
262 | +if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { |
|
263 | 263 | $text = $language_name; |
264 | 264 | $form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage'); |
265 | - $class='add'; |
|
265 | + $class = 'add'; |
|
266 | 266 | $form->addElement('header', '', $text); |
267 | - $form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"'); |
|
267 | + $form->addElement('text', 'original_name', get_lang('OriginalName'), 'class="input_titles"'); |
|
268 | 268 | $form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required'); |
269 | - $form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"'); |
|
269 | + $form->addElement('text', 'english_name', get_lang('EnglishName'), 'class="input_titles"'); |
|
270 | 270 | $form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required'); |
271 | 271 | $form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"'); |
272 | 272 | $form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required'); |
@@ -279,18 +279,18 @@ discard block |
||
279 | 279 | $form->setDefaults($values); |
280 | 280 | $form->display(); |
281 | 281 | } else { |
282 | - if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') { |
|
283 | - $text=$language_name; |
|
282 | + if (isset($_GET['action']) && $_GET['action'] == 'deletesublanguage') { |
|
283 | + $text = $language_name; |
|
284 | 284 | $form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id'])); |
285 | - $class='minus'; |
|
285 | + $class = 'minus'; |
|
286 | 286 | $form->addElement('header', '', $text); |
287 | - $form->addElement('static', '', get_lang('OriginalName'),$original_name); |
|
288 | - $form->addElement('static', '', get_lang('EnglishName'),$english_name); |
|
289 | - $form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode); |
|
287 | + $form->addElement('static', '', get_lang('OriginalName'), $original_name); |
|
288 | + $form->addElement('static', '', get_lang('EnglishName'), $english_name); |
|
289 | + $form->addElement('static', '', get_lang('PlatformCharsetTitle'), $isocode); |
|
290 | 290 | $form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage'); |
291 | 291 | $form->display(); |
292 | 292 | } |
293 | - if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') { |
|
293 | + if (isset($_GET['action']) && $_GET['action'] == 'definenewsublanguage') { |
|
294 | 294 | Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded')); |
295 | 295 | } |
296 | 296 | } |
@@ -128,7 +128,7 @@ |
||
128 | 128 | /** |
129 | 129 | * Update users from the imported data |
130 | 130 | * @param array $users List of users |
131 | - * @return void |
|
131 | + * @return false|null |
|
132 | 132 | * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in |
133 | 133 | */ |
134 | 134 |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | // We are sure that the extra field exists. |
216 | 216 | foreach ($extra_fields as $extras) { |
217 | 217 | if (isset($user[$extras[1]])) { |
218 | - $key = $extras[1]; |
|
219 | - $value = $user[$extras[1]]; |
|
218 | + $key = $extras[1]; |
|
219 | + $value = $user[$extras[1]]; |
|
220 | 220 | UserManager::update_extra_field_value($user_id, $key, $value); |
221 | 221 | } |
222 | 222 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | global $current_tag; |
254 | 254 | switch ($data) { |
255 | 255 | case 'Contact': |
256 | - $user = array (); |
|
256 | + $user = array(); |
|
257 | 257 | break; |
258 | 258 | default: |
259 | 259 | $current_tag = $data; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | if (in_array($ext_import_file, $allowed_file_mimetype)) { |
352 | 352 | if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) { |
353 | - $users = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
353 | + $users = parse_csv_data($_FILES['import_file']['tmp_name']); |
|
354 | 354 | $errors = validate_data($users); |
355 | 355 | $error_kind_file = false; |
356 | 356 | } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) { |
@@ -206,7 +206,7 @@ |
||
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Restores an attendance entry and fallback to attendances rendering |
209 | - * @param int $attendanceId |
|
209 | + * @param int $attendance_id |
|
210 | 210 | */ |
211 | 211 | public function attendance_restore($attendance_id) |
212 | 212 | { |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $attendance->set_attendance_qualify_title($_POST['attendance_qualify_title']); |
61 | 61 | $attendance->set_attendance_weight($_POST['attendance_weight']); |
62 | 62 | $link_to_gradebook = false; |
63 | - if ( isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1 ) { |
|
63 | + if (isset($_POST['attendance_qualify_gradebook']) && $_POST['attendance_qualify_gradebook'] == 1) { |
|
64 | 64 | $link_to_gradebook = true; |
65 | 65 | } |
66 | 66 | $attendance->category_id = $_POST['category_id']; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ) { |
113 | 113 | $link_to_gradebook = true; |
114 | 114 | } |
115 | - $attendance->attendance_edit($attendance_id,$link_to_gradebook); |
|
115 | + $attendance->attendance_edit($attendance_id, $link_to_gradebook); |
|
116 | 116 | Security::clear_token(); |
117 | 117 | header('location:index.php?action=attendance_list&'.api_get_cidreq()); |
118 | 118 | exit; |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | } |
544 | 544 | } |
545 | 545 | $max_cols_per_page = 12; //10 dates + 2 name and number |
546 | - $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2;//10 |
|
546 | + $max_dates_per_page = $max_dates_per_page_original = $max_cols_per_page - 2; //10 |
|
547 | 547 | $rows = count($data_table); |
548 | 548 | |
549 | 549 | if ($cols > $max_cols_per_page) { |
550 | - $number_tables = round(($cols-2)/$max_dates_per_page); |
|
550 | + $number_tables = round(($cols - 2) / $max_dates_per_page); |
|
551 | 551 | $headers = $data_table[0]; |
552 | 552 | $all = array(); |
553 | 553 | $tables = array(); |
554 | 554 | $changed = 1; |
555 | 555 | |
556 | - for ($i= 0; $i <= $rows; $i++) { |
|
556 | + for ($i = 0; $i <= $rows; $i++) { |
|
557 | 557 | $row = isset($data_table[$i]) ? $data_table[$i] : null; |
558 | 558 | $key = 1; |
559 | 559 | $max_dates_per_page = 10; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | foreach ($item as $value) { |
565 | 565 | if ($count_j >= $max_dates_per_page) { |
566 | 566 | $key++; |
567 | - $max_dates_per_page = $max_dates_per_page_original*$key; |
|
567 | + $max_dates_per_page = $max_dates_per_page_original * $key; |
|
568 | 568 | //magic hack |
569 | 569 | $tables[$key][$i][] = $tables[1][$i][0]; |
570 | 570 | $tables[$key][$i][] = $tables[1][$i][1]; |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | $form = new FormValidator( |
623 | 623 | 'search', |
624 | 624 | 'post', |
625 | - api_get_self() . '?' . api_get_cidreq( |
|
626 | - ) . '&action=calendar_logins' |
|
625 | + api_get_self().'?'.api_get_cidreq( |
|
626 | + ).'&action=calendar_logins' |
|
627 | 627 | ); |
628 | 628 | $form->addDateRangePicker('range', get_lang('DateRange')); |
629 | 629 | $form->addButton('submit', get_lang('Submit')); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | require_once api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php'; |
11 | 11 | |
12 | 12 | /** |
13 | -* @return true if cas is configured |
|
13 | +* @return boolean if cas is configured |
|
14 | 14 | * |
15 | 15 | **/ |
16 | 16 | function cas_configured() { |
@@ -41,13 +41,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | /** |
517 | 517 | * Logs a string in debug mode. |
518 | 518 | * |
519 | - * @param $str the string to write |
|
519 | + * @param string $str the string to write |
|
520 | 520 | * |
521 | 521 | * @private |
522 | 522 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * This method is used by interface methods to print an error and where the function |
538 | 538 | * was originally called from. |
539 | 539 | * |
540 | - * @param $msg the message to print |
|
540 | + * @param string $msg the message to print |
|
541 | 541 | * |
542 | 542 | * @private |
543 | 543 | */ |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | /** |
665 | 665 | * This method returns the phpCAS version. |
666 | 666 | * |
667 | - * @return the phpCAS version. |
|
667 | + * @return string phpCAS version. |
|
668 | 668 | */ |
669 | 669 | function getVersion() { |
670 | 670 | return PHPCAS_VERSION; |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | * @warning should not be called only after phpCAS::forceAuthentication() |
1071 | 1071 | * or phpCAS::checkAuthentication(). |
1072 | 1072 | * |
1073 | - * @return the login name of the authenticated user |
|
1073 | + * @return string login name of the authenticated user |
|
1074 | 1074 | */ |
1075 | 1075 | function getUser() { |
1076 | 1076 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | // hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI'] in IIS |
34 | 34 | // |
35 | 35 | if (!$_SERVER['REQUEST_URI']) { |
36 | - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; |
|
36 | + $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING']; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // |
40 | 40 | // another one by Vangelis Haniotakis also to make phpCAS work with PHP5 |
41 | 41 | // |
42 | 42 | if (version_compare(PHP_VERSION, '5', '>=')) { |
43 | - require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php'); |
|
43 | + require_once (dirname(__FILE__).'/CAS/domxml-php4-to-php5.php'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @hideinitializer |
283 | 283 | */ |
284 | -$GLOBALS['PHPCAS_INIT_CALL'] = array ( |
|
284 | +$GLOBALS['PHPCAS_INIT_CALL'] = array( |
|
285 | 285 | 'done' => FALSE, |
286 | 286 | 'file' => '?', |
287 | 287 | 'line' => -1, |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @hideinitializer |
296 | 296 | */ |
297 | -$GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array ( |
|
297 | +$GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array( |
|
298 | 298 | 'done' => FALSE, |
299 | 299 | 'file' => '?', |
300 | 300 | 'line' => -1, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @hideinitializer |
309 | 309 | */ |
310 | -$GLOBALS['PHPCAS_DEBUG'] = array ( |
|
310 | +$GLOBALS['PHPCAS_DEBUG'] = array( |
|
311 | 311 | 'filename' => '/tmp/cas.log', |
312 | 312 | 'indent' => 0, |
313 | 313 | 'unique_id' => '' |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | // ######################################################################## |
321 | 321 | |
322 | 322 | // include client class |
323 | -include_once (dirname(__FILE__) . '/CAS/client.php'); |
|
323 | +include_once (dirname(__FILE__).'/CAS/client.php'); |
|
324 | 324 | |
325 | 325 | // ######################################################################## |
326 | 326 | // INTERFACE CLASS |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | phpCAS :: traceBegin(); |
370 | 370 | if (is_object($PHPCAS_CLIENT)) { |
371 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
371 | + phpCAS :: error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')'); |
|
372 | 372 | } |
373 | 373 | if (gettype($server_version) != 'string') { |
374 | 374 | phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
@@ -385,11 +385,11 @@ discard block |
||
385 | 385 | |
386 | 386 | // store where the initializer is called from |
387 | 387 | $dbg = phpCAS :: backtrace(); |
388 | - $PHPCAS_INIT_CALL = array ( |
|
388 | + $PHPCAS_INIT_CALL = array( |
|
389 | 389 | 'done' => TRUE, |
390 | 390 | 'file' => $dbg[0]['file'], |
391 | 391 | 'line' => $dbg[0]['line'], |
392 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
392 | + 'method' => __CLASS__.'::'.__FUNCTION__ |
|
393 | 393 | ); |
394 | 394 | |
395 | 395 | // initialize the global object $PHPCAS_CLIENT |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | phpCAS :: traceBegin(); |
419 | 419 | if (is_object($PHPCAS_CLIENT)) { |
420 | - phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')'); |
|
420 | + phpCAS :: error($PHPCAS_INIT_CALL['method'].'() has already been called (at '.$PHPCAS_INIT_CALL['file'].':'.$PHPCAS_INIT_CALL['line'].')'); |
|
421 | 421 | } |
422 | 422 | if (gettype($server_version) != 'string') { |
423 | 423 | phpCAS :: error('type mismatched for parameter $server_version (should be `string\')'); |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | |
435 | 435 | // store where the initialzer is called from |
436 | 436 | $dbg = phpCAS :: backtrace(); |
437 | - $PHPCAS_INIT_CALL = array ( |
|
437 | + $PHPCAS_INIT_CALL = array( |
|
438 | 438 | 'done' => TRUE, |
439 | 439 | 'file' => $dbg[0]['file'], |
440 | 440 | 'line' => $dbg[0]['line'], |
441 | - 'method' => __CLASS__ . '::' . __FUNCTION__ |
|
441 | + 'method' => __CLASS__.'::'.__FUNCTION__ |
|
442 | 442 | ); |
443 | 443 | |
444 | 444 | // initialize the global object $PHPCAS_CLIENT |
@@ -472,17 +472,17 @@ discard block |
||
472 | 472 | if (empty ($filename)) { |
473 | 473 | if (preg_match('/^Win.*/', getenv('OS'))) { |
474 | 474 | if (isset ($_ENV['TMP'])) { |
475 | - $debugDir = $_ENV['TMP'] . '/'; |
|
475 | + $debugDir = $_ENV['TMP'].'/'; |
|
476 | 476 | } else |
477 | 477 | if (isset ($_ENV['TEMP'])) { |
478 | - $debugDir = $_ENV['TEMP'] . '/'; |
|
478 | + $debugDir = $_ENV['TEMP'].'/'; |
|
479 | 479 | } else { |
480 | 480 | $debugDir = ''; |
481 | 481 | } |
482 | 482 | } else { |
483 | 483 | $debugDir = DEFAULT_DEBUG_DIR; |
484 | 484 | } |
485 | - $filename = $debugDir . 'phpCAS.log'; |
|
485 | + $filename = $debugDir.'phpCAS.log'; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | if (empty ($PHPCAS_DEBUG['unique_id'])) { |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | return debug_backtrace(); |
510 | 510 | } else { |
511 | 511 | // poor man's hack ... but it does work ... |
512 | - return array (); |
|
512 | + return array(); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) { |
529 | 529 | $indent_str .= '| '; |
530 | 530 | } |
531 | - error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']); |
|
531 | + error_log($PHPCAS_DEBUG['unique_id'].' '.$indent_str.$str."\n", 3, $PHPCAS_DEBUG['filename']); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | } |
558 | 558 | } |
559 | 559 | } |
560 | - echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n"; |
|
560 | + echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>".__CLASS__."::".$function.'(): '.htmlentities($msg)."</b></font> in <b>".$file."</b> on line <b>".$line."</b><br />\n"; |
|
561 | 561 | phpCAS :: trace($msg); |
562 | 562 | phpCAS :: traceExit(); |
563 | 563 | exit (); |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | */ |
569 | 569 | function trace($str) { |
570 | 570 | $dbg = phpCAS :: backtrace(); |
571 | - phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']'); |
|
571 | + phpCAS :: log($str.' ['.basename($dbg[1]['file']).':'.$dbg[1]['line'].']'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | $dbg = phpCAS :: backtrace(); |
581 | 581 | $str = '=> '; |
582 | 582 | if (!empty ($dbg[2]['class'])) { |
583 | - $str .= $dbg[2]['class'] . '::'; |
|
583 | + $str .= $dbg[2]['class'].'::'; |
|
584 | 584 | } |
585 | - $str .= $dbg[2]['function'] . '('; |
|
585 | + $str .= $dbg[2]['function'].'('; |
|
586 | 586 | if (is_array($dbg[2]['args'])) { |
587 | 587 | foreach ($dbg[2]['args'] as $index => $arg) { |
588 | 588 | if ($index != 0) { |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | $str .= str_replace("\n", "", var_export($arg, TRUE)); |
592 | 592 | } |
593 | 593 | } |
594 | - $str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']'; |
|
594 | + $str .= ') ['.basename($dbg[2]['file']).':'.$dbg[2]['line'].']'; |
|
595 | 595 | phpCAS :: log($str); |
596 | 596 | $PHPCAS_DEBUG['indent']++; |
597 | 597 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $PHPCAS_DEBUG['indent']--; |
608 | 608 | $dbg = phpCAS :: backtrace(); |
609 | 609 | $str = ''; |
610 | - $str .= '<= ' . str_replace("\n", "", var_export($res, TRUE)); |
|
610 | + $str .= '<= '.str_replace("\n", "", var_export($res, TRUE)); |
|
611 | 611 | phpCAS :: log($str); |
612 | 612 | } |
613 | 613 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | function setLang($lang) { |
645 | 645 | global $PHPCAS_CLIENT; |
646 | 646 | if (!is_object($PHPCAS_CLIENT)) { |
647 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
647 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
648 | 648 | } |
649 | 649 | if (gettype($lang) != 'string') { |
650 | 650 | phpCAS :: error('type mismatched for parameter $lang (should be `string\')'); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | function setHTMLHeader($header) { |
688 | 688 | global $PHPCAS_CLIENT; |
689 | 689 | if (!is_object($PHPCAS_CLIENT)) { |
690 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
690 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
691 | 691 | } |
692 | 692 | if (gettype($header) != 'string') { |
693 | 693 | phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | function setHTMLFooter($footer) { |
704 | 704 | global $PHPCAS_CLIENT; |
705 | 705 | if (!is_object($PHPCAS_CLIENT)) { |
706 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
706 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
707 | 707 | } |
708 | 708 | if (gettype($footer) != 'string') { |
709 | 709 | phpCAS :: error('type mismatched for parameter $footer (should be `string\')'); |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | |
733 | 733 | phpCAS :: traceBegin(); |
734 | 734 | if (!is_object($PHPCAS_CLIENT)) { |
735 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
735 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
736 | 736 | } |
737 | 737 | if (!$PHPCAS_CLIENT->isProxy()) { |
738 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
738 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
739 | 739 | } |
740 | 740 | if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
741 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
741 | + phpCAS :: error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')'); |
|
742 | 742 | } |
743 | 743 | if (gettype($format) != 'string') { |
744 | 744 | phpCAS :: error('type mismatched for parameter $format (should be `string\')'); |
@@ -770,13 +770,13 @@ discard block |
||
770 | 770 | |
771 | 771 | phpCAS :: traceBegin(); |
772 | 772 | if (!is_object($PHPCAS_CLIENT)) { |
773 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
773 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
774 | 774 | } |
775 | 775 | if (!$PHPCAS_CLIENT->isProxy()) { |
776 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
776 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
777 | 777 | } |
778 | 778 | if ($PHPCAS_AUTH_CHECK_CALL['done']) { |
779 | - phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')'); |
|
779 | + phpCAS :: error('this method should only be called before '.$PHPCAS_AUTH_CHECK_CALL['method'].'() (called at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].')'); |
|
780 | 780 | } |
781 | 781 | if (gettype($user) != 'string') { |
782 | 782 | phpCAS :: error('type mismatched for parameter $user (should be `string\')'); |
@@ -830,16 +830,16 @@ discard block |
||
830 | 830 | |
831 | 831 | phpCAS :: traceBegin(); |
832 | 832 | if (!is_object($PHPCAS_CLIENT)) { |
833 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
833 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
834 | 834 | } |
835 | 835 | if (!$PHPCAS_CLIENT->isProxy()) { |
836 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
836 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
837 | 837 | } |
838 | 838 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
839 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
839 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling '.__CLASS__.'::checkAuthentication() or '.__CLASS__.'::forceAuthentication()'); |
|
840 | 840 | } |
841 | 841 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
842 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
842 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
843 | 843 | } |
844 | 844 | if (gettype($url) != 'string') { |
845 | 845 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -873,16 +873,16 @@ discard block |
||
873 | 873 | |
874 | 874 | phpCAS :: traceBegin(); |
875 | 875 | if (!is_object($PHPCAS_CLIENT)) { |
876 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
876 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
877 | 877 | } |
878 | 878 | if (!$PHPCAS_CLIENT->isProxy()) { |
879 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
879 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
880 | 880 | } |
881 | 881 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
882 | - phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()'); |
|
882 | + phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling '.__CLASS__.'::checkAuthentication() or '.__CLASS__.'::forceAuthentication()'); |
|
883 | 883 | } |
884 | 884 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
885 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
885 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
886 | 886 | } |
887 | 887 | if (gettype($url) != 'string') { |
888 | 888 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | function setCacheTimesForAuthRecheck($n) { |
919 | 919 | global $PHPCAS_CLIENT; |
920 | 920 | if (!is_object($PHPCAS_CLIENT)) { |
921 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
921 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
922 | 922 | } |
923 | 923 | if (gettype($n) != 'integer') { |
924 | 924 | phpCAS :: error('type mismatched for parameter $header (should be `string\')'); |
@@ -935,18 +935,18 @@ discard block |
||
935 | 935 | |
936 | 936 | phpCAS :: traceBegin(); |
937 | 937 | if (!is_object($PHPCAS_CLIENT)) { |
938 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
938 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | $auth = $PHPCAS_CLIENT->checkAuthentication(); |
942 | 942 | |
943 | 943 | // store where the authentication has been checked and the result |
944 | 944 | $dbg = phpCAS :: backtrace(); |
945 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
945 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
946 | 946 | 'done' => TRUE, |
947 | 947 | 'file' => $dbg[0]['file'], |
948 | 948 | 'line' => $dbg[0]['line'], |
949 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
949 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
950 | 950 | 'result' => $auth |
951 | 951 | ); |
952 | 952 | phpCAS :: traceEnd($auth); |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | |
964 | 964 | phpCAS :: traceBegin(); |
965 | 965 | if (!is_object($PHPCAS_CLIENT)) { |
966 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
966 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | $auth = $PHPCAS_CLIENT->forceAuthentication(); |
970 | 970 | |
971 | 971 | // store where the authentication has been checked and the result |
972 | 972 | $dbg = phpCAS :: backtrace(); |
973 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
973 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
974 | 974 | 'done' => TRUE, |
975 | 975 | 'file' => $dbg[0]['file'], |
976 | 976 | 'line' => $dbg[0]['line'], |
977 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
977 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
978 | 978 | 'result' => $auth |
979 | 979 | ); |
980 | 980 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | phpCAS :: trace('user is not authenticated, redirecting to the CAS server'); |
983 | 983 | $PHPCAS_CLIENT->forceAuthentication(); |
984 | 984 | } else { |
985 | - phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)'); |
|
985 | + phpCAS :: trace('no need to authenticate (user `'.phpCAS :: getUser().'\' is already authenticated)'); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | phpCAS :: traceEnd(); |
@@ -997,16 +997,16 @@ discard block |
||
997 | 997 | |
998 | 998 | phpCAS :: traceBegin(); |
999 | 999 | if (!is_object($PHPCAS_CLIENT)) { |
1000 | - phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1000 | + phpCAS :: error('this method should not be called before'.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | // store where the authentication has been checked and the result |
1004 | 1004 | $dbg = phpCAS :: backtrace(); |
1005 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1005 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
1006 | 1006 | 'done' => TRUE, |
1007 | 1007 | 'file' => $dbg[0]['file'], |
1008 | 1008 | 'line' => $dbg[0]['line'], |
1009 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1009 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
1010 | 1010 | 'result' => $auth |
1011 | 1011 | ); |
1012 | 1012 | |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | * This method has been left from version 0.4.1 for compatibility reasons. |
1019 | 1019 | */ |
1020 | 1020 | function authenticate() { |
1021 | - phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead'); |
|
1021 | + phpCAS :: error('this method is deprecated. You should use '.__CLASS__.'::forceAuthentication() instead'); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | |
1033 | 1033 | phpCAS :: traceBegin(); |
1034 | 1034 | if (!is_object($PHPCAS_CLIENT)) { |
1035 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1035 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | // call the isAuthenticated method of the global $PHPCAS_CLIENT object |
@@ -1040,11 +1040,11 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | // store where the authentication has been checked and the result |
1042 | 1042 | $dbg = phpCAS :: backtrace(); |
1043 | - $PHPCAS_AUTH_CHECK_CALL = array ( |
|
1043 | + $PHPCAS_AUTH_CHECK_CALL = array( |
|
1044 | 1044 | 'done' => TRUE, |
1045 | 1045 | 'file' => $dbg[0]['file'], |
1046 | 1046 | 'line' => $dbg[0]['line'], |
1047 | - 'method' => __CLASS__ . '::' . __FUNCTION__, |
|
1047 | + 'method' => __CLASS__.'::'.__FUNCTION__, |
|
1048 | 1048 | 'result' => $auth |
1049 | 1049 | ); |
1050 | 1050 | phpCAS :: traceEnd($auth); |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | function isSessionAuthenticated() { |
1061 | 1061 | global $PHPCAS_CLIENT; |
1062 | 1062 | if (!is_object($PHPCAS_CLIENT)) { |
1063 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1063 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1064 | 1064 | } |
1065 | 1065 | return ($PHPCAS_CLIENT->isSessionAuthenticated()); |
1066 | 1066 | } |
@@ -1075,13 +1075,13 @@ discard block |
||
1075 | 1075 | function getUser() { |
1076 | 1076 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
1077 | 1077 | if (!is_object($PHPCAS_CLIENT)) { |
1078 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1078 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1079 | 1079 | } |
1080 | 1080 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
1081 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1081 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'); |
|
1082 | 1082 | } |
1083 | 1083 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
1084 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1084 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
1085 | 1085 | } |
1086 | 1086 | return $PHPCAS_CLIENT->getUser(); |
1087 | 1087 | } |
@@ -1096,13 +1096,13 @@ discard block |
||
1096 | 1096 | function getAttributes() { |
1097 | 1097 | global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL; |
1098 | 1098 | if (!is_object($PHPCAS_CLIENT)) { |
1099 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1099 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1100 | 1100 | } |
1101 | 1101 | if (!$PHPCAS_AUTH_CHECK_CALL['done']) { |
1102 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()'); |
|
1102 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::forceAuthentication() or '.__CLASS__.'::isAuthenticated()'); |
|
1103 | 1103 | } |
1104 | 1104 | if (!$PHPCAS_AUTH_CHECK_CALL['result']) { |
1105 | - phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE'); |
|
1105 | + phpCAS :: error('authentication was checked (by '.$PHPCAS_AUTH_CHECK_CALL['method'].'() at '.$PHPCAS_AUTH_CHECK_CALL['file'].':'.$PHPCAS_AUTH_CHECK_CALL['line'].') but the method returned FALSE'); |
|
1106 | 1106 | } |
1107 | 1107 | return $PHPCAS_CLIENT->getAttributes(); |
1108 | 1108 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | function handleLogoutRequests($check_client = true, $allowed_clients = false) { |
1113 | 1113 | global $PHPCAS_CLIENT; |
1114 | 1114 | if (!is_object($PHPCAS_CLIENT)) { |
1115 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1115 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1116 | 1116 | } |
1117 | 1117 | return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients)); |
1118 | 1118 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | function getServerLoginURL() { |
1127 | 1127 | global $PHPCAS_CLIENT; |
1128 | 1128 | if (!is_object($PHPCAS_CLIENT)) { |
1129 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1129 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1130 | 1130 | } |
1131 | 1131 | return $PHPCAS_CLIENT->getServerLoginURL(); |
1132 | 1132 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | phpCAS :: traceBegin(); |
1142 | 1142 | if (!is_object($PHPCAS_CLIENT)) { |
1143 | 1143 | phpCAS :: error('this method should only be called after |
1144 | - ' . __CLASS__ . '::client()'); |
|
1144 | + ' . __CLASS__.'::client()'); |
|
1145 | 1145 | } |
1146 | 1146 | if (gettype($url) != 'string') { |
1147 | 1147 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | phpCAS :: traceBegin(); |
1163 | 1163 | if (!is_object($PHPCAS_CLIENT)) { |
1164 | 1164 | phpCAS :: error('this method should only be called after |
1165 | - ' . __CLASS__ . '::client()'); |
|
1165 | + ' . __CLASS__.'::client()'); |
|
1166 | 1166 | } |
1167 | 1167 | if (gettype($url) != 'string') { |
1168 | 1168 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1183,7 +1183,7 @@ discard block |
||
1183 | 1183 | phpCAS :: traceBegin(); |
1184 | 1184 | if (!is_object($PHPCAS_CLIENT)) { |
1185 | 1185 | phpCAS :: error('this method should only be called after |
1186 | - ' . __CLASS__ . '::client()'); |
|
1186 | + ' . __CLASS__.'::client()'); |
|
1187 | 1187 | } |
1188 | 1188 | if (gettype($url) != 'string') { |
1189 | 1189 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | phpCAS :: traceBegin(); |
1204 | 1204 | if (!is_object($PHPCAS_CLIENT)) { |
1205 | 1205 | phpCAS :: error('this method should only be called after |
1206 | - ' . __CLASS__ . '::client()'); |
|
1206 | + ' . __CLASS__.'::client()'); |
|
1207 | 1207 | } |
1208 | 1208 | if (gettype($url) != 'string') { |
1209 | 1209 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | function getServerLogoutURL() { |
1223 | 1223 | global $PHPCAS_CLIENT; |
1224 | 1224 | if (!is_object($PHPCAS_CLIENT)) { |
1225 | - phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()'); |
|
1225 | + phpCAS :: error('this method should not be called before '.__CLASS__.'::client() or '.__CLASS__.'::proxy()'); |
|
1226 | 1226 | } |
1227 | 1227 | return $PHPCAS_CLIENT->getServerLogoutURL(); |
1228 | 1228 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | phpCAS :: traceBegin(); |
1238 | 1238 | if (!is_object($PHPCAS_CLIENT)) { |
1239 | 1239 | phpCAS :: error('this method should only be called after |
1240 | - ' . __CLASS__ . '::client()'); |
|
1240 | + ' . __CLASS__.'::client()'); |
|
1241 | 1241 | } |
1242 | 1242 | if (gettype($url) != 'string') { |
1243 | 1243 | phpCAS :: error('type mismatched for parameter $url (should be |
@@ -1256,9 +1256,9 @@ discard block |
||
1256 | 1256 | global $PHPCAS_CLIENT; |
1257 | 1257 | phpCAS :: traceBegin(); |
1258 | 1258 | if (!is_object($PHPCAS_CLIENT)) { |
1259 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1259 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1260 | 1260 | } |
1261 | - $parsedParams = array (); |
|
1261 | + $parsedParams = array(); |
|
1262 | 1262 | if ($params != "") { |
1263 | 1263 | if (is_string($params)) { |
1264 | 1264 | phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead'); |
@@ -1286,12 +1286,12 @@ discard block |
||
1286 | 1286 | global $PHPCAS_CLIENT; |
1287 | 1287 | phpCAS :: traceBegin(); |
1288 | 1288 | if (!is_object($PHPCAS_CLIENT)) { |
1289 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1289 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1290 | 1290 | } |
1291 | 1291 | if (!is_string($service)) { |
1292 | 1292 | phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
1293 | 1293 | } |
1294 | - $PHPCAS_CLIENT->logout(array ( |
|
1294 | + $PHPCAS_CLIENT->logout(array( |
|
1295 | 1295 | "service" => $service |
1296 | 1296 | )); |
1297 | 1297 | // never reached |
@@ -1306,12 +1306,12 @@ discard block |
||
1306 | 1306 | global $PHPCAS_CLIENT; |
1307 | 1307 | phpCAS :: traceBegin(); |
1308 | 1308 | if (!is_object($PHPCAS_CLIENT)) { |
1309 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1309 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1310 | 1310 | } |
1311 | 1311 | if (!is_string($url)) { |
1312 | 1312 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
1313 | 1313 | } |
1314 | - $PHPCAS_CLIENT->logout(array ( |
|
1314 | + $PHPCAS_CLIENT->logout(array( |
|
1315 | 1315 | "url" => $url |
1316 | 1316 | )); |
1317 | 1317 | // never reached |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | global $PHPCAS_CLIENT; |
1328 | 1328 | phpCAS :: traceBegin(); |
1329 | 1329 | if (!is_object($PHPCAS_CLIENT)) { |
1330 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1330 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1331 | 1331 | } |
1332 | 1332 | if (!is_string($service)) { |
1333 | 1333 | phpCAS :: error('type mismatched for parameter $service (should be `string\')'); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | if (!is_string($url)) { |
1336 | 1336 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
1337 | 1337 | } |
1338 | - $PHPCAS_CLIENT->logout(array ( |
|
1338 | + $PHPCAS_CLIENT->logout(array( |
|
1339 | 1339 | "service" => $service, |
1340 | 1340 | "url" => $url |
1341 | 1341 | )); |
@@ -1353,10 +1353,10 @@ discard block |
||
1353 | 1353 | global $PHPCAS_CLIENT; |
1354 | 1354 | phpCAS :: traceBegin(); |
1355 | 1355 | if (!is_object($PHPCAS_CLIENT)) { |
1356 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1356 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1357 | 1357 | } |
1358 | 1358 | if (!$PHPCAS_CLIENT->isProxy()) { |
1359 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1359 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1360 | 1360 | } |
1361 | 1361 | if (gettype($url) != 'string') { |
1362 | 1362 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | global $PHPCAS_CLIENT; |
1376 | 1376 | phpCAS :: traceBegin(); |
1377 | 1377 | if (!is_object($PHPCAS_CLIENT)) { |
1378 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1378 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1379 | 1379 | } |
1380 | 1380 | if (gettype($url) != 'string') { |
1381 | 1381 | phpCAS :: error('type mismatched for parameter $url (should be `string\')'); |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | function getServiceURL() { |
1391 | 1391 | global $PHPCAS_CLIENT; |
1392 | 1392 | if (!is_object($PHPCAS_CLIENT)) { |
1393 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1393 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1394 | 1394 | } |
1395 | 1395 | return ($PHPCAS_CLIENT->getURL()); |
1396 | 1396 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | function retrievePT($target_service, & $err_code, & $err_msg) { |
1402 | 1402 | global $PHPCAS_CLIENT; |
1403 | 1403 | if (!is_object($PHPCAS_CLIENT)) { |
1404 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()'); |
|
1404 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::proxy()'); |
|
1405 | 1405 | } |
1406 | 1406 | if (gettype($target_service) != 'string') { |
1407 | 1407 | phpCAS :: error('type mismatched for parameter $target_service(should be `string\')'); |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | global $PHPCAS_CLIENT; |
1419 | 1419 | phpCAS :: traceBegin(); |
1420 | 1420 | if (!is_object($PHPCAS_CLIENT)) { |
1421 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1421 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1422 | 1422 | } |
1423 | 1423 | if (gettype($cert) != 'string') { |
1424 | 1424 | phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | global $PHPCAS_CLIENT; |
1437 | 1437 | phpCAS :: traceBegin(); |
1438 | 1438 | if (!is_object($PHPCAS_CLIENT)) { |
1439 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1439 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1440 | 1440 | } |
1441 | 1441 | if (gettype($cert) != 'string') { |
1442 | 1442 | phpCAS :: error('type mismatched for parameter $cert (should be `string\')'); |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | global $PHPCAS_CLIENT; |
1453 | 1453 | phpCAS :: traceBegin(); |
1454 | 1454 | if (!is_object($PHPCAS_CLIENT)) { |
1455 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1455 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1456 | 1456 | } |
1457 | 1457 | $PHPCAS_CLIENT->setNoCasServerValidation(); |
1458 | 1458 | phpCAS :: traceEnd(); |
@@ -1470,7 +1470,7 @@ discard block |
||
1470 | 1470 | global $PHPCAS_CLIENT; |
1471 | 1471 | phpCAS :: traceBegin(); |
1472 | 1472 | if (!is_object($PHPCAS_CLIENT)) { |
1473 | - phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()'); |
|
1473 | + phpCAS :: error('this method should only be called after '.__CLASS__.'::client() or'.__CLASS__.'::proxy()'); |
|
1474 | 1474 | } |
1475 | 1475 | $PHPCAS_CLIENT->setExtraCurlOption($key, $value); |
1476 | 1476 | phpCAS :: traceEnd(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * Used by CASClient::PrintHTMLHeader() and CASClient::printHTMLFooter(). |
76 | 76 | * |
77 | - * @param $str the string to filter and output |
|
77 | + * @param string $str the string to filter and output |
|
78 | 78 | * |
79 | 79 | * @private |
80 | 80 | */ |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | /** |
188 | 188 | * This method returns the language used by phpCAS. |
189 | 189 | * |
190 | - * @return a string representing the language |
|
190 | + * @return string string representing the language |
|
191 | 191 | * |
192 | 192 | * @private |
193 | 193 | */ |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | /** |
213 | 213 | * This method returns a string depending on the language. |
214 | 214 | * |
215 | - * @param $str the index of the string in $_string. |
|
215 | + * @param integer $str the index of the string in $_string. |
|
216 | 216 | * |
217 | 217 | * @return the string corresponding to $index in $string. |
218 | 218 | * |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * This method is used to set the language used by phpCAS. |
234 | 234 | * @note Can be called only once. |
235 | 235 | * |
236 | - * @param $lang a string representing the language. |
|
236 | + * @param string $lang a string representing the language. |
|
237 | 237 | * |
238 | 238 | * @public |
239 | 239 | * @sa CAS_LANG_FRENCH, CAS_LANG_ENGLISH |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | /** |
422 | 422 | * This method is used to retrieve the service validating URL of the CAS server. |
423 | - * @return a URL. |
|
423 | + * @return string URL. |
|
424 | 424 | * @private |
425 | 425 | */ |
426 | 426 | function getServerServiceValidateURL() |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | } |
442 | 442 | /** |
443 | 443 | * This method is used to retrieve the SAML validating URL of the CAS server. |
444 | - * @return a URL. |
|
444 | + * @return string URL. |
|
445 | 445 | * @private |
446 | 446 | */ |
447 | 447 | function getServerSamlValidateURL() |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | } |
461 | 461 | /** |
462 | 462 | * This method is used to retrieve the proxy validating URL of the CAS server. |
463 | - * @return a URL. |
|
463 | + * @return string URL. |
|
464 | 464 | * @private |
465 | 465 | */ |
466 | 466 | function getServerProxyValidateURL() |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | |
542 | 542 | /** |
543 | 543 | * This method checks to see if the request is secured via HTTPS |
544 | - * @return true if https, false otherwise |
|
544 | + * @return boolean if https, false otherwise |
|
545 | 545 | * @private |
546 | 546 | */ |
547 | 547 | function isHttps() { |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * CASClient constructor. |
562 | 562 | * |
563 | 563 | * @param $server_version the version of the CAS server |
564 | - * @param $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise |
|
564 | + * @param boolean $proxy TRUE if the CAS client is a CAS proxy, FALSE otherwise |
|
565 | 565 | * @param $server_hostname the hostname of the CAS server |
566 | 566 | * @param $server_port the port the CAS server is running on |
567 | 567 | * @param $server_uri the URI the CAS server is responding on |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @warning should be called only after CASClient::forceAuthentication() or |
760 | 760 | * CASClient::isAuthenticated(), otherwise halt with an error. |
761 | 761 | * |
762 | - * @return the login name of the authenticated user |
|
762 | + * @return string login name of the authenticated user |
|
763 | 763 | */ |
764 | 764 | function getUser() |
765 | 765 | { |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | /** |
832 | 832 | * This method is called to be sure that the user is authenticated. When not |
833 | 833 | * authenticated, halt by redirecting to the CAS server; otherwise return TRUE. |
834 | - * @return TRUE when the user is authenticated; otherwise halt. |
|
834 | + * @return boolean when the user is authenticated; otherwise halt. |
|
835 | 835 | * @public |
836 | 836 | */ |
837 | 837 | function forceAuthentication() |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | |
878 | 878 | /** |
879 | 879 | * This method is called to check whether the user is authenticated or not. |
880 | - * @return TRUE when the user is authenticated, FALSE otherwise. |
|
880 | + * @return boolean when the user is authenticated, FALSE otherwise. |
|
881 | 881 | * @public |
882 | 882 | */ |
883 | 883 | function checkAuthentication() |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * This method is called to check if the user is authenticated (previously or by |
934 | 934 | * tickets given in the URL). |
935 | 935 | * |
936 | - * @return TRUE when the user is authenticated. Also may redirect to the same URL without the ticket. |
|
936 | + * @return boolean when the user is authenticated. Also may redirect to the same URL without the ticket. |
|
937 | 937 | * |
938 | 938 | * @public |
939 | 939 | */ |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | |
1004 | 1004 | /** |
1005 | 1005 | * This method tells if the current session is authenticated. |
1006 | - * @return true if authenticated based soley on $_SESSION variable |
|
1006 | + * @return boolean if authenticated based soley on $_SESSION variable |
|
1007 | 1007 | * @since 0.4.22 by Brendan Arnold |
1008 | 1008 | */ |
1009 | 1009 | function isSessionAuthenticated () |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @note This function switches to callback mode when needed. |
1019 | 1019 | * |
1020 | - * @return TRUE when the user has already been authenticated; FALSE otherwise. |
|
1020 | + * @return boolean when the user has already been authenticated; FALSE otherwise. |
|
1021 | 1021 | * |
1022 | 1022 | * @private |
1023 | 1023 | */ |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
1132 | - * @return true if the current request is a logout request. |
|
1132 | + * @return boolean if the current request is a logout request. |
|
1133 | 1133 | * @private |
1134 | 1134 | */ |
1135 | 1135 | function isLogoutRequest() { |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | /** |
1243 | 1243 | * This method returns the Service Ticket provided in the URL of the request. |
1244 | - * @return The service ticket. |
|
1244 | + * @return string service ticket. |
|
1245 | 1245 | * @private |
1246 | 1246 | */ |
1247 | 1247 | function getST() |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | |
1258 | 1258 | /** |
1259 | 1259 | * This method tells if a Service Ticket was stored. |
1260 | - * @return TRUE if a Service Ticket has been stored. |
|
1260 | + * @return boolean if a Service Ticket has been stored. |
|
1261 | 1261 | * @private |
1262 | 1262 | */ |
1263 | 1263 | function hasST() |
@@ -1330,7 +1330,7 @@ discard block |
||
1330 | 1330 | * $text_reponse and $tree_response on success. These parameters are used later |
1331 | 1331 | * by CASClient::validatePGT() for CAS proxies. |
1332 | 1332 | * Used for all CAS 1.0 validations |
1333 | - * @param $validate_url the URL of the request to the CAS server. |
|
1333 | + * @param string $validate_url the URL of the request to the CAS server. |
|
1334 | 1334 | * @param $text_response the response of the CAS server, as is (XML text). |
1335 | 1335 | * @param $tree_response the response of the CAS server, as a DOM XML tree. |
1336 | 1336 | * |
@@ -1460,7 +1460,7 @@ discard block |
||
1460 | 1460 | * $text_reponse and $tree_response on success. These parameters are used later |
1461 | 1461 | * by CASClient::validatePGT() for CAS proxies. |
1462 | 1462 | * |
1463 | - * @param $validate_url the URL of the request to the CAS server. |
|
1463 | + * @param string $validate_url the URL of the request to the CAS server. |
|
1464 | 1464 | * @param $text_response the response of the CAS server, as is (XML text). |
1465 | 1465 | * @param $tree_response the response of the CAS server, as a DOM XML tree. |
1466 | 1466 | * |
@@ -1648,7 +1648,7 @@ discard block |
||
1648 | 1648 | |
1649 | 1649 | /** |
1650 | 1650 | * This method returns the Proxy Granting Ticket given by the CAS server. |
1651 | - * @return The Proxy Granting Ticket. |
|
1651 | + * @return string Proxy Granting Ticket. |
|
1652 | 1652 | * @private |
1653 | 1653 | */ |
1654 | 1654 | function getPGT() |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | |
1665 | 1665 | /** |
1666 | 1666 | * This method tells if a Proxy Granting Ticket was stored. |
1667 | - * @return TRUE if a Proxy Granting Ticket has been stored. |
|
1667 | + * @return boolean if a Proxy Granting Ticket has been stored. |
|
1668 | 1668 | * @private |
1669 | 1669 | */ |
1670 | 1670 | function hasPGT() |
@@ -1697,7 +1697,7 @@ discard block |
||
1697 | 1697 | /** |
1698 | 1698 | * This method sets/unsets callback mode. |
1699 | 1699 | * |
1700 | - * @param $callback_mode TRUE to set callback mode, FALSE otherwise. |
|
1700 | + * @param boolean $callback_mode TRUE to set callback mode, FALSE otherwise. |
|
1701 | 1701 | * |
1702 | 1702 | * @private |
1703 | 1703 | */ |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | * This method returns TRUE when the CAs client is running i callback mode, |
1711 | 1711 | * FALSE otherwise. |
1712 | 1712 | * |
1713 | - * @return A boolean. |
|
1713 | + * @return boolean boolean. |
|
1714 | 1714 | * |
1715 | 1715 | * @private |
1716 | 1716 | */ |
@@ -1734,7 +1734,7 @@ discard block |
||
1734 | 1734 | * fact the URL of the current request without any CGI parameter, except if |
1735 | 1735 | * phpCAS::setFixedCallbackURL() was used). |
1736 | 1736 | * |
1737 | - * @return The callback URL |
|
1737 | + * @return string callback URL |
|
1738 | 1738 | * |
1739 | 1739 | * @private |
1740 | 1740 | */ |
@@ -1777,6 +1777,7 @@ discard block |
||
1777 | 1777 | * This method sets the callback url. |
1778 | 1778 | * |
1779 | 1779 | * @param $callback_url url to set callback |
1780 | + * @param string $url |
|
1780 | 1781 | * |
1781 | 1782 | * @private |
1782 | 1783 | */ |
@@ -1861,7 +1862,7 @@ discard block |
||
1861 | 1862 | /** |
1862 | 1863 | * This method reads a PGT from its Iou and deletes the corresponding storage entry. |
1863 | 1864 | * |
1864 | - * @param $pgt_iou the PGT Iou |
|
1865 | + * @param string $pgt_iou the PGT Iou |
|
1865 | 1866 | * |
1866 | 1867 | * @return The PGT corresponding to the Iou, FALSE when not found. |
1867 | 1868 | * |
@@ -1991,7 +1992,7 @@ discard block |
||
1991 | 1992 | * @param $err_code an error code (PHPCAS_SERVICE_OK on success). |
1992 | 1993 | * @param $err_msg an error message (empty on success). |
1993 | 1994 | * |
1994 | - * @return a Proxy Ticket, or FALSE on error. |
|
1995 | + * @return false|string Proxy Ticket, or FALSE on error. |
|
1995 | 1996 | * |
1996 | 1997 | * @private |
1997 | 1998 | */ |
@@ -2093,14 +2094,14 @@ discard block |
||
2093 | 2094 | /** |
2094 | 2095 | * This method is used to acces a remote URL. |
2095 | 2096 | * |
2096 | - * @param $url the URL to access. |
|
2097 | + * @param string $url the URL to access. |
|
2097 | 2098 | * @param $cookies an array containing cookies strings such as 'name=val' |
2098 | 2099 | * @param $headers an array containing the HTTP header lines of the response |
2099 | 2100 | * (an empty array on failure). |
2100 | 2101 | * @param $body the body of the response, as a string (empty on failure). |
2101 | 2102 | * @param $err_msg an error message, filled on failure. |
2102 | 2103 | * |
2103 | - * @return TRUE on success, FALSE otherwise (in this later case, $err_msg |
|
2104 | + * @return boolean on success, FALSE otherwise (in this later case, $err_msg |
|
2104 | 2105 | * contains an error message). |
2105 | 2106 | * |
2106 | 2107 | * @private |
@@ -2197,7 +2198,7 @@ discard block |
||
2197 | 2198 | /** |
2198 | 2199 | * This method is used to build the SAML POST body sent to /samlValidate URL. |
2199 | 2200 | * |
2200 | - * @return the SOAP-encased SAMLP artifact (the ticket). |
|
2201 | + * @return string SOAP-encased SAMLP artifact (the ticket). |
|
2201 | 2202 | * |
2202 | 2203 | * @private |
2203 | 2204 | */ |
@@ -2235,7 +2236,7 @@ discard block |
||
2235 | 2236 | * @param $output the output of the service (also used to give an error |
2236 | 2237 | * message on failure). |
2237 | 2238 | * |
2238 | - * @return TRUE on success, FALSE otherwise (in this later case, $err_code |
|
2239 | + * @return boolean on success, FALSE otherwise (in this later case, $err_code |
|
2239 | 2240 | * gives the reason why it failed and $output contains an error message). |
2240 | 2241 | * |
2241 | 2242 | * @public |
@@ -2382,7 +2383,7 @@ discard block |
||
2382 | 2383 | |
2383 | 2384 | /** |
2384 | 2385 | * This method returns the Proxy Ticket provided in the URL of the request. |
2385 | - * @return The proxy ticket. |
|
2386 | + * @return string proxy ticket. |
|
2386 | 2387 | * @private |
2387 | 2388 | */ |
2388 | 2389 | function getPT() |
@@ -2401,14 +2402,14 @@ discard block |
||
2401 | 2402 | |
2402 | 2403 | /** |
2403 | 2404 | * This method tells if a Proxy Ticket was stored. |
2404 | - * @return TRUE if a Proxy Ticket has been stored. |
|
2405 | + * @return boolean if a Proxy Ticket has been stored. |
|
2405 | 2406 | * @private |
2406 | 2407 | */ |
2407 | 2408 | function hasPT() |
2408 | 2409 | { return !empty($this->_pt); } |
2409 | 2410 | /** |
2410 | 2411 | * This method returns the SAML Ticket provided in the URL of the request. |
2411 | - * @return The SAML ticket. |
|
2412 | + * @return string SAML ticket. |
|
2412 | 2413 | * @private |
2413 | 2414 | */ |
2414 | 2415 | function getSA() |
@@ -2424,7 +2425,7 @@ discard block |
||
2424 | 2425 | |
2425 | 2426 | /** |
2426 | 2427 | * This method tells if a SAML Ticket was stored. |
2427 | - * @return TRUE if a SAML Ticket has been stored. |
|
2428 | + * @return boolean if a SAML Ticket has been stored. |
|
2428 | 2429 | * @private |
2429 | 2430 | */ |
2430 | 2431 | function hasSA() |
@@ -2442,6 +2443,7 @@ discard block |
||
2442 | 2443 | /** |
2443 | 2444 | * This method is used to validate a ST or PT; halt on failure |
2444 | 2445 | * Used for all CAS 2.0 validations |
2446 | + * @param string $validate_url |
|
2445 | 2447 | * @return bool TRUE when successfull, halt otherwise by calling CASClient::authError(). |
2446 | 2448 | * |
2447 | 2449 | * @private |
@@ -2556,7 +2558,7 @@ discard block |
||
2556 | 2558 | * This method returns the URL of the current request (without any ticket |
2557 | 2559 | * CGI parameter). |
2558 | 2560 | * |
2559 | - * @return The URL |
|
2561 | + * @return string URL |
|
2560 | 2562 | * |
2561 | 2563 | * @private |
2562 | 2564 | */ |
@@ -2634,7 +2636,7 @@ discard block |
||
2634 | 2636 | /** |
2635 | 2637 | * This method sets the URL of the current request |
2636 | 2638 | * |
2637 | - * @param $url url to set for service |
|
2639 | + * @param string $url url to set for service |
|
2638 | 2640 | * |
2639 | 2641 | * @private |
2640 | 2642 | */ |
@@ -2649,9 +2651,9 @@ discard block |
||
2649 | 2651 | /** |
2650 | 2652 | * This method is used to print the HTML output when the user was not authenticated. |
2651 | 2653 | * |
2652 | - * @param $failure the failure that occured |
|
2654 | + * @param string $failure the failure that occured |
|
2653 | 2655 | * @param $cas_url the URL the CAS server was asked for |
2654 | - * @param $no_response the response from the CAS server (other |
|
2656 | + * @param boolean $no_response the response from the CAS server (other |
|
2655 | 2657 | * parameters are ignored if TRUE) |
2656 | 2658 | * @param $bad_response bad response from the CAS server ($err_code |
2657 | 2659 | * and $err_msg ignored if TRUE) |
@@ -80,9 +80,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |