Skip to content

Instantly share code, notes, and snippets.

<?php
class Film {
protected $queryCriteria;
public function where($key, $value)
{
$this->queryCriteria .= "Findind the Film by $key:$value\n";
return $this;
}
@mateusgf
mateusgf / routes.php
Created October 22, 2015 17:42
Laravel url validation Security vulnerability
<?php
/**
* Imagine if this came from the request or a database entry editable by the user.
* The Laravel URL validator relies on PHP's filter_var() method which considers
* file:// and php:// valid URLs. The vast majority of Laravel users probably
* expect this validator to only validate http:// & https://
* @link http://www.php.net/manual/en/wrappers.php
*/
Route::get('/', function () {
$url = 'file:///etc/hosts';
<?php
return [
// http://www.cidades.ibge.gov.br/download/mapa_e_municipios.php?uf=ac (Thu May 14 16:30:15 BRT 2015)
'AC' => [
1200013 => 'Acrelândia',
1200054 => 'Assis Brasil',
1200104 => 'Brasiléia',
1200138 => 'Bujari',
1200179 => 'Capixaba',
@mateusgf
mateusgf / CreateCategoriesTable.php
Created August 19, 2014 13:33
Criar migration das categorias
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration {
/**
* Run the migrations.
*
# Apache configuration file
# http://httpd.apache.org/docs/2.2/mod/quickreference.html
# Note: ".htaccess" files are an overhead for each request. This logic should
# be placed in your Apache config whenever possible.
# http://httpd.apache.org/docs/2.2/howto/htaccess.html
# Turning on the rewrite engine is necessary for the following rules and
# features. "+FollowSymLinks" must be enabled for this to work symbolically.
// Adiciona o update na autenticacao!
public function __construct() {
$this->filter('before', 'auth')->only(array('create', 'your_questions', 'edit', 'update'));
}
public function put_update() {
$id = Input::get('question_id');
if (!$this->question_belongs_to_user($id)) {
return Redirect::to_route('your_questions')->with('message', 'Invalid Question');
@layout("layouts.default")
@section('content')
<h1>Edit Your Question</h1>
@if($errors->has())
<ul id="form-errors">
{{ $errors->first('question', '<li>:message</li>') }}
{{ $errors->first('solved', '<li>:message</li>') }}
</ul>
// Nossa ação de editar também deve ser protegida!
public function __construct() {
$this->filter('before', 'auth')->only(array('create', 'your_questions', 'edit'));
}
public function get_edit($id = NULL) {
if (!$this->question_belongs_to_user($id)) {
return Redirect::to_route('your_questions')->with('message', 'Invalid Question');
}
@layout('layouts.default')
@section('content')
<h1>{{ ucfirst($username) }} Questions</h1>
@if(!$questions->results)
<p>You've not posted any questions yet.</p>
@else
<ul>
@foreach($questions->results as $question)
@layout('layouts.default')
@section('content')
<h1>{{ ucfirst($username) }} Questions</h1>
@if(!$questions->results)
<p>You've not posted any questions yet.</p>
@else
<ul>
@foreach($questions->results as $question)