PHPZona

Espacio dedicado a PHP. En este espacio encontrarás enlaces, tutoriales, código fuente, etc.


Contactenos

Contactese con nosotros, lo estaremos atendiendo a la brevedad.
Nuestro nuevo servicio de atención al Cliente "cubre" en estos momentos las ciudades de Lima, Ilo, Arequipa, Ayacucho, Moquegua.


Servicios

Tenemos todo lo que usted necesita.
Soporte On Line 24 x 7, a la medida de su empresa y/o infraestructura. Nuestros servicios, comprende la instalación, configuración, y puesta a punto según los requerimientos y la infraestructura de su Corporación.


Network tools

Estas son algunas herramientas que generalmente se utilizan para administrar y acceder a una Red.

These are some tools that are used generally to administer and to accede to a Network.
:)


Peruviansoft PHP Group
About Peru in PHP-Classes
Inicio de PHPZona

PHP Zona, es un espacio para dar a conocer información referente al famoso lenguaje de programación PHP, el cual ya tiene ganado un sitio dentro de la Internet. Poco a poco iremos publicando información que de seguro les será de mucha utilidad.

Imagen de formato

A lo largo del tiempo hemos usado PHP como lenguaje de programación para el desarrollo de nuestras aplicaciones, dentro de las etapas de la construción de código hemos obtenido experiencias sobre el uso y control de php.

Dentro de este espacio (llámese PHPZona) , iremos publicando algunos tips, manuales, concejos, y tutoriales. Por otro lado haremos promoción de aplicaciones desarrolladas en PHP, sus versiones y novedades.


Imagen de formato
PHP Encode Image

Programa que me permite crear una clase PHP con imagenes gif codificadas y contenidas en la misma clase. SE podría usar clase cuando tenemos imagenes GIF de poco peso y queremos olvidarnos de ubicarlos en una carpeta y subirlos a nuestro host.

Versión que utiliza un filtro de archivos llamando a un comando externo bash de Linux.

<?php
$script_img ='';
$script_img .='<?php'."\n";
$script_img .= "//  image_encode.php"."\n";
$script_img .= "//  Author: Angel Alberto Briceno Obregon (abriceno@peruviansoft.com)"."\n";
$script_img .= "//  This program is free software; you can redistribute it and/or modify"."\n";
$script_img .= "//  it under the terms of the GNU General Public License as published by"."\n";
$script_img .= "//  the Free Software Foundation; either version 2 of the License, or"."\n";
$script_img .= "//  (at your option) any later version."."\n";
$script_img .= "//"."\n";
$script_img .= "//  This program is distributed in the hope that it will be useful,"."\n";
$script_img .= "//  but WITHOUT ANY WARRANTY; without even the implied warranty of"."\n";
$script_img .= "//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"."\n";
$script_img .= "//  GNU General Public License for more details."."\n";
$script_img .= "//"."\n";
$script_img .= "//  You should have received a copy of the GNU General Public License"."\n";
$script_img .= "//  along with this program; if not, write to the Free Software"."\n";
$script_img .= "//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."."\n";
$script_img .= "//"."\n";
$script_img .='class img_ram {'."\n";
$script_img .='var $arrimg;'."\n";
$script_img .='function img_ram() {'."\n";
$script_img .='$this->arrimg=array(';
//$ultima_linea = exec("ls -l|awk '{print $9}'|grep '.gif$'", $retval);
$dh  = opendir('./');
while (false !== ($nombre_archivo = readdir($dh))) {
    if(substr($nombre_archivo, 0, -4) == '.gif')
        $retval[] = $nombre_archivo;
}

$num_images=count($retval);
foreach($retval as $key => $value) {
    if ( $key > 0 and !empty($value) and $key < $num_images) {
        $script_img .= ","."\n";
    }
    $fp = fopen($value,'r');
    $linea='';
    while (!feof($fp)) {
            $linea .=fgets($fp,6000);
    }
    $cadena=chunk_split(base64_encode($linea));
    fclose($fp);
    $otro_gif = $value.'.tmp';
    $fp2=fopen($otro_gif,'w');
    fwrite($fp2,$cadena);
    fclose($fp2);
    $fp3=fopen($otro_gif,'r');
    $script_img .= "\"".$value."\"=>"."\n";
    $contador=1;
    while (!feof($fp3)) {
        $linea2 = fgets($fp3,6000);
        if ( $contador == 1) {
            $script_img .= "\"".$linea2."\"";
        }
        if ( $contador > 1 and !empty($linea2) ) {
            $script_img .= "."."\n"."\"".$linea2."\"";
        }
        $contador += $contador;
    }
}
$script_img .= ');'."\n";
$script_img .= '}'."\n";
$script_img .= "\n";
$script_img .= 'function show_img($img_idx) {'."\n";
$script_img .= '    header("Content-type: image/gif");'."\n";
$script_img .= '    header("Cache-control: public");'."\n";
$script_img .= '    header("Expires: ".date("r",mktime(0,0,0,1,1,2030)));'."\n";
$script_img .= '    header("Cache-control: max-age=".(60*60*24*7));'."\n";
$script_img .= '    header("Last-Modified: ".date("r",filemtime(__FILE__)));'."\n";
$script_img .= '    echo base64_decode($this->arrimg[$img_idx]);'."\n";
$script_img .= '}'."\n";
$script_img .= '}'."\n";
$script_img .= '?>';
fclose($fp3);
$fp4=fopen('php.gif.php','w');
fwrite($fp4,$script_img);
fclose($fp4);
?>

