function file_upload($articleid) { global $wfsConfig; global $wfsUploadSize; if ($articleid == 0) return 21; $error = check_post_files('filename'); if ($error != 0) return $error; $upload = new uploadfile('filename'); $upload->loadPostVars(); $upload->setMaxFilesize($wfsUploadSize); $upload->setMode($wfsConfig['wfsmode']); $distfilename = $upload->doUploadToRandumFile(XOOPS_ROOT_PATH."/".$wfsConfig['filesbasepath']); if (!$distfilename) return $upload->getErrorCode(); $file = new WfsFiles(); $file->setByUploadFile($upload); $file->setFiledescript($_POST['filedescript']); // $file->setFiletext($_POST['filetext']); $file->setgroupid($_POST['groupid']); if (empty($_POST['fileshowname'])) { $file->setFileShowName($upload->getOriginalName()); } else { $file->setFileShowName($_POST['fileshowname']); } $file->setArticleid($articleid); $ret = $file->store(); if (!$ret) return 22; return 0; }
//$story->setGroupid($groupid); $story->setGroupid($groupid); $story->setNosmiley($nosmiley); $story->setPublished(0); $story->setExpired(0); $story->setNotifyPub($notifypub); echo $story->articleid; $story->setType('user'); $upload = new uploadfile($HTTP_POST_VARS['filename']); $distfilename = $upload->doUploadToRandumFile(XOOPS_ROOT_PATH . "/" . $wfsConfig['filesbasepath']); if ($distfilename) { $article = new WfsArticle($story->articleid); $file = new WfsFiles(); $file->setByUploadFile($HTTP_POST_VARS['filename']); if (empty($HTTP_POST_VARS['downloadfilename'])) { $file->setFileShowName($HTTP_POST_VARS['filename']); } else { $file->setFileShowName($HTTP_POST_VARS['$downloadfilename']); } $article->addFile($HTTP_POST_VARS['filename']); } if ($wfsConfig['autoapprove'] == 1) { $approve = 1; $story->setApproved($approve); $story->setPublished(time()); $story->setExpired(0); } $result = $story->store(); if ($result) { if ($wfsConfig['notifysubmit'] == 1) { $xoopsMailer =& getMailer();
check_permit_upload(); include XOOPS_ROOT_PATH.'/header.php'; include_once "$dir_module/class/wfsfiles.php"; file_editform($articleid,$fileid); include XOOPS_ROOT_PATH.'/footer.php'; break; // --- file save --- case "filesave": check_permit_upload(); include_once "$dir_module/class/wfsfiles.php"; $file = new WfsFiles($fileid); $file->setDownloadname($_POST['downloadname']); $file->setFileShowName($_POST['fileshowname']); $file->setFiledescript($_POST['filedescript']); $file->store(); redirect_header("modify.php?articleid=".$articleid,2,_WFS_FILE_MODIFY_END); exit(); break; // --- file delete comform --- case "filedelcomf": check_permit_upload(); include_once XOOPS_ROOT_PATH.'/include/cp_functions.php'; include_once "$dir_module/class/wfsfiles.php"; include XOOPS_ROOT_PATH.'/header.php';
global $wfsConfig; include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/class/uploadfile.php"; include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/class/wfsfiles.php"; $upload = new uploadfile(); $upload->loadPostVars(); $upload->setMode($wfsConfig['wfsmode']); $distfilename = $upload->doUploadToRandumFile(XOOPS_ROOT_PATH . "/" . $wfsConfig['filesbasepath']); if ($distfilename) { $article = new WfsArticle($HTTP_POST_VARS['articleid']); $file = new WfsFiles(); $file->setByUploadFile($upload); $file->setFiledescript($HTTP_POST_VARS['textfiledescript']); $file->setFiletext($HTTP_POST_VARS['textfilesearch']); $file->setgroupid($HTTP_POST_VARS['groupid']); if (empty($HTTP_POST_VARS['fileshowname'])) { $file->setFileShowName($upload->getOriginalName()); } else { $file->setFileShowName($HTTP_POST_VARS['fileshowname']); } $article->addFile($file); redirect_header("index.php?op=edit&articleid=" . $HTTP_POST_VARS['articleid'], 1, _AM_DBUPDATED); exit; } else { xoops_cp_header(); echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class='odd'>"; echo "<h4>" . _AM_UPDATEFAIL . "</h4>"; if (!$upload->isAllowedMineType()) { echo _AM_NOTALLOWEDMINETYPE . "<br />"; } if (!$upload->isAllowedFileSize()) { echo _AM_FILETOOBIG . "<br />";
// error message // $distfilename = $upload->doUploadToRandumFile(XOOPS_ROOT_PATH."/".$wfsConfig['filesbasepath']); $filesbasepath = XOOPS_ROOT_PATH."/".$wfsConfig['filesbasepath']; $distfilename = $upload->doUploadToRandumFile($filesbasepath); $code = $upload->getErrorCode(); if ( $distfilename ) { $article = new WfsArticle($_POST['articleid']); $file = new WfsFiles(); $file->setByUploadFile($upload); $file->setFiledescript($_POST['textfiledescript']); $file->setFiletext($_POST['textfilesearch']); $file->setgroupid($_POST['groupid']); if (empty($_POST['fileshowname'])) { $file->setFileShowName($upload->getOriginalName()); } else { $file->setFileShowName($_POST['fileshowname']); } $article->addFile($file); redirect_header("index.php?op=edit&articleid=".$_POST['articleid'],1,_AM_DBUPDATED); exit(); // } else { } } xoops_cp_header(); echo"<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class='odd'>"; // error message