/** * @param $errors * * @return bool */ function publisher_pagewrap_upload(&$errors) { // include_once PUBLISHER_ROOT_PATH . '/class/uploader.php'; xoops_load('XoopsMediaUploader'); $publisher =& PublisherPublisher::getInstance(); $postField = 'fileupload'; $maxFileSize = $publisher->getConfig('maximum_filesize'); $maxImageWidth = $publisher->getConfig('maximum_image_width'); $maxImageHeight = $publisher->getConfig('maximum_image_height'); if (!is_dir(publisherGetUploadDir(true, 'content'))) { mkdir(publisherGetUploadDir(true, 'content'), 0757); } $allowedMimeTypes = array('text/html', 'text/plain', 'application/xhtml+xml'); $uploader = new XoopsMediaUploader(publisherGetUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight); if ($uploader->fetchMedia($postField)) { $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
function publisher_pagewrap_upload(&$errors) { $publisher = Publisher::getInstance(); $post_field = 'fileupload'; $max_size = $publisher->getConfig('maximum_filesize'); $max_imgwidth = $publisher->getConfig('maximum_image_width'); $max_imgheight = $publisher->getConfig('maximum_image_height'); if (!is_dir(PublisherUtils::getUploadDir(true, 'content'))) { mkdir(PublisherUtils::getUploadDir(true, 'content'), 0757); } $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml'); $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($post_field)) { $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
function storeUpload($post_field, $response = null, $allowed_mimetypes = null) { //global $xoopsModuleConfig, $xoopsUser, $xoopsDB, $xoopsModule; include_once XHELP_CLASS_PATH . '/uploader.php'; $config =& xhelpGetModuleConfig(); $ticketid = $this->getVar('id'); if (!isset($allowed_mimetypes)) { $hMime =& xhelpGetHandler('mimetype'); $allowed_mimetypes = $hMime->checkMimeTypes(); if (!$allowed_mimetypes) { return false; } } $maxfilesize = $config['xhelp_uploadSize']; $maxfilewidth = $config['xhelp_uploadWidth']; $maxfileheight = $config['xhelp_uploadHeight']; if (!is_dir(XHELP_UPLOAD_PATH)) { mkdir(XHELP_UPLOAD_PATH, 0757); } $uploader = new XoopsMediaUploader(XHELP_UPLOAD_PATH . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($post_field)) { if (!isset($response)) { $uploader->setTargetFileName($ticketid . "_" . $uploader->getMediaName()); } else { $uploader->setTargetFileName($ticketid . "_" . $response . "_" . $uploader->getMediaName()); } if ($uploader->upload()) { $hFile =& xhelpGetHandler('file'); $file =& $hFile->create(); $file->setVar('filename', $uploader->getSavedFileName()); $file->setVar('ticketid', $ticketid); $file->setVar('mimetype', $allowed_mimetypes); $file->setVar('responseid', isset($response) ? intval($response) : 0); if ($hFile->insert($file)) { return $file; } else { return $uploader->getErrors(); } } else { return $uploader->getErrors(); } } }
function smartsection_pagewrap_upload(&$errors) { include_once SMARTSECTION_ROOT_PATH . "class/uploader.php"; global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModule, $xoopsModuleConfig; include_once SMARTSECTION_ROOT_PATH . 'class/uploader.php'; $config =& smartsection_getModuleConfig(); $post_field = 'fileupload'; //$allowed_mimetypes = ''; // TODO : this needs to be managed by the MimeType section but we need a new parameter for allowed mimetype for pagewrap /* if(!isset($allowed_mimetypes)){ $hMime =& xoops_getmodulehandler('mimetype'); $allowed_mimetypes = $hMime->checkMimeTypes($post_field); if(!$allowed_mimetypes){ $errors[] = _SMARTSECTION_MESSAGE_WRONG_MIMETYPE; return false; } }*/ /*$maxfilesize = $config['xhelp_uploadSize']; $maxfilewidth = $config['xhelp_uploadWidth']; $maxfileheight = $config['xhelp_uploadHeight'];*/ $max_size = $xoopsModuleConfig['maximum_filesize']; $max_imgwidth = $xoopsModuleConfig['maximum_image_width']; $max_imgheight = $xoopsModuleConfig['maximum_image_height']; if (!is_dir(smartsection_getUploadDir(true, 'content'))) { mkdir(smartsection_getUploadDir(true, 'content'), 0757); } $allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml'); $uploader = new XoopsMediaUploader(smartsection_getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($post_field)) { $uploader->setTargetFileName($uploader->getMediaName()); if ($uploader->upload()) { return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
/** * @param string $post_field * @param array $allowed_mimetypes * @param array $errors * * @return bool */ public function storeUpload($post_field, $allowed_mimetypes = array(), &$errors) { $itemid = $this->getVar('itemid'); if (empty($allowed_mimetypes)) { $allowed_mimetypes = $this->publisher->getMimetypeHandler()->getArrayByType(); } $maxfilesize = $this->publisher->getConfig('maximum_filesize'); $maxfilewidth = $this->publisher->getConfig('maximum_image_width'); $maxfileheight = $this->publisher->getConfig('maximum_image_height'); if (!is_dir(PublisherUtils::getUploadDir())) { mkdir(PublisherUtils::getUploadDir(), 0757); } $uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($post_field)) { $uploader->setTargetFileName($itemid . "_" . $uploader->getMediaName()); if ($uploader->upload()) { $this->setVar('filename', $uploader->getSavedFileName()); if ($this->getVar('name') == '') { $this->setVar('name', $this->getNameFromFilename()); } $this->setVar('mimetype', $uploader->getMediaType()); return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
function addTopic() { global $xoopsDB, $xoopsModule, $xoopsModuleConfig; $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0; $xt = new AmsTopic($xoopsDB->prefix("ams_topics")); if (!$xt->topicExists($topicpid, $_POST['topic_title'])) { $xt->setTopicPid($topicpid); if (empty($_POST['topic_title']) || trim($_POST['topic_title']) == '') { redirect_header("index.php?op=topicsmanager", 2, _AMS_AM_ERRORTOPICNAME); } $xt->setTopicTitle($_POST['topic_title']); if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") { $xt->setTopicImgurl($_POST['topic_imgurl']); } if (isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (trim($fldname != '')) { $sfiles = new sFiles(); $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics'; $destname = $sfiles->createUploadName($dstpath, $fldname, true); $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $xt->setTopicImgurl(basename($destname)); } else { echo _AMS_AM_UPLOAD_ERROR; } } else { echo $uploader->getErrors(); } } } $xt->banner_inherit = isset($_POST['banner_inherit']) ? 1 : 0; $xt->banner = $_POST['banner']; $xt->forum_id = isset($_POST['forum_id']) ? intval($_POST['forum_id']) : 0; if ($xt->store()) { //This will set default audience global $xoopsModule; $allTopics = $xt->getAllTopics(); $totaltopics = count($allTopics); if ($totaltopics = 1) { //Make sure xoopsModule is AMS. if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != "AMS") { $mod_handler =& xoops_gethandler('module'); $amsModule =& $mod_handler->getByDirname('AMS'); } else { $amsModule =& $xoopsModule; } // Check audience, and set default value if not yet exist if (!ams_isaudiencesetup($amsModule->getVar('mid'))) { $gperm_handler =& xoops_gethandler('groupperm'); $member_handler =& xoops_gethandler('member'); $group_id_ref =& $member_handler->getGroups(null, true); //insert all groups into default audience foreach (array_keys($group_id_ref) as $i) { $gperm_handler->addRight("ams_audience", 1, intval($group_id_ref[$i]->getVar('groupid')), intval($amsModule->getVar('mid'))); } } } //Added in AMS 2.50 Final. Use News 1.62 permission style // Permissions $gperm_handler =& xoops_gethandler('groupperm'); if (isset($_POST['groups_AMS_can_approve'])) { foreach ($_POST['groups_AMS_can_approve'] as $onegroup_id) { $gperm_handler->addRight('ams_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if (isset($_POST['groups_AMS_can_submit'])) { foreach ($_POST['groups_AMS_can_submit'] as $onegroup_id) { $gperm_handler->addRight('ams_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if (isset($_POST['groups_AMS_can_view'])) { foreach ($_POST['groups_AMS_can_view'] as $onegroup_id) { $gperm_handler->addRight('ams_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } AMS_updateCache(); $notification_handler =& xoops_gethandler('notification'); $tags = array(); $tags['TOPIC_NAME'] = $_POST['topic_title']; $notification_handler->triggerEvent('global', 0, 'new_category', $tags); redirect_header('index.php?op=topicsmanager', 1, _AMS_AM_DBUPDATED); exit; } } else { redirect_header('index.php?op=topicsmanager', 2, _AMS_AM_ADD_TOPIC_ERROR); exit; } }
$HotelObj->setVar('hotel_star', isset($_POST['hotel_star']) ? intval($_POST['hotel_star']) : 0); $HotelObj->setVar('hotel_address', isset($_POST['hotel_address']) ? addslashes($_POST['hotel_address']) : ''); $HotelObj->setVar('hotel_telephone', isset($_POST['hotel_telephone']) ? addslashes($_POST['hotel_telephone']) : ''); $HotelObj->setVar('hotel_fax', isset($_POST['hotel_fax']) ? addslashes($_POST['hotel_fax']) : ''); $HotelObj->setVar('hotel_room_count', isset($_POST['hotel_room_count']) ? intval($_POST['hotel_room_count']) : 0); //file upload $hotel_icon = isset($_POST['hotel_icon_old']) ? $_POST['hotel_icon_old'] : null; include XOOPS_ROOT_PATH . '/class/uploader.php'; if (!empty($_FILES['hotel_icon']['tmp_name'])) { $path = MARTIN_ROOT_PATH . '/images/hotelicon/'; $FileTypeUpload = array("image/jpg", "image/png", "image/gif", "image/jpeg"); $uploader = new XoopsMediaUploader($path, $FileTypeUpload, 2048 * 1024); if ($uploader->fetchMedia($_POST["xoops_upload_file"][0])) { $uploader->ext = strtolower(ltrim(strrchr($uploader->getMediaName(), '.'), '.')); $SaveFileName = time() . rand(1000, 10000) . "." . $uploader->ext; $uploader->setTargetFileName($SaveFileName); if (!$uploader->upload()) { xoops_error($uploader->getErrors()); exit; } elseif (file_exists($uploader->getSavedDestination())) { //delete images if (!empty($hotel_icon)) { unlink(MARTIN_ROOT_PATH . '/images/hotelicon/' . $hotel_icon); } $hotel_icon = $uploader->getSavedFileName(); } } else { xoops_error($uploader->getErrors()); } } //echo $hotel_icon;exit;
$sfiles->delete(); } } if (isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $sfiles = new sFiles(); $destname = $sfiles->createUploadName(XOOPS_UPLOAD_PATH, $fldname); /** * You can attach files to your news */ $permittedtypes = explode("\n", str_replace("\r", '', news_getmoduleoption('mimetypes'))); array_walk($permittedtypes, 'trim'); $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $sfiles->setFileRealName($uploader->getMediaName()); $sfiles->setStoryid($story->storyid()); $sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH . '/' . $uploader->getMediaName())); $sfiles->setDownloadname($destname); if (!$sfiles->store()) { echo _AM_UPLOAD_DBERROR_SAVE; } } else { echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); }
function addTopic() { global $xoopsDB, $xoopsModule, $xoopsModuleConfig; $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0; $xt = new NewsTopic(); if (!$xt->topicExists($topicpid, $_POST['topic_title'])) { $xt->setTopicPid($topicpid); if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title']) == '') { redirect_header("index.php?op=topicsmanager", 2, _AM_ERRORTOPICNAME); } $xt->setTopicTitle($_POST['topic_title']); //$xt->Settopic_rssurl($_POST['topic_rssfeed']); $xt->setTopic_color($_POST['topic_color']); if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") { $xt->setTopicImgurl($_POST['topic_imgurl']); } $xt->setMenu(intval($_POST['submenu'])); $xt->setTopicFrontpage(intval($_POST['topic_frontpage'])); if (isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $sfiles = new sFiles(); $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics'; $destname = $sfiles->createUploadName($dstpath, $fldname, true); $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $xt->setTopicImgurl(basename($destname)); } else { echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); } } } $xt->setTopicDescription($_POST['topic_description']); $xt->store(); updateCache(); $notification_handler =& xoops_gethandler('notification'); $tags = array(); $tags['TOPIC_NAME'] = $_POST['topic_title']; $notification_handler->triggerEvent('global', 0, 'new_category', $tags); redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED); } else { redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR); } exit; }
$max_imgheight = 0; // ou =$xoopsModuleConfig['max_imgheight'] //$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'); $allowed_mimetypes = ''; include_once XOOPS_ROOT_PATH . "/class/uploader.php"; // Retreive the filename to be uploaded $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _AM_SS_FILEUPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(ss_getUploadDir(), $allowed_mimetypes, $max_size, null, null); $ext = preg_replace("/^.+\\.([^.]+)\$/sU", "\\1", $_FILES["my_file"]['name']); $new_name = time() . "." . $ext; $uploader->setTargetFileName($new_name); if ($uploader->fetchMedia($filename) && $uploader->upload()) { if (!$xoopsUser) { if ($xoopsModuleConfig['anonpost'] == 1) { $uid = 0; } else { redirect_header("index.php", 3, _NOPERM); exit; } } else { $uid = $xoopsUser->uid(); } $fileObj = $smartsection_file_handler->create(); $fileObj->setVar('name', $_POST['name']); $fileObj->setVar('description', $_POST['description']); $fileObj->setVar('filename', $uploader->getSavedFileName());
$obj->setVar('photo', $uploader->getSavedFileName()); } } else { $obj->setVar('photo', Request::getString('photo')); } } if (!empty($_FILES['photo2']['name'])) { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploaddir2 = XOOPS_ROOT_PATH . '/modules/alumni/photos/now_photo'; $photomax = $xoops->getModuleConfig('alumni_photomax'); $maxwide = $xoops->getModuleConfig('alumni_maxwide'); $maxhigh = $xoops->getModuleConfig('alumni_maxhigh'); $allowed_mimetypes = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); $uploader2 = new XoopsMediaUploader($uploaddir2, $allowed_mimetypes, $photomax, $maxwide, $maxhigh); if ($uploader2->fetchMedia($_POST['xoops_upload_file'][1])) { $uploader2->setTargetFileName($date . '_' . $_FILES['photo2']['name']); $uploader2->fetchMedia($_POST['xoops_upload_file'][1]); if (!$uploader2->upload()) { $errors = $uploader2->getErrors(); $xoops->redirect('javascript:history.go(-1)', 3, $errors); } else { $obj->setVar('photo2', $uploader2->getSavedFileName()); } } else { $obj->setVar('photo2', Request::getString('photo2')); } } if ($new_id = $listingHandler->insert($obj)) { if ($xoops->getModuleConfig('alumni_moderated') == '1') { $xoops->redirect('index.php', 3, AlumniLocale::MODERATE); } else {
function storeUpload($post_field, $allowed_mimetypes = null, &$errors) { global $xoopsUser, $xoopsDB, $xoopsModule; include_once SMARTPARTNER_ROOT_PATH . 'class/uploader.php'; $config =& smartpartner_getModuleConfig(); $id = $this->getVar('id'); if (!isset($allowed_mimetypes)) { $hMime =& xoops_getmodulehandler('mimetype'); $allowed_mimetypes = $hMime->checkMimeTypes($post_field); if (!$allowed_mimetypes) { return false; } } /*$maxfilesize = $config['xhelp_uploadSize']; $maxfilewidth = $config['xhelp_uploadWidth']; $maxfileheight = $config['xhelp_uploadHeight'];*/ $maxfilesize = $config['maximum_filesize']; $maxfilewidth = 100000; //$config['maximum_image_width']; $maxfileheight = 100000; //$config['maximum_image_height']; if (!is_dir(smartpartner_getUploadDir())) { mkdir(smartpartner_getUploadDir(), 0757); } $uploader = new XoopsMediaUploader(smartpartner_getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); if ($uploader->fetchMedia($post_field)) { $file_title = $this->purifyText($uploader->getMediaName()); $uploader->setTargetFileName($id . "_" . $file_title); if ($uploader->upload()) { $this->setVar('filename', $uploader->getSavedFileName()); if ($this->getVar('name') == '') { $this->setVar('name', $this->getNameFromFilename()); } $this->setVar('mimetype', $uploader->getMediaType()); return true; } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } } else { $errors = array_merge($errors, $uploader->getErrors(false)); return false; } }
function saveNewVideoCategory() { $videoCatHandler =& xoops_getmodulehandler('video_category', 'vidshop'); $video = $videoCatHandler->create(); $video->setVar('name', $_REQUEST["name"]); $video->setVar('description', $_REQUEST["description"]); if (isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $destname = md5(time()) . '_' . $fldname; /** * You can attach files to your news, actually : Web pictures (png, gif, jpeg), zip, pdf, gtar, tar, pdf */ $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, 1024 * 1024 * 3); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $video->setVar('image', str_replace(XOOPS_ROOT_PATH, '', $destname)); } else { echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); } } } if ($cid = $videoCatHandler->insert($video)) { if (!strpos($_SERVER['REQUEST_URI'], '/vidshop/admin/')) { redirect_header('admin.php?op=cats&fct=edit&id=' . $cid, 8, sprintf(_VSP_RH_CATEGORY_EDITED, $video->getVar('name'))); } else { redirect_header('admin.php?op=cats', 8, sprintf(_VSP_RH_CATEGORY_EDITED, $video->getVar('name'))); } exit(0); } else { redirect_header('index.php', 4, sprintf(_VSP_RH_CATEGORY_NOCREATION, $video->getVar('name'), implode('<br/>', $video->getErrors()))); exit(0); } }
} else { $obj =& $tablesHandler->create(); } $tables_blocs = isset($_REQUEST['tables_blocs']) ? $_REQUEST['tables_blocs'] : '0'; $tables_display_admin = isset($_REQUEST['tables_display_admin']) ? $_REQUEST['tables_display_admin'] : '0'; $tables_search = isset($_REQUEST['tables_search']) ? $_REQUEST['tables_search'] : '0'; $tables_coms = isset($_REQUEST['tables_coms']) ? $_REQUEST['tables_coms'] : '0'; $select = isset($_REQUEST['select']) ? $_REQUEST['select'] : '0'; //Image include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploaddir = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/images/uploads/tables/"; $uploader = new XoopsMediaUploader($uploaddir, "gif|jpeg|pjpeg|png", 104857600, null, null); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $extension = preg_replace("/^.+\\.([^.]+)\$/sU", "\\1", $_FILES["attachedfile"]['name']); $name_img = $_REQUEST['tables_name'] . '.' . $extension; $uploader->setTargetFileName($name_img); $uploader->fetchMedia($_POST['xoops_upload_file'][0]); if (!$uploader->upload()) { $errors = $uploader->getErrors(); redirect_header("javascript:history.go(-1)", 3, $errors); } else { $obj->setVar('tables_img', $uploader->getSavedFileName()); } } else { $obj->setVar('tables_img', $_REQUEST['tables_img']); } if ($tablesHandler->insert($obj)) { $tables_id = $xoopsDB->getInsertId(); $obj = $tablesHandler->get($tables_id); $form = $obj->getFormChamps(false, $tables_id, intval($_REQUEST['tables_modules']), strtolower($_REQUEST['tables_name']), $tables_blocs, $tables_display_admin, $tables_search, $tables_coms, intval($_REQUEST['tables_nb_champs']), $select); }
function addTopic() { global $xoopsDB, $xoopsModule, $xoopsModuleConfig; $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0; $xt = new nw_NewsTopic(); if (!$xt->topicExists($topicpid, $_POST['topic_title'])) { $xt->setTopicPid($topicpid); if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title'])=='') { redirect_header( 'index.php?op=topicsmanager', 2, _AM_NW_ERRORTOPICNAME ); } $xt->setTopicTitle($_POST['topic_title']); //$xt->Settopic_rssurl($_POST['topic_rssfeed']); $xt->setTopic_color($_POST['topic_color']); if (isset($_POST['topic_imgurl'] ) && $_POST['topic_imgurl'] != '') { $xt->setTopicImgurl($_POST['topic_imgurl'] ); } $xt->setMenu(intval($_POST['submenu'])); $xt->setTopicFrontpage(intval($_POST['topic_frontpage'])); if(isset($_SESSION['items_count'])) { $_SESSION['items_count'] = -1; } if(isset($_POST['xoops_upload_file'])) { $fldname = $_FILES[$_POST['xoops_upload_file'][0]]; $fldname = (get_magic_quotes_gpc()) ? stripslashes($fldname['name']) : $fldname['name']; if(xoops_trim($fldname!='')) { $sfiles = new nw_sFiles(); $dstpath = NW_TOPICS_FILES_PATH; $destname=$sfiles->createUploadName($dstpath ,$fldname, true); $permittedtypes=array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'); $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']); $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { if ($uploader->upload()) { $xt->setTopicImgurl(basename($destname)); } else { echo _AM_NW_UPLOAD_ERROR . ' ' . $uploader->getErrors(); } } else { echo $uploader->getErrors(); } } } if(isset($_POST['topic_description'])) { $xt->setTopicDescription($_POST['topic_description']); } else { $xt->setTopicDescription(''); } $xt->store(); // Permissions $gperm_handler = &xoops_gethandler('groupperm'); if(isset($_POST['groups_news_can_approve'])) { foreach($_POST['groups_news_can_approve'] as $onegroup_id) { $gperm_handler->addRight('nw_approve', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if(isset($_POST['groups_news_can_submit'])) { foreach($_POST['groups_news_can_submit'] as $onegroup_id) { $gperm_handler->addRight('nw_submit', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } if(isset($_POST['groups_news_can_view'])) { foreach($_POST['groups_news_can_view'] as $onegroup_id) { $gperm_handler->addRight('nw_view', $xt->topic_id(), $onegroup_id, $xoopsModule->getVar('mid')); } } nw_updateCache(); $notification_handler = & xoops_gethandler('notification'); $tags = array(); $tags['TOPIC_NAME'] = $_POST['topic_title']; $notification_handler->triggerEvent( 'global', 0, 'new_category', $tags); redirect_header('index.php?op=topicsmanager', 1, _AM_NW_DBUPDATED); } else { redirect_header('index.php?op=topicsmanager', 2, _AM_NW_ADD_TOPIC_ERROR); } exit(); }
$obj->setVar('sczip', Request::getString('sczip')); $obj->setVar('scphone', Request::getString('scphone')); $obj->setVar('scfax', Request::getString('scfax')); $obj->setVar('scmotto', Request::getString('scmotto')); $obj->setVar('scurl', Request::getString('scurl')); $date = time(); if (!empty($_FILES['scphoto']['name'])) { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploaddir = XOOPS_ROOT_PATH . "/modules/{$moduleDirName}/photos/school_photos"; $photomax = $xoops->getModuleConfig('alumni_photomax'); $maxwide = $xoops->getModuleConfig('alumni_maxwide'); $maxhigh = $xoops->getModuleConfig('alumni_maxhigh'); $allowedMimetypes = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); $uploader = new XoopsMediaUploader($uploaddir, $allowedMimetypes, $photomax, $maxwide, $maxhigh); if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { $uploader->setTargetFileName($date . '_' . $_FILES['scphoto']['name']); $uploader->fetchMedia($_POST['xoops_upload_file'][1]); if (!$uploader->upload()) { $errors = $uploader->getErrors(); $xoops->redirect('javascript:history.go(-1)', 3, $errors); } else { $obj->setVar('scphoto', $uploader->getSavedFileName()); } } else { $obj->setVar('scphoto', Request::getString('scphoto')); } } if ($categoriesHandler->insert($obj)) { $xoops->redirect('category.php', 3, AlumniLocale::FORMOK); } echo $obj->getHtmlErrors();
/** * Guardamos una im?gen */ function rmmfSaveImg() { global $db, $mc; $id = isset($_POST['id']) ? $_POST['id'] : 0; if ($id <= 0) { header('location: index.php'); die; } include_once '../class/work.class.php'; $work = new MFWork($id); if (!$work->getVar('found')) { redirect_header('index.php', 1, _MA_RMMF_ERRNOEXIST); die; } $dir = rmmf_add_slash($mc['storedir']); if (!is_uploaded_file($_FILES['archivo']['tmp_name'])) { redirect_header('index.php?op=imgs&id=' . $id, 1, _MA_RMMF_ERRIMG); die; } include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $upload = new XoopsMediaUploader($mc['storedir'], array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/pjpg', 'image/x-png', 'image/png'), 1024 * 1024); $ext = strrchr($_FILES['archivo']['name'], "."); $ext = strtolower($ext); do { $newname = rmmf_make_random(8, 'mfex') . $ext; } while (file_exists($dir . $newname)); $upload->setTargetFileName($newname); $upload->fetchMedia('archivo'); if (!$upload->upload()) { redirect_header("?op=imgs&id=" . $id, 1, $upload->getErrors()); exit; } else { $newname = $upload->getSavedFileName(); } // Redimensionamos las im?genes rmmf_image_resize($dir . $newname, $dir . $newname, $mc['imgw'], $mc['imgh']); if (!is_dir($dir . 'ths/')) { mkdir($dir . 'ths/', 0777); } //rmmf_image_resize($dir . $newname, $dir . 'ths/' . $newname, $mc['thw'], $mc['thh']); resize_then_crop($dir . $newname, $dir . 'ths/' . $newname, $mc['thw'], $mc['thh'], 255, 255, 255); // Guardamos en la base de datos $db->query("INSERT INTO " . $db->prefix("rmmf_images") . " (`archivo`,`work`)\n\t\t\tVALUES ('{$newname}', '{$id}')"); if ($db->error() != '') { redirect_header('index.php?op=imgs&id=' . $id, 2, sprintf(_MA_RMMF_ERRDB, $db->error())); die; } else { redirect_header('index.php?op=imgs&id=' . $id, 2, ''); die; } }
/** * Fonction chargée de gérer l'upload * * @param integer $indice L'indice du fichier à télécharger * @return mixed True si l'upload s'est bien déroulé sinon le message d'erreur correspondant */ function uploadFile($indice, $dstpath = XOOPS_UPLOAD_PATH, $mimeTypes = null, $uploadMaxSize = null) { require_once XOOPS_ROOT_PATH . '/class/uploader.php'; global $destname; if (isset($_POST['xoops_upload_file'])) { require_once XOOPS_ROOT_PATH . '/class/uploader.php'; $fldname = ''; $fldname = $_FILES[$_POST['xoops_upload_file'][$indice]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $destname = self::createUploadName($dstpath, $fldname, true); if ($mimeTypes === null) { $permittedtypes = explode("\n", str_replace("\r", '', self::getModuleOption('mimetypes'))); array_walk($permittedtypes, 'trim'); } else { $permittedtypes = $mimeTypes; } if ($uploadMaxSize === null) { $uploadSize = self::getModuleOption('maxuploadsize'); } else { $uploadSize = $uploadMaxSize; } $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $uploadSize); //$uploader->allowUnknownTypes = true; $uploader->setTargetFileName($destname); if ($uploader->fetchMedia($_POST['xoops_upload_file'][$indice])) { if ($uploader->upload()) { return true; } else { return _ERRORS . ' ' . htmlentities($uploader->getErrors()); } } else { return htmlentities($uploader->getErrors()); } } else { return false; } } else { return false; } }