@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | ); |
27 | 27 | |
28 | 28 | public $ops = array( |
29 | - 'eq' => '=', //equal |
|
30 | - 'ne' => '<>', //not equal |
|
31 | - 'lt' => '<', //less than |
|
32 | - 'le' => '<=', //less than or equal |
|
33 | - 'gt' => '>', //greater than |
|
34 | - 'ge' => '>=', //greater than or equal |
|
35 | - 'bw' => 'LIKE', //begins with |
|
29 | + 'eq' => '=', //equal |
|
30 | + 'ne' => '<>', //not equal |
|
31 | + 'lt' => '<', //less than |
|
32 | + 'le' => '<=', //less than or equal |
|
33 | + 'gt' => '>', //greater than |
|
34 | + 'ge' => '>=', //greater than or equal |
|
35 | + 'bw' => 'LIKE', //begins with |
|
36 | 36 | 'bn' => 'NOT LIKE', //doesn't begin with |
37 | - 'in' => 'LIKE', //is in |
|
37 | + 'in' => 'LIKE', //is in |
|
38 | 38 | 'ni' => 'NOT LIKE', //is not in |
39 | - 'ew' => 'LIKE', //ends with |
|
39 | + 'ew' => 'LIKE', //ends with |
|
40 | 40 | 'en' => 'NOT LIKE', //doesn't end with |
41 | - 'cn' => 'LIKE', //contains |
|
41 | + 'cn' => 'LIKE', //contains |
|
42 | 42 | 'nc' => 'NOT LIKE' //doesn't contain |
43 | 43 | ); |
44 | 44 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | */ |
324 | 324 | public static function get_extra_fields_by_handler($handler) |
325 | 325 | { |
326 | - $types= array(); |
|
326 | + $types = array(); |
|
327 | 327 | $types[self::FIELD_TYPE_TEXT] = get_lang('FieldTypeText'); |
328 | 328 | $types[self::FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea'); |
329 | 329 | $types[self::FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio'); |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | // chzn-select doesn't work for sessions?? |
963 | 963 | $form->addElement( |
964 | 964 | 'select', |
965 | - 'extra_' . $field_details['variable'], |
|
965 | + 'extra_'.$field_details['variable'], |
|
966 | 966 | $field_details['display_text'], |
967 | 967 | $options, |
968 | 968 | array('id' => 'extra_'.$field_details['variable']) |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | |
1022 | 1022 | if (!$admin_permissions) { |
1023 | 1023 | if ($field_details['visible'] == 0) { |
1024 | - $form->freeze('extra_' . $field_details['variable']); |
|
1024 | + $form->freeze('extra_'.$field_details['variable']); |
|
1025 | 1025 | } |
1026 | 1026 | } |
1027 | 1027 | break; |
@@ -1369,9 +1369,9 @@ discard block |
||
1369 | 1369 | |
1370 | 1370 | if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) { |
1371 | 1371 | |
1372 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
1372 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
1373 | 1373 | $fieldTexts[] = Display::img( |
1374 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1374 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1375 | 1375 | $field_details['display_text'], |
1376 | 1376 | array('width' => '300') |
1377 | 1377 | ); |
@@ -1388,10 +1388,10 @@ discard block |
||
1388 | 1388 | $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
1389 | 1389 | $form->applyFilter('extra_'.$field_details['variable'], 'trim'); |
1390 | 1390 | |
1391 | - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1391 | + $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1392 | 1392 | $form->addRule( |
1393 | 1393 | 'extra_'.$field_details['variable'], |
1394 | - get_lang('OnlyImagesAllowed') . ' ('.implode(',', $allowed_picture_types).')', |
|
1394 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
1395 | 1395 | 'filetype', |
1396 | 1396 | $allowed_picture_types |
1397 | 1397 | ); |
@@ -1433,10 +1433,10 @@ discard block |
||
1433 | 1433 | if (is_array($extraData) && |
1434 | 1434 | array_key_exists($fieldVariable, $extraData) |
1435 | 1435 | ) { |
1436 | - if (file_exists(api_get_path(SYS_UPLOAD_PATH) . $extraData[$fieldVariable])) { |
|
1436 | + if (file_exists(api_get_path(SYS_UPLOAD_PATH).$extraData[$fieldVariable])) { |
|
1437 | 1437 | $fieldTexts[] = Display::url( |
1438 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1439 | - api_get_path(WEB_UPLOAD_PATH) . $extraData[$fieldVariable], |
|
1438 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1439 | + api_get_path(WEB_UPLOAD_PATH).$extraData[$fieldVariable], |
|
1440 | 1440 | array( |
1441 | 1441 | 'title' => $field_details['display_text'], |
1442 | 1442 | 'target' => '_blank' |
@@ -1486,12 +1486,12 @@ discard block |
||
1486 | 1486 | "extra_{$field_details['variable']}", |
1487 | 1487 | $field_details['display_text'] |
1488 | 1488 | ); |
1489 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
1489 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
1490 | 1490 | |
1491 | 1491 | if (!$admin_permissions) { |
1492 | 1492 | if ($field_details['visible'] == 0) { |
1493 | 1493 | $form->freeze( |
1494 | - 'extra_' . $field_details['variable'] |
|
1494 | + 'extra_'.$field_details['variable'] |
|
1495 | 1495 | ); |
1496 | 1496 | } |
1497 | 1497 | } |
@@ -1502,13 +1502,13 @@ discard block |
||
1502 | 1502 | $field_details['display_text'] |
1503 | 1503 | ); |
1504 | 1504 | $form->applyFilter( |
1505 | - 'extra_' . $field_details['variable'], |
|
1505 | + 'extra_'.$field_details['variable'], |
|
1506 | 1506 | 'stripslashes' |
1507 | 1507 | ); |
1508 | 1508 | if (!$admin_permissions) { |
1509 | 1509 | if ($field_details['visible'] == 0) { |
1510 | 1510 | $form->freeze( |
1511 | - 'extra_' . $field_details['variable'] |
|
1511 | + 'extra_'.$field_details['variable'] |
|
1512 | 1512 | ); |
1513 | 1513 | } |
1514 | 1514 | } |
@@ -1518,12 +1518,12 @@ discard block |
||
1518 | 1518 | "extra_{$field_details['variable']}", |
1519 | 1519 | $field_details['display_text'] |
1520 | 1520 | ); |
1521 | - $form->applyFilter('extra_' . $field_details['variable'], 'stripslashes'); |
|
1521 | + $form->applyFilter('extra_'.$field_details['variable'], 'stripslashes'); |
|
1522 | 1522 | |
1523 | 1523 | if (!$admin_permissions) { |
1524 | 1524 | if ($field_details['visible'] == 0) { |
1525 | 1525 | $form->freeze( |
1526 | - 'extra_' . $field_details['variable'] |
|
1526 | + 'extra_'.$field_details['variable'] |
|
1527 | 1527 | ); |
1528 | 1528 | } |
1529 | 1529 | } |
@@ -1534,13 +1534,13 @@ discard block |
||
1534 | 1534 | $field_details['display_text'] |
1535 | 1535 | ); |
1536 | 1536 | $form->applyFilter( |
1537 | - 'extra_' . $field_details['variable'], |
|
1537 | + 'extra_'.$field_details['variable'], |
|
1538 | 1538 | 'stripslashes' |
1539 | 1539 | ); |
1540 | 1540 | if (!$admin_permissions) { |
1541 | 1541 | if ($field_details['visible'] == 0) { |
1542 | 1542 | $form->freeze( |
1543 | - 'extra_' . $field_details['variable'] |
|
1543 | + 'extra_'.$field_details['variable'] |
|
1544 | 1544 | ); |
1545 | 1545 | } |
1546 | 1546 | } |
@@ -2221,19 +2221,19 @@ discard block |
||
2221 | 2221 | break; |
2222 | 2222 | } |
2223 | 2223 | |
2224 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
2224 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
2225 | 2225 | break; |
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | $image = Display::img( |
2229 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2229 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2230 | 2230 | $field['display_text'], |
2231 | 2231 | array('width' => '300') |
2232 | 2232 | ); |
2233 | 2233 | |
2234 | 2234 | $displayedValue = Display::url( |
2235 | 2235 | $image, |
2236 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2236 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2237 | 2237 | array('target' => '_blank') |
2238 | 2238 | ); |
2239 | 2239 | break; |
@@ -2242,13 +2242,13 @@ discard block |
||
2242 | 2242 | break; |
2243 | 2243 | } |
2244 | 2244 | |
2245 | - if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) { |
|
2245 | + if (!file_exists(api_get_path(SYS_UPLOAD_PATH).$valueData['value'])) { |
|
2246 | 2246 | break; |
2247 | 2247 | } |
2248 | 2248 | |
2249 | 2249 | $displayedValue = Display::url( |
2250 | 2250 | get_lang('Download'), |
2251 | - api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], |
|
2251 | + api_get_path(WEB_UPLOAD_PATH).$valueData['value'], |
|
2252 | 2252 | array( |
2253 | 2253 | 'title' => $field['display_text'], |
2254 | 2254 | 'target' => '_blank' |
@@ -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'].'>'; |
@@ -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, |
@@ -18,7 +18,7 @@ |
||
18 | 18 | //$PHPMAILER_LANG['invalid_email'] = 'Not sending, email address is invalid: '; |
19 | 19 | $PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.'; |
20 | 20 | //$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.'; |
21 | -$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' . |
|
21 | +$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية '. |
|
22 | 22 | 'فشل في الارسال لكل من : '; |
23 | 23 | $PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; |
24 | 24 | //$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License |
39 | 39 | */ |
40 | 40 | |
41 | -if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n"); |
|
41 | +if (version_compare(PHP_VERSION, '5.0.0', '<')) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n"); |
|
42 | 42 | |
43 | 43 | class PHPMailer { |
44 | 44 | |
@@ -50,64 +50,64 @@ discard block |
||
50 | 50 | * Email priority (1 = High, 3 = Normal, 5 = low). |
51 | 51 | * @var int |
52 | 52 | */ |
53 | - public $Priority = 3; |
|
53 | + public $Priority = 3; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Sets the CharSet of the message. |
57 | 57 | * @var string |
58 | 58 | */ |
59 | - public $CharSet = 'iso-8859-1'; |
|
59 | + public $CharSet = 'iso-8859-1'; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Sets the Content-type of the message. |
63 | 63 | * @var string |
64 | 64 | */ |
65 | - public $ContentType = 'text/plain'; |
|
65 | + public $ContentType = 'text/plain'; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Sets the Encoding of the message. Options for this are |
69 | 69 | * "8bit", "7bit", "binary", "base64", and "quoted-printable". |
70 | 70 | * @var string |
71 | 71 | */ |
72 | - public $Encoding = '8bit'; |
|
72 | + public $Encoding = '8bit'; |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Holds the most recent mailer error message. |
76 | 76 | * @var string |
77 | 77 | */ |
78 | - public $ErrorInfo = ''; |
|
78 | + public $ErrorInfo = ''; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Sets the From email address for the message. |
82 | 82 | * @var string |
83 | 83 | */ |
84 | - public $From = 'root@localhost'; |
|
84 | + public $From = 'root@localhost'; |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Sets the From name of the message. |
88 | 88 | * @var string |
89 | 89 | */ |
90 | - public $FromName = 'Root User'; |
|
90 | + public $FromName = 'Root User'; |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Sets the Sender email (Return-Path) of the message. If not empty, |
94 | 94 | * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. |
95 | 95 | * @var string |
96 | 96 | */ |
97 | - public $Sender = ''; |
|
97 | + public $Sender = ''; |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Sets the Subject of the message. |
101 | 101 | * @var string |
102 | 102 | */ |
103 | - public $Subject = ''; |
|
103 | + public $Subject = ''; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Sets the Body of the message. This can be either an HTML or text body. |
107 | 107 | * If HTML then run IsHTML(true). |
108 | 108 | * @var string |
109 | 109 | */ |
110 | - public $Body = ''; |
|
110 | + public $Body = ''; |
|
111 | 111 | |
112 | 112 | /** |
113 | 113 | * Sets the text-only body of the message. This automatically sets the |
@@ -116,39 +116,39 @@ discard block |
||
116 | 116 | * that can read HTML will view the normal Body. |
117 | 117 | * @var string |
118 | 118 | */ |
119 | - public $AltBody = ''; |
|
119 | + public $AltBody = ''; |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Sets word wrapping on the body of the message to a given number of |
123 | 123 | * characters. |
124 | 124 | * @var int |
125 | 125 | */ |
126 | - public $WordWrap = 0; |
|
126 | + public $WordWrap = 0; |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Method to send mail: ("mail", "sendmail", or "smtp"). |
130 | 130 | * @var string |
131 | 131 | */ |
132 | - public $Mailer = 'mail'; |
|
132 | + public $Mailer = 'mail'; |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Sets the path of the sendmail program. |
136 | 136 | * @var string |
137 | 137 | */ |
138 | - public $Sendmail = '/usr/sbin/sendmail'; |
|
138 | + public $Sendmail = '/usr/sbin/sendmail'; |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Path to PHPMailer plugins. Useful if the SMTP class |
142 | 142 | * is in a different directory than the PHP include path. |
143 | 143 | * @var string |
144 | 144 | */ |
145 | - public $PluginDir = ''; |
|
145 | + public $PluginDir = ''; |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Sets the email address that a reading confirmation will be sent. |
149 | 149 | * @var string |
150 | 150 | */ |
151 | - public $ConfirmReadingTo = ''; |
|
151 | + public $ConfirmReadingTo = ''; |
|
152 | 152 | |
153 | 153 | /** |
154 | 154 | * Sets the hostname to use in Message-Id and Received headers |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | * by SERVER_NAME is used or 'localhost.localdomain'. |
157 | 157 | * @var string |
158 | 158 | */ |
159 | - public $Hostname = ''; |
|
159 | + public $Hostname = ''; |
|
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Sets the message ID to be used in the Message-Id header. |
163 | 163 | * If empty, a unique id will be generated. |
164 | 164 | * @var string |
165 | 165 | */ |
166 | - public $MessageID = ''; |
|
166 | + public $MessageID = ''; |
|
167 | 167 | |
168 | 168 | ///////////////////////////////////////////////// |
169 | 169 | // PROPERTIES FOR SMTP |
@@ -177,57 +177,57 @@ discard block |
||
177 | 177 | * Hosts will be tried in order. |
178 | 178 | * @var string |
179 | 179 | */ |
180 | - public $Host = 'localhost'; |
|
180 | + public $Host = 'localhost'; |
|
181 | 181 | |
182 | 182 | /** |
183 | 183 | * Sets the default SMTP server port. |
184 | 184 | * @var int |
185 | 185 | */ |
186 | - public $Port = 25; |
|
186 | + public $Port = 25; |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * Sets the SMTP HELO of the message (Default is $Hostname). |
190 | 190 | * @var string |
191 | 191 | */ |
192 | - public $Helo = ''; |
|
192 | + public $Helo = ''; |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * Sets connection prefix. |
196 | 196 | * Options are "", "ssl" or "tls" |
197 | 197 | * @var string |
198 | 198 | */ |
199 | - public $SMTPSecure = ''; |
|
199 | + public $SMTPSecure = ''; |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Sets SMTP authentication. Utilizes the Username and Password variables. |
203 | 203 | * @var bool |
204 | 204 | */ |
205 | - public $SMTPAuth = false; |
|
205 | + public $SMTPAuth = false; |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Sets SMTP username. |
209 | 209 | * @var string |
210 | 210 | */ |
211 | - public $Username = ''; |
|
211 | + public $Username = ''; |
|
212 | 212 | |
213 | 213 | /** |
214 | 214 | * Sets SMTP password. |
215 | 215 | * @var string |
216 | 216 | */ |
217 | - public $Password = ''; |
|
217 | + public $Password = ''; |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * Sets the SMTP server timeout in seconds. |
221 | 221 | * This function will not work with the win32 version. |
222 | 222 | * @var int |
223 | 223 | */ |
224 | - public $Timeout = 10; |
|
224 | + public $Timeout = 10; |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Sets SMTP class debugging on or off. |
228 | 228 | * @var bool |
229 | 229 | */ |
230 | - public $SMTPDebug = false; |
|
230 | + public $SMTPDebug = false; |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Prevents the SMTP connection from being closed after each mail |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * emails, instead of sending to entire TO addresses |
243 | 243 | * @var bool |
244 | 244 | */ |
245 | - public $SingleTo = false; |
|
245 | + public $SingleTo = false; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * If SingleTo is true, this provides the array to hold the email addresses |
@@ -254,34 +254,34 @@ discard block |
||
254 | 254 | * Provides the ability to change the line ending |
255 | 255 | * @var string |
256 | 256 | */ |
257 | - public $LE = "\n"; |
|
257 | + public $LE = "\n"; |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Used with DKIM DNS Resource Record |
261 | 261 | * @var string |
262 | 262 | */ |
263 | - public $DKIM_selector = 'phpmailer'; |
|
263 | + public $DKIM_selector = 'phpmailer'; |
|
264 | 264 | |
265 | 265 | /** |
266 | 266 | * Used with DKIM DNS Resource Record |
267 | 267 | * optional, in format of email address '[email protected]' |
268 | 268 | * @var string |
269 | 269 | */ |
270 | - public $DKIM_identity = ''; |
|
270 | + public $DKIM_identity = ''; |
|
271 | 271 | |
272 | 272 | /** |
273 | 273 | * Used with DKIM DNS Resource Record |
274 | 274 | * optional, in format of email address '[email protected]' |
275 | 275 | * @var string |
276 | 276 | */ |
277 | - public $DKIM_domain = ''; |
|
277 | + public $DKIM_domain = ''; |
|
278 | 278 | |
279 | 279 | /** |
280 | 280 | * Used with DKIM DNS Resource Record |
281 | 281 | * optional, in format of email address '[email protected]' |
282 | 282 | * @var string |
283 | 283 | */ |
284 | - public $DKIM_private = ''; |
|
284 | + public $DKIM_private = ''; |
|
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Callback Action function name |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * Sets the PHPMailer Version number |
301 | 301 | * @var string |
302 | 302 | */ |
303 | - public $Version = '5.1'; |
|
303 | + public $Version = '5.1'; |
|
304 | 304 | |
305 | 305 | ///////////////////////////////////////////////// |
306 | 306 | // PROPERTIES, PRIVATE AND PROTECTED |
@@ -451,13 +451,13 @@ discard block |
||
451 | 451 | */ |
452 | 452 | private function AddAnAddress($kind, $address, $name = '') { |
453 | 453 | if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { |
454 | - error_log('Invalid recipient array: ' . $kind); |
|
454 | + error_log('Invalid recipient array: '.$kind); |
|
455 | 455 | return false; |
456 | 456 | } |
457 | 457 | $address = trim($address); |
458 | 458 | $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim |
459 | 459 | if (!self::ValidateAddress($address)) { |
460 | - $this->SetError($this->Lang('invalid_address').': '. $address); |
|
460 | + $this->SetError($this->Lang('invalid_address').': '.$address); |
|
461 | 461 | if ($this->exceptions) { |
462 | 462 | throw new phpmailerException($this->Lang('invalid_address').': '.$address); |
463 | 463 | } |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | * @param string $name |
486 | 486 | * @return boolean |
487 | 487 | */ |
488 | - public function SetFrom($address, $name = '',$auto=1) { |
|
488 | + public function SetFrom($address, $name = '', $auto = 1) { |
|
489 | 489 | $address = trim($address); |
490 | 490 | $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim |
491 | 491 | if (!self::ValidateAddress($address)) { |
492 | - $this->SetError($this->Lang('invalid_address').': '. $address); |
|
492 | + $this->SetError($this->Lang('invalid_address').': '.$address); |
|
493 | 493 | if ($this->exceptions) { |
494 | 494 | throw new phpmailerException($this->Lang('invalid_address').': '.$address); |
495 | 495 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public static function ValidateAddress($address) { |
524 | 524 | if (function_exists('filter_var')) { //Introduced in PHP 5.2 |
525 | - if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { |
|
525 | + if (filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { |
|
526 | 526 | return false; |
527 | 527 | } else { |
528 | 528 | return true; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | |
551 | 551 | // Set whether the message is multipart/alternative |
552 | - if(!empty($this->AltBody)) { |
|
552 | + if (!empty($this->AltBody)) { |
|
553 | 553 | $this->ContentType = 'multipart/alternative'; |
554 | 554 | } |
555 | 555 | |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | |
565 | 565 | // digitally sign with DKIM if enabled |
566 | 566 | if ($this->DKIM_domain && $this->DKIM_private) { |
567 | - $header_dkim = $this->DKIM_Add($header,$this->Subject,$body); |
|
568 | - $header = str_replace("\r\n","\n",$header_dkim) . $header; |
|
567 | + $header_dkim = $this->DKIM_Add($header, $this->Subject, $body); |
|
568 | + $header = str_replace("\r\n", "\n", $header_dkim).$header; |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | // Choose the mailer and send through it |
572 | - switch($this->Mailer) { |
|
572 | + switch ($this->Mailer) { |
|
573 | 573 | case 'sendmail': |
574 | 574 | return $this->SendmailSend($header, $body); |
575 | 575 | case 'smtp': |
@@ -602,32 +602,32 @@ discard block |
||
602 | 602 | } |
603 | 603 | if ($this->SingleTo === true) { |
604 | 604 | foreach ($this->SingleToArray as $key => $val) { |
605 | - if(!@$mail = popen($sendmail, 'w')) { |
|
606 | - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
605 | + if (!@$mail = popen($sendmail, 'w')) { |
|
606 | + throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
607 | 607 | } |
608 | - fputs($mail, "To: " . $val . "\n"); |
|
608 | + fputs($mail, "To: ".$val."\n"); |
|
609 | 609 | fputs($mail, $header); |
610 | 610 | fputs($mail, $body); |
611 | 611 | $result = pclose($mail); |
612 | 612 | // implement call back function if it exists |
613 | 613 | $isSent = ($result == 0) ? 1 : 0; |
614 | - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); |
|
615 | - if($result != 0) { |
|
616 | - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
614 | + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); |
|
615 | + if ($result != 0) { |
|
616 | + throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } else { |
620 | - if(!@$mail = popen($sendmail, 'w')) { |
|
621 | - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
620 | + if (!@$mail = popen($sendmail, 'w')) { |
|
621 | + throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
622 | 622 | } |
623 | 623 | fputs($mail, $header); |
624 | 624 | fputs($mail, $body); |
625 | 625 | $result = pclose($mail); |
626 | 626 | // implement call back function if it exists |
627 | 627 | $isSent = ($result == 0) ? 1 : 0; |
628 | - $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body); |
|
629 | - if($result != 0) { |
|
630 | - throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); |
|
628 | + $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body); |
|
629 | + if ($result != 0) { |
|
630 | + throw new phpmailerException($this->Lang('execute').$this->Sendmail, self::STOP_CRITICAL); |
|
631 | 631 | } |
632 | 632 | } |
633 | 633 | return true; |
@@ -642,13 +642,13 @@ discard block |
||
642 | 642 | */ |
643 | 643 | protected function MailSend($header, $body) { |
644 | 644 | $toArr = array(); |
645 | - foreach($this->to as $t) { |
|
645 | + foreach ($this->to as $t) { |
|
646 | 646 | $toArr[] = $this->AddrFormat($t); |
647 | 647 | } |
648 | 648 | $to = implode(', ', $toArr); |
649 | 649 | |
650 | 650 | $params = sprintf("-oi -f %s", $this->Sender); |
651 | - if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { |
|
651 | + if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) { |
|
652 | 652 | $old_from = ini_get('sendmail_from'); |
653 | 653 | ini_set('sendmail_from', $this->Sender); |
654 | 654 | if ($this->SingleTo === true && count($toArr) > 1) { |
@@ -656,13 +656,13 @@ discard block |
||
656 | 656 | $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); |
657 | 657 | // implement call back function if it exists |
658 | 658 | $isSent = ($rt == 1) ? 1 : 0; |
659 | - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); |
|
659 | + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); |
|
660 | 660 | } |
661 | 661 | } else { |
662 | 662 | $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); |
663 | 663 | // implement call back function if it exists |
664 | 664 | $isSent = ($rt == 1) ? 1 : 0; |
665 | - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); |
|
665 | + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); |
|
666 | 666 | } |
667 | 667 | } else { |
668 | 668 | if ($this->SingleTo === true && count($toArr) > 1) { |
@@ -670,19 +670,19 @@ discard block |
||
670 | 670 | $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); |
671 | 671 | // implement call back function if it exists |
672 | 672 | $isSent = ($rt == 1) ? 1 : 0; |
673 | - $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); |
|
673 | + $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body); |
|
674 | 674 | } |
675 | 675 | } else { |
676 | 676 | $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); |
677 | 677 | // implement call back function if it exists |
678 | 678 | $isSent = ($rt == 1) ? 1 : 0; |
679 | - $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); |
|
679 | + $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body); |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | if (isset($old_from)) { |
683 | 683 | ini_set('sendmail_from', $old_from); |
684 | 684 | } |
685 | - if(!$rt) { |
|
685 | + if (!$rt) { |
|
686 | 686 | throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL); |
687 | 687 | } |
688 | 688 | return true; |
@@ -698,64 +698,64 @@ discard block |
||
698 | 698 | * @return bool |
699 | 699 | */ |
700 | 700 | protected function SmtpSend($header, $body) { |
701 | - require_once $this->PluginDir . 'class.smtp.php'; |
|
701 | + require_once $this->PluginDir.'class.smtp.php'; |
|
702 | 702 | $bad_rcpt = array(); |
703 | 703 | |
704 | - if(!$this->SmtpConnect()) { |
|
704 | + if (!$this->SmtpConnect()) { |
|
705 | 705 | throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL); |
706 | 706 | } |
707 | 707 | $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; |
708 | - if(!$this->smtp->Mail($smtp_from)) { |
|
709 | - throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL); |
|
708 | + if (!$this->smtp->Mail($smtp_from)) { |
|
709 | + throw new phpmailerException($this->Lang('from_failed').$smtp_from, self::STOP_CRITICAL); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | // Attempt to send attach all recipients |
713 | - foreach($this->to as $to) { |
|
713 | + foreach ($this->to as $to) { |
|
714 | 714 | if (!$this->smtp->Recipient($to[0])) { |
715 | 715 | $bad_rcpt[] = $to[0]; |
716 | 716 | // implement call back function if it exists |
717 | 717 | $isSent = 0; |
718 | - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); |
|
718 | + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); |
|
719 | 719 | } else { |
720 | 720 | // implement call back function if it exists |
721 | 721 | $isSent = 1; |
722 | - $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); |
|
722 | + $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body); |
|
723 | 723 | } |
724 | 724 | } |
725 | - foreach($this->cc as $cc) { |
|
725 | + foreach ($this->cc as $cc) { |
|
726 | 726 | if (!$this->smtp->Recipient($cc[0])) { |
727 | 727 | $bad_rcpt[] = $cc[0]; |
728 | 728 | // implement call back function if it exists |
729 | 729 | $isSent = 0; |
730 | - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); |
|
730 | + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); |
|
731 | 731 | } else { |
732 | 732 | // implement call back function if it exists |
733 | 733 | $isSent = 1; |
734 | - $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); |
|
734 | + $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body); |
|
735 | 735 | } |
736 | 736 | } |
737 | - foreach($this->bcc as $bcc) { |
|
737 | + foreach ($this->bcc as $bcc) { |
|
738 | 738 | if (!$this->smtp->Recipient($bcc[0])) { |
739 | 739 | $bad_rcpt[] = $bcc[0]; |
740 | 740 | // implement call back function if it exists |
741 | 741 | $isSent = 0; |
742 | - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); |
|
742 | + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); |
|
743 | 743 | } else { |
744 | 744 | // implement call back function if it exists |
745 | 745 | $isSent = 1; |
746 | - $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); |
|
746 | + $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body); |
|
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | 750 | |
751 | - if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses |
|
751 | + if (count($bad_rcpt) > 0) { //Create error message for any bad addresses |
|
752 | 752 | $badaddresses = implode(', ', $bad_rcpt); |
753 | - throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses); |
|
753 | + throw new phpmailerException($this->Lang('recipients_failed').$badaddresses); |
|
754 | 754 | } |
755 | - if(!$this->smtp->Data($header . $body)) { |
|
755 | + if (!$this->smtp->Data($header.$body)) { |
|
756 | 756 | throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL); |
757 | 757 | } |
758 | - if($this->SMTPKeepAlive == true) { |
|
758 | + if ($this->SMTPKeepAlive == true) { |
|
759 | 759 | $this->smtp->Reset(); |
760 | 760 | } |
761 | 761 | return true; |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * @return bool |
770 | 770 | */ |
771 | 771 | public function SmtpConnect() { |
772 | - if(is_null($this->smtp)) { |
|
772 | + if (is_null($this->smtp)) { |
|
773 | 773 | $this->smtp = new SMTP(); |
774 | 774 | } |
775 | 775 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | |
781 | 781 | // Retry while there is no connection |
782 | 782 | try { |
783 | - while($index < count($hosts) && !$connection) { |
|
783 | + while ($index < count($hosts) && !$connection) { |
|
784 | 784 | $hostinfo = array(); |
785 | 785 | if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { |
786 | 786 | $host = $hostinfo[1]; |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | $tls = ($this->SMTPSecure == 'tls'); |
794 | 794 | $ssl = ($this->SMTPSecure == 'ssl'); |
795 | 795 | |
796 | - if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { |
|
796 | + if ($this->smtp->Connect(($ssl ? 'ssl://' : '').$host, $port, $this->Timeout)) { |
|
797 | 797 | |
798 | 798 | $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); |
799 | 799 | $this->smtp->Hello($hello); |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | * @return void |
832 | 832 | */ |
833 | 833 | public function SmtpClose() { |
834 | - if(!is_null($this->smtp)) { |
|
835 | - if($this->smtp->Connected()) { |
|
834 | + if (!is_null($this->smtp)) { |
|
835 | + if ($this->smtp->Connected()) { |
|
836 | 836 | $this->smtp->Quit(); |
837 | 837 | $this->smtp->Close(); |
838 | 838 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | * @return string |
895 | 895 | */ |
896 | 896 | public function AddrAppend($type, $addr) { |
897 | - $addr_str = $type . ': '; |
|
897 | + $addr_str = $type.': '; |
|
898 | 898 | $addresses = array(); |
899 | 899 | foreach ($addr as $a) { |
900 | 900 | $addresses[] = $this->AddrFormat($a); |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | if (empty($addr[1])) { |
915 | 915 | return $this->SecureHeader($addr[0]); |
916 | 916 | } else { |
917 | - return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; |
|
917 | + return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase')." <".$this->SecureHeader($addr[0]).">"; |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | |
@@ -941,10 +941,10 @@ discard block |
||
941 | 941 | |
942 | 942 | $line = explode($this->LE, $message); |
943 | 943 | $message = ''; |
944 | - for ($i=0 ;$i < count($line); $i++) { |
|
944 | + for ($i = 0; $i < count($line); $i++) { |
|
945 | 945 | $line_part = explode(' ', $line[$i]); |
946 | 946 | $buf = ''; |
947 | - for ($e = 0; $e<count($line_part); $e++) { |
|
947 | + for ($e = 0; $e < count($line_part); $e++) { |
|
948 | 948 | $word = $line_part[$e]; |
949 | 949 | if ($qp_mode and (strlen($word) > $length)) { |
950 | 950 | $space_left = $length - strlen($buf) - 1; |
@@ -960,10 +960,10 @@ discard block |
||
960 | 960 | } |
961 | 961 | $part = substr($word, 0, $len); |
962 | 962 | $word = substr($word, $len); |
963 | - $buf .= ' ' . $part; |
|
964 | - $message .= $buf . sprintf("=%s", $this->LE); |
|
963 | + $buf .= ' '.$part; |
|
964 | + $message .= $buf.sprintf("=%s", $this->LE); |
|
965 | 965 | } else { |
966 | - $message .= $buf . $soft_break; |
|
966 | + $message .= $buf.$soft_break; |
|
967 | 967 | } |
968 | 968 | $buf = ''; |
969 | 969 | } |
@@ -980,22 +980,22 @@ discard block |
||
980 | 980 | $word = substr($word, $len); |
981 | 981 | |
982 | 982 | if (strlen($word) > 0) { |
983 | - $message .= $part . sprintf("=%s", $this->LE); |
|
983 | + $message .= $part.sprintf("=%s", $this->LE); |
|
984 | 984 | } else { |
985 | 985 | $buf = $part; |
986 | 986 | } |
987 | 987 | } |
988 | 988 | } else { |
989 | 989 | $buf_o = $buf; |
990 | - $buf .= ($e == 0) ? $word : (' ' . $word); |
|
990 | + $buf .= ($e == 0) ? $word : (' '.$word); |
|
991 | 991 | |
992 | 992 | if (strlen($buf) > $length and $buf_o != '') { |
993 | - $message .= $buf_o . $soft_break; |
|
993 | + $message .= $buf_o.$soft_break; |
|
994 | 994 | $buf = $word; |
995 | 995 | } |
996 | 996 | } |
997 | 997 | } |
998 | - $message .= $buf . $this->LE; |
|
998 | + $message .= $buf.$this->LE; |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | return $message; |
@@ -1024,8 +1024,7 @@ discard block |
||
1024 | 1024 | if ($dec < 128) { // Single byte character. |
1025 | 1025 | // If the encoded char was found at pos 0, it will fit |
1026 | 1026 | // otherwise reduce maxLength to start of the encoded char |
1027 | - $maxLength = ($encodedCharPos == 0) ? $maxLength : |
|
1028 | - $maxLength - ($lookBack - $encodedCharPos); |
|
1027 | + $maxLength = ($encodedCharPos == 0) ? $maxLength : $maxLength - ($lookBack - $encodedCharPos); |
|
1029 | 1028 | $foundSplitPos = true; |
1030 | 1029 | } elseif ($dec >= 192) { // First byte of a multi byte character |
1031 | 1030 | // Reduce maxLength to split at start of character |
@@ -1049,11 +1048,11 @@ discard block |
||
1049 | 1048 | * @return void |
1050 | 1049 | */ |
1051 | 1050 | public function SetWordWrap() { |
1052 | - if($this->WordWrap < 1) { |
|
1051 | + if ($this->WordWrap < 1) { |
|
1053 | 1052 | return; |
1054 | 1053 | } |
1055 | 1054 | |
1056 | - switch($this->message_type) { |
|
1055 | + switch ($this->message_type) { |
|
1057 | 1056 | case 'alt': |
1058 | 1057 | case 'alt_attachments': |
1059 | 1058 | $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); |
@@ -1074,24 +1073,24 @@ discard block |
||
1074 | 1073 | |
1075 | 1074 | // Set the boundaries |
1076 | 1075 | $uniq_id = md5(uniqid(time())); |
1077 | - $this->boundary[1] = 'b1_' . $uniq_id; |
|
1078 | - $this->boundary[2] = 'b2_' . $uniq_id; |
|
1076 | + $this->boundary[1] = 'b1_'.$uniq_id; |
|
1077 | + $this->boundary[2] = 'b2_'.$uniq_id; |
|
1079 | 1078 | |
1080 | 1079 | $result .= $this->HeaderLine('Date', self::RFCDate()); |
1081 | - if($this->Sender == '') { |
|
1080 | + if ($this->Sender == '') { |
|
1082 | 1081 | $result .= $this->HeaderLine('Return-Path', trim($this->From)); |
1083 | 1082 | } else { |
1084 | 1083 | $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); |
1085 | 1084 | } |
1086 | 1085 | |
1087 | 1086 | // To be created automatically by mail() |
1088 | - if($this->Mailer != 'mail') { |
|
1087 | + if ($this->Mailer != 'mail') { |
|
1089 | 1088 | if ($this->SingleTo === true) { |
1090 | - foreach($this->to as $t) { |
|
1089 | + foreach ($this->to as $t) { |
|
1091 | 1090 | $this->SingleToArray[] = $this->AddrFormat($t); |
1092 | 1091 | } |
1093 | 1092 | } else { |
1094 | - if(count($this->to) > 0) { |
|
1093 | + if (count($this->to) > 0) { |
|
1095 | 1094 | $result .= $this->AddrAppend('To', $this->to); |
1096 | 1095 | } elseif (count($this->cc) == 0) { |
1097 | 1096 | $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); |
@@ -1105,38 +1104,38 @@ discard block |
||
1105 | 1104 | $result .= $this->AddrAppend('From', $from); |
1106 | 1105 | |
1107 | 1106 | // sendmail and mail() extract Cc from the header before sending |
1108 | - if(count($this->cc) > 0) { |
|
1107 | + if (count($this->cc) > 0) { |
|
1109 | 1108 | $result .= $this->AddrAppend('Cc', $this->cc); |
1110 | 1109 | } |
1111 | 1110 | |
1112 | 1111 | // sendmail and mail() extract Bcc from the header before sending |
1113 | - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { |
|
1112 | + if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { |
|
1114 | 1113 | $result .= $this->AddrAppend('Bcc', $this->bcc); |
1115 | 1114 | } |
1116 | 1115 | |
1117 | - if(count($this->ReplyTo) > 0) { |
|
1116 | + if (count($this->ReplyTo) > 0) { |
|
1118 | 1117 | $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); |
1119 | 1118 | } |
1120 | 1119 | |
1121 | 1120 | // mail() sets the subject itself |
1122 | - if($this->Mailer != 'mail') { |
|
1121 | + if ($this->Mailer != 'mail') { |
|
1123 | 1122 | $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); |
1124 | 1123 | } |
1125 | 1124 | |
1126 | - if($this->MessageID != '') { |
|
1127 | - $result .= $this->HeaderLine('Message-ID',$this->MessageID); |
|
1125 | + if ($this->MessageID != '') { |
|
1126 | + $result .= $this->HeaderLine('Message-ID', $this->MessageID); |
|
1128 | 1127 | } else { |
1129 | 1128 | $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); |
1130 | 1129 | } |
1131 | 1130 | $result .= $this->HeaderLine('X-Priority', $this->Priority); |
1132 | 1131 | $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)'); |
1133 | 1132 | |
1134 | - if($this->ConfirmReadingTo != '') { |
|
1135 | - $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); |
|
1133 | + if ($this->ConfirmReadingTo != '') { |
|
1134 | + $result .= $this->HeaderLine('Disposition-Notification-To', '<'.trim($this->ConfirmReadingTo).'>'); |
|
1136 | 1135 | } |
1137 | 1136 | |
1138 | 1137 | // Add custom headers |
1139 | - for($index = 0; $index < count($this->CustomHeader); $index++) { |
|
1138 | + for ($index = 0; $index < count($this->CustomHeader); $index++) { |
|
1140 | 1139 | $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); |
1141 | 1140 | } |
1142 | 1141 | if (!$this->sign_key_file) { |
@@ -1154,27 +1153,27 @@ discard block |
||
1154 | 1153 | */ |
1155 | 1154 | public function GetMailMIME() { |
1156 | 1155 | $result = ''; |
1157 | - switch($this->message_type) { |
|
1156 | + switch ($this->message_type) { |
|
1158 | 1157 | case 'plain': |
1159 | 1158 | $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); |
1160 | 1159 | $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); |
1161 | 1160 | break; |
1162 | 1161 | case 'attachments': |
1163 | 1162 | case 'alt_attachments': |
1164 | - if($this->InlineImageExists()){ |
|
1163 | + if ($this->InlineImageExists()) { |
|
1165 | 1164 | $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); |
1166 | 1165 | } else { |
1167 | 1166 | $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); |
1168 | - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
1167 | + $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"'); |
|
1169 | 1168 | } |
1170 | 1169 | break; |
1171 | 1170 | case 'alt': |
1172 | 1171 | $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); |
1173 | - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); |
|
1172 | + $result .= $this->TextLine("\tboundary=\"".$this->boundary[1].'"'); |
|
1174 | 1173 | break; |
1175 | 1174 | } |
1176 | 1175 | |
1177 | - if($this->Mailer != 'mail') { |
|
1176 | + if ($this->Mailer != 'mail') { |
|
1178 | 1177 | $result .= $this->LE.$this->LE; |
1179 | 1178 | } |
1180 | 1179 | |
@@ -1195,7 +1194,7 @@ discard block |
||
1195 | 1194 | |
1196 | 1195 | $this->SetWordWrap(); |
1197 | 1196 | |
1198 | - switch($this->message_type) { |
|
1197 | + switch ($this->message_type) { |
|
1199 | 1198 | case 'alt': |
1200 | 1199 | $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); |
1201 | 1200 | $body .= $this->EncodeString($this->AltBody, $this->Encoding); |
@@ -1216,11 +1215,11 @@ discard block |
||
1216 | 1215 | break; |
1217 | 1216 | case 'alt_attachments': |
1218 | 1217 | $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); |
1219 | - $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); |
|
1220 | - $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body |
|
1218 | + $body .= sprintf("Content-Type: %s;%s"."\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); |
|
1219 | + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '').$this->LE; // Create text body |
|
1221 | 1220 | $body .= $this->EncodeString($this->AltBody, $this->Encoding); |
1222 | 1221 | $body .= $this->LE.$this->LE; |
1223 | - $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body |
|
1222 | + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '').$this->LE; // Create the HTML body |
|
1224 | 1223 | $body .= $this->EncodeString($this->Body, $this->Encoding); |
1225 | 1224 | $body .= $this->LE.$this->LE; |
1226 | 1225 | $body .= $this->EndBoundary($this->boundary[2]); |
@@ -1261,16 +1260,16 @@ discard block |
||
1261 | 1260 | */ |
1262 | 1261 | private function GetBoundary($boundary, $charSet, $contentType, $encoding) { |
1263 | 1262 | $result = ''; |
1264 | - if($charSet == '') { |
|
1263 | + if ($charSet == '') { |
|
1265 | 1264 | $charSet = $this->CharSet; |
1266 | 1265 | } |
1267 | - if($contentType == '') { |
|
1266 | + if ($contentType == '') { |
|
1268 | 1267 | $contentType = $this->ContentType; |
1269 | 1268 | } |
1270 | - if($encoding == '') { |
|
1269 | + if ($encoding == '') { |
|
1271 | 1270 | $encoding = $this->Encoding; |
1272 | 1271 | } |
1273 | - $result .= $this->TextLine('--' . $boundary); |
|
1272 | + $result .= $this->TextLine('--'.$boundary); |
|
1274 | 1273 | $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); |
1275 | 1274 | $result .= $this->LE; |
1276 | 1275 | $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); |
@@ -1284,7 +1283,7 @@ discard block |
||
1284 | 1283 | * @access private |
1285 | 1284 | */ |
1286 | 1285 | private function EndBoundary($boundary) { |
1287 | - return $this->LE . '--' . $boundary . '--' . $this->LE; |
|
1286 | + return $this->LE.'--'.$boundary.'--'.$this->LE; |
|
1288 | 1287 | } |
1289 | 1288 | |
1290 | 1289 | /** |
@@ -1293,16 +1292,16 @@ discard block |
||
1293 | 1292 | * @return void |
1294 | 1293 | */ |
1295 | 1294 | private function SetMessageType() { |
1296 | - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { |
|
1295 | + if (count($this->attachment) < 1 && strlen($this->AltBody) < 1) { |
|
1297 | 1296 | $this->message_type = 'plain'; |
1298 | 1297 | } else { |
1299 | - if(count($this->attachment) > 0) { |
|
1298 | + if (count($this->attachment) > 0) { |
|
1300 | 1299 | $this->message_type = 'attachments'; |
1301 | 1300 | } |
1302 | - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { |
|
1301 | + if (strlen($this->AltBody) > 0 && count($this->attachment) < 1) { |
|
1303 | 1302 | $this->message_type = 'alt'; |
1304 | 1303 | } |
1305 | - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { |
|
1304 | + if (strlen($this->AltBody) > 0 && count($this->attachment) > 0) { |
|
1306 | 1305 | $this->message_type = 'alt_attachments'; |
1307 | 1306 | } |
1308 | 1307 | } |
@@ -1314,7 +1313,7 @@ discard block |
||
1314 | 1313 | * @return string |
1315 | 1314 | */ |
1316 | 1315 | public function HeaderLine($name, $value) { |
1317 | - return $name . ': ' . $value . $this->LE; |
|
1316 | + return $name.': '.$value.$this->LE; |
|
1318 | 1317 | } |
1319 | 1318 | |
1320 | 1319 | /** |
@@ -1323,7 +1322,7 @@ discard block |
||
1323 | 1322 | * @return string |
1324 | 1323 | */ |
1325 | 1324 | public function TextLine($value) { |
1326 | - return $value . $this->LE; |
|
1325 | + return $value.$this->LE; |
|
1327 | 1326 | } |
1328 | 1327 | |
1329 | 1328 | ///////////////////////////////////////////////// |
@@ -1342,11 +1341,11 @@ discard block |
||
1342 | 1341 | */ |
1343 | 1342 | public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { |
1344 | 1343 | try { |
1345 | - if ( !@is_file($path) ) { |
|
1346 | - throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE); |
|
1344 | + if (!@is_file($path)) { |
|
1345 | + throw new phpmailerException($this->Lang('file_access').$path, self::STOP_CONTINUE); |
|
1347 | 1346 | } |
1348 | 1347 | $filename = basename($path); |
1349 | - if ( $name == '' ) { |
|
1348 | + if ($name == '') { |
|
1350 | 1349 | $name = $filename; |
1351 | 1350 | } |
1352 | 1351 | |
@@ -1356,7 +1355,7 @@ discard block |
||
1356 | 1355 | 2 => $name, |
1357 | 1356 | 3 => $encoding, |
1358 | 1357 | 4 => $type, |
1359 | - 5 => false, // isStringAttachment |
|
1358 | + 5 => false, // isStringAttachment |
|
1360 | 1359 | 6 => 'attachment', |
1361 | 1360 | 7 => 0 |
1362 | 1361 | ); |
@@ -1367,7 +1366,7 @@ discard block |
||
1367 | 1366 | throw $e; |
1368 | 1367 | } |
1369 | 1368 | error_log($e->getMessage()."\n"); |
1370 | - if ( $e->getCode() == self::STOP_CRITICAL ) { |
|
1369 | + if ($e->getCode() == self::STOP_CRITICAL) { |
|
1371 | 1370 | return false; |
1372 | 1371 | } |
1373 | 1372 | } |
@@ -1412,29 +1411,29 @@ discard block |
||
1412 | 1411 | $disposition = $attachment[6]; |
1413 | 1412 | $cid = $attachment[7]; |
1414 | 1413 | $incl[] = $attachment[0]; |
1415 | - if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } |
|
1414 | + if ($disposition == 'inline' && isset($cidUniq[$cid])) { continue; } |
|
1416 | 1415 | $cidUniq[$cid] = true; |
1417 | 1416 | |
1418 | 1417 | $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); |
1419 | 1418 | $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); |
1420 | 1419 | $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); |
1421 | 1420 | |
1422 | - if($disposition == 'inline') { |
|
1421 | + if ($disposition == 'inline') { |
|
1423 | 1422 | $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); |
1424 | 1423 | } |
1425 | 1424 | |
1426 | 1425 | $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); |
1427 | 1426 | |
1428 | 1427 | // Encode as string attachment |
1429 | - if($bString) { |
|
1428 | + if ($bString) { |
|
1430 | 1429 | $mime[] = $this->EncodeString($string, $encoding); |
1431 | - if($this->IsError()) { |
|
1430 | + if ($this->IsError()) { |
|
1432 | 1431 | return ''; |
1433 | 1432 | } |
1434 | 1433 | $mime[] = $this->LE.$this->LE; |
1435 | 1434 | } else { |
1436 | 1435 | $mime[] = $this->EncodeFile($path, $encoding); |
1437 | - if($this->IsError()) { |
|
1436 | + if ($this->IsError()) { |
|
1438 | 1437 | return ''; |
1439 | 1438 | } |
1440 | 1439 | $mime[] = $this->LE.$this->LE; |
@@ -1458,7 +1457,7 @@ discard block |
||
1458 | 1457 | private function EncodeFile($path, $encoding = 'base64') { |
1459 | 1458 | try { |
1460 | 1459 | if (!is_readable($path)) { |
1461 | - throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); |
|
1460 | + throw new phpmailerException($this->Lang('file_open').$path, self::STOP_CONTINUE); |
|
1462 | 1461 | } |
1463 | 1462 | $magic_quotes = get_magic_quotes_runtime(); |
1464 | 1463 | if ($magic_quotes) { |
@@ -1492,9 +1491,9 @@ discard block |
||
1492 | 1491 | * @access public |
1493 | 1492 | * @return string |
1494 | 1493 | */ |
1495 | - public function EncodeString ($str, $encoding = 'base64') { |
|
1494 | + public function EncodeString($str, $encoding = 'base64') { |
|
1496 | 1495 | $encoded = ''; |
1497 | - switch(strtolower($encoding)) { |
|
1496 | + switch (strtolower($encoding)) { |
|
1498 | 1497 | case 'base64': |
1499 | 1498 | $encoded = chunk_split(base64_encode($str), 76, $this->LE); |
1500 | 1499 | break; |
@@ -1512,7 +1511,7 @@ discard block |
||
1512 | 1511 | $encoded = $this->EncodeQP($str); |
1513 | 1512 | break; |
1514 | 1513 | default: |
1515 | - $this->SetError($this->Lang('encoding') . $encoding); |
|
1514 | + $this->SetError($this->Lang('encoding').$encoding); |
|
1516 | 1515 | break; |
1517 | 1516 | } |
1518 | 1517 | return $encoded; |
@@ -1554,7 +1553,7 @@ discard block |
||
1554 | 1553 | |
1555 | 1554 | $maxlen = 75 - 7 - strlen($this->CharSet); |
1556 | 1555 | // Try to select the encoding which should produce the shortest output |
1557 | - if (strlen($str)/3 < $x) { |
|
1556 | + if (strlen($str) / 3 < $x) { |
|
1558 | 1557 | $encoding = 'B'; |
1559 | 1558 | // Modified by Ivan Tcholakov, 24-JAN-2010. |
1560 | 1559 | //if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { |
@@ -1635,7 +1634,7 @@ discard block |
||
1635 | 1634 | } |
1636 | 1635 | while (strlen($chunk) > $length); |
1637 | 1636 | |
1638 | - $encoded .= $chunk . $this->LE; |
|
1637 | + $encoded .= $chunk.$this->LE; |
|
1639 | 1638 | } |
1640 | 1639 | |
1641 | 1640 | // Chomp the last linefeed |
@@ -1651,37 +1650,37 @@ discard block |
||
1651 | 1650 | * @param integer $line_max Number of chars allowed on a line before wrapping |
1652 | 1651 | * @return string |
1653 | 1652 | */ |
1654 | - public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { |
|
1655 | - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
1653 | + public function EncodeQPphp($input = '', $line_max = 76, $space_conv = false) { |
|
1654 | + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
1656 | 1655 | $lines = preg_split('/(?:\r\n|\r|\n)/', $input); |
1657 | 1656 | $eol = "\r\n"; |
1658 | 1657 | $escape = '='; |
1659 | 1658 | $output = ''; |
1660 | - while( list(, $line) = each($lines) ) { |
|
1659 | + while (list(, $line) = each($lines)) { |
|
1661 | 1660 | $linlen = strlen($line); |
1662 | 1661 | $newline = ''; |
1663 | - for($i = 0; $i < $linlen; $i++) { |
|
1664 | - $c = substr( $line, $i, 1 ); |
|
1665 | - $dec = ord( $c ); |
|
1666 | - if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E |
|
1662 | + for ($i = 0; $i < $linlen; $i++) { |
|
1663 | + $c = substr($line, $i, 1); |
|
1664 | + $dec = ord($c); |
|
1665 | + if (($i == 0) && ($dec == 46)) { // convert first point in the line into =2E |
|
1667 | 1666 | $c = '=2E'; |
1668 | 1667 | } |
1669 | - if ( $dec == 32 ) { |
|
1670 | - if ( $i == ( $linlen - 1 ) ) { // convert space at eol only |
|
1668 | + if ($dec == 32) { |
|
1669 | + if ($i == ($linlen - 1)) { // convert space at eol only |
|
1671 | 1670 | $c = '=20'; |
1672 | - } else if ( $space_conv ) { |
|
1671 | + } else if ($space_conv) { |
|
1673 | 1672 | $c = '=20'; |
1674 | 1673 | } |
1675 | - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required |
|
1676 | - $h2 = floor($dec/16); |
|
1677 | - $h1 = floor($dec%16); |
|
1674 | + } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
1675 | + $h2 = floor($dec / 16); |
|
1676 | + $h1 = floor($dec % 16); |
|
1678 | 1677 | $c = $escape.$hex[$h2].$hex[$h1]; |
1679 | 1678 | } |
1680 | - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted |
|
1679 | + if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
1681 | 1680 | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
1682 | 1681 | $newline = ''; |
1683 | 1682 | // check if newline first character will be point or not |
1684 | - if ( $dec == 46 ) { |
|
1683 | + if ($dec == 46) { |
|
1685 | 1684 | $c = '=2E'; |
1686 | 1685 | } |
1687 | 1686 | } |
@@ -1733,7 +1732,7 @@ discard block |
||
1733 | 1732 | * @access public |
1734 | 1733 | * @return string |
1735 | 1734 | */ |
1736 | - public function EncodeQ ($str, $position = 'text') { |
|
1735 | + public function EncodeQ($str, $position = 'text') { |
|
1737 | 1736 | // There should not be any EOL in the string |
1738 | 1737 | $encoded = preg_replace('/[\r\n]*/', '', $str); |
1739 | 1738 | |
@@ -1776,7 +1775,7 @@ discard block |
||
1776 | 1775 | 2 => basename($filename), |
1777 | 1776 | 3 => $encoding, |
1778 | 1777 | 4 => $type, |
1779 | - 5 => true, // isStringAttachment |
|
1778 | + 5 => true, // isStringAttachment |
|
1780 | 1779 | 6 => 'attachment', |
1781 | 1780 | 7 => 0 |
1782 | 1781 | ); |
@@ -1797,13 +1796,13 @@ discard block |
||
1797 | 1796 | */ |
1798 | 1797 | public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { |
1799 | 1798 | |
1800 | - if ( !@is_file($path) ) { |
|
1801 | - $this->SetError($this->Lang('file_access') . $path); |
|
1799 | + if (!@is_file($path)) { |
|
1800 | + $this->SetError($this->Lang('file_access').$path); |
|
1802 | 1801 | return false; |
1803 | 1802 | } |
1804 | 1803 | |
1805 | 1804 | $filename = basename($path); |
1806 | - if ( $name == '' ) { |
|
1805 | + if ($name == '') { |
|
1807 | 1806 | $name = $filename; |
1808 | 1807 | } |
1809 | 1808 | |
@@ -1814,7 +1813,7 @@ discard block |
||
1814 | 1813 | 2 => $name, |
1815 | 1814 | 3 => $encoding, |
1816 | 1815 | 4 => $type, |
1817 | - 5 => false, // isStringAttachment |
|
1816 | + 5 => false, // isStringAttachment |
|
1818 | 1817 | 6 => 'inline', |
1819 | 1818 | 7 => $cid |
1820 | 1819 | ); |
@@ -1828,7 +1827,7 @@ discard block |
||
1828 | 1827 | * @return bool |
1829 | 1828 | */ |
1830 | 1829 | public function InlineImageExists() { |
1831 | - foreach($this->attachment as $attachment) { |
|
1830 | + foreach ($this->attachment as $attachment) { |
|
1832 | 1831 | if ($attachment[6] == 'inline') { |
1833 | 1832 | return true; |
1834 | 1833 | } |
@@ -1845,7 +1844,7 @@ discard block |
||
1845 | 1844 | * @return void |
1846 | 1845 | */ |
1847 | 1846 | public function ClearAddresses() { |
1848 | - foreach($this->to as $to) { |
|
1847 | + foreach ($this->to as $to) { |
|
1849 | 1848 | unset($this->all_recipients[strtolower($to[0])]); |
1850 | 1849 | } |
1851 | 1850 | $this->to = array(); |
@@ -1856,7 +1855,7 @@ discard block |
||
1856 | 1855 | * @return void |
1857 | 1856 | */ |
1858 | 1857 | public function ClearCCs() { |
1859 | - foreach($this->cc as $cc) { |
|
1858 | + foreach ($this->cc as $cc) { |
|
1860 | 1859 | unset($this->all_recipients[strtolower($cc[0])]); |
1861 | 1860 | } |
1862 | 1861 | $this->cc = array(); |
@@ -1867,7 +1866,7 @@ discard block |
||
1867 | 1866 | * @return void |
1868 | 1867 | */ |
1869 | 1868 | public function ClearBCCs() { |
1870 | - foreach($this->bcc as $bcc) { |
|
1869 | + foreach ($this->bcc as $bcc) { |
|
1871 | 1870 | unset($this->all_recipients[strtolower($bcc[0])]); |
1872 | 1871 | } |
1873 | 1872 | $this->bcc = array(); |
@@ -1924,7 +1923,7 @@ discard block |
||
1924 | 1923 | if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { |
1925 | 1924 | $lasterror = $this->smtp->getError(); |
1926 | 1925 | if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { |
1927 | - $msg .= '<p>' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n"; |
|
1926 | + $msg .= '<p>'.$this->Lang('smtp_error').$lasterror['smtp_msg']."</p>\n"; |
|
1928 | 1927 | } |
1929 | 1928 | } |
1930 | 1929 | $this->ErrorInfo = $msg; |
@@ -1940,7 +1939,7 @@ discard block |
||
1940 | 1939 | $tz = date('Z'); |
1941 | 1940 | $tzs = ($tz < 0) ? '-' : '+'; |
1942 | 1941 | $tz = abs($tz); |
1943 | - $tz = (int)($tz/3600)*100 + ($tz%3600)/60; |
|
1942 | + $tz = (int) ($tz / 3600) * 100 + ($tz % 3600) / 60; |
|
1944 | 1943 | $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); |
1945 | 1944 | |
1946 | 1945 | return $result; |
@@ -1969,14 +1968,14 @@ discard block |
||
1969 | 1968 | * @return string |
1970 | 1969 | */ |
1971 | 1970 | private function Lang($key) { |
1972 | - if(count($this->language) < 1) { |
|
1971 | + if (count($this->language) < 1) { |
|
1973 | 1972 | $this->SetLanguage('en'); // set the default language |
1974 | 1973 | } |
1975 | 1974 | |
1976 | - if(isset($this->language[$key])) { |
|
1975 | + if (isset($this->language[$key])) { |
|
1977 | 1976 | return $this->language[$key]; |
1978 | 1977 | } else { |
1979 | - return 'Language string failed to load: ' . $key; |
|
1978 | + return 'Language string failed to load: '.$key; |
|
1980 | 1979 | } |
1981 | 1980 | } |
1982 | 1981 | |
@@ -2017,19 +2016,19 @@ discard block |
||
2017 | 2016 | */ |
2018 | 2017 | public function MsgHTML($message, $basedir = '') { |
2019 | 2018 | preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); |
2020 | - if(isset($images[2])) { |
|
2021 | - foreach($images[2] as $i => $url) { |
|
2019 | + if (isset($images[2])) { |
|
2020 | + foreach ($images[2] as $i => $url) { |
|
2022 | 2021 | // do not change urls for absolute images (thanks to corvuscorax) |
2023 | - if (!preg_match('#^[A-z]+://#',$url)) { |
|
2022 | + if (!preg_match('#^[A-z]+://#', $url)) { |
|
2024 | 2023 | $filename = basename($url); |
2025 | 2024 | $directory = dirname($url); |
2026 | - ($directory == '.')?$directory='':''; |
|
2027 | - $cid = 'cid:' . md5($filename); |
|
2025 | + ($directory == '.') ? $directory = '' : ''; |
|
2026 | + $cid = 'cid:'.md5($filename); |
|
2028 | 2027 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
2029 | - $mimeType = self::_mime_types($ext); |
|
2030 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } |
|
2031 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
2032 | - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { |
|
2028 | + $mimeType = self::_mime_types($ext); |
|
2029 | + if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; } |
|
2030 | + if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } |
|
2031 | + if ($this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType)) { |
|
2033 | 2032 | $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); |
2034 | 2033 | } |
2035 | 2034 | } |
@@ -2037,12 +2036,12 @@ discard block |
||
2037 | 2036 | } |
2038 | 2037 | $this->IsHTML(true); |
2039 | 2038 | $this->Body = $message; |
2040 | - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); |
|
2039 | + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message))); |
|
2041 | 2040 | if (!empty($textMsg) && empty($this->AltBody)) { |
2042 | 2041 | $this->AltBody = html_entity_decode($textMsg); |
2043 | 2042 | } |
2044 | 2043 | if (empty($this->AltBody)) { |
2045 | - $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; |
|
2044 | + $this->AltBody = 'To view this email message, open it in a program that understands HTML!'."\n\n"; |
|
2046 | 2045 | } |
2047 | 2046 | } |
2048 | 2047 | |
@@ -2160,10 +2159,10 @@ discard block |
||
2160 | 2159 | */ |
2161 | 2160 | public function set($name, $value = '') { |
2162 | 2161 | try { |
2163 | - if (isset($this->$name) ) { |
|
2162 | + if (isset($this->$name)) { |
|
2164 | 2163 | $this->$name = $value; |
2165 | 2164 | } else { |
2166 | - throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL); |
|
2165 | + throw new phpmailerException($this->Lang('variable_set').$name, self::STOP_CRITICAL); |
|
2167 | 2166 | } |
2168 | 2167 | } catch (Exception $e) { |
2169 | 2168 | $this->SetError($e->getMessage()); |
@@ -2207,14 +2206,14 @@ discard block |
||
2207 | 2206 | * @param string $key_pass Password for private key |
2208 | 2207 | */ |
2209 | 2208 | public function DKIM_QP($txt) { |
2210 | - $tmp=""; |
|
2211 | - $line=""; |
|
2212 | - for ($i=0;$i<strlen($txt);$i++) { |
|
2213 | - $ord=ord($txt[$i]); |
|
2214 | - if ( ((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E)) ) { |
|
2215 | - $line.=$txt[$i]; |
|
2209 | + $tmp = ""; |
|
2210 | + $line = ""; |
|
2211 | + for ($i = 0; $i < strlen($txt); $i++) { |
|
2212 | + $ord = ord($txt[$i]); |
|
2213 | + if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { |
|
2214 | + $line .= $txt[$i]; |
|
2216 | 2215 | } else { |
2217 | - $line.="=".sprintf("%02X",$ord); |
|
2216 | + $line .= "=".sprintf("%02X", $ord); |
|
2218 | 2217 | } |
2219 | 2218 | } |
2220 | 2219 | return $line; |
@@ -2228,8 +2227,8 @@ discard block |
||
2228 | 2227 | */ |
2229 | 2228 | public function DKIM_Sign($s) { |
2230 | 2229 | $privKeyStr = file_get_contents($this->DKIM_private); |
2231 | - if ($this->DKIM_passphrase!='') { |
|
2232 | - $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase); |
|
2230 | + if ($this->DKIM_passphrase != '') { |
|
2231 | + $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); |
|
2233 | 2232 | } else { |
2234 | 2233 | $privKey = $privKeyStr; |
2235 | 2234 | } |
@@ -2245,15 +2244,15 @@ discard block |
||
2245 | 2244 | * @param string $s Header |
2246 | 2245 | */ |
2247 | 2246 | public function DKIM_HeaderC($s) { |
2248 | - $s=preg_replace("/\r\n\s+/"," ",$s); |
|
2249 | - $lines=explode("\r\n",$s); |
|
2247 | + $s = preg_replace("/\r\n\s+/", " ", $s); |
|
2248 | + $lines = explode("\r\n", $s); |
|
2250 | 2249 | foreach ($lines as $key=>$line) { |
2251 | - list($heading,$value)=explode(":",$line,2); |
|
2252 | - $heading=strtolower($heading); |
|
2253 | - $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces |
|
2254 | - $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value |
|
2250 | + list($heading, $value) = explode(":", $line, 2); |
|
2251 | + $heading = strtolower($heading); |
|
2252 | + $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces |
|
2253 | + $lines[$key] = $heading.":".trim($value); // Don't forget to remove WSP around the value |
|
2255 | 2254 | } |
2256 | - $s=implode("\r\n",$lines); |
|
2255 | + $s = implode("\r\n", $lines); |
|
2257 | 2256 | return $s; |
2258 | 2257 | } |
2259 | 2258 | |
@@ -2266,11 +2265,11 @@ discard block |
||
2266 | 2265 | public function DKIM_BodyC($body) { |
2267 | 2266 | if ($body == '') return "\r\n"; |
2268 | 2267 | // stabilize line endings |
2269 | - $body=str_replace("\r\n","\n",$body); |
|
2270 | - $body=str_replace("\n","\r\n",$body); |
|
2268 | + $body = str_replace("\r\n", "\n", $body); |
|
2269 | + $body = str_replace("\n", "\r\n", $body); |
|
2271 | 2270 | // END stabilize line endings |
2272 | - while (substr($body,strlen($body)-4,4) == "\r\n\r\n") { |
|
2273 | - $body=substr($body,0,strlen($body)-2); |
|
2271 | + while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { |
|
2272 | + $body = substr($body, 0, strlen($body) - 2); |
|
2274 | 2273 | } |
2275 | 2274 | return $body; |
2276 | 2275 | } |
@@ -2283,52 +2282,52 @@ discard block |
||
2283 | 2282 | * @param string $subject Subject |
2284 | 2283 | * @param string $body Body |
2285 | 2284 | */ |
2286 | - public function DKIM_Add($headers_line,$subject,$body) { |
|
2285 | + public function DKIM_Add($headers_line, $subject, $body) { |
|
2287 | 2286 | $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms |
2288 | 2287 | $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body |
2289 | 2288 | $DKIMquery = 'dns/txt'; // Query method |
2290 | - $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) |
|
2289 | + $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) |
|
2291 | 2290 | $subject_header = "Subject: $subject"; |
2292 | - $headers = explode("\r\n",$headers_line); |
|
2293 | - foreach($headers as $header) { |
|
2294 | - if (strpos($header,'From:') === 0) { |
|
2295 | - $from_header=$header; |
|
2296 | - } elseif (strpos($header,'To:') === 0) { |
|
2297 | - $to_header=$header; |
|
2291 | + $headers = explode("\r\n", $headers_line); |
|
2292 | + foreach ($headers as $header) { |
|
2293 | + if (strpos($header, 'From:') === 0) { |
|
2294 | + $from_header = $header; |
|
2295 | + } elseif (strpos($header, 'To:') === 0) { |
|
2296 | + $to_header = $header; |
|
2298 | 2297 | } |
2299 | 2298 | } |
2300 | - $from = str_replace('|','=7C',$this->DKIM_QP($from_header)); |
|
2301 | - $to = str_replace('|','=7C',$this->DKIM_QP($to_header)); |
|
2302 | - $subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable |
|
2299 | + $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); |
|
2300 | + $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); |
|
2301 | + $subject = str_replace('|', '=7C', $this->DKIM_QP($subject_header)); // Copied header fields (dkim-quoted-printable |
|
2303 | 2302 | $body = $this->DKIM_BodyC($body); |
2304 | - $DKIMlen = strlen($body) ; // Length of body |
|
2305 | - $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body |
|
2306 | - $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; |
|
2307 | - $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". |
|
2308 | - "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n". |
|
2303 | + $DKIMlen = strlen($body); // Length of body |
|
2304 | + $DKIMb64 = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body |
|
2305 | + $ident = ($this->DKIM_identity == '') ? '' : " i=".$this->DKIM_identity.";"; |
|
2306 | + $dkimhdrs = "DKIM-Signature: v=1; a=".$DKIMsignatureType."; q=".$DKIMquery."; l=".$DKIMlen."; s=".$this->DKIM_selector.";\r\n". |
|
2307 | + "\tt=".$DKIMtime."; c=".$DKIMcanonicalization.";\r\n". |
|
2309 | 2308 | "\th=From:To:Subject;\r\n". |
2310 | - "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n". |
|
2309 | + "\td=".$this->DKIM_domain.";".$ident."\r\n". |
|
2311 | 2310 | "\tz=$from\r\n". |
2312 | 2311 | "\t|$to\r\n". |
2313 | 2312 | "\t|$subject;\r\n". |
2314 | - "\tbh=" . $DKIMb64 . ";\r\n". |
|
2313 | + "\tbh=".$DKIMb64.";\r\n". |
|
2315 | 2314 | "\tb="; |
2316 | - $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs); |
|
2315 | + $toSign = $this->DKIM_HeaderC($from_header."\r\n".$to_header."\r\n".$subject_header."\r\n".$dkimhdrs); |
|
2317 | 2316 | $signed = $this->DKIM_Sign($toSign); |
2318 | 2317 | return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; |
2319 | 2318 | } |
2320 | 2319 | |
2321 | - protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) { |
|
2320 | + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) { |
|
2322 | 2321 | if (!empty($this->action_function) && function_exists($this->action_function)) { |
2323 | - $params = array($isSent,$to,$cc,$bcc,$subject,$body); |
|
2324 | - call_user_func_array($this->action_function,$params); |
|
2322 | + $params = array($isSent, $to, $cc, $bcc, $subject, $body); |
|
2323 | + call_user_func_array($this->action_function, $params); |
|
2325 | 2324 | } |
2326 | 2325 | } |
2327 | 2326 | } |
2328 | 2327 | |
2329 | 2328 | class phpmailerException extends Exception { |
2330 | 2329 | public function errorMessage() { |
2331 | - $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n"; |
|
2330 | + $errorMsg = '<strong>'.$this->getMessage()."</strong><br />\n"; |
|
2332 | 2331 | return $errorMsg; |
2333 | 2332 | } |
2334 | 2333 | } |