Ver Mensaje Individual
  #5 (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.

Código PHP:
Ver original
  1. //***********************************************************************************
  2.  
  3.      //Check if image size is bigger than 800 X 800 then make it small to atleast 800 but proportionally
  4.      $img = imagecreatefromunknown($image);
  5.                                  
  6.      $mainWidth = imagesx($img);
  7.      $mainHeight = imagesy($img);
  8.              
  9.      if (($mainWidth > 800) || ($mainHeight > 800))
  10.      {
  11.           $a = ($mainWidth >= $mainHeight) ? $mainWidth : $mainHeight;
  12.           $div = $a / 800;
  13.           $mainWidth = intval($mainWidth / $div);
  14.           $mainHeight = intval($mainHeight / $div);
  15.  
  16.           echo "<br><br><a href='$image' title='Click aqui para ver la imagen en tamaño original' target='_blank'>
  17.                   <img src='$image' border=1 width='$mainWidth' height='$mainHeight'>
  18.                   </a>";
  19.      }
  20.      else {
  21.          echo "<br><br><img src='$image' border='1'>";
  22.      }
  23.  
  24.   //***********************************************************************************
  25.  
  26.  
  27.  
  28.   echo "<br><br><LABEL id='title'>Detalles:</LABEL> {$row['details']}";
  29.   echo "<br><LABEL id='title'>Subida Por:</LABEL> $username";
  30.   echo "<br><br><LABEL id='title'>Tags:</LABEL><br>{$row['tags']}";
  31.  
  32.   echo "<br><br><br><br>";
  33.  
  34.   echo "<div class='emailBox'>
  35.         <form method='POST' action='email.php'>
  36.         <LABEL id='title'>Envia esta imagen a un amigo via Email:</LABEL><br> &nbsp; <input type='text' size='20' name='email'>&nbsp; &nbsp;
  37.         <input type='submit' value='Enviar' name='emailImage'>
  38.         <input type='hidden' name='id' value='$id'>
  39.         <br>En caso de multiples emails, separar emails con comas (,)
  40.         </form></div>";
  41.  
  42.   echo "<br><br><a href='report.php?id=$id'><img src='images/abuse.png' border=0></a>";
  43.  
  44.   if ($session == true)
  45.      echo "&nbsp;  <a href='addfavourite.php?id=$id'><img src='images/favourites.png' border=0></a>";
  46.  
  47.  
  48.   echo "<br><br><br><br>";
  49.  
  50.   //*****************************************************************************************************
  51.  
  52.  
  53. if ($imguserid != -1) {  
  54.  
  55.   $r = mysql_query("SELECT * FROM `comments` WHERE imageid = '$id' ORDER BY id DESC");
  56.   $n = mysql_num_rows($r);  
  57.  
  58.  
  59.   echo "<div style='FLOAT: left; WIDTH: 500px; TEXT-ALIGN: left; BORDER-RIGHT: #42679c 2px solid;
  60.                     PADDING-LEFT: 20px; PADDING-RIGHT: 20px; HEIGHT: 300px; MARGIN-RIGHT: 20px'>";
  61.   echo "<h2><u>Comentarios</u></h2>";
  62.  
  63.   if ($n) {
  64.  
  65.      $ccount = -1;
  66.      while ($row1 = mysql_fetch_array($r)) {
  67.        $comment = str_replace("\n", "<br>", $row1['comment']);
  68.      
  69.        $ccount++;
  70.        if ($ccount == 5)
  71.          echo "<br><a href='#' style='FONT-SIZE: 16px'
  72.                  onclick=\"getElementById('allcomments').style.display='block'; this.style.display='none'\">
  73.                  Ver todos los comentarios</a>
  74.                <div style='display: none' id='allcomments'>";
  75.  
  76.        echo "<div class='commentbox'> $comment ";
  77.        if ($own == true)
  78.            echo "<br><a href='deletecomment.php?id={$row1['id']}'>Delete</a>";
  79.        echo "</div>";
  80.      }
  81.       if ($ccount > 4) echo "</div>";  
  82.  
  83.   }
  84.   else
  85.       echo "<div class='commentbox'>No hay comentarios para esta imagen!</div>";
  86.  
  87.    
  88.   if ($session == true) {
  89.  
  90.     echo "<form method='POST' action='postcomment.php'>
  91.           <br><h2>Publicar Comentario</h2>
  92.           <textarea cols=40 rows=4 name='comment'></textarea><br>
  93.           <input type='hidden' name='id' value='$id'>
  94.           <input type='submit' value='Publicar' name='postcomment'>
  95.           </form> <b>Caracteres Maximos: 200</b>
  96.          ";    
  97.     }
  98.    echo "</div>";
  99.  
  100. }
  101.  
  102.  
  103.   //********************************************************************************************************
  104.  
  105.   echo "<div style='TEXT-ALIGN: left'>
  106.         <h2><u>Codigos:</u> </h2>";
  107.   echo "<table style='border-collapse: collapse'><tr><td>";
  108.  
  109.   echo "<LABEL id='title'>HTML:</LABEL><br><input type='text' size=50 onclick=\"this.select();\" value=\"<a href='{$website}/show-image.php?id=$id'> <img src='{$website}/{$thumb}' alt='Image Hosting' border='0'> </a>\">";
  110.   echo "<br><br>";
  111.    
  112.  
  113.   echo "<LABEL id='title'>Codigo BB:</LABEL><br><input type='text' size=50 onclick=\"this.select();\" value=\"[URL={$website}/show-image.php?id={$id}] [IMG]{$website}/{$thumb}[/IMG][/URL]\">";
  114.   echo "<br><br>";
  115.  
  116.  
  117.   echo "<LABEL id='title'>Link Directo:</LABEL><br><input type='text' size=50 onclick=\"this.select();\" value=\"{$website}/{$image}\">";
  118.   echo "<br><br>";
  119.  
  120.  
  121.   echo "<LABEL id='title'>Link Directo (BB Code):</LABEL><br><input type='text' size=50 onclick=\"this.select();\" value=\"[URL={$website}] [IMG]{$website}/{$image}[/IMG][/URL]\">";
  122.   echo "<br><br>";
  123.  
  124.   echo "<LABEL id='title'>URL:</LABEL><br><input type='text' size=50 onclick=\"this.select();\" value=\"{$website}/show-image.php?id=$id\">";
  125.  
  126.   echo "</td></tr></table></div>";
  127.  
  128.  
  129.  
  130.   //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  131.  
  132.   echo "<p style='CLEAR: both'>";
  133.   echo "<br><br>-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>";
  134.   include("random.inc.php");  
  135.  
  136.  
  137. }
  138.  
  139.  
  140.  
  141. // Returns the userid of image.. if its a gallery image it retrieves the userid from the galleries table
  142. function getUserId($id) {
  143.  
  144.  $userid = "";
  145.  $result = mysql_query("SELECT * FROM `images` WHERE id='$id'");
  146.  $row = mysql_fetch_array($result);
  147.  $type = $row['type'];
  148.  
  149.  if ($type == "gallery") {
  150.  
  151.       $q = "SELECT galleryid FROM `images` WHERE id = '$id'";
  152.       if(!($result_set = mysql_query($q))) die(mysql_error());
  153.       $row = mysql_fetch_row($result_set);
  154.       $galleryid = $row[0];
  155.  
  156.       $result_set = mysql_query("SELECT userid FROM `galleries` WHERE id = '$galleryid'");
  157.       $row = mysql_fetch_row($result_set);
  158.       $userid = $row[0];
  159.  }
  160.  else {
  161.  
  162.       $q = "SELECT userid FROM `images` WHERE id = '$id'";
  163.       if(!($result_set = mysql_query($q))) die(mysql_error());
  164.       $row = mysql_fetch_row($result_set);
  165.       $userid = $row[0];
  166.  }
  167.  
  168.  
  169.  return $userid;
  170.  
  171. }
  172.  
  173.  
  174.  
  175.  
  176.  
  177. function findExtension ($filename)
  178. {
  179.    $filename = strtolower($filename) ;
  180.    $exts = split("[/\\.]", $filename) ;
  181.    $n = count($exts)-1;
  182.    $exts = $exts[$n];
  183.    return $exts;
  184. }
  185.  
  186.  
  187. function imagecreatefromunknown($path) {
  188.  
  189.    $ext = findExtension($path);
  190.    
  191.    switch ($ext) {
  192.       case "jpg":
  193.         $img = imagecreatefromjpeg($path);
  194.         break;
  195.       case "gif":
  196.         $img = imagecreatefromgif($path);
  197.         break;
  198.       case "png":
  199.         $img = imagecreatefrompng($path);
  200.         break;
  201.   }
  202.  
  203.   return $img;
  204. }
  205.  
  206.  
  207.  
  208.  
  209.  
  210. ?>
  211.  
  212. <!-- ######################################################################################### -->
  213.  
  214. <?php  include("footer.php"); ?>
  215.  
  216.  
  217. </div>
  218. </center>
  219. </body>
  220. </html>

Saludos!!

Última edición por SonrisaCs; 08/02/2011 a las 14:09