Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Goto page: 1 - 2 [+1]

Bottom
i-lastseen doesn't work
  • Posted: 26.11.2005, 11:14
     
    Bad_Dude
    rank:
    Helper Helper
    registered:
     September 2005
    Status:
    offline
    last visit:
    03.07.08
    Posts:
    463

    Code

    // i-Block [Last Seen] its version is version 1.0
    // sideblock by : Alexander Graef aka MagicX
    // http://www.portalzine.de
    // ----------------------------------------------------------------------

    $blocks_modules['i-lastseen'] = array(
        'func_display'      => 'blocks_lastseen_block',
         'func_add'         => 'blocks_lastseen_add',
        'func_update'       => 'blocks_lastseen_update',
        'func_edit'         => 'blocks_lastseen_edit',
        'text_type'         => '    'text_type_long'    => 'i-Block[Last Seen]',
        '
    allow_multiple'    => false,
        '
    form_content'      => false,
        '
    form_refresh'      => false,
    //  '
    support_xhtml'     => true,
        '
    show_preview'      => true
    );

    pnSecAddSchema("iBlock_Last_Seen::", "Block title::");

    function blocks_lastseen_block($row)
    {

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

        if (pnUserLoggedIn())
        {
        $username = pnUserGetVar('
    uname');
        }

        $ip = getenv("REMOTE_ADDR");

        if (!isset($username)){
            $username=$ip;
            $tag = 1;
        }

        $sql = "CREATE TABLE IF NOT EXISTS ".pnConfigGetVar('
    prefix')."_lastseen (
        id int(15) NOT NULL auto_increment,
        username text NOT NULL,
        date int(15) NOT NULL default '
    0',
        ip varchar(50) default NULL,
        tag text NOT NULL,
        PRIMARY KEY  (id),
        UNIQUE KEY id (id))";

        $result=$dbconn->Execute($sql);

        $sql = "SELECT * FROM ".pnConfigGetVar('
    prefix')."_lastseen
                WHERE username = '
    ".pnVarPrepForStore($username)."'";

        $result=$dbconn->Execute($sql);


       if ($dbconn->ErrorNo() != 0) {
          die("ERROR: (checking current list" . $dbconn->ErrorMsg());
       }

       if  {
          $sql= "UPDATE ".pnConfigGetVar('
    prefix')."_lastseen
                SET date = '
    ".pnVarPrepForStore(time())."'
                WHERE username='
    ".pnVarPrepForStore($username)."'
                ";
          $result=$dbconn->Execute($sql);

          if ($dbconn->ErrorNo() != 0) {
             die("ERROR: (updating existing user" . $dbconn->ErrorMsg());
          }
       }
       else
       {
           sql = "INSERT INTO ".pnConfigGetVar('
    prefix')."_lastseen VALUES
           ('
    ',
           '
    ".pnVarPrepForStore($username)."',
           '
    ".pnVarPrepForStore(time())."',
           '
    ".pnVarPrepForStore($ip)."',
           '
    ".pnVarPrepForStore($tag)."'
           )";
           $result=$dbconn->Execute($sql);

           if ($dbconn->ErrorNo() != 0) {
              die("ERROR: (adding new user" . $dbconn->ErrorMsg());
           }
        }

        $url = explode('
    |', $row['url']);

        if (!$url[0])
        {
            $url[0] = 1;
        }
        if (!$url[1])
        {
            $url[1] = 10;
        }
        if ($url[0] == 1)
        {
        $settag = "";
        }
        else
        {
        $settag = "where tag =\"\"";
        }
         if (!$url[2])
        {
            $url[2] = 100;
                }

        $result= $dbconn -> Execute("select * from ".pnConfigGetVar('
    prefix')."_lastseen
                                    where username='
    ".pnVarPrepForStore($ip)."'");
        $numrows = $result-> RecordCount();

        if ($numrows >= $url[2])
        {
        $sql= "Delete from ".pnConfigGetVar('
    prefix')."_      $result=$dbconn->Execute(sql);
        }

        $row['
    content'] = "";
        if($url[0] ==2){
        $sql = "SELECT
                username,
                date,
                ip,
                tag
                FROM ".pnConfigGetVar('
    prefix')."_lastseen
                where tag !='
    1'
                ORDER BY date DESC
                LIMIT $url[1]";
        }
        elseif($url[0]==1)
        {
        $sql = "SELECT
                username,
                date,
                ip,
                tag
                FROM ".pnConfigGetVar('
    prefix')."_lastseen
                ORDER BY date DESC
                LIMIT $url[1]";
        }

        $result=$dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
           die("ERROR: (getting user list" . $dbconn->ErrorMsg());
        }
        ///start
        while (!$result->EOF) {
               list($uname, $date, $ip) = $result->fields;
               if ($uname == $ip) {
              if (pnSecAuthAction(0, '
    iBlock_Last_Seen::', "$row[title]::", ACCESS_ADMIN)) {
                 $uname="<a href=\"http://www.samspade.org/t/lookat?a=$uname\"
    target=\"_blank\"><b>$uname</b></a>";
              }
                else {
                 $uname="<b>"._ANONYMOUS."</b>";
              }
           } else {
               $uname="<a href=\"user.php?op=userinfo&uname=$uname\"><b>$uname</b></a>";
           }

           $date = GetUserTime($date);

           $system_offset = pnConfigGetVar('
    timezone_offset');
           $user_offset=pnUserGetVar('
    timezone_offset');
           $adjusteddate=mktime((date("H",$date)), date("i",$date), date("s",$date), date("m",$date), date("d",$date), date("Y",$date));
           $lastdate=date(_DATESETTING,$date);
           $content .= "<img src=\"images/iBlock/Last_Seen/arrow.gif\"> $uname<br><font size=1>$lastdate</font><br>";
           $result->MoveNext();
        }

            $row['
    content'] = $content;

        if (!pnSecAuthAction(0, "iBlock_Last_Seen::", "$row[title]::", ACCESS_READ)) {
            return;
        }
        else
        {
            return themesideblock($row);
        }


    }

    function blocks_lastseen_add($row)
    {
        $row['
    url'] = '1|10|200';
        return $row;
    }
    function blocks_lastseen_update($vars)
    {
        $vars['
    url'] = "$vars[guest]|$vars[amount]|$vars[delete]";
        return $vars;
    }
    function blocks_lastseen_edit($row)
    {
            $url = explode('
    |', $row['url']);

            $guest = $url[0];
            $amount = $url[1];
            $delete = $url[2];
            $guests[$url[0]] = '
    slected';

         $output ="<td>"
       .""._DISPLAYGUEST."</td><td> <select name=\"guest\" size=\"1\">\n"
        ."<option name=\"guest\" value=\"1\" $guests[1] >"._YES."</option>\n"
        ."<option name=\"guest\" value=\"2\" $guests[2] >"._NO."</option>\n"
               ."</select>$url[0]</td></tr>";
        $output .= "<tr><td valign=\"top\" class=\"pn-normal\">"._DISPLAY."</td><td>"
            ."<input type=\"text\" name=\"amount\" size=\"30\" maxlength=\"255\" value=\"$amount\" class=\"pn-normal\">"
            .""._HOWMANY."</td></tr>\n";
        $output .= "<tr><td valign=\"top\" class=\"pn-normal\">Delete Anonymous after:</td><td>"
            ."<input type=\"text\" name=\"delete\" size=\"30\" maxlength=\"255\" value=\"$delete\" class=\"pn-normal\">"
            ."reached</td></tr>\n";

        return $output;
    }
    ?>


    I have been trying to get this block work with PostNuke .750 for months but there is no luck at all...
    Here is the error I get after uploading the file to the proper directory, forum/includes/blocks/ and so on...

    Here is the error that I get after trying to access to add a block.....


    Code

    Parse error: parse error, unexpected T_STRING, expecting ')' in /home/james19/public_html/forum/includes/blocks/i-lastseen.php on line 35


    Thanks in advane...

    --
    -James


  • Posted: 30.11.2005, 08:03
     
    Bad_Dude
    rank:
    Helper Helper
    registered:
     September 2005
    Status:
    offline
    last visit:
    03.07.08
    Posts:
    463
    Help guys! :(

    --
    -James


  • Posted: 30.11.2005, 12:52
     
    jmvedrine
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    633
    Your version is certainly corrupted because a line like:

    Code

    'text_type'       => '    'text_type_long'    => 'i-Block[Last Seen]',

    doesn't make sense !!
    should be something like

    Code

    'text_type'       => 'i-lastseen',
        'text_type_long'    => 'i-Block[Last Seen]',

    Maybe there are other problems so I suggest getting a fresh file.

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • Posted: 01.12.2005, 06:08
     
    Bad_Dude
    rank:
    Helper Helper
    registered:
     September 2005
    Status:
    offline
    last visit:
    03.07.08
    Posts:
    463
    Hmmm, it didn't work. They don't have any newer version at all. One more thing, I visited your site, it was nice but felt bad for those fishes in that tank because the tank is extremely dirty. Clean it up please before those poor creatures die... ;)

    --
    -James


  • Posted: 03.12.2005, 08:21
     
    IBCOHO
    rank:
    Freshman Freshman
    registered:
     January 2004
    Status:
    offline
    last visit:
    08.03.06
    Posts:
    40
    I don't understand that here is a block that has been discussed so many times that no one has done anything to update it.

    COHO
  • Posted: 03.12.2005, 16:46
     
    manarak
    rank:
    Helper Helper
    registered:
     December 1969
    Status:
    offline
    last visit:
    18.07.08
    Posts:
    393
    Here is the code I have - it is old (end of 2002):



    Code

    <?php
    /********************************************************/
    /* i-Block [Last Seen v1.0]                             */
    /* Written by: MagicX                                   */
    /* http://www.portalzine.de                             */
    /*                                                      */
    /********************************************************/

    $blocks_modules['i-lastseen'] = array(
        'func_display' => 'blocks_lastseen_block',
         'func_add' => 'blocks_lastseen_add',
        'func_update' => 'blocks_lastseen_update',
        'func_edit' => 'blocks_lastseen_edit',
        'text_type' => 'iLastSeen',
        'text_type_long' => 'i-Block[Last Seen 1.0]',
        'allow_multiple' => false,
        'form_content' => false,
        'form_refresh' => false,
    //  'support_xhtml' => true,
        'show_preview' => true
    );

    pnSecAddSchema('iBlock_Last_Seen::', 'Block title::');

    function blocks_lastseen_block($row)
    {
      global $prefix;
       list($dbconn) = pnDBGetConn();
       if (pnUserLoggedIn()) $username=pnUserGetVar('uname');
       $ip = getenv("REMOTE_ADDR");
       if (!isset($username)){
        $username=$ip;
        $tag = 1;
        }
       $sql = "SELECT * FROM $prefix"._lastseen." WHERE username = \"$username\"";
       $result=$dbconn->Execute($sql);
       if ($dbconn->ErrorNo() != 0) {
          die("ERROR: (checking current list" . $dbconn->ErrorMsg());
       }
       if (!$result->EOF) {
          $sql= "UPDATE $prefix"._lastseen." SET date = ".time()." WHERE username=\"$username\"";
          $result=$dbconn->Execute($sql);
          if ($dbconn->ErrorNo() != 0) {
             die("ERROR: (updating existing user" . $dbconn->ErrorMsg());
          }
       } else {
           $sql = "INSERT INTO $prefix"._lastseen." VALUES (\"\", \"$username\", ".time().", \"".$ip."\", \"".$tag."\")";
           $result=$dbconn->Execute($sql);
           if ($dbconn->ErrorNo() != 0) {
              die("ERROR: (adding new user" . $dbconn->ErrorMsg());
           }
        }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
        if (!pnSecAuthAction(0, 'PastVisitors::', "$row[title]::", ACCESS_READ)) {
            return;
        }
         $url = explode('|', $row['url']);
        if (!$url[0])
        {
            $url[0] = 1;
        }
        if (!$url[1])
        {
            $url[1] = 10;
        }
        if ($url[0] == 1)
        {
        $settag = "";
        }
        else
        {
        $settag = "where tag =\"\"";
        }
        $row[content] = "";
        $sql = "SELECT username, date, ip FROM $prefix"._lastseen." $settag ORDER BY date DESC LIMIT $url[1]";
        $result=$dbconn->Execute($sql);
        if ($dbconn->ErrorNo() != 0) {
           die("ERROR: (getting user list" . $dbconn->ErrorMsg());
        }
        $content="";
        while (!$result->EOF) {
               list($uname, $date, $ip) = $result->fields;
               if ($uname == $ip) {
              if (pnSecAuthAction(0, 'iBlock_Last_Seen::', "$row[title]::", ACCESS_ADMIN)) {
                 $uname="<b>$uname</b>";
              }
                else {
                 $uname="<b>Anonymous</b>";
              }
           } else {
           $unamex = $uname;
            if(strlen($unamex) > 15) { // Limit title length to avoid wrap
                       $unamex = strip_tags($unamex, '<a><i><b><ul><li>');
                       $unamex = substr($unamex,0,15);
                       $unamex .= "...";
                 }
               $uname="<a href=\"user.php?op=userinfo&uname=$uname\"><b>$unamex</b></a>";
           }
           $date = GetUserTime($date);
           $system_offset=pnConfigGetVar('timezone_offset');
           $user_offset=pnUserGetVar('timezone_offset');
           $adjusteddate=mktime((date("H",$date)), date("i",$date), date("s",$date), date("m",$date), date("d",$date), date("Y",$date));
           $lastdate=date("G:i:s - d.m.Y",$date);
           $content .= "<img src=\"images/iBlock/Last_Seen/arrow.gif\"> $uname<br><font size=1>$lastdate</font><br>";
           $result->MoveNext();
        }
       $row['content'] = $content;
       return themesideblock($row);

    }
    function blocks_lastseen_add($row)
    {
        $row['url'] = '1|10';
        return $row;
    }
    function blocks_lastseen_update($vars)
    {
        $vars['url'] = "$vars[guest]|$vars[amount]";
        return $vars;
    }
    function blocks_lastseen_edit($row)
    {
               $url = explode('|', $row['url']);
            $guest = $url[0];
            $amount = $url[1];

        $output = '<tr><td valign=top class=pn-normal>Display Guest:</td><td>'
            ."<input type=\"text\" name=\"guest\" size=\"30\" maxlength=\"255\" value=\"$guest\" class=\"pn-normal\">"
            ."(1-yes | 2-no)</td></tr>\n";
    $output .= "<tr><td valign=\"top\" class=\"pn-normal\">Display</td><td>"
    ."<input type=\"text\" name=\"amount\" size=\"30\" maxlength=\"255\" value=\"$amount\" class=\"pn-normal\">"
    ."</td></tr>\n";
    return $output;
    }
    ?>
  • Posted: 03.12.2005, 21:51
     
    edfel
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    02.09.07
    Posts:
    831

    IBCOHO

    I don't understand that here is a block that has been discussed so many times that no one has done anything to update it.

    COHO


    Unfortunately I guess there are some PostNukers that fix and enhance modules and blocks BUT don't share 'em with the rest of the community.

    You are probably right, this block could have been updated by someone. PostNuke community will develop much more IF we share and support each other. Thats is the foundation of Open Source.

    Thanks, there are many that contribute and support PostNuke, but there are others.... that don't.

    Later

    Edfel
  • Posted: 03.12.2005, 22:40
     
    jmvedrine
    rank:
    Professional Professional
    registered:
     January 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    633
    I do have fixed that module and it works well icon_lol
    Problem with the version posted by manarak is that you will have to purge the table from all the gests from time to time.
    My version does it automatically when a certain amount of guests is reached.
    And I always share all my work with the community (proof is the numerous fixed modules that I released) but on that particular subject I was hitten by the remark about my fishes and that prevented me to post the result of my work :(
    Fishes don't die from too much algea on the front glass !!

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • Posted: 03.12.2005, 23:01
     
    edfel
    rank:
    Professional Professional
    registered:
     December 1969
    Status:
    offline
    last visit:
    02.09.07
    Posts:
    831
    Hi:

    Jmvedrine, yes I and many of us are aware (and appreciate) of your contribution to the community; Books, AmaZone, eCards and other modules I can't remember now. But, there are others IMO that fix and enhance things but don't share.

    BTW, I also think their participation at the pnForum is also minimal. That explain why PostNuke have a so large installed base and sometimes when we seek support for a module, response is so low.

    Later

    :)
  • Posted: 04.12.2005, 01:32
     
    IBCOHO
    rank:
    Freshman Freshman
    registered:
     January 2004
    Status:
    offline
    last visit:
    08.03.06
    Posts:
    40

    jmvedrine

    I do have fixed that module and it works well icon_lol
    Problem with the version posted by manarak is that you will have to purge the table from all the gests from time to time.
    My version does it automatically when a certain amount of guests is reached.
    And I always share all my work with the community (proof is the numerous fixed modules that I released) but on that particular subject I was hitten by the remark about my fishes and that prevented me to post the result of my work :(
    Fishes don't die from too much algea on the front glass !!


    Where can we find your Last_seen program?

    COHO
  • Posted: 04.12.2005, 01:34
     
    IBCOHO
    rank:
    Freshman Freshman
    registered:
     January 2004
    Status:
    offline
    last visit:
    08.03.06
    Posts:
    40

    edfel

    Unfortunately I guess there are some PostNukers that fix and enhance modules and blocks BUT don't share 'em with the rest of the community.

    You are probably right, this block could have been updated by someone. PostNuke community will develop much more IF we share and support each other. Thats is the foundation of Open Source.

    Thanks, there are many that contribute and support PostNuke, but there are others.... that don't.

    Later

    Edfel


    Is that why the PHPNuke CMS has so many modules and Blocks? It appears they have tons of addons versus PostNuke. I posted about this in another thread the other day in my search for some addons.

    COHO
  • Posted: 04.12.2005, 02:59
     
    cannibus
    rank:
    Helper Helper
    registered:
     November 2004
    Status:
    offline
    last visit:
    20.09.08
    Posts:
    401
    modules and addons, are only created, for the most part, if someone has a need for it.
  • Posted: 04.12.2005, 04:06
     
    IBCOHO
    rank:
    Freshman Freshman
    registered:
     January 2004
    Status:
    offline
    last visit:
    08.03.06
    Posts:
    40

    cannibus

    modules and addons, are only created, for the most part, if someone has a need for it.


    Understood. I guess I am curious that there are quite a few people asking about the Last_seen block and the fact that PHPNuke has, or appears to have, much more than PostNuke, then why is PostNuke not up to speed with PHPnuke?

    I have been using PostNuke for over 3years and I search once and awhile for new blocks relevant to gaming and then give up. I just happened to browse the CSS top list for gaming sites the other day and I was just blown away how awesome the PHPNuke site are compared to PN. I wish it was the other way around.

    COHO
  • Posted: 08.12.2005, 00:34
     
    Bad_Dude
    rank:
    Helper Helper
    registered:
     September 2005
    Status:
    offline
    last visit:
    03.07.08
    Posts:
    463
    Hmmm that seems to work but here is another problem it is asking for an SQL code to create the table...

    Code

    ERROR: (checking current listTable 'tablename_lastseen' doesn't exist


    --
    -James