ayuda con thumb.php

Inicio Foros WordPress Themes y Diseño ayuda con thumb.php

Etiquetado: , ,

Este debate contiene 0 respuestas, tiene 1 mensaje y lo actualizó  aroagarcia hace 8 años, 7 meses.

  • Autor
    Publicaciones
  • #16261

    aroagarcia
    Participante

    <p>Les explico tengo una plantilla que en la parte frontal de la pagina principal tiene un slide por el que pasa el título de las entradas y una imagen que enlaza a las entradas. bien`, pues monto la web en un servidor local, funciona, la monto en webcindario.com para probar, funciona, pero a la hora de entregarla a la empresa la he colgado en el servidor de la empresa pero el archivo thumb.php deja de funcionar correctamente y no me carga las imagenes en el slide.</p>
    <p>Parece ser un problema de incompatibilidad pero claro tendría que reconstruir el archivo no se como hacerlo estoy realmente desesperada. Les dejo las dos direcciones y los códigos por si a alguno/a de ustedes se les ocurre una solución</p>
    <p>http://wpprueba.webcindario.com este funciona bien<br />
    http://bodegasloculto.visualwebstudios.com este no</p>
    <p>Código de thumb.php</p>
    <p>&lt;?php</p>
    <p>// TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks<br />
    // http://code.google.com/p/timthumb/</p&gt;
    <p>// MIT License: http://www.opensource.org/licenses/mit-license.php</p&gt;
    <p>/* Parameters allowed: */</p>
    <p>// w: width<br />
    // h: height<br />
    // zc: zoom crop (0 or 1)<br />
    // q: quality (default is 75 and max is 100)</p>
    <p>// HTML example: <img src="/scripts/timthumb.php?src=/images/whatever.jpg&amp;w=150&amp;h=200&amp;zc=1" alt="" /></p>
    <p>if( !isset( $_REQUEST[ "src" ] ) ) { die( "no image specified" ); }</p>
    <p>// clean params before use<br />
    $src = $_REQUEST;<br />
    // possibles?<br />
    //$src = preg_replace( "/^(.+(/|))+/", "", $src );<br />
    //$src = str_replace( "../", "", $src );<br />
    //$src = preg_replace( ‘/^(s?f|ht)tps?://[^/]+/i’, ”, $src );<br />
    $src = preg_replace( "/(?:^/+|.{2,}/+?)/", "", $src );<br />
    $src = preg_replace( ‘/^w+://[^/]+/’, ”, $src );<br />
    $new_width = preg_replace( "/[^0-9]+/", "", $_REQUEST[ ‘w’ ] );<br />
    $new_height = preg_replace( "/[^0-9]+/", "", $_REQUEST[ ‘h’ ] );<br />
    $zoom_crop = preg_replace( "/[^0-9]+/", "", $_REQUEST[ ‘zc’ ] );</p>
    <p>if( !isset( $_REQUEST ) ) { $quality = 80; } else { $quality = preg_replace("/[^0-9]/", "", $_REQUEST ); }</p>
    <p>// set path to cache directory (default is ./cache)<br />
    // this can be changed to a different location<br />
    $cache_dir = ‘./cache’;</p>
    <p>// get mime type of src<br />
    $mime_type = mime_type( $src );</p>
    <p>// check to see if this image is in the cache already<br />
    check_cache( $cache_dir, $mime_type );</p>
    <p>// make sure that the src is gif/jpg/png<br />
    if( !valid_src_mime_type( $mime_type ) ) {<br />
    $error = "Invalid src mime type: $mime_type";<br />
    die( $error );<br />
    }</p>
    <p>// check to see if GD function exist<br />
    if(!function_exists(‘imagecreatetruecolor’)) {<br />
    $error = "GD Library Error: imagecreatetruecolor does not exist";<br />
    die( $error );<br />
    }</p>
    <p>// set document root<br />
    $doc_root = $_SERVER;</p>
    <p>// get path to image on file system<br />
    $src = $doc_root . ‘/’ . $src;</p>
    <p>if(strlen($src) &amp;&amp; file_exists( $src ) ) {</p>
    <p> // open the existing image<br />
    $image = open_image($mime_type, $src);<br />
    if ($image === false) { die (‘Unable to open image : ‘ . $src ); } </p>
    <p> // Get original width and height<br />
    $width = imagesx($image);<br />
    $height = imagesy($image);</p>
    <p> // generate new w/h if not provided<br />
    if($new_width &amp;&amp; !$new_height) {<br />
    $new_height = $height * ($new_width/$width);<br />
    }<br />
    elseif($new_height &amp;&amp; !$new_width) {<br />
    $new_width = $width * ($new_height/$height);<br />
    }<br />
    elseif(!$new_width &amp;&amp; !$new_height) {<br />
    $new_width = $width;<br />
    $new_height = $height;<br />
    }</p>
    <p> // create a new true color image<br />
    $canvas = imagecreatetruecolor($new_width, $new_height);</p>
    <p> if( $zoom_crop ) {</p>
    <p> $src_x = $src_y = 0;<br />
    $src_w = $width;<br />
    $src_h = $height;</p>
    <p> $cmp_x = $width / $new_width;<br />
    $cmp_y = $height / $new_height;</p>
    <p> // calculate x or y coordinate and width or height of source</p>
    <p> if ( $cmp_x &gt; $cmp_y ) {</p>
    <p> $src_w = round( ( $width / $cmp_x * $cmp_y ) );<br />
    $src_x = round( ( $width – ( $width / $cmp_x * $cmp_y ) ) / 2 );</p>
    <p> }<br />
    elseif ( $cmp_y &gt; $cmp_x ) {</p>
    <p> $src_h = round( ( $height / $cmp_y * $cmp_x ) );<br />
    $src_y = round( ( $height – ( $height / $cmp_y * $cmp_x ) ) / 2 );</p>
    <p> }</p>
    <p> imagecopyresampled( $canvas, $image, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h );</p>
    <p> }<br />
    else {</p>
    <p> // copy and resize part of an image with resampling<br />
    imagecopyresampled( $canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height );</p>
    <p> }</p>
    <p> // output image to browser based on mime type<br />
    show_image( $mime_type, $canvas, $quality, $cache_dir );</p>
    <p> // remove image from memory<br />
    ImageDestroy( $canvas );</p>
    <p>} else {</p>
    <p> if( strlen( $src ) ) { echo $src . ‘ not found.’; } else { echo ‘no source specified.’; }</p>
    <p>}</p>
    <p>function show_image ($mime_type, $image_resized, $quality, $cache_dir) {</p>
    <p> // check to see if we can write to the cache directory<br />
    $is_writable = 0;<br />
    $cache_file_name = $cache_dir . ‘/’ . get_cache_file(); </p>
    <p> if( touch( $cache_file_name ) ) {<br />
    // give 666 permissions so that the developer<br />
    // can overwrite web server user<br />
    chmod( $cache_file_name, 0666 );<br />
    $is_writable = 1;<br />
    }<br />
    else {<br />
    $cache_file_name = NULL;<br />
    header(‘Content-type: ‘ . $mime_type);<br />
    }</p>
    <p> if(stristr( $mime_type, ‘gif’ ) ) {<br />
    imagegif( $image_resized, $cache_file_name );<br />
    }<br />
    elseif( stristr( $mime_type, ‘jpeg’ ) ) {<br />
    imagejpeg( $image_resized, $cache_file_name, $quality );<br />
    }<br />
    elseif( stristr( $mime_type, ‘png’ ) ) {<br />
    imagepng( $image_resized, $cache_file_name, ceil( $quality / 10 ) );<br />
    }<br />
    if( $is_writable ) { show_cache_file( $cache_dir, $mime_type ); }<br />
    exit;</p>
    <p>}</p>
    <p>function open_image ($mime_type, $src) {</p>
    <p> if(stristr($mime_type, ‘gif’)) {<br />
    $image = imagecreatefromgif($src);<br />
    }<br />
    elseif(stristr($mime_type, ‘jpeg’)) {<br />
    $image = imagecreatefromjpeg($src);<br />
    }<br />
    elseif(stristr($mime_type, ‘png’)) {<br />
    $image = imagecreatefrompng($src);<br />
    }<br />
    return $image;</p>
    <p>}</p>
    <p>function mime_type( $file ) {</p>
    <p> $frags = split( ".", $file );<br />
    $ext = strtolower( $frags[ count( $frags ) – 1 ] );<br />
    $types = array(<br />
    ‘jpg’ =&gt; ‘image/jpeg’,<br />
    ‘jpeg’ =&gt; ‘image/jpeg’,<br />
    ‘png’ =&gt; ‘image/png’,<br />
    ‘gif’ =&gt; ‘image/gif’,<br />
    ‘bmp’ =&gt; ‘image/bmp’,<br />
    ‘doc’ =&gt; ‘application/msword’,<br />
    ‘xls’ =&gt; ‘application/msword’,<br />
    ‘xml’ =&gt; ‘text/xml’,<br />
    ‘html’ =&gt; ‘text/html'<br />
    );<br />
    $mime_type = $types[ $ext ];<br />
    if( !strlen( $mime_type ) ) { $mime_type = ‘unknown’; }<br />
    return $mime_type;</p>
    <p>}</p>
    <p>function valid_src_mime_type ( $mime_type ) {</p>
    <p> if( preg_match( "/jpg|jpeg|gif|png/i", $mime_type ) ) { return 1; }<br />
    return 0;</p>
    <p>}</p>
    <p>function check_cache ( $cache_dir, $mime_type ) {</p>
    <p> // make sure cache dir exists<br />
    if( !file_exists( $cache_dir ) ) {<br />
    // give 777 permissions so that developer can overwrite<br />
    // files created by web server user<br />
    mkdir( $cache_dir );<br />
    chmod( $cache_dir, 0777 );<br />
    }</p>
    <p> show_cache_file( $cache_dir, $mime_type );</p>
    <p>}</p>
    <p>function show_cache_file ( $cache_dir, $mime_type ) {</p>
    <p> $cache_file = get_cache_file();</p>
    <p> if( file_exists( $cache_dir . ‘/’ . $cache_file ) ) {</p>
    <p> // check for updates<br />
    $if_modified_since = preg_replace( ‘/;.*$/’, ”, $_SERVER["HTTP_IF_MODIFIED_SINCE"] );<br />
    $gmdate_mod = gmdate( ‘D, d M Y H:i:s’, filemtime( $cache_dir . ‘/’ . $cache_file ) );<br />
    if( strstr( $gmdate_mod, ‘GMT’ ) ) {<br />
    $gmdate_mod .= " GMT";<br />
    }</p>
    <p> //error_log("TimThumb: $gmdate_mod == $if_modified_since");</p>
    <p> if ( $if_modified_since == $gmdate_mod ) {<br />
    header( "HTTP/1.1 304 Not Modified" );<br />
    exit;<br />
    }</p>
    <p> // send headers then display image<br />
    header( "Content-Type: " . $mime_type );<br />
    header( "Last-Modified: " . gmdate( ‘D, d M Y H:i:s’, filemtime( $cache_dir . ‘/’ . $cache_file ) . " GMT" ) );<br />
    header( "Content-Length: " . filesize( $cache_dir . ‘/’ . $cache_file ) );<br />
    header( "Cache-Control: max-age=9999, must-revalidate" );<br />
    header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + 9999 ) . "GMT" );<br />
    readfile( $cache_dir . ‘/’ . $cache_file );<br />
    exit;</p>
    <p> }</p>
    <p>}</p>
    <p>function get_cache_file () {</p>
    <p> $request_params = $_REQUEST;<br />
    $cachename = $_REQUEST . $_REQUEST . $_REQUEST . $_REQUEST . $_REQUEST;<br />
    $cache_file = md5( $cachename );<br />
    return $cache_file;</p>
    <p>}</p>
    <p>?&gt;</p>
    <p>Código de la página principal</p>
    <p> &lt;?php krones_get_image(‘thumb’,’featured’,”,”,’item thumbnail’, 95, 0); ?&gt;</p>
    <p>PArece ser que en el servidor windows mkdir, y chmod no sirve, pero al venir asi la plantilla yo me pierdo par modificarlo, un millon de gracias ya solo por leerlo.
    </p>

El foro ‘Themes y Diseño’ está cerrado y no se permiten nuevos debates ni respuestas.

Pin It on Pinterest