@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | $slideshow_extension = strrchr($file, '.'); |
26 | 26 | $slideshow_extension = strtolower($slideshow_extension); |
27 | 27 | if (in_array($slideshow_extension, $accepted_extensions)) { |
28 | - $png_svg_files[] =$file; |
|
28 | + $png_svg_files[] = $file; |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | } |
32 | 32 | $style = '<style>'; |
33 | 33 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'base.css";'; |
34 | 34 | $style .= '@import "'.api_get_path(WEB_CSS_PATH).'themes/'.api_get_visual_theme().'/default.css";'; |
35 | -$style .='</style>'; |
|
35 | +$style .= '</style>'; |
|
36 | 36 | |
37 | 37 | ?> |
38 | 38 | <!doctype html> |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | if (!empty($png_svg_files)) { |
49 | 49 | echo '<h3>'.get_lang('SelectSVGEditImage').'</h3>'; |
50 | 50 | echo '<ul>'; |
51 | - foreach($png_svg_files as $filename) { |
|
51 | + foreach ($png_svg_files as $filename) { |
|
52 | 52 | $image = $user_disk_path.$filename; |
53 | 53 | |
54 | - if (strpos($filename, "svg")){ |
|
54 | + if (strpos($filename, "svg")) { |
|
55 | 55 | $new_sizes['width'] = 60; |
56 | 56 | $new_sizes['height'] = 60; |
57 | 57 | } else { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | if ($i == $max_level) { |
332 | 332 | $select_part .= "rg$rg_number.group_id as id_$rg_number "; |
333 | 333 | } else { |
334 | - $select_part .="rg$rg_number.group_id as id_$rg_number, "; |
|
334 | + $select_part .= "rg$rg_number.group_id as id_$rg_number, "; |
|
335 | 335 | } |
336 | 336 | if ($i == 1) { |
337 | 337 | $cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id "; |
@@ -1334,14 +1334,14 @@ discard block |
||
1334 | 1334 | */ |
1335 | 1335 | public static function get_groups_by_user_count($user_id = null, $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) |
1336 | 1336 | { |
1337 | - $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
|
1338 | - $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1337 | + $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); |
|
1338 | + $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); |
|
1339 | 1339 | $user_id = intval($user_id); |
1340 | 1340 | |
1341 | 1341 | if ($relation_type == 0) { |
1342 | 1342 | $where_relation_condition = ''; |
1343 | 1343 | } else { |
1344 | - $relation_type = intval($relation_type); |
|
1344 | + $relation_type = intval($relation_type); |
|
1345 | 1345 | $where_relation_condition = "AND gu.relation_type = $relation_type "; |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1394,7 +1394,7 @@ discard block |
||
1394 | 1394 | |
1395 | 1395 | // Picture |
1396 | 1396 | $form->addElement('file', 'picture', get_lang('AddPicture')); |
1397 | - $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); |
|
1397 | + $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); |
|
1398 | 1398 | $form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types); |
1399 | 1399 | |
1400 | 1400 | if (!empty($groupData)) { |
@@ -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, |