Subject: Top Downloads Block

Posted on: 07/03/06 06:07pm
By: gon

Could someone tell me what could I paste in libcustom in order to have a Top Downloads phpblock function? I wrote Squatty, I know he have one code btw it doesnt work...

Thnx!

Top Downloads Block

Posted on: 08/03/06 04:27am
By: gon

[QUOTE BY= gon] Could someone tell me what could I paste in libcustom in order to have a Top Downloads phpblock function? I wrote Squatty, I know he have one code btw it doesnt work...

Thnx![/QUOTE]

function phpblock_topdls()
{

global $_CONF, $_USER, $_TABLES, $HTTP_GET_VARS, $PHP_SELF, $QUERY_STRING;

$topdls = $HTTP_GET_VARS['topdls'];
$siteurl = $_CONF['site_url'];

if (empty($QUERY_STRING)){
$self = $PHP_SELF . '?';
} else {
$self = $_CONF['site_url'] . $PHP_SELF . '?' . $QUERY_STRING . '&';
}

//default is by views
if(empty($topdls)){
$topdls='default';
}
if ($topdls=='default'){

$display .= "

n";
$display .= "TítuloD/Ls";
$sqlresult = DB_query("SELECT * FROM gl_filemgmt_filedetail where
hits > 0 order by hits DESC limit 0, 10");
while ($row = DB_fetchArray ($sqlresult)) {
$display .=" >$row[title]$row[hits]";
}
$display .= "";
}

if (($_USER['uid'] > 1)){
$display .="";
}

if (!SEC_inGroup('DocMgmt-Admin',$uid)) {
$display .= "

n";
$display .= "";
$display .= '' .
"Más Descargas" . '
';
$display .= "";
}

return $display;
}


Top Downloads Block

Posted on: 08/03/06 04:34am
By: Robin

function phpblock_topdownloads () {
    global $LANG_FILEMGMT, $_FM_TABLES, $_CONF;

    $retval = '';

    $result = DB_query("SELECT lid, title, hits from {$_FM_TABLES['filemgmt_filedetail']} WHERE hits > 0 ORDER BY hits desc LIMIT 10");
    $nrows  = DB_numRows($result);
    if ($nrows > 0) {
        $retval .= '<table border="0" cellspacing="0" cellpadding="0">' . LB;
        $retval .= '<tr><td><b>Plik</b></td><td align="right"><b>D/Ls</b></td></tr>' . LB;
        for ($i = 0; $i < $nrows && $i < 10; $i++) {
            list ($lid, $title,$hits) = DB_fetchARRAY($result);
            if (strlen ($title) > 20) {
                $attr = ' title="' . htmlspecialchars ($title) . '"';
                $title = substr ($title, 0, 17) . '...';
            } else {
                $attr = '';
            }
            $title = str_replace (' ', ' ', $title);
            $retval .= '<tr><td><a href="' . $_CONF[site_url]
                . '/filemgmt/singlefile.php?lid=' . $lid . '"' . $attr . '>'
                . $title . '</td><td align="right">' . $hits . '</td></tr>' . LB;
        }
        $retval .= '</table>' . LB;
        $retval .= '<p><a href="' . $_CONF[site_url]
                . '/filemgmt/index.php">Więcej Plików</a></p>' . LB;
    }

    return $retval;
}

Re: Top Downloads Block

Posted on: 16/07/07 08:31pm
By: Anonymous

Tried to get the ones mentioned here to work, w/o any luck. Here's my version, that finally works for me:

PHP Formatted Code

function phpblock_topdl()
{
    global $_TABLES;

    $query  = "SELECT *FROM `gl_filemgmt_filedetail` ORDER BY `gl_filemgmt_filedetail`.`hits` DESC LIMIT 0 , 5";
    $result = mysql_query($query);

    $nrows  = DB_numRows($result);

    if( $nrows > 0 ){
        $string = '';
        $popular = array();

        for( $i = 0; $i < $nrows; $i++ ){
            $A = DB_fetchArray( $result );
            $string .= $poplist . '<br>';
            $popular[] = '<a href="' . COM_buildUrl( $_CONF['site_url']
                    . '/filemgmt/index.php?id=' . $A['lid'] ) . '">' . $A['title']
                    . '</a> (' . $A['hits'] . ')';
        }
        if( !empty( $popular )){
            $poplist = COM_makeList( $popular, 'list-popular-stories' );
        }
    }
    return $poplist;
}
 

Re: Top Downloads Block

Posted on: 27/09/07 03:00am
By: Anonymous

so, the block is working real well so far but now i have a new requirement to enhance this block. i'd like to see the name of the author/submitter of the file too. well, that's simple since i can just add (' . $A['submitter'] .'Wink but the problem is that the table only stores userids and not full names Smile

anyone able to help me here please?

Re: Top Downloads Block

Posted on: 27/09/07 09:39am
By: jmucchiello

Try:
$display .= COM_getDisplayName($A['submitter']);

COM_getDisplayName is in lib-common.php.

Re: Top Downloads Block

Posted on: 29/09/07 01:09am
By: Anonymous

Terrific. Thanks!

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=64819