D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
gre
/
Models
/
helper
/
Filename :
GreValCpf.php
back
Copy
<?php namespace App\gre\Models\helper; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of GrsValCpf * * @copyright (c) year, Cesar Szpak - Celke */ class GreValCpf { private $Cpf; private $Resultado; function getResultado() { return $this->Resultado; } public function valCpf($Cpf) { $this->Cpf= $Cpf; if(strlen($this->Cpf) !== 11) { $this->Cpf = preg_filter("/[^0-9]/","", $this->Cpf); } $this->Resultado = $this->Cpf; if(strlen($this->Cpf) != 11 || $this->Cpf == '00000000000' || $this->Cpf == '11111111111' || $this->Cpf == '22222222222' || $this->Cpf == '33333333333' || $this->Cpf == '44444444444' || $this->Cpf == '55555555555' || $this->Cpf == '66666666666' || $this->Cpf == '77777777777' || $this->Cpf == '88888888888' || $this->Cpf == '99999999999'){ $_SESSION['msg'] = "<div class='alert alert-danger'>Erro: Cpf invalido!</div>"; $this->Resultado = false; }else{ for ($t = 9; $t < 11; $t++) { for ($d = 0, $c = 0; $c < $t; $c++) { $d += $this->Cpf{$c} * (($t + 1) - $c); } $d = ((10 * $d) % 11) % 10; if ($this->Cpf{$c} != $d) { $_SESSION['msg'] = "<div class='alert alert-danger'>Erro: CPF Invalido!</div>"; $this->Resultado = false; } } } // $_SESSION['msg'] = "<div class='alert alert-danger'>Erro: Este e-mail já está cadastrado!</div>"; // $this->Resultado = false; } }