Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/02/2011, 23:03
SonrisaCs
 
Fecha de Ingreso: diciembre-2010
Mensajes: 180
Antigüedad: 13 años, 4 meses
Puntos: 5
Respuesta: Ayuda, Imagenes al azar.

show-images.php
Código PHP:
Ver original
  1. <?php
  2.  
  3.  include("db-info.php");
  4.  $link = mysql_connect($server, $user, $pass);
  5.  if(!mysql_select_db($database)) die(mysql_error());
  6.  
  7.  include("session.inc.php");
  8.  include("loadsettings.inc.php");
  9. ?>
  10.  
  11.  
  12.  
  13. <html>
  14.  
  15. <head>
  16.  
  17. <title><? echo $webtitle; ?> -  Hosting de Imagenes</title>
  18. <link rel="stylesheet" href="style.css" type="text/css" />
  19.  
  20. <meta name="description" content="<? echo $description; ?>" />
  21. <meta name="keywords" content="<? echo $keywords; ?>" />
  22.  
  23.  
  24. <script language="JavaScript">
  25.  
  26. function showWindow(id) {
  27.    window.open("show-fullsize.php?id=" + id,"FullsizeImage","menubar=no,width=800,height=600,scrollbars=yes,status=yes,resizable=yes");
  28. }
  29.  
  30. </script>
  31.  
  32. </head>
  33.  
  34.  
  35. <body link=#336699 vlink=#336699 alink=#336699>
  36. <?php include("header.php"); ?>
  37.  
  38. <center>
  39. <div class="content-container">
  40.    
  41.  
  42. <!-- ######################################################################################### -->
  43.  
  44. <?php
  45.  
  46.  
  47. if (isset($_GET["id"])) {
  48.  
  49. $id = $_GET["id"];
  50. if ($id == "") die("Please specify an image id!");
  51.  
  52. $result = mysql_query("SELECT * FROM `images` WHERE id='$id'");
  53. $number = mysql_num_rows($result);
  54. $row = mysql_fetch_array($result);
  55. 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>!");
  56.  
  57. $type = $row['type'];
  58.  
  59.  
  60. //IF IMAGE TYPE IS PRIVATE THEN SHOW THE PASSWORD FORM
  61. if ($type == "member-private") {
  62.  
  63.   if ($row['userid'] != $userid) {
  64.       echo "Esta imagen es privada. Por favor ingrese el password para verla<br><br>";
  65.       echo "<form action='show-image.php' method='POST'>
  66.           <LABEL id='title'>Password: </LABEL> <input type='password' name='password' maxlength='30'>";
  67.       echo "<input type='hidden' name='id' value='$id'> <input type='hidden' name='image' value='member'> ";
  68.       echo "&nbsp; &nbsp; <input type='submit' value='View'></form>";
  69.   }
  70.   else show();
  71.  
  72. }
  73.  
  74.  
  75. //IF THE IMAGE TYPE IS MEMBER PUBLIC THEN SHOW IT!
  76. if ($type == "member-public") {
  77.   show();
  78. }
  79.  
  80.  
  81. //IF THE IMAGE TYPE IS ANONYMOUS PUBLIC THEN SHOW IT!
  82. if ($type == "public") {
  83.   show();
  84. }
  85.  
  86.  
  87. //IF THE IMAGE IS OF A GALLERY THEN:
  88. if ($type == "gallery") {
  89.  
  90.  $q = "SELECT galleryid FROM `images` WHERE id = '$id'";
  91.  if(!($result_set = mysql_query($q))) die(mysql_error());
  92.  $row = mysql_fetch_row($result_set);
  93.  $galleryid = $row[0];
  94.  
  95.  
  96.  //CHECK IF THE GALLERY IN WHICH THE IMAGE IS PRESENT IS PUBLIC OR PRIVATE
  97.  $result_set = mysql_query("SELECT * FROM `galleries` WHERE id = '$galleryid'");
  98.  $row = mysql_fetch_array($result_set);
  99.  $type1 = $row['type'];
  100.  $imguserid = $row['userid'];
  101.  
  102.  
  103.  //IF PRIVATE THEN SHOW THE PASSWORD FORM
  104.  if ($type1 == "private") {
  105.  
  106.     if ($imguserid == $userid) {
  107.        show();
  108.     } else {
  109.      
  110.          if (isset($_SESSION['gallery' . $galleryid]))
  111.               show();
  112.          else {
  113.               echo "Esta galeria es privada. Por favor ingrese el password para verla<br><br>";
  114.               echo "<form action='show-image.php' method='POST'>Password: <input type='password' name='password' maxlength='30'>";
  115.               echo "<input type='hidden' name='id' value='$id'>  <input type='hidden' name='image' value='gallery'>";
  116.               echo "&nbsp; &nbsp; <input type='submit' value='View'></form>";
  117.          }
  118.     }
  119.    
  120. }
  121.  else
  122.    show();
  123.  
  124. }
  125.  
  126.  
  127.  
  128.  
  129.  
  130. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  131.  
  132.  
  133. }
  134. else {
  135.  
  136.     //IF PASSWORD IS SUBMITTED
  137.     if (isset($_POST["password"]))  {
  138.  
  139.        $id = $_POST["id"];
  140.        $image = $_POST["image"];
  141.  
  142.        //GET THE ASSOCIATIVE USER ID  
  143.        $imguserid = getUserId($id);
  144.  
  145.        //EXTRACT HIS USER PASS
  146.        $r = mysql_query("SELECT userpass FROM `members` WHERE id = '$imguserid'");
  147.        $row1 = mysql_fetch_row($r);
  148.        $userpass = $row1[0];
  149.  
  150.        //THEN CHECK IT.. IF CORRECT THEN SHOW
  151.        if ($_POST["password"] != $userpass)
  152.           echo "Lo sentimos! Usted ingreso un password incorrecto.";
  153.        else
  154.           show();
  155.    }
  156.  
  157. }
  158.  
  159.  
  160.  
  161.  
  162. //THIS FUNCTION DISPLAYS THE IMAGE
  163. function show() {
  164.  
  165.   global $id; global $session; global $userid;
  166.  
  167.   include("loadsettings.inc.php");
  168.  
  169.  
  170.   $q = "SELECT * FROM `images` WHERE id = '$id'";
  171.   if(!($result_set = mysql_query($q))) die(mysql_error());
  172.   $row = mysql_fetch_array($result_set);
  173.  
  174.   $thumb = $row['thumb'];
  175.   $image = $row['image'];
  176.  
  177.   //UPDATE VIEWS COUNT AND LAST ACCESS DATE
  178.   $views = $row['views'] + 1;
  179.   $access = date("y-m-d");
  180.   $r = mysql_query("UPDATE `images` SET views = '$views', access = '$access' WHERE id = '$id' ");
  181.  
  182.  
  183.   $imguserid = getUserId($id);
  184.  
  185.   $own = false;
  186.   if ($imguserid != -1) {
  187.        
  188.        if ($userid == $imguserid)
  189.           $own = true;
  190.  
  191.        $r = mysql_query("SELECT username FROM `members` WHERE id = '$imguserid'");
  192.        $row1 = mysql_fetch_row($r);
  193.        $username = $row1[0];
  194.   }
  195.   else $username = "Anonymous";
  196.    
  197.  
  198.  
  199.   echo "<center>";
  200.   echo "<br><LABEL id='title'>Visitas:</LABEL> $views";
  201.   echo "<br><LABEL id='title'>Subida el Día:</LABEL> {$row['date']}";

Es muy largo T.T, Sigo abajo