@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $content = '<li class="help">'; |
265 | 265 | $content .= Display::url( |
266 | 266 | Display::return_icon('help.large.png', get_lang('Help')), |
267 | - api_get_path(WEB_CODE_PATH) . 'help/help.php?open=' . $help, |
|
267 | + api_get_path(WEB_CODE_PATH).'help/help.php?open='.$help, |
|
268 | 268 | [ |
269 | 269 | 'class' => 'ajax', |
270 | 270 | 'data-title' => get_lang('Help') |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | 'web_course' => api_get_path(WEB_COURSE_PATH), |
479 | 479 | 'web_main' => api_get_path(WEB_CODE_PATH), |
480 | 480 | 'web_css' => api_get_path(WEB_CSS_PATH), |
481 | - 'web_css_theme' => api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/', |
|
481 | + 'web_css_theme' => api_get_path(WEB_CSS_PATH).'themes/'.$this->theme.'/', |
|
482 | 482 | 'web_ajax' => api_get_path(WEB_AJAX_PATH), |
483 | 483 | 'web_img' => api_get_path(WEB_IMG_PATH), |
484 | 484 | 'web_plugin' => api_get_path(WEB_PLUGIN_PATH), |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | foreach ($bowerCSSFiles as $file) { |
537 | 537 | $css[] = api_get_path(WEB_PATH).'web/assets/'.$file; |
538 | 538 | } |
539 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
540 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css'; |
|
541 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css'; |
|
539 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/bootstrap-select/css/bootstrap-select.min.css'; |
|
540 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css'; |
|
541 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css'; |
|
542 | 542 | |
543 | 543 | if (api_is_global_chat_enabled()) { |
544 | - $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css'; |
|
544 | + $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chat/css/chat.css'; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | //THEME CSS STYLE |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | |
609 | 609 | $style_print = ''; |
610 | 610 | if (is_readable(api_get_path(SYS_CSS_PATH).$this->theme.'/print.css')) { |
611 | - $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH) . $this->theme . '/print.css'), |
|
611 | + $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/print.css'), |
|
612 | 612 | 'print'); |
613 | 613 | } |
614 | 614 | $this->assign('css_style_print', $style_print); |
@@ -631,10 +631,10 @@ discard block |
||
631 | 631 | |
632 | 632 | $isoCode = api_get_language_isocode(); |
633 | 633 | |
634 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_' . strtoupper($isoCode) . '.min.js'; |
|
634 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_'.strtoupper($isoCode).'.min.js'; |
|
635 | 635 | |
636 | 636 | if ($isoCode == 'en') { |
637 | - $selectLink = 'bootstrap-select/js/i18n/defaults-' . $isoCode . '_US.min.js'; |
|
637 | + $selectLink = 'bootstrap-select/js/i18n/defaults-'.$isoCode.'_US.min.js'; |
|
638 | 638 | } |
639 | 639 | // JS files |
640 | 640 | $js_files = array( |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | if ($isoCode != 'en') { |
687 | - $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-' . $isoCode . '.js'; |
|
688 | - $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-' . $isoCode . '.min.js'; |
|
687 | + $bowerJsFiles[] = 'jqueryui-timepicker-addon/dist/i18n/jquery-ui-timepicker-'.$isoCode.'.js'; |
|
688 | + $bowerJsFiles[] = 'jquery-ui/ui/minified/i18n/datepicker-'.$isoCode.'.min.js'; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | foreach ($bowerJsFiles as $file) { |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | } |
767 | 767 | |
768 | 768 | $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); |
769 | - $this->assign('offline_button',Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
769 | + $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); |
|
770 | 770 | |
771 | 771 | // Get language iso-code for this page - ignore errors |
772 | 772 | $this->assign('document_language', api_get_language_isocode()); |
@@ -825,15 +825,15 @@ discard block |
||
825 | 825 | $this->assign('section_name', 'section-'.$this_section); |
826 | 826 | |
827 | 827 | //Defaul root chamilo favicon |
828 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; |
|
828 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; |
|
829 | 829 | |
830 | 830 | //Added to verify if in the current Chamilo Theme exist a favicon |
831 | - $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; |
|
831 | + $favicoThemeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$this->theme.'/images/'; |
|
832 | 832 | |
833 | 833 | //If exist pick the current chamilo theme favicon |
834 | - if (is_file($favicoThemeUrl . 'favicon.ico')) { |
|
835 | - $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) |
|
836 | - . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; |
|
834 | + if (is_file($favicoThemeUrl.'favicon.ico')) { |
|
835 | + $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_CSS_PATH) |
|
836 | + . 'themes/'.$this->theme.'/images/favicon.ico" type="image/x-icon" />'; |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | if (api_is_multiple_url_enabled()) { |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { |
864 | 864 | $bug_notification_link = '<li class="report"> |
865 | 865 | <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> |
866 | - '. $iconBug . ' |
|
866 | + '. $iconBug.' |
|
867 | 867 | </a> |
868 | 868 | </li>'; |
869 | 869 | } |
@@ -975,26 +975,26 @@ discard block |
||
975 | 975 | $socialMeta = ''; |
976 | 976 | $metaTitle = api_get_setting('meta_title'); |
977 | 977 | if (!empty($metaTitle)) { |
978 | - $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; |
|
979 | - $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; |
|
980 | - $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; |
|
978 | + $socialMeta .= '<meta name="twitter:card" content="summary" />'."\n"; |
|
979 | + $socialMeta .= '<meta property="og:title" content="'.$metaTitle.'" />'."\n"; |
|
980 | + $socialMeta .= '<meta property="og:url" content="'.api_get_path(WEB_PATH).'" />'."\n"; |
|
981 | 981 | $metaDescription = api_get_setting('meta_description'); |
982 | 982 | if (!empty($metaDescription)) { |
983 | - $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; |
|
983 | + $socialMeta .= '<meta property="og:description" content="'.$metaDescription.'" />'."\n"; |
|
984 | 984 | } |
985 | 985 | $metaSite = api_get_setting('meta_twitter_site'); |
986 | 986 | if (!empty($metaSite)) { |
987 | - $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; |
|
987 | + $socialMeta .= '<meta name="twitter:site" content="'.$metaSite.'" />'."\n"; |
|
988 | 988 | $metaCreator = api_get_setting('meta_twitter_creator'); |
989 | 989 | if (!empty($metaCreator)) { |
990 | - $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; |
|
990 | + $socialMeta .= '<meta name="twitter:creator" content="'.$metaCreator.'" />'."\n"; |
|
991 | 991 | } |
992 | 992 | } |
993 | 993 | $metaImage = api_get_setting('meta_image_path'); |
994 | 994 | if (!empty($metaImage)) { |
995 | - if (is_file(api_get_path(SYS_PATH) . $metaImage)) { |
|
996 | - $path = api_get_path(WEB_PATH) . $metaImage; |
|
997 | - $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; |
|
995 | + if (is_file(api_get_path(SYS_PATH).$metaImage)) { |
|
996 | + $path = api_get_path(WEB_PATH).$metaImage; |
|
997 | + $socialMeta .= '<meta property="og:image" content="'.$path.'" />'."\n"; |
|
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | } |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | // Tutor name |
1028 | 1028 | if (api_get_setting('show_tutor_data') == 'true') { |
1029 | 1029 | // Course manager |
1030 | - $courseId = api_get_course_int_id(); |
|
1030 | + $courseId = api_get_course_int_id(); |
|
1031 | 1031 | $id_session = api_get_session_id(); |
1032 | 1032 | if (!empty($courseId)) { |
1033 | 1033 | $tutor_data = ''; |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | $courseId = api_get_course_int_id(); |
1060 | 1060 | if (!empty($courseId)) { |
1061 | 1061 | $teacher_data = ''; |
1062 | - $mail= CourseManager::get_emails_of_tutors_to_course($courseId); |
|
1062 | + $mail = CourseManager::get_emails_of_tutors_to_course($courseId); |
|
1063 | 1063 | if (!empty($mail)) { |
1064 | 1064 | $teachers_parsed = array(); |
1065 | 1065 | foreach ($mail as $value) { |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | 'sessionVar' => basename(__FILE__, '.php'), |
1294 | 1294 | 'imageOptions' => array( |
1295 | 1295 | 'font_size' => 20, |
1296 | - 'font_path' => api_get_path(SYS_FONTS_PATH) . 'opensans/', |
|
1296 | + 'font_path' => api_get_path(SYS_FONTS_PATH).'opensans/', |
|
1297 | 1297 | 'font_file' => 'OpenSans-Regular.ttf', |
1298 | 1298 | //'output' => 'gif' |
1299 | 1299 | ) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | const STATUS_OK = 1; |
17 | 17 | const STATUS_WARNING = 2; |
18 | - const STATUS_ERROR = 3; |
|
18 | + const STATUS_ERROR = 3; |
|
19 | 19 | const STATUS_INFORMATION = 4; |
20 | 20 | |
21 | 21 | /** |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | $html .= '<li>'; |
45 | 45 | } |
46 | 46 | $params['section'] = $section; |
47 | - $html .='<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
47 | + $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $html .= '</ul><div class="tab-pane">'; |
51 | 51 | |
52 | - $data = call_user_func(array($this, 'get_' . $current_section . '_data')); |
|
52 | + $data = call_user_func(array($this, 'get_'.$current_section.'_data')); |
|
53 | 53 | echo $html; |
54 | 54 | $table = new SortableTableFromArray($data, 1, 100); |
55 | 55 | |
56 | - $table->set_header(0,'', false); |
|
57 | - $table->set_header(1,get_lang('Section'), false); |
|
58 | - $table->set_header(2,get_lang('Setting'), false); |
|
59 | - $table->set_header(3,get_lang('Current'), false); |
|
60 | - $table->set_header(4,get_lang('Expected'), false); |
|
61 | - $table->set_header(5,get_lang('Comment'), false); |
|
56 | + $table->set_header(0, '', false); |
|
57 | + $table->set_header(1, get_lang('Section'), false); |
|
58 | + $table->set_header(2, get_lang('Setting'), false); |
|
59 | + $table->set_header(3, get_lang('Current'), false); |
|
60 | + $table->set_header(4, get_lang('Expected'), false); |
|
61 | + $table->set_header(5, get_lang('Comment'), false); |
|
62 | 62 | |
63 | 63 | $table->display(); |
64 | 64 | echo '</div></div>'; |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | { |
73 | 73 | $array = array(); |
74 | 74 | $writable_folders = array( |
75 | - api_get_path(SYS_APP_PATH) .'cache', |
|
75 | + api_get_path(SYS_APP_PATH).'cache', |
|
76 | 76 | api_get_path(SYS_COURSE_PATH), |
77 | - api_get_path(SYS_APP_PATH) .'home', |
|
78 | - api_get_path(SYS_APP_PATH) .'upload/users/', |
|
79 | - api_get_path(SYS_PATH) .'main/default_course_document/images/', |
|
77 | + api_get_path(SYS_APP_PATH).'home', |
|
78 | + api_get_path(SYS_APP_PATH).'upload/users/', |
|
79 | + api_get_path(SYS_PATH).'main/default_course_document/images/', |
|
80 | 80 | ); |
81 | 81 | foreach ($writable_folders as $index => $folder) { |
82 | 82 | $writable = is_writable($folder); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | $exists = file_exists(api_get_path(SYS_CODE_PATH).'install'); |
97 | 97 | $status = $exists ? self :: STATUS_WARNING : self :: STATUS_OK; |
98 | - $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
98 | + $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists').': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
99 | 99 | |
100 | 100 | $app_version = api_get_setting('chamilo_database_version'); |
101 | - $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
101 | + $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
102 | 102 | |
103 | 103 | return $array; |
104 | 104 | } |
@@ -165,33 +165,33 @@ discard block |
||
165 | 165 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
166 | 166 | |
167 | 167 | $setting = ini_get('max_execution_time'); |
168 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
168 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
169 | 169 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
170 | 170 | $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo')); |
171 | 171 | |
172 | 172 | $setting = ini_get('max_input_time'); |
173 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
173 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
174 | 174 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
175 | 175 | $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo')); |
176 | 176 | |
177 | 177 | $setting = ini_get('memory_limit'); |
178 | 178 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
179 | 179 | $status = self :: STATUS_ERROR; |
180 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
180 | + if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
181 | 181 | $status = self :: STATUS_OK; |
182 | 182 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
183 | 183 | |
184 | 184 | $setting = ini_get('post_max_size'); |
185 | 185 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
186 | 186 | $status = self :: STATUS_ERROR; |
187 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
187 | + if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
188 | 188 | $status = self :: STATUS_OK; |
189 | 189 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
190 | 190 | |
191 | 191 | $setting = ini_get('upload_max_filesize'); |
192 | 192 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
193 | 193 | $status = self :: STATUS_ERROR; |
194 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
194 | + if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
195 | 195 | $status = self :: STATUS_OK; |
196 | 196 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
197 | 197 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
206 | 206 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
207 | 207 | |
208 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
208 | + if (api_check_browscap()) {$setting = true; } else {$setting = false; } |
|
209 | 209 | $req_setting = true; |
210 | 210 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
211 | 211 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $loaded = extension_loaded($extension); |
263 | 263 | $status = $loaded ? self :: STATUS_OK : self :: STATUS_ERROR; |
264 | - $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension') . ': ' . $extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
264 | + $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $array; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | break; |
369 | 369 | } |
370 | 370 | |
371 | - if (! $img_path) { |
|
371 | + if (!$img_path) { |
|
372 | 372 | $img_path = api_get_path(WEB_IMG_PATH); |
373 | 373 | } |
374 | 374 | $image = Display::return_icon($img, $status); |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | $formatted_expected_value = $expected_value; |
380 | 380 | |
381 | 381 | if ($formatter) { |
382 | - if (method_exists($this, 'format_' . $formatter)) { |
|
383 | - $formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value); |
|
384 | - $formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value); |
|
382 | + if (method_exists($this, 'format_'.$formatter)) { |
|
383 | + $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value); |
|
384 | + $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function get_link($title, $url) |
398 | 398 | { |
399 | - return '<a href="' . $url . '" target="about:bank">' . $title . '</a>'; |
|
399 | + return '<a href="'.$url.'" target="about:bank">'.$title.'</a>'; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | public function format_yes_no_optional($value) |
403 | 403 | { |
404 | 404 | $return = ''; |
405 | - switch($value) { |
|
405 | + switch ($value) { |
|
406 | 406 | case 0: |
407 | 407 | $return = get_lang('No'); |
408 | 408 | break; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->skills = $skills; |
29 | 29 | $this->type = $type; |
30 | - $this->center_x = intval($offset_x + $this->canvas_x/2 - $this->block_size/2); |
|
30 | + $this->center_x = intval($offset_x + $this->canvas_x / 2 - $this->block_size / 2); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function prepare_skill_box($skill, $position, $class) |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | $extra_class = 'second_window'; |
40 | 40 | } |
41 | 41 | |
42 | - $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:' . $position['y'] . 'px; left:' . $position['x'] . 'px;">'; |
|
42 | + $this->html .= '<div id="block_'.$block_id.'" class = "open_block window '.$extra_class.' '.$class.'" style = "top:'.$position['y'].'px; left:'.$position['x'].'px;">'; |
|
43 | 43 | |
44 | - $content = $skill['name']; |
|
44 | + $content = $skill['name']; |
|
45 | 45 | $content .= '<div class="btn-group">'; |
46 | 46 | $content .= Display::url(get_lang('Edit'), '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
47 | 47 | $content .= Display::url('+', '#', array('id'=>'edit_block_'.$block_id, 'class'=>'edit_block btn')); |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | } |
88 | 88 | //default_arrow_color |
89 | 89 | |
90 | - $this->js .= 'var e'.$block_id.' = prepare("block_' . $block_id.'", '.$end_point.');'."\n"; |
|
91 | - $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_' . $skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | - $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n";; |
|
90 | + $this->js .= 'var e'.$block_id.' = prepare("block_'.$block_id.'", '.$end_point.');'."\n"; |
|
91 | + $this->js .= 'var e'.$skill['parent_id'].' = prepare("block_'.$skill['parent_id'].'", '.$end_point.');'."\n"; |
|
92 | + $this->js .= 'jsPlumb.connect({source: e'.$block_id.', target:e'.$skill['parent_id'].'});'."\n"; ; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $brothers = array(); |
126 | 126 | |
127 | 127 | foreach ($this->skills as &$skill) { |
128 | - if (!in_array($skill['parent_id'], array(0,1))) { |
|
128 | + if (!in_array($skill['parent_id'], array(0, 1))) { |
|
129 | 129 | continue; |
130 | 130 | } |
131 | - $childs = isset($skill['children']) ? count($skill['children']) : 0 ; |
|
131 | + $childs = isset($skill['children']) ? count($skill['children']) : 0; |
|
132 | 132 | |
133 | 133 | //$x = round($this->offsetX * sin(deg2rad($corner * $count))); |
134 | 134 | //$y = round($this->offsetY * cos(deg2rad($corner * $count))); |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | if ($skill['parent_id'] == 0) { |
145 | 145 | //$x = 130*$childs/2; |
146 | 146 | //$x = $this->space_between_blocks_x*$childs/2; |
147 | - $x = $this->canvas_x/2 - $this->block_size/2; |
|
147 | + $x = $this->canvas_x / 2 - $this->block_size / 2; |
|
148 | 148 | } else { |
149 | 149 | $max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0; |
150 | - foreach($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
150 | + foreach ($this->skills[$skill['parent_id']]['children'] as $id => $sk) { |
|
151 | 151 | if ($skill['id'] == $sk['id']) { |
152 | 152 | break; |
153 | 153 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | } |
156 | 156 | $parent_x = isset($this->skills[$skill['parent_id']]['x']) ? $this->skills[$skill['parent_id']]['x'] : 0; |
157 | 157 | //$x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->space_between_blocks_x*$max/2) ; |
158 | - $x = $my_count*$this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x/2 ) ; |
|
158 | + $x = $my_count * $this->space_between_blocks_x + $parent_x + $this->block_size - ($this->canvas_x / 2); |
|
159 | 159 | } |
160 | 160 | |
161 | - $y = $skill['level']*$this->space_between_blocks_y; |
|
161 | + $y = $skill['level'] * $this->space_between_blocks_y; |
|
162 | 162 | |
163 | 163 | $skill['x'] = $x; |
164 | 164 | $skill['y'] = $y; |
165 | 165 | |
166 | 166 | //$skill['description'] = "{$brothers[$skill['parent_id']]} $x - $y"; |
167 | 167 | //$skill['name'] = $skill['name']." | $x = $my_count * 150 + $parent_x - (150* $max/2) - 10*$childs "; |
168 | - $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y +$y)); |
|
168 | + $this->add_item($skill, array('x' => $this->offset_x + $x, 'y' => $this->offset_y + $y)); |
|
169 | 169 | } |
170 | 170 | return $this->get_html(); |
171 | 171 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | break; |
210 | 210 | } |
211 | 211 | |
212 | - $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE . "_{$params['item_id']}.png"; |
|
212 | + $fileName = ExtraField::FIELD_TYPE_FILE_IMAGE."_{$params['item_id']}.png"; |
|
213 | 213 | |
214 | 214 | if (!file_exists($fileDir)) { |
215 | 215 | mkdir($fileDir, $dirPermissions, true); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | |
218 | 218 | if ($value['error'] == 0) { |
219 | 219 | $imageExtraField = new Image($value['tmp_name']); |
220 | - $imageExtraField->send_image($fileDir . $fileName, -1, 'png'); |
|
220 | + $imageExtraField->send_image($fileDir.$fileName, -1, 'png'); |
|
221 | 221 | $newParams = array( |
222 | 222 | 'item_id' => $params['item_id'], |
223 | 223 | 'field_id' => $extraFieldInfo['id'], |
224 | - 'value' => $fileDirStored . $fileName, |
|
224 | + 'value' => $fileDirStored.$fileName, |
|
225 | 225 | 'comment' => $comment |
226 | 226 | ); |
227 | 227 | |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | $cleanedName = api_replace_dangerous_char($value['name']); |
250 | - $fileName = ExtraField::FIELD_TYPE_FILE . "_{$params['item_id']}_$cleanedName"; |
|
250 | + $fileName = ExtraField::FIELD_TYPE_FILE."_{$params['item_id']}_$cleanedName"; |
|
251 | 251 | if (!file_exists($fileDir)) { |
252 | 252 | mkdir($fileDir, $dirPermissions, true); |
253 | 253 | } |
254 | 254 | |
255 | 255 | if ($value['error'] == 0) { |
256 | - moveUploadedFile($value, $fileDir . $fileName); |
|
256 | + moveUploadedFile($value, $fileDir.$fileName); |
|
257 | 257 | |
258 | 258 | $new_params = array( |
259 | 259 | 'item_id' => $params['item_id'], |
260 | 260 | 'field_id' => $extraFieldInfo['id'], |
261 | - 'value' => $fileDirStored . $fileName |
|
261 | + 'value' => $fileDirStored.$fileName |
|
262 | 262 | ); |
263 | 263 | |
264 | 264 | if ($this->type !== 'session' && $this->type !== 'course') { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | if (false) { |
382 | 382 | global $app; |
383 | - switch($this->type) { |
|
383 | + switch ($this->type) { |
|
384 | 384 | case 'question': |
385 | 385 | $extraFieldValue = new ChamiloLMS\Entity\QuestionFieldValues(); |
386 | 386 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | */ |
443 | 443 | if (false) { |
444 | 444 | global $app; |
445 | - switch($this->type) { |
|
445 | + switch ($this->type) { |
|
446 | 446 | case 'question': |
447 | 447 | $extraFieldValue = $app['orm.ems']['db_write']->getRepository('ChamiloLMS\Entity\QuestionFieldValues')->find($field_values['id']); |
448 | 448 | $extraFieldValue->setUserId(api_get_user_id()); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | foreach ($data as $row) { |
101 | 101 | $string = implode("</td><td>", $row); |
102 | - $string = '<tr><td>' . $string . '</td></tr>'; |
|
102 | + $string = '<tr><td>'.$string.'</td></tr>'; |
|
103 | 103 | if ($encoding != 'utf-8') { |
104 | 104 | $string = api_convert_encoding($string, $encoding, $systemEncoding); |
105 | 105 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | fwrite($handle, '<'.$wrapper_tagname.'>'); |
174 | 174 | } |
175 | 175 | $s = self::_export_complex_table_xml_helper($data); |
176 | - fwrite($handle,$s); |
|
176 | + fwrite($handle, $s); |
|
177 | 177 | if (!is_null($wrapper_tagname)) { |
178 | 178 | fwrite($handle, '</'.$wrapper_tagname.'>'."\n"); |
179 | 179 | } |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | } |
196 | 196 | $string = ''; |
197 | 197 | foreach ($data as $row) { |
198 | - $string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>'; |
|
198 | + $string .= "\n".str_repeat("\t", $level).'<'.$row['name'].'>'; |
|
199 | 199 | if (is_array($row['value'])) { |
200 | - $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
201 | - $string .= str_repeat("\t",$level).'</'.$row['name'].'>'; |
|
200 | + $string .= self::_export_complex_table_xml_helper($row['value'], $level + 1)."\n"; |
|
201 | + $string .= str_repeat("\t", $level).'</'.$row['name'].'>'; |
|
202 | 202 | } else { |
203 | 203 | $string .= $row['value']; |
204 | 204 | $string .= '</'.$row['name'].'>'; |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function __toString() |
347 | 347 | { |
348 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
349 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
350 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
348 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
349 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
350 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
351 | 351 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
352 | 352 | } |
353 | 353 | |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); |
586 | 586 | $this->setBrowser(self::BROWSER_IE); |
587 | 587 | $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
588 | - if(stripos($this->_agent, 'IEMobile') !== false) { |
|
588 | + if (stripos($this->_agent, 'IEMobile') !== false) { |
|
589 | 589 | $this->setBrowser(self::BROWSER_POCKET_IE); |
590 | 590 | $this->setMobile(true); |
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
594 | + else if (stripos($this->_agent, 'trident') !== false) { |
|
595 | 595 | $this->setBrowser(self::BROWSER_IE); |
596 | 596 | $result = explode('rv:', $this->_agent); |
597 | 597 | $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | protected function checkFacebookExternalHit() |
1014 | 1014 | { |
1015 | - if(stristr($this->_agent,'FacebookExternalHit')) |
|
1015 | + if (stristr($this->_agent, 'FacebookExternalHit')) |
|
1016 | 1016 | { |
1017 | 1017 | $this->setRobot(true); |
1018 | 1018 | $this->setFacebook(true); |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | */ |
1028 | 1028 | protected function checkForFacebookIos() |
1029 | 1029 | { |
1030 | - if(stristr($this->_agent,'FBIOS')) |
|
1030 | + if (stristr($this->_agent, 'FBIOS')) |
|
1031 | 1031 | { |
1032 | 1032 | $this->setFacebook(true); |
1033 | 1033 | return true; |
@@ -1041,10 +1041,10 @@ discard block |
||
1041 | 1041 | */ |
1042 | 1042 | protected function getSafariVersionOnIos() |
1043 | 1043 | { |
1044 | - $aresult = explode('/',stristr($this->_agent,'Version')); |
|
1045 | - if( isset($aresult[1]) ) |
|
1044 | + $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
1045 | + if (isset($aresult[1])) |
|
1046 | 1046 | { |
1047 | - $aversion = explode(' ',$aresult[1]); |
|
1047 | + $aversion = explode(' ', $aresult[1]); |
|
1048 | 1048 | $this->setVersion($aversion[0]); |
1049 | 1049 | return true; |
1050 | 1050 | } |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | protected function getChromeVersionOnIos() |
1059 | 1059 | { |
1060 | - $aresult = explode('/',stristr($this->_agent,'CriOS')); |
|
1061 | - if( isset($aresult[1]) ) |
|
1060 | + $aresult = explode('/', stristr($this->_agent, 'CriOS')); |
|
1061 | + if (isset($aresult[1])) |
|
1062 | 1062 | { |
1063 | - $aversion = explode(' ',$aresult[1]); |
|
1063 | + $aversion = explode(' ', $aresult[1]); |
|
1064 | 1064 | $this->setVersion($aversion[0]); |
1065 | 1065 | $this->setBrowser(self::BROWSER_CHROME); |
1066 | 1066 | return true; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @return boolean True if the browser is iPhone otherwise false |
1074 | 1074 | */ |
1075 | 1075 | protected function checkBrowseriPhone() { |
1076 | - if( stripos($this->_agent,'iPhone') !== false ) { |
|
1076 | + if (stripos($this->_agent, 'iPhone') !== false) { |
|
1077 | 1077 | $this->setVersion(self::VERSION_UNKNOWN); |
1078 | 1078 | $this->setBrowser(self::BROWSER_IPHONE); |
1079 | 1079 | $this->getSafariVersionOnIos(); |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | * @return boolean True if the browser is iPad otherwise false |
1091 | 1091 | */ |
1092 | 1092 | protected function checkBrowseriPad() { |
1093 | - if( stripos($this->_agent,'iPad') !== false ) { |
|
1093 | + if (stripos($this->_agent, 'iPad') !== false) { |
|
1094 | 1094 | $this->setVersion(self::VERSION_UNKNOWN); |
1095 | 1095 | $this->setBrowser(self::BROWSER_IPAD); |
1096 | 1096 | $this->getSafariVersionOnIos(); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | * @return boolean True if the browser is iPod otherwise false |
1108 | 1108 | */ |
1109 | 1109 | protected function checkBrowseriPod() { |
1110 | - if( stripos($this->_agent,'iPod') !== false ) { |
|
1110 | + if (stripos($this->_agent, 'iPod') !== false) { |
|
1111 | 1111 | $this->setVersion(self::VERSION_UNKNOWN); |
1112 | 1112 | $this->setBrowser(self::BROWSER_IPOD); |
1113 | 1113 | $this->getSafariVersionOnIos(); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $scoredisplay = ScoreDisplay :: instance(); |
168 | 168 | $scorecourse = $my_category[0]->calc_score($this->user_id); |
169 | - $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'); |
|
169 | + $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable'); |
|
170 | 170 | |
171 | 171 | // Prepare all necessary variables: |
172 | 172 | $organization_name = api_get_setting('Institution'); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $organization_name, $stud_fn.' '.$stud_ln, $my_category[0]->get_name(), |
181 | 181 | $scorecourse_display |
182 | 182 | ); |
183 | - $certif_text = str_replace("\\n","\n", $certif_text); |
|
183 | + $certif_text = str_replace("\\n", "\n", $certif_text); |
|
184 | 184 | |
185 | 185 | //If the gradebook is related to skills we added the skills to the user |
186 | 186 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | // Creating new name |
220 | 220 | $name = md5($this->user_id.$this->certificate_data['cat_id']).'.html'; |
221 | 221 | $my_path_certificate = $this->certification_user_path.$name; |
222 | - $path_certificate ='/'.$name; |
|
222 | + $path_certificate = '/'.$name; |
|
223 | 223 | |
224 | 224 | //Getting QR filename |
225 | 225 | $file_info = pathinfo($path_certificate); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR'), |
231 | 231 | $new_content_html['content'] |
232 | 232 | ); |
233 | - $my_new_content_html = mb_convert_encoding($my_new_content_html,'UTF-8', api_get_system_encoding()); |
|
233 | + $my_new_content_html = mb_convert_encoding($my_new_content_html, 'UTF-8', api_get_system_encoding()); |
|
234 | 234 | |
235 | 235 | $result = @file_put_contents($my_path_certificate, $my_new_content_html); |
236 | 236 | if ($result) { |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | $path_certificate |
274 | 274 | ) { |
275 | 275 | $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); |
276 | - if (!UserManager::is_user_certified($cat_id,$user_id)) { |
|
277 | - $sql='UPDATE '.$table_certificate.' SET path_certificate="'.Database::escape_string($path_certificate).'" |
|
276 | + if (!UserManager::is_user_certified($cat_id, $user_id)) { |
|
277 | + $sql = 'UPDATE '.$table_certificate.' SET path_certificate="'.Database::escape_string($path_certificate).'" |
|
278 | 278 | WHERE cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'" '; |
279 | 279 | Database::query($sql); |
280 | 280 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | if (!empty($content)) { |
332 | 332 | foreach ($content as $key => $value) { |
333 | - $my_header = str_replace(array('((', '))') , '', $headers[$key]); |
|
333 | + $my_header = str_replace(array('((', '))'), '', $headers[$key]); |
|
334 | 334 | $final_content[$my_header] = $value; |
335 | 335 | } |
336 | 336 | } |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | $final_content['gradebook_institution'].' - '. |
359 | 359 | $final_content['gradebook_sitename'].' - '. |
360 | 360 | get_lang('Certification').$break_space. |
361 | - get_lang('Student'). ': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space. |
|
362 | - get_lang('Teacher'). ': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space. |
|
363 | - get_lang('Date'). ': '.$final_content['date_certificate'].$break_space. |
|
364 | - get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space. |
|
365 | - 'URL'. ': '.$final_content['certificate_link']; |
|
361 | + get_lang('Student').': '.$final_content['user_firstname'].' '.$final_content['user_lastname'].$break_space. |
|
362 | + get_lang('Teacher').': '.$final_content['teacher_firstname'].' '.$final_content['teacher_lastname'].$break_space. |
|
363 | + get_lang('Date').': '.$final_content['date_certificate'].$break_space. |
|
364 | + get_lang('Score').': '.$final_content['gradebook_grade'].$break_space. |
|
365 | + 'URL'.': '.$final_content['certificate_link']; |
|
366 | 366 | |
367 | 367 | return $text; |
368 | 368 | } |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (!empty($this->certificate_data['path_certificate'])) { |
416 | 416 | $user_certificate = $this->certification_user_path.basename($this->certificate_data['path_certificate']); |
417 | 417 | if (file_exists($user_certificate)) { |
418 | - header('Content-Type: text/html; charset='. api_get_system_encoding()); |
|
418 | + header('Content-Type: text/html; charset='.api_get_system_encoding()); |
|
419 | 419 | echo @file_get_contents($user_certificate); |
420 | 420 | } |
421 | 421 | } else { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * Sets whether debugging is turned on |
64 | 64 | * @var bool |
65 | 65 | */ |
66 | - public $do_debug; // the level of debug to perform |
|
66 | + public $do_debug; // the level of debug to perform |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Sets VERP use on/off (default is off) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ///////////////////////////////////////////////// |
77 | 77 | |
78 | 78 | private $smtp_conn; // the socket to the server |
79 | - private $error; // error if any on the last call |
|
79 | + private $error; // error if any on the last call |
|
80 | 80 | private $helo_rply; // the reply the server sent to us for HELO |
81 | 81 | |
82 | 82 | /** |
@@ -114,43 +114,43 @@ discard block |
||
114 | 114 | $this->error = null; |
115 | 115 | |
116 | 116 | // make sure we are __not__ connected |
117 | - if($this->connected()) { |
|
117 | + if ($this->connected()) { |
|
118 | 118 | // already connected, generate error |
119 | 119 | $this->error = array("error" => "Already connected to a server"); |
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | |
123 | - if(empty($port)) { |
|
123 | + if (empty($port)) { |
|
124 | 124 | $port = $this->SMTP_PORT; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // connect to the smtp server |
128 | - $this->smtp_conn = @fsockopen($host, // the host of the server |
|
129 | - $port, // the port to use |
|
130 | - $errno, // error number if any |
|
131 | - $errstr, // error message if any |
|
132 | - $tval); // give up after ? secs |
|
128 | + $this->smtp_conn = @fsockopen($host, // the host of the server |
|
129 | + $port, // the port to use |
|
130 | + $errno, // error number if any |
|
131 | + $errstr, // error message if any |
|
132 | + $tval); // give up after ? secs |
|
133 | 133 | // verify we connected properly |
134 | - if(empty($this->smtp_conn)) { |
|
134 | + if (empty($this->smtp_conn)) { |
|
135 | 135 | $this->error = array("error" => "Failed to connect to server", |
136 | 136 | "errno" => $errno, |
137 | 137 | "errstr" => $errstr); |
138 | - if($this->do_debug >= 1) { |
|
139 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'; |
|
138 | + if ($this->do_debug >= 1) { |
|
139 | + echo "SMTP -> ERROR: ".$this->error["error"].": $errstr ($errno)".$this->CRLF.'<br />'; |
|
140 | 140 | } |
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | |
144 | 144 | // SMTP server can take longer to respond, give longer timeout for first read |
145 | 145 | // Windows does not have support for this timeout function |
146 | - if(substr(PHP_OS, 0, 3) != "WIN") |
|
146 | + if (substr(PHP_OS, 0, 3) != "WIN") |
|
147 | 147 | socket_set_timeout($this->smtp_conn, $tval, 0); |
148 | 148 | |
149 | 149 | // get any announcement |
150 | 150 | $announce = $this->get_lines(); |
151 | 151 | |
152 | - if($this->do_debug >= 2) { |
|
153 | - echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
152 | + if ($this->do_debug >= 2) { |
|
153 | + echo "SMTP -> FROM SERVER:".$announce.$this->CRLF.'<br />'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return true; |
@@ -168,33 +168,33 @@ discard block |
||
168 | 168 | public function StartTLS() { |
169 | 169 | $this->error = null; # to avoid confusion |
170 | 170 | |
171 | - if(!$this->connected()) { |
|
171 | + if (!$this->connected()) { |
|
172 | 172 | $this->error = array("error" => "Called StartTLS() without being connected"); |
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); |
|
176 | + fputs($this->smtp_conn, "STARTTLS".$this->CRLF); |
|
177 | 177 | |
178 | 178 | $rply = $this->get_lines(); |
179 | - $code = substr($rply,0,3); |
|
179 | + $code = substr($rply, 0, 3); |
|
180 | 180 | |
181 | - if($this->do_debug >= 2) { |
|
182 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
181 | + if ($this->do_debug >= 2) { |
|
182 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
183 | 183 | } |
184 | 184 | |
185 | - if($code != 220) { |
|
185 | + if ($code != 220) { |
|
186 | 186 | $this->error = |
187 | 187 | array("error" => "STARTTLS not accepted from server", |
188 | 188 | "smtp_code" => $code, |
189 | - "smtp_msg" => substr($rply,4)); |
|
190 | - if($this->do_debug >= 1) { |
|
191 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
189 | + "smtp_msg" => substr($rply, 4)); |
|
190 | + if ($this->do_debug >= 1) { |
|
191 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
192 | 192 | } |
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Begin encrypted connection |
197 | - if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
197 | + if (!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
@@ -209,52 +209,52 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function Authenticate($username, $password) { |
211 | 211 | // Start authentication |
212 | - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); |
|
212 | + fputs($this->smtp_conn, "AUTH LOGIN".$this->CRLF); |
|
213 | 213 | |
214 | 214 | $rply = $this->get_lines(); |
215 | - $code = substr($rply,0,3); |
|
215 | + $code = substr($rply, 0, 3); |
|
216 | 216 | |
217 | - if($code != 334) { |
|
217 | + if ($code != 334) { |
|
218 | 218 | $this->error = |
219 | 219 | array("error" => "AUTH not accepted from server", |
220 | 220 | "smtp_code" => $code, |
221 | - "smtp_msg" => substr($rply,4)); |
|
222 | - if($this->do_debug >= 1) { |
|
223 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
221 | + "smtp_msg" => substr($rply, 4)); |
|
222 | + if ($this->do_debug >= 1) { |
|
223 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
224 | 224 | } |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Send encoded username |
229 | - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); |
|
229 | + fputs($this->smtp_conn, base64_encode($username).$this->CRLF); |
|
230 | 230 | |
231 | 231 | $rply = $this->get_lines(); |
232 | - $code = substr($rply,0,3); |
|
232 | + $code = substr($rply, 0, 3); |
|
233 | 233 | |
234 | - if($code != 334) { |
|
234 | + if ($code != 334) { |
|
235 | 235 | $this->error = |
236 | 236 | array("error" => "Username not accepted from server", |
237 | 237 | "smtp_code" => $code, |
238 | - "smtp_msg" => substr($rply,4)); |
|
239 | - if($this->do_debug >= 1) { |
|
240 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
238 | + "smtp_msg" => substr($rply, 4)); |
|
239 | + if ($this->do_debug >= 1) { |
|
240 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
241 | 241 | } |
242 | 242 | return false; |
243 | 243 | } |
244 | 244 | |
245 | 245 | // Send encoded password |
246 | - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); |
|
246 | + fputs($this->smtp_conn, base64_encode($password).$this->CRLF); |
|
247 | 247 | |
248 | 248 | $rply = $this->get_lines(); |
249 | - $code = substr($rply,0,3); |
|
249 | + $code = substr($rply, 0, 3); |
|
250 | 250 | |
251 | - if($code != 235) { |
|
251 | + if ($code != 235) { |
|
252 | 252 | $this->error = |
253 | 253 | array("error" => "Password not accepted from server", |
254 | 254 | "smtp_code" => $code, |
255 | - "smtp_msg" => substr($rply,4)); |
|
256 | - if($this->do_debug >= 1) { |
|
257 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
255 | + "smtp_msg" => substr($rply, 4)); |
|
256 | + if ($this->do_debug >= 1) { |
|
257 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
258 | 258 | } |
259 | 259 | return false; |
260 | 260 | } |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * @return bool |
269 | 269 | */ |
270 | 270 | public function Connected() { |
271 | - if(!empty($this->smtp_conn)) { |
|
271 | + if (!empty($this->smtp_conn)) { |
|
272 | 272 | $sock_status = socket_get_status($this->smtp_conn); |
273 | - if($sock_status["eof"]) { |
|
273 | + if ($sock_status["eof"]) { |
|
274 | 274 | // the socket is valid but we are not connected |
275 | - if($this->do_debug >= 1) { |
|
276 | - echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; |
|
275 | + if ($this->do_debug >= 1) { |
|
276 | + echo "SMTP -> NOTICE:".$this->CRLF."EOF caught while checking if connected"; |
|
277 | 277 | } |
278 | 278 | $this->Close(); |
279 | 279 | return false; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | public function Close() { |
294 | 294 | $this->error = null; // so there is no confusion |
295 | 295 | $this->helo_rply = null; |
296 | - if(!empty($this->smtp_conn)) { |
|
296 | + if (!empty($this->smtp_conn)) { |
|
297 | 297 | // close the connection and cleanup |
298 | 298 | fclose($this->smtp_conn); |
299 | 299 | $this->smtp_conn = 0; |
@@ -326,28 +326,28 @@ discard block |
||
326 | 326 | public function Data($msg_data) { |
327 | 327 | $this->error = null; // so no confusion is caused |
328 | 328 | |
329 | - if(!$this->connected()) { |
|
329 | + if (!$this->connected()) { |
|
330 | 330 | $this->error = array( |
331 | 331 | "error" => "Called Data() without being connected"); |
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | |
335 | - fputs($this->smtp_conn,"DATA" . $this->CRLF); |
|
335 | + fputs($this->smtp_conn, "DATA".$this->CRLF); |
|
336 | 336 | |
337 | 337 | $rply = $this->get_lines(); |
338 | - $code = substr($rply,0,3); |
|
338 | + $code = substr($rply, 0, 3); |
|
339 | 339 | |
340 | - if($this->do_debug >= 2) { |
|
341 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
340 | + if ($this->do_debug >= 2) { |
|
341 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
342 | 342 | } |
343 | 343 | |
344 | - if($code != 354) { |
|
344 | + if ($code != 354) { |
|
345 | 345 | $this->error = |
346 | 346 | array("error" => "DATA command not accepted from server", |
347 | 347 | "smtp_code" => $code, |
348 | - "smtp_msg" => substr($rply,4)); |
|
349 | - if($this->do_debug >= 1) { |
|
350 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
348 | + "smtp_msg" => substr($rply, 4)); |
|
349 | + if ($this->do_debug >= 1) { |
|
350 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
351 | 351 | } |
352 | 352 | return false; |
353 | 353 | } |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | */ |
365 | 365 | |
366 | 366 | // normalize the line breaks so we know the explode works |
367 | - $msg_data = str_replace("\r\n","\n",$msg_data); |
|
368 | - $msg_data = str_replace("\r","\n",$msg_data); |
|
369 | - $lines = explode("\n",$msg_data); |
|
367 | + $msg_data = str_replace("\r\n", "\n", $msg_data); |
|
368 | + $msg_data = str_replace("\r", "\n", $msg_data); |
|
369 | + $lines = explode("\n", $msg_data); |
|
370 | 370 | |
371 | 371 | /* we need to find a good way to determine is headers are |
372 | 372 | * in the msg_data or if it is a straight msg body |
@@ -377,71 +377,71 @@ discard block |
||
377 | 377 | * headers. |
378 | 378 | */ |
379 | 379 | |
380 | - $field = substr($lines[0],0,strpos($lines[0],":")); |
|
380 | + $field = substr($lines[0], 0, strpos($lines[0], ":")); |
|
381 | 381 | $in_headers = false; |
382 | - if(!empty($field) && !strstr($field," ")) { |
|
382 | + if (!empty($field) && !strstr($field, " ")) { |
|
383 | 383 | $in_headers = true; |
384 | 384 | } |
385 | 385 | |
386 | 386 | $max_line_length = 998; // used below; set here for ease in change |
387 | 387 | |
388 | - while(list(,$line) = @each($lines)) { |
|
388 | + while (list(,$line) = @each($lines)) { |
|
389 | 389 | $lines_out = null; |
390 | - if($line == "" && $in_headers) { |
|
390 | + if ($line == "" && $in_headers) { |
|
391 | 391 | $in_headers = false; |
392 | 392 | } |
393 | 393 | // ok we need to break this line up into several smaller lines |
394 | - while(strlen($line) > $max_line_length) { |
|
395 | - $pos = strrpos(substr($line,0,$max_line_length)," "); |
|
394 | + while (strlen($line) > $max_line_length) { |
|
395 | + $pos = strrpos(substr($line, 0, $max_line_length), " "); |
|
396 | 396 | |
397 | 397 | // Patch to fix DOS attack |
398 | - if(!$pos) { |
|
398 | + if (!$pos) { |
|
399 | 399 | $pos = $max_line_length - 1; |
400 | - $lines_out[] = substr($line,0,$pos); |
|
401 | - $line = substr($line,$pos); |
|
400 | + $lines_out[] = substr($line, 0, $pos); |
|
401 | + $line = substr($line, $pos); |
|
402 | 402 | } else { |
403 | - $lines_out[] = substr($line,0,$pos); |
|
404 | - $line = substr($line,$pos + 1); |
|
403 | + $lines_out[] = substr($line, 0, $pos); |
|
404 | + $line = substr($line, $pos + 1); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /* if processing headers add a LWSP-char to the front of new line |
408 | 408 | * rfc 822 on long msg headers |
409 | 409 | */ |
410 | - if($in_headers) { |
|
411 | - $line = "\t" . $line; |
|
410 | + if ($in_headers) { |
|
411 | + $line = "\t".$line; |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | $lines_out[] = $line; |
415 | 415 | |
416 | 416 | // send the lines to the server |
417 | - while(list(,$line_out) = @each($lines_out)) { |
|
418 | - if(strlen($line_out) > 0) |
|
417 | + while (list(,$line_out) = @each($lines_out)) { |
|
418 | + if (strlen($line_out) > 0) |
|
419 | 419 | { |
420 | - if(substr($line_out, 0, 1) == ".") { |
|
421 | - $line_out = "." . $line_out; |
|
420 | + if (substr($line_out, 0, 1) == ".") { |
|
421 | + $line_out = ".".$line_out; |
|
422 | 422 | } |
423 | 423 | } |
424 | - fputs($this->smtp_conn,$line_out . $this->CRLF); |
|
424 | + fputs($this->smtp_conn, $line_out.$this->CRLF); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | // message data has been sent |
429 | - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); |
|
429 | + fputs($this->smtp_conn, $this->CRLF.".".$this->CRLF); |
|
430 | 430 | |
431 | 431 | $rply = $this->get_lines(); |
432 | - $code = substr($rply,0,3); |
|
432 | + $code = substr($rply, 0, 3); |
|
433 | 433 | |
434 | - if($this->do_debug >= 2) { |
|
435 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
434 | + if ($this->do_debug >= 2) { |
|
435 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
436 | 436 | } |
437 | 437 | |
438 | - if($code != 250) { |
|
438 | + if ($code != 250) { |
|
439 | 439 | $this->error = |
440 | 440 | array("error" => "DATA not accepted from server", |
441 | 441 | "smtp_code" => $code, |
442 | - "smtp_msg" => substr($rply,4)); |
|
443 | - if($this->do_debug >= 1) { |
|
444 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
442 | + "smtp_msg" => substr($rply, 4)); |
|
443 | + if ($this->do_debug >= 1) { |
|
444 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
445 | 445 | } |
446 | 446 | return false; |
447 | 447 | } |
@@ -463,21 +463,21 @@ discard block |
||
463 | 463 | public function Hello($host = '') { |
464 | 464 | $this->error = null; // so no confusion is caused |
465 | 465 | |
466 | - if(!$this->connected()) { |
|
466 | + if (!$this->connected()) { |
|
467 | 467 | $this->error = array( |
468 | 468 | "error" => "Called Hello() without being connected"); |
469 | 469 | return false; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // if hostname for HELO was not specified send default |
473 | - if(empty($host)) { |
|
473 | + if (empty($host)) { |
|
474 | 474 | // determine appropriate default to send to server |
475 | 475 | $host = "localhost"; |
476 | 476 | } |
477 | 477 | |
478 | 478 | // Send extended hello first (RFC 2821) |
479 | - if(!$this->SendHello("EHLO", $host)) { |
|
480 | - if(!$this->SendHello("HELO", $host)) { |
|
479 | + if (!$this->SendHello("EHLO", $host)) { |
|
480 | + if (!$this->SendHello("HELO", $host)) { |
|
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | } |
@@ -491,22 +491,22 @@ discard block |
||
491 | 491 | * @return bool |
492 | 492 | */ |
493 | 493 | private function SendHello($hello, $host) { |
494 | - fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); |
|
494 | + fputs($this->smtp_conn, $hello." ".$host.$this->CRLF); |
|
495 | 495 | |
496 | 496 | $rply = $this->get_lines(); |
497 | - $code = substr($rply,0,3); |
|
497 | + $code = substr($rply, 0, 3); |
|
498 | 498 | |
499 | - if($this->do_debug >= 2) { |
|
500 | - echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
499 | + if ($this->do_debug >= 2) { |
|
500 | + echo "SMTP -> FROM SERVER: ".$rply.$this->CRLF.'<br />'; |
|
501 | 501 | } |
502 | 502 | |
503 | - if($code != 250) { |
|
503 | + if ($code != 250) { |
|
504 | 504 | $this->error = |
505 | - array("error" => $hello . " not accepted from server", |
|
505 | + array("error" => $hello." not accepted from server", |
|
506 | 506 | "smtp_code" => $code, |
507 | - "smtp_msg" => substr($rply,4)); |
|
508 | - if($this->do_debug >= 1) { |
|
509 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
507 | + "smtp_msg" => substr($rply, 4)); |
|
508 | + if ($this->do_debug >= 1) { |
|
509 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
510 | 510 | } |
511 | 511 | return false; |
512 | 512 | } |
@@ -533,29 +533,29 @@ discard block |
||
533 | 533 | public function Mail($from) { |
534 | 534 | $this->error = null; // so no confusion is caused |
535 | 535 | |
536 | - if(!$this->connected()) { |
|
536 | + if (!$this->connected()) { |
|
537 | 537 | $this->error = array( |
538 | 538 | "error" => "Called Mail() without being connected"); |
539 | 539 | return false; |
540 | 540 | } |
541 | 541 | |
542 | 542 | $useVerp = ($this->do_verp ? "XVERP" : ""); |
543 | - fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); |
|
543 | + fputs($this->smtp_conn, "MAIL FROM:<".$from.">".$useVerp.$this->CRLF); |
|
544 | 544 | |
545 | 545 | $rply = $this->get_lines(); |
546 | - $code = substr($rply,0,3); |
|
546 | + $code = substr($rply, 0, 3); |
|
547 | 547 | |
548 | - if($this->do_debug >= 2) { |
|
549 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
548 | + if ($this->do_debug >= 2) { |
|
549 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
550 | 550 | } |
551 | 551 | |
552 | - if($code != 250) { |
|
552 | + if ($code != 250) { |
|
553 | 553 | $this->error = |
554 | 554 | array("error" => "MAIL not accepted from server", |
555 | 555 | "smtp_code" => $code, |
556 | - "smtp_msg" => substr($rply,4)); |
|
557 | - if($this->do_debug >= 1) { |
|
558 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
556 | + "smtp_msg" => substr($rply, 4)); |
|
557 | + if ($this->do_debug >= 1) { |
|
558 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
559 | 559 | } |
560 | 560 | return false; |
561 | 561 | } |
@@ -576,38 +576,38 @@ discard block |
||
576 | 576 | public function Quit($close_on_error = true) { |
577 | 577 | $this->error = null; // so there is no confusion |
578 | 578 | |
579 | - if(!$this->connected()) { |
|
579 | + if (!$this->connected()) { |
|
580 | 580 | $this->error = array( |
581 | 581 | "error" => "Called Quit() without being connected"); |
582 | 582 | return false; |
583 | 583 | } |
584 | 584 | |
585 | 585 | // send the quit command to the server |
586 | - fputs($this->smtp_conn,"quit" . $this->CRLF); |
|
586 | + fputs($this->smtp_conn, "quit".$this->CRLF); |
|
587 | 587 | |
588 | 588 | // get any good-bye messages |
589 | 589 | $byemsg = $this->get_lines(); |
590 | 590 | |
591 | - if($this->do_debug >= 2) { |
|
592 | - echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
591 | + if ($this->do_debug >= 2) { |
|
592 | + echo "SMTP -> FROM SERVER:".$byemsg.$this->CRLF.'<br />'; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | $rval = true; |
596 | 596 | $e = null; |
597 | 597 | |
598 | - $code = substr($byemsg,0,3); |
|
599 | - if($code != 221) { |
|
598 | + $code = substr($byemsg, 0, 3); |
|
599 | + if ($code != 221) { |
|
600 | 600 | // use e as a tmp var cause Close will overwrite $this->error |
601 | 601 | $e = array("error" => "SMTP server rejected quit command", |
602 | 602 | "smtp_code" => $code, |
603 | - "smtp_rply" => substr($byemsg,4)); |
|
603 | + "smtp_rply" => substr($byemsg, 4)); |
|
604 | 604 | $rval = false; |
605 | - if($this->do_debug >= 1) { |
|
606 | - echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; |
|
605 | + if ($this->do_debug >= 1) { |
|
606 | + echo "SMTP -> ERROR: ".$e["error"].": ".$byemsg.$this->CRLF.'<br />'; |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | - if(empty($e) || $close_on_error) { |
|
610 | + if (empty($e) || $close_on_error) { |
|
611 | 611 | $this->Close(); |
612 | 612 | } |
613 | 613 | |
@@ -629,28 +629,28 @@ discard block |
||
629 | 629 | public function Recipient($to) { |
630 | 630 | $this->error = null; // so no confusion is caused |
631 | 631 | |
632 | - if(!$this->connected()) { |
|
632 | + if (!$this->connected()) { |
|
633 | 633 | $this->error = array( |
634 | 634 | "error" => "Called Recipient() without being connected"); |
635 | 635 | return false; |
636 | 636 | } |
637 | 637 | |
638 | - fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); |
|
638 | + fputs($this->smtp_conn, "RCPT TO:<".$to.">".$this->CRLF); |
|
639 | 639 | |
640 | 640 | $rply = $this->get_lines(); |
641 | - $code = substr($rply,0,3); |
|
641 | + $code = substr($rply, 0, 3); |
|
642 | 642 | |
643 | - if($this->do_debug >= 2) { |
|
644 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
643 | + if ($this->do_debug >= 2) { |
|
644 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
645 | 645 | } |
646 | 646 | |
647 | - if($code != 250 && $code != 251) { |
|
647 | + if ($code != 250 && $code != 251) { |
|
648 | 648 | $this->error = |
649 | 649 | array("error" => "RCPT not accepted from server", |
650 | 650 | "smtp_code" => $code, |
651 | - "smtp_msg" => substr($rply,4)); |
|
652 | - if($this->do_debug >= 1) { |
|
653 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
651 | + "smtp_msg" => substr($rply, 4)); |
|
652 | + if ($this->do_debug >= 1) { |
|
653 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
654 | 654 | } |
655 | 655 | return false; |
656 | 656 | } |
@@ -672,28 +672,28 @@ discard block |
||
672 | 672 | public function Reset() { |
673 | 673 | $this->error = null; // so no confusion is caused |
674 | 674 | |
675 | - if(!$this->connected()) { |
|
675 | + if (!$this->connected()) { |
|
676 | 676 | $this->error = array( |
677 | 677 | "error" => "Called Reset() without being connected"); |
678 | 678 | return false; |
679 | 679 | } |
680 | 680 | |
681 | - fputs($this->smtp_conn,"RSET" . $this->CRLF); |
|
681 | + fputs($this->smtp_conn, "RSET".$this->CRLF); |
|
682 | 682 | |
683 | 683 | $rply = $this->get_lines(); |
684 | - $code = substr($rply,0,3); |
|
684 | + $code = substr($rply, 0, 3); |
|
685 | 685 | |
686 | - if($this->do_debug >= 2) { |
|
687 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
686 | + if ($this->do_debug >= 2) { |
|
687 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
688 | 688 | } |
689 | 689 | |
690 | - if($code != 250) { |
|
690 | + if ($code != 250) { |
|
691 | 691 | $this->error = |
692 | 692 | array("error" => "RSET failed", |
693 | 693 | "smtp_code" => $code, |
694 | - "smtp_msg" => substr($rply,4)); |
|
695 | - if($this->do_debug >= 1) { |
|
696 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
694 | + "smtp_msg" => substr($rply, 4)); |
|
695 | + if ($this->do_debug >= 1) { |
|
696 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
697 | 697 | } |
698 | 698 | return false; |
699 | 699 | } |
@@ -720,28 +720,28 @@ discard block |
||
720 | 720 | public function SendAndMail($from) { |
721 | 721 | $this->error = null; // so no confusion is caused |
722 | 722 | |
723 | - if(!$this->connected()) { |
|
723 | + if (!$this->connected()) { |
|
724 | 724 | $this->error = array( |
725 | 725 | "error" => "Called SendAndMail() without being connected"); |
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); |
|
729 | + fputs($this->smtp_conn, "SAML FROM:".$from.$this->CRLF); |
|
730 | 730 | |
731 | 731 | $rply = $this->get_lines(); |
732 | - $code = substr($rply,0,3); |
|
732 | + $code = substr($rply, 0, 3); |
|
733 | 733 | |
734 | - if($this->do_debug >= 2) { |
|
735 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
734 | + if ($this->do_debug >= 2) { |
|
735 | + echo "SMTP -> FROM SERVER:".$rply.$this->CRLF.'<br />'; |
|
736 | 736 | } |
737 | 737 | |
738 | - if($code != 250) { |
|
738 | + if ($code != 250) { |
|
739 | 739 | $this->error = |
740 | 740 | array("error" => "SAML not accepted from server", |
741 | 741 | "smtp_code" => $code, |
742 | - "smtp_msg" => substr($rply,4)); |
|
743 | - if($this->do_debug >= 1) { |
|
744 | - echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
|
742 | + "smtp_msg" => substr($rply, 4)); |
|
743 | + if ($this->do_debug >= 1) { |
|
744 | + echo "SMTP -> ERROR: ".$this->error["error"].": ".$rply.$this->CRLF.'<br />'; |
|
745 | 745 | } |
746 | 746 | return false; |
747 | 747 | } |
@@ -764,8 +764,8 @@ discard block |
||
764 | 764 | public function Turn() { |
765 | 765 | $this->error = array("error" => "This method, TURN, of the SMTP ". |
766 | 766 | "is not implemented"); |
767 | - if($this->do_debug >= 1) { |
|
768 | - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
767 | + if ($this->do_debug >= 1) { |
|
768 | + echo "SMTP -> NOTICE: ".$this->error["error"].$this->CRLF.'<br />'; |
|
769 | 769 | } |
770 | 770 | return false; |
771 | 771 | } |
@@ -794,17 +794,17 @@ discard block |
||
794 | 794 | */ |
795 | 795 | private function get_lines() { |
796 | 796 | $data = ""; |
797 | - while($str = @fgets($this->smtp_conn,515)) { |
|
798 | - if($this->do_debug >= 4) { |
|
799 | - echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'; |
|
800 | - echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'; |
|
797 | + while ($str = @fgets($this->smtp_conn, 515)) { |
|
798 | + if ($this->do_debug >= 4) { |
|
799 | + echo "SMTP -> get_lines(): \$data was \"$data\"".$this->CRLF.'<br />'; |
|
800 | + echo "SMTP -> get_lines(): \$str is \"$str\"".$this->CRLF.'<br />'; |
|
801 | 801 | } |
802 | 802 | $data .= $str; |
803 | - if($this->do_debug >= 4) { |
|
804 | - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; |
|
803 | + if ($this->do_debug >= 4) { |
|
804 | + echo "SMTP -> get_lines(): \$data is \"$data\"".$this->CRLF.'<br />'; |
|
805 | 805 | } |
806 | 806 | // if 4th character is a space, we are done reading, break the loop |
807 | - if(substr($str,3,1) == " ") { break; } |
|
807 | + if (substr($str, 3, 1) == " ") { break; } |
|
808 | 808 | } |
809 | 809 | return $data; |
810 | 810 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | private $pop_conn; |
122 | 122 | private $connected; |
123 | - private $error; // Error log array |
|
123 | + private $error; // Error log array |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Constructor, sets the initial values |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string $username |
143 | 143 | * @param string $password |
144 | 144 | */ |
145 | - public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { |
|
145 | + public function Authorise($host, $port = false, $tval = false, $username, $password, $debug_level = 0) { |
|
146 | 146 | $this->host = $host; |
147 | 147 | |
148 | 148 | // If no port value is passed, retrieve it |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param integer $tval |
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | - public function Connect ($host, $port = false, $tval = 30) { |
|
197 | + public function Connect($host, $port = false, $tval = 30) { |
|
198 | 198 | // Are we already connected? |
199 | 199 | if ($this->connected) { |
200 | 200 | return true; |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | set_error_handler(array(&$this, 'catchWarning')); |
209 | 209 | |
210 | 210 | // Connect to the POP3 server |
211 | - $this->pop_conn = fsockopen($host, // POP3 Host |
|
212 | - $port, // Port # |
|
213 | - $errno, // Error Number |
|
214 | - $errstr, // Error Message |
|
215 | - $tval); // Timeout (seconds) |
|
211 | + $this->pop_conn = fsockopen($host, // POP3 Host |
|
212 | + $port, // Port # |
|
213 | + $errno, // Error Number |
|
214 | + $errstr, // Error Message |
|
215 | + $tval); // Timeout (seconds) |
|
216 | 216 | |
217 | 217 | // Restore the error handler |
218 | 218 | restore_error_handler(); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param string $password |
270 | 270 | * @return boolean |
271 | 271 | */ |
272 | - public function Login ($username = '', $password = '') { |
|
272 | + public function Login($username = '', $password = '') { |
|
273 | 273 | if ($this->connected == false) { |
274 | 274 | $this->error = 'Not connected to POP3 server'; |
275 | 275 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | $password = $this->password; |
287 | 287 | } |
288 | 288 | |
289 | - $pop_username = "USER $username" . $this->CRLF; |
|
290 | - $pop_password = "PASS $password" . $this->CRLF; |
|
289 | + $pop_username = "USER $username".$this->CRLF; |
|
290 | + $pop_password = "PASS $password".$this->CRLF; |
|
291 | 291 | |
292 | 292 | // Send the Username |
293 | 293 | $this->sendString($pop_username); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * Disconnect from the POP3 server |
313 | 313 | * @access public |
314 | 314 | */ |
315 | - public function Disconnect () { |
|
315 | + public function Disconnect() { |
|
316 | 316 | $this->sendString('QUIT'); |
317 | 317 | |
318 | 318 | fclose($this->pop_conn); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param integer $size |
330 | 330 | * @return string |
331 | 331 | */ |
332 | - private function getResponse ($size = 128) { |
|
332 | + private function getResponse($size = 128) { |
|
333 | 333 | $pop3_response = fgets($this->pop_conn, $size); |
334 | 334 | |
335 | 335 | return $pop3_response; |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param string $string |
342 | 342 | * @return integer |
343 | 343 | */ |
344 | - private function sendString ($string) { |
|
344 | + private function sendString($string) { |
|
345 | 345 | $bytes_sent = fwrite($this->pop_conn, $string, strlen($string)); |
346 | 346 | |
347 | 347 | return $bytes_sent; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param string $string |
354 | 354 | * @return boolean |
355 | 355 | */ |
356 | - private function checkResponse ($string) { |
|
356 | + private function checkResponse($string) { |
|
357 | 357 | if (substr($string, 0, 3) !== '+OK') { |
358 | 358 | $this->error = array( |
359 | 359 | 'error' => "Server reported an error: $string", |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * If debug is enabled, display the error message array |
377 | 377 | * @access private |
378 | 378 | */ |
379 | - private function displayErrors () { |
|
379 | + private function displayErrors() { |
|
380 | 380 | echo '<pre>'; |
381 | 381 | |
382 | 382 | foreach ($this->error as $single_error) { |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @param string $errfile |
395 | 395 | * @param integer $errline |
396 | 396 | */ |
397 | - private function catchWarning ($errno, $errstr, $errfile, $errline) { |
|
397 | + private function catchWarning($errno, $errstr, $errfile, $errline) { |
|
398 | 398 | $this->error[] = array( |
399 | 399 | 'error' => "Connecting to the POP3 server raised a PHP warning: ", |
400 | 400 | 'errno' => $errno, |