Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('../includes/config.php');
- require('../structure/base.php');
- require('../structure/forum.php');
- require('../structure/forum.index.php');
- require('../structure/forum.thread.php');
- require('../structure/forum.post.php');
- require('../structure/database.php');
- require('../structure/user.php');
- $database = new database($db_host, $db_name, $db_user, $db_password);
- $base = new base($database);
- $user = new user($database);
- $forum = new forum($database);
- $forum_index = new forum_index($database);
- $thread = new thread($database);
- $post = new post($database);
- $user->updateLastActive();
- //get config
- $config = $base->loadConfig();
- //set some variables that are used a lot throughout the page
- if (!empty($_GET['username'])) {
- $profile_name = htmlspecialchars($_GET["username"]);
- }
- else{
- $profile_name = $user->getUsername($_COOKIE['user'], 2);
- }
- $username = $user->getUsername($_COOKIE['user'], 2);
- $rank = $user->getRank($username);
- $f = $_GET['forum'];
- $i = $_GET['id'];
- //assign data to details[] array
- $details['lock'] = $detail_query[0]['lock'];
- $details['sticky'] = $detail_query[0]['sticky'];
- $details['title'] = stripslashes(htmlentities($detail_query[0]['title']));
- $details['username'] = $detail_query[0]['username'];
- $details['status'] = $detail_query[0]['status'];
- $details['content'] = $detail_query[0]['content'];
- $details['date'] = $detail_query[0]['date'];
- $details['lastedit'] = $detail_query[0]['lastedit'];
- $details['qfc'] = $detail_query[0]['qfc'];
- $details['moved'] = $detail_query[0]['moved'];
- $details['hidden'] = $detail_query[0]['hidden'];
- $details['autohiding'] = $detail_query[0]['autohiding'];
- //get forum details
- $forum_details = $database->processQuery("SELECT `title` FROM `forums` WHERE `id` = ?", array($f), true);
- if(isset($_GET['username'])){
- if($user->doesExist($_GET['username'])){;
- }
- }else{
- if(!$user->isLoggedIn()){
- $base->redirect('../login.php');
- }else{
- $user_s = $username;
- }
- }
- $messages = array();
- $avatar = $user->getAvatar($profile_user);
- $usr = $user->getUsername($profile_user);
- if($username == $profile_user && $user->isLoggedIn() && isset($_REQUEST['cust_title'])) {
- $user->setTitle($username, htmlentities($_REQUEST['cust_title']));
- }
- if($user_s == $username && $user->isLoggedIn() && isset($_FILES['uploaded'])) {
- if(isset($_REQUEST['delete'])) {
- $user->setAvatar($username, '');
- $messages[] = "Your avatar has been removed.";
- } else {
- $ok = false;
- $info = getimagesize($_FILES['uploaded']['tmp_name']);
- if ($_FILES['uploaded']['error'] !== UPLOAD_ERR_OK) {
- $messages[] = ("Upload failed with error code " . $_FILES['uploaded']['error']);
- } else if($info === FALSE) {
- $messages[] = ("Unable to determine image type of uploaded file");
- } else if(($info[2] !== IMAGETYPE_GIF) && ($info[2] !== IMAGETYPE_JPEG) && ($info[2] !== IMAGETYPE_PNG)) {
- $messages[] = ("Not a gif/jpeg/png");
- } else if($_FILES['uploaded']['size'] > 350000) {
- $messages[] = "Your file is too large.";
- } else if($_FILES['uploaded']['type'] == "text/php") {
- $messages[] = "No PHP files";
- } else {
- $ok = true;
- }
- $target = md5(strtolower(trim($username))) .'.'. pathinfo($_FILES['uploaded']['name'])['extension'];
- if($ok) {
- if(move_uploaded_file($_FILES['uploaded']['tmp_name'], "../images/avatar/" . $target)){
- $messages[] = "Your avatar has been uploaded. Please allow atleast 10 minutes for it to update.";
- $user->setAvatar($username, $target);
- } else {
- $messages[] = "Sorry, there was a problem uploading your file.";
- }
- }
- }
- }
- //retrieve posts/threads
- $posts = $database->processQuery("SELECT `id`,`thread`,`username`,`timestamp`,`content` FROM `posts` WHERE `username` = ? AND ". time() ." - `timestamp` < 1209600 ORDER BY `id` DESC", array($user_s), true);
- $threads = $database->processQuery("SELECT `id`,`parent`,`title`,`username`,`timestamp`,`content` FROM `threads` WHERE `username` = ? AND ". time() ." - `timestamp` < 1209600 ORDER BY `id` DESC", array($user_s), true);
- //type:id:forum:timestamp:(if post)thread
- $list = array();
- foreach($posts as $post){
- //get the thread's forum/parent
- $t = $database->processQuery("SELECT `parent` FROM `threads` WHERE `id` = ? LIMIT 1", array($post['thread']), true);
- $list[$post['timestamp']] = 'p:'.$post['id'].':'. $t[0]['parent'] .':'.$post['timestamp'].':'.$post['thread'].':'.$post['content'];
- }
- //add threads
- foreach($threads as $thread){
- $list[$thread['timestamp']] = 't:'.$thread['id'].':'.$thread['parent'].':'.$thread['timestamp'].':'.$thread['content'];
- }
- //now sort them
- krsort($list, SORT_NUMERIC);
- $r = $database->processQuery("SELECT * FROM `users` WHERE `username` = ?", array($profile_name), true);
- ?>
Add Comment
Please, Sign In to add comment