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; } }
case 1: //Submitters and Approvers $allowupload = true; break; case 2: //Approvers only $allowupload = $approveprivilege ? true : false; break; case 3: //Upload Disabled $allowupload = false; break; } if ($allowupload) { if ($op == 'edit') { $sfiles = new sFiles(); $filesarr = array(); $filesarr = $sfiles->getAllbyStory($storyid); if (count($filesarr) > 0) { $upl_tray = new XoopsFormElementTray(_AM_UPLOAD_ATTACHFILE, '<br />'); $upl_checkbox = new XoopsFormCheckBox('', 'delupload[]'); foreach ($filesarr as $onefile) { $link = sprintf("<a href='%s/%s' target='_blank'>%s</a>\n", XOOPS_UPLOAD_URL, $onefile->getDownloadname('S'), $onefile->getFileRealName('S')); $upl_checkbox->addOption($onefile->getFileid(), $link); } $upl_tray->addElement($upl_checkbox, false); $dellabel = new XoopsFormLabel(_AM_DELETE_SELFILES, ''); $upl_tray->addElement($dellabel, false); $sform->addElement($upl_tray); } }
$notification_handler->triggerEvent('global', 0, 'story_submit', $tags); } } if ($allowupload) { // Manage upload(s) if (isset($_POST['delupload']) && count($_POST['delupload']) > 0) { foreach ($_POST['delupload'] as $onefile) { $sfiles = new sFiles($onefile); $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()) {
// // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include_once '../../mainfile.php'; include_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; $fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0; if (empty($fileid)) { redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _ERRORS); exit; } $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $sfiles = new sFiles($fileid); // Do we have the right to see the file ? $article = new NewsStory($sfiles->getStoryid()); // and the news, can we see it ? if ($article->published() == 0 || $article->published() > time()) { redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); exit; } // Expired if ($article->expired() != 0 && $article->expired() < time()) { redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); exit; } $gperm_handler =& xoops_gethandler('groupperm'); if (is_object($xoopsUser)) { $groups = $xoopsUser->getGroups();
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; }
$xoopsOption['storynum'] = $xoopsModuleConfig['storyhome']; } if (isset($_GET['start'])) { $start = intval($_GET['start']); } else { $start = 0; } if (empty($xoopsModuleConfig['newsdisplay']) || $xoopsModuleConfig['newsdisplay'] == 'Classic' || $xoopsOption['storytopic'] > 0) { $showclassic = 1; } else { $showclassic = 0; } $firsttitle = ''; $topictitle = ''; $myts =& MyTextSanitizer::getInstance(); $sfiles = new sFiles(); $column_count = $xoopsModuleConfig['columnmode']; if ($showclassic) { $xoopsOption['template_main'] = 'news_index.html'; include_once XOOPS_ROOT_PATH . '/header.php'; $xt = new NewsTopic(); $xoopsTpl->assign('columnwidth', intval(1 / $column_count * 100)); if ($xoopsModuleConfig['ratenews']) { $xoopsTpl->assign('rates', true); $xoopsTpl->assign('lang_ratingc', _NW_RATINGC); $xoopsTpl->assign('lang_ratethisnews', _NW_RATETHISNEWS); } else { $xoopsTpl->assign('rates', false); } if ($xoopsOption['storytopic']) { $xt->getTopic($xoopsOption['storytopic']);
// You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // include_once "../../mainfile.php"; include_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; $fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0; if (empty($fileid)) { redirect_header(XOOPS_URL . "/modules/news/index.php", 2, _ERRORS); exit; } $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $sfiles = new sFiles($fileid); $sfiles->updateCounter(); $url = XOOPS_UPLOAD_URL . '/' . $sfiles->getDownloadname(); if (!preg_match("/^ed2k*:\\/\\//i", $url)) { Header("Location: {$url}"); } echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=" . $myts->oopsHtmlSpecialChars($url) . "\"></meta></head><body></body></html>"; exit;
$news->story_type = $article['story_type']; $news->setTopicdisplay($article['topicdisplay']); $news->setTopicalign($article['topicalign']); $news->setComments($article['comments']); $news->rating = $article['rating']; $news->votes = $votes['cpt']; $approved = $article['published'] > 0 ? true : false; $news->approved = $approved; $news->store($approved); echo '<br> This story was imported : ' . $news->title(); $news_newsid = $news->storyid(); // ******************** // The files $result4 = $db->query('SELECT * FROM ' . $ams_files . ' WHERE storyid=' . $ams_newsid); while ($file = $db->fetchArray($result4)) { $sfile = new sFiles(); $sfile->setFileRealName($file['filerealname']); $sfile->setStoryid($news_newsid); $sfile->date = $file['date']; $sfile->setMimetype($file['mimetype']); $sfile->setDownloadname($file['downloadname']); $sfile->counter = $file['counter']; $sfile->store(); echo '<br> This file was imported : ' . $sfile->getDownloadname(); $news_fileid = $sfile->fileid; } // The ratings $result5 = $db->query('SELECT * FROM ' . $ams_rating . ' WHERE storyid=' . $ams_newsid); while ($ratings = $db->fetchArray($result5)) { $result6 = $db->queryF('INSERT INTO ' . $news_stories_votedata . " (storyid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (" . $news_newsid . ',' . $ratings['ratinguser'] . ',' . $ratings['rating'] . ',' . $ratings['ratinghostname'] . ',' . $ratings['ratingtimestamp'] . ')'); }
case 1: //Submitters and Approvers $allowupload = true; break; case 2: //Approvers only $allowupload = $approveprivilege ? true : false; break; case 3: //Upload Disabled $allowupload = false; break; } if ($allowupload) { if ($edit) { $sfiles = new sFiles(); $filesarr = array(); $filesarr = $sfiles->getAllbyStory($story->storyid()); if (count($filesarr) > 0) { $upl_tray = new XoopsFormElementTray(_AMS_AM_UPLOAD_ATTACHFILE, '<br />'); $upl_checkbox = new XoopsFormCheckBox('', 'delupload[]'); foreach ($filesarr as $onefile) { $link = sprintf("<a href='%s/%s' target='_blank'>%s</a>\n", XOOPS_UPLOAD_URL, $onefile->getDownloadname('S'), $onefile->getFileRealName('S')); $upl_checkbox->addOption($onefile->getFileid(), $link); } $upl_tray->addElement($upl_checkbox, false); $dellabel = new XoopsFormLabel(_AMS_AM_DELETE_SELFILES, ''); $upl_tray->addElement($dellabel, false); $sform->addElement($upl_tray); } }