Thread subject: pHpFusion Nederlands (BE|NL) » Ondersteuning, Themas, Infusies, Modificaties en Installatie :: Downloads sorteren in standaard downloads.php

Posted by Thijs on 24 juni 2009, 18:51
#1

Ik zou graag in de standaard downloads.php een knop hebben waarmee de downloads op naam, datum en hits te sorteren zijn. Ik heb hier een begin in gemaakt maar ben vast gelopen. Ik heb op www.phpfusion-mods.com hulp gevraagd en op phpfusion-mods.net, hier ben ik alleen niets mee op geschoten doordat er gewoon niemand reageert. Ik hoop dat ik hier wel geholpen wordt.

De code is als volgt:

Code



/*-------------------------------------------------------+

| PHP-Fusion Content Management System

| Copyright (C) 2002 - 2008 Nick Jones

| http://www.php-fusion.co.uk/

+--------------------------------------------------------+

| Filename: downloads.php

| Author: Nick Jones (Digitanium)

+--------------------------------------------------------+

| This program is released as free software under the

| Affero GPL license. You can redistribute it and/or

| modify it under the terms of this license which you

| can read by viewing the included agpl.txt or online

| at www.gnu.org/licenses/agpl.html. Removal of this

| copyright header is strictly prohibited without

| written permission from the original author(s).

+--------------------------------------------------------*/

require_once "maincore.php";

require_once THEMES."templates/header.php";

include LOCALE.LOCALESET."downloads.php";



add_to_title($locale['global_200'].$locale['400']);



$type_id= $_GET['type_id'];

$cat_id= $_GET['cat_id'];



if (isset($_GET['download_id']) && isnum($_GET['download_id'])) {

        $res = 0;

        if ($data = dbarray(dbquery("SELECT download_url,download_cat FROM ".DB_DOWNLOADS." WHERE download_id='".$_GET['download_id']."'"))) {

                $cdata = dbarray(dbquery("SELECT * FROM ".DB_DOWNLOAD_CATS." WHERE download_cat_id='".$data['download_cat']."'"));

                if (checkgroup($cdata['download_cat_access'])) {

                        $res = 1;

                        $result = dbquery("UPDATE ".DB_DOWNLOADS." SET download_count=download_count+1 WHERE download_id='".$_GET['download_id']."'");

                        redirect($data['download_url']);

                }

        }

        if ($res == 0) { redirect("downloads.php"); }

}



if (!isset($_GET['cat_id']) || !isnum($_GET['cat_id'])) {

        opentable($locale['400']);

        $result = dbquery("SELECT * FROM ".DB_DOWNLOAD_CATS." WHERE ".groupaccess('download_cat_access')." ORDER BY download_cat_name");

        $rows = dbrows($result);

        if ($rows) {

                $counter = 0; $columns = 2;

                echo "".$locale['401']."
".$locale['402']."
\n\n";

                echo "
\n\n";

                while ($data = dbarray($result)) {

                        if ($counter != 0 && ($counter % $columns == 0)) { echo "\n\n"; }

                        $num = dbcount("(download_cat)", DB_DOWNLOADS, "download_cat='".$data['download_cat_id']."'");

                        echo "\n" ;

                        $counter++;

                }

                echo "\n
RSS ''
".$data['download_cat_name']." ($num)";

                        if ($data['download_cat_description'] != "") { echo "
\n".$data['download_cat_description'].""; }

                        echo "
\n";

        } else {

                echo "

\n".$locale['430']."

\n
\n";

        }

        closetable();

} else {

        $res = 0;

        $result = dbquery("SELECT * FROM ".DB_DOWNLOAD_CATS." WHERE download_cat_id='".$_GET['cat_id']."'");

        if (dbrows($result) != 0) {

                $cdata = dbarray($result);

                if (checkgroup($cdata['download_cat_access'])) {

                        $res = 1;

                        add_to_title($locale['global_201'].$cdata['download_cat_name']);



                echo "\n";

                echo "\n";

                echo "\n";

                echo "
\n";

                echo "  \n";

                echo " Popularity  \n";

                echo " Date  \n";

                echo " Name\n";

            echo "
\n";

                if ($cat_id > 0) { $where = " WHERE download_cat='".$cat_id."'";} else { $where = "";}

                if ($type_id == 2) { $order = " download_count DESC";}

                elseif ($type_id == 3) { $order = " download_datestamp DESC";}

                else { $order = " download_title ASC";}

               

                        opentable($locale['400'].": ".$cdata['download_cat_name']);

                        echo"
''
";

                        $rows = dbcount("(*)", DB_DOWNLOADS, "download_cat='".$_GET['cat_id']."'");

                        if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }

                        if ($rows != 0) {



                                if ($cat_id > 0) { $where2 = " AND download_cat ='".$cat_id."'";} else { $where2 = "";}

                                $myquery =" SELECT tu.*, tn.*, download_cat_id, download_cat_name FROM ".$db_prefix."download_cats tn

                                        LEFT JOIN ".$db_prefix."downloads tu ON tn.download_cat_id=tu.download_cat

                                        WHERE download_id!=''".$where2." ORDER BY download_title ASC,".$order." LIMIT ".$_GET['rowstart'].",15";

                                $result = dbquery($myquery);




                                //$result = dbquery("SELECT * FROM ".DB_DOWNLOADS." WHERE download_cat='".$_GET['cat_id']."' ORDER BY ".$order." LIMIT ".$_GET['rowstart'].",15");

                                $numrows = dbrows($result); $i = 1;

                                while ($data = dbarray($result)) {

                                        if ($data['download_datestamp'] + 604800 > time() + ($settings['timeoffset'] * 3600)) {

                                                $new = " ".$locale['410']."";

                                        } else {

                                                $new = "";

                                        }

                                        echo "\n";

                                        echo "\n\n\n";

                                        if ($data['download_description']) { echo "\n\n\n"; }

                                        echo "\n\n\n";

                                        echo "\n\n\n\n";

                                        echo "\n\n\n";

                                        echo "
".$data['download_title']." $new
".nl2br(stripslashes($data['download_description']))."
".$locale['411']." ".$data['download_license']."".$locale['412']." ".$data['download_os']." ".$locale['413']." ".$data['download_version']."
".$locale['414']." ".showdate("shortdate", $data['download_datestamp'])." ".$locale['415']." ".$data['download_count']."";



if (iMEMBER){

echo "".$locale['416']." (".$data['download_filesize'].")";



}else{



echo "".$locale['417']."";



}







echo"
\n";

                                        if ($i != $numrows) { echo "
''
\n"; $i++; }

                                }

echo"
''
";

                                closetable();

                                if ($rows > 15) { echo "
\n".makepagenav($_GET['rowstart'], 15, $rows, 3, FUSION_SELF."?cat_id=".$_GET['cat_id']."&")."\n
\n"; }

                        } else {

                                echo $locale['431']."\n";

                                closetable();

                        }

                }

        }

        if ($res == 0) { redirect(FUSION_SELF); }

}



require_once THEMES."templates/footer.php";

?>


De code in rood gekleurd is wat toegevoegd of aangepast is. Kan iemand hier de fout uit halen of mij vertellen hoe het moet??