@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | $array_to_search = is_array($docs_and_folders) ? $docs_and_folders : array(); |
35 | 35 | |
36 | 36 | if (count($array_to_search) > 0) { |
37 | - while (list($key) = each($array_to_search)) { |
|
38 | - $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | - } |
|
37 | + while (list($key) = each($array_to_search)) { |
|
38 | + $all_files[] = basename($array_to_search[$key]['path']); |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //get all svg and png group files |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | ($is_allowed_to_edit || GroupManager :: is_user_in_group($_user['user_id'], $groupId))) || $group_properties['doc_state'] == 1 |
71 | 71 | ){ |
72 | 72 | |
73 | - if (!empty($png_svg_files)) { |
|
74 | - echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | - echo '<ul>'; |
|
76 | - foreach($png_svg_files as $filename) { |
|
77 | - $image = $group_disk_path.$filename; |
|
78 | - |
|
79 | - if (strpos($filename, "svg")){ |
|
80 | - $new_sizes['width'] = 60; |
|
81 | - $new_sizes['height'] = 60; |
|
82 | - } else { |
|
83 | - $new_sizes = api_resize_image($image, 60, 60); |
|
84 | - } |
|
73 | + if (!empty($png_svg_files)) { |
|
74 | + echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
|
75 | + echo '<ul>'; |
|
76 | + foreach($png_svg_files as $filename) { |
|
77 | + $image = $group_disk_path.$filename; |
|
78 | + |
|
79 | + if (strpos($filename, "svg")){ |
|
80 | + $new_sizes['width'] = 60; |
|
81 | + $new_sizes['height'] = 60; |
|
82 | + } else { |
|
83 | + $new_sizes = api_resize_image($image, 60, 60); |
|
84 | + } |
|
85 | 85 | echo '<li style="display:inline; padding:8px;">'; |
86 | 86 | echo '<a href = "'.$group_web_path.$filename.'" alt="'.$filename.'" title="'.$filename.'">'; |
87 | 87 | echo '<img src = "'.$group_web_path.$filename.'" width = "'.$new_sizes['width'].'" height="'.$new_sizes['height'].'" border="0"></a></li>'; |
88 | - } |
|
89 | - echo '</ul>'; |
|
90 | - } |
|
88 | + } |
|
89 | + echo '</ul>'; |
|
90 | + } |
|
91 | 91 | } else { |
92 | - echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
92 | + echo Display::display_warning_message(get_lang('OnlyAccessFromYourGroup')); |
|
93 | 93 | } |
94 | 94 | ?> |
95 | 95 | </body> |
@@ -1335,27 +1335,27 @@ |
||
1335 | 1335 | public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
1336 | 1336 | { |
1337 | 1337 | $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
1338 | - $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | - $user_id = intval($user_id); |
|
1338 | + $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | + $user_id = intval($user_id); |
|
1340 | 1340 | |
1341 | - if ($relation_type == 0) { |
|
1342 | - $where_relation_condition = ''; |
|
1343 | - } else { |
|
1344 | - $relation_type = intval($relation_type); |
|
1345 | - $where_relation_condition = "AND gu.relation_type = $relation_type "; |
|
1346 | - } |
|
1341 | + if ($relation_type == 0) { |
|
1342 | + $where_relation_condition = ''; |
|
1343 | + } else { |
|
1344 | + $relation_type = intval($relation_type); |
|
1345 | + $where_relation_condition = "AND gu.relation_type = $relation_type "; |
|
1346 | + } |
|
1347 | 1347 | |
1348 | - $sql = "SELECT count(g.id) as count |
|
1348 | + $sql = "SELECT count(g.id) as count |
|
1349 | 1349 | FROM $tbl_group g |
1350 | 1350 | INNER JOIN $table_group_rel_user gu |
1351 | 1351 | ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition "; |
1352 | 1352 | |
1353 | - $result = Database::query($sql); |
|
1354 | - if (Database::num_rows($result) > 0) { |
|
1355 | - $row = Database::fetch_array($result, 'ASSOC'); |
|
1353 | + $result = Database::query($sql); |
|
1354 | + if (Database::num_rows($result) > 0) { |
|
1355 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
1356 | 1356 | return $row['count']; |
1357 | - } |
|
1358 | - return 0; |
|
1357 | + } |
|
1358 | + return 0; |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | 'changeable', |
20 | 20 | 'filter', |
21 | 21 | 'extra_field_type', |
22 | - /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
22 | + /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
23 | 23 | 'field_loggeable', |
24 | 24 | */ |
25 | 25 | 'created_at' |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * France:Paris;Bretagne;Marseilles;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura; |
524 | 524 | * into |
525 | 525 | * array( |
526 | - * 'France' => |
|
526 | + * 'France' => |
|
527 | 527 | * array('Paris', 'Bregtane', 'Marseilles'), |
528 | 528 | * 'Belgique' => |
529 | 529 | * array('Namur', 'Liège') |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | |
1185 | 1185 | if ($this->type == 'user') { |
1186 | 1186 | |
1187 | - /* //the magic should be here |
|
1187 | + /* //the magic should be here |
|
1188 | 1188 | $user_tags = UserManager::get_user_tags($user_id, $field_details[0]); |
1189 | 1189 | |
1190 | 1190 | $tag_list = ''; |
@@ -401,19 +401,19 @@ |
||
401 | 401 | |
402 | 402 | public function format_yes_no_optional($value) |
403 | 403 | { |
404 | - $return = ''; |
|
405 | - switch($value) { |
|
406 | - case 0: |
|
407 | - $return = get_lang('No'); |
|
408 | - break; |
|
409 | - case 1: |
|
410 | - $return = get_lang('Yes'); |
|
411 | - break; |
|
412 | - case 2: |
|
413 | - $return = get_lang('Optional'); |
|
414 | - break; |
|
415 | - } |
|
416 | - return $return; |
|
404 | + $return = ''; |
|
405 | + switch($value) { |
|
406 | + case 0: |
|
407 | + $return = get_lang('No'); |
|
408 | + break; |
|
409 | + case 1: |
|
410 | + $return = get_lang('Yes'); |
|
411 | + break; |
|
412 | + case 2: |
|
413 | + $return = get_lang('Optional'); |
|
414 | + break; |
|
415 | + } |
|
416 | + return $return; |
|
417 | 417 | |
418 | 418 | } |
419 | 419 |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | return false; |
721 | 721 | } |
722 | 722 | |
723 | - /** |
|
724 | - * @param int $itemId |
|
725 | - * @param int $fieldId |
|
726 | - * @return array |
|
727 | - */ |
|
723 | + /** |
|
724 | + * @param int $itemId |
|
725 | + * @param int $fieldId |
|
726 | + * @return array |
|
727 | + */ |
|
728 | 728 | public function getAllValuesByItemAndField($itemId, $fieldId) |
729 | 729 | { |
730 | 730 | $fieldId = intval($fieldId); |
@@ -847,7 +847,6 @@ discard block |
||
847 | 847 | /** |
848 | 848 | * Deletes all values from an item |
849 | 849 | * @param int $itemId (session id, course id, etc) |
850 | - |
|
851 | 850 | * @assert (-1,-1) == null |
852 | 851 | */ |
853 | 852 | public function deleteValuesByItem($itemId) |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | DocumentManager::file_send_for_download($filePath, true, $filename.'.csv'); |
58 | 58 | exit; |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Export tabular data to XLS-file |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | DocumentManager::file_send_for_download($filePath, true, $filename.'.xlsx'); |
81 | 81 | exit; |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Export tabular data to XLS-file (as html table) |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * Export tabular data to XML-file |
|
116 | - * @param array Simple array of data to put in XML |
|
117 | - * @param string Name of file to be given to the user |
|
118 | - * @param string Name of common tag to place each line in |
|
119 | - * @param string Name of the root element. A root element should always be given. |
|
120 | - * @param string Encoding in which the data is provided |
|
121 | - */ |
|
115 | + * Export tabular data to XML-file |
|
116 | + * @param array Simple array of data to put in XML |
|
117 | + * @param string Name of file to be given to the user |
|
118 | + * @param string Name of common tag to place each line in |
|
119 | + * @param string Name of the root element. A root element should always be given. |
|
120 | + * @param string Encoding in which the data is provided |
|
121 | + */ |
|
122 | 122 | public static function arrayToXml( |
123 | 123 | $data, |
124 | 124 | $filename = 'export', |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | fclose($handle); |
149 | 149 | DocumentManager :: file_send_for_download($file, true, $filename.'.xml'); |
150 | 150 | exit; |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Export hierarchical tabular data to XML-file |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | foreach ($data as $row) { |
198 | 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"; |
|
200 | + $string .= self::_export_complex_table_xml_helper($row['value'],$level+1)."\n"; |
|
201 | 201 | $string .= str_repeat("\t",$level).'</'.$row['name'].'>'; |
202 | 202 | } else { |
203 | 203 | $string .= $row['value']; |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Is the browser from facebook? |
|
260 | - * @return boolean True if the browser is from facebook otherwise false |
|
261 | - */ |
|
259 | + * Is the browser from facebook? |
|
260 | + * @return boolean True if the browser is from facebook otherwise false |
|
261 | + */ |
|
262 | 262 | public function isFacebook() |
263 | 263 | { |
264 | 264 | return $this->_is_facebook; |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | - $this->setBrowser(self::BROWSER_IE); |
|
596 | - $result = explode('rv:', $this->_agent); |
|
597 | - $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | - } // Test for Pocket IE |
|
594 | + else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | + $this->setBrowser(self::BROWSER_IE); |
|
596 | + $result = explode('rv:', $this->_agent); |
|
597 | + $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | + $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | + } // Test for Pocket IE |
|
600 | 600 | else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) { |
601 | 601 | $aresult = explode(' ', stristr($this->_agent, 'mspie')); |
602 | 602 | $this->setPlatform(self::PLATFORM_WINDOWS_CE); |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Generates an HTML Certificate and fills the path_certificate field in the DB |
|
148 | - **/ |
|
147 | + * Generates an HTML Certificate and fills the path_certificate field in the DB |
|
148 | + **/ |
|
149 | 149 | public function generate($params = array()) |
150 | 150 | { |
151 | 151 | // The user directory should be set |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * update user info about certificate |
|
265 | - * @param int $cat_id category id |
|
266 | - * @param int $user_id user id |
|
267 | - * @param string $path_certificate the path name of the certificate |
|
268 | - * @return void() |
|
269 | - */ |
|
264 | + * update user info about certificate |
|
265 | + * @param int $cat_id category id |
|
266 | + * @param int $user_id user id |
|
267 | + * @param string $path_certificate the path name of the certificate |
|
268 | + * @return void() |
|
269 | + */ |
|
270 | 270 | public function update_user_info_about_certificate( |
271 | 271 | $cat_id, |
272 | 272 | $user_id, |
@@ -368,13 +368,13 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Shows the student's certificate (HTML file). If the global setting |
|
372 | - * allow_public_certificates is set to 'false', no certificate can be printed. |
|
373 | - * If the global allow_public_certificates is set to 'true' and the course |
|
374 | - * setting allow_public_certificates is set to 0, no certificate *in this |
|
375 | - * course* can be printed (for anonymous users). Connected users can always |
|
376 | - * print them. |
|
377 | - */ |
|
371 | + * Shows the student's certificate (HTML file). If the global setting |
|
372 | + * allow_public_certificates is set to 'false', no certificate can be printed. |
|
373 | + * If the global allow_public_certificates is set to 'true' and the course |
|
374 | + * setting allow_public_certificates is set to 0, no certificate *in this |
|
375 | + * course* can be printed (for anonymous users). Connected users can always |
|
376 | + * print them. |
|
377 | + */ |
|
378 | 378 | public function show() |
379 | 379 | { |
380 | 380 | // Special rules for anonymous users |
@@ -47,130 +47,130 @@ discard block |
||
47 | 47 | */ |
48 | 48 | |
49 | 49 | class SMTP { |
50 | - /** |
|
51 | - * SMTP server port |
|
52 | - * @var int |
|
53 | - */ |
|
54 | - public $SMTP_PORT = 25; |
|
55 | - |
|
56 | - /** |
|
57 | - * SMTP reply line ending |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - public $CRLF = "\r\n"; |
|
61 | - |
|
62 | - /** |
|
63 | - * Sets whether debugging is turned on |
|
64 | - * @var bool |
|
65 | - */ |
|
66 | - public $do_debug; // the level of debug to perform |
|
67 | - |
|
68 | - /** |
|
69 | - * Sets VERP use on/off (default is off) |
|
70 | - * @var bool |
|
71 | - */ |
|
72 | - public $do_verp = false; |
|
73 | - |
|
74 | - ///////////////////////////////////////////////// |
|
75 | - // PROPERTIES, PRIVATE AND PROTECTED |
|
76 | - ///////////////////////////////////////////////// |
|
77 | - |
|
78 | - private $smtp_conn; // the socket to the server |
|
79 | - private $error; // error if any on the last call |
|
80 | - private $helo_rply; // the reply the server sent to us for HELO |
|
81 | - |
|
82 | - /** |
|
83 | - * Initialize the class so that the data is in a known state. |
|
84 | - * @access public |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function __construct() { |
|
50 | + /** |
|
51 | + * SMTP server port |
|
52 | + * @var int |
|
53 | + */ |
|
54 | + public $SMTP_PORT = 25; |
|
55 | + |
|
56 | + /** |
|
57 | + * SMTP reply line ending |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + public $CRLF = "\r\n"; |
|
61 | + |
|
62 | + /** |
|
63 | + * Sets whether debugging is turned on |
|
64 | + * @var bool |
|
65 | + */ |
|
66 | + public $do_debug; // the level of debug to perform |
|
67 | + |
|
68 | + /** |
|
69 | + * Sets VERP use on/off (default is off) |
|
70 | + * @var bool |
|
71 | + */ |
|
72 | + public $do_verp = false; |
|
73 | + |
|
74 | + ///////////////////////////////////////////////// |
|
75 | + // PROPERTIES, PRIVATE AND PROTECTED |
|
76 | + ///////////////////////////////////////////////// |
|
77 | + |
|
78 | + private $smtp_conn; // the socket to the server |
|
79 | + private $error; // error if any on the last call |
|
80 | + private $helo_rply; // the reply the server sent to us for HELO |
|
81 | + |
|
82 | + /** |
|
83 | + * Initialize the class so that the data is in a known state. |
|
84 | + * @access public |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function __construct() { |
|
88 | 88 | $this->smtp_conn = 0; |
89 | 89 | $this->error = null; |
90 | 90 | $this->helo_rply = null; |
91 | 91 | |
92 | 92 | $this->do_debug = 0; |
93 | - } |
|
94 | - |
|
95 | - ///////////////////////////////////////////////// |
|
96 | - // CONNECTION FUNCTIONS |
|
97 | - ///////////////////////////////////////////////// |
|
98 | - |
|
99 | - /** |
|
100 | - * Connect to the server specified on the port specified. |
|
101 | - * If the port is not specified use the default SMTP_PORT. |
|
102 | - * If tval is specified then a connection will try and be |
|
103 | - * established with the server for that number of seconds. |
|
104 | - * If tval is not specified the default is 30 seconds to |
|
105 | - * try on the connection. |
|
106 | - * |
|
107 | - * SMTP CODE SUCCESS: 220 |
|
108 | - * SMTP CODE FAILURE: 421 |
|
109 | - * @access public |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function Connect($host, $port = 0, $tval = 30) { |
|
93 | + } |
|
94 | + |
|
95 | + ///////////////////////////////////////////////// |
|
96 | + // CONNECTION FUNCTIONS |
|
97 | + ///////////////////////////////////////////////// |
|
98 | + |
|
99 | + /** |
|
100 | + * Connect to the server specified on the port specified. |
|
101 | + * If the port is not specified use the default SMTP_PORT. |
|
102 | + * If tval is specified then a connection will try and be |
|
103 | + * established with the server for that number of seconds. |
|
104 | + * If tval is not specified the default is 30 seconds to |
|
105 | + * try on the connection. |
|
106 | + * |
|
107 | + * SMTP CODE SUCCESS: 220 |
|
108 | + * SMTP CODE FAILURE: 421 |
|
109 | + * @access public |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function Connect($host, $port = 0, $tval = 30) { |
|
113 | 113 | // set the error val to null so there is no confusion |
114 | 114 | $this->error = null; |
115 | 115 | |
116 | 116 | // make sure we are __not__ connected |
117 | 117 | if($this->connected()) { |
118 | - // already connected, generate error |
|
119 | - $this->error = array("error" => "Already connected to a server"); |
|
120 | - return false; |
|
118 | + // already connected, generate error |
|
119 | + $this->error = array("error" => "Already connected to a server"); |
|
120 | + return false; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | if(empty($port)) { |
124 | - $port = $this->SMTP_PORT; |
|
124 | + $port = $this->SMTP_PORT; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | // connect to the smtp server |
128 | 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 |
|
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 | 134 | if(empty($this->smtp_conn)) { |
135 | - $this->error = array("error" => "Failed to connect to server", |
|
136 | - "errno" => $errno, |
|
137 | - "errstr" => $errstr); |
|
138 | - if($this->do_debug >= 1) { |
|
135 | + $this->error = array("error" => "Failed to connect to server", |
|
136 | + "errno" => $errno, |
|
137 | + "errstr" => $errstr); |
|
138 | + if($this->do_debug >= 1) { |
|
139 | 139 | echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />'; |
140 | - } |
|
141 | - return false; |
|
140 | + } |
|
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 | 146 | if(substr(PHP_OS, 0, 3) != "WIN") |
147 | - socket_set_timeout($this->smtp_conn, $tval, 0); |
|
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 | 152 | if($this->do_debug >= 2) { |
153 | - echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
153 | + echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />'; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | return true; |
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Initiate a TLS communication with the server. |
|
161 | - * |
|
162 | - * SMTP CODE 220 Ready to start TLS |
|
163 | - * SMTP CODE 501 Syntax error (no parameters allowed) |
|
164 | - * SMTP CODE 454 TLS not available due to temporary reason |
|
165 | - * @access public |
|
166 | - * @return bool success |
|
167 | - */ |
|
168 | - public function StartTLS() { |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Initiate a TLS communication with the server. |
|
161 | + * |
|
162 | + * SMTP CODE 220 Ready to start TLS |
|
163 | + * SMTP CODE 501 Syntax error (no parameters allowed) |
|
164 | + * SMTP CODE 454 TLS not available due to temporary reason |
|
165 | + * @access public |
|
166 | + * @return bool success |
|
167 | + */ |
|
168 | + public function StartTLS() { |
|
169 | 169 | $this->error = null; # to avoid confusion |
170 | 170 | |
171 | 171 | if(!$this->connected()) { |
172 | - $this->error = array("error" => "Called StartTLS() without being connected"); |
|
173 | - return false; |
|
172 | + $this->error = array("error" => "Called StartTLS() without being connected"); |
|
173 | + return false; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); |
@@ -179,35 +179,35 @@ discard block |
||
179 | 179 | $code = substr($rply,0,3); |
180 | 180 | |
181 | 181 | if($this->do_debug >= 2) { |
182 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
182 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | if($code != 220) { |
186 | - $this->error = |
|
187 | - array("error" => "STARTTLS not accepted from server", |
|
188 | - "smtp_code" => $code, |
|
189 | - "smtp_msg" => substr($rply,4)); |
|
190 | - if($this->do_debug >= 1) { |
|
186 | + $this->error = |
|
187 | + array("error" => "STARTTLS not accepted from server", |
|
188 | + "smtp_code" => $code, |
|
189 | + "smtp_msg" => substr($rply,4)); |
|
190 | + if($this->do_debug >= 1) { |
|
191 | 191 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
192 | - } |
|
193 | - return false; |
|
192 | + } |
|
193 | + return false; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | // Begin encrypted connection |
197 | 197 | if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
198 | - return false; |
|
198 | + return false; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return true; |
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Performs SMTP authentication. Must be run after running the |
|
206 | - * Hello() method. Returns true if successfully authenticated. |
|
207 | - * @access public |
|
208 | - * @return bool |
|
209 | - */ |
|
210 | - public function Authenticate($username, $password) { |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Performs SMTP authentication. Must be run after running the |
|
206 | + * Hello() method. Returns true if successfully authenticated. |
|
207 | + * @access public |
|
208 | + * @return bool |
|
209 | + */ |
|
210 | + public function Authenticate($username, $password) { |
|
211 | 211 | // Start authentication |
212 | 212 | fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); |
213 | 213 | |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | $code = substr($rply,0,3); |
216 | 216 | |
217 | 217 | if($code != 334) { |
218 | - $this->error = |
|
218 | + $this->error = |
|
219 | 219 | array("error" => "AUTH not accepted from server", |
220 | - "smtp_code" => $code, |
|
221 | - "smtp_msg" => substr($rply,4)); |
|
222 | - if($this->do_debug >= 1) { |
|
220 | + "smtp_code" => $code, |
|
221 | + "smtp_msg" => substr($rply,4)); |
|
222 | + if($this->do_debug >= 1) { |
|
223 | 223 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
224 | - } |
|
225 | - return false; |
|
224 | + } |
|
225 | + return false; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Send encoded username |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | $code = substr($rply,0,3); |
233 | 233 | |
234 | 234 | if($code != 334) { |
235 | - $this->error = |
|
235 | + $this->error = |
|
236 | 236 | array("error" => "Username not accepted from server", |
237 | - "smtp_code" => $code, |
|
238 | - "smtp_msg" => substr($rply,4)); |
|
239 | - if($this->do_debug >= 1) { |
|
237 | + "smtp_code" => $code, |
|
238 | + "smtp_msg" => substr($rply,4)); |
|
239 | + if($this->do_debug >= 1) { |
|
240 | 240 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
241 | - } |
|
242 | - return false; |
|
241 | + } |
|
242 | + return false; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | // Send encoded password |
@@ -249,87 +249,87 @@ discard block |
||
249 | 249 | $code = substr($rply,0,3); |
250 | 250 | |
251 | 251 | if($code != 235) { |
252 | - $this->error = |
|
252 | + $this->error = |
|
253 | 253 | array("error" => "Password not accepted from server", |
254 | - "smtp_code" => $code, |
|
255 | - "smtp_msg" => substr($rply,4)); |
|
256 | - if($this->do_debug >= 1) { |
|
254 | + "smtp_code" => $code, |
|
255 | + "smtp_msg" => substr($rply,4)); |
|
256 | + if($this->do_debug >= 1) { |
|
257 | 257 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
258 | - } |
|
259 | - return false; |
|
258 | + } |
|
259 | + return false; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | return true; |
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * Returns true if connected to a server otherwise false |
|
267 | - * @access public |
|
268 | - * @return bool |
|
269 | - */ |
|
270 | - public function Connected() { |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * Returns true if connected to a server otherwise false |
|
267 | + * @access public |
|
268 | + * @return bool |
|
269 | + */ |
|
270 | + public function Connected() { |
|
271 | 271 | if(!empty($this->smtp_conn)) { |
272 | - $sock_status = socket_get_status($this->smtp_conn); |
|
273 | - if($sock_status["eof"]) { |
|
272 | + $sock_status = socket_get_status($this->smtp_conn); |
|
273 | + if($sock_status["eof"]) { |
|
274 | 274 | // the socket is valid but we are not connected |
275 | 275 | if($this->do_debug >= 1) { |
276 | 276 | echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; |
277 | 277 | } |
278 | 278 | $this->Close(); |
279 | 279 | return false; |
280 | - } |
|
281 | - return true; // everything looks good |
|
280 | + } |
|
281 | + return true; // everything looks good |
|
282 | 282 | } |
283 | 283 | return false; |
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * Closes the socket and cleans up the state of the class. |
|
288 | - * It is not considered good to use this function without |
|
289 | - * first trying to use QUIT. |
|
290 | - * @access public |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - public function Close() { |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * Closes the socket and cleans up the state of the class. |
|
288 | + * It is not considered good to use this function without |
|
289 | + * first trying to use QUIT. |
|
290 | + * @access public |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + public function Close() { |
|
294 | 294 | $this->error = null; // so there is no confusion |
295 | 295 | $this->helo_rply = null; |
296 | 296 | if(!empty($this->smtp_conn)) { |
297 | - // close the connection and cleanup |
|
298 | - fclose($this->smtp_conn); |
|
299 | - $this->smtp_conn = 0; |
|
300 | - } |
|
301 | - } |
|
302 | - |
|
303 | - ///////////////////////////////////////////////// |
|
304 | - // SMTP COMMANDS |
|
305 | - ///////////////////////////////////////////////// |
|
306 | - |
|
307 | - /** |
|
308 | - * Issues a data command and sends the msg_data to the server |
|
309 | - * finializing the mail transaction. $msg_data is the message |
|
310 | - * that is to be send with the headers. Each header needs to be |
|
311 | - * on a single line followed by a <CRLF> with the message headers |
|
312 | - * and the message body being seperated by and additional <CRLF>. |
|
313 | - * |
|
314 | - * Implements rfc 821: DATA <CRLF> |
|
315 | - * |
|
316 | - * SMTP CODE INTERMEDIATE: 354 |
|
317 | - * [data] |
|
318 | - * <CRLF>.<CRLF> |
|
319 | - * SMTP CODE SUCCESS: 250 |
|
320 | - * SMTP CODE FAILURE: 552,554,451,452 |
|
321 | - * SMTP CODE FAILURE: 451,554 |
|
322 | - * SMTP CODE ERROR : 500,501,503,421 |
|
323 | - * @access public |
|
324 | - * @return bool |
|
325 | - */ |
|
326 | - public function Data($msg_data) { |
|
297 | + // close the connection and cleanup |
|
298 | + fclose($this->smtp_conn); |
|
299 | + $this->smtp_conn = 0; |
|
300 | + } |
|
301 | + } |
|
302 | + |
|
303 | + ///////////////////////////////////////////////// |
|
304 | + // SMTP COMMANDS |
|
305 | + ///////////////////////////////////////////////// |
|
306 | + |
|
307 | + /** |
|
308 | + * Issues a data command and sends the msg_data to the server |
|
309 | + * finializing the mail transaction. $msg_data is the message |
|
310 | + * that is to be send with the headers. Each header needs to be |
|
311 | + * on a single line followed by a <CRLF> with the message headers |
|
312 | + * and the message body being seperated by and additional <CRLF>. |
|
313 | + * |
|
314 | + * Implements rfc 821: DATA <CRLF> |
|
315 | + * |
|
316 | + * SMTP CODE INTERMEDIATE: 354 |
|
317 | + * [data] |
|
318 | + * <CRLF>.<CRLF> |
|
319 | + * SMTP CODE SUCCESS: 250 |
|
320 | + * SMTP CODE FAILURE: 552,554,451,452 |
|
321 | + * SMTP CODE FAILURE: 451,554 |
|
322 | + * SMTP CODE ERROR : 500,501,503,421 |
|
323 | + * @access public |
|
324 | + * @return bool |
|
325 | + */ |
|
326 | + public function Data($msg_data) { |
|
327 | 327 | $this->error = null; // so no confusion is caused |
328 | 328 | |
329 | 329 | if(!$this->connected()) { |
330 | - $this->error = array( |
|
331 | - "error" => "Called Data() without being connected"); |
|
332 | - return false; |
|
330 | + $this->error = array( |
|
331 | + "error" => "Called Data() without being connected"); |
|
332 | + return false; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | fputs($this->smtp_conn,"DATA" . $this->CRLF); |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | $code = substr($rply,0,3); |
339 | 339 | |
340 | 340 | if($this->do_debug >= 2) { |
341 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
341 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if($code != 354) { |
345 | - $this->error = |
|
345 | + $this->error = |
|
346 | 346 | array("error" => "DATA command not accepted from server", |
347 | - "smtp_code" => $code, |
|
348 | - "smtp_msg" => substr($rply,4)); |
|
349 | - if($this->do_debug >= 1) { |
|
347 | + "smtp_code" => $code, |
|
348 | + "smtp_msg" => substr($rply,4)); |
|
349 | + if($this->do_debug >= 1) { |
|
350 | 350 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
351 | - } |
|
352 | - return false; |
|
351 | + } |
|
352 | + return false; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /* the server is ready to accept data! |
@@ -380,49 +380,49 @@ discard block |
||
380 | 380 | $field = substr($lines[0],0,strpos($lines[0],":")); |
381 | 381 | $in_headers = false; |
382 | 382 | if(!empty($field) && !strstr($field," ")) { |
383 | - $in_headers = true; |
|
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 | 388 | while(list(,$line) = @each($lines)) { |
389 | - $lines_out = null; |
|
390 | - if($line == "" && $in_headers) { |
|
389 | + $lines_out = null; |
|
390 | + if($line == "" && $in_headers) { |
|
391 | 391 | $in_headers = false; |
392 | - } |
|
393 | - // ok we need to break this line up into several smaller lines |
|
394 | - while(strlen($line) > $max_line_length) { |
|
392 | + } |
|
393 | + // ok we need to break this line up into several smaller lines |
|
394 | + while(strlen($line) > $max_line_length) { |
|
395 | 395 | $pos = strrpos(substr($line,0,$max_line_length)," "); |
396 | 396 | |
397 | 397 | // Patch to fix DOS attack |
398 | 398 | if(!$pos) { |
399 | - $pos = $max_line_length - 1; |
|
400 | - $lines_out[] = substr($line,0,$pos); |
|
401 | - $line = substr($line,$pos); |
|
399 | + $pos = $max_line_length - 1; |
|
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 | 410 | if($in_headers) { |
411 | - $line = "\t" . $line; |
|
411 | + $line = "\t" . $line; |
|
412 | 412 | } |
413 | - } |
|
414 | - $lines_out[] = $line; |
|
413 | + } |
|
414 | + $lines_out[] = $line; |
|
415 | 415 | |
416 | - // send the lines to the server |
|
417 | - while(list(,$line_out) = @each($lines_out)) { |
|
416 | + // send the lines to the server |
|
417 | + while(list(,$line_out) = @each($lines_out)) { |
|
418 | 418 | if(strlen($line_out) > 0) |
419 | 419 | { |
420 | - if(substr($line_out, 0, 1) == ".") { |
|
420 | + if(substr($line_out, 0, 1) == ".") { |
|
421 | 421 | $line_out = "." . $line_out; |
422 | - } |
|
422 | + } |
|
423 | 423 | } |
424 | 424 | fputs($this->smtp_conn,$line_out . $this->CRLF); |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // message data has been sent |
@@ -432,111 +432,111 @@ discard block |
||
432 | 432 | $code = substr($rply,0,3); |
433 | 433 | |
434 | 434 | if($this->do_debug >= 2) { |
435 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
435 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | if($code != 250) { |
439 | - $this->error = |
|
439 | + $this->error = |
|
440 | 440 | array("error" => "DATA not accepted from server", |
441 | - "smtp_code" => $code, |
|
442 | - "smtp_msg" => substr($rply,4)); |
|
443 | - if($this->do_debug >= 1) { |
|
441 | + "smtp_code" => $code, |
|
442 | + "smtp_msg" => substr($rply,4)); |
|
443 | + if($this->do_debug >= 1) { |
|
444 | 444 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
445 | - } |
|
446 | - return false; |
|
445 | + } |
|
446 | + return false; |
|
447 | 447 | } |
448 | 448 | return true; |
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Sends the HELO command to the smtp server. |
|
453 | - * This makes sure that we and the server are in |
|
454 | - * the same known state. |
|
455 | - * |
|
456 | - * Implements from rfc 821: HELO <SP> <domain> <CRLF> |
|
457 | - * |
|
458 | - * SMTP CODE SUCCESS: 250 |
|
459 | - * SMTP CODE ERROR : 500, 501, 504, 421 |
|
460 | - * @access public |
|
461 | - * @return bool |
|
462 | - */ |
|
463 | - public function Hello($host = '') { |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Sends the HELO command to the smtp server. |
|
453 | + * This makes sure that we and the server are in |
|
454 | + * the same known state. |
|
455 | + * |
|
456 | + * Implements from rfc 821: HELO <SP> <domain> <CRLF> |
|
457 | + * |
|
458 | + * SMTP CODE SUCCESS: 250 |
|
459 | + * SMTP CODE ERROR : 500, 501, 504, 421 |
|
460 | + * @access public |
|
461 | + * @return bool |
|
462 | + */ |
|
463 | + public function Hello($host = '') { |
|
464 | 464 | $this->error = null; // so no confusion is caused |
465 | 465 | |
466 | 466 | if(!$this->connected()) { |
467 | - $this->error = array( |
|
467 | + $this->error = array( |
|
468 | 468 | "error" => "Called Hello() without being connected"); |
469 | - return false; |
|
469 | + return false; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | // if hostname for HELO was not specified send default |
473 | 473 | if(empty($host)) { |
474 | - // determine appropriate default to send to server |
|
475 | - $host = "localhost"; |
|
474 | + // determine appropriate default to send to server |
|
475 | + $host = "localhost"; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | // Send extended hello first (RFC 2821) |
479 | 479 | if(!$this->SendHello("EHLO", $host)) { |
480 | - if(!$this->SendHello("HELO", $host)) { |
|
480 | + if(!$this->SendHello("HELO", $host)) { |
|
481 | 481 | return false; |
482 | - } |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | return true; |
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * Sends a HELO/EHLO command. |
|
490 | - * @access private |
|
491 | - * @return bool |
|
492 | - */ |
|
493 | - private function SendHello($hello, $host) { |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * Sends a HELO/EHLO command. |
|
490 | + * @access private |
|
491 | + * @return bool |
|
492 | + */ |
|
493 | + private function SendHello($hello, $host) { |
|
494 | 494 | fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); |
495 | 495 | |
496 | 496 | $rply = $this->get_lines(); |
497 | 497 | $code = substr($rply,0,3); |
498 | 498 | |
499 | 499 | if($this->do_debug >= 2) { |
500 | - echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
500 | + echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />'; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | if($code != 250) { |
504 | - $this->error = |
|
504 | + $this->error = |
|
505 | 505 | array("error" => $hello . " not accepted from server", |
506 | - "smtp_code" => $code, |
|
507 | - "smtp_msg" => substr($rply,4)); |
|
508 | - if($this->do_debug >= 1) { |
|
506 | + "smtp_code" => $code, |
|
507 | + "smtp_msg" => substr($rply,4)); |
|
508 | + if($this->do_debug >= 1) { |
|
509 | 509 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
510 | - } |
|
511 | - return false; |
|
510 | + } |
|
511 | + return false; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $this->helo_rply = $rply; |
515 | 515 | |
516 | 516 | return true; |
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * Starts a mail transaction from the email address specified in |
|
521 | - * $from. Returns true if successful or false otherwise. If True |
|
522 | - * the mail transaction is started and then one or more Recipient |
|
523 | - * commands may be called followed by a Data command. |
|
524 | - * |
|
525 | - * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> |
|
526 | - * |
|
527 | - * SMTP CODE SUCCESS: 250 |
|
528 | - * SMTP CODE SUCCESS: 552,451,452 |
|
529 | - * SMTP CODE SUCCESS: 500,501,421 |
|
530 | - * @access public |
|
531 | - * @return bool |
|
532 | - */ |
|
533 | - public function Mail($from) { |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Starts a mail transaction from the email address specified in |
|
521 | + * $from. Returns true if successful or false otherwise. If True |
|
522 | + * the mail transaction is started and then one or more Recipient |
|
523 | + * commands may be called followed by a Data command. |
|
524 | + * |
|
525 | + * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF> |
|
526 | + * |
|
527 | + * SMTP CODE SUCCESS: 250 |
|
528 | + * SMTP CODE SUCCESS: 552,451,452 |
|
529 | + * SMTP CODE SUCCESS: 500,501,421 |
|
530 | + * @access public |
|
531 | + * @return bool |
|
532 | + */ |
|
533 | + public function Mail($from) { |
|
534 | 534 | $this->error = null; // so no confusion is caused |
535 | 535 | |
536 | 536 | if(!$this->connected()) { |
537 | - $this->error = array( |
|
538 | - "error" => "Called Mail() without being connected"); |
|
539 | - return false; |
|
537 | + $this->error = array( |
|
538 | + "error" => "Called Mail() without being connected"); |
|
539 | + return false; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | $useVerp = ($this->do_verp ? "XVERP" : ""); |
@@ -546,40 +546,40 @@ discard block |
||
546 | 546 | $code = substr($rply,0,3); |
547 | 547 | |
548 | 548 | if($this->do_debug >= 2) { |
549 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
549 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | if($code != 250) { |
553 | - $this->error = |
|
553 | + $this->error = |
|
554 | 554 | array("error" => "MAIL not accepted from server", |
555 | - "smtp_code" => $code, |
|
556 | - "smtp_msg" => substr($rply,4)); |
|
557 | - if($this->do_debug >= 1) { |
|
555 | + "smtp_code" => $code, |
|
556 | + "smtp_msg" => substr($rply,4)); |
|
557 | + if($this->do_debug >= 1) { |
|
558 | 558 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
559 | - } |
|
560 | - return false; |
|
559 | + } |
|
560 | + return false; |
|
561 | 561 | } |
562 | 562 | return true; |
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Sends the quit command to the server and then closes the socket |
|
567 | - * if there is no error or the $close_on_error argument is true. |
|
568 | - * |
|
569 | - * Implements from rfc 821: QUIT <CRLF> |
|
570 | - * |
|
571 | - * SMTP CODE SUCCESS: 221 |
|
572 | - * SMTP CODE ERROR : 500 |
|
573 | - * @access public |
|
574 | - * @return bool |
|
575 | - */ |
|
576 | - public function Quit($close_on_error = true) { |
|
563 | + } |
|
564 | + |
|
565 | + /** |
|
566 | + * Sends the quit command to the server and then closes the socket |
|
567 | + * if there is no error or the $close_on_error argument is true. |
|
568 | + * |
|
569 | + * Implements from rfc 821: QUIT <CRLF> |
|
570 | + * |
|
571 | + * SMTP CODE SUCCESS: 221 |
|
572 | + * SMTP CODE ERROR : 500 |
|
573 | + * @access public |
|
574 | + * @return bool |
|
575 | + */ |
|
576 | + public function Quit($close_on_error = true) { |
|
577 | 577 | $this->error = null; // so there is no confusion |
578 | 578 | |
579 | 579 | if(!$this->connected()) { |
580 | - $this->error = array( |
|
581 | - "error" => "Called Quit() without being connected"); |
|
582 | - return false; |
|
580 | + $this->error = array( |
|
581 | + "error" => "Called Quit() without being connected"); |
|
582 | + return false; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | // send the quit command to the server |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $byemsg = $this->get_lines(); |
590 | 590 | |
591 | 591 | if($this->do_debug >= 2) { |
592 | - echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
592 | + echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />'; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | $rval = true; |
@@ -597,42 +597,42 @@ discard block |
||
597 | 597 | |
598 | 598 | $code = substr($byemsg,0,3); |
599 | 599 | if($code != 221) { |
600 | - // use e as a tmp var cause Close will overwrite $this->error |
|
601 | - $e = array("error" => "SMTP server rejected quit command", |
|
602 | - "smtp_code" => $code, |
|
603 | - "smtp_rply" => substr($byemsg,4)); |
|
604 | - $rval = false; |
|
605 | - if($this->do_debug >= 1) { |
|
600 | + // use e as a tmp var cause Close will overwrite $this->error |
|
601 | + $e = array("error" => "SMTP server rejected quit command", |
|
602 | + "smtp_code" => $code, |
|
603 | + "smtp_rply" => substr($byemsg,4)); |
|
604 | + $rval = false; |
|
605 | + if($this->do_debug >= 1) { |
|
606 | 606 | echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />'; |
607 | - } |
|
607 | + } |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | if(empty($e) || $close_on_error) { |
611 | - $this->Close(); |
|
611 | + $this->Close(); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | return $rval; |
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Sends the command RCPT to the SMTP server with the TO: argument of $to. |
|
619 | - * Returns true if the recipient was accepted false if it was rejected. |
|
620 | - * |
|
621 | - * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> |
|
622 | - * |
|
623 | - * SMTP CODE SUCCESS: 250,251 |
|
624 | - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 |
|
625 | - * SMTP CODE ERROR : 500,501,503,421 |
|
626 | - * @access public |
|
627 | - * @return bool |
|
628 | - */ |
|
629 | - public function Recipient($to) { |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Sends the command RCPT to the SMTP server with the TO: argument of $to. |
|
619 | + * Returns true if the recipient was accepted false if it was rejected. |
|
620 | + * |
|
621 | + * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF> |
|
622 | + * |
|
623 | + * SMTP CODE SUCCESS: 250,251 |
|
624 | + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 |
|
625 | + * SMTP CODE ERROR : 500,501,503,421 |
|
626 | + * @access public |
|
627 | + * @return bool |
|
628 | + */ |
|
629 | + public function Recipient($to) { |
|
630 | 630 | $this->error = null; // so no confusion is caused |
631 | 631 | |
632 | 632 | if(!$this->connected()) { |
633 | - $this->error = array( |
|
634 | - "error" => "Called Recipient() without being connected"); |
|
635 | - return false; |
|
633 | + $this->error = array( |
|
634 | + "error" => "Called Recipient() without being connected"); |
|
635 | + return false; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); |
@@ -641,41 +641,41 @@ discard block |
||
641 | 641 | $code = substr($rply,0,3); |
642 | 642 | |
643 | 643 | if($this->do_debug >= 2) { |
644 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
644 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | if($code != 250 && $code != 251) { |
648 | - $this->error = |
|
648 | + $this->error = |
|
649 | 649 | array("error" => "RCPT not accepted from server", |
650 | - "smtp_code" => $code, |
|
651 | - "smtp_msg" => substr($rply,4)); |
|
652 | - if($this->do_debug >= 1) { |
|
650 | + "smtp_code" => $code, |
|
651 | + "smtp_msg" => substr($rply,4)); |
|
652 | + if($this->do_debug >= 1) { |
|
653 | 653 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
654 | - } |
|
655 | - return false; |
|
654 | + } |
|
655 | + return false; |
|
656 | 656 | } |
657 | 657 | return true; |
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Sends the RSET command to abort and transaction that is |
|
662 | - * currently in progress. Returns true if successful false |
|
663 | - * otherwise. |
|
664 | - * |
|
665 | - * Implements rfc 821: RSET <CRLF> |
|
666 | - * |
|
667 | - * SMTP CODE SUCCESS: 250 |
|
668 | - * SMTP CODE ERROR : 500,501,504,421 |
|
669 | - * @access public |
|
670 | - * @return bool |
|
671 | - */ |
|
672 | - public function Reset() { |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Sends the RSET command to abort and transaction that is |
|
662 | + * currently in progress. Returns true if successful false |
|
663 | + * otherwise. |
|
664 | + * |
|
665 | + * Implements rfc 821: RSET <CRLF> |
|
666 | + * |
|
667 | + * SMTP CODE SUCCESS: 250 |
|
668 | + * SMTP CODE ERROR : 500,501,504,421 |
|
669 | + * @access public |
|
670 | + * @return bool |
|
671 | + */ |
|
672 | + public function Reset() { |
|
673 | 673 | $this->error = null; // so no confusion is caused |
674 | 674 | |
675 | 675 | if(!$this->connected()) { |
676 | - $this->error = array( |
|
677 | - "error" => "Called Reset() without being connected"); |
|
678 | - return false; |
|
676 | + $this->error = array( |
|
677 | + "error" => "Called Reset() without being connected"); |
|
678 | + return false; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | fputs($this->smtp_conn,"RSET" . $this->CRLF); |
@@ -684,46 +684,46 @@ discard block |
||
684 | 684 | $code = substr($rply,0,3); |
685 | 685 | |
686 | 686 | if($this->do_debug >= 2) { |
687 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
687 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if($code != 250) { |
691 | - $this->error = |
|
691 | + $this->error = |
|
692 | 692 | array("error" => "RSET failed", |
693 | - "smtp_code" => $code, |
|
694 | - "smtp_msg" => substr($rply,4)); |
|
695 | - if($this->do_debug >= 1) { |
|
693 | + "smtp_code" => $code, |
|
694 | + "smtp_msg" => substr($rply,4)); |
|
695 | + if($this->do_debug >= 1) { |
|
696 | 696 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
697 | - } |
|
698 | - return false; |
|
697 | + } |
|
698 | + return false; |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | return true; |
702 | - } |
|
703 | - |
|
704 | - /** |
|
705 | - * Starts a mail transaction from the email address specified in |
|
706 | - * $from. Returns true if successful or false otherwise. If True |
|
707 | - * the mail transaction is started and then one or more Recipient |
|
708 | - * commands may be called followed by a Data command. This command |
|
709 | - * will send the message to the users terminal if they are logged |
|
710 | - * in and send them an email. |
|
711 | - * |
|
712 | - * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> |
|
713 | - * |
|
714 | - * SMTP CODE SUCCESS: 250 |
|
715 | - * SMTP CODE SUCCESS: 552,451,452 |
|
716 | - * SMTP CODE SUCCESS: 500,501,502,421 |
|
717 | - * @access public |
|
718 | - * @return bool |
|
719 | - */ |
|
720 | - public function SendAndMail($from) { |
|
702 | + } |
|
703 | + |
|
704 | + /** |
|
705 | + * Starts a mail transaction from the email address specified in |
|
706 | + * $from. Returns true if successful or false otherwise. If True |
|
707 | + * the mail transaction is started and then one or more Recipient |
|
708 | + * commands may be called followed by a Data command. This command |
|
709 | + * will send the message to the users terminal if they are logged |
|
710 | + * in and send them an email. |
|
711 | + * |
|
712 | + * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF> |
|
713 | + * |
|
714 | + * SMTP CODE SUCCESS: 250 |
|
715 | + * SMTP CODE SUCCESS: 552,451,452 |
|
716 | + * SMTP CODE SUCCESS: 500,501,502,421 |
|
717 | + * @access public |
|
718 | + * @return bool |
|
719 | + */ |
|
720 | + public function SendAndMail($from) { |
|
721 | 721 | $this->error = null; // so no confusion is caused |
722 | 722 | |
723 | 723 | if(!$this->connected()) { |
724 | - $this->error = array( |
|
725 | - "error" => "Called SendAndMail() without being connected"); |
|
726 | - return false; |
|
724 | + $this->error = array( |
|
725 | + "error" => "Called SendAndMail() without being connected"); |
|
726 | + return false; |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); |
@@ -732,82 +732,82 @@ discard block |
||
732 | 732 | $code = substr($rply,0,3); |
733 | 733 | |
734 | 734 | if($this->do_debug >= 2) { |
735 | - echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
735 | + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />'; |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | if($code != 250) { |
739 | - $this->error = |
|
739 | + $this->error = |
|
740 | 740 | array("error" => "SAML not accepted from server", |
741 | - "smtp_code" => $code, |
|
742 | - "smtp_msg" => substr($rply,4)); |
|
743 | - if($this->do_debug >= 1) { |
|
741 | + "smtp_code" => $code, |
|
742 | + "smtp_msg" => substr($rply,4)); |
|
743 | + if($this->do_debug >= 1) { |
|
744 | 744 | echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />'; |
745 | - } |
|
746 | - return false; |
|
745 | + } |
|
746 | + return false; |
|
747 | 747 | } |
748 | 748 | return true; |
749 | - } |
|
750 | - |
|
751 | - /** |
|
752 | - * This is an optional command for SMTP that this class does not |
|
753 | - * support. This method is here to make the RFC821 Definition |
|
754 | - * complete for this class and __may__ be implimented in the future |
|
755 | - * |
|
756 | - * Implements from rfc 821: TURN <CRLF> |
|
757 | - * |
|
758 | - * SMTP CODE SUCCESS: 250 |
|
759 | - * SMTP CODE FAILURE: 502 |
|
760 | - * SMTP CODE ERROR : 500, 503 |
|
761 | - * @access public |
|
762 | - * @return bool |
|
763 | - */ |
|
764 | - public function Turn() { |
|
749 | + } |
|
750 | + |
|
751 | + /** |
|
752 | + * This is an optional command for SMTP that this class does not |
|
753 | + * support. This method is here to make the RFC821 Definition |
|
754 | + * complete for this class and __may__ be implimented in the future |
|
755 | + * |
|
756 | + * Implements from rfc 821: TURN <CRLF> |
|
757 | + * |
|
758 | + * SMTP CODE SUCCESS: 250 |
|
759 | + * SMTP CODE FAILURE: 502 |
|
760 | + * SMTP CODE ERROR : 500, 503 |
|
761 | + * @access public |
|
762 | + * @return bool |
|
763 | + */ |
|
764 | + public function Turn() { |
|
765 | 765 | $this->error = array("error" => "This method, TURN, of the SMTP ". |
766 | 766 | "is not implemented"); |
767 | 767 | if($this->do_debug >= 1) { |
768 | - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
768 | + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />'; |
|
769 | 769 | } |
770 | 770 | return false; |
771 | - } |
|
772 | - |
|
773 | - /** |
|
774 | - * Get the current error |
|
775 | - * @access public |
|
776 | - * @return array |
|
777 | - */ |
|
778 | - public function getError() { |
|
771 | + } |
|
772 | + |
|
773 | + /** |
|
774 | + * Get the current error |
|
775 | + * @access public |
|
776 | + * @return array |
|
777 | + */ |
|
778 | + public function getError() { |
|
779 | 779 | return $this->error; |
780 | - } |
|
781 | - |
|
782 | - ///////////////////////////////////////////////// |
|
783 | - // INTERNAL FUNCTIONS |
|
784 | - ///////////////////////////////////////////////// |
|
785 | - |
|
786 | - /** |
|
787 | - * Read in as many lines as possible |
|
788 | - * either before eof or socket timeout occurs on the operation. |
|
789 | - * With SMTP we can tell if we have more lines to read if the |
|
790 | - * 4th character is '-' symbol. If it is a space then we don't |
|
791 | - * need to read anything else. |
|
792 | - * @access private |
|
793 | - * @return string |
|
794 | - */ |
|
795 | - private function get_lines() { |
|
780 | + } |
|
781 | + |
|
782 | + ///////////////////////////////////////////////// |
|
783 | + // INTERNAL FUNCTIONS |
|
784 | + ///////////////////////////////////////////////// |
|
785 | + |
|
786 | + /** |
|
787 | + * Read in as many lines as possible |
|
788 | + * either before eof or socket timeout occurs on the operation. |
|
789 | + * With SMTP we can tell if we have more lines to read if the |
|
790 | + * 4th character is '-' symbol. If it is a space then we don't |
|
791 | + * need to read anything else. |
|
792 | + * @access private |
|
793 | + * @return string |
|
794 | + */ |
|
795 | + private function get_lines() { |
|
796 | 796 | $data = ""; |
797 | 797 | while($str = @fgets($this->smtp_conn,515)) { |
798 | - if($this->do_debug >= 4) { |
|
798 | + if($this->do_debug >= 4) { |
|
799 | 799 | echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />'; |
800 | 800 | echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />'; |
801 | - } |
|
802 | - $data .= $str; |
|
803 | - if($this->do_debug >= 4) { |
|
801 | + } |
|
802 | + $data .= $str; |
|
803 | + if($this->do_debug >= 4) { |
|
804 | 804 | echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />'; |
805 | - } |
|
806 | - // if 4th character is a space, we are done reading, break the loop |
|
807 | - if(substr($str,3,1) == " ") { break; } |
|
805 | + } |
|
806 | + // if 4th character is a space, we are done reading, break the loop |
|
807 | + if(substr($str,3,1) == " ") { break; } |
|
808 | 808 | } |
809 | 809 | return $data; |
810 | - } |
|
810 | + } |
|
811 | 811 | |
812 | 812 | } |
813 | 813 |