Código PHP:
Ver original
# Mysql class Cm_mysql{ # Conexion public function Conectar(){ } # Consulta public function Consulta($Consulta){ } # Reg_Num public function Reg_Num($Consulta){ } # Assoc public function Assoc($Consulta){ } # String Search public function Con_Like($Consulta,$Por,$Text){ } } # Convert class Cm_Convert{ # Certifica Valor existente, Convierte a int public function ParseValInt($GetPost){ return $Devuelve; }else{ $Devuelve = 0; return $Devuelve; } } } # --- Paginador class Cm_Paginador{ # --- Configuracion var $Posicion,$Botones,$Base,$Article,$Order,$Mysql,$Query,$Exect,$Cant,$Paginas,$Comming,$Consulta,$Estructura; # --- Mysql public function _Mysql($Mysql,$base,$article,$orden,$Posicion){ # --- Mysql $this->Base = $base; $this->Order = $orden; $this->Article = $article; $this->Posicion = $Posicion; $this->Mysql->Conectar(); $this->Query = "SELECT * FROM ".($this->Base); $this->Exect = $this->Mysql->Consulta($this->Query); # --- Condicionales $this->Cant = $this->Mysql->Reg_Num($this->Exect); $this->Comming = $this->Article*$this->Posicion; $Desde = $this->Posicion*$this->Paginas; # --- Consulta $this->Consulta = $this->Mysql->Consulta($this->Query.' ORDER BY id '.$orden.' LIMIT '.$Desde.' , '.$this->Cant); } # --- Estructura public function _Estructure($estructure){ $this->Estructura = $estructure; } # --- Devolucion public function _Devolucion(){ while($Campo = $this->Mysql->Assoc($this->Consulta)){ $str = $this->Estructura; foreach($Campo as $clave => $valor) { } echo $str; } } # --- Navegacion public function _Navegacion($botones){ # Vars $this->Botones = $botones; if(($this->Botones)>=3){ // next if((($this->Posicion)+1)>1 && ($this->Paginas)>1){ echo '<input type="button" onClick="Paginacion('.($this-Posicion).')" value="next">'; } // numbers for($i = 1;$i<$this->Botones;$i++){ if($i<$this->Paginas){ echo '<input type="button" value="'.$i.'" onClick="Paginacion('.$i.')">'; } } // prev if((($this->Posicion)+1)<($this->Paginas)){ echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+2).')" value="prev">'; } } if(($this->Botones)<=2){ // next if((($this->Posicion+1))>1 && ($this->Paginas)>1){ echo '<input type="button" onClick="Paginacion('.($this->Posicion).')" value="next">'; } // prev if((($this->Posicion)+1)<($this->Paginas)){ echo '<input type="button" onClick="Paginacion('.(($this->Posicion)+2).')" value="prev">'; } } } } # Upload class Cm_Upload{ # Forma de uso # $Upload->UploadConfig($Name,$Path); # $Upload->_Type(); # $Upload->_MinSize(); # $Upload->_MaxSize(); # $Upload->_UploadSave(); # Configuracion protected $_Name = NULL; protected $_Path = NULL; private $_Type = NULL; private $_MinSize = NULL; private $_MaxSize = NULL; # Privates & Condicionales private $_Extencion = NULL; private $states = 0; # Constructor public function UploadConfig($Name,$Path){ $this->_Name = $Name; $this->_Path = $Path; } # Convertor Bytes private function _ConvertBytes($size){ return (int) $size; } $size = (int) $size; switch ($tipo) { case 'g': //Gigabytes $size *= 1073741824; break; case 'm': //Megabytes $size *= 1048576; break; case 'k': //Kilobytes $size *= 1024; break; default : $size = -1; } return $size; } # MinSize public function _MinSize($int){ $this->_MinSize = $this->_ConvertBytes($int); } # MaxSize public function _MaxSize($int){ $this->_MaxSize = $this->_ConvertBytes($int); } # Type public function _Type($array){ } $this->_Type = $array; } # Extencion private function _Extencion(){ } # Validador private function _Validator(){ # MinSize if($this->_MinSize!==NULL && $_FILES[$this->_Name]['size'] < $this->_MinSize){ echo 'El archivo es inferior a los '.$this->_MinSize.' bytes'; $this->states = 0; } # MaxSize if($this->_MaxSize!==NULL && $_FILES[$this->_Name]['size'] > $this->_MaxSize){ echo 'El archivo es mayor a los '.$this->_MaxSize.' bytes'; $this->states = 0; } # Extencion echo 'El archivo no es valido.'; $this->states = 0; } # Escribir Carpeta echo 'Lo sentimos pero no tienes permisos para escribir en '.$this->_Path; $this->states = 0; } $this->states = 1; } # UploadSave public function _UploadSave($name){ # Extencion $this->_Extencion(); # Validador $this->_Validator(); # Verificacion if(move_uploaded_file($_FILES[$this->_Name]['tmp_name'],$this->_Path.'/'.$name.'.'.$this->_Extencion)) echo 1; else echo 0; } } }
Forma de uso
Código PHP:
Ver original
# Upload $Upload->UploadConfig('Foto','Carpeta'); # nombre $_FILES[nombre], Carpeta $Upload->_Type('jpg,png,gif,bmp'); # tipos $Upload->_MinSize('12k'); # k, m, g $Upload->_MaxSize('2m'); # k, m, g $Uploaded = $Upload->_UploadSave('Producto'.$Rand); # Parametro: Nombre # Paginator $Page = $Convert->ParseValInt($_POST['Page']); echo '<div class="Titulos"><h1>Titulo</h1> <h1><img src="../../Nayla/Imagenes/Ui/linedpaper32.png">Pie</h1> <h1><img src="../../Nayla/Imagenes/Ui/gear32.png">Acciones</h1></div>'; $Paginator->_Mysql(new Cm_mysql,'Albums',5,'DESC',$Page); $Paginator->_Estructure('<div class="Album" id="Album_{id}"><h1>{Titulo}</h1><p>{MinPie} ...</p><span><a href="http://laentreviasrock/Albums/{Slug}" title="Acceder al evento (seras redireccionado)" class="Ver"></a><input type="button" title="Agregar fotos al album." class="Agregar"><input type="button" title="Acceder a editar el evento." class="Editar"><input type="button" title="Eliminar el evento" class="Eliminar"></span></div>'); $Paginator->_Devolucion(); $Paginator->_Navegacion(5);
El que sepa adaptarlo el upload de simple a multiple también me serviria mucho, ya estoy medio quemado con el upload :p