| 1 | <?php |
|---|
| 2 | // $Id: index.php,v 1.5 2005/09/04 20:46:11 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // Based on: // |
|---|
| 9 | // myPHPNUKE Web Portal System - http://myphpnuke.com/ // |
|---|
| 10 | // PHP-NUKE Web Portal System - http://phpnuke.org/ // |
|---|
| 11 | // Thatware - http://thatware.org/ // |
|---|
| 12 | // ------------------------------------------------------------------------- // |
|---|
| 13 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 14 | // it under the terms of the GNU General Public License as published by // |
|---|
| 15 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 16 | // (at your option) any later version. // |
|---|
| 17 | // // |
|---|
| 18 | // You may not change or alter any portion of this comment or credits // |
|---|
| 19 | // of supporting developers from this source code or any supporting // |
|---|
| 20 | // source code which is considered copyrighted (c) material of the // |
|---|
| 21 | // original comment or credit authors. // |
|---|
| 22 | // // |
|---|
| 23 | // This program is distributed in the hope that it will be useful, // |
|---|
| 24 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 26 | // GNU General Public License for more details. // |
|---|
| 27 | // // |
|---|
| 28 | // You should have received a copy of the GNU General Public License // |
|---|
| 29 | // along with this program; if not, write to the Free Software // |
|---|
| 30 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 31 | // ------------------------------------------------------------------------ // |
|---|
| 32 | include 'header.php'; |
|---|
| 33 | |
|---|
| 34 | function listsections() |
|---|
| 35 | { |
|---|
| 36 | global $xoopsConfig, $xoopsDB, $xoopsUser, $xoopsTheme, $xoopsLogger, $xoopsModule, $xoopsTpl, $xoopsUserIsAdmin; |
|---|
| 37 | include XOOPS_ROOT_PATH.'/header.php'; |
|---|
| 38 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 39 | $result = $xoopsDB->query("SELECT secid, secname, image FROM ".$xoopsDB->prefix("sections")." ORDER BY secname"); |
|---|
| 40 | echo "<div style='text-align: center;'>"; |
|---|
| 41 | printf(_MD_WELCOMETOSEC,htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)); |
|---|
| 42 | echo "<br /><br />"; |
|---|
| 43 | echo _MD_HEREUCANFIND.'<br /><br /><table border="0">'; |
|---|
| 44 | $count = 0; |
|---|
| 45 | while ( list($secid, $secname, $image) = $xoopsDB->fetchRow($result) ) { |
|---|
| 46 | $secname = $myts->makeTboxData4Show($secname); |
|---|
| 47 | $image = $myts->makeTboxData4Show($image); |
|---|
| 48 | if ( $count == 2 ) { |
|---|
| 49 | echo "<tr>"; |
|---|
| 50 | $count = 0; |
|---|
| 51 | } |
|---|
| 52 | echo "<td><a href='index.php?op=listarticles&secid=$secid'><img src='images/$image' border='0' alt='$secname' /></a>"; |
|---|
| 53 | $count++; |
|---|
| 54 | if ( $count == 2 ) { |
|---|
| 55 | echo "</tr>"; |
|---|
| 56 | } |
|---|
| 57 | echo "</td>"; |
|---|
| 58 | } |
|---|
| 59 | echo "</table></div>"; |
|---|
| 60 | include '../../footer.php'; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | function listarticles($secid) |
|---|
| 64 | { |
|---|
| 65 | global $xoopsConfig, $xoopsUser, $xoopsDB, $xoopsTheme, $xoopsLogger, $xoopsModule, $xoopsTpl, $xoopsUserIsAdmin; |
|---|
| 66 | include '../../header.php'; |
|---|
| 67 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 68 | $result = $xoopsDB->query("SELECT secname, image FROM ".$xoopsDB->prefix("sections")." WHERE secid=$secid"); |
|---|
| 69 | list($secname, $image) = $xoopsDB->fetchRow($result); |
|---|
| 70 | $secname = $myts->makeTboxData4Show($secname); |
|---|
| 71 | $image = $myts->makeTboxData4Show($image); |
|---|
| 72 | $result = $xoopsDB->query("SELECT artid, secid, title, content, counter FROM ".$xoopsDB->prefix("seccont")." WHERE secid=$secid"); |
|---|
| 73 | echo "<div><img src='images/$image' border='0' /><br /><br />"; |
|---|
| 74 | printf(_MD_THISISSECTION,$secname); |
|---|
| 75 | echo "<br />"._MD_THEFOLLOWING."<br /><br /><table border='0'>"; |
|---|
| 76 | while ( list($artid, $secid, $title, $content, $counter) = $xoopsDB->fetchRow($result) ) { |
|---|
| 77 | $title = $myts->makeTboxData4Show($title); |
|---|
| 78 | $content = $myts->makeTareaData4Show($content); |
|---|
| 79 | echo "<tr><td align='left'> <strong><big>·</big></strong> <a href='index.php?op=viewarticle&artid=$artid'>$title</a>"; |
|---|
| 80 | printf(" (read: %s times)",$counter); |
|---|
| 81 | echo "<a href='index.php?op=printpage&artid=$artid'> <img src='".XOOPS_URL."/modules/sections/images/print.gif' border='0' alt='" . _MD_PRINTERPAGE."' /></a></td></tr>"; |
|---|
| 82 | } |
|---|
| 83 | echo "</table><br /><br /><br />[ <a href=index.php>"._MD_RETURN2INDEX."</a> ]</div>"; |
|---|
| 84 | include '../../footer.php'; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | function viewarticle($artid,$page) |
|---|
| 88 | { |
|---|
| 89 | global $xoopsConfig, $xoopsUser, $xoopsDB, $xoopsTheme, $xoopsLogger, $xoopsModule, $xoopsTpl, $xoopsUserIsAdmin; |
|---|
| 90 | include '../../header.php'; |
|---|
| 91 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 92 | $xoopsDB->queryF("UPDATE ".$xoopsDB->prefix("seccont")." SET counter=counter+1 WHERE artid=$artid"); |
|---|
| 93 | $result = $xoopsDB->query("SELECT artid, secid, title, content, counter FROM ".$xoopsDB->prefix("seccont")." WHERE artid=$artid"); |
|---|
| 94 | list($artid, $secid, $title, $content, $counter) = $xoopsDB->fetchRow($result); |
|---|
| 95 | $title = $myts->makeTboxData4Show($title); |
|---|
| 96 | $content = $myts->makeTareaData4Show($content); |
|---|
| 97 | $result2 = $xoopsDB->query("SELECT secid, secname FROM ".$xoopsDB->prefix("sections")." WHERE secid=$secid"); |
|---|
| 98 | list($secid, $secname) = $xoopsDB->fetchRow($result2); |
|---|
| 99 | $secname = $myts->makeTboxData4Show($secname); |
|---|
| 100 | $words = count(explode(" ", $content)); |
|---|
| 101 | //echo "<center>"; |
|---|
| 102 | /* Rip the article into pages. Delimiter string is "[pagebreak]" */ |
|---|
| 103 | $contentpages = explode( "[pagebreak]", $content); |
|---|
| 104 | $pageno = count($contentpages); |
|---|
| 105 | /* Define the current page */ |
|---|
| 106 | if ( $page=="" || $page < 1 ) { |
|---|
| 107 | $page = 1; |
|---|
| 108 | } |
|---|
| 109 | if ( $page > $pageno ) { |
|---|
| 110 | $page = $pageno; |
|---|
| 111 | } |
|---|
| 112 | $arrayelement = (int)$page; |
|---|
| 113 | $arrayelement --; |
|---|
| 114 | echo "<table width='100%'><tr><td><b>$title</b><br /><br />"; |
|---|
| 115 | if ( $page >= $pageno ) { |
|---|
| 116 | $next_page = '<a href="index.php">' ._MD_RETURN2INDEX.'</a>'; |
|---|
| 117 | } else { |
|---|
| 118 | $next_pagenumber = $page + 1; |
|---|
| 119 | $next_page = "<a href='index.php?op=viewarticle&artid=$artid&page=$next_pagenumber'>"._MD_NEXTPAGE." ".sprintf("(%s/%s)",$next_pagenumber,$pageno)." >></a>"; |
|---|
| 120 | } |
|---|
| 121 | if( $page <= 1 ) { |
|---|
| 122 | $previous_page = '<a href="index.php">' ._MD_RETURN2INDEX.'</a>'; |
|---|
| 123 | } else { |
|---|
| 124 | $previous_pagenumber = $page -1; |
|---|
| 125 | $previous_page = "<a href='index.php?op=viewarticle&artid=$artid&page=$previous_pagenumber'><< "._MD_PREVPAGE." ".sprintf("(%s/%s)",$previous_pagenumber,$pageno)."</a>"; |
|---|
| 126 | } |
|---|
| 127 | echo ($contentpages[$arrayelement]); |
|---|
| 128 | echo "<br /><table width='100%' border='0' cellspacing='0' cellpadding='2'><tr><td>$previous_page</td> <td align='right'>$next_page</td></tr></table>"; |
|---|
| 129 | echo "</td></tr> |
|---|
| 130 | <tr><td align='center'>[ <a href='index.php?op=listarticles&secid=$secid'>".sprintf(_MD_BACK2SEC,$secname)."</a> | |
|---|
| 131 | <a href='index.php'>"._MD_RETURN2INDEX."</a> | <a href='index.php?op=printpage&artid=$artid'><img src='".XOOPS_URL."/modules/sections/images/print.gif' border='0' alt='" . _MD_PRINTERPAGE."' /></a>]</td></tr></table>"; |
|---|
| 132 | include '../../footer.php'; |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | function PrintSecPage($artid) |
|---|
| 136 | { |
|---|
| 137 | global $xoopsConfig, $xoopsUser, $xoopsDB, $xoopsTpl, $xoopsUserIsAdmin; |
|---|
| 138 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 139 | $result=$xoopsDB->query("SELECT title, content FROM ".$xoopsDB->prefix("seccont")." WHERE artid=$artid"); |
|---|
| 140 | list($title, $content) = $xoopsDB->fetchRow($result); |
|---|
| 141 | $title = $myts->makeTboxData4Show($title); |
|---|
| 142 | $content = $myts->makeTareaData4Show($content); |
|---|
| 143 | echo " |
|---|
| 144 | <html> |
|---|
| 145 | <head><title>".htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)."</title></head> |
|---|
| 146 | <body> |
|---|
| 147 | <table border='0'><tr><td> |
|---|
| 148 | <table border='0' width='640' cellpadding='0' cellspacing='1' bgcolor='#000000'><tr><td> |
|---|
| 149 | <table border='0' width='640' cellpadding='20' cellspacing='1' bgcolor='#ffffff'><tr><td> |
|---|
| 150 | <img src='".XOOPS_URL."/images/logo.gif' border='0' alt='' /><br /><br /> |
|---|
| 151 | <b>$title</b><br /> |
|---|
| 152 | ".str_replace("[pagebreak]","",$content)."<br /><br />"; |
|---|
| 153 | echo "</td></tr></table></td></tr></table>"; |
|---|
| 154 | echo "<br /><br />"; |
|---|
| 155 | printf(_MD_COMESFROM, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)); |
|---|
| 156 | echo "<br /><a href='".XOOPS_URL."'>".XOOPS_URL."</a><br /><br />"; |
|---|
| 157 | echo _MD_URLFORTHIS."<br /> |
|---|
| 158 | <a href='".XOOPS_URL."/modules/sections/index.php?op=viewarticle&artid=$artid'>".XOOPS_URL."/modules/sections/index.php?op=viewarticle&artid=$artid</a> |
|---|
| 159 | </td></tr></table> |
|---|
| 160 | </body> |
|---|
| 161 | </html>"; |
|---|
| 162 | } |
|---|
| 163 | |
|---|
| 164 | $op = isset($_GET['op']) ? trim($_GET['op']) : ''; |
|---|
| 165 | $secid = isset($_GET['secid']) ? intval($_GET['secid']) : 0; |
|---|
| 166 | $page = isset($_GET['page']) ? intval($_GET['page']) : 0; |
|---|
| 167 | $artid = isset($_GET['artid']) ? intval($_GET['artid']) : 0; |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | switch ( $op ) { |
|---|
| 171 | case "viewarticle": |
|---|
| 172 | viewarticle($artid, $page); |
|---|
| 173 | break; |
|---|
| 174 | case "listarticles": |
|---|
| 175 | listarticles($secid); |
|---|
| 176 | break; |
|---|
| 177 | case "printpage": |
|---|
| 178 | PrintSecPage($artid); |
|---|
| 179 | break; |
|---|
| 180 | default: |
|---|
| 181 | listsections(); |
|---|
| 182 | break; |
|---|
| 183 | } |
|---|
| 184 | ?> |
|---|