<?php
include("db-info.php");
include("session.inc.php");
include("loadsettings.inc.php");
?>
<html>
<head>
<title><? echo $webtitle; ?> - Hosting de Imagenes</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<meta name="description" content="<? echo $description; ?>" />
<meta name="keywords" content="<? echo $keywords; ?>" />
<script language="JavaScript">
function showWindow(id) {
window.open("show-fullsize.php?id=" + id,"FullsizeImage","menubar=no,width=800,height=600,scrollbars=yes,status=yes,resizable=yes");
}
</script>
</head>
<body link=#336699 vlink=#336699 alink=#336699>
<?php include("header.php"); ?>
<center>
<div class="content-container">
<!-- ######################################################################################### -->
<?php
if (isset($_GET["id"])) {
$id = $_GET["id"];
if ($id == "") die("Please specify an image id!");
$result = mysql_query("SELECT * FROM `images` WHERE id='$id'"); if (!$number) die("Lo sentimos! La imagen no existe, O fue eliminada por la violacion de los <a href='terms.php'>Terminos de Servicio</a>!");
$type = $row['type'];
//IF IMAGE TYPE IS PRIVATE THEN SHOW THE PASSWORD FORM
if ($type == "member-private") {
if ($row['userid'] != $userid) {
echo "Esta imagen es privada. Por favor ingrese el password para verla<br><br>";
echo "<form action='show-image.php' method='POST'>
<LABEL id='title'>Password: </LABEL> <input type='password' name='password' maxlength='30'>";
echo "<input type='hidden' name='id' value='$id'> <input type='hidden' name='image' value='member'> ";
echo " <input type='submit' value='View'></form>";
}
else show();
}
//IF THE IMAGE TYPE IS MEMBER PUBLIC THEN SHOW IT!
if ($type == "member-public") {
show();
}
//IF THE IMAGE TYPE IS ANONYMOUS PUBLIC THEN SHOW IT!
if ($type == "public") {
show();
}
//IF THE IMAGE IS OF A GALLERY THEN:
if ($type == "gallery") {
$q = "SELECT galleryid FROM `images` WHERE id = '$id'";
$galleryid = $row[0];
//CHECK IF THE GALLERY IN WHICH THE IMAGE IS PRESENT IS PUBLIC OR PRIVATE
$result_set = mysql_query("SELECT * FROM `galleries` WHERE id = '$galleryid'"); $type1 = $row['type'];
$imguserid = $row['userid'];
//IF PRIVATE THEN SHOW THE PASSWORD FORM
if ($type1 == "private") {
if ($imguserid == $userid) {
show();
} else {
if (isset($_SESSION['gallery' . $galleryid])) show();
else {
echo "Esta galeria es privada. Por favor ingrese el password para verla<br><br>";
echo "<form action='show-image.php' method='POST'>Password: <input type='password' name='password' maxlength='30'>";
echo "<input type='hidden' name='id' value='$id'> <input type='hidden' name='image' value='gallery'>";
echo " <input type='submit' value='View'></form>";
}
}
}
else
show();
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
else {
//IF PASSWORD IS SUBMITTED
if (isset($_POST["password"])) {
$id = $_POST["id"];
$image = $_POST["image"];
//GET THE ASSOCIATIVE USER ID
$imguserid = getUserId($id);
//EXTRACT HIS USER PASS
$r = mysql_query("SELECT userpass FROM `members` WHERE id = '$imguserid'"); $userpass = $row1[0];
//THEN CHECK IT.. IF CORRECT THEN SHOW
if ($_POST["password"] != $userpass)
echo "Lo sentimos! Usted ingreso un password incorrecto.";
else
show();
}
}
//THIS FUNCTION DISPLAYS THE IMAGE
function show() {
global $id; global $session; global $userid;
include("loadsettings.inc.php");
$q = "SELECT * FROM `images` WHERE id = '$id'";
$thumb = $row['thumb'];
$image = $row['image'];
//UPDATE VIEWS COUNT AND LAST ACCESS DATE
$views = $row['views'] + 1;
$r = mysql_query("UPDATE `images` SET views = '$views', access = '$access' WHERE id = '$id' ");
$imguserid = getUserId($id);
$own = false;
if ($imguserid != -1) {
if ($userid == $imguserid)
$own = true;
$r = mysql_query("SELECT username FROM `members` WHERE id = '$imguserid'"); $username = $row1[0];
}
else $username = "Anonymous";
echo "<center>";
echo "<br><LABEL id='title'>Visitas:</LABEL> $views";
echo "<br><LABEL id='title'>Subida el Día:</LABEL> {$row['date']}";