/** * Gestion de l'upload */ function formulaire_upload($indice, $dstpath, $destname, $permittedtypes, $maxUploadSize) { // global $destname; //$permittedtypes = array("image/gif","image/pjpeg","image/jpeg","image/x-png") ; $permittedtypes = $allowed_mimetypes; if (isset($_POST['xoops_upload_file'])) { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; if (isset($_FILES[$_POST['xoops_upload_file'][$indice]])) { $fldname = $_FILES[$_POST['xoops_upload_file'][$indice]]; $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name']; if (xoops_trim($fldname != '')) { $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $maxUploadSize); if ($uploader->fetchMedia($_POST['xoops_upload_file'][$indice])) { if ($uploader->upload()) { return true; } else { echo _ERRORS . ' ' . $uploader->getErrors(); echo "indice :" . $indice . "<br> dstpath :" . $dstpath . "<br> destname :" . $destname . " - " . $uploadDestName . "<br> permittedtypes :" . $permittedtypes[0] . "-" . $permittedtypes[1] . "-" . $permittedtypes[2] . "-" . $permittedtypes[3] . "<br>Max upload file:" . $maxUploadSize; exit; } } else { echo $uploader->getErrors(); } } } } 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; } }
/** * @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 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; } }
function createFile($eventId) { $userId = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getVar('uid') : 0; $allowedMimeType = array(); $mimeType = (include XOOPS_ROOT_PATH . '/class/mimetypes.inc.php'); foreach ($GLOBALS['xoopsModuleConfig']['allowed_file_extention'] as $fileExt) { $allowedMimeType[] = $mimeType[$fileExt]; } $uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/uploads/extcal', $allowedMimeType, 3145728); $uploader->setPrefix($userId . '-' . $eventId . '_'); if ($uploader->fetchMedia('event_file')) { if (!$uploader->upload()) { return false; } } else { return false; } $data = array('file_name' => $uploader->getSavedFileName(), 'file_nicename' => $uploader->getMediaName(), 'file_mimetype' => $uploader->getMediaType(), 'file_size' => $_FILES['event_file']['size'], 'file_date' => time(), 'file_approved' => 1, 'event_id' => $eventId, 'uid' => $userId); $file = $this->create(); $file->setVars($data); return $this->insert($file); }
function addFolder($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_folder_handler; include_once XOOPS_ROOT_PATH . "/class/uploader.php"; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); $upload_msgs = array(); $folderid = isset($_POST['folderid']) ? intval($_POST['folderid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($folderid != 0) { $folderObj = $smartmedia_folder_handler->get($folderid, $languageid); } else { $folderObj = $smartmedia_folder_handler->create(); } if (!$language_text) { /* // Upload lr_image if ( $_FILES['lr_image_file']['name'] != "" ) { $filename = $_POST["xoops_upload_file"][0] ; if( !empty( $filename ) || $filename != "" ) { if( $_FILES[$filename]['tmp_name'] == "" || ! is_readable( $_FILES[$filename]['tmp_name'] ) ) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('folder'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if( $uploader->fetchMedia( $filename ) && $uploader->upload() ) { $folderObj->setVar('image_lr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $folderObj->setVar('image_lr', $_POST['image_lr']); } */ // Upload hr_image if ($_FILES['hr_image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('folder'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $folderObj->setVar('image_hr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $folderObj->setVar('image_hr', $_POST['image_hr']); } $folderObj->setVar('statusid', isset($_POST['statusid']) ? intval($_POST['statusid']) : 0); $folderObj->setVar('categoryid', isset($_POST['categoryid']) ? intval($_POST['categoryid']) : 0); $folderObj->setVar('new_category', isset($_POST['category_action']) ? $_POST['category_action'] == 'add' : false); $folderObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $folderObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $folderObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $folderObj->setTextVar('languageid', $languageid); } $folderObj->setTextVar('languageid', $languageid); $folderObj->setTextVar('title', $_POST['title']); $folderObj->setTextVar('short_title', $_POST['short_title']); $folderObj->setTextVar('summary', $_POST['summary']); $folderObj->setTextVar('description', $_POST['description']); $folderObj->setTextVar('meta_description', $_POST['meta_description']); if ($folderObj->isNew()) { $redirect_msg = _AM_SMEDIA_FOLDER_CREATED; $redirect_to = 'folder.php'; } else { if ($language_text) { $redirect_to = 'folder.php?op=mod&folderid=' . $folderObj->folderid(); } else { $redirect_to = 'folder.php'; } $redirect_msg = _AM_SMEDIA_FOLDER_MODIFIED; } if (!$folderObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_FOLDER_SAVE_ERROR . smartmedia_formatErrors($folderObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
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; }
} else { $obj = $avatar_Handler->create(); } $error_msg = ''; $obj->setVars($_POST); if (preg_match('/^\\d+$/', $_POST["avatar_weight"]) == false) { $error_msg .= XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER . '<br />'; $obj->setVar("avatar_weight", 0); } else { $obj->setVar("avatar_weight", Request::getInt('avatar_weight', 0)); } $obj->setVar('avatar_type', 'C'); if ($uploader_avatars_img->fetchMedia('avatar_file')) { $uploader_avatars_img->setPrefix('savt'); $uploader_avatars_img->fetchMedia('avatar_file'); if (!$uploader_avatars_img->upload()) { $error_msg .= $uploader_avatars_img->getErrors(); $obj->setVar('avatar_file', 'avatars/blank.gif'); } else { $obj->setVar('avatar_mimetype', $uploader_avatars_img->getMediaType()); $obj->setVar('avatar_file', 'avatars/' . $uploader_avatars_img->getSavedFileName()); } } else { $file = Request::getString('avatar_file', 'blank.gif'); $obj->setVar('avatar_file', 'avatars/' . $file); } if ($error_msg == '') { if ($avatar_Handler->insert($obj)) { $xoops->redirect('avatar_custom.php', 2, XoopsLocale::S_ITEM_SAVED); } $error_msg .= $obj->getHtmlErrors();
include XOOPS_ROOT_PATH . '/footer.php'; exit; } if ($op == 'avatarupload') { if (!$xoopsGTicket->check(true, 'avatarupload', false)) { redirect_header(XOOPS_URL . '/', 3, $xoopsGTiket->getErrors()); exit; } if ($myxoopsConfigUser['avatar_allow_upload'] == 1 && $u_obj->getVar('posts', 's') >= $myxoopsConfigUser['avatar_minposts']) { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $myxoopsConfigUser['avatar_maxsize'], $myxoopsConfigUser['avatar_width'], $myxoopsConfigUser['avatar_height']); $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png')); $xoops_upload_file = $formdata->getValueArray('post', 'xoops_upload_file', 's', true); if ($uploader->fetchMedia($xoops_upload_file[0])) { $uploader->setPrefix('cavt'); if ($uploader->upload()) { $avt_handler =& xoops_gethandler('avatar'); $avatar =& $avt_handler->create(); $avatar->setVar('avatar_file', $uploader->getSavedFileName()); $avatar->setVar('avatar_name', $u_obj->getVar('uname', 'n'), true); // not gpc $avatar->setVar('avatar_mimetype', $uploader->getMediaType()); $avatar->setVar('avatar_display', 1); $avatar->setVar('avatar_type', 'C'); if (!$avt_handler->insert($avatar)) { @unlink($uploader->getSavedDestination()); } else { $oldavatar = $u_obj->getVar('user_avatar', 's'); if (!empty($oldavatar) && $oldavatar != 'blank.gif' && !preg_match('/^savt/', strtolower($oldavatar))) { $avatars =& $avt_handler->getObjects(new Criteria('avatar_file', $oldavatar)); $avt_handler->delete($avatars[0]);
function addClip($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_clip_handler; include_once XOOPS_ROOT_PATH . "/class/uploader.php"; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); $upload_msgs = array(); $clipid = isset($_POST['clipid']) ? intval($_POST['clipid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($clipid != 0) { $clipObj = $smartmedia_clip_handler->get($clipid, $languageid); } else { $clipObj = $smartmedia_clip_handler->create(); } if (!$language_text) { /* // Upload lr_image if ( $_FILES['lr_image_file']['name'] != "" ) { $filename = $_POST["xoops_upload_file"][0] ; if( !empty( $filename ) || $filename != "" ) { if( $_FILES[$filename]['tmp_name'] == "" || ! is_readable( $_FILES[$filename]['tmp_name'] ) ) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('clip'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if( $uploader->fetchMedia( $filename ) && $uploader->upload() ) { $clipObj->setVar('image_lr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $clipObj->setVar('image_lr', $_POST['image_lr']); } */ // Upload hr_image if ($_FILES['hr_image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('clip'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $clipObj->setVar('image_hr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $clipObj->setVar('image_hr', $_POST['image_hr']); } //var_dump($uploader->errors); //exit; $clipObj->setVar('width', isset($_POST['width']) ? intval($_POST['width']) : 320); $clipObj->setVar('height', isset($_POST['height']) ? intval($_POST['height']) : 260); $clipObj->setVar('folderid', isset($_POST['folderid']) ? intval($_POST['folderid']) : 0); $clipObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $clipObj->setVar('file_hr', $_POST['file_hr']); $clipObj->setVar('file_lr', $_POST['file_lr']); $clipObj->setVar('formatid', $_POST['formatid']); $clipObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $clipObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $clipObj->setTextVar('languageid', $languageid); } $clipObj->setTextVar('languageid', $languageid); $clipObj->setTextVar('title', $_POST['title']); $clipObj->setTextVar('description', $_POST['description']); $clipObj->setTextVar('meta_description', $_POST['meta_description']); $clipObj->setTextVar('tab_caption_1', $_POST['tab_caption_1']); $clipObj->setTextVar('tab_text_1', $_POST['tab_text_1']); $clipObj->setTextVar('tab_caption_2', $_POST['tab_caption_2']); $clipObj->setTextVar('tab_text_2', $_POST['tab_text_2']); $clipObj->setTextVar('tab_caption_3', $_POST['tab_caption_3']); $clipObj->setTextVar('tab_text_3', $_POST['tab_text_3']); if (!$xoopsUser) { $uid = 0; } else { $uid = $xoopsUser->uid(); } $clipObj->setVar('modified_uid', $uid); if ($clipObj->isNew()) { $clipObj->setVar('created_uid', $uid); $redirect_msg = _AM_SMEDIA_CLIP_CREATED; $redirect_to = 'clip.php'; } else { if ($language_text) { $redirect_to = 'clip.php?op=mod&clipid=' . $clipObj->clipid(); } else { if (isset($_GET['from_within'])) { // To come... } $redirect_to = 'clip.php'; } $redirect_msg = _AM_SMEDIA_CLIP_MODIFIED; } if (!$clipObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_CLIP_SAVE_ERROR . smartmedia_formatErrors($clipObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
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); } }
/** * Saves a new/updated rank into the database * * @todo $_FILES['rank_image'] is an array and should be treated as such! */ function RankForumSave($rank_id, $rank_title, $rank_min, $rank_max, $rank_image, $rank_special, $old_rank) { global $HTTP_POST_VARS, $HTTP_POST_FILES; $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); if (isset($rank_image['name']) && trim($rank_image['name']) != '') { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); $uploader->setPrefix('rank'); if ($uploader->fetchMedia($HTTP_POST_VARS['xoops_upload_file'][0])) { if (!$uploader->upload()) { $err = $uploader->getErrors(); } else { $rank_title = $myts->makeTboxData4Save($rank_title); $rank_image = $myts->makeTboxData4Save($uploader->getSavedFileName()); if ($rank_special != 1) { $sql = "UPDATE " . $db->prefix("ranks") . " SET rank_title='{$rank_title}',rank_min=" . intval($rank_min) . ", rank_max=" . intval($rank_max) . ", rank_special=0, rank_image='{$rank_image}' WHERE rank_id=" . $rank_id; } else { $sql = "UPDATE " . $db->prefix("ranks") . " SET rank_title='{$rank_title}', rank_min=-1, rank_max=-1, rank_special=1, rank_image='{$rank_image}' WHERE rank_id=" . $rank_id; } if (!$db->query($sql)) { $err = 'Failed storing rank data into the database'; } else { @unlink(XOOPS_UPLOAD_PATH . '/' . $old_rank); } } } else { $err = $uploader->getErrors(); } } else { $rank_title = $myts->makeTboxData4Save($rank_title); if ($rank_special != 1) { $sql = "UPDATE " . $db->prefix("ranks") . " SET rank_title='{$rank_title}',rank_min=" . intval($rank_min) . ", rank_max=" . intval($rank_max) . ", rank_special=0 WHERE rank_id=" . $rank_id; } else { $sql = "UPDATE " . $db->prefix("ranks") . " SET rank_title='{$rank_title}', rank_min=-1, rank_max=-1, rank_special=1 WHERE rank_id=" . $rank_id; } if (!$db->query($sql)) { $err = 'Failed storing rank data into the database'; } } if (!isset($err)) { redirect_header("admin.php?fct=userrank&op=RankForumAdmin", 1, _AM_DBUPDATED); } else { xoops_cp_header(); xoops_error($err); xoops_cp_footer(); exit; } }
function addCategory($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_category_handler; $categoryid = isset($_POST['categoryid']) ? intval($_POST['categoryid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($categoryid != 0) { $categoryObj = $smartmedia_category_handler->get($categoryid, $languageid); } else { $categoryObj = $smartmedia_category_handler->create(); } // Uploading the image, if any // Retreive the filename to be uploaded if (!$language_text) { if ($_FILES['image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { global $xoopsModuleConfig; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); include_once XOOPS_ROOT_PATH . "/class/uploader.php"; if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _AM_SMEDIA_FILEUPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(smartmedia_getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $categoryObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _AM_SMEDIA_FILEUPLOAD_ERROR . $uploader->getErrors()); exit; } } } else { $categoryObj->setVar('image', $_POST['image']); } $categoryObj->setVar('parentid', isset($_POST['parentid']) ? intval($_POST['parentid']) : 0); $categoryObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $categoryObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $categoryObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $categoryObj->setTextVar('languageid', $languageid); } $categoryObj->setTextVar('title', $_POST['title']); $categoryObj->setTextVar('description', $_POST['description']); if ($categoryObj->isNew()) { $redirect_msg = _AM_SMEDIA_CATCREATED; $redirect_to = 'category.php'; } else { if ($language_text) { $redirect_to = 'category.php?op=mod&categoryid=' . $categoryObj->categoryid(); } else { $redirect_to = 'category.php'; } $redirect_msg = _AM_SMEDIA_COLMODIFIED; } if (!$categoryObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_CATEGORY_SAVE_ERROR . smartmedia_formatErrors($categoryObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
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(); }
function dispatch() { if($this->isGuest()){ redirect_header(XOOPS_URL, 2, _NOPERM); } require XSNS_FRAMEWORK_DIR.'/global.php'; require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php'; if (!$this->validateToken('upload')) { redirect_header(XSNS_URL_MYPAGE_PROFILE, 3, _US_NOEDITRIGHT); } $config_handler =& xoops_gethandler('config'); if(defined('XOOPS_CUBE_LEGACY')){ $xoopsConfigUser =& $config_handler->getConfigsByDirname('user'); } else{ $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER); } $xoops_upload_file = array(); $uid = 0; if (!empty($_POST['xoops_upload_file']) && is_array($_POST['xoops_upload_file'])){ $xoops_upload_file = $_POST['xoops_upload_file']; } if (!empty($_POST['uid'])) { $uid = intval($_POST['uid']); } if (empty($uid) || $xoopsUser->getVar('uid') != $uid ) { redirect_header(XSNS_URL_MYPAGE_PROFILE, 3, _US_NOEDITRIGHT); } if ($xoopsConfigUser['avatar_allow_upload'] == 1 && $xoopsUser->getVar('posts') >= $xoopsConfigUser['avatar_minposts']) { require_once XOOPS_ROOT_PATH.'/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $xoopsConfigUser['avatar_maxsize'], $xoopsConfigUser['avatar_width'], $xoopsConfigUser['avatar_height']); $uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png')); if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { $uploader->setPrefix('cavt'); if ($uploader->upload()) { $avt_handler =& xoops_gethandler('avatar'); $avatar =& $avt_handler->create(); $avatar->setVar('avatar_file', $uploader->getSavedFileName()); $avatar->setVar('avatar_name', $xoopsUser->getVar('uname')); $avatar->setVar('avatar_mimetype', $uploader->getMediaType()); $avatar->setVar('avatar_display', 1); $avatar->setVar('avatar_type', 'C'); if (!$avt_handler->insert($avatar)) { @unlink($uploader->getSavedDestination()); } else { $oldavatar = $xoopsUser->getVar('user_avatar'); if (!empty($oldavatar) && $oldavatar != 'blank.gif' && !preg_match("/^savt/", strtolower($oldavatar))) { $avatars =& $avt_handler->getObjects(new Criteria('avatar_file', $oldavatar)); $avt_handler->delete($avatars[0]); $oldavatar_path = str_replace("\\", "/", realpath(XOOPS_UPLOAD_PATH.'/'.$oldavatar)); if (0 === strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) { unlink($oldavatar_path); } } $sql = sprintf("UPDATE %s SET user_avatar = %s WHERE uid = %u", $this->db->prefix('users'), $this->db->quoteString($uploader->getSavedFileName()), $xoopsUser->getVar('uid')); $this->db->query($sql); $avt_handler->addUser($avatar->getVar('avatar_id'), $xoopsUser->getVar('uid')); redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _US_PROFUPDATED); } } } redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _MD_XSNS_PROFILE_AVATAR_UPLOAD_NG); } redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _MD_XSNS_PROFILE_AVATAR_UPLOAD_NG); }
function receiveTribe($tribe_title, $tribe_desc, $tribe_img, $path_upload, $maxfilebytes, $maxfilewidth, $maxfileheight, $change_img = 1, $tribe = "") { global $xoopsUser, $xoopsDB, $_POST, $_FILES; //busca id do user logado $uid = $xoopsUser->getVar('uid'); if (!is_a($tribe, "yogurt_tribes")) { $tribe = $this->create(); } else { $tribe->unsetNew(); } if ($change_img == 1) { // mimetypes and settings put this in admin part later $allowed_mimetypes = array('image/jpeg', 'image/pjpeg'); $maxfilesize = $maxfilebytes; // create the object to upload $uploader = new XoopsMediaUploader($path_upload, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); // fetch the media if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { //lets create a name for it $uploader->setPrefix('tribe_' . $uid . '_'); //now let s upload the file if (!$uploader->upload()) { // if there are errors lets return them echo "<div style=\"color:#FF0000; background-color:#FFEAF4; border-color:#FF0000; border-width:thick; border-style:solid; text-align:center\"><p>" . $uploader->getErrors() . "</p></div>"; return false; } else { // now let s create a new object picture and set its variables $url = $uploader->getSavedFileName(); $saved_destination = $uploader->getSavedDestination(); $image_name = $this->resizeImage2($saved_destination, 125, 80, $path_upload); $tribe->setVar("tribe_img", $image_name); } } else { echo "<div style=\"color:#FF0000; background-color:#FFEAF4; border-color:#FF0000; border-width:thick; border-style:solid; text-align:center\"><p>" . $uploader->getErrors() . "</p></div>"; return false; } } $tribe->setVar("tribe_title", $tribe_title); $tribe->setVar("tribe_desc", $tribe_desc); $tribe->setVar("owner_uid", $uid); $this->insert($tribe); return true; }
$error_msg = ''; $obj->setVar("banner_cid", Request::getInt('cid', 0)); if (preg_match('/^[0-9]*[0-9]+$|^[0-9]+[0-9]*$/', $_POST["imptotal"]) == false) { $error_msg .= XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER . '<br />'; $obj->setVar("banner_imptotal", 0); } else { $obj->setVar("banner_imptotal", Request::getInt('imptotal', 0)); } $obj->setVar("banner_clickurl", Request::getString('clickurl', '')); $obj->setVar("banner_htmlbanner", Request::getInt('htmlbanner', 0)); $obj->setVar("banner_htmlcode", Request::getString('htmlcode', '')); $uploader_banners_img = new XoopsMediaUploader($xoops_upload_path . '/banners', $mimetypes, $upload_size, null, null); if ($uploader_banners_img->fetchMedia("banners_imageurl")) { $uploader_banners_img->setPrefix("banner"); $uploader_banners_img->fetchMedia("banners_imageurl"); if (!$uploader_banners_img->upload()) { $error_msg .= $uploader_banners_img->getErrors(); } else { $obj->setVar("banner_imageurl", $xoops_upload_url . '/banners/' . $uploader_banners_img->getSavedFileName()); } } else { if ($_POST["banners_imageurl"] === 'blank.gif') { $obj->setVar("banner_imageurl", Request::getString('imageurl', '')); } else { $obj->setVar("banner_imageurl", $xoops_upload_url . '/banners/' . Request::getString('banners_imageurl', '')); } } if ($error_msg == '') { if ($banner_Handler->insert($obj)) { $xoops->redirect("banners.php", 2, XoopsLocale::S_ITEM_SAVED); }
/** * Upload the file and Save into database * * @param text $title A litle description of the file * @param text $path_upload The path to where the file should be uploaded * @param text $author the author of the music or audio file * @return bool FALSE if upload fails or database fails */ function receiveAudio($title, $path_upload, $author, $maxfilebytes) { global $xoopsUser, $xoopsDB, $_POST, $_FILES; //busca id do user logado $uid = $xoopsUser->getVar('uid'); //create a hash so it does not erase another file //$hash1 = date(); //$hash = substr($hash1,0,4); // mimetypes and settings put this in admin part later $allowed_mimetypes = array("audio/mp3", "audio/x-mp3", "audio/mpeg"); $maxfilesize = $maxfilebytes; // create the object to upload $uploader = new XoopsMediaUploader($path_upload, $allowed_mimetypes, $maxfilesize); // fetch the media if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { //lets create a name for it $uploader->setPrefix('aud_' . $uid . '_'); //now let s upload the file if (!$uploader->upload()) { // if there are errors lets return them echo "<div style=\"color:#FF0000; background-color:#FFEAF4; border-color:#FF0000; border-width:thick; border-style:solid; text-align:center\"><p>" . $uploader->getErrors() . "</p></div>"; return false; } else { // now let s create a new object audio and set its variables //echo "passei aqui"; $audio = $this->create(); $url = $uploader->getSavedFileName(); $audio->setVar("url", $url); $audio->setVar("title", $title); $audio->setVar("author", $author); $uid = $xoopsUser->getVar('uid'); $audio->setVar("uid_owner", $uid); $this->insert($audio); $saved_destination = $uploader->getSavedDestination(); //print_r($_FILES); } } else { echo "<div style=\"color:#FF0000; background-color:#FFEAF4; border-color:#FF0000; border-width:thick; border-style:solid; text-align:center\"><p>" . $uploader->getErrors() . "</p></div>"; return false; } return true; }
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; } }
} if (isset($_POST["rank_id"])) { $obj = $userrank_Handler->get($_POST["rank_id"]); } else { $obj = $userrank_Handler->create(); } $obj->setVar("rank_title", $_POST["rank_title"]); $obj->setVar("rank_min", $_POST["rank_min"]); $obj->setVar("rank_max", $_POST["rank_max"]); $verif_rank_special = $_POST["rank_special"] == 1 ? "1" : "0"; $obj->setVar("rank_special", $verif_rank_special); $uploader_rank_img = new XoopsMediaUploader(\XoopsBaseConfig::get('uploads-url') . '/ranks', $mimetypes, $upload_size, null, null); if ($uploader_rank_img->fetchMedia("rank_image")) { $uploader_rank_img->setPrefix("rank"); $uploader_rank_img->fetchMedia("rank_image"); if (!$uploader_rank_img->upload()) { $errors = $uploader_rank_img->getErrors(); $xoops->redirect("javascript:history.go(-1)", 3, $errors); } else { $obj->setVar("rank_image", 'ranks/' . $uploader_rank_img->getSavedFileName()); } } else { $obj->setVar("rank_image", 'ranks/' . $_POST["rank_image"]); } if ($userrank_Handler->insert($obj)) { $xoops->redirect("userrank.php", 2, _AM_USERRANK_SAVE); } break; // Delete userrank // Delete userrank case 'userrank_delete':
if (isset($_POST["smilies_id"])) { $obj =& $smilies_Handler->get(system_CleanVars($_POST, 'smilies_id', 0, 'int')); } else { $obj =& $smilies_Handler->create(); } // erreur $obj->setVar("code", $_POST["code"]); $obj->setVar("emotion", $_POST["emotion"]); $display = $_POST["display"] == 1 ? "1" : "0"; $obj->setVar("display", $display); include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader_smilies_img = new XoopsMediaUploader(XOOPS_UPLOAD_PATH . '/smilies', $mimetypes, $upload_size, null, null); if ($uploader_smilies_img->fetchMedia("smile_url")) { $uploader_smilies_img->setPrefix("smil"); $uploader_smilies_img->fetchMedia("smile_url"); if (!$uploader_smilies_img->upload()) { $errors = $uploader_smilies_img->getErrors(); redirect_header("javascript:history.go(-1)", 3, $errors); } else { $obj->setVar("smile_url", 'smilies/' . $uploader_smilies_img->getSavedFileName()); } } else { $obj->setVar("smile_url", 'smilies/' . $_POST["smile_url"]); } if ($smilies_Handler->insert($obj)) { redirect_header("admin.php?fct=smilies", 2, _AM_SYSTEM_SMILIES_SAVE); } echo $obj->getHtmlErrors(); // Create form $obj =& $smilies_Handler->create(); $form =& $obj->getForm();
/** * @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 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; } }
$filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { global $xoopsModuleConfig; $max_size = 10000000; $max_imgwidth = $xoopsModuleConfig['img_max_width']; $max_imgheight = $xoopsModuleConfig['img_max_height']; $allowed_mimetypes = smartclient_getAllowedMimeTypes(); include_once XOOPS_ROOT_PATH . "/class/uploader.php"; if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _CO_SCLIENT_FILE_UPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(smartclient_getImageDir(), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); // TODO : prefix the image file with the clientid, but for that we need to first save the client to get clientid... // $uploader->setTargetFileName($clientObj->clientid() . "_" . $_FILES['logo_file']['name']); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $clientObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _CO_SCLIENT_FILE_UPLOAD_ERROR . $uploader->getErrors()); exit; } } } else { $clientObj->setVar('image', $_POST['image']); } // Putting the values in the client object $clientObj->setVar('id', isset($_POST['id']) ? intval($_POST['id']) : 0); $clientObj->setVar('status', isset($_POST['status']) ? intval($_POST['status']) : 0); $clientObj->setVar('title', $_POST['title']); $clientObj->setVar('summary', $_POST['summary']); $clientObj->setVar('image_url', $_POST['image_url']);
} 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 { $xoops->redirect('listing.php?lid=' . $new_id . '', 3, XoopsLocale::S_DATABASE_UPDATED); }
/** * 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; } }
</script>'; } break; case 'update': if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.php?fct=tplsets', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())); } include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf'), 200000); $uploader->setPrefix('tmp'); $msg = array(); foreach ($_POST['xoops_upload_file'] as $upload_file) { // '.' is converted to '_' when upload $upload_file2 = str_replace('.', '_', $upload_file); if ($uploader->fetchMedia($upload_file2)) { if (!$uploader->upload()) { $msg[] = $uploader->getErrors(); } else { $tpltpl_handler =& xoops_gethandler('tplfile'); if (!isset($old_template[$upload_file])) { $tplfile =& $tpltpl_handler->find('default', null, null, $moddir, $upload_file); if (count($tplfile) > 0) { $tpl =& $tplfile[0]->xoopsClone(); $tpl->setVar('tpl_id', 0); $tpl->setVar('tpl_tplset', $tplset); } else { $msg[] = 'Template file <b>' . $upload_file . '</b> does not need to be installed (PHP files using this template file does not exist)'; continue; } } else { $tpl =& $tpltpl_handler->get($old_template[$upload_file]);
function SmilesSave($id, $smile_code, $smile_url, $smile_desc, $smile_display, $old_smile) { global $HTTP_POST_VARS; $db =& Database::getInstance(); $myts =& MyTextSanitizer::getInstance(); if (isset($smile_url) && trim($smile_url) != '') { include_once XOOPS_ROOT_PATH . '/class/uploader.php'; $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png'), 100000, 120, 120); $uploader->setPrefix('smil'); if ($uploader->fetchMedia($HTTP_POST_VARS['xoops_upload_file'][0])) { if (!$uploader->upload()) { $err = $uploader->getErrors(); } else { $smile_url = $myts->makeTboxData4Save($uploader->getSavedFileName()); $smile_code = $myts->makeTboxData4Save($smile_code); $smile_desc = $myts->makeTboxData4Save($smile_desc); $smile_display = intval($smile_display) > 0 ? 1 : 0; if (!$db->query("UPDATE " . $db->prefix('smiles') . " SET code = '{$smile_code}', smile_url = '{$smile_url}', emotion = '{$smile_desc}', display={$smile_display} WHERE id =" . intval($id))) { $err = 'Failed storing smiley data into the database'; } else { @unlink(XOOPS_UPLOAD_PATH . '/' . $old_smile); } } } else { $err = $uploader->getErrors(); } } else { $smile_code = $myts->makeTboxData4Save($smile_code); $smile_desc = $myts->makeTboxData4Save($smile_desc); $smile_display = intval($smile_display) > 0 ? 1 : 0; if (!$db->query("UPDATE " . $db->prefix('smiles') . " SET code = '{$smile_code}', emotion = '{$smile_desc}', display={$smile_display} WHERE id =" . intval($id))) { $err = 'Failed storing smiley data into the database'; } } if (!isset($err)) { redirect_header('admin.php?fct=smilies&op=SmilesAdmin', 2, _AM_DBUPDATED); } else { xoops_cp_header(); xoops_error($err); xoops_cp_footer(); exit; } }