function nw_b_news_latestnews_show($options) { global $xoopsTpl, $xoopsUser, $xoopsConfig; include_once NW_MODULE_PATH . '/include/functions.php'; $block = array(); include_once NW_MODULE_PATH . '/class/class.newsstory.php'; include_once NW_MODULE_PATH . '/class/class.sfiles.php'; include_once NW_MODULE_PATH . '/class/class.newstopic.php'; include_once NW_MODULE_PATH . '/class/class.latestnews.php'; //Bandit-X include_once XOOPS_ROOT_PATH . '/class/tree.php'; if (file_exists(NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php')) { include_once NW_MODULE_PATH . '/language/'.$xoopsConfig['language'].'/main.php'; }else{ include_once NW_MODULE_PATH . '/language/english/main.php'; } $myts =& MyTextSanitizer::getInstance(); $sfiles = new nw_sFiles(); $dateformat = nw_getmoduleoption('dateformat', NW_MODULE_PATH); if($dateformat == '') { $dateformat = 's'; } $limit = $options[0]; $column_count = $options[1]; $letters = $options[2]; $imgwidth = $options[3]; $imgheight = $options[4]; $border = $options[5]; $bordercolor = $options[6]; $selected_stories = $options[7]; $block['spec']['columnwidth'] = intval(1/$column_count*100); if ($options[8] == 1) { $imgposition = 'right'; } else { $imgposition = 'left'; } $xoopsTpl->assign( 'xoops_module_header' , '<style type="text/css"> .itemText {text-align: left;} .latestnews { border-bottom: 1px solid #cccccc; } </style>' . $xoopsTpl->get_template_vars("xoops_module_header") ); if (!isset($options[26])) { $sarray = nw_Latestnewsstory::getAllPublished($limit, $selected_stories, 0, true, 0, 0, true, $options[25], false); } else { $topics = array_slice($options, 26); $sarray = nw_Latestnewsstory::getAllPublished($limit, $selected_stories, 0, true, $topics, 0, true, $options[25], false); } $scount = count($sarray); $k = 0; $columns = array(); if($scount > 0) { $storieslist=array(); foreach ($sarray as $storyid => $thisstory) { $storieslist[] = $thisstory->storyid(); } $filesperstory = $sfiles->getCountbyStories($storieslist); foreach ($sarray as $key => $thisstory) { $storyid = $thisstory->storyid(); $filescount = array_key_exists($thisstory->storyid(),$filesperstory) ? $filesperstory[$thisstory->storyid()] : 0; $published = formatTimestamp($thisstory->published(), $dateformat); $bodytext = $thisstory->bodytext; $news = $thisstory->prepare2show($filescount); $len = strlen($thisstory->hometext()); if ($letters < $len && $letters > 0){ $patterns = array(); $replacements = array(); if($options[4] != 0) { $height = 'height="'.$imgheight.'"'; } // set height = 0 in block option for auto height $startdiv = '<div style="float:'.$imgposition.'"><a href="' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'">'; $style = 'style="border: '.$border.'px solid #'.$bordercolor.'"'; $enddiv = 'alt="'.$thisstory->title.'" width="'.$imgwidth.'" '.$height.' /></a></div>'; $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1 width=(['\"]?)([0-9]*)\\3]([^\"\(\)\?\&'<>]*)\[\/img\]/sU"; $patterns[] = "/\[img align=(['\"]?)(left|center|right)\\1]([^\"\(\)\?\&'<>]*)\[\/img\]/sU"; $patterns[] = "/\[img]([^\"\(\)\?\&'<>]*)\[\/img\]/sU"; $patterns[] = "/<img src=\"(.*)\" \/>/sU"; $patterns[] = "/<img src=(.*) \/>/sU"; $replacements[] = $startdiv.'<img '.$style.' src="\\3" '.$enddiv; $replacements[] = $startdiv.'<img '.$style.' src="\\3" '.$enddiv; $replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv; $replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv; $replacements[] = $startdiv.'<img '.$style.' src="\\1" '.$enddiv; $letters = strrpos(substr($thisstory->hometext,0, $letters), ' '); $news['text'] = preg_replace($patterns, $replacements, xoops_substr($thisstory->hometext, 0, $letters + 3)); } if(is_object($xoopsUser) && $xoopsUser->isAdmin(-1)){ $news['admin'] = '<a href="' . NW_MODULE_URL . '/admin/index.php?op=edit&storyid='.$storyid.'"><img src="' . NW_MODULE_URL . '/images/edit_block.png" alt="'._EDIT.'" width="18" /></a> <a href="' . NW_MODULE_URL . '/admin/index.php?op=delete&storyid='.$storyid.'"><img src="' . NW_MODULE_URL . '/images/delete_block.png" alt="'._DELETE.'" width="20" /></a>'; } else { $news['admin'] = ''; } if ($options[9] == 1) { $block['topiclink'] = '| <a href="' . NW_MODULE_URL . '/topics_directory.php">'._AM_NW_TOPICS_DIRECTORY.'</a> '; } if ($options[10] == 1) { $block['archivelink'] = '| <a href="' . NW_MODULE_URL . '/archive.php">'._MA_NW_NEWSARCHIVES.'</a> '; } if ($options[11] == 1) { if (empty($xoopsUser)) { $block['submitlink'] = ''; } else { $block['submitlink'] = '| <a href="' . NW_MODULE_URL . '/submit.php">'._MA_NW_SUBMITNEWS.'</a> '; } } $news['poster'] = ''; if ($options[12] == 1) { if ( $thisstory->uname() != '' ) { $news['poster'] = ''._MB_NW_LATESTNEWS_POSTER.' '.$thisstory->uname().''; } } $news['posttime'] = ''; if ($options[13] == 1) { if ( $thisstory->uname() != '' ) { $news['posttime'] = ''._ON.' '.$published.''; } else { $news['posttime'] = ''._MB_NW_POSTED.' '._ON.' '.$published.''; } } $news['topic_image'] = ''; $news['topic_articlepicture'] = ''; if ($options[14] == 1) { $news['topic_image'] = ''.$thisstory->imglink().''; } $news['topic_title'] = ''; if ($options[15] == 1) { $news['topic_title'] = ''.$thisstory->textlink().''; $news['topic_separator'] = ( $thisstory->textlink() != '' ) ? _MB_NW_SP : ''; } $news['read'] = ''; if ($options[16] == 1) { $news['read']= ' ('.$thisstory->counter.' '._READS.')'; } $comments = $thisstory->comments(); if(!empty($bodytext) || $comments>0){ $news['more'] = '<a href="' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'">'. _MA_NW_READMORE .'</a>'; }else{ $news['more'] = ''; } if ($options[17] == 1) { if ($comments > 0) { //shows 1 comment instead of 1 comm. if comments ==1 //langugage file modified accordingly if ($comments == 1) { $news['comment'] =' '._MA_NW_ONECOMMENT.'</a> '; } else { $news['comment'] =' '.$comments.' '._MB_NW_NW_COMMENTS.'</a> '; } } else { $news['comment'] =' '._MB_NW_NO_COMMENT.'</a> '; } } $news['print'] = ''; if ($options[18] == 1) { $news['print']= '<a href="' . NW_MODULE_URL . '/print.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/print.png" width="22" alt="'._MA_NW_PRINTERFRIENDLY.'" /></a>'; } $news['pdf'] = ''; if ($options[19] == 1) { $news['pdf']= ' <a href="' . NW_MODULE_URL . '/makepdf.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/acrobat.png" width="20" alt="'._MA_NW_MAKEPDF.'" /></a> '; } $news['email'] = ''; if ($options[20] == 1) { $news['email']= '<a href="mailto:?subject='.sprintf(_MA_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_MA_NW_INTARTFOUND, $xoopsConfig['sitename']).': ' . NW_MODULE_URL . '/article.php?storyid='.$storyid.'" rel="nofollow"><img src="' . NW_MODULE_URL . '/images/friend.png" width="20" alt="'._MA_NW_SENDSTORY.'" /></a> '; } if ($options[21] == 1) { // $block['morelink'] = ' <a href="' . NW_MODULE_URL . '/index.php?storytopic=0&start='.$limit.'">'._MB_NW_NW_MORE_STORIES.'</A> '; $block['morelink'] = ' <a href="' . NW_MODULE_URL . '/index.php ">'._MB_NW_MORE_STORIES.'</A> '; } if ($options[22] == 1) { $block['latestnews_scroll'] = true; } else { $block['latestnews_scroll'] = false; } $block['scrollheight'] = $options[23]; $block['scrollspeed'] = $options[24]; $columns[$k][] = $news; $k++; if ($k == $column_count) { $k = 0; } } } unset($news); $block['columns'] = $columns; return $block; }
$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 nw_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'].')');
// // // 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 'header.php'; include_once NW_MODULE_PATH . '/class/class.sfiles.php'; include_once NW_MODULE_PATH . '/class/class.newsstory.php'; $fileid = (isset($_GET['fileid'])) ? intval($_GET['fileid']) : 0; if (empty($fileid)) { redirect_header(NW_MODULE_URL . '/index.php',2,_ERRORS); exit(); } $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object $sfiles = new nw_sFiles($fileid); // Do we have the right to see the file ? $article = new nw_NewsStory($sfiles->getStoryid()); // and the news, can we see it ? if ( $article->published() == 0 || $article->published() > time() ) { redirect_header(NW_MODULE_URL . '/index.php', 2, _MA_NW_NOSTORY); exit(); } // Expired if ( $article->expired() != 0 && $article->expired() < time() ) { redirect_header(NW_MODULE_URL . '/index.php', 2, _MA_NW_NOSTORY); exit(); }
switch ($xoopsModuleConfig['uploadgroups']) { 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 nw_sFiles(); $filesarr=Array(); $filesarr=$sfiles->getAllbyStory($storyid); if(count($filesarr)>0) { $upl_tray = new XoopsFormElementTray(_AM_NW_UPLOAD_ATTACHFILE,'<br />'); $upl_checkbox=new XoopsFormCheckBox('', 'delupload[]'); foreach ($filesarr as $onefile) { $link = sprintf("<a href='%s/%s' target='_blank'>%s</a>\n",NW_ATTACHED_FILES_URL,$onefile->getDownloadname('S'),$onefile->getFileRealName('S')); $upl_checkbox->addOption($onefile->getFileid(),$link); } $upl_tray->addElement($upl_checkbox,false); $dellabel=new XoopsFormLabel(_AM_NW_DELETE_SELFILES,''); $upl_tray->addElement($dellabel,false); $sform->addElement($upl_tray);
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 nw_sFiles(); $column_count = $xoopsModuleConfig['columnmode']; if ($showclassic) { $xoopsOption['template_main'] = 'nw_news_index.html'; include_once XOOPS_ROOT_PATH.'/header.php'; $xt = new nw_NewsTopic(); //DNPROSSI - ADDED $xoopsTpl->assign('newsmodule_url', NW_MODULE_URL); $xoopsTpl->assign('column_width', intval(1/$column_count*100)); if ($xoopsModuleConfig['ratenews']) { $xoopsTpl->assign('rates', true); $xoopsTpl->assign('lang_ratingc', _MA_NW_RATINGC); $xoopsTpl->assign('lang_ratethisnews', _MA_NW_RATETHISNEWS);
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(); }
} if($allowupload) { // Manage upload(s) if(isset($_POST['delupload']) && count($_POST['delupload']) > 0) { foreach ($_POST['delupload'] as $onefile) { $sfiles = new nw_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 nw_sFiles(); $destname=$sfiles->createUploadName(NW_ATTACHED_FILES_PATH,$fldname); /** * You can attach files to your news */ $permittedtypes = explode("\n",str_replace("\r",'',nw_getmoduleoption('mimetypes', NW_MODULE_DIR_NAME))); array_walk($permittedtypes, 'trim'); $uploader = new XoopsMediaUploader( NW_ATTACHED_FILES_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(NW_ATTACHED_FILES_PATH.'/'.$uploader->getMediaName())); $sfiles->setDownloadname($destname); if(!$sfiles->store()) {