Mismo código usando un filtro de archivos usando funciones de mismo PHP. Gracias a Victor Anaya por su colaboración.

<?php
$script_img ='';
$script_img .='<?php'."\n";
$script_img .= "//  image_encode.php"."\n";
$script_img .= "//  Author: Angel Alberto Briceno Obregon (abriceno@peruviansoft.com)"."\n";
$script_img .= "//  This program is free software; you can redistribute it and/or modify"."\n";
$script_img .= "//  it under the terms of the GNU General Public License as published by"."\n";
$script_img .= "//  the Free Software Foundation; either version 2 of the License, or"."\n";
$script_img .= "//  (at your option) any later version."."\n";
$script_img .= "//"."\n";
$script_img .= "//  This program is distributed in the hope that it will be useful,"."\n";
$script_img .= "//  but WITHOUT ANY WARRANTY; without even the implied warranty of"."\n";
$script_img .= "//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"."\n";
$script_img .= "//  GNU General Public License for more details."."\n";
$script_img .= "//"."\n";
$script_img .= "//  You should have received a copy of the GNU General Public License"."\n";
$script_img .= "//  along with this program; if not, write to the Free Software"."\n";
$script_img .= "//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."."\n";
$script_img .= "//"."\n";
$script_img .='class img_ram {'."\n";
$script_img .='var $arrimg;'."\n";
$script_img .='function img_ram() {'."\n";
$script_img .='$this->arrimg=array(';
//$ultima_linea = exec("ls -l|awk '{print $9}'|grep '.gif$'", $retval);
$dh  = opendir('./');
while (false !== ($nombre_archivo = readdir($dh))) {
    if(substr($nombre_archivo, 0, -4) == '.gif')
        $retval[] = $nombre_archivo;
}

$num_images=count($retval);
foreach($retval as $key => $value) {
    if ( $key > 0 and !empty($value) and $key < $num_images) {
        $script_img .= ","."\n";
    }
    $fp = fopen($value,'r');
    $linea='';
    while (!feof($fp)) {
            $linea .=fgets($fp,6000);
    }
    $cadena=chunk_split(base64_encode($linea));
    fclose($fp);
    $otro_gif = $value.'.tmp';
    $fp2=fopen($otro_gif,'w');
    fwrite($fp2,$cadena);
    fclose($fp2);
    $fp3=fopen($otro_gif,'r');
    $script_img .= "\"".$value."\"=>"."\n";
    $contador=1;
    while (!feof($fp3)) {
        $linea2 = fgets($fp3,6000);
        if ( $contador == 1) {
            $script_img .= "\"".$linea2."\"";
        }
        if ( $contador > 1 and !empty($linea2) ) {
            $script_img .= "."."\n"."\"".$linea2."\"";
        }
        $contador += $contador;
    }
}
$script_img .= ');'."\n";
$script_img .= '}'."\n";
$script_img .= "\n";
$script_img .= 'function show_img($img_idx) {'."\n";
$script_img .= '    header("Content-type: image/gif");'."\n";
$script_img .= '    header("Cache-control: public");'."\n";
$script_img .= '    header("Expires: ".date("r",mktime(0,0,0,1,1,2030)));'."\n";
$script_img .= '    header("Cache-control: max-age=".(60*60*24*7));'."\n";
$script_img .= '    header("Last-Modified: ".date("r",filemtime(__FILE__)));'."\n";
$script_img .= '    echo base64_decode($this->arrimg[$img_idx]);'."\n";
$script_img .= '}'."\n";
$script_img .= '}'."\n";
$script_img .= '?>';
fclose($fp3);
$fp4=fopen('php.gif.php','w');
fwrite($fp4,$script_img);
fclose($fp4);
?>


 

Contador
Copyright © 2003-2008 www.peruviansoft.com - Todos los derechos reservados

Valid HTML 4.01 Transitional