Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require('variables.php');
- mysql_connect($host,$user,$pass) or die('Erorr');
- mysql_select_db($db);
- if (isset($_GET['id']) && !empty($_GET['id'])) {
- $id = $_GET['id'];
- $query = 'SELECT * FROM approved WHERE id=\''.$id.'\'';
- }
- elseif (isset($_GET['res'])) {
- $res = $_GET['res'];
- $query = "SELECT * FROM approved WHERE id>'".$res."'";
- }
- elseif (isset($_GET['option'])) {
- if ($_GET['option'] == "random") {
- $query = "SELECT * FROM approved ORDER BY rand() limit ".$perpage;
- }
- if ($_GET['option'] == "top") {
- $perpage = 100;
- $query = "SELECT * FROM approved ORDER BY total DESC limit ".$perpage;
- }
- }
- else {
- $query = 'SELECT * FROM approved';
- }
- $result = mysql_query($query) or die(mysql_error());
- ?>
- <html>
- <head>
- <title>QDB</title>
- <link rel="stylesheet" type="text/css" href="default.css" />
- <link rel="stylesheet" type="text/css" href="overlay.css" />
- <script type="text/javascript">
- function vote(id,op)
- {
- if (window.XMLHttpRequest) {
- xmlhttp=new XMLHttpRequest();
- }
- xmlhttp.onreadystatechange=function()
- {
- if (xmlhttp.readState==4 && xmlhttp.status==200) {
- }
- }
- <?php
- if (isset($_SESSION['logged'])) {
- echo 'xmlhttp.open("GET","vote.php?id="+id+"&option="+op,true);
- xmlhttp.send();
- document.getElementById("vote"+id).innerHTML="Thanks for the vote";';
- }
- else {
- echo 'document.getElementById("vote"+id).innerHTML="You need to be logged in to vote. <a href=\"javascript:overlay();\">Login here</a>";';
- }
- ?>
- };
- function overlay() {
- el = document.getElementById("overlay");
- el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
- el = document.getElementById("overlay1");
- el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
- }
- </script>
- </head>
- <body>
- <?php include('header.php'); ?>
- <div id="main">
- <div id="content">
- <div id="overlay" onclick="overlay()">
- </div>
- <div id="overlay1">
- <div id="close"><a href="javascript:overlay();"><img src="close.png" /></a></div>
- <h1>You need an account to do that.</h1>
- <div id="box">
- <div id="left">
- <h2>Login if you have an account</h2>
- <form name="login" action="login.php?'.$_SERVER['QUERY_STRING'].'" method="post">
- Username:<input type="text" name="username" /><br />
- Password:<input type="password" name="password" /><br />
- <button type="submit">Submit</button>
- </form>
- </div>
- <div id="right">
- <h2>If you don't, register. It's simple</h2>
- <form name="login" action="" method="post">
- Username:<input type="text" name="username" /><br />
- Password:<input type="password" name="password" /><br />
- <button type="submit">Submit</button>
- </div>
- </div>
- </div>
- <?php
- if (isset($id)) {
- $row = mysql_fetch_array($result);
- $calc = $row['up'] - $row['down'];
- $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 />
- '.$row['quote'].'<br /></div>';
- echo $text;
- }
- else {
- $x = 1;
- while ($x <= $perpage && $x <= mysql_num_rows($result)) {
- $row = mysql_fetch_array( $result );
- $calc = $row['up'] - $row['down'];
- $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 />
- '.$row['quote'].'<br /></div>';
- echo $text;
- $x += 1;
- }
- }
- ?>
- </div>
- <?php include('footer.txt'); ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement