query('SELECT * FROM Users WHERE UserID = ' . $user_id); if($result && $result->num_rows) { $test = $result->fetch_assoc(); echo ('
First Name
Last Name
Country
City
Zip
Street Address
Avatar URL Or (Images will be resized to 100x100 pixels)
'); } } function updateAccount($mysqli,$image) { $update = $mysqli->query('UPDATE Users SET FirstName = \''.$_POST["FirstName"].'\', LastName = \''.$_POST["LastName"].'\', Country = \''.$_POST["Country"].'\', City = \''.$_POST['City'].'\', Zip = \''.$_POST['Zip'].'\', Street = \''.$_POST['Street'].'\', AvatarURL = \''.$image.'\' WHERE UserID = '.$_SESSION["user_id"]); if($update) echo ''; else echo ''; } /*function resizeImage($filename, $max_width, $max_height) { list($orig_width, $orig_height) = getimagesize($filename); $width = $orig_width; $height = $orig_height; # taller if ($height > $max_height) { $width = ($max_height / $height) * $width; $height = $max_height; } # wider if ($width > $max_width) { $height = ($max_width / $width) * $height; $width = $max_width; } $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $orig_width, $orig_height); return $image_p; }*/ function resize($width, $height){ /* Get original image x y*/ list($w, $h) = getimagesize($_FILES['image']['tmp_name']); /* calculate new image size with ratio */ $ratio = max($width/$w, $height/$h); $h = ceil($height / $ratio); $x = ($w - $width / $ratio) / 2; $w = ceil($width / $ratio); /* new file name */ $path = 'images/avatars/'.$width.'x'.$height.'_'.$_FILES['image']['name']; /* read binary data from image file */ $imgString = file_get_contents($_FILES['image']['tmp_name']); /* create image from string */ $image = imagecreatefromstring($imgString); $tmp = imagecreatetruecolor($width, $height); imagecopyresampled($tmp, $image, 0, 0, $x, 0, $width, $height, $w, $h); /* Save image */ switch ($_FILES['image']['type']) { case 'image/jpeg': imagejpeg($tmp, $path, 100); break; case 'image/png': imagepng($tmp, $path, 0); break; case 'image/gif': imagegif($tmp, $path); break; default: exit; break; } return $path; /* cleanup memory */ imagedestroy($image); imagedestroy($tmp); }query('SELECT * FROM BookInstances WHERE BookID = '. $book_id); if ($result) { $row = $result->fetch_assoc(); print_binfo($mysqli, $book_id); echo ''; if (check_owned($mysqli, $_SESSION['user_id'], $book_id)) { echo ''; } else { echo ''; } echo ''; echo '
You have this book on your Bookshelf.'.delete_button($mysqli, $row['BIID']).''; echo '
'; echo '
'; } } } function status_choice($mysqli, $user_id, $biid, $status) { $result = '
'.''.(($status == 0)? '':'Read'). (($status == 1)? '':'Reading').(($status == 2)? '':'On hold '). (($status == 3)? '':'Dropped').'
'; return $result; } function status_change($mysqli, $biid, $status) { if ($stmt = $mysqli) { $stmt->query('UPDATE BookInstances SET Status='.$status.' WHERE BIID='.$biid); } } function list_read($mysqli, $user_id) { if ($stmt = $mysqli) { $result = $stmt->query('SELECT * FROM BookInstances WHERE UserID = '.$user_id.' AND Status = 0'); if ($result&&$result->num_rows) { echo "

Read

"; echo ''; echo ''; echo ''; while ($row = $result->fetch_assoc()) { $result2 = $stmt->query('SELECT * FROM Books WHERE BookID = '.$row['BookID']); while ($row2 = $result2->fetch_assoc()) { echo ''; echo ''; if ($user_id == $_SESSION['user_id']) { echo ''; echo ''; } echo ''; } } echo '
TitleAuthors
'; echo ''.$row2['Title'].''.$row2['Authors'].''.status_choice($mysqli, $user_id, $row['BIID'], $row['Status']).''.delete_button($mysqli, $row['BIID']).'
'; } else { echo "

No read books.

"; return false; } } else return NULL; } function list_reading($mysqli, $user_id) { if ($stmt = $mysqli) { $result = $stmt->query('SELECT * FROM BookInstances WHERE UserID = '.$user_id.' AND Status = 1'); if ($result&&$result->num_rows) { echo "

Reading

"; echo ''; echo ''; echo ''; while ($row = $result->fetch_assoc()) { $result2 = $stmt->query('SELECT * FROM Books WHERE BookID = '.$row['BookID']); while ($row2 = $result2->fetch_assoc()) { echo ''; echo ''; if ($user_id == $_SESSION['user_id']) { echo ''; echo ''; } echo ''; } } echo '
TitleAuthors
'; echo ''.$row2['Title'].''.$row2['Authors'].''.status_choice($mysqli, $user_id, $row['BIID'], $row['Status']).''.delete_button($mysqli, $row['BIID']).'
'; } else { echo "

No books in reading.

"; return false; } } else return NULL; } function list_hold($mysqli, $user_id) { if ($stmt = $mysqli) { $result = $stmt->query('SELECT * FROM BookInstances WHERE UserID = '.$user_id.' AND Status = 2'); if ($result&&$result->num_rows) { echo "

On hold

"; echo ''; echo ''; echo ''; while ($row = $result->fetch_assoc()) { $result2 = $stmt->query('SELECT * FROM Books WHERE BookID = '.$row['BookID']); while ($row2 = $result2->fetch_assoc()) { echo ''; echo ''; if ($user_id == $_SESSION['user_id']) { echo ''; echo ''; } echo ''; } } echo '
TitleAuthors
'; echo ''.$row2['Title'].''.$row2['Authors'].''.status_choice($mysqli, $user_id, $row['BIID'], $row['Status']).''.delete_button($mysqli, $row['BIID']).'
'; } else { echo "

No books on hold.

"; return false; } } else return NULL; } function list_drop($mysqli, $user_id) { if ($stmt = $mysqli) { $result = $stmt->query('SELECT * FROM BookInstances WHERE UserID = '.$user_id.' AND Status = 3'); if ($result&&$result->num_rows) { echo "

Dropped

"; echo ''; echo ''; echo ''; while ($row = $result->fetch_assoc()) { $result2 = $stmt->query('SELECT * FROM Books WHERE BookID = '.$row['BookID']); while ($row2 = $result2->fetch_assoc()) { echo ''; echo ''; if ($user_id == $_SESSION['user_id']) { echo ''; echo ''; } echo ''; } } echo '
TitleAuthors
'; echo ''.$row2['Title'].''.$row2['Authors'].''.status_choice($mysqli, $user_id, $row['BIID'], $row['Status']).''.delete_button($mysqli, $row['BIID']).'
'; } else { echo "

No dropped books.

"; return false; } } else return NULL; } function list_my_books($mysqli, $user_id) { list_read($mysqli, $user_id); echo "
"; echo "
"; list_reading($mysqli, $user_id); echo "
"; echo "
"; list_hold($mysqli, $user_id); echo "
"; echo "
"; list_drop($mysqli, $user_id); } function get_username($mysqli, $user_id) { if ($stmt = $mysqli) { $result = $stmt->query('SELECT UserName FROM Users WHERE UserID = '.$user_id); if ($result) { $row = $result->fetch_assoc(); return $row['UserName']; } } } function wishlist ($mysqli, $user_id) { if ($stmt = $mysqli) { $result = ($stmt->query('SELECT BID FROM Wishlist WHERE UID='.$user_id)); if ($result&&$result->num_rows) { echo (''); echo (''); echo (''); while ($row = $result->fetch_assoc()) { $result2 = ($stmt->query('SELECT Title, Authors FROM Books WHERE BookID='.$row['BID'])); $row2 = $result2->fetch_assoc(); echo ''; echo (''); echo ''; echo ''; // echo ''; } echo '
TitleAuthors
' . $row2['Title'] . ''.$row2['Authors'].'
'; } } else { echo "Your Wishlist is empty."; } } function book_add($mysqli,$title,$authors,$language,$isbn) { if($title==='' && $isbn==='') { echo(''); return false; }; require_once('recaptchalib.php'); $privatekey = "6Lcaf_ASAAAAAN7INSG0Ie7DZqPLjqyb0Yjz89PT"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly //die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); echo(''); } else { if ($stmt= $mysqli) { if ($stmt->query('INSERT INTO Books (Title, Authors, Language, ISBN13, Pending4Approval) VALUES (\''.$title.'\',\''.$authors.'\',\''.$language.'\','.(int)$isbn.',1)')) { echo(''); return true; } else { echo(''); return false; }; } else return NULL; }; return NULL; } function change_wish($mysqli, $user, $bookid) { if ($stmt = $mysqli) { if (check_wish($mysqli, $user, $bookid)){ $stmt->query('DELETE FROM Wishlist WHERE UID = '.$user.' AND BID = '.$bookid); echo(''); return true; } else { $stmt->query('INSERT INTO Wishlist (UID, BID) VALUES ('.$user.','.$bookid.')'); echo(''); return true; } } else { echo(''); return false; } return NULL; } function check_owned($mysqli, $user, $bid) { if ($stmt = $mysqli) { if ($result = $stmt->query('SELECT BookID FROM BookInstances WHERE UserID = '.$user)) { while ($row = $result->fetch_assoc()) { if ($row['BookID']==$bid) { return true; } } return false; } } return NULL; } function check_wish($mysqli, $user, $bid) { if ($stmt = $mysqli) { ($result = $stmt->query('SELECT BID FROM Wishlist WHERE UID = '.$user.' AND BID='.$bid)); if ($result&&$result->num_rows) { return true; } else { return false; } } return NULL; } function delete_button($mysqli, $biid){ $result = '
'; // return $result; } function delete_book($mysqli, $biid) { if ($stmt = $mysqli) { $stmt->query('DELETE FROM BookInstances WHERE BIID = '.$biid); } } function print_binfo($mysqli, $bid) { if($stmt = $mysqli) { $result = $stmt->query('SELECT * FROM Books WHERE BookID = '.$bid); if ($result) { echo ''; while($row = $result->fetch_assoc()) { echo (''); echo ''; if ($row['Subtitle']) { echo ''; } echo ''; if ($row['Publisher']) { echo ''; } if ($row['PrintDate']) { echo ''; } echo ''; if ($row['ISBN10']) { echo ''; } if ($row['ISBN13']) { echo ''; } if ($row['Format']) { echo ''; } if ($row['Edition']) { echo ''; } if ($row['SeriesCollection']) { echo ''; } if ($row['Category']) { echo ''; } } echo '
Title: '.$row['Title'].'
Subtitle: '.$row['Subtitle'].'
Authors: '.$row['Authors'].'
Publisher: '.$row['Publisher'].'
Date of Print: '.date('d-m-Y', strtotime($row['PrintDate']) ).'
Language: '.$row['Language'].'
ISBN10: '.$row['ISBN10'].'
ISBN13: '.$row['ISBN13'].'
Format: '.$row['Format'].'
Edition: '.$row['Edition'].'
Series or Collection: '.$row['SeriesCollection'].'
Category: '.$row['Category'].'
'; } } } Libri Vermis - Loginpage
Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in /var/www/librivermis.projects.metropolia.fi/public_html/includes/functions.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at /var/www/librivermis.projects.metropolia.fi/public_html/includes/badger.php:1) in /var/www/librivermis.projects.metropolia.fi/public_html/includes/functions.php on line 18