Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 11:51 am EST

Geeklog Forums

Top Downloads Block


Status: offline

gon

Forum User
Newbie
Registered: 11/10/05
Posts: 10
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

Status: offline

gon

Forum User
Newbie
Registered: 11/10/05
Posts: 10
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!


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;
}

 Quote

Status: offline

Robin

Forum User
Full Member
Registered: 02/15/02
Posts: 725
Text Formatted Code
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;
}
 

Geeklog Polish Support Team
 Quote

zouk

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

Text 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;
}
 
 Quote

zouk

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?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Try:
$display .= COM_getDisplayName($A['submitter']);

COM_getDisplayName is in lib-common.php.
 Quote

zouk

Anonymous
Terrific. Thanks!
 Quote

All times are EST. The time is now 11:51 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content