private function setData()
 {
     $this->Data = array_map('strip_tags', $this->Data);
     $this->Data = array_map('trim', $this->Data);
     $this->Data['category_name'] = Check::Name($this->Data['category_title']);
     $this->Data['category_date'] = Check::Data($this->Data['category_date']);
     $this->Data['category_parent'] = $this->Data['category_parent'] == 'null' ? null : $this->Data['category_parent'];
 }
Пример #2
0
 public static function Data($Data)
 {
     self::$Format = explode(' ', $Data);
     self::$Data = explode('/', self::$Format[0]);
     if (empty(self::$Format[1])) {
         self::$Format[1] = date('H:i:s');
     }
     self::$Data = self::$Data[2] . '-' . self::$Data[1] . '-' . self::$Data[0] . ' ' . self::$Format[1];
     return self::$Data;
 }
Пример #3
0
 public static function Image($ImageUrl, $ImageDesc, $ImageW = NULL, $ImageH = NULL)
 {
     self::$Data = 'uploads/' . $ImageUrl;
     if (file_exists(self::$Data) && !is_dir(self::$Data)) {
         $patch = HOME;
         $imagem = self::$Data;
         return "<img src=\"{$patch}/tim.php?src={$patch}/{$imagem}&w={$ImageW}&h={$ImageH}\" alt=\"{$ImageDesc}\" title=\"{$ImageDesc}\"/>";
     } else {
         return FALSE;
     }
 }
 /**
  * ****************************************
  * *********** PRIVATES *******************
  * ****************************************
  */
 private function setDados($Data)
 {
     if (in_array('', $Data)) {
         $this->Result = false;
         $this->Error = ["<b>Erro de insersão:</b> Para efetuar esta ação, preencha todos os campos!", WS_ALERT];
     } else {
         $this->Data = $Data;
         $this->Data = array_map("trim", $this->Data);
         $this->Data = array_map("strip_tags", $this->Data);
         $this->Data['setor_date'] = Check::Data($this->Data['setor_date']);
         return true;
     }
 }
Пример #5
0
 private function setData()
 {
     $Cover = $this->Data['post_cover'];
     $Content = $this->Data['post_content'];
     unset($this->Data['post_cover'], $this->Data['post_content']);
     $this->Data = array_map('strip_tags', $this->Data);
     $this->Data = array_map('trim', $this->Data);
     $this->Data['post_name'] = Check::Name($this->Data['post_title']);
     $this->Data['post_date'] = Check::Data($this->Data['post_date']);
     $this->Data['post_type'] = 'post';
     $this->Data['post_cover'] = $Cover;
     $this->Data['post_content'] = $Content;
     $this->Data['post_cat_parent'] = $this->getCatParent();
 }
Пример #6
0
 private function getStringLog()
 {
     $orderBy = ' ORDER BY ';
     $fields = [];
     $order = [];
     $i = 0;
     $this->Sentence = "SELECT created_date, action, user_id, answer, ip FROM " . DB_LOGS . " WHERE ";
     if ($this->UserId != null) {
         $fields[$i] = "user_id IN (" . implode(", ", $this->UserId) . ")";
         $order[$i++] = "user_id ASC";
     }
     if ($this->StartDate != '') {
         $fields[$i] = "created_date BETWEEN '" . substr(Check::Data($this->StartDate), 0, 10) . "'";
         if ($this->EndDate != '') {
             $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         } else {
             $fields[$i] .= " AND CURRENT_DATE()";
         }
         $order[$i] = "created_date DESC";
         $i++;
     } elseif ($this->StartDate == '' && $this->EndDate != '') {
         $fields[$i] = "created_date BETWEEN '2014-01-01'";
         $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         $order[$i] = "created_date DESC";
         $i++;
     }
     if ($this->Action == 'l') {
         $fields[$i++] = "action LIKE '%' :action1 '%' OR action LIKE '%' :action2 '%'";
     } elseif ($this->Action != 't') {
         $fields[$i++] = "action LIKE '%' :action '%'";
     }
     if ($this->Answer == 'Sucesso') {
         $fields[$i] = "answer LIKE '%' 'Sucesso' '%'";
     } elseif ($this->Answer == 'Erro') {
         $fields[$i] = "answer LIKE '%' 'Erro' '%'";
     }
     if (count($order) > 0) {
         $this->Sentence .= implode(' AND ', $fields) . $orderBy . implode(', ', $order);
     } else {
         $this->Sentence .= implode(' AND ', $fields);
     }
     if ($i == 0) {
         $this->Sentence = str_replace(" WHERE ", "", $this->Sentence);
     }
 }
Пример #7
0
 /**
  * <b>Cria Cardápio:</b> Cria o esqueleto do cardápio com a data desejada para edição das informaçoes posteriores
  * @param array $Data - Atribuitivo
  * @param INT $userId = id do usuário que está criando o registro
  */
 public function ExeCreateCardapio(array $Data, $userId)
 {
     $this->Data = $Data;
     $this->UserId = $userId;
     if (!empty($this->Data['cardapio_dia'])) {
         $readCardapio = new Read();
         $readCardapio->FullRead("SELECT id FROM " . DB_NUTRICAO_CARDAPIO_DIA . " WHERE cardapio_dia = :dia", "dia=" . substr(Check::Data($this->Data['cardapio_dia']), 0, 10));
         if (!$readCardapio->getResult()) {
             $this->Data['cardapio_dia'] = substr(Check::Data($this->Data['cardapio_dia']), 0, 10);
             $this->setCreateDate();
             $this->setCreatedBy();
             $this->Create(DB_NUTRICAO_CARDAPIO_DIA);
         } else {
             $this->Result = false;
             $this->Error = ["Erro ao criar cardápio. Cardápio já existe.", TW_ERROR];
         }
     } else {
         $this->Result = false;
         $this->Error = ["Erro ao criar cardápio. Verifique se preencheu corretamente.", TW_ERROR];
     }
 }
Пример #8
0
 private function getStringFull()
 {
     $orderBy = ' ORDER BY ';
     $fields = [];
     $order = [];
     $i = 0;
     $this->Sentence = "SELECT t1.*, t2.visitante_nome FROM " . DB_VISITAS . " t1 INNER JOIN " . DB_VISITANTES . " t2 ON (t1.visitante_id = t2.visitante_id) WHERE ";
     if ($this->UserId != null) {
         $fields[$i] = "t1.visitante_id IN (" . implode(", ", $this->UserId) . ")";
         $order[$i++] = "t2.visitante_nome ASC";
     }
     if ($this->StartDate != '') {
         $fields[$i] = "t1.visita_data_entrada BETWEEN '" . substr(Check::Data($this->StartDate), 0, 10) . "'";
         if ($this->EndDate != '') {
             $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         } else {
             $fields[$i] .= " AND CURRENT_DATE()";
         }
         $order[$i] = "t1.visita_data_entrada DESC";
         $i++;
     } elseif ($this->StartDate == '' && $this->EndDate != '') {
         $fields[$i] = "t1.visita_data_entrada BETWEEN '2014-01-01'";
         $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         $order[$i] = "t1.visita_data_entrada DESC";
         $i++;
     }
     if (count($order) > 0) {
         $this->Sentence .= implode(' AND ', $fields) . $orderBy . implode(', ', $order);
     } else {
         $this->Sentence .= implode(' AND ', $fields);
     }
 }
Пример #9
0
 /**
  * <b>Imagem Upload:</b> Ao executar este HELPER, ele automaticamente verifica a existencia da imagem na pasta
  * uploads. Se existir retorna a imagem redimensionada!
  * @return HTML = imagem redimencionada!
  */
 public static function Image($ImageUrl, $ImageDesc, $ImageW = null, $ImageH = null)
 {
     self::$Data = $ImageUrl;
     if (file_exists(self::$Data) && !is_dir(self::$Data)) {
         $patch = HOME;
         $imagem = self::$Data;
         return "<img src=\"{$patch}/tim.php?src={$patch}/{$imagem}&w={$ImageW}&h={$ImageH}\" alt=\"{$ImageDesc}\" title=\"{$ImageDesc}\" class='img-thumbnail'/>";
     } else {
         return false;
     }
 }
<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="UTF-8">
        <title>WS PHP - Helpers :: Manipulação e Validação</title>
    </head>
    <body>
        <?php 
