Exemplo n.º 1
0
 public function index()
 {
     // inclui os arquivos
     require_once '../App/Model/photo.class.php';
     require_once '../App/Model/characteristics.class.php';
     require_once '../App/Model/presentation.class.php';
     require_once '../App/Model/skills.class.php';
     require_once '../App/Model/portifolio.class.php';
     // instancia os objetos
     $photo = new Photo();
     $characteristics = new Characteristics();
     $presentation = new Presentation();
     $skills = new Skills();
     $portifolio = new Portifolio();
     // chama os metodos
     $selectPhoto = $photo->selectPhoto();
     $selectCharacteristics = $characteristics->selectCharacteristics();
     $selectPresentation = $presentation->selectPresentation();
     $selectBasicSkills = $skills->selectBasicSkills();
     $selectIntermediateSkills = $skills->selectIntermediateSkills();
     $selectAdvancedSkills = $skills->selectAdvancedSkills();
     $selectPortifolio = $portifolio->selectPortifolio();
     // Enviando mensagem de contato
     $to = '*****@*****.**';
     $subject = 'Contato do site';
     $contactName = $_POST['name'];
     $contactEmail = $_POST['email'];
     $contactPhone = $_POST['phone'];
     $contactMessage = $_POST['message'];
     $body = '<strong>Mensagem de contato</strong><br><br>';
     $body .= '<strong>Nome: </strong>' . $contactName . '<br>';
     $body .= '<strong>Email: </strong>' . $contactEmail . '<br>';
     $body .= '<strong>Telefone: </strong>' . $contactPhone . '<br>';
     $body .= '<strong>Mensagem: </strong>' . $contactMessage . '<br>';
     $header = 'From: ' . $contactEmail . ' Reply-to: ' . $contactEmail;
     $header .= 'Content-type: text/html; charset=utf-8';
     $resposta = mail($to, $subject, $body, $header);
     // envia os resultados para o index
     require_once '../App/View/Index/index.php';
 }
Exemplo n.º 2
0
 public function photo()
 {
     require_once '../App/Model/photo.class.php';
     $photo = new Photo();
     $id = $this->getURL();
     if (isset($_GET['action'])) {
         switch ($_GET['action']) {
             case 'insert':
                 if (!empty($_FILES['photo']['name'])) {
                     $photo_size = $_FILES['photo']['size'];
                     $photo_type = $_FILES['photo']['type'];
                     $photo_tmp_name = $_FILES['photo']['tmp_name'];
                     $photo_type = substr($photo_type, 6);
                     if (strstr('.jpg;.jpeg;.gif;.png', $photo_type)) {
                         $photo_name = md5(uniqid(time())) . "." . $photo_type;
                         if (file_exists('assets/img/photo/')) {
                             $photo_path = "assets/img/photo/" . $photo_name;
                         } else {
                             echo '<h2>A imagem nao pode ser salva no diretorio assets/img/photo/ devido erro</h2>';
                         }
                         move_uploaded_file($photo_tmp_name, $photo_path);
                         $photo = new Photo($photo_name, $photo_size, $photo_type);
                         $insertPhoto = $photo->insertPhoto();
                         if (!empty($insertPhoto)) {
                             echo $insertPhoto;
                         }
                     } else {
                         echo '<h2>Tipo de arquivo incorreto</h2>';
                     }
                 }
                 break;
             case 'edit':
                 $selectOnePhoto_edit = $photo->selectOnePhoto($id);
                 if (isset($_GET['operation']) && $_GET['operation'] == 'ok') {
                     if (!empty($_FILES['photo_edit']['name'])) {
                         if (file_exists('assets/img/photo/')) {
                             unlink('assets/img/photo/' . $selectOnePhoto_edit[0]->content_photo_name);
                         } else {
                             echo '<h2>A imagem nao foi deletada do diretorio assets/img/photo/</h2>';
                         }
                         $photo_edit_size = $_FILES['photo_edit']['size'];
                         $photo_edit_type = $_FILES['photo_edit']['type'];
                         $photo_edit_tmp_name = $_FILES['photo_edit']['tmp_name'];
                         $photo_edit_type = substr($photo_edit_type, 6);
                         if (strstr('.jpg;.jpeg;.gif;.png', $photo_edit_type)) {
                             $photo_edit_name = md5(uniqid(time())) . "." . $photo_edit_type;
                             $photo_edit_path = "assets/img/photo/" . $photo_edit_name;
                             move_uploaded_file($photo_edit_tmp_name, $photo_edit_path);
                             $photo = new Photo($photo_edit_name, $photo_edit_size, $photo_edit_type);
                             $updateOnePhoto = $photo->updateOnePhoto($id);
                             if (!empty($updateOnePhoto)) {
                                 echo $updateOnePhoto;
                             }
                         } else {
                             echo '<h2>Tipo de arquivo incorreto</h2>';
                         }
                     }
                 }
                 break;
             case 'delete':
                 $selectOnePhoto_delete = $photo->selectOnePhoto($id);
                 $deleteOnePhoto = $photo->deleteOnePhoto($id);
                 if (!empty($selectOnePhoto_delete[0]->content_photo_name) && !empty($deleteOnePhoto)) {
                     if (file_exists('assets/img/photo/')) {
                         unlink('assets/img/photo/' . $selectOnePhoto_delete[0]->content_photo_name);
                     } else {
                         echo '<h2>A imagem nao foi deletada do diretorio assets/img/photo/</h2>';
                     }
                     echo $deleteOnePhoto;
                 }
         }
     } else {
         echo '<h2>Acao diferente de insert, edit e delete</h2>';
     }
     $selectPhoto = $photo->selectPhoto();
     require_once '../App/View/Adm_content/photo.php';
 }