Likes and dislike in shout

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Likes and dislike in shout

    Help me how to insert like and dislike in shoutbox lavalair. Thanks in advance

    #2
    Here It Is

    like.php
    PHP Code:
    <?php
    include("config.php");
    include(
    "core.php");
    header("Content-type: text/vnd.wap.wml");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    echo 
    "<?xml version=\"1.0\"?>";
    echo 
    "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""" \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
    ?>
    <wml>
    <?php
    $bcon 
    connectdb();
    $sitename mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
    $sitename $sitename[0];

    if (!
    $bcon)
    {
        echo 
    "<card id=\"main\" title=\"(ERROR!)\">";
        echo 
    "<p align=\"center\">";
        echo 
    "<img src=\"../images/exit.gif\" alt=\"!\"/><br/>";
        echo 
    "<b>Error! Cannot Connect To Database...</b><br/><br/>";
        echo 
    "This error happens usually when backing up the database, please be patient...";
        echo 
    "</p>";
        echo 
    "</card>";
        echo 
    "</wml>";
        exit();
    }

    $brws explode("/",$HTTP_USER_AGENT);
    $ubr $brws[0];
    $uip getip();
    $action $_GET["action"];
    $sid $_GET["sid"];
    $page $_GET["page"];
    $who $_GET["who"];
    $uid getuid_sid($sid);
    cleardata();

    if((
    $action != "") && ($action!="view"))
    {
        
    $uid getuid_sid($sid);
        if((
    islogged($sid)==false)||($uid==0))
        {
            echo 
    "<card id=\"main\" title=\"$sitename\">";
          echo 
    "<p align=\"center\">";
          echo 
    "You are not logged in<br/>";
          echo 
    "Or Your session has been expired<br/><br/>";
          echo 
    "<a href=\"index.php\">Login</a>";
          echo 
    "</p>";
          echo 
    "</card>";
          echo 
    "</wml>";
          exit();
        } 
    }
    $res mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");

    if(
    $action=="like")
    {

    addvisitor();
    addonline(getuid_sid($sid),"Likers","");

    echo 
    "<card id=\"main\" title=\"Likers\">";
    echo 
    "<p align=\"center\">";

    $shid $_GET['shid'];

    if(
    $page=="" || $page<=0) {$page=1;}
    $count mysql_fetch_assoc(mysql_query("SELECT COUNT(*) page FROM ibwf_like WHERE shoutid='".$shid."'"));

    $num_items $count['page']; //changable
    $event_per_page20;
    $num_pages ceil($num_items/$event_per_page);
    if((
    $page>$num_pages)&&$page!=1) {$page$num_pages;}
    $limit_start = ($page-1)*$event_per_page;


    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter FROM ibwf_shouts WHERE id='".$shid."'"));
    $shnick getnick_uid($lshout[1]);
    $text parsepm($lshout[0],$sid);
    echo 
    '</p><p align="center">';
    echo 
    "<b>[<a href=\"index.php?action=viewuser&sid=$sid&who=$lshout[1]\">".$shnick."</a>]</b><br/>";
    echo 
    "$text<br/><br/>";

    echo 
    '</p><p align="left">';  


    $results mysql_query("SELECT * FROM ibwf_like WHERE shoutid='".$shid."' ORDER BY ltime ASC LIMIT $limit_start$event_per_page");
    while (
    $event mysql_fetch_assoc($results)){
    $user $event['uid'];
    $unick getnick_uid($user);

    echo 
    "<a href=\"index.php?action=viewuser&sid=$sid&who=$user\">$unick</a>";
    echo 
    "<small>» ".gmstrftime("%d %B,%Y - %H:%M:%S %p",$event['ltime'])."</small><br/>-----------<br/>";
      
    }

    }
    elseif(
    $action=="dislike")
    {
    addvisitor();
    addonline(getuid_sid($sid),"Dislikers","");


    echo 
    "<card id=\"main\" title=\"Dislikers\">";
    echo 
    "<p align=\"center\">";

    $shid $_GET['shid'];

    if(
    $page=="" || $page<=0) {$page=1;}
    $count mysql_fetch_assoc(mysql_query("SELECT COUNT(*) page FROM ibwf_dislike WHERE shoutid='".$shid."'"));

    $num_items $count['page']; //changable
    $event_per_page20;
    $num_pages ceil($num_items/$event_per_page);
    if((
    $page>$num_pages)&&$page!=1) {$page$num_pages;}
    $limit_start = ($page-1)*$event_per_page;


    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter FROM ibwf_shouts WHERE id='".$shid."'"));
    $shnick getnick_uid($lshout[1]);
    $text parsepm($lshout[0],$sid);
    echo 
    '</p><p align="center">';
    echo 
    "<b>[<a href=\"index.php?action=viewuser&sid=$sid&who=$lshout[1]\">".$shnick."</a>]</b><br/>";
    echo 
    "$text<br/><br/>";

    echo 
    '</p><p align="left">';  


    $results mysql_query("SELECT * FROM ibwf_dislike WHERE shoutid='".$shid."' ORDER BY ltime ASC LIMIT $limit_start$event_per_page");
    while (
    $event mysql_fetch_assoc($results)){
    $user $event['uid'];
    $unick getnick_uid($user);

    echo 
    "<a href=\"index.php?action=viewuser&sid=$sid&who=$user\">$unick</a>";
    echo 
    "<small>» ".gmstrftime("%d %B,%Y - %H:%M:%S %p",$event['ltime'])."</small><br/>-----------<br/>";

    }
    }

    echo 
    '</p><p align="center">';
    echo 
    mobads();
    echo 
    "<a href=\"index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"*\"/>";
    echo 
    "Home</a>";


    echo 
    "</p>";
    echo 
    "</card>";
    ?>
    </wml>
    shcomments.php
    PHP Code:
    <?php
    include("config.php");
    include(
    "core.php");
    header("Content-type: text/vnd.wap.wml");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    echo 
    "<?xml version=\"1.0\"?>";
    echo 
    "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""" \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
    ?>
    <wml>
    <?php
    $bcon 
    connectdb();
    $sitename mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
    $sitename $sitename[0];

    if (!
    $bcon)
    {
        echo 
    "<card id=\"main\" title=\"(ERROR!)\">";
        echo 
    "<p align=\"center\">";
        echo 
    "<img src=\"../images/exit.gif\" alt=\"!\"/><br/>";
        echo 
    "<b>Error! Cannot Connect To Database...</b><br/><br/>";
        echo 
    "This error happens usually when backing up the database, please be patient...";
        echo 
    "</p>";
        echo 
    "</card>";
        echo 
    "</wml>";
        exit();
    }

    $brws explode("/",$HTTP_USER_AGENT);
    $ubr $brws[0];
    $uip getip();
    $action $_GET["action"];
    $sid $_GET["sid"];
    $page $_GET["page"];
    $who $_GET["who"];
    $uid getuid_sid($sid);
    cleardata();

    if((
    $action != "") && ($action!="main"))
    {
        
    $uid getuid_sid($sid);
        if((
    islogged($sid)==false)||($uid==0))
        {
            echo 
    "<card id=\"main\" title=\"$sitename\">";
          echo 
    "<p align=\"center\">";
          echo 
    "You are not logged in<br/>";
          echo 
    "Or Your session has been expired<br/><br/>";
          echo 
    "<a href=\"index.php\">Login</a>";
          echo 
    "</p>";
          echo 
    "</card>";
          echo 
    "</wml>";
          exit();
        }
    }
    $res mysql_query("UPDATE ibwf_users SET browserm='".$ubr."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");

    if(
    $action=="main")
    {
      
    addvisitor();
      
    addonline(getuid_sid($sid),"Shout Comments","");

    echo 
    "<card id=\"main\" title=\"Shout Comments\">";
    echo 
    "<p align=\"left\">";

    //--------------------------> SHOUT COMMENTS BY W3B_JOCKY
    $shid $_GET['shid'];

    if(
    $page=="" || $page<=0) {$page=1;}
    $count mysql_fetch_assoc(mysql_query("SELECT COUNT(*) page FROM w3bjocky_shcomments WHERE shoutid='".$shid."'"));

    $num_items $count['page']; //changable
    $event_per_page10;
    $num_pages ceil($num_items/$event_per_page);
    if((
    $page>$num_pages)&&$page!=1) {$page$num_pages;}
    $limit_start = ($page-1)*$event_per_page;


    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter FROM ibwf_shouts WHERE id='".$shid."'"));
    $shnick getnick_uid($lshout[1]);
    $text parsepm($lshout[0],$sid);
    echo 
    '</p><p align="center">';
    echo 
    "<b>[<a href=\"index.php?action=viewuser&sid=$sid&who=$lshout[1]\">".$shnick."</a>]</b><br/>";
    echo 
    "$text<br/><br/>";

    echo 
    '</p><p align="left">';
    //---------------------> SHOUT COMMENT BY W3B_JOCKY

    $results mysql_query("SELECT * FROM w3bjocky_shcomments WHERE shoutid='".$shid."' ORDER BY shtime ASC LIMIT $limit_start$event_per_page");
    while (
    $event mysql_fetch_assoc($results)){
    $user $event['uid'];
    $unick getnick_uid($user);

    echo 
    "<a href=\"index.php?action=viewuser&sid=$sid&who=$user\">$unick</a>: ";
    echo 
    getbbcode($event[shcomments],$sid,1)."<br/>";
    echo 
    "<small>» ".gmstrftime("%d %B,%Y - %H:%M:%S %p",$event['shtime'])."</small><br/><br/>";
    }
    //---------------------> SHOUT COMMENT BY W3B_JOCKY
       
    echo "Comment:<input type=\"text\" name=\"shcomments\"/><br/>";
       echo 
    "<anchor>Add";
      echo 
    "<go href=\"shcomments.php?action=addcomm&sid=$sid&shid=$shid\" method=\"post\">";
      echo 
    "<postfield name=\"shcomments\" value=\"$(shcomments)\"/>";
      echo 
    "</go>";
      echo 
    "</anchor> I <anchor><refresh><setvar name=\"shcomments\" value=\"\"/></refresh>Clear</anchor><br/>";

    echo 
    "</p><p align=\"center\">";
    if(
    $page>1)
        {
          
    $ppage $page-1;
          echo 
    "<a href=\"shcomments.php?action=main&page=$ppage&sid=$sid&shid=$shid\">«PREV</a> ";
        }
        if(
    $page<$num_pages)
        {
          
    $npage $page+1;
          echo 
    "<a href=\"shcomments.php?action=main&page=$npage&sid=$sid&shid=$shid\">NEXT»</a>";
        }
        echo 
    "<br/>$page/$num_pages<br/>";
        if(
    $num_pages>2)
        {
        echo 
    getjumper2($action$sid"shcomments"$shid);
        }


        }
    else if(
    $action=="addcomm")
    {
      
    addvisitor();
      
    addonline(getuid_sid($sid),"Adding Comment","shcomments.php?action=$action");

    echo 
    "<card id=\"main\" title=\"Adding Comments\">";
    echo 
    "<p align=\"center\">";
    $shid $_GET['shid'];
    $shtext $_POST['shcomments'];
    $user getnick_uid($uid);
    $shtime time();
    $uid getuid_sid($sid);

    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter FROM ibwf_shouts WHERE id='".$shid."'"));
        
    $who $_POST["$lshout[1]"];

    if(
    trim($shtext)!="" && strlen($shtext) > "5"){
    mysql_query("INSERT INTO w3bjocky_shcomments SET shoutid='".$shid."', shcomments='".$shtext."', uid='".$uid."', shtime='".$shtime."'");
    echo 
    "<img src=\"../images/ok.gif\" alt=\"O\"/>Comment Added Successfully<br/>";

    //--------------------------> RECENT ACTIVITIES BY W3B_JOCKY
    $w3btime time();
    $user getnick_uid($uid);

    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter FROM ibwf_shouts WHERE id='".$shid."'"));

    $who parsepm($lshout[1],$sid);
    $whonick getnick_uid($who);
    //mysql_query("insert into w3bjocky_activities (event,time) values ('[user=".$uid."]".$user."[/user] liked  the shout of [user=".$who."]".$whonick."[/user]!','$w3btime')");
    //--------------------------> RECENT ACTIVITIES BY W3B_JOCKY

     //--------------------------> NOTIFICATIONS BY W3B_JOCKY
          //$note = "$user has commented on your shout!";
          //notify($note,$uid,$who);
          //--------------------------> NOTIFICATIONS BY W3B_JOCKY



    } else {
    echo 
    "<img src=\"../images/notok.gif\" alt=\"X\"/>Error Adding Comment<br/>";
    }

      
    $lshout mysql_fetch_array(mysql_query("SELECT shout, shouter, id  FROM ibwf_shouts ORDER BY shtime DESC LIMIT 1"));

      echo 
    " <a href=\"shcomments.php?action=main&sid=$sid&shid=$lshout[2]\">Comments</a>";




    }
    echo 
    "<br/><a href=\"index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"*\"/>";
    echo 
    "Home</a><br/><br/>";

    echo 
    "</p>";
    echo 
    "</card>";
    ?>
    </wml>

    Shoutbox Function in Core.php
    Code:
    /////////////////////////////////////////////function Shoutbox
    
    function getshoutbox($sid)
    {
    
      $lshout = mysql_fetch_array(mysql_query("SELECT shout, shouter, id  FROM ibwf_shouts ORDER BY shtime DESC LIMIT 1"));
     $shbox .= "<b>Shoutbox</b><br/>";
     $shnick = getnick_uid($lshout[1]);
      $avlink = getavatar($lshout[1]);
    if($avlink=="")
    {
    $shbox .= "<img src=\"../images/nopic.jpg\" height=\"25\" width=\"25\" alt=\"x\"/> ";
    }else{
    $shbox .= "<img src=\"$avlink\" height=\"25\" width=\"25\" alt=\"0\"/> ";
    }
    
    $shbox .= "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp;who=$lshout[1]\">".$shnick."</a><br/>";
    $text = parsepm($lshout[0], $sid);
    $shbox .= $text;
    $shbox .= "<br/>~~~~~<br/>";
    
    $shcomm = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) comm FROM w3bjocky_shcomments WHERE shoutid='".$lshout[2]."'"));
    $shout = $shcomm['comm'];
    $like = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_like WHERE shoutid='".$lshout[2]."'"));
    //$dislike = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_dislike WHERE shoutid='".$lshout[2]."'"));
    
    $shbox .= "<a href=\"shcomments.php?action=main&amp;sid=$sid&amp;shid=$lshout[2]\">Com ($shout)</a> - ";
    $shbox .= "<a href=\"like.php?action=like&amp;sid=$sid&amp;shid=$lshout[2]\">L:$like[0]</a>/";
    $shbox .= "<a href=\"like.php?action=dislike&amp;sid=$sid&amp;shid=$lshout[2]\">D:$dislike[0]</a>";
    $shbox .= "<br/>~~~~~<br/>";
    
    $shbox .= "<a href=\"genproc.php?action=like&amp;sid=$sid&amp;shid=$lshout[2]\">Like</a> | ";
    $shbox .= "<a href=\"genproc.php?action=dislike&amp;sid=$sid&amp;shid=$lshout[2]\">Dislike</a> | ";
    $shbox .= "<a href=\"lists.php?action=shouts&amp;sid=$sid\">History</a>";
    $shbox .= "";
    
      if (ismod(getuid_sid($sid)))
      {
        $shbox .= ",<a href=\"modproc.php?action=delsh&amp;sid=$sid&amp;shid=$lshout[2]\">delete</a>";
      }
      $shbox .= "<br/>";
    
      return $shbox;
    }

    call shoutbox in index.php

    Code:
    echo getshoutbox($sid);
    echo "<input name=\"shtxt\" maxlength=\"250\"/><br/>";
    echo "<anchor>Add Shout";
    echo "<go href=\"genproc.php?action=shout&amp;sid=$sid\" method=\"post\">
    <postfield name=\"shtxt\" value=\"$(shtxt)\"/>";
    echo "</go></anchor>";
    echo " | <anchor><refresh><setvar name=\"shtxt\" value=\"\"/></refresh>Clear Text</anchor>";
    SQL Data >
    Code:
    --
    -- Table structure for table `ibwf_like`
    --
    
    CREATE TABLE IF NOT EXISTS `ibwf_like` (
      `id` int(100) NOT NULL AUTO_INCREMENT,
      `shoutid` int(100) NOT NULL DEFAULT '0',
      `uid` int(100) NOT NULL DEFAULT '0',
      `lrate` char(1) NOT NULL,
      `ltime` varchar(20) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    --
    -- Dumping data for table `ibwf_like`
    --
    
    
    -- --------------------------------------------------------
    
    --
    -- Table structure for table `ibwf_dislike`
    --
    
    CREATE TABLE IF NOT EXISTS `ibwf_dislike` (
      `id` int(100) NOT NULL AUTO_INCREMENT,
      `shoutid` int(100) NOT NULL DEFAULT '0',
      `uid` int(100) NOT NULL DEFAULT '0',
      `ltime` varchar(20) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    --
    -- Dumping data for table `ibwf_dislike`
    --
    
    
    -- --------------------------------------------------------
    
    
    --
    -- Table structure for table `w3bjocky_shcomments`
    --
    
    CREATE TABLE IF NOT EXISTS `w3bjocky_shcomments` (
      `id` int(100) NOT NULL AUTO_INCREMENT,
      `shoutid` int(100) NOT NULL DEFAULT '0',
      `uid` int(100) NOT NULL DEFAULT '0',
      `shcomments` varchar(255) NOT NULL DEFAULT '',
      `shtime` varchar(20) NOT NULL DEFAULT '',
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    
    --
    -- Dumping data for table `w3bjocky_shcomments`
    --
    
    
    -- --------------------------------------------------------
    All of those pages Based on WML !
    < Collected From a Bengali Lava Forum ! >

    Comment


      #3
      thanks where is the code to genproc.php?

      Comment

      Working...
      X