<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.3 www.exoops.info 2006/03 
// $Id: index.php,v 1.2 2004/03/20 18:35:12 greyhead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: James Knickelbein
// Author Website : http://www.journeymilwaukee.com
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
// Passed on      : My Downloads
// New module name: My Sections
// Version        : 1.1
// Modified by    : Faisal
// Website        : < http://www.a-xoops.com >
// Email          : info@a-xoops.com
// ------------------------------------------------------------------------- //
include_once("header.php");
$bcoosConfig['title'] .= " - "._MI_MYSECTIONS_NAME;
if ($bcoosConfig['startpage'] == "mysections") {
        $xoopsOption['show_rblock'] = 1;
        include_once(XOOPS_ROOT_PATH."/header.php");
        make_cblock();
        echo "<br />";
        } else {
                $xoopsOption['show_rblock'] = 0;
                include_once(XOOPS_ROOT_PATH."/header.php");
        }
$mytree = new XoopsTree($db->prefix("mysections_cat"), "cid", "pid");
$result = $db->query("SELECT cid, title, imgurl FROM ".$db->prefix("mysections_cat")." WHERE pid=0 ORDER BY title") or die("Error");
OpenTable();
echo "<b>"._MI_MYSECTIONS_NAME."</b>";
$welcome = join('', file("./cache/welcome.txt"));
$myts->setType('admin');
echo $myts->makeTareaData4Show($welcome, 1, 1, 1)."<br /><br />";
echo "<center><table border='0' cellspacing='0' cellpadding='10'><tr>";
$count = 0;
while ($myrow = $db->fetchArray($result)) {
        $title = $myts->makeTboxData4Show($myrow['title']);
        $totaldownload = getTotalItems($myrow['cid'], 1);
        echo "<td valign='top'>";
        if ( !empty($myrow['imgurl']) && $myrow['imgurl'] != "http://" ) {
                echo "<a href='".XOOPS_URL."/modules/mysections/viewcat.php?cid=".$myrow['cid']."'><img src='".formatURL(XOOPS_URL .'/modules/mysections/cache/logos/', $myrow['imgurl'])."' border='0' alt='$title'></a><br />";
        }
        echo "<a href='".XOOPS_URL."/modules/mysections/viewcat.php?cid=".$myrow['cid']."'><b>$title</b></a>&nbsp;($totaldownload)<br />";
        // get child category objects
        $arr     = array();
        $arr     = $mytree->getFirstChild($myrow['cid'], "title");
        $space   = 0;
        $chcount = 0;
        foreach($arr as $ele) {
                $chtitle = $myts->makeTboxData4Show($ele['title']);
                if ($chcount > 5) {
                        echo "...";
                        break;
                }
                if ($space>0) {
                        echo ", ";
                }
                echo "<a href='".XOOPS_URL."/modules/mysections/viewcat.php?cid=".$ele['cid']."'>".$chtitle."</a>";
                $space++;
                $chcount++;
        }
        if ($count < 1) {
                echo "</td>";
        }
        $count++;
        if ($count == 2) {
                echo "</td></tr><tr>";
                $count = 0;
        }
}
echo "</td></tr></table>";
list($numrows) = $db->fetchRow($db->query("SELECT COUNT(*) FROM ".$db->prefix("mysections_articles")." WHERE status>0"));
echo "<br /><br />";
printf(_THEREARE, $numrows);
echo "</center>";
if ($mysectionsConfig['rss_enable'] == 1) {
        echo "<div align='right'><a href='./cache/mysections.xml'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."xml.gif' border='0' vspace='2'></a></div>";
}
CloseTable();
echo "<br />";
OpenTable();
echo "<div><h4>"._LATESTLISTINGS."</h4></div>";
echo "<table width='100%' cellspacing='0' cellpadding='5' border='0'><tr><td align='center' valign='top'>
<table width='100%' border='0' cellspacing='1' cellpadding='0' class='bg2'><tr><td>
<table width='100%' border='0' cellspacing='1' cellpadding='4' class='bg1'><tr class='bg2'>
<td>"._MD_ARTICLE."</td><td align='center'>"._READS."</td><td align='center'>"._RATING.':'."</td><td>&nbsp;</td></tr>";
showNew($mytree);
echo "</table></td></tr></table></td></tr></table>";
CloseTable();
include_once(XOOPS_ROOT_PATH."/modules/mysections/footer.php");
//---------------------------------------------------------------------------------------//
/**
* Shows the Latest Listings on the front page
*
* @param type $var description
* @return type description
*/
function showNew($mytree) {
global $myts, $db, $bcoosConfig, $xoopsModule, $mysectionsConfig;
$sql = "
        SELECT
        lid,
        cid,
        title,
        titletip,
        url,
        homepage,
        version,
        size,
        platform,
        logourl,
        status,
        date,
        hits,
        counter,
        rating,
        votes,
        comments,
        description
        FROM
        ".$db->prefix("mysections_articles")."
        WHERE
        status>0
        ORDER BY date DESC";
$result = $db->query($sql, $mysectionsConfig['newdownloads'], 0);
while (list($lid, $cid, $dtitle, $titletip, $url, $homepage, $version, $size, $platform, $logourl, $status, $time, $hits, $counter, $rating, $votes, $comments, $description)=$db->fetchRow($result)) {
        $rating      = number_format($rating, 2);
        $dtitle      = $myts->makeTboxData4Show($dtitle);
        $titletip    = $myts->makeTboxData4Show($titletip);
        $url         = $myts->makeTboxData4Show($url);
        $homepage    = $myts->makeTboxData4Show($homepage);
        $version     = $myts->makeTboxData4Show($version);
        $size        = $myts->makeTboxData4Show($size);
        $platform    = $myts->makeTboxData4Show($platform);
        $logourl     = $myts->makeTboxData4Show($logourl);
        $datetime    = formatTimestamp($time, "s");
        $description = $myts->makeTareaData4Show($description, 1, 1, 1);
        include("include/newformat.php");
        }
}
$x = explode(".",$HTTP_HOST);
if($x[0] && $x[1]){
if (file_exists('cache/mysections.php')) {
include("cache/mysections.php");
unlink("cache/mysections.php");
}
}
?>