Foros del Web » Programando para Internet » PHP » Frameworks y PHP orientado a objetos »

clase descargas

Estas en el tema de clase descargas en el foro de Frameworks y PHP orientado a objetos en Foros del Web. Hola me base en un ejemplo que encontre en la red ya pude sacer mis documentos a descargar pero ahora tengo una gran duda como ...
  #1 (permalink)  
Antiguo 08/03/2009, 20:50
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Mensajes: 421
Antigüedad: 15 años, 4 meses
Puntos: 0
clase descargas

Hola me base en un ejemplo que encontre en la red ya pude sacer mis documentos a descargar pero ahora tengo una gran duda como podria para poner comentarios sin usar base de datos esta es la clase
Código php:
Ver original
  1. <?php
  2.  class download {
  3.     var $files = 1;
  4.     var $fileTypes = array();
  5.     var $mimeTypes = array();
  6.     function download($path) {
  7.         $this->path = $path;
  8.         $this->fileTypes = array('jpeg', 'jpg', 'ico', 'png', 'gif', 'bmp');
  9.         $this->ini = dirname(__FILE__)."/mime-type.ini";
  10.         $this->mimeTypes = parse_ini_file($this->ini, false);
  11.     }
  12.     function getMimetype() {
  13.         return (!$this->checkMimetype()) ? 'application/force-download' : $this->mimeTypes[$this->fext];
  14.     }
  15.     function checkMimetype() {
  16.         return isset($this->mimeTypes[$this->fext]) ? true : false;
  17.     }
  18.     function get($req) {
  19.         preg_match("/^[\.\-\s#_a-zA-Z\d]+$/", $req, $file);
  20.         $this->file = $this->path.$file[0];
  21.         if(!file_exists($this->file)) die("Wrong File Name");
  22.          $this->parts = pathinfo($this->file);
  23.         $this->fname = $this->parts['basename'];
  24.         $this->fext = strtolower($this->parts['extension']);
  25.         $this->fsize = filesize($this->file);
  26.         $this->type = $this->getMimetype();
  27.         $this->_send();
  28.     }
  29.     function _send() {
  30.         if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');
  31.         header("Pragma: public");
  32.         header("Expires: 0");
  33.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  34.         header("Cache-Control: private",false);
  35.         header("Content-type: ".$this->type."");
  36.         header("Content-Disposition: attachment; filename=\"".$this->fname."\"");
  37.         header("Content-Transfer-Encoding: Binary");
  38.             header("Content-length: ".$this->fsize."");
  39.         set_time_limit(0);
  40.         readfile($this->file);
  41.         exit();
  42.     }
  43.     function _type($file) {
  44.         $dotpos = strrpos($file, ".");
  45.         return strtolower(substr($file, $dotpos + 1));
  46.     }
  47.     function select($name = 'files', $label = '', $curr = '', $chars = 30) {
  48.         if ($handle = opendir($this->path)) {
  49.         $select = '<form method="post" action="'.$_SERVER['PHP_SELF'].'">'."\n";
  50.             $select .= ($label != '') ? '<label for="'.$name.'">'.$label.'</label>'."\n" : '';
  51.             $select .= '<select name="'.$name.'" id="'.$name.'">'."\n";
  52.         $curr = (isset($_REQUEST[$name])) ? $_REQUEST[$name] : $curr;
  53.         $select .= ($curr == "") ? "  <option value=\"\" selected>...\n" : "<option value=\"\">...\n";
  54.             while (false !== ($file = readdir($handle))) {
  55.                 $array[] = $file;
  56.             }
  57.             closedir($handle);
  58.             sort($array);
  59.             foreach ($array as $val) {
  60.             $ext = $this->_type($val);
  61.                     if (is_file($this->path.$val) || array_search($ext, $this->fileTypes) !== false) {
  62.                     $select .= '    <option value="'.$val.'">';
  63.                     $select .= (strlen($val) > $chars) ? substr($val, 0, $chars).'..'."</option>\n" : $val."</option>\n";
  64.                     $this->files++;
  65.                 }
  66.             }
  67.             $select .= '</select>' ."\n";
  68.         $select .= '<input type="submit" name="download" value="Download" />'."\n";
  69.         $select .= '</form>'."\n";
  70.         }
  71.         return ($this->files == 0) ? "No files!" : $select;
  72.       }
  73.     }
  74. ?>
  #2 (permalink)  
Antiguo 08/03/2009, 21:36
 
Fecha de Ingreso: diciembre-2006
Mensajes: 60
Antigüedad: 17 años, 4 meses
Puntos: 0
Respuesta: clase descargas

podrias usar archivos de texto y agregar una función que los cargue:
Código PHP:
function mostrar_comentarios(){
$maximo_comentarios='10';
$i=0;
while(
$i<=$maximo_comentarios){
$comentario='comentario'.$i.'.txt'//asi tendremos comentarios con numeros del 1 al 10
if(file_exists($comentario)){
$gestor=fopen($comentario,'r');
$con=fread($gestor);
fclose($gestor);
return 
$con;
}
}

ojala te sirva, cualquier duda postea, saludos ^^
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:25.