Skip to content

Instantly share code, notes, and snippets.

View sergiopvilar's full-sized avatar

Sergio Vilar sergiopvilar

View GitHub Profile
<?php
/**
* App Controller
*
* @link http://book.cakephp.org/pt/view/957/A-classe-AppController
*/
class AppController extends Controller
{
CREATE TABLE `publications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` varchar(120) NOT NULL,
`account_id` int(11) NOT NULL,
`message` text NOT NULL,
`link` text NOT NULL,
`date` datetime NOT NULL,
`status` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
<?php
class Publication extends AppModel {
var $name = 'Publication';
var $validate = array(
'uid' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'account_id' => array(
<?php
class PainelController extends AppController {
var $name = "Painel";
var $uses = null;
function admin_index(){
$this->loadModel('Publication');
$this->set("publication", $this->Publication->find(array('uid'=>$this->Auth->User('id'))));
<?php
class PainelController extends AppController {
var $name = "Painel";
var $components = array('Auth','Session','Cookie');
var $helpers = array('Html','Form','Session','Ajax','Paginator');
var $uses = array('Publication','Account');
function admin_index(){
$this->set('title', 'Painel');
@sergiopvilar
sergiopvilar / app_controller.php
Created September 25, 2011 02:23
Problema com Hash de senhas
/**
* App Controller
*
* @link http://book.cakephp.org/pt/view/957/A-classe-AppController
*/
class AppController extends Controller
{
/**
* Define os componentes disponíveis por padrão
function admin_delete($id = null){
$pub = $this->Publicacao->read(null,$id);
if($pub['Publicacao']['usuario_id']==$this->Auth->user('id')):
$this->Publicacao->set(array(
'id' => $id,
'state' => '0'
));
$this->Publicacao->save($this->data);
$this->Publicacao->deleteAll(array('Publicacao.parent' => $id));
<?php
function admin_delete($id = null){
$pub = $this->Publicacao->read(null,$id);
if($pub['Publicacao']['usuario_id']==$this->Auth->user('id')):
$this->Publicacao->set(array(
'id' => $id,
'state' => '0'
));
$this->Publicacao->save($this->data);
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/svilar/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<?php
query_posts( array( 'posts_per_page' => '5', 'cat' => get_query_var('cat'), 'paged' => get_query_var('paged') ) );
?>