gusucode.com > weenCompany闻名企业网站系统 4.0.0 繁体中英文 UTF8源码程序 > modules/m2_news/news.php
<?php // +---------------------------------------------+ // | Copyright 2006-2008 weenCompany | // | http://www.weentech.com | // | This file may not be redistributed. | // +---------------------------------------------+ if(!defined('IN_WEENCOMPANY')) die('File not found!'); // get the value of $m2_action $m2_action = isset($_POST['m2_action']) ? $_POST['m2_action'] : (isset($_GET['m2_action']) ? $_GET['m2_action'] : 'displaynews'); // get module language $m2_language = GetLanguage(2); // article bitfield settings $m2_articlebitfield = array('useglobalsettings' => 1, 'displayonline' => 2, 'displaytitle' => 4, 'displayauthor' => 8, 'displaycreateddate' => 16, 'displayupdateddate' => 32, 'displayprintarticlelink' => 64, 'displayemailarticlelink' => 128, 'displaydescription' => 256, 'displaysmilies' => 512, 'displaycomments' => 1024); // get global article settings $getsettings = $DB->query("SELECT title, description, value FROM " . TABLE_PREFIX . "modulesettings WHERE moduleid = 2"); while($setting = $DB->fetch_array($getsettings)) { // Some settings have titles, some have descriptions. Go figure $title = strlen($setting['title']) > 0 ? $setting['title'] : $setting['description']; $m2_settings[$title] = $setting['value']; } // ############################### SEND ARTICLE ################################ function m2_SendEmail($articleid) { global $DB, $categoryid, $weenurl, $m2_language, $m2_settings, $sdlanguage, $mainsettings, $rootpath; if($m2_settings['文章推廣'] == 1) { if($m2_settings['郵件驗證碼'] == 1) { $vvcid = $_POST['m2_vvcid']; $code = $_POST['m2_verifycode']; if(!ValidVisualVerifyCode($vvcid, $code)) { $errors[] = $sdlanguage['incorrect_vvc_code']; } } $useremail = $_POST['m2_emailfrom']; $emailto = $_POST['m2_emailto']; $emailcomment = $_POST['m2_emailcomment']; // Strip \r\n to prevent injection attacks $useremail = preg_replace("/\r/", "", $useremail); $useremail = preg_replace("/\n/", "", $useremail); $emailto = preg_replace("/\r/", "", $emailto); $emailto = preg_replace("/\n/", "", $emailto); // obtain emails $getemails = str_replace(',', ' ', $emailto); // get rid of commas $getemails = eregi_replace("[[:space:]]+", " ", $getemails); // get rid of extra spaces $getemails = trim($getemails); // then trim $emails = explode(" ", $getemails); // setup some vars $invalidemails = 0; // check if emails are real for($i = 0; $i < count($emails); $i++) { if(!ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $emails[$i])) $invalidemails = 1; } if($invalidemails == 1) { $errors[] = $m2_language['invalid_email']; } else { // check user email if(!ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $useremail)) $errors[] = $m2_language['invalid_email']; } // check if article exists/online if(!$article = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "m2_news WHERE articleid = '$articleid' AND categoryid = '$categoryid' AND (settings & 2) AND (datestart = 0 OR datestart < '" . time() . "') AND (dateend = 0 OR dateend > '" . time() . "')") ) { echo $m2_language['article_offline']; return; } // send email if no errors if(!isset($errors)) { // email headers $headers = "MIME-Version: 1.0" . EMAIL_CRLF; $headers .= "From: \"$useremail\" <$useremail>" . EMAIL_CRLF; $headers .= "Reply-To: \"$useremail\" <$useremail>" . EMAIL_CRLF; $headers .= "Content-type: text/plain; charset=utf-8" . EMAIL_CRLF; // email subject $subject = '=?utf-8?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', $article['title']))).'?='; // email main message $message = $weenurl . "index.php?categoryid=" . $categoryid . "&m2_articleid=$articleid&moduleid=m2_news&articleid=$articleid " . EMAIL_CRLF . EMAIL_CRLF . $emailcomment; if( $mainsettings['email_use_smtp'] == "1" ) { require_once $rootpath . "/includes/mail/class.phpmailer.php"; for($i = 0; $i < count($emails); $i++) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = $mainsettings['email_smtp_host']; $mail->Port = $mainsettings['email_smtp_port']; $mail->CharSet = "utf8"; $mail->Encoding = "base64"; if( $mainsettings['email_smtp_require_auth'] == "1" ) { $mail->SMTPAuth = true; $mail->Username = $mainsettings['email_smtp_user']; $mail->Password = $mainsettings['email_smtp_pass']; } $mail->From = $useremail; $mail->FromName = $useremail; $mail->AddAddress($emails[$i]); $mail->Subject = $article['title']; $mail->Body = $message; if($mail->Send()){$messagesent = 1;} } }else{ for($i = 0; $i < count($emails); $i++) { if(@mail($emails[$i], $subject, $message, $headers)) { $messagesent = 1; } } } if($messagesent == 1) { echo $m2_language['email_sent'] . '<br />' . $article['title'] . '<br /><br /> <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $articleid . '&moduleid=m2_news&articleid='.$articleid) . '">' . $m2_language['go_back'] . '<a>'; } else { echo $m2_language['email_not_sent']; } } else { foreach($errors as $key=>$value) { echo $value . '<br /><br />'; } m2_EmailArticle($articleid); } } } // ############################ EMAIL ARTICLE FORM ############################# function m2_EmailArticle($articleid) { global $DB, $categoryid, $inputsize, $m2_language, $m2_settings, $sdlanguage; if($m2_settings['文章推廣'] == 1) { // check if article exists/online if(!$article = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "m2_news WHERE articleid = '$articleid' AND categoryid = '$categoryid' AND (settings & 2) AND (datestart = 0 OR datestart < '" . time() . "') AND (dateend = 0 OR dateend > '" . time() . "')") ) { echo $m2_language['article_offline']; return; } echo '<b>' . $article['title'] . '</b><br /><br /> ' . $m2_language['enter_recipient_email'] . '<br /> <form method="post" action="' . RewriteLink('index.php?categoryid=' . $categoryid. '&m2_articleid=' . $articleid . '&m2_action=sendemail&moduleid=m2_news&articleid=' .$articleid) . '"> <input type="text" name="m2_emailto" value="' . $_POST['m2_emailto'] . '" size="'.$inputsize.'" /><br /> ' . $m2_language['separate_with_commas'] . '<br /><br /> ' . $m2_language['enter_your_email'] . '<br /> <input type="text" name="m2_emailfrom" size="'.$inputsize.'" value="' . $_POST['m2_emailfrom'] . '" /><br /><br /> ' . $m2_language['enter_comment'] . '<br /> <textarea name="m2_emailcomment" cols="'.$inputsize.'" rows="5">' . $_POST['m2_emailcomment'] . '</textarea><br /><br />'; if($m2_settings['郵件驗證碼']) { $vvcid = CreateVisualVerifyCode(); echo '<input type="hidden" name="m2_vvcid" value="' . $vvcid . '"/>'; echo '<img src="includes/vvc.php?vvcid=' . $vvcid . '"/><br/><br/> ' . $sdlanguage['enter_verify_code'] . '<br /> <input type="text" size="'.$inputsize.'" name="m2_verifycode"/><br/><br/>'; } echo '<input type="submit" value="' . strip_tags($m2_language['send_email']) . '" /> </form>'; } } // ######################### INSERT ARTICLE INTO DB ########################### function m2_InsertArticle() { global $DB, $categoryid, $m2_language, $m2_settings, $mainsettings, $rootpath; if($m2_settings['文章驗證碼'] == 1) { $vvcid = $_POST['m2_vvcid']; $code = $_POST['m2_verifycode']; if(!ValidVisualVerifyCode($vvcid, $code)) { $errors .= $sdlanguage['incorrect_vvc_code'] . '<br />'; } } $author = $_POST['m2_author']; $title = $_POST['m2_title']; $description = nl2br($_POST['m2_description']); $article = nl2br($_POST['m2_article']); if(strlen($author) == 0) { $errors .= $m2_language['enter_name'] . '<br />'; } if(strlen($title) == 0) { $errors .= $m2_language['enter_title'] . '<br />'; } if(strlen($article) == 0) { $errors .= $m2_language['enter_article'] . '<br />'; } if($samearticle = $DB->query_first("SELECT articleid FROM " . TABLE_PREFIX . "m2_news WHERE author = '$author' AND title = '$title' AND description = '$description' AND article = '$article'") ) { $errors .= '<font color=red><b>Sorry! this is a same article.</b></font>' . '<br />'; } // if no errors insert news, else print error and show submit form if(!isset($errors)) { $articlesettings = iif($m2_settings['自動發佈'] == 1, 3, 1); $DB->query("INSERT INTO " . TABLE_PREFIX . "m2_news (categoryid, settings, datecreated, author, title, metadescription, metakeywords, description, article) VALUES ($categoryid, $articlesettings, '" . time() . "', '$author', '$title', '', '', '$description', '$article')"); echo $m2_language['article_submitted']; $email = $m2_settings['郵件通知']; if(strlen($email) > 0) { // obtain emails $getemails = str_replace(',', ' ', $email); // get rid of commas $getemails = eregi_replace("[[:space:]]+", " ", $getemails); // get rid of extra spaces $getemails = trim($getemails); // then trim $emails = explode(" ", $getemails); $fullname = '=?utf-8?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', $m2_language['notify_email_from']))).'?='; $subject = '=?utf-8?B?'.base64_encode(str_replace("\r", '', str_replace("\n", '', $m2_language['notify_email_subject']))).'?='; $message = $m2_language['notify_email_message'] . EMAIL_CRLF; $message .= $m2_language['notify_email_author'] . ' - ' . $author . EMAIL_CRLF; $message .= $m2_language['notify_email_title'] . ' - ' . $title . EMAIL_CRLF; $headers = "MIME-Version: 1.0" . EMAIL_CRLF; $headers .= "From: \"$fullname\" <$emails[0]>" . EMAIL_CRLF; $headers .= "Reply-To: \"$fullname\" <$emails[0]>" . EMAIL_CRLF; $headers .= "Content-type: text/plain; charset=utf-8" . EMAIL_CRLF; if( $mainsettings['email_use_smtp'] == "1" ) { require_once $rootpath . "/includes/mail/class.phpmailer.php"; for($i = 0; $i < count($emails); $i++) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = $mainsettings['email_smtp_host']; $mail->Port = $mainsettings['email_smtp_port']; $mail->CharSet = "utf8"; $mail->Encoding = "base64"; if( $mainsettings['email_smtp_require_auth'] == "1" ) { $mail->SMTPAuth = true; $mail->Username = $mainsettings['email_smtp_user']; $mail->Password = $mainsettings['email_smtp_pass']; } $mail->From = $emails[0]; $mail->FromName = $m2_language['notify_email_from']; $mail->AddAddress($emails[$i]); $mail->Subject = $m2_language['notify_email_subject']; $mail->Body = $message; $mail->Send(); } }else{ for($i = 0; $i < count($emails); $i++) { @mail($emails[$i], $subject, $message, $headers); } } } } else { echo '<b>' . $errors . '</b><br /><br />'; m2_SubmitArticle($author, $title, $description, $article); } } // ########################### SUBMIT ARTICLE FORM ############################ function m2_SubmitArticle($author, $title, $description, $article) { global $categoryid, $userinfo, $inputsize, $m2_language, $m2_settings, $sdlanguage; echo '<form method="post" action="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_action=insertarticle') . '">'; if($userinfo['loggedin']) { echo '<input type="hidden" name="m2_author" value="' . $userinfo['username'] . '" /> <table width="100%" border="0" cellpadding="0" cellspacing="0">'; } else { echo '<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="25%" valign="top">' . $m2_language['author'] . '</td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"> <input type="text" name="m2_author" value="'.$author.'" size="'.$inputsize.'" maxlength="64" /> </td> </tr>'; } echo '<tr> <td width="25%" valign="top">' . $m2_language['title'] . '</td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"> <input type="text" name="m2_title" value="'.$title.'" size="'.$inputsize.'" maxlength="128" /> </td> </tr> <tr> <td width="25%" valign="top">' . $m2_language['description'] . '</td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"> <textarea name="m2_description" cols="'.$inputsize.'" rows="5">'.$description.'</textarea> </td> </tr> <tr> <td width="25%" valign="top">' . $m2_language['article'] . '</td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"> <textarea name="m2_article" cols="'.$inputsize.'" rows="25">'.$article.'</textarea> </td> </tr>'; if($m2_settings['文章驗證碼']) { $vvcid = CreateVisualVerifyCode(); echo '<tr> <td width="25%" valign="top"></td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"><input type="hidden" name="m2_vvcid" value="' . $vvcid . '"/> <img src="includes/vvc.php?vvcid=' . $vvcid . '"/></td> </tr> <tr> <td width="100%" valign="top" colspan="2" style="padding-left: 8px; padding-bottom: 6px;">' . $sdlanguage['enter_verify_code'] . '</td> </tr> <tr> <td width="25%" valign="top"></td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"><input type="text" size="'.$inputsize.'" name="m2_verifycode"/></td> </tr>'; } echo '<tr> <td width="25%" valign="top"></td> <td width="75%" valign="top" style="padding-left: 8px; padding-bottom: 6px;"> <input type="hidden" name="m2_action" value="insertarticle" /> <input type="submit" value="' . strip_tags($m2_language['submit_article']) . '" /> </td> </tr> </table> </form>'; } // ############################## DISPLAY ARTICLE ############################## function m2_DisplayArticle($article) { global $DB, $weenurl, $categoryid, $userinfo, $m2_articlebitfield, $m2_language, $m2_settings; // check which page of the article we are on // this variable needs to be created before displaying the article becuase it's used // in the description printing area $currentpage = (isset($_GET['m2_page']) AND ereg("^[0-9]+$", $_GET['m2_page'])) ? $_GET['m2_page'] : 1; // to prevent blank lines from showing, create a variable that will determine if weed need to break $displaylinebreaks = false; // 顯示標題? if($article['settings'] & $m2_articlebitfield['displaytitle']) { if(!strlen($article['description']) OR isset($_GET['m2_articleid'])) { echo '<b>' . $article['title'] . '</b><br />'; $displaylinebreaks = true; } else { echo '<b><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $article['articleid'].'&moduleid=m2_news&articleid=' . $article['articleid']) . '">' . $article['title'] . '</a></b><br />'; $displaylinebreaks = true; } } // display author? if($article['settings'] & $m2_articlebitfield['displayauthor']) { echo $m2_language['by'] . ' ' . $article['author'] . '<br />'; $displaylinebreaks = true; } // display published date? if($article['settings'] & $m2_articlebitfield['displaycreateddate']) { echo $m2_language['published'] . ' ' . iif($article['datestart'] != 0, DisplayDate($article['datestart']), DisplayDate($article['datecreated'])) . '<br />'; $displaylinebreaks = true; } // 顯示更新日期? if( ($article['settings'] & $m2_articlebitfield['displayupdateddate']) AND ($article['dateupdated'] != 0) ) { echo $m2_language['updated'] . ' ' . DisplayDate($article['dateupdated']) . '<br />'; $displaylinebreaks = true; } // 顯示打印? if($article['settings'] & $m2_articlebitfield['displayprintarticlelink']) { echo '<img alt="" src="' . $weenurl . 'modules/m2_news/print.gif" /> <a href="' . $weenurl . 'modules/m2_news/printarticle.php?m2_articleid=' . $article['articleid'] . '" target="_blank">' . $m2_language['print'] . '</a> ' . iif(!($article['settings'] & $m2_articlebitfield['displayemailarticlelink']), '<br />'); $displaylinebreaks = true; } // 顯示發送郵件? if(($article['settings'] & $m2_articlebitfield['displayemailarticlelink']) && $m2_settings['文章推廣'] == 1) { echo '<img alt="" src="' . $weenurl . 'modules/m2_news/email.gif" /> <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $article['articleid'] . '&m2_action=emailarticle&moduleid=m2_news&articleid=' . $article['articleid']) . '">' . $m2_language['email'] . '</a><br />'; $displaylinebreaks = true; } if($displaylinebreaks) { echo '<br />'; } // display description? if(strlen($article['description'])) { if(!isset($_GET['m2_articleid'])) { echo iif($article['settings'] & $m2_articlebitfield['displaysmilies'], AddSmilies($article['description']), $article['description']); } else if( ($article['settings'] & $m2_articlebitfield['displaydescription']) AND $currentpage == 1) { echo iif($article['settings'] & $m2_articlebitfield['displaysmilies'], AddSmilies($article['description']), $article['description']); } } // display article? if(!strlen($article['description']) OR isset($_GET['m2_articleid'])) { if(strlen($article['article'])) { // find out how many pages are in this article $articlepages = preg_split('/{(pagebreak)\s*(.*?)}/i', $article['article']); // a few more checks... if($currentpage == 0 OR $currentpage > count($articlepages)) { $currentpage = 1; } // add smilies to article? if($article['settings'] & $m2_articlebitfield['displaysmilies']) { $articlepages[$currentpage - 1] = AddSmilies($articlepages[$currentpage - 1]); } echo preg_replace('#(\A[\s]*<br[^>]*>[\s]*|' // remove <br/> at beginning of the string .'<br[^>]*>\s*(?=(?:\{pagebreak\}))|' // remove <br/> before {pagebreak} .'(?<=(?:\{pagebreak\}))\s*<br[^>]*>|' // remove <br/> after {pagebreak} .'<br[^>]*>[\s]*\Z)#is', '', $articlepages[$currentpage - 1]); // remove <br/> at end of string if(count($articlepages) > 1) { echo '<br /><br /> <center>'; // display previous page link? if($currentpage > 1) { echo '<a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $article['articleid'].'&moduleid=m2_news&articleid=' . $article['articleid'] . '&m2_page=' . ($currentpage - 1)) . '">' . $m2_language['previous_page'] . '</a> | '; } echo $m2_language['page'] . ' ' . $currentpage . ' ' . $m2_language['of'] . ' ' . count($articlepages); if(count($articlepages) > $currentpage) { echo ' | <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $article['articleid'].'&moduleid=m2_news&articleid=' . $article['articleid'] . '&m2_page=' . ($currentpage + 1)) . '">' . $m2_language['next_page'] . '</a>'; } echo '</center>'; } // update the views but only on the first page if($currentpage == 1) { $DB->query("UPDATE " . TABLE_PREFIX . "m2_news SET views=views+1 WHERE articleid = '" . $article['articleid'] . "'"); } } } else { // display link to article echo ' <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_articleid=' . $article['articleid'].'&moduleid=m2_news&articleid=' . $article['articleid']) . '">' . $m2_language['read_more'] . '</a>'; } // display submit news link? if(in_array(2, $userinfo['modulesubmitids'])) { echo '<br /><br /><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_action=submitarticle') . '">' . $m2_language['submit_article'] . '</a>'; } // 顯示用戶評論? if($article['settings'] & $m2_articlebitfield['displaycomments']) { echo iif(in_array(2, $userinfo['modulesubmitids']), ' - ', '<br /><br />'); // if m2_start is set, then it has already been confirmed to be an int (checked below) Comments(2, $article['articleid'], 'index.php?categoryid=' . $categoryid . iif(isset($_GET['m2_start']), '&m2_start=' . $_GET['m2_start']) . '&m2_articleid=' . $article['articleid'] . '&moduleid=m2_news&articleid=' . $article['articleid']); } } // ############################### DISPLAY NEWS ############################### function m2_DisplayNews() { global $DB, $categoryid, $m2_articlebitfield, $m2_language, $m2_settings; // create global settings $globalsettings = 0; $globalsettings += $m2_settings['顯示標題'] == 1 ? 4 : 0; $globalsettings += $m2_settings['顯示作者'] == 1 ? 8 : 0; $globalsettings += $m2_settings['顯示發佈日期'] == 1 ? 16 : 0; $globalsettings += $m2_settings['顯示更新日期'] == 1 ? 32 : 0; $globalsettings += $m2_settings['顯示打印'] == 1 ? 64 : 0; $globalsettings += $m2_settings['顯示發送郵件'] == 1 ? 128 : 0; $globalsettings += $m2_settings['簡要描述顯示在詳細內容中'] == 1 ? 256 : 0; $globalsettings += $m2_settings['顯示表情符號'] == 1 ? 512 : 0; $globalsettings += $m2_settings['顯示用戶評論'] == 1 ? 1024 : 0; // display specific article? if(isset($_GET['m2_articleid'])) { if($article = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "m2_news WHERE articleid = '" . $_GET['m2_articleid'] . "' AND categoryid = '$categoryid' AND (settings & 2) AND (datestart = 0 OR datestart < '" . time() . "') AND (dateend = 0 OR dateend > '" . time() . "')") ) { // use global settings for this article? if($article['settings'] & $m2_articlebitfield['useglobalsettings']) { $article['settings'] = $globalsettings; } // display the article m2_DisplayArticle($article); } else { echo $m2_language['article_offline']; return; } } else { // display all articles // find the limit start $start = (isset($_GET['m2_start']) AND ereg("^[0-9]+$", $_GET['m2_start'])) ? $_GET['m2_start'] : 0; // get category settings, if none then resort to default if($categorysettings = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "m2_settings WHERE categoryid = '$categoryid'")) { $limit = $categorysettings['maxarticles']; $order = $categorysettings['sorting']; $multiplepages = $categorysettings['multiplepages']; } else { $limit = 10; $order = 'IF ( dateupdated = 0, datecreated, dateupdated ) DESC'; $multiplepages = 1; } $getarticles = $DB->query("SELECT * FROM " . TABLE_PREFIX . "m2_news WHERE categoryid = '$categoryid' AND (settings & 2) AND (datestart = 0 OR datestart < '" . time() . "') AND (dateend = 0 OR dateend > '" . time() . "') ORDER BY " . $order . " LIMIT $start, " . ($limit + 1) . ""); $rows = $DB->get_num_rows($getarticles); for($i = 0; $i < $rows AND $i < $limit; $i++) { $article = $DB->fetch_array($getarticles); // use global settings for this article? if($article['settings'] & $m2_articlebitfield['useglobalsettings']) { $article['settings'] = $globalsettings; } // display article m2_DisplayArticle($article); // display break if( (($i + 1) < $rows) AND (($i + 1) < $limit) ) { echo '<br /><br /><hr /><br />'; } } // display multiple pages? if($multiplepages) { // get all section articles number $getsectionarticles = $DB->query("SELECT * FROM " . TABLE_PREFIX . "m2_news WHERE categoryid = '$categoryid' AND (settings & 2) AND (datestart = 0 OR datestart < '" . time() . "') AND (dateend = 0 OR dateend > '" . time() . "')"); $sectionarticlesnum = $DB->get_num_rows($getsectionarticles); if($start > 0 OR $rows > $limit) { echo '<br /><br /><hr /><br /> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr>'; if($start > 0) { echo '<td style="padding-left: 3px; padding-bottom: 3px;" width="10%" nowrap="nowrap"><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_start=' . ($start - $limit)) . '">' . $m2_language['previous'] . '</a></td>'; }else{ echo '<td style="padding-left: 3px; padding-bottom: 3px;" width="10%" nowrap="nowrap"> </td>'; } $page_num = ceil($sectionarticlesnum / $limit); for ($p=1 ; $p <= $page_num ; $p++ ) { if (($start/$limit+1) == $p){ $direct_bar .= "[<font color=red><b>".$p."</b></font>] "; }else{ $direct_bar .= '[<a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_start=' . ($p-1)*$limit) . '">'.$p.'</a>] '; } } echo '<td width="80%" style="text-align:center">'.$direct_bar.'</td>'; if($rows > $limit) { echo '<td style="padding-right: 3px; padding-bottom: 3px;" width="10%" nowrap="nowrap"><div align="right"><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&m2_start=' . ($start + $limit)) . '">' . $m2_language['next'] . '</a></div></td>'; }else{ echo '<td style="padding-right: 3px; padding-bottom: 3px;" width="10%" nowrap="nowrap"> </td>'; } echo '</tr></table>'; } } } } // ######################### START CALLING FUNCTIONS ########################## // $m2_action is created at the top of this page // first do a security check on articleid: if(isset($_GET['m2_articleid']) AND !ereg("^[0-9]+$", $_GET['m2_articleid'])) { unset($_GET['m2_articleid']); } if($m2_action == 'insertarticle' AND in_array(2, $userinfo['modulesubmitids'])) { m2_InsertArticle(); } else if($m2_action == 'submitarticle' AND in_array(2, $userinfo['modulesubmitids'])) { m2_SubmitArticle(NULL, NULL, NULL, NULL); } else if(isset($_GET['m2_articleid']) AND $m2_action == 'emailarticle') { m2_EmailArticle($_GET['m2_articleid']); } else if(isset($_GET['m2_articleid']) AND $m2_action == 'sendemail') { m2_SendEmail($_GET['m2_articleid']); } else { m2_DisplayNews(); } // ############################## UNSET VARIABLES ############################## unset($m2_action, $m2_language, $m2_articlebitfield, $m2_settings); ?>