|
@@ 320-351 (lines=32) @@
|
| 317 |
|
Database::query($sql); |
| 318 |
|
} |
| 319 |
|
|
| 320 |
|
if ($has_attachment) { |
| 321 |
|
$courseDir = $_course['path'].'/upload/blog'; |
| 322 |
|
$sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 323 |
|
$updir = $sys_course_path.$courseDir; |
| 324 |
|
|
| 325 |
|
// Try to add an extension to the file if it hasn't one |
| 326 |
|
$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
| 327 |
|
|
| 328 |
|
// user's file name |
| 329 |
|
$file_name = $_FILES['user_upload']['name']; |
| 330 |
|
|
| 331 |
|
if (!filter_extension($new_file_name)) { |
| 332 |
|
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 333 |
|
} else { |
| 334 |
|
$new_file_name = uniqid(''); |
| 335 |
|
$new_path = $updir.'/'.$new_file_name; |
| 336 |
|
$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
| 337 |
|
$comment = Database::escape_string($file_comment); |
| 338 |
|
|
| 339 |
|
// Storing the attachments if any |
| 340 |
|
if ($result) { |
| 341 |
|
$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
| 342 |
|
"VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
| 343 |
|
Database::query($sql); |
| 344 |
|
$id = Database::insert_id(); |
| 345 |
|
if ($id) { |
| 346 |
|
$sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 347 |
|
Database::query($sql); |
| 348 |
|
} |
| 349 |
|
} |
| 350 |
|
} |
| 351 |
|
} |
| 352 |
|
} else { |
| 353 |
|
Display::display_error_message(get_lang('UplNoFileUploaded')); |
| 354 |
|
} |
|
@@ 454-490 (lines=37) @@
|
| 451 |
|
Database::query($sql); |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
if ($has_attachment) { |
| 455 |
|
$courseDir = $_course['path'].'/upload/blog'; |
| 456 |
|
$sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 457 |
|
$updir = $sys_course_path.$courseDir; |
| 458 |
|
|
| 459 |
|
// Try to add an extension to the file if it hasn't one |
| 460 |
|
$new_file_name = add_ext_on_mime( |
| 461 |
|
stripslashes($_FILES['user_upload']['name']), |
| 462 |
|
$_FILES['user_upload']['type'] |
| 463 |
|
); |
| 464 |
|
|
| 465 |
|
// user's file name |
| 466 |
|
$file_name =$_FILES['user_upload']['name']; |
| 467 |
|
|
| 468 |
|
if (!filter_extension($new_file_name)) { |
| 469 |
|
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 470 |
|
} else { |
| 471 |
|
$new_file_name = uniqid(''); |
| 472 |
|
$new_path=$updir.'/'.$new_file_name; |
| 473 |
|
$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
| 474 |
|
$comment = Database::escape_string($file_comment); |
| 475 |
|
|
| 476 |
|
// Storing the attachments if any |
| 477 |
|
if ($result) { |
| 478 |
|
$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
| 479 |
|
"VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
| 480 |
|
Database::query($sql); |
| 481 |
|
|
| 482 |
|
$id = Database::insert_id(); |
| 483 |
|
|
| 484 |
|
if ($id) { |
| 485 |
|
$sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 486 |
|
Database::query($sql); |
| 487 |
|
} |
| 488 |
|
} |
| 489 |
|
} |
| 490 |
|
} |
| 491 |
|
} |
| 492 |
|
} |
| 493 |
|
|