like/dislike profile in XHTML /english

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

    like/dislike profile in XHTML /english

    this is my XHTML like/dislike profile script (in english) for lava/wapdesire
    old
    versions..it's started from a wml script by srecnica ,that script had some bugs that i fixed when i done it in xhtml. i use it on my italian wapdesire and works right. i hope i didn't make errors when i coded in english..

    you can like/dislike profile every 7 days, with lists of users like/dislike in profile

    first thing create this on your SQL
    Code:
    CREATE TABLE IF NOT EXISTS `ibwf_rate` (
    `id` int(100) NOT NULL AUTO_INCREMENT,
    `uid` int(100) NOT NULL DEFAULT '0',
    `action` varchar(100) NOT NULL DEFAULT '',
    `target` int(100) NOT NULL DEFAULT '0',
    `actime` int(100) NOT NULL DEFAULT '0',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    now on your index.php put this in
    action VIEWUSER

    Code:
    ///////////
    
    
    
    echo "<b>LIKE/dislike</b><br/>";
    
    
    
    $likes = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM ibwf_rate WHERE target='".$who."' AND action='likeprof'")); //changable
    $dislikes = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM ibwf_rate WHERE target='".$who."' AND action='dislikeprof'")); //changable
    
    echo "<a href=\"giudica.php?action=like&amp;who=$who&amp;sid=$sid\"><b>[$likes[0]]</b></a>*** <a href=\"giudica.php?action=likeprof&amp;who=$who&amp;sid=$sid\"><b>like</b><img src=\"../images/like.gif\" alt=\"\"/></a>";
    
    echo "<a href=\"giudica.php?action=dislikeprof&amp;who=$who&amp;sid=$sid\">dislike<img src=\"../images/dislike.gif\" alt=\"\"/></a>***<a href=\"giudica.php?action=dislike&amp;who=$who&amp;sid=$sid\"><b>[$dislikes[0]]</b></a><br/>"; 
    
    
    
    ////////////////////////////////
    well, now create this php page and name it giudica.php
    then
    put it on your web folder (i did it a new page 'cause index.php usually so long on lava/wapdesire,
    doing some changes you can put it on index.php if you want)


    Code:
    <?php
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    //header('Content-type: application/vnd.wap.xhtml+xml'); 
    echo "<?xml version=\"1.0\"?>";
    echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta forua="true" http-equiv="Cache-Control" content="max-age=0"/>
    <meta forua="true" http-equiv="Cache-Control" content="must-revalidate"/>
    </head>
    <?php
    include("config.php");
    include("core.php");
    
    
    
    
    $bcon = connectdb();
    if (!$bcon)
    {
        echo "<head>";
        echo "<title>Error!!!</title>";
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/black_medium.css\">";
        echo "</head>";
        echo "<body>";
        echo "<p align=\"center\">";
        echo "<img src=\"../images/notok.gif\" alt=\"\"/><br/>";
        echo "<b><strong>database error</strong></b><br/><br/>";
        
    
        echo "</p>";
        echo "</body>";
        echo "</html>";
        exit();
    }
    $brws = explode("/",$HTTP_USER_AGENT);
    $ubr = $brws[0];
    $uip = getip();
    $action = $_GET["action"];
    $sid = $_GET["sid"];
    $page = $_GET["page"];
    $who = $_GET["who"];
    $sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
    $sitename = $sitename[0];
    $uid = getuid_sid($sid);
    $theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));
    cleardata();
    
    if(($action != "") && ($action!="terms"))
    {
        $uid = getuid_sid($sid);
        if((islogged($sid)==false)||($uid==0))
        {
          echo "<head>";
          echo "<title>your site</title>";
          echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/black_medium.css\">";
          echo "</head>";
          echo "<body>";
          echo "<p align=\"center\">";
          
          echo "<a href=\"index.php\">Login</a>";
    
          echo "</p>";
          echo "</body>";
          echo "</html>";
          exit();
        }
    }
    
    
    $res = mysql_query("UPDATE ibwf_users SET browserm='".$brws4."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");
    
    ////////////////////////////////////////MAIN PAGE
    
    if($action=="like")
    
    
    
    {
        
         addonline(getuid_sid($sid),"like profile","");
    $who = $_GET["who"];
        $wnick = getnick_uid($who);
    
      echo "<head>";
        echo "<title>your site</title>";
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo "</head>";
    echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
        echo "<center>";
    
    echo "<br/><img src=\"../images/ILIKE.gif\" alt=\"\"/> <b>$wnick</b><br/>";
    
    
        
    
    
      
    
        
        
        echo "</center><center>";
    
        //////ALL LISTS SCRIPT <<
        
        if($page=="" || $page<=0)$page=1;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM ibwf_rate WHERE target='".$who."' AND action='likeprof'")); //changable
        $num_items = $noi[0];
        $items_per_page= 10;
        $num_pages = ceil($num_items/$items_per_page);
        if(($page>$num_pages)&&$page!=1)$page= $num_pages;
        $limit_start = ($page-1)*$items_per_page;
    
        //changable sql
    
            $sql = "
            SELECT a.uid, b.name
            FROM ibwf_rate a INNER JOIN ibwf_users b ON a.uid = b.id
            WHERE a.target='".$who."' AND a.action='likeprof'
            ORDER BY a.actime DESC LIMIT $limit_start, $items_per_page
            ;";
    
    
      
        $items = mysql_query($sql);
        echo mysql_error();
        if(mysql_num_rows($items)>0)
        {
        while ($item = mysql_fetch_array($items))
        {
    
    
          $lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[0]&amp;sid=$sid\">$item[1]</a>";
          echo "$lnk<br/>";
        }
        }
        
        
        if($page>1)
        {
          $ppage = $page-1;
          echo "<a href=\"giudica.php?action=$action&amp;page=$ppage&amp;sid=$sid&amp;who=$who\">up</a> ";
        }
        if($page<$num_pages)
        {
          $npage = $page+1;
          echo "<a href=\"giudica.php?action=$action&amp;page=$npage&amp;sid=$sid&amp;who=$who\">down</a>";
        }
        if($num_pages>1)
        {
        echo "<br/>$page/$num_pages<br/>";
        }
        if($num_pages>2)
        {
          
        
          $rets = "<form action=\"giudica.php\" method=\"get\">";
        $rets .= "<input name=\"page\" style=\"-wap-input-format: '*N'\" size=\"2\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
        $rets .= "<input type=\"Submit\" value=\"jump\" Name=\"Submit\"/></form>";
    
            echo $rets;
        }
        
        
      ////// UNTILL HERE >>
        
    
         
        echo "back to<a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\">$wnick</a><br/><br/>";
    
            echo "<b></b><a accesskey=\"0\" href=\"index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "<br/>";
    
    
            echo "</center></body>";
    
    
            
    }
    /////////////////
    
    
    else if($action=="dislike")
    {
        
         addonline(getuid_sid($sid),"dislike profile","");
      
        $who = $_GET["who"];
        $wnick = getnick_uid($who);
    
    echo "<head>";
        echo "<title>your site</title>";
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo "</head>";
    echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
        echo "<center>";
    
    
    echo "<br/><img src=\"../images/dislike.gif\" alt=\"\"/> <b>$wnick</b><br/>";
    
    
    
    
    
    
    
    
    
       
       
       
        //////ALL LISTS SCRIPT <<
        
        if($page=="" || $page<=0)$page=1;
        $noi = mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM ibwf_rate WHERE target='".$who."' AND action='dislikeprof'")); //changable
        $num_items = $noi[0];
        $items_per_page= 10;
        $num_pages = ceil($num_items/$items_per_page);
        if(($page>$num_pages)&&$page!=1)$page= $num_pages;
        $limit_start = ($page-1)*$items_per_page;
    
        //changable sql
    
            $sql = "
            SELECT a.uid, b.name
            FROM ibwf_rate a INNER JOIN ibwf_users b ON a.uid = b.id
            WHERE a.target='".$who."' AND a.action='dislikeprof'
            ORDER BY a.actime DESC LIMIT $limit_start, $items_per_page
            ;";
    
    
        
        $items = mysql_query($sql);
        echo mysql_error();
        if(mysql_num_rows($items)>0)
        {
        while ($item = mysql_fetch_array($items))
        {
    
    
          $lnk = "<a href=\"index.php?action=viewuser&amp;who=$item[0]&amp;sid=$sid\">$item[1]</a>";
          echo "$lnk<br/>";
        }
        }
       
        if($page>1)
        {
          $ppage = $page-1;
          echo "<a href=\"giudica.php?action=$action&amp;page=$ppage&amp;sid=$sid&amp;who=$who\">up</a> ";
        }
        if($page<$num_pages)
        {
          $npage = $page+1;
          echo "<a href=\"giudica.php?action=$action&amp;page=$npage&amp;sid=$sid&amp;who=$who\">down</a>";
        }
        if($num_pages>1)
        {
        echo "<br/>$page/$num_pages<br/>";
        }
        if($num_pages>2)
        {
          
       
          $rets = "<form action=\"giudica.php\" method=\"get\">";
        $rets .= "<input name=\"page\" style=\"-wap-input-format: '*N'\" size=\"2\"/>";
        $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\"/>";
        $rets .= "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
        $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\"/>";
        $rets .= "<input type=\"Submit\" value=\"jump\" Name=\"Submit\"/></form>";
    
            echo $rets;
        }
        
       
      ////// UNTILL HERE >>
        
         
          echo "back to<a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\">$wnick</a><br/><br/>";
    
         echo "<b></b><a accesskey=\"0\" href=\"index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "<br/>";
    
    
            echo "</center></body>";
    
    
    
    
    }
    
    //////////////
    
    else if($action=="dislikeprof")
    {
    
    
        addonline(getuid_sid($sid),"dislike profile","");
      
    $who = $_GET["who"];
        $wnick = getnick_uid($who);
    
    echo "<head>";
        echo "<title>your site</title>";
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo "</head>";
    echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
    
    echo "<center>";
    echo "<br/><img src=\"../images/dislike.gif\" alt=\"\"/><br/>";
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     echo "<br/>";
    
    
    $dislikeswho = getuid_sid($sid);
     $dislikeswho = $_REQUEST["who"];
     $dislikenick = getnick_sid($sid);
    $whonick=$_POST["whonick"];
            $who = $_GET["who"];
            $whonick = getnick_uid($who);
    $byuid = getuid_sid($sid);
     $tm = time();
    
    
    
    
    $actime = mysql_fetch_array(mysql_query("SELECT actime FROM ibwf_rate WHERE uid='".$uid."' AND target='".$who."' ORDER BY actime DESC LIMIT 1"));
            $timeout = $actime[0] + (7*24*60*60);
            if(time()<$timeout)
            {
                echo "<img src=\"../images/notok.gif\" alt=\"\"/>ERROR ,only 7 days...<br/>";
                echo "back to <a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\"> <b>$wnick</b></a><br/><br/>";
    
    
    
    
    
    
    }else{
                if($uid==$who)
                {
                    echo "<img src=\"../images/notok.gif\" alt=\"\"/>error<br/>";
        echo "back to<a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\"> <b>$wnick</b></a><br/><br/>";
    
    
    
                }else{
    
    
    $res = mysql_query("INSERT INTO ibwf_rate SET uid='".$uid."', action='".$action."', target='".$who."', actime='".time()."'");
    
    
    
    if($res)
      {
    
    
    
    
    
    
        echo "<img src=\"../images/dislike.gif\" alt=\"\"/>";
       echo "$whonick disliked<br/>";
    
    
    
    
    
    
    
    
    
      }
      }
      }
    
    
          echo "<b></b><a accesskey=\"0\" href=\"index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "<br/>";
    
    
            echo "</center></body>";
    
    
    }
    ///////////////////////////////////////////
    else if($action=="likeprof")
    {
    
    
    
      addonline(getuid_sid($sid),"like profile","");
      $who = $_GET["who"];
        $wnick = getnick_uid($who);
    
    echo "<head>";
        echo "<title>your site</title>";
        echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
        echo "</head>";
    echo "<body bgcolor=\"#99CCFF\" link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
    
    echo "<center>";
    echo "<br/><img src=\"../images/like.gif\" alt=\"\"/><br/>";
    
    
    
    
    
    
    
    
    
    
    
    
    
    
      echo "<br/>";
     $likeswho = getuid_sid($sid);
     $likeswho = $_REQUEST["who"];
     $likenick = getnick_sid($sid);
    $whonick=$_POST["whonick"];
            $who = $_GET["who"];
            $whonick = getnick_uid($who);
    $byuid = getuid_sid($sid);
     $tm = time();
    
    $actime = mysql_fetch_array(mysql_query("SELECT actime FROM ibwf_rate WHERE uid='".$uid."' AND target='".$who."' ORDER BY actime DESC LIMIT 1"));
            $timeout = $actime[0] + (7*24*60*60);
            if(time()<$timeout)
            {
                echo "<img src=\"../images/notok.gif\" alt=\"\"/>ERROR, only 7 days..<br/>";
    
        echo "back to<a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\"> <b>$wnick</b></a><br/><br/>";
    
            }else{
                if($uid==$who)
                {
                    echo "<img src=\"../smilies/ihih.gif\" alt=\"\"/>error<br/>";
    
        echo "back to<a href=\"index.php?action=viewuser&amp;who=$who&amp;sid=$sid\"> <b>$wnick</b></a><br/><br/>";
    
                }else{
    
    
    $res = mysql_query("INSERT INTO ibwf_rate SET uid='".$uid."', action='".$action."', target='".$who."', actime='".time()."'");
    
    if($res)
      {
    
    
    
    
    
    
        echo "<img src=\"../images/like.gif\" alt=\"\"/>";
       echo "$whonick liked<br/>";
    
    
    
    
    
    
    
    
      }
    }
    }
    
         echo "<b></b><a accesskey=\"0\" href=\"index.php?action=main&amp;sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
    echo "<br/>";
    
            echo "</center></body>";
    
    
    
    }
    
    
    
    
    
    ?>
    </html>
    now put 2 gifs on images folder for like and dislike

    and if you want ,you can change time in like/dislike
    on this (7*24*60*60)
    exemple:
    (15*24*60*60)
    Last edited by honkytonkman; 11.04.11, 12:56.
    sigpicthe italian/international COMMUNITY of friendship
    http://people2000.netne.net
    WAP/WEB
    peoplemailbox@katamail.com
Working...
X