onokazu
onoka****@users*****
2005年 6月 11日 (土) 11:32:48 JST
Index: xoops2jp/html/modules/news/article.php diff -u xoops2jp/html/modules/news/article.php:1.2 xoops2jp/html/modules/news/article.php:1.3 --- xoops2jp/html/modules/news/article.php:1.2 Fri Mar 18 21:52:25 2005 +++ xoops2jp/html/modules/news/article.php Sat Jun 11 11:32:47 2005 @@ -1,5 +1,5 @@ <?php -// $Id: article.php,v 1.2 2005/03/18 12:52:25 onokazu Exp $ +// $Id: article.php,v 1.3 2005/06/11 02:32:47 onokazu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -27,15 +27,11 @@ include "../../mainfile.php"; include_once "class/class.newsstory.php"; -foreach ($HTTP_POST_VARS as $k => $v) { - ${$k} = $v; -} -$storyid = (isset($HTTP_GET_VARS['storyid'])) ? $HTTP_GET_VARS['storyid'] : 0; -$storyid = intval($storyid); +$storyid = (isset($_GET['storyid'])) ? intval($_GET['storyid']) : 0; if (empty($storyid)) { - redirect_header("index.php",2,_NW_NOSTORY); - exit(); + redirect_header("index.php",2,_NW_NOSTORY); + exit(); } $xoopsOption['template_main'] = 'news_article.html'; @@ -47,13 +43,13 @@ $article = new NewsStory($storyid); if ( $article->published() == 0 || $article->published() > time() ) { - redirect_header('index.php', 2, _NW_NOSTORY); - exit(); + redirect_header('index.php', 2, _NW_NOSTORY); + exit(); } -$storypage = isset($HTTP_GET_VARS['page']) ? intval($HTTP_GET_VARS['page']) : 0; +$storypage = isset($_GET['page']) ? intval($_GET['page']) : 0; // update counter only when viewing top page -if (empty($HTTP_GET_VARS['com_id']) && $storypage == 0) { - $article->updateCounter(); +if (empty($_GET['com_id']) && $storypage == 0) { + $article->updateCounter(); } $story['id'] = $storyid; $story['posttime'] = formatTimestamp($article->published()); @@ -62,47 +58,47 @@ $bodytext = $article->bodytext(); if ( trim($bodytext) != '' ) { - $articletext = explode("[pagebreak]", $bodytext); - $story_pages = count($articletext); + $articletext = explode("[pagebreak]", $bodytext); + $story_pages = count($articletext); - if ($story_pages > 1) { - include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; - $pagenav = new XoopsPageNav($story_pages, 1, $storypage, 'page', 'storyid='.$storyid); - $xoopsTpl->assign('pagenav', $pagenav->renderNav()); - //$xoopsTpl->assign('pagenav', $pagenav->renderImageNav()); - - if ($storypage == 0) { - $story['text'] = $story['text'].'<br /><br />'.$articletext[$storypage]; - } else { - $story['text'] = $articletext[$storypage]; - } - } else { - $story['text'] = $story['text'].'<br /><br />'.$bodytext; - } + if ($story_pages > 1) { + include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; + $pagenav = new XoopsPageNav($story_pages, 1, $storypage, 'page', 'storyid='.$storyid); + $xoopsTpl->assign('pagenav', $pagenav->renderNav()); + //$xoopsTpl->assign('pagenav', $pagenav->renderImageNav()); + + if ($storypage == 0) { + $story['text'] = $story['text'].'<br /><br />'.$articletext[$storypage]; + } else { + $story['text'] = $articletext[$storypage]; + } + } else { + $story['text'] = $story['text'].'<br /><br />'.$bodytext; + } } $story['poster'] = $article->uname(); if ( $story['poster'] ) { - $story['posterid'] = $article->uid(); - $story['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$story['posterid'].'">'.$story['poster'].'</a>'; + $story['posterid'] = $article->uid(); + $story['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$story['posterid'].'">'.$story['poster'].'</a>'; } else { - $story['poster'] = ''; - $story['posterid'] = 0; - $story['poster'] = $xoopsConfig['anonymous']; + $story['poster'] = ''; + $story['posterid'] = 0; + $story['poster'] = $xoopsConfig['anonymous']; } $story['morelink'] = ''; $story['adminlink'] = ''; unset($isadmin); if ( $xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid')) ) { - $isadmin = true; - $story['adminlink'] = $article->adminlink(); + $isadmin = true; + $story['adminlink'] = $article->adminlink(); } $story['topicid'] = $article->topicid(); $story['imglink'] = ''; $story['align'] = ''; if ( $article->topicdisplay() ) { - $story['imglink'] = $article->imglink(); - $story['align'] = $article->topicalign(); + $story['imglink'] = $article->imglink(); + $story['align'] = $article->topicalign(); } $story['hits'] = $article->counter(); $story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/news/article.php?storyid='.$article->storyid(); Index: xoops2jp/html/modules/news/print.php diff -u xoops2jp/html/modules/news/print.php:1.2 xoops2jp/html/modules/news/print.php:1.3 --- xoops2jp/html/modules/news/print.php:1.2 Fri Mar 18 21:52:25 2005 +++ xoops2jp/html/modules/news/print.php Sat Jun 11 11:32:47 2005 @@ -1,5 +1,5 @@ <?php -// $Id: print.php,v 1.2 2005/03/18 12:52:25 onokazu Exp $ +// $Id: print.php,v 1.3 2005/06/11 02:32:47 onokazu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -28,46 +28,46 @@ $storyid = isset($HTTP_GET_VARS['storyid']) ? intval($HTTP_GET_VARS['storyid']) : 0; if ( empty($storyid) ) { - redirect_header("index.php"); + redirect_header("index.php"); } include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->dirname().'/class/class.newsstory.php'; function PrintPage($storyid) { - global $xoopsConfig, $xoopsModule; - $story = new NewsStory($storyid); + global $xoopsConfig, $xoopsModule; + $story = new NewsStory($storyid); $datetime = formatTimestamp($story->published()); echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'; - echo '<html><head>'; - echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET.'" />'; - echo '<title>'.$xoopsConfig['sitename'].'</title>'; - echo '<meta name="AUTHOR" content="'.$xoopsConfig['sitename'].'" />'; - echo '<meta name="COPYRIGHT" content="Copyright (c) 2001 by '.$xoopsConfig['sitename'].'" />'; - echo '<meta name="DESCRIPTION" content="'.$xoopsConfig['slogan'].'" />'; - echo '<meta name="GENERATOR" content="'.XOOPS_VERSION.'" />'; - echo '<body bgcolor="#ffffff" text="#000000" onload="window.print()"> - <table border="0"><tr><td align="center"> - <table border="0" width="640" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td> - <table border="0" width="640" cellpadding="20" cellspacing="1" bgcolor="#ffffff"><tr><td align="center"> - <img src="'.XOOPS_URL.'/images/logo.gif" border="0" alt="" /><br /><br /> - <h3>'.$story->title().'</h3> - <small><b>'._NW_DATE.'</b> '.$datetime.' | <b>'._NW_TOPICC.'</b> '.$story->topic_title().'</small><br /><br /></td></tr>'; - echo '<tr valign="top" style="font:12px;"><td>'.$story->hometext().'<br />'; - $bodytext = $story->bodytext(); - $bodytext = str_replace("[pagebreak]","<br style=\"page-break-after:always;\">",$bodytext); - if ( $bodytext != '' ){ - echo $bodytext.'<br /><br />'; - } - echo '</td></tr></table></td></tr></table> - <br /><br />'; - printf(_NW_THISCOMESFROM,$xoopsConfig['sitename']); - echo '<br /><a href="'.XOOPS_URL.'/">'.XOOPS_URL.'</a><br /><br /> - '._NW_URLFORSTORY.' <!-- Tag below can be used to display Permalink image --><!--img src="'.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/images/x.gif" /--><br /> - <a href="'.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/article.php?storyid='.$story->storyid().'">'.XOOPS_URL.'/article.php?storyid='.$story->storyid().'</a> - </td></tr></table> - </body> - </html> - '; + echo '<html><head>'; + echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET.'" />'; + echo '<title>'.htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES).'</title>'; + echo '<meta name="AUTHOR" content="'.htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES).'" />'; + echo '<meta name="COPYRIGHT" content="Copyright (c) 2005 by '.htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES).'" />'; + echo '<meta name="DESCRIPTION" content="'.$xoopsConfig['slogan'].'" />'; + echo '<meta name="GENERATOR" content="'.XOOPS_VERSION.'" />'; + echo '<body bgcolor="#ffffff" text="#000000" onload="window.print()"> + <table border="0"><tr><td align="center"> + <table border="0" width="640" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><td> + <table border="0" width="640" cellpadding="20" cellspacing="1" bgcolor="#ffffff"><tr><td align="center"> + <img src="'.XOOPS_URL.'/images/logo.gif" border="0" alt="" /><br /><br /> + <h3>'.$story->title().'</h3> + <small><b>'._NW_DATE.'</b> '.$datetime.' | <b>'._NW_TOPICC.'</b> '.$story->topic_title().'</small><br /><br /></td></tr>'; + echo '<tr valign="top" style="font:12px;"><td>'.$story->hometext().'<br />'; + $bodytext = $story->bodytext(); + $bodytext = str_replace("[pagebreak]","<br style=\"page-break-after:always;\">",$bodytext); + if ( $bodytext != '' ){ + echo $bodytext.'<br /><br />'; + } + echo '</td></tr></table></td></tr></table> + <br /><br />'; + printf(_NW_THISCOMESFROM,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)); + echo '<br /><a href="'.XOOPS_URL.'/">'.XOOPS_URL.'</a><br /><br /> + '._NW_URLFORSTORY.' <!-- Tag below can be used to display Permalink image --><!--img src="'.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/images/x.gif" /--><br /> + <a href="'.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/article.php?storyid='.$story->storyid().'">'.XOOPS_URL.'/article.php?storyid='.$story->storyid().'</a> + </td></tr></table> + </body> + </html> + '; } PrintPage($storyid); ?> \ No newline at end of file Index: xoops2jp/html/modules/news/submit.php diff -u xoops2jp/html/modules/news/submit.php:1.2 xoops2jp/html/modules/news/submit.php:1.3 --- xoops2jp/html/modules/news/submit.php:1.2 Fri Mar 18 21:52:25 2005 +++ xoops2jp/html/modules/news/submit.php Sat Jun 11 11:32:47 2005 @@ -1,5 +1,5 @@ <?php -// $Id: submit.php,v 1.2 2005/03/18 12:52:25 onokazu Exp $ +// $Id: submit.php,v 1.3 2005/06/11 02:32:47 onokazu Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -27,133 +27,143 @@ include '../../mainfile.php'; include_once 'class/class.newsstory.php'; if (empty($xoopsModuleConfig['anonpost']) && !is_object($xoopsUser)) { - redirect_header("index.php", 0, _NOPERM); - exit(); + redirect_header("index.php", 0, _NOPERM); + exit(); } -$op = 'form'; -foreach ( $HTTP_POST_VARS as $k => $v ) { - ${$k} = $v; -} -if ( isset($HTTP_POST_VARS['preview'] )) { - $op = 'preview'; -} elseif ( isset($HTTP_POST_VARS['post']) ) { - $op = 'post'; +error_reporting(E_ALL); +$op = isset($_POST['op']) ? $_POST['op'] : 'form'; + +if (!empty($_POST['preview'])) { + if (XoopsMultiTokenHandler::quickValidate('news_submit')) { + $op = 'preview'; + } + else { + $op = 'form'; + } +} elseif (!empty($_POST['post'])) { + if (XoopsMultiTokenHandler::quickValidate('news_submit')) { + $op = 'post'; + } + else { + $op = 'form'; + } } + +$topic_id = isset($_POST['topic_id']) ? intval($_POST['topic_id']) : 0; +$noname = isset($_POST['noname']) ? intval($_POST['noname']) : 0; +$notifypub = isset($_POST['notifypub']) ? intval($_POST['notifypub']) : 0; +$nosmiley = isset($_POST['nosmiley']) ? intval($_POST['nosmiley']) : 0; +$myts =& MyTextSanitizer::getInstance(); switch ($op) { case "preview": - $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object - $xt = new XoopsTopic($xoopsDB->prefix("topics"), $HTTP_POST_VARS['topic_id']); - include XOOPS_ROOT_PATH.'/header.php'; - $p_subject = $myts->makeTboxData4Preview($subject); - if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { - $nohtml = isset($nohtml) ? intval($nohtml) : 0; - } else { - $nohtml = 1; - } - $html = empty($nohtml) ? 1 : 0; - if ( isset($nosmiley) && intval($nosmiley) > 0 ) { - $nosmiley = 1; - $smiley = 0; - } else { - $nosmiley = 0; - $smiley = 1; - } - $p_message = $myts->makeTareaData4Preview($message, $html, $smiley, 1); - $subject = $myts->makeTboxData4PreviewInForm($subject); - $message = $myts->makeTareaData4PreviewInForm($message); - $noname = isset($noname) ? intval($noname) : 0; - $notifypub = isset($notifypub) ? intval($notifypub) : 0; - $p_message = ($xt->topic_imgurl() != '') ? '<img src="images/topics/'.$xt->topic_imgurl().'" align="right" alt="" />'.$p_message : $p_message; - themecenterposts($p_subject, $p_message); - include 'include/storyform.inc.php'; - include XOOPS_ROOT_PATH.'/footer.php'; - break; + $xt = new XoopsTopic($xoopsDB->prefix("topics"), $topic_id); + include XOOPS_ROOT_PATH.'/header.php'; + $p_subject = $myts->makeTboxData4Preview($_POST['subject']); + if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { + $nohtml = isset($_POST['nohtml']) ? intval($_POST['nohtml']) : 0; + } else { + $nohtml = 1; + } + $html = empty($nohtml) ? 1 : 0; + if ( isset($nosmiley) && intval($nosmiley) > 0 ) { + $nosmiley = 1; + $smiley = 0; + } else { + $nosmiley = 0; + $smiley = 1; + } + $p_message = $myts->makeTareaData4Preview($_POST['message'], $html, $smiley, 1); + $subject = $myts->makeTboxData4PreviewInForm($_POST['subject']); + $message = $myts->makeTareaData4PreviewInForm($_POST['message']); + $p_message = ($xt->topic_imgurl() != '') ? '<img src="images/topics/'.$xt->topic_imgurl().'" align="right" alt="" />'.$p_message : $p_message; + themecenterposts($p_subject, $p_message); + include 'include/storyform.inc.php'; + include XOOPS_ROOT_PATH.'/footer.php'; + break; case "post": - $nohtml_db = 1; - if ( $xoopsUser ) { - $uid = $xoopsUser->getVar('uid'); - if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) { - $nohtml_db = empty($nohtml) ? 0 : 1; - } - } else { - if ( $xoopsModuleConfig['anonpost'] == 1 ) { - $uid = 0; - } else { - redirect_header("index.php",3,_NOPERM); - exit(); - } - } - $story = new NewsStory(); - $story->setTitle($subject); - $story->setHometext($message); - $story->setUid($uid); - $story->setTopicId($topic_id); - $story->setHostname(xoops_getenv('REMOTE_ADDR')); - $story->setNohtml($nohtml_db); - $nosmiley = isset($nosmiley) ? intval($nosmiley) : 0; - $notifypub = isset($notifypub) ? intval($notifypub) : 0; - $story->setNosmiley($nosmiley); - $story->setNotifyPub($notifypub); - $story->setType('user'); + $nohtml_db = 1; + if ( $xoopsUser ) { + $uid = $xoopsUser->getVar('uid'); + if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) { + $nohtml_db = empty($_POST['nohtml']) ? 0 : 1; + } + } else { + if ( $xoopsModuleConfig['anonpost'] == 1 ) { + $uid = 0; + } else { + redirect_header("index.php",3,_NOPERM); + exit(); + } + } + $story = new NewsStory(); + $story->setTitle($_POST['subject']); + $story->setHometext($_POST['message']); + $story->setUid($uid); + $story->setTopicId($topic_id); + $story->setHostname(xoops_getenv('REMOTE_ADDR')); + $story->setNohtml($nohtml_db); + $story->setNosmiley($nosmiley); + $story->setNotifyPub($notifypub); + $story->setType('user'); if ( $xoopsModuleConfig['autoapprove'] == 1 ) { - $approve = 1; - $story->setApproved($approve); - $story->setPublished(time()); - $story->setExpired(0); - $story->setTopicalign('R'); - } - $result = $story->store(); - if ($result) { - // Notification - $notification_handler =& xoops_gethandler('notification'); - $tags = array(); - $tags['STORY_NAME'] = $subject; - $tags['STORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/article.php?storyid=' . $story->storyid(); - if ( $xoopsModuleConfig['autoapprove'] == 1) { - $notification_handler->triggerEvent('global', 0, 'new_story', $tags); - } else { - $tags['WAITINGSTORIES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=newarticle'; - $notification_handler->triggerEvent('global', 0, 'story_submit', $tags); - } - // If notify checkbox is set, add subscription for approve - if ($notifypub) { - include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; - $notification_handler->subscribe('story', $story->storyid(), 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); - } - /* - if ($xoopsModuleConfig['notifysubmit'] == 1 ) { - $xoopsMailer =& getMailer(); - $xoopsMailer->useMail(); - $xoopsMailer->setToEmails($xoopsConfig['adminmail']); - $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); - $xoopsMailer->setFromName($xoopsConfig['sitename']); - $xoopsMailer->setSubject(_NW_NOTIFYSBJCT); - $body = _NW_NOTIFYMSG; - $body .= "\n\n"._NW_TITLE.": ".$story->title(); - $body .= "\n"._POSTEDBY.": ".XoopsUser::getUnameFromId($uid); - $body .= "\n"._DATE.": ".formatTimestamp(time(), 'm', $xoopsConfig['default_TZ']); - $body .= "\n\n".XOOPS_URL.'/modules/news/admin/index.php?op=edit&storyid='.$result; - $xoopsMailer->setBody($body); - $xoopsMailer->send(); - } - */ - } else { - echo 'error'; - } - redirect_header("index.php",2,_NW_THANKS); - break; + $approve = 1; + $story->setApproved($approve); + $story->setPublished(time()); + $story->setExpired(0); + $story->setTopicalign('R'); + } + $result = $story->store(); + if ($result) { + // Notification + $notification_handler =& xoops_gethandler('notification'); + $tags = array(); + $tags['STORY_NAME'] = $myts->stripSlashesGPC($_POST['subject']); + $tags['STORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/article.php?storyid=' . $story->storyid(); + if ( $xoopsModuleConfig['autoapprove'] == 1) { + $notification_handler->triggerEvent('global', 0, 'new_story', $tags); + } else { + $tags['WAITINGSTORIES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=newarticle'; + $notification_handler->triggerEvent('global', 0, 'story_submit', $tags); + } + // If notify checkbox is set, add subscription for approve + if ($notifypub) { + include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; + $notification_handler->subscribe('story', $story->storyid(), 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); + } + /* + if ($xoopsModuleConfig['notifysubmit'] == 1 ) { + $xoopsMailer =& getMailer(); + $xoopsMailer->useMail(); + $xoopsMailer->setToEmails($xoopsConfig['adminmail']); + $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); + $xoopsMailer->setFromName($xoopsConfig['sitename']); + $xoopsMailer->setSubject(_NW_NOTIFYSBJCT); + $body = _NW_NOTIFYMSG; + $body .= "\n\n"._NW_TITLE.": ".$story->title(); + $body .= "\n"._POSTEDBY.": ".XoopsUser::getUnameFromId($uid); + $body .= "\n"._DATE.": ".formatTimestamp(time(), 'm', $xoopsConfig['default_TZ']); + $body .= "\n\n".XOOPS_URL.'/modules/news/admin/index.php?op=edit&storyid='.$result; + $xoopsMailer->setBody($body); + $xoopsMailer->send(); + } + */ + } else { + echo 'error'; + } + redirect_header("index.php",2,_NW_THANKS); + break; case 'form': default: - $xt = new XoopsTopic($xoopsDB->prefix("topics")); - include XOOPS_ROOT_PATH.'/header.php'; - $subject = ''; - $message = ''; - $noname = 0; - $nohtml = 0; - $nosmiley = 0; - $notifypub = 1; - include 'include/storyform.inc.php'; - include XOOPS_ROOT_PATH.'/footer.php'; - break; + $xt = new XoopsTopic($xoopsDB->prefix("topics")); + include XOOPS_ROOT_PATH.'/header.php'; + $subject = ''; + $message = ''; + $noname = 0; + $nohtml = 0; + $nosmiley = 0; + $notifypub = 1; + include 'include/storyform.inc.php'; + include XOOPS_ROOT_PATH.'/footer.php'; + break; } ?>