Skip to content

Instantly share code, notes, and snippets.

@hugodias
hugodias / .htaccess
Created August 27, 2015 19:17
Site em Manutenção
RewriteEngine On
RewriteRule !^manutencao.php$ /manutencao.php [R=302,L]
@hugodias
hugodias / .htaccess
Created February 5, 2014 15:52
Wordpress first htaccess for SEO
Options -Indexes
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@hugodias
hugodias / robots.txt
Created February 5, 2014 15:52
Robots for wordpress
User-agent: *
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /wp-content/themes
Disallow: /wp-includes/js
Disallow: /trackback
Disallow: /category/*/*
Disallow: */trackback
<?php
require_once('recaptchalib.php');
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "6Ld6m-8SAAAAAGNrxIf7Dn6rt_6yfjcMO40Zxs_G";
$privatekey = "6Ld6m-8SAAAAAOLkKK6T8j4K9YntpGA0f-xszASW";
$token = 'VopcWwRNfnCzUhmgaXM7sbQBurqixY59yFvt1J8ZkjeD2AK4SH36TPLdEG';
$referer = "http://www.verscontabilidade.com.br";
$url_back = "http://www.verscontabilidade.com.br/obrigado";
@hugodias
hugodias / gist:9662954
Created March 20, 2014 12:42
Error handling in CakePHP 2.0+
Exception handling in cakephp 2.0+
Now, I discribe step by step how to handle error 400,403,404,405,501 in cakephp2.0+
Step-1 : Update /app/Config/core.php
open /app/Config/core.php, and find the following:
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'ExceptionRenderer',
@hugodias
hugodias / CategoriesController.php
Last active August 29, 2015 13:58
Cakephp Controller Scaffold
<?php
class CategoriesController extends GerenciadorAppController{
public $components = array('Error');
public function index(){
$this->set('categories', $this->Category->find('all'));
}
public function add(){
$this->set('label', 'Cadastrar categoria');
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
<?php
if (App::environment('production')) {
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));
$_ENV['DATABASE_HOST'] = $url["host"];
$_ENV['DATABASE_USERNAME'] = $url["user"];
$_ENV['DATABASE_PASSWORD'] = $url["pass"];
$_ENV['DATABASE_DATABASE'] = substr($url["path"], 1);
}
<?php
# ....
$env = $app->detectEnvironment(array(
'local' => array('homestead'),
));
#....
@hugodias
hugodias / AppModel.php
Created May 30, 2014 14:27
Converting all created & modified fields date to BR format in CakePHP for all models
<?php
/**
* Application model for Cake.
*
* This file is application-wide model file. You can put all
* application-wide model-related methods here.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)