function page_edit_virusscan_isClean($filename_on_disc, $filename_orig) { global $page; global $c_virus_scan; global $environment; $class_factory = $environment->getClassFactory(); $retour = true; if (isset($c_virus_scan) and $c_virus_scan) { global $c_virus_scan_cron; if (!isset($c_virus_scan_cron) or !$c_virus_scan_cron) { include_once 'classes/cs_virus_scan.php'; $virus_scanner = new cs_virus_scan($environment); if (!$virus_scanner->isClean($filename_on_disc, $filename_orig)) { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $params['width'] = 500; $errorbox = $class_factory->getClass(ERRORBOX_VIEW, $params); unset($params); $errorbox->setText($virus_scanner->getOutput()); $page->add($errorbox); $retour = false; } } } return $retour; }
$session_item->setValue('ads_'.$current_iid.'_files_array',$files_array); } unset($files_array); unset($temp_temp_name); if ( isset($_POST['hidden_normal_name'][$key]) and !empty($_POST['hidden_normal_name'][$key]) ) { $_POST['hidden_delete_normal_name'][] = $_POST['hidden_normal_name'][$key]; } } else { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $params['width'] = 500; $errorbox = $class_factory->getClass(ERRORBOX_VIEW,$params); unset($params); $errorbox->setText($virus_scanner->getOutput()); $page->add($errorbox); $focus_element_onload = ''; $error_on_upload = true; } } else { move_uploaded_file($_FILES['normal_name']['tmp_name'][$key],$_FILES['normal_name']['tmp_name'][$key].'_TEMP_'.$value); $_FILES['normal_name']['tmp_name'][$key] = $_FILES['normal_name']['tmp_name'][$key].'_TEMP_'.$value; $current_iid = $environment->getCurrentContextID(); $session_item = $environment->getSessionItem(); if ( isset($session_item) ) { $files_array = array(); if ( $session_item->issetValue('ads_'.$current_iid.'_files_array') ) { $files_array = $session_item->getValue('ads_'.$current_iid.'_files_array'); }
if ( !empty($_FILES['upload']['tmp_name']) ) { $scan = false; if ( !empty($_FILES['upload']['tmp_name']) and $_FILES['upload']['size'] > 0 ) { if ( isset($c_virus_scan) and $c_virus_scan and isset($c_virus_scan_cron) and !empty($c_virus_scan_cron) and !$c_virus_scan_cron ) { include_once('classes/cs_virus_scan.php'); $virus_scanner = new cs_virus_scan($environment); if ( !$virus_scanner->isClean($_FILES['upload']['tmp_name'],$_FILES['upload']['name']) ) { include_once('functions/error_functions.php'); trigger_error($virus_scanner->getOutput(),E_USER_ERROR); } else { $scan = true; } } } $file_man = $environment->getFileManager(); $file_item = $file_man->getNewItem(); $file_item->setPostFile($_FILES['upload']); $file_item->save(); $file_id_array = $item_files_upload_to->getFileIDArray(); $file_id_array[] = $file_item->getFileID(); $item_files_upload_to->setFileIDArray($file_id_array); $item_files_upload_to->save(); echo('success'); }
public function actionSaveFile() { $environment = $this->_environment; $session = $environment->getSessionItem(); include_once 'functions/development_functions.php'; if (!empty($_FILES)) { $post_file_ids = array(); $tempFile = $_FILES['upload']['tmp_name']; $focus_element_onload = 'Filedata'; $file_array = array(); if (!empty($tempFile) && $_FILES['upload']['size'] > 0) { if (isset($_REQUEST['c_virus_scan']) && $_REQUEST['c_virus_scan'] && isset($_REQUEST['c_virus_scan_cron']) && !empty($_REQUEST['c_virus_scan_cron']) && !$_REQUEST['c_virus_scan_crom']) { // use virus scanner require_once 'classes/cs_virus_scan.php'; $virus_scanner = new cs_virus_scan($environment); if ($virus_scanner->isClean($tempFile, $tempFile)) { move_uploaded_file($tempFile, $tempFile . 'commsy3'); $temp_array = array(); $temp_array['name'] = $_FILES['upload']['name']; $temp_array['tmp_name'] = $tempFile . 'commsy3'; $temp_array['file_id'] = $temp_array['name'] . '_' . getCurrentDateTimeInMySQL(); $file_array[] = $temp_array; } else { $params = array(); $params['environment'] = $environment; $params['with_modifying_actions'] = true; $params['width'] = 500; $errorbox = $class_factory->getClass(ERRORBOX_VIEW, $params); unset($params); $errorbox->setText($virus_scanner->getOutput()); $page->add($errorbox); $focus_element_onload = ''; $error_on_upload = true; } } else { require_once 'functions/date_functions.php'; move_uploaded_file($tempFile, $tempFile . 'commsy3'); $temp_array = array(); $temp_array['name'] = $_FILES['upload']['name']; $temp_array['tmp_name'] = $tempFile . 'commsy3'; $temp_array['file_id'] = $temp_array['name'] . '_' . getCurrentDateTimeInMySQL(); $file_array[] = $temp_array; } } $file_data = $file_array[0]; $file_manager = $environment->getFileManager(); $file_item = $file_manager->getNewItem(); $file_item->setTempKey($file_data["file_id"]); $file_item->setPostFile($file_data); $file_item->setTempUploadFromEditorSessionID($environment->getSessionID()); $file_item->save(); unlink($file_data["tmp_name"]); // Nach dem Speichern des Eintrags die Items-Tabelle anhand temp=true und der extras->SESSION_ID durchsuchen. // Text im Textfeld nach Dateinamen parsen und passende Dateien aus der files-Tabelle mit dem Item verlinken. // Extras temp und id zurücksetzen. // cron für das regelmäßige löschen von temp-files. $callback_function = ''; $callback_function .= '<script type="text/javascript">' . LF; $callback_function .= '<!--' . LF; $callback_function .= 'var fileTypeFunction = function () {'; $callback_function .= 'var dialog = this.getDialog();'; $callback_function .= 'if(dialog.getName() == "CommSyVideo"){'; $callback_function .= 'var element = dialog.getContentElement( "videoTab", "videoType" );'; $callback_function .= 'element.setValue("' . $file_item->getMime() . '")'; $callback_function .= '}'; $callback_function .= '};'; $callback_function .= 'window.parent.CKEDITOR.tools.callFunction(' . $_GET['CKEditorFuncNum'] . ', "commsy.php/?cid=' . $environment->getCurrentContextID() . '&mod=material&fct=getfile&iid=' . $file_item->getFileID() . '", fileTypeFunction);' . LF; $callback_function .= '-->' . LF; $callback_function .= '</script>' . LF; echo $callback_function; } $environment->getSessionManager()->save($session); exit; }
echo "POSTLET REPLY\r\n"; // "YES" tells Postlet that this file was successfully uploaded. echo "POSTLET:YES - " . $_FILES['userfile']['name'] . "\r\n"; // End the Postlet reply echo "END POSTLET REPLY\r\n"; exit; } else { $failure = true; } } else { if ($session_item->issetValue($environment->getCurrentModule() . '_add_files_multi_error')) { $file_error_array = $session_item->getValue($environment->getCurrentModule() . '_add_files_multi_error'); } else { $file_error_array = array(); } $file_error_array[] = $virus_scanner->getOutput(); $session_item->setValue($environment->getCurrentModule() . '_add_files_multi_error', $file_error_array); $session_manager = $environment->getSessionManager(); $session_manager->save($session_item); // All replies MUST start with "POSTLET REPLY", if they don't, then Postlet will // not read the reply and will assume the file uploaded successfully. echo "POSTLET REPLY\r\n"; echo "POSTLET:NO - " . $_FILES['userfile']['name'] . "\r\n"; echo "POSTLET:VIRUS INSIDE\r\n"; echo "POSTLET:ABORT THIS\r\n"; // Postlet should NOT send this file again. echo "END POSTLET REPLY\r\n"; exit; } } elseif (move_uploaded_file($_FILES['userfile']['tmp_name'], $_FILES['userfile']['tmp_name'] . 'commsy3')) { $temp_array = array();