Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
eldorado
Involved
Involved



Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Sun Mar 08, 2009 5:03 am Reply with quote

Just got my hands on the top10 downloads block and just for the fun I used some ideas from the collapsible forum block.
Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/
/************************************************************************/
/* Additional code clean-up, performance enhancements, and W3C and      */
/* XHTML compliance fixes by Raven and Montego.                         */
/************************************************************************/
/* Some HTML addons in this script can cause the block not to be W3C      */
/* compliant                                                                                  */

if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}

global $prefix, $db;

function random_color(){
    mt_srand((double)microtime()*1000000);
    $c = '';
    while(strlen($c)<6){
        $c .= sprintf("%02X", mt_rand(0, 255));
    }
    return $c;
}

//Additionals Configs
$SkipSubmitter = "'eldorado','montego','gazzasan','loki'"; //these are the fools who's downloads won't be shown.Rofl I'm kidding guys :P
$MaxDownloads = 10; //Input Max Downloads to show up in the block
$Font_Size_Max = 6; //Fancy Styling the thing.
$Font_Size_Min = 1; //Set minimum font for maximum visibility

$content = '';
$n = 1;
$result = $db->sql_query("SELECT lid, title FROM ".$prefix."_downloads_downloads WHERE submitter NOT IN ($SkipSubmitter) ORDER BY hits DESC LIMIT 0,$MaxDownloads");
   if($result==''){$content = "Error in MYSQL script.Either you don't have downloads or the config of the block is flawed.";
      }
while (list($lid, $title) = $db->sql_fetchrow($result)) {
   
   $size = $Font_Size_Max-$n+1;
      if($size < $Font_Size_Min){$size = $Font_Size_Min;
         }
   $lid = intval($lid);
   $title2 = htmlspecialchars(str_replace('_', ' ', $title), ENT_QUOTES, _CHARSET);
   $content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Downloads&amp;d_op=viewdownloaddetails&amp;lid='.$lid.'"><font color="'.random_color().'" "size="'.$size.'"><u>'.$title2.'</u></font></a>&nbsp;';
   ++$n;
}
error_reporting($currentReporting);
?>


The idea behind this was to create a sort of height hierarchy between the top downloads.
edit:This script is unfinished .I want to add the RSS tag from nukefeed but would be cool if I had some newer Ideas.
The height hierarchy can easily be shutdown if the $font_size_max and $font_size_min are set to the same value.
 
View user's profile Send private message Visit poster's website MSN Messenger
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Mon Apr 13, 2009 6:24 am Reply with quote

How is the script coming along? You mentioned that it was "unfinished".

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
eldorado







PostPosted: Mon Apr 13, 2009 8:02 am Reply with quote

Well I do have some problems with the colors not displaying in firefox. And I still need to add some additionnal config layers to make it pro Very Happy
Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/
/************************************************************************/
/* Additional code clean-up, performance enhancements, and W3C and      */
/* XHTML compliance fixes by Raven and Montego.                         */
/************************************************************************/
/* Modded for me and perhaps for RN                                     */

if ( !defined('BLOCK_FILE') ) {
   Header('Location: ../index.php');
   die();
}

global $prefix, $db;
//Additionals Configs
$SkipSubmitter = "'eldorado','montego','gazzasan','loki'"; //these are the fools who's downloads won't be shown.Rofl I'm kidding guys :P
$MaxDownloads = 10; //Input Max Downloads to show up in the block
$Font_Size_Max = 6; //Fancy Styling the thing.
$Font_Size_Min = 1; //Set minimum font for maximum visibility
$Font_Color = 1; // Allow Random Colours.Not Working in Gecko Engine for some reason.
$backend_DL_XML = 'feeds-3-rss20.xml'; //URL of your Downloads Feed.Assumed in root directory. If it's empty then it won't show up.Remember to create it with nukefeed.

function random_color(){
    mt_srand((double)microtime()*1000000);
    $c = '';   //Init.
    while(strlen($c)<6){  //Colours = 6 numbers or letters
        $c .= sprintf("%02X", mt_rand(0, 255));
    }
   if($Font_Color==1){
               return $c;
                  }
}
$ContentXML= ''; // XML button.
if (strlen($backend_DL_XML)>0) $ContentXML = '<center><a href="'.$backend_DL_XML.'" title="Downloads Backend"><img src="images/blocks/xmlicon.gif" alt="" border="0" /></a></center>';


$content = '';
$result = $db->sql_query("SELECT lid, title FROM ".$prefix."_downloads_downloads WHERE submitter NOT IN ($SkipSubmitter) ORDER BY hits DESC LIMIT 0,$MaxDownloads");
if($result==''){$content = "Error in MYSQL script.Either you don't have downloads or the config of the block is flawed.";}

$n = 1;
$content .= $ContentXML;
while (list($lid, $title) = $db->sql_fetchrow($result)) {
   
   $size = $Font_Size_Max-$n+1;
      if($size < $Font_Size_Min){$size = $Font_Size_Min;
         }
   $lid = intval($lid);
   $title2 = htmlspecialchars(str_replace('_', ' ', $title), ENT_QUOTES, _CHARSET);

   $content .= '<strong><big>&middot;</big></strong>&nbsp;<a href="modules.php?name=Downloads&amp;d_op=viewdownloaddetails&amp;lid='.$lid.'"><font color="'.random_color().'" "size="'.$size.'">'.$title2.'</font></a>&nbsp;';
   ++$n;
}
error_reporting($currentReporting);
?>


here it is. enjoy , that's the best I could achieve under 70 lines of code
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©