Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2. class homeController extends Controller {
  3.  
  4.     public function __construct() {
  5.         parent::__construct();
  6.        
  7.         $u = new usuarios();
  8.        
  9.         if(!$u->isLogged()){ //Se não estiver logado
  10.            
  11.             header("Location: /twitter/login");
  12.         }  
  13.     }
  14.         public function index() {
  15.         $dados = array(
  16.             'nome' => ''
  17.         );
  18.        
  19.         $u = new usuarios($_SESSION['twlog']);
  20.         $dados['nome'] = $u->getNome();
  21.            //Debugando print_r($dados);
  22.         $dados['qt_seguidos'] = $u->countSeguidos();
  23.         $dados['qt_seguidores'] = $u->countSeguidores();
  24.         $dados['sugestao'] = $u->getUsuarios(5);
  25.        
  26.         $this->loadTemplate('home', $dados);
  27.     }
  28.  
  29.     public function seguir($id){
  30.        
  31.         if(!empty($id)){
  32.             $id = addslashes($id);
  33.            
  34.             $sql = "SELECT * FROM usuarios WHERE id = '$id'";
  35.                        
  36.             $sql = $this->db->query($sql);
  37.            
  38.             if($sql->rowCount() > 0){
  39.                
  40.                 $r = new relacionamentos();                
  41.                 $r->seguir($_SESSION['twlog'], $id);
  42.             }
  43.         }
  44.        
  45.        header("Location: /twitter");
  46.     }
  47.    
  48.     public function desseguir($id){
  49.        
  50.         if(!empty($id)){
  51.             $id = addslashes($id);
  52.            
  53.             $sql = "SELECT * FROM usuarios WHERE id = '$id'";
  54.             $sql = $this->db->query($sql);
  55.            
  56.             if($sql->rowCount() > 0){
  57.                
  58.                 $r = new relacionamentos();                
  59.                 $r->desseguir($_SESSION['twlog'], $id);
  60.             }
  61.         }
  62.        
  63.        header("Location: /twitter");
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement