Skip to content

Instantly share code, notes, and snippets.

@bytefade
bytefade / multiexplode.php
Created March 25, 2015 16:29
Multi explode PHP
<?php
function multiexplode ($delimiters,$string) {
$ready = str_replace($delimiters, $delimiters[0], $string);
$launch = explode($delimiters[0], $ready);
return $launch;
}
// uso
$exploded = multiexplode(array(",",".","|",":"),$text);
@bytefade
bytefade / except.php
Created March 11, 2015 14:28
Except files
$except = array("rar", "zip", "mp3", "mp4", "mp3", "mov", "flv", "wmv", "swf", "png", "gif", "jpg", "bmp", "avi");
$imp = implode('|', $except);
foreach($files as $file)
{
if(preg_match('/^.*\.('.$imp.')$/i', $file))
echo $file;
}
@bytefade
bytefade / composeUso.md
Last active August 29, 2015 14:16
Composer uso básico do básico
1 - Instalando via cURL:
curl -sS https://getcomposer.org/installer | php

Instalando via PHP:
php -r “readfile(‘https://getcomposer.org/installer’);” | php

*dentro do diretorio do projeto

2 - Ter o composer.json 
<?php # -*- coding: utf-8 -*-
// function remove_accents()
/**
* Unaccent the input string string. An example string like `ÀØėÿᾜὨζὅБю`
* will be translated to `AOeyIOzoBY`. More complete than :
* strtr( (string)$str,
* "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
* "aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn" );
*
@bytefade
bytefade / messageSuccessSession.php
Created January 31, 2015 14:21
Mensagem de sucesso com session
<?php
session_start();
//The second parameter on print_r returns the result to a variable rather than displaying it
$RequestSignature = md5($_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'].print_r($_POST, true));
if ($_SESSION['LastRequest'] == $RequestSignature)
{
echo 'This is a refresh.';
}
else
@bytefade
bytefade / ano.php
Created December 29, 2014 16:23
ano
// --Retorna ano para select
function ano_select(){
//The 60 value here is the amount of years to go back
$year = date("Y") - 100;
//The 60 value here is the amount of years to go forward
//because i went back 50 years, i'm going forward 50 years so the dropdown will always have the current year.
for ($i = 0; $i <= 82; ++$i)
{
$year2[] = $year;
@bytefade
bytefade / ExemploBuscaCep.js
Created December 22, 2014 18:56
Busca Cep Via Correios Mobile
function buscarCep (cep) {
cep = cep.replace(/\D/g, "");
var end = '';
var path = path_site();
// console.log("p" + path);
// -- a busca
$.getJSON( path + '/cep.php?cep='+cep,
function (dados){
@bytefade
bytefade / erroAddDomainSuperdominios
Created December 19, 2014 16:02
alterar dns, erro
Fatal error: Uncaught exception 'Exception' with message 'Falha ao alterar servidores DNS código 2308: mensagem 'Violação na política de gerência
Fatal error: Uncaught exception 'Exception' with message 'Falha ao alterar servidores DNS código 2308: mensagem 'Violação na política de gerência de dados' motivo 'Domínio desconhecido'' in /home/super/public_html/home/modules/registrars/registrobr/RegistroEPP/RegistroEPPDomain.class.php:108 Stack trace: #0 /home/super/public_html/home/modules/registrars/registrobr/registrobr.php(324): RegistroEPPDomain->updateNameServers(Array, Array) #1 /home/super/public_html/home/includes/classes/WHMCS/Module.php(0): registrobr_SaveNameservers(Array) #2 /home/super/public_html/home/includes/classes/WHMCS/Module/Registrar.php(0): WHMCS_Module->call() #3 /home/super/public_html/home/includes/classes/WHMCS/Domains.php(0): WHMCS_Module_Registrar->call() #4 /home/super/public_html/home/clientarea.php(0): WHMCS_Domains->moduleCall() #5 {main} Next exception 'Exception' with message
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="valor">Qual o valor senhor?</label>
<input id="valor" type="text" name="valor">
@bytefade
bytefade / sqlin.sql
Created November 6, 2014 19:26
SQL IN
SELECT * FROM table where id IN('74', '75', '76', '77', '78', '79', '80', '81')