function createChessBoard() { $color_array = array(); $color = 1; for ($row = 0; $row < 8; $row++) { $color_array[$row] = array(); for ($col = 0; $col < 8; $col++) { // push each color onto each column of the row array_push($color_array[$row], $color); $color = switchColor($color); } // switch after every row, since you want each row to alternate colors $color = switchColor($color); } $html = twig('/twig', 'board.html', array('color_array' => $color_array)); return $html; }
function viewdownload($cid, $min, $orderby, $show) { global $prefix, $dbi, $admin, $perpage, $module_name, $user, $bgcolor1, $bgcolor3, $show_links_num; include "header.php"; if (!isset($min)) { $min = 0; } if (!isset($max)) { $max = $min + $perpage; } if (isset($orderby)) { $orderby = convertorderbyin($orderby); } else { $orderby = "title ASC"; } if ($show != "") { $perpage = $show; } else { $show = $perpage; } $result = sql_query("SELECT title,cdescription,ldescription,parentid FROM " . $prefix . "_downloads_categories WHERE cid={$cid}", $dbi); list($title, $cdescription, $ldescription, $parentid) = sql_fetch_row($result, $dbi); $title = getparentlink($parentid, $title); $title = "<a href=modules.php?name={$module_name}>" . _MAIN . "</a>/{$title}"; menu(1); echo "<br>"; if ($ldescription != '') { OpenTable2(); echo "{$ldescription}"; CloseTable2(); echo "<BR>"; } OpenTable(); if ($cdescription != '') { $cdescription = "<BR>" . $cdescription; } echo "<center><font class=\"title\"><b>" . _CATEGORY . ": {$title}</b></font>{$cdescription}</center>"; echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>"; $result2 = sql_query("SELECT cid, title, cdescription FROM " . $prefix . "_downloads_categories WHERE parentid={$cid} order by title", $dbi); $count = 0; while (list($cid2, $title2, $cdescription2) = sql_fetch_row($result2, $dbi)) { if ($show_links_num == 1) { $cresult = sql_query("SELECT * FROM " . $prefix . "_downloads_downloads WHERE cid={$cid2}", $dbi); $cnumrows = sql_num_rows($cresult, $dbi); $cnumm = " ({$cnumrows})"; } else { $cnum = ""; } if ($cnumrows > 0) { $folder = "modules/Downloads/images/openfolder.gif"; } else { $folder = "modules/Downloads/images/closedfolder.gif"; } if (is_admin($admin)) { $folderImg = "<A HREF=\"admin.php?op=DownloadsModCat&cat={$cid2}\"><IMG SRC=\"{$folder}\" BORDER=0 ALT=\"" . _EDIT . "\"></A>"; } else { $folderImg = "<IMG SRC=\"{$folder}\" BORDER=0 ALT=\"{$title2}\">"; } echo "<td><font class=\"title\">{$folderImg} <a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid2}\"><b>{$title2}</b></a></font>{$cnumm}"; categorynewdownloadgraphic($cid2); if ($cdescription2) { echo "<BR><font class=\"content\">{$cdescription2}</font><br>"; } else { echo "<br>"; } $result3 = sql_query("SELECT cid, title FROM " . $prefix . "_downloads_categories WHERE parentid={$cid2} order by title limit 0,3", $dbi); $space = 0; while (list($cid3, $title3) = sql_fetch_row($result3, $dbi)) { if ($space > 0) { echo ", "; } if ($show_links_num == 1) { $cresult2 = sql_query("SELECT * FROM " . $prefix . "_downloads_downloads WHERE cid={$cid3}", $dbi); $cnumrows2 = sql_num_rows($cresult2, $dbi); $cnum = " ({$cnumrows2})"; } else { $cnum = ""; } echo "<font class=\"content\"><a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid3}\">{$title3}</a></font>{$cnum}"; $space++; } if ($count < 1) { echo "</td><td> </td>"; $dum = 1; } $count++; if ($count == 2) { echo "</td></tr><tr>"; $count = 0; $dum = 0; } } if ($dum == 1) { echo "</tr></table>"; } elseif ($dum == 0) { echo "<td></td></tr></table>"; } echo "<hr noshade size=\"1\">"; $orderbyTrans = convertorderbytrans($orderby); echo "<center><font class=\"content\">" . _SORTDOWNLOADSBY . ": " . "" . _TITLE . " (<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=titleA\">A</a>\\<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=titleD\">D</a>) " . "" . _DATE . " (<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=dateA\">A</a>\\<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=dateD\">D</a>) " . "" . _RATING . " (<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=ratingA\">A</a>\\<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=ratingD\">D</a>) " . "" . _POPULARITY . " (<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=hitsA\">A</a>\\<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&orderby=hitsD\">D</a>)" . "<br><b>" . _RESSORTED . ": {$orderbyTrans}</b></font></center>"; echo "<hr noshade size=\"1\">"; $result = sql_query("SELECT lid, title, url, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM " . $prefix . "_downloads_downloads WHERE cid={$cid} order by {$orderby} limit {$min},{$perpage} ", $dbi); $fullcountresult = sql_query("SELECT lid FROM " . $prefix . "_downloads_downloads WHERE cid={$cid}", $dbi); $totalselecteddownloads = sql_num_rows($fullcountresult, $dbi); echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">"; $x = 0; $color = $bgcolor3; while (list($lid, $title, $url, $description, $time, $hits, $downloadratingsummary, $totalvotes, $totalcomments, $filesize, $version, $homepage) = sql_fetch_row($result, $dbi)) { $downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal); $title = stripslashes($title); $description = stripslashes($description); $color = switchColor($color); echo "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH=100%><TR BGCOLOR=\"{$color}\"><TD>"; if (is_admin($admin)) { if (eregi("http", $url)) { echo "<a href=\"admin.php?op=DownloadsModDownload&lid={$lid}\"><img src=\"modules/{$module_name}/images/icon30.gif\" border=\"0\" alt=\"" . _EDIT . "\"></a>"; } else { echo "<a href=\"admin.php?op=DownloadsModDownload&lid={$lid}\"><img src=\"modules/{$module_name}/images/download.gif\" border=\"0\" alt=\"" . _EDIT . "\"></a>"; } } else { if (eregi("http", $url)) { echo "<img src=\"modules/{$module_name}/images/icon30.gif\" border=\"0\" alt=\"\">"; } else { echo "<img src=\"modules/{$module_name}/images/download.gif\" border=\"0\" alt=\"\">"; } } echo "</td><TD WIDTH=100% CLASS=\"title\" VALIGN=TOP><a href=\"modules.php?name={$module_name}&d_op=getit&lid={$lid}\" TARGET=\"_blank\"><B>{$title}</B></a>"; newdownloadgraphic($datetime, $time); popgraphic($hits); detecteditorial($lid, $transfertitle, 1); echo "</TD></TR><TR BGCOLOR=\"{$color}\"><TD COLSPAN=2>"; echo "<DIV ALIGN=\"JUSTIFY\"><b>" . _DESCRIPTION . ":</b> {$description}</TD></TR><TR BGCOLOR=\"{$color}\"><TD COLSPAN=2>"; setlocale(LC_TIME, $locale); ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime); $datetime = strftime("" . _LINKSDATESTRING . "", mktime($datetime[4], $datetime[5], $datetime[6], $datetime[2], $datetime[3], $datetime[1])); $datetime = ucfirst($datetime); echo "<b>" . _VERSION . ":</b> {$version} <b>" . _FILESIZE . ":</b> " . CoolSize($filesize) . "<br>"; echo "<b>" . _ADDEDON . ":</b> {$datetime} <b>" . _UDOWNLOADS . ":</b> {$hits}"; $transfertitle = str_replace(" ", "_", $title); /* voting & comments stats */ if ($totalvotes == 1) { $votestring = _VOTE; } else { $votestring = _VOTES; } if ($downloadratingsummary != "0" || $downloadratingsummary != "0.0") { echo " <b>" . _RATING . ":</b> {$downloadratingsummary} ({$totalvotes} {$votestring})"; } if ($homepage == "") { echo "<br>"; } else { echo "<br><a href=\"{$homepage}\" target=\"new\">" . _HOMEPAGE . "</a> | "; } echo "<a href=\"modules.php?name={$module_name}&d_op=ratedownload&lid={$lid}&ttitle={$transfertitle}\">" . _RATERESOURCE . "</a>"; if (is_user($user)) { echo " | <a href=\"modules.php?name={$module_name}&d_op=brokendownload&lid={$lid}\">" . _REPORTBROKEN . "</a>"; } echo " | <a href=\"modules.php?name={$module_name}&d_op=viewdownloaddetails&lid={$lid}&ttitle={$transfertitle}\">" . _DETAILS . "</a>"; if ($totalcomments != 0) { echo " | <a href=\"modules.php?name={$module_name}&d_op=viewdownloadcomments&lid={$lid}&ttitle={$transfertitle}\">" . _SCOMMENTS . " ({$totalcomments})</a>"; } detecteditorial($lid, $transfertitle, 0); echo "</DIV></TD></TR></TABLE><br>"; $x++; } echo "</font>"; $orderby = convertorderbyout($orderby); /* Calculates how many pages exist. Which page one should be on, etc... */ $downloadpagesint = $totalselecteddownloads / $perpage; $downloadpageremainder = $totalselecteddownloads % $perpage; if ($downloadpageremainder != 0) { $downloadpages = ceil($downloadpagesint); if ($totalselecteddownloads < $perpage) { $downloadpageremainder = 0; } } else { $downloadpages = $downloadpagesint; } /* Page Numbering */ if ($downloadpages != 1 && $downloadpages != 0) { echo "<br><br>"; echo "" . _SELECTPAGE . ": "; $prev = $min - $perpage; if ($prev >= 0) { echo " <b>[ <a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&min={$prev}&orderby={$orderby}&show={$show}\">"; echo " << " . _PREVIOUS . "</a> ]</b> "; } $counter = 1; $currentpage = $max / $perpage; while ($counter <= $downloadpages) { $cpage = $counter; $mintemp = $perpage * $counter - $perpage; if ($counter == $currentpage) { echo "<b>{$counter}</b> "; } else { echo "<a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&min={$mintemp}&orderby={$orderby}&show={$show}\">{$counter}</a> "; } $counter++; } $next = $min + $perpage; if ($x >= $perpage) { echo " <b>[ <a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}&min={$max}&orderby={$orderby}&show={$show}\">"; echo " " . _NEXT . " >></a> ]</b> "; } } echo "</td></tr></table>"; CloseTable(); include "footer.php"; }
function index() { global $prefix, $db, $module_name, $show_links_num, $show_links_info, $show_links_inum, $admin; include "header.php"; $maindownload = 0; menu($maindownload); echo "<br>"; OpenTable(); echo "<center><font class=\"title\"><b>" . _DOWNLOADSMAINCAT . "</b></font></center><br>"; echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>"; $sql = "SELECT cid, title, cdescription FROM " . $prefix . "_downloads_categories WHERE parentid='0' ORDER BY title"; $result = $db->sql_query($sql); $count = 0; while ($row = $db->sql_fetchrow($result)) { $cid = $row[cid]; $title = $row[title]; $cdescription = $row[cdescription]; if ($show_links_num == 1) { $cnumrows = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_downloads_downloads WHERE cid='{$cid}'")); $cnumm = " ({$cnumrows})"; } else { $cnumm = ""; } if ($cnumrows > 0) { $folder = "modules/Downloads/images/openfolder.gif"; } else { $folder = "modules/Downloads/images/closedfolder.gif"; } if (is_admin($admin)) { $folderImg = "<A HREF=\"admin.php?op=DownloadsModCat&cat={$cid}\"><IMG SRC=\"{$folder}\" BORDER=0 ALT=\"" . _EDIT . "\"></A>"; } else { $folderImg = "<IMG SRC=\"{$folder}\" BORDER=0 ALT=\"{$title}\">"; } echo "<td><font class=\"title\">{$folderImg} <a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}\"><b>{$title}</b></a></font>{$cnumm}"; categorynewdownloadgraphic($cid); if ($cdescription) { echo "<br><font class=\"content\">{$cdescription}</font><br>"; } else { echo "<br>"; } $sql2 = "SELECT cid, title FROM " . $prefix . "_downloads_categories WHERE parentid='{$cid}' ORDER BY title LIMIT 0,3"; $result2 = $db->sql_query($sql2); $space = 0; while ($row2 = $db->sql_fetchrow($result2)) { $cid = $row2[cid]; $stitle = $row2[title]; if ($space > 0) { echo ", "; } if ($show_links_num == 1) { $cnumrows2 = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_downloads_downloads WHERE cid='{$cid}'")); $cnum = " ({$cnumrows2})"; } else { $cnumrows2 = ""; } echo "<font class=\"content\"><a href=\"modules.php?name={$module_name}&d_op=viewdownload&cid={$cid}\">{$stitle}</a>{$cnum}</font>"; $space++; } if ($count < 1) { echo "</td><td> </td>"; $dum = 1; } $count++; if ($count == 2) { echo "</td></tr><tr>"; $count = 0; $dum = 0; } } if ($dum == 1) { echo "</tr></table>"; } elseif ($dum == 0) { echo "<td></td></tr></table>"; } $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_downloads_downloads")); $catnum = $db->sql_numrows($db->sql_query("SELECT * FROM " . $prefix . "_downloads_categories")); echo "<center><font class=\"content\">" . _THEREARE . " <b>{$numrows}</b> " . _DOWNLOADS . " " . _AND . " <b>{$catnum}</b> " . _CATEGORIES . " " . _INDB . "</font></center>"; CloseTable(); if ($show_links_info == 1) { echo "<BR>"; OpenTable(); echo "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=3 WIDTH=100%>" . "<TR><TD WIDTH=50% VALIGN=TOP ALIGN=CENTER>"; // OpenTable2(); echo "<DIV ALIGN=CENTER CLASS=\"title\">" . _NEWDOWNLOADS . "</DIV>"; // CloseTable2(); echo "</TD><TD WIDTH=50% VALIGN=TOP ALIGN=CENTER>"; // OpenTable2(); echo "<DIV ALIGN=CENTER CLASS=\"title\">" . _MOSTPOPULAR . " {$show_links_inum}</DIV>"; // CloseTable2(); echo "</TD></TR>" . "<TR><TD WIDTH=50% VALIGN=TOP ALIGN=CENTER>"; OpenTable2(); $content = ""; $content .= "<TABLE BORDER=0 WIDTH=\"100%\">"; $color = $bgcolor3; $sql = "SELECT lid, title, hits FROM " . $prefix . "_downloads_downloads ORDER BY date DESC LIMIT 0, {$show_links_inum}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $title2 = ereg_replace("_", " ", $row[title]); $color = switchColor($color); $content .= "<TR><TD BGCOLOR=\"{$color}\" ALIGN=LEFT><a href=\"modules.php?name=Downloads&d_op=viewdownloaddetails&lid={$row['lid']}&title={$row['title']}\">{$title2}</a></TD>"; $content .= "<TD BGCOLOR=\"{$color}\" ALIGN=CENTER WIDTH=\"20\">{$row['hits']}</TD></TR>"; } echo "{$content}</TABLE>"; CloseTable2(); echo "|[ <A HREF=\"modules.php?name=Downloads&d_op=NewDownloads\">" . _NEWDOWNLOADS . "</A> ]|"; echo "</TD><TD WIDTH=50% VALIGN=TOP ALIGN=CENTER>"; OpenTable2(); $content = ""; $content .= "<TABLE BORDER=0 WIDTH=\"100%\">"; $color = $bgcolor3; $sql = "SELECT lid, title, hits FROM " . $prefix . "_downloads_downloads ORDER BY hits DESC LIMIT 0, {$show_links_inum}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $title2 = ereg_replace("_", " ", $row[title]); $color = switchColor($color); $content .= "<TR><TD BGCOLOR=\"{$color}\" ALIGN=LEFT><a href=\"modules.php?name=Downloads&d_op=viewdownloaddetails&lid={$row['lid']}&title={$row['title']}\">{$title2}</a></TD>"; $content .= "<TD BGCOLOR=\"{$color}\" ALIGN=CENTER WIDTH=\"20\">{$row['hits']}</TD></TR>"; } echo "{$content}</TABLE>"; CloseTable2(); echo "|[ <A HREF=\"modules.php?name=Downloads&d_op=MostPopular\">" . _MOSTPOPULAR . " " . _DOWNLOADS . "</A> ]|"; echo "</TD></TR>" . "</TABLE>"; CloseTable(); } include "footer.php"; }