require './_app/Config.inc.php';
//$check = new Check();
//var_dump($check);
$Email = 'bruno.gmail.com';
if (Check::Email($Email)) {
    echo 'Válido!<hr>';
} else {
    echo 'Inválido!<hr>';
}
$Name = 'Estamos aprendendo PHP. Veja você como é!';
echo Check::Name($Name) . '<hr>';
$Data = '21/12/2015 20:36:10';
echo Check::Data($Data) . '<hr>';
?>
    </body>
</html>
Пример #11
0
 private function setData()
 {
     if ($this->Data['visita_data_entrada'] !== '') {
         $updateData['visita_data_entrada'] = Check::Data($this->Data['visita_data_entrada'] . ' ' . $this->Data['visita_hora_entrada']);
     }
     if ($this->Data['visita_data_saida'] !== '') {
         $updateData['visita_data_saida'] = Check::Data($this->Data['visita_data_saida'] . ' ' . $this->Data['visita_hora_saida']);
     }
     unset($this->Data['visita_data_entrada']);
     unset($this->Data['visita_hora_entrada']);
     unset($this->Data['visita_data_saida']);
     unset($this->Data['visita_hora_saida']);
     $read = new Read();
     $read->ExeRead(DB_VISITAS, "WHERE visitante_id = :id ORDER BY id DESC LIMIT 1", "id={$this->VisitanteId}");
     if (isset($updateData)) {
         $update = new Update();
         $update->ExeUpdate(DB_VISITAS, $updateData, "WHERE id = :id", "id={$read->getResult()[0]['id']}");
     }
 }
Пример #12
0
 private function setData()
 {
     $cover = !empty($this->Data['user_cover']) ? $this->Data['user_cover'] : NULL;
     unset($this->Data['user_cover']);
     $this->Data = array_map('strip_tags', $this->Data);
     $this->Data = array_map('trim', $this->Data);
     $this->Data['user_birthday'] = Check::Data($this->Data['user_birthday']);
     $this->Data['user_cover'] = !empty($cover) ? $cover : NULL;
     if (!Check::Email($this->Data['user_email'])) {
         $this->Error = ['<b>Oppss, email Inválido</b>, por favor preencha corretamente o campo.', WS_ALERT];
         $this->Data['user_email'] = null;
         $this->Result = null;
     }
     //        $this->Data['user_level'] = 5;
     $this->Data['user_status'] = 1;
     $this->Data['user_registration'] = date('Y-m-d H:i:s', time());
     $this->Data['user_lastupdate'] = date('Y-m-d H:i:s', time());
     if (!empty($this->Data['user_password'])) {
         $this->Data['user_password'] = md5($this->Data['user_password']);
     } else {
         unset($this->Data['user_password']);
     }
 }
Пример #13
0
 private function getStringFull()
 {
     $orderBy = ' ORDER BY ';
     $groupBy = " GROUP BY t1.prod_name, t3.reg_action ";
     $fields = [];
     $order = [];
     $i = 0;
     $this->Sentence = "SELECT t1.prod_name, t1.prod_unidade, t3.reg_quantidade, t2.cat_name, t3.reg_action, t3.reg_data, t3.reg_motivo, t3.reg_descricao FROM " . DB_PRODUTOS . " t1 INNER JOIN " . DB_PRODUTOS_CATEGORIAS . " t2 ON (t1.prod_categoria = t2.cat_id) INNER JOIN " . DB_PRODUTOS_REGISTRO . " t3 ON (t1.prod_id = t3.prod_id) WHERE ";
     $this->SumSentence = "SELECT t1.prod_name, t1.prod_quantidade, t1.prod_unidade, t2.cat_name, SUM(t3.reg_quantidade) AS soma, t3.reg_action FROM " . DB_PRODUTOS . " t1 INNER JOIN " . DB_PRODUTOS_CATEGORIAS . " t2 ON (t1.prod_categoria = t2.cat_id) INNER JOIN " . DB_PRODUTOS_REGISTRO . " t3 ON (t1.prod_id = t3.prod_id) WHERE ";
     if ($this->Action === 'u') {
         $fields[$i++] = "t3.reg_action = 'remove'";
     } elseif ($this->Action === 'r') {
         $fields[$i++] = "t3.reg_action = 'add'";
     }
     if ($this->ProdId != null) {
         $fields[$i++] = "t1.prod_id IN (" . implode(", ", $this->ProdId) . ")";
     }
     if ($this->CatId != null) {
         $fields[$i++] = "t2.cat_id IN (" . implode(", ", $this->CatId) . ")";
     }
     if ($this->StartDate != '') {
         $fields[$i] = "t3.reg_data BETWEEN '" . substr(Check::Data($this->StartDate), 0, 10) . "'";
         if ($this->EndDate != '') {
             $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         } else {
             $fields[$i] .= " AND CURRENT_DATE()";
         }
         $order[$i] = "t3.reg_data DESC";
         $i++;
     } elseif ($this->StartDate == '' && $this->EndDate != '') {
         $fields[$i] = "t3.reg_data BETWEEN '2014-01-01'";
         $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         $order[$i] = "t3.reg_data DESC";
         $i++;
     }
     if (count($order) > 0) {
         $this->Sentence .= implode(' AND ', $fields) . $orderBy . implode(', ', $order);
         $this->SumSentence .= implode(' AND ', $fields) . $groupBy . $orderBy . implode(', ', $order);
     } else {
         $this->Sentence .= implode(' AND ', $fields);
         $this->SumSentence .= implode(' AND ', $fields) . $groupBy;
     }
     if ($this->StartDate == '' and $this->EndDate == '' and $this->ProdId === null and $this->Action !== 'u' and $this->Action !== 'r' and $this->CatId === null) {
         $this->Sentence = str_replace(" WHERE ", "", $this->Sentence);
         $this->SumSentence = str_replace(" WHERE ", "", $this->SumSentence);
     }
 }
 $Upload = new Upload();
 $Upload->File($file);
 $filename = DOCUMENT_ROOT . NAME . "/uploads/" . $Upload->getResult();
 if (file_exists($filename)) {
     $FileRead = fopen($filename, "r");
     $Read = new Controle('sft_particular');
     $Read->truncate();
     $Erros = [];
     while (!feof($FileRead)) {
         $file = fgets($FileRead);
         $Linha = !empty($file) ? explode(";", utf8_encode($file)) : null;
         if (is_array($Linha) && count($Linha) == 12) {
             $Erro = null;
             $Objeto = array();
             $Objeto['part_os'] = $Linha[0];
             $Objeto['part_date'] = Check::Data($Linha[1]);
             $Objeto['part_nm_paciente'] = $Linha[4];
             $Objeto['part_vl_liquido'] = Check::toFloat($Linha[9]);
             $Objeto['part_vl_pago'] = Check::toFloat($Linha[10]);
             $Objeto['part_vl_debito'] = Check::toFloat($Linha[11]);
             $Linha[2] = $Linha[2] == '0' ? "418 - Sistema" : $Linha[2];
             $findUser = explode(" - ", $Linha[2])[1];
             $atendente = FindUser($findUser);
             $findCode = explode('-', $Linha[0])[0];
             $unidade = FindCod($findCode);
             if (!$atendente) {
                 $Erro = true;
                 $Objeto['error'] = 'Não encontrado atendente: ' . $findUser;
                 $Erros[] = $Objeto;
             } else {
                 $Objeto['aten_id'] = $atendente;
Пример #15
0
 public static function CheckImage($ImageUrl, $ImageDesc, $ImageW = null, $ImageH = null)
 {
     // Caminho da Imagem
     self::$Data = $ImageUrl;
     // Verifica se a imagem existe e retorna ela redimensionada
     if (file_exists(self::$Data) && !is_dir(self::$Data)) {
         $patch = BASE;
         $image = self::$Data;
         return "<img src=\"{$patch}/tim.php?src={$patch}/{$image}&w={$ImageW}&h={$ImageH}\" alt=\"{$ImageDesc}\" title=\"{$ImageDesc}\"/>";
     } else {
         return false;
     }
 }
Пример #16
0
 /**
  * Calcula a idade a partir da data de nascimento
  * @param STRING $data - data de nascimento
  * @return INT - a idade
  */
 public function getIdade($data)
 {
     $data = substr(Check::Data($data), 0, 10);
     $nascimento = new DateTime($data);
     $idade = $nascimento->diff(new DateTime(date('Y-m-d')));
     return $idade->format('%Y');
 }
Пример #17
0
 /**
  * Calcula a idade a partir da data de nascimento
  * @param STRING $time - data de nascimento
  * @return INT - a idade
  */
 public static function getIdade($time)
 {
     if ($time == '') {
         return null;
     }
     $data = substr(Check::Data($time), 0, 10);
     $nascimento = new DateTime($data);
     $idade = $nascimento->diff(new DateTime(date('Y-m-d')));
     return $idade->format('%Y');
 }
 /**
  * ****************************************
  * *************** PRIVATES ***************
  * ****************************************
  */
 private function setData()
 {
     $Content = $this->Data['perfil_content'];
     unset($this->Data['perfil_content']);
     $this->Data = array_map('strip_tags', $this->Data);
     $this->Data = array_map('trim', $this->Data);
     $this->Data['perfil_name'] = Check::Name($this->Data['perfil_title']);
     $this->Data['perfil_date'] = Check::Data($this->Data['perfil_date']);
     $this->Data['perfil_content'] = $Content;
 }
Пример #19
0
 private function setData()
 {
     $this->Data['reg_data'] = substr(Check::Data($this->Data['reg_data']), 0, 10);
 }
Пример #20
0
 private function getStringFull()
 {
     $orderBy = ' ORDER BY t1.cardapio_dia ASC';
     $fields = [];
     $i = 0;
     $this->Sentence = "SELECT t1.cardapio_dia, t2.cardapio_porcao, t3.nutri_name, t3.nutri_quantidade, t3.nutri_medida, t3.nutri_tabela, t4.cat_name FROM " . DB_NUTRICAO_CARDAPIO_DIA . " t1 INNER JOIN " . DB_NUTRICAO_CARDAPIO . " t2 ON (t1.id = t2.cardapio_id) INNER JOIN " . DB_NUTRICAO . " t3 ON (t2.nutri_id = t3.nutri_id) INNER JOIN " . DB_NUTRICAO_CATEGORIAS . " t4 ON (t3.nutri_cat = t4.cat_id) WHERE ";
     if ($this->NutriId != null) {
         $fields[$i++] = "t2.nutri_id IN (" . implode(", ", $this->NutriId) . ")";
     }
     if ($this->StartDate != '') {
         $fields[$i] = "t1.cardapio_dia BETWEEN '" . substr(Check::Data($this->StartDate), 0, 10) . "'";
         if ($this->EndDate != '') {
             $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         } else {
             $fields[$i] .= " AND CURRENT_DATE()";
         }
         $i++;
     } elseif ($this->StartDate == '' && $this->EndDate != '') {
         $fields[$i] = "t1.cardapio_dia BETWEEN '2014-01-01'";
         $fields[$i] .= " AND '" . substr(Check::Data($this->EndDate), 0, 10) . "'";
         $i++;
     }
     $this->Sentence .= implode(' AND ', $fields) . $orderBy;
     if ($this->StartDate == '' and $this->EndDate == '' and $this->NutriId === null) {
         $this->Sentence = str_replace(" WHERE ", "", $this->Sentence);
     }
 }
Пример #21
0
 private function setData()
 {
     $i = 0;
     foreach ($this->Data as $key => $value) {
         if (strpos($key, 'semana_') !== false) {
             $buffer[$i++] = $value;
             unset($this->Data[$key]);
         }
     }
     $this->Data['turma_semana'] = implode(", ", $buffer);
     $this->Data['curso_id'] = $this->CursoId;
     $this->Data['turma_data_inicio'] = Check::Data($this->Data['turma_data_inicio']);
     $this->Data['turma_data_termino'] = Check::Data($this->Data['turma_data_termino']);
 }
Пример #22
0
 /**
  * ****************************************
  * *************** PRIVATES ***************
  * ****************************************
  */
 private function setData()
 {
     $this->Data = array_map('strip_tags', $this->Data);
     $this->Data = array_map('trim', $this->Data);
     $this->Data['youtube_date'] = Check::Data($this->Data['youtube_date']);
 }