Fork me on GitHub

Need help hacking Latest Comments module  Bottom

  • I am stuck on a problem I don't really understand trying to hack this modules to have the downloads comments diplayed, a $pntable that refers to pnDBGetTables gets empty output and I can't figure why...

    here is the code:

    Code

    list($dbconn) = pnDBGetConn();
        $pntable = pnDBGetTables();

        $LCtemptable = $pntable['latestcomments_temp'];
        $LCtempcol= &$pntable['latestcomments_temp_column'];
       
        $pollcommtable= $pntable['pollcomments'];
        $commcol = &$pntable['comments_column'];
        $storcol = &$pntable['stories_column'];
        $phpbcol = &$pntable['phpbb14_posts_column'];
       
        $pollcommcol= $pntable['pollcomments_column'];
        $polldesctable= $pntable['poll_desc'];
        $polldesccol= $pntable['poll_desc_column'];

        $userscol = &$pntable['users_column'];
         
        //LMS hack
       
        $downcol=$pntable['downloads_downloads_column'];
        $downcommcol=$pntable['downloads_votedata_column'];
       
        // create a temporary table; needs to do this since table merging not supported
        // in current mysql version
        $sql ="DROP TABLE IF EXISTS $LCtemptable";
        $result1=$dbconn->Execute($sql);
        $result1->Close();

        $sql ="CREATE  TABLE $LCtemptable
               (
                    $LCtempcol[tid]     INT(10),
                    $LCtempcol[pid]     INT(10),
                    $LCtempcol[sid]     INT(10),
                    $LCtempcol[date]    VARCHAR(20),
                    $LCtempcol[fid]     INT(10),
                    $LCtempcol[subject] VARCHAR(40),
                    $LCtempcol[title]   VARCHAR(40),
                    $LCtempcol[name]    VARCHAR(30)
                )
               
                "
    ;     // type=heap   temporary
       
        $result1=$dbconn->Execute($sql);

        if ($dbconn->ErrorNo() != 0) {
            pnSessionSetVar('errormsg', _CREATEFAILED);
            return false;
        }
       
        if ($merge_pn==1)   {
             $query="INSERT INTO $LCtemptable
                 SELECT  $commcol[tid],
                         $commcol[pid],
                         $commcol[sid],
                         $commcol[date],
                         0,
                         $commcol[subject],
                         $storcol[title],
                         $commcol[name]
                 FROM $pntable[comments], $pntable[stories]
                 WHERE $commcol[sid]=$storcol[sid]
                 ORDER BY $commcol[date] $order
                 LIMIT 0,$lastc"
    ;
              $result2 = $dbconn->Execute($query);
              if ($dbconn->ErrorNo() != 0) {
                      pnSessionSetVar('errormsg', _INSERTPNFAILED);
                      return false;
              }
              else {
                  $result2->Close();
              }
         }
         
         
              //LMS hack
     if(pnModAvailable('Downloads')) {
             $query="INSERT INTO $LCtemptable
                 SELECT  $downcol[cid] AS tid,
                         $downcommcol[id] AS pid,
                         $downcommcol[lid] AS sid,
                         $downcommcol[timestamp] AS date,
                         -1,
                         'Download' AS subject,
                         $downcol[title],
                         $downcommcol[user] AS name
                 FROM $pntable[downloads_votedata], $pntable[downloads_downloads]
                 WHERE $downcommcol[lid]=$downcol[lid]
                 ORDER BY date $order
                 LIMIT 0,$lastc"
    ;
             
              $result6 = $dbconn->Execute($query);
              if ($dbconn->ErrorNo() != 0) {
                echo $query;
                      pnSessionSetVar('errormsg', _INSERTDOWNFAILED);
                      return false;
              }
              else {
                  $result6->Close();
              }
        }

          //end LMS hack


    and the $query I get comes with empty $downcommcol[stuff]:

    Code

    INSERT INTO nuke_latestcomments_temp SELECT nuke_downloads_downloads.pn_cid as tid, as pid, as sid, as date, -1, 'Download' as subject, nuke_downloads_downloads.pn_title, as name FROM nuke_downloads_votedata, nuke_downloads_downloads WHERE =nuke_downloads_downloads.pn_lid ORDER BY date desc LIMIT 0,31


    you will notice the // LMS hacks comments where I inserted my code.

    please help me I'm getting mad trying to find out what's wrong with this code!!! cry

    PS: I'm with heavily hacked postnuke 0.714

This list is based on users active over the last 60 minutes.