Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'check.php';
- include 'dbconnect.php';
- include 'navbar.php';
- include 'functions.php';
- $query = $db->prepare("SELECT id,active,registered,lastlogin,name,handle,email,dob,bio,rating,rated,settings,power FROM accounts WHERE handle = :handle LIMIT 1");
- $query->execute(array('handle' => $_GET['user']));
- $user = $query->fetch();
- if ($user['active'] != 1)
- {
- exit("<center style='background: #FFFFFF; padding: 10px;'> <p style='font-size: 25px; color: black; font-weight: bold;'>This user has been banned, deleted or doesn't exist. <br> Please contact an admin for help if you believe that this is incorrect.</p></center>");
- }
- if (!empty($user['rated']))
- {
- $rated = explode(",",$user['rated']);
- }
- else
- {
- $rated = array(0=>3,);
- }
- $script = '';
- print_r($rated);
- foreach ($rated as $rater => $rating)
- {
- if ($rater == $_SESSION['id'])
- {
- $script = "<script> rate(" . $rating . "); </script>";
- }
- }
- if (isset($_POST['submit']))
- {
- if (count($rated)<$_SESSION['id'])
- {
- $difference = $_SESSION['id'] - count($rated);
- $rated = implode(',',$rated);
- while ($difference >= 0)
- {
- $rated .= "0,";
- $difference--;
- }
- $rated = explode(',',$rated);
- }
- $rated[$_SESSION['id']] = $_POST['rating'];
- $ratings = 0;
- $ratingsadded = 0;
- foreach ($rated as $user => $rating)
- {
- if ($rating != 0)
- {
- $query = $db->prepare("SELECT id, active FROM accounts WHERE id = :id");
- $query->execute(array('id' => $user));
- $useractive = $query->fetch();
- if ($useractive['active'] == 1 || $user == 0 || $user == 50)
- {
- $ratings++;
- $ratingsadded += $rating;
- }
- else
- {
- $rated[$user] = 0;
- }
- }
- }
- $ratingtotal = $ratingsadded / $ratings;
- $query = $db->prepare("UPDATE accounts SET rating = :rating, rated = :rated WHERE id = :id");
- $query->execute(array('rating' => $ratingtotal, 'rated' => implode(",",$rated), 'id' => $user['id']));
- header('Location: ?user=' . $_GET['user']);
- }
- ?>
- <html>
- <head>
- <title> Rater - <?php echo $_GET['user'] . ' 's' ?> Profile </title>
- <link rel='stylesheet' type='text/css' href='style.css'>
- <script type='text/js' src='/rater/script.js'></script>
- </head>
- <body>
- <div>
- <?php
- if ($user['rating'] >= 4)
- {
- $star = '/rater/content/filledstar.png';
- }
- elseif ($user['rating'] <= 2)
- {
- $star = '/rater/content/emptystar.png';
- }
- else
- {
- $star = '/rater/content/halffilledstar.png';
- }
- echo $user['name'] . "<br>";
- echo $user['handle'] . "<sup><img height='16px' src='" . $star . "'>" . $user['rating'] . "</sup><br>";
- ?>
- </div>
- <div id='rate'>
- <form method='POST'><img src='/rater/content/emptystar.png' id='button1' height='25px' onclick='rate(1);'></img><img src='/rater/content/emptystar.png' id='button2' height='25px' onclick='rate(2);'></img><img src='/rater/content/emptystar.png' id='button3' height='25px' onclick='rate(3);'></img><img src='/rater/content/emptystar.png' id='button4' height='25px' onclick='rate(4);'></img><img src='/rater/content/emptystar.png' id='button5' height='25px' onclick='rate(5);'></img><input id='rating' name='rating' type='hidden' value='2.5'><button name='submit' type='submit'>Submit</button></form>
- </div>
- <?php
- echo $user['bio'];
- ?>
- <script>
- function rate(num)
- {
- for (var x = 1; x <= num; x++)
- {
- document.getElementById('button'+x).src = '/rater/content/filledstar.png';
- }
- for (var x = 5; x > num; x--)
- {
- document.getElementById('button'+x).src = '/rater/content/emptystar.png';
- }
- document.getElementById('rating').value = num;
- }
- </script>
- <?php echo $script; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement