4 chdir(
'../../../../../');
6 require_once
'Services/Init/classes/class.ilInitialisation.php';
17 $lng->loadLanguageModule(
"form");
49 include_once
'webservice/soap/include/inc.soap_functions.php';
58 if(isset($_FILES[
'img_file']) && is_array($_FILES[
'img_file']))
61 while(substr($_FILES[
'img_file'][
'name'], -1) ==
'/')
63 $_FILES[
'img_file'][
'name'] = substr($_FILES[
'img_file'][
'name'], 0, -1);
66 $error = $_FILES[
'img_file'][
'error'];
69 case UPLOAD_ERR_INI_SIZE:
70 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
'form_msg_file_size_exceeds'));
73 case UPLOAD_ERR_FORM_SIZE:
74 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_size_exceeds"));
77 case UPLOAD_ERR_PARTIAL:
78 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_partially_uploaded"));
81 case UPLOAD_ERR_NO_FILE:
82 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_no_upload"));
85 case UPLOAD_ERR_NO_TMP_DIR:
86 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_missing_tmp_dir"));
89 case UPLOAD_ERR_CANT_WRITE:
90 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_cannot_write_to_disk"));
93 case UPLOAD_ERR_EXTENSION:
94 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_upload_stopped_ext"));
101 $finfo = pathinfo($_FILES[
'img_file'][
'name']);
102 require_once
'Services/Utilities/classes/class.ilMimeTypeUtil.php';
103 $mime_type =
ilMimeTypeUtil::getMimeType($_FILES[
'img_file'][
'tmp_name'], $_FILES[
'img_file'][
'name'], $_FILES[
'img_file'][
'type']);
104 if(!in_array(strtolower($finfo[
'extension']),
$tinyMCE_valid_imgs) || !in_array($mime_type, array(
110 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_wrong_file_type"));
117 if($_FILES[
'img_file'][
"tmp_name"] !=
"")
122 $errors->fields[] = array(
'name' =>
'img_file',
'message' =>
$lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
129 include_once
'webservice/soap/include/inc.soap_functions.php';
130 $safefilename = preg_replace(
'/[^a-zA-z0-9_\.]/',
'', $_FILES[
'img_file'][
'name']);
135 $media_object->_saveUsage($media_object->getId(),
$_GET[
'obj_type'] .
':html', (int)
$_GET[
'obj_id']);
138 $mobs[$media_object->getId()] = $media_object->getId();
148 $tpl->setVariable(
"OBJ_ID", (
int)
$_GET[
"obj_id"]);
149 $tpl->setVariable(
"OBJ_TYPE", $_GET[
"obj_type"]);
150 $tpl->setVariable(
"VALUE_UPDATE", (
int)$_GET[
"update"]);
154 "TXT_ALLOWED_FILE_EXTENSIONS",
155 $lng->txt(
"file_allowed_suffixes").
" ".
156 implode(
', ', array_map(create_function(
'$value',
'return ".".$value;'),
$tinyMCE_valid_imgs))
159 if(
$ilUser->getLanguage() ==
'de')
161 $tpl->touchBlock(
'validation_engine_lang_de');
165 $tpl->touchBlock(
'validation_engine_lang_default');
168 if($_GET[
"update"] == 1)
170 $tpl->setVariable(
"IMG_FROM_URL_TAB_DESC",
"{#ilimgupload.edit_image}");
171 $tpl->setVariable(
"IMG_FROM_URL_DESC",
"{#ilimgupload.edit_image_desc}");
172 $tpl->setVariable(
"INSERT_COMMAND",
"{#ilimgupload.insert}");
176 $tpl->setVariable(
"IMG_FROM_URL_TAB_DESC",
"{#ilimgupload.upload_image_from_url}");
177 $tpl->setVariable(
"IMG_FROM_URL_DESC",
"{#ilimgupload.upload_image_from_url_desc}");
178 $tpl->setVariable(
"INSERT_COMMAND",
"{#ilimgupload.insert}");
182 foreach(
$mobs as $mob)
189 while(
false !== ($entry =
$d->read()))
191 $ext = strtolower(substr(strrchr($entry,
'.'), 1));
204 foreach(
$errors->fields as $field)
206 $tpl->setCurrentBlock(
'errors');
207 $tpl->setVariable(
'ERRORS_FIELDNAME', $field[
'name']);
208 $tpl->setVariable(
'ERRORS_MESSAGE', $field[
'message']);
209 $tpl->parseCurrentBlock();
215 $tpl->setVariable(
'UPLOADED_FILE_WIDTH', (
int)$img_size[0]);
216 $tpl->setVariable(
'UPLOADED_FILE_HEIGHT', (
int)$img_size[1]);