|
@@ 362-393 (lines=32) @@
|
| 359 |
|
Database::query($sql); |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
if ($has_attachment) { |
| 363 |
|
$courseDir = $_course['path'].'/upload/blog'; |
| 364 |
|
$sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 365 |
|
$updir = $sys_course_path.$courseDir; |
| 366 |
|
|
| 367 |
|
// Try to add an extension to the file if it hasn't one |
| 368 |
|
$new_file_name = add_ext_on_mime( |
| 369 |
|
stripslashes($_FILES['user_upload']['name']), |
| 370 |
|
$_FILES['user_upload']['type'] |
| 371 |
|
); |
| 372 |
|
|
| 373 |
|
// user's file name |
| 374 |
|
$file_name = $_FILES['user_upload']['name']; |
| 375 |
|
|
| 376 |
|
if (!filter_extension($new_file_name)) { |
| 377 |
|
Display::display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 378 |
|
} else { |
| 379 |
|
$new_file_name = uniqid(''); |
| 380 |
|
$new_path = $updir.'/'.$new_file_name; |
| 381 |
|
$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
| 382 |
|
$comment = Database::escape_string($file_comment); |
| 383 |
|
|
| 384 |
|
// Storing the attachments if any |
| 385 |
|
if ($result) { |
| 386 |
|
$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
| 387 |
|
"VALUES ($course_id, '".Database::escape_string( |
| 388 |
|
$file_name |
| 389 |
|
)."', '".$comment."', '".Database::escape_string( |
| 390 |
|
$new_file_name |
| 391 |
|
)."' , '".$last_post_id."', '".intval( |
| 392 |
|
$_FILES['user_upload']['size'] |
| 393 |
|
)."', '".$blog_id."', '0' )"; |
| 394 |
|
Database::query($sql); |
| 395 |
|
$id = Database::insert_id(); |
| 396 |
|
if ($id) { |
|
@@ 518-554 (lines=37) @@
|
| 515 |
|
Database::query($sql); |
| 516 |
|
} |
| 517 |
|
|
| 518 |
|
if ($has_attachment) { |
| 519 |
|
$courseDir = $_course['path'].'/upload/blog'; |
| 520 |
|
$sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 521 |
|
$updir = $sys_course_path.$courseDir; |
| 522 |
|
|
| 523 |
|
// Try to add an extension to the file if it hasn't one |
| 524 |
|
$new_file_name = add_ext_on_mime( |
| 525 |
|
stripslashes($_FILES['user_upload']['name']), |
| 526 |
|
$_FILES['user_upload']['type'] |
| 527 |
|
); |
| 528 |
|
|
| 529 |
|
// user's file name |
| 530 |
|
$file_name = $_FILES['user_upload']['name']; |
| 531 |
|
|
| 532 |
|
if (!filter_extension($new_file_name)) { |
| 533 |
|
Display:: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 534 |
|
} else { |
| 535 |
|
$new_file_name = uniqid(''); |
| 536 |
|
$new_path = $updir.'/'.$new_file_name; |
| 537 |
|
$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
| 538 |
|
$comment = Database::escape_string($file_comment); |
| 539 |
|
|
| 540 |
|
// Storing the attachments if any |
| 541 |
|
if ($result) { |
| 542 |
|
$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
| 543 |
|
"VALUES ($course_id, '".Database::escape_string( |
| 544 |
|
$file_name |
| 545 |
|
)."', '".$comment."', '".Database::escape_string( |
| 546 |
|
$new_file_name |
| 547 |
|
)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
| 548 |
|
Database::query($sql); |
| 549 |
|
|
| 550 |
|
$id = Database::insert_id(); |
| 551 |
|
|
| 552 |
|
if ($id) { |
| 553 |
|
$sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 554 |
|
Database::query($sql); |
| 555 |
|
} |
| 556 |
|
} |
| 557 |
|
} |