Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.94 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require('variables.php');
  4.     mysql_connect($host,$user,$pass) or die('Erorr');
  5.     mysql_select_db($db);
  6.     if (isset($_GET['id']) && !empty($_GET['id'])) {
  7.         $id = $_GET['id'];
  8.         $query = 'SELECT * FROM approved WHERE id=\''.$id.'\'';
  9.     }
  10.     elseif (isset($_GET['res'])) {
  11.         $res = $_GET['res'];
  12.         $query = "SELECT * FROM approved WHERE id>'".$res."'";
  13.     }
  14.     elseif (isset($_GET['option'])) {
  15.         if ($_GET['option'] == "random") {
  16.         $query  = "SELECT * FROM approved ORDER BY rand() limit ".$perpage;
  17.     }
  18.         if ($_GET['option'] == "top") {
  19.             $perpage = 100;
  20.             $query  = "SELECT * FROM approved ORDER BY total DESC limit ".$perpage;
  21.         }
  22.     }
  23.     else {
  24.         $query = 'SELECT * FROM approved';
  25.     }
  26.     $result = mysql_query($query) or die(mysql_error());
  27. ?>
  28. <html>
  29.     <head>
  30.         <title>QDB</title>
  31.         <link rel="stylesheet" type="text/css" href="default.css" />
  32.         <link rel="stylesheet" type="text/css" href="overlay.css" />
  33.     <script type="text/javascript">
  34. function vote(id,op)
  35. {
  36.     if (window.XMLHttpRequest) {
  37.         xmlhttp=new XMLHttpRequest();
  38.     }
  39.     xmlhttp.onreadystatechange=function()
  40.         {
  41.         if (xmlhttp.readState==4 && xmlhttp.status==200) {
  42.            
  43.         }
  44.     }
  45.     <?php
  46.         if (isset($_SESSION['logged'])) {
  47.             echo 'xmlhttp.open("GET","vote.php?id="+id+"&option="+op,true);
  48.             xmlhttp.send();
  49.             document.getElementById("vote"+id).innerHTML="Thanks for the vote";';
  50.         }
  51.         else {
  52.             echo 'document.getElementById("vote"+id).innerHTML="You need to be logged in to vote. <a href=\"javascript:overlay();\">Login here</a>";';
  53.         }
  54.     ?>
  55. };
  56.  
  57. function overlay() {
  58.     el = document.getElementById("overlay");
  59.     el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
  60.     el = document.getElementById("overlay1");
  61.     el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
  62. }
  63. </script>
  64.     </head>
  65.    
  66.     <body>
  67.  
  68.     <?php include('header.php'); ?>
  69.    
  70.  
  71.     <div id="main">
  72.     <div id="content">
  73.         <div id="overlay" onclick="overlay()">
  74.         </div>
  75.         <div id="overlay1">
  76.             <div id="close"><a href="javascript:overlay();"><img src="close.png" /></a></div>
  77.             <h1>You need an account to do that.</h1>
  78.             <div id="box">
  79.                
  80.                 <div id="left">
  81.                 <h2>Login if you have an account</h2>
  82.                 <form name="login" action="login.php?'.$_SERVER['QUERY_STRING'].'" method="post">
  83.         Username:<input type="text" name="username" /><br />
  84.         Password:<input type="password" name="password" /><br />
  85.         <button type="submit">Submit</button>
  86.         </form>
  87.                 </div>
  88.                
  89.                 <div id="right">
  90.                                     <h2>If you don't, register. It's simple</h2>
  91.                 <form name="login" action="" method="post">
  92.         Username:<input type="text" name="username" /><br />
  93.         Password:<input type="password" name="password" /><br />
  94.         <button type="submit">Submit</button>
  95.                 </div>
  96.             </div>
  97.         </div>
  98.         <?php
  99.         if (isset($id)) {
  100.             $row = mysql_fetch_array($result);
  101.             $calc = $row['up'] - $row['down'];
  102.             $text = '<div id="quote"><div id="wrap"><div id="id"><a href="index.php?id='.$row['id'].'">'.$row['id'].'</a> <a href="javascript:vote('.$row['id'].',\'u\');">'.$row['up'].'+</a> ('.$calc.') <a href="javascript:vote('.$row['id'].',\'d\');"> -'.$row['down'].'</a></div><div id="vote"><div id="vote'.$row['id'].'"></div></div></div><br />
  103.             '.$row['quote'].'<br /></div>';
  104.             echo $text;
  105.         }
  106.         else {
  107.                 $x = 1;
  108.                 while ($x <= $perpage && $x <= mysql_num_rows($result)) {
  109.                     $row = mysql_fetch_array( $result );
  110.                     $calc = $row['up'] - $row['down'];
  111.                     $text = '<div id="quote"><div id="wrap"><div id="id"><a href="index.php?id='.$row['id'].'">'.$row['id'].'</a> <a href="javascript:vote('.$row['id'].',\'u\');">'.$row['up'].'+</a> ('.$calc.') <a href="javascript:vote('.$row['id'].',\'d\');"> -'.$row['down'].'</a></div><div id="vote"><div id="vote'.$row['id'].'"></div></div></div><br />
  112.                     '.$row['quote'].'<br /></div>';
  113.                     echo $text;
  114.                     $x += 1;
  115.                 }
  116.         }
  117.        
  118.         ?>
  119.             </div>
  120.             <?php include('footer.txt'); ?>
  121.     </div>
  122.  
  123.  
  124.     </body>
  125. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement