Home Files
Adminer
Execute Command
PHP Eval
Symlink
File Upload
Owner :
www-data
PHP Version
8.1.8
Disk Space
203.89 GB
Server Addr
171.9.3.2
Your IP
171.9.3.1
Edit File
File:
<?php class Datatable { // TRATAMENTO DE FORMATOS DE CAMPOS VIA SQL. function addCampos($array) { $i = 0; $campos = null; foreach ($array as $key => $value) { $i++; switch ($value) { case 'DATE': $campos[] = "DATE_FORMAT(".$key.",'%d/%m/%Y') as Campo".$i; break; case 'NUMBER': $campos[] = "FORMAT(".$key.",2,'de_DE') as Campo".$i; break; case 'NULL': $campos[] = "NULL as Campo".$i; break; default: $campos[] = $key." as Campo".$i; break; } } return $campos; } // QUERY PARA LISTAGENS SIMPLES function Query ($sql,$smarty,$paginar,$campos_select = null,$query, $filter = null, $fields = null, $limit = null, $campos_consulta ,$arrayValue = null,$debug = null) { if ($campos_select == null) { $select = "SELECT SQL_CALC_FOUND_ROWS * "; } else { $select = "SELECT SQL_CALC_FOUND_ROWS ".implode(", ",$this->addCampos($campos_select)); } if ($filter != '') { $arrayValue[':filter'] = "%".$filter."%"; if ($fields != 'Todos' and in_array($fields,$campos_consulta) == false) { $filtered[] = $campos_consulta[$fields]['campo']." LIKE :filter"; } else { foreach ($campos_consulta as $key => $value) { $campos_consulta_im[] = $value['campo']." LIKE :filter "; } $filtered[] = "(". implode(" OR ",$campos_consulta_im) .")"; } $filtered = " AND ".implode(" AND ",$filtered); } $consulta = $select.$query.$filtered.$limit; if ($debug == 1) { var_dump($consulta); } $qr_list = $sql->consulta($consulta,$arrayValue); $paginar->num_total = $this->Contar($sql); $smarty->assign('filtered', $filter); $smarty->assign('filter', $filter); $smarty->assign('fields', $fields); $smarty->assign('campos_consulta', $campos_consulta); $smarty->assign('num_total', $paginar->num_total); $smarty->assign('paginar', $paginar->paginar()); $smarty->assign('list', $qr_list->fetchAll(PDO::FETCH_OBJ)); return $paginar->num_total; } // QUERY PARA LISTAGENS SIMPLES function QueryExport($sql,$smarty,$paginar,$campos_select = null,$query, $filter = null, $fields = null, $limit = null, $campos_consulta ,$arrayValue = null,$debug = null) { if ($campos_select == null) { $select = "SELECT SQL_CALC_FOUND_ROWS * "; } else { $select = "SELECT SQL_CALC_FOUND_ROWS ".implode(", ",$this->addCampos($campos_select)); } $consulta = $select.$query.$filtered; if ($debug == 1) { var_dump($consulta); } $qr_list = $sql->consulta($consulta,$arrayValue); $paginar->num_total = $this->Contar($sql); $smarty->assign('filtered', $filter); $smarty->assign('num_total', $paginar->num_total); $smarty->assign('list', $qr_list->fetchAll(PDO::FETCH_OBJ)); return $paginar->num_total; } function Contar ($sql) { $qrtotal = $sql->consulta("SELECT FOUND_ROWS() AS CONTAR"); $totalregistros = $sql->resultado($qrtotal); return $totalregistros['CONTAR']; } }