Skip to content

Instantly share code, notes, and snippets.

View helisoncruz's full-sized avatar

Helison S. Cruz helisoncruz

View GitHub Profile
@helisoncruz
helisoncruz / select-estados-br.php
Last active December 13, 2021 10:35 — forked from cassiocardoso/select-estados-br
Select com uma lista de todos os estados brasileiros.
<select name="estados-brasil">
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AP">Amapá</option>
<option value="AM">Amazonas</option>
<option value="BA">Bahia</option>
<option value="CE">Ceará</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Espírito Santo</option>
<option value="GO">Goiás</option>
<?php
// Remove acentos e espaços dos arquivos no upload
function custom_sanitize_file_name ( $filename ) {
$filename = remove_accents( $filename );
$filename = strtolower( $filename );
$file_parts = pathinfo( $filename );
$new_filename = sanitize_title( $file_parts['filename'] );
if ( ! empty( $file_parts['extension'] ) ) {
@adilmughal
adilmughal / blog.web.config
Last active September 14, 2023 17:56 — forked from anonymous/blog.web.config
Web.config URL rewriting rules for hosting WordPress (PHP) on IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove html" stopProcessing="true">
<match url="(.*).html$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@guisehn
guisehn / gist:3276302
Last active June 27, 2024 01:40
Validar CNPJ (PHP)
<?php
function validar_cnpj($cnpj)
{
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj);
// Valida tamanho
if (strlen($cnpj) != 14)
return false;
@danilowm
danilowm / gist:1997944
Last active March 26, 2023 22:51
Função de Saudação (bom dia, boa tarde e boa noite)
<?php
function saudacao( $nome = '' ) {
date_default_timezone_set('America/Sao_Paulo');
$hora = date('H');
if( $hora >= 6 && $hora <= 12 )
return 'Bom dia' . (empty($nome) ? '' : ', ' . $nome);
else if ( $hora > 12 && $hora <=18 )
return 'Boa tarde' . (empty($nome) ? '' : ', ' . $nome);
else
return 'Boa noite' . (empty($nome) ? '' : ', ' . $nome);