<?php
session_start();
require_once('lib/Users.class.php');
$login = New Users;
$login->esegui_login();
?>
<html>
<head>
<title>Login page</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/menu.css" type="text/css" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" />
<script type="text/javascript" src="jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery/1.7/jquery.validate.js"></script>
<script type="text/javascript" src="js/validation_login.js"></script>
<script type="text/javascript" src="js/lightbox-2.6.min.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen">
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen">
<script type="text/javascript">
$(document).ready(function(){
$('.lightbox').click(function(){
$('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear');
$('.box').animate({'opacity':'1.00'}, 300, 'linear');
$('.backdrop, .box').css('display', 'block');
});
$('.close').click(function(){
close_box();
});
$('.backdrop').click(function(){
close_box();
});
});
function close_box()
{
$('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){
$('.backdrop, .box').css('display', 'none');
});
}
</script>
</head>
<body>
<div id="content">
<?php $login->is_logged(); ?>
<div id="top_header">
<input type="search" id="search_box" placeholder="Search...">
</div>
<br>
<br>
<br>
<div id="main">
<?php
$username = $_SESSION['username_logged'];
$host="localhost"; // host del database
$uname="root"; // utente del db
$psw=""; // password dell'utente sopra
$nomedb="familiaechat"; // nome del db
mysql_connect($host,$uname,$psw);
mysql_select_db($nomedb);
$q=mysql_query("SELECT * FROM users WHERE username='$username'");
$r=mysql_fetch_assoc($q);
// Ora se nella tabella c'è un campo chiamato ad esempio "nome".
//Se fai così:
?>
<div id="gallery">
<?php
if(isset($_FILES['file']['tmp_name'])) {
$fileCount = getNextNumber();
$newName = 'users/'. $login->get_username(). "/photo_gallery/" . ( $fileCount) . '.jpg';
move_uploaded_file($_FILES['file']['tmp_name'], $newName);
mysql_query("INSERT INTO `photogallery` (`username`, `photo`) VALUES('$username', '$newName')") or die(mysql_error());
/* function: generates thumbnail */
function make_thumb($src,$dest,$desired_width) {
/* read the source image */
$source_image = imagecreatefromjpeg($src);
$width = imagesx($source_image);
$height = imagesy($source_image);
/* find the "desired height" of this thumbnail, relative to the desired width */
$desired_height = floor($height*($desired_width/$width));
/* create a new, "virtual" image */
$virtual_image = imagecreatetruecolor($desired_width,$desired_height);
/* copy source image at a resized size */
imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
/* create the physical thumbnail image to its destination */
imagejpeg($virtual_image,$dest);
}
/* function: returns files from dir */
function get_files($images_dir,$exts = array('jpg')) {
$files = array();
if($handle = opendir($images_dir)) {
while(false !== ($file = readdir($handle))) {
$extension = strtolower(get_file_extension($file));
if($extension && in_array($extension,$exts)) {
$files[] = $file;
}
}
closedir($handle);
}
return $files;
}
/* function: returns a file's extension */
function get_file_extension($file_name) {
return substr(strrchr($file_name,'.'),1);
}
/** settings **/
$images_dir = 'users/'. $login->get_username(). "/photo_gallery/";
$thumbs_dir = 'users/'. $login->get_username(). "/photo_gallery_thumbs/";
$thumbs_width = 200;
$images_per_row = 3;
/** generate photo gallery **/
$image_files = get_files($images_dir);
if(count($image_files)) {
$index = 0;
foreach($image_files as $index=>$file) {
$index++;
$thumbnail_image = $thumbs_dir.$file;
if(!file_exists($thumbnail_image)) {
$extension = get_file_extension($thumbnail_image);
if($extension) {
make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width);
}
}
echo '
<a href="',$images_dir.$file,'" class="photo-link smoothbox" rel="gallery">
<img src="',$thumbnail_image,' " id="photo" rel="lightbox" /></a>';
if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; }
}
echo '<div class="clear"></div>';
}
else {
echo '<p>There are no images in this gallery.</p>';
}
}
function getNextNumber() {
$count = (int)file_get_contents('yourFile.txt');
$count+=1;
file_put_contents('yourFile.txt',$count);
return $count;
}
?>
</div>
<div id="left_sidebar">
<?php
echo '<br><br><br><br><br><br><br><br>';
echo '<font id="name_lastname" face="Verdana, Geneva, sans-serif" style="font-weight: bold;"><center>'; echo $r['name']; echo ' '; echo $r['lastname']; echo '</font>'; echo '<br><br>';
include 'left_menu.php';
?>
</div>
<div id="right_sidebar">
<?php
include 'right_menu.php';
?>
</div>
</div>
</body>
<p style="text-align: justify;">
</html>