コード例 #1
0
<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
        require_once 'File.php';
        require_once 'PublicationController.php';
        require_once 'Publication.php';
        require_once 'Paper.php';
        require_once 'PublicationDao.php';
        require_once '../core/generics/SubArea.php';
        //require_once '../core/generics/State.php';
        require_once '../core/generics/PublicationType.php';
        //$jsonResponse = new JsonResponse();
        $file = $_FILES['Arquivo'];
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        $controller->setPath("../publicacao/");
        $publicationType = new PublicationType(null, $_POST['publication_type']);
        $publication = new Paper($_POST['title'], new SubArea(null, $_POST['subarea']), new File($file), null, date("Y-m-d"), null, $publicationType, $_POST['year']);
        //print_r($jsonResponse->response(false, $publication->getTypeId())->withoutHeader()->serialize());
        try {
            $controller->savePaper($publication);
            print_r($jsonResponse->response(true, "Arquivo enviado com sucesso!")->withoutHeader()->serialize());
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->withoutHeader()->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Todos os campos devem ser preenchidos e/ou marcados.")->withoutHeader()->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não configurados corretamente.")->withoutHeader()->serialize());
コード例 #2
0
<?php

require_once 'util/RequestsPatterns.php';
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted('title', 'text', 'analysis_id')) {
    if (RequestsPatterns::postParamsSent('title', 'text', 'analysis_id')) {
        if (Session::isLogged()) {
            require_once 'core/User/User.php';
            require_once 'Publication.php';
            require_once 'Analyse.php';
            require_once 'PublicationController.php';
            require_once 'PublicationDao.php';
            require_once 'Comment.php';
            $user = Session::getLoggedUser();
            $analysis = new Analyse(null);
            $analysis->setId($_POST['analysis_id']);
            $user->comment(new Comment(date("Y-m-d H:i:s"), $_POST['title'], $_POST['text']), $analysis);
            $controller = new PublicationController(new PublicationDao(Connection::connect()));
            try {
                if ($controller->comment($analysis)) {
                    print_r($jsonResponse->response(true, "Comentário enviado com sucesso!")->serialize());
                } else {
                    print_r($jsonResponse->response(false, "Falha ao eviar comentário. Tente novamente")->serialize());
                }
            } catch (Exception $err) {
                print_r($jsonResponse->response(false, $err->getMessage())->serialize());
            }
        } else {
            print_r($jsonResponse->response(false, "Faça o login para poder deixar seu comentário")->serialize());
        }
    } else {
コード例 #3
0
<?
    require_once '../core/generics/Param.php';
    require_once '../core/generics/datacenter/Country.php';
    require_once '../core/generics/Controller.php';
    require_once '../core/generics/GenericDao.php';        
    
    $json = new JsonResponse();
    
    if(RequestsPatterns::postParamsSetted('name', 'type')){
        if(RequestsPatterns::postParamsSent('name', 'type')){
            $name = $_POST['name'];
            $typeCountry = $_POST['type'];
            
            $country = new Country($name);
             
            $dao = new GenericDao(Connection::connect());
            $controller = new Controller($dao);
            
            $message = "País inserido com sucesso";
            $message_error = "Falha na inserção do país"; 
            try{
                if($typeCountry == 'origin'){
                    if(isset($_POST['reexport']) && $_POST['reexport'] == true){
                        $country->setReexport();
                    }
                    if($controller->createNewOriginCountry($country)){
                        $countryToCache = $controller->getCountryByName($country,$typeCountry);                        
                        cacheCountry($countryToCache, $typeCountry);
                        print_r($json->response (true, $message)->serialize ());
                    }else
                        print_r($json->response (true, $message_error)->serialize ());
コード例 #4
0
<?php

$jsonResponse = new JsonResponse();
$_POST['fromAdmin'] = true;
//require_once 'build.php';
require_once 'requires_build.php';
if (RequestsPatterns::postParamsSetted('subgroup', 'font', 'coffetype', 'variety', 'destiny')) {
    if (RequestsPatterns::postParamsSent('subgroup', 'font', 'coffetype', 'variety', 'destiny')) {
        require_once '../core/Exceptions/WrongTypeException.php';
        require_once '../core/Exceptions/WrongFormatException.php';
        require_once '../core/Datacenter/CountryMap.php';
        require_once '../util/excel/reader/ExcelInputFile.php';
        require_once '../util/excel/reader/SpreadsheetValidator.php';
        require_once '../util/excel/reader/excel_reader2.php';
        $file = $_FILES['Planilha']['tmp_name'];
        $subgroup = $_POST['subgroup'];
        $font = $_POST['font'];
        $coffeType = $_POST['coffetype'];
        if ($coffeType == 'none') {
            $coffeType = 0;
        }
        $variety = $_POST['variety'];
        if ($variety == "none") {
            $variety = 0;
        }
        $destiny = $_POST['destiny'];
        $origin = $_POST['origin'];
        $typeCountry = null;
        if (isset($_POST['typeCountry'])) {
            $typeCountry = $_POST['typeCountry'];
        }
コード例 #5
0
<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$ID)) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$ID)) {
        require_once 'VideoController.php';
        require_once 'VideoDao.php';
        $controller = new VideoController(new VideoDao(Connection::connect()));
        try {
            if ($controller->delete($_POST[RequestsPatterns::$ID])) {
                print_r($jsonResponse->response(true, "Video excluído com sucesso")->serialize());
            } else {
                print_r($jsonResponse->response(false, "Falha ao excluir o video")->serialize());
            }
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "O identificador do video não pode estar vazio!")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não configurados!")->serialize());
}
コード例 #6
0
<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, RequestsPatterns::$LINK)) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, RequestsPatterns::$LINK)) {
        require_once 'NewsController.php';
        require_once 'NewsDao.php';
        require_once 'NewRSS.php';
        try {
            $controller = new NewsController(new NewsDao(Connection::connect()));
            $controller->save(new NewRSS($_POST[RequestsPatterns::$TITLE], $_POST[RequestsPatterns::$LINK]));
            print_r($jsonResponse->response(TRUE, "RSS inserido com sucesso!")->serialize());
        } catch (PDOException $err) {
            print_r($jsonResponse->response(FALSE, $err->getMessage())->serialize());
        } catch (LoginException $err) {
            print_r($jsonResponse->response(NULL, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(NULL, "Todos os campos devem ser preenchidos.")->serialize());
    }
} else {
    print_r($jsonResponse->response(FALSE, "Os parâmetros não foram configurados. Comunique o desenvolvedor")->serialize());
}
コード例 #7
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, 'subarea', 'state', 'text')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, 'subarea', 'state', 'text')) {
        require_once 'PublicationController.php';
        require_once 'Publication.php';
        require_once 'Analyse.php';
        require_once 'PublicationDao.php';
        require_once '../core/generics/SubArea.php';
        require_once '../core/generics/State.php';
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        $publication = new Analyse($_POST[RequestsPatterns::$TITLE], new SubArea(null, $_POST['subarea']), new State($_POST['state']), date("Y-m-d"));
        $publication->setText($_POST['text']);
        try {
            $controller->saveAnalysis($publication);
            print_r($jsonResponse->response(true, "Análise inserida com sucesso!")->serialize());
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Todos os campos devem ser preenchidos.")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Alguns parâmetros não foram configurados")->serialize());
}
コード例 #8
0
<?php

if (RequestsPatterns::postParamsSetted('email', 'name', 'username', 'password', 'confirm_password', 'city', 'activity')) {
    if (RequestsPatterns::postParamsSent('email', 'name', 'username', 'password', 'confirm_password', 'city', 'activity')) {
        require_once 'UserController.php';
        require_once 'UserDao.php';
        require_once '../core/generics/City.php';
        require_once '../core/generics/Activity.php';
        $city = new City(null, $_POST['city']);
        $activity = new Activity();
        $activity->setId($_POST['activity']);
        $user = new User($_POST['name'], $_POST['username'], $_POST['password']);
        $user->setEmail($_POST['email']);
        $user->setCity($city);
        $user->setActivity($activity);
        $positions = 'noticias,metereologia|publicacoes,videoteca|cotacoes';
        $user->setPositions($positions);
        $userController = new UserController(new UserDao(Connection::connect()));
        try {
            if ($userController->subscribe($user, $_POST['confirm_password'])) {
                $jsonResponse = new JsonResponse();
                print_r($jsonResponse->response(true, 'Usuário cadastrado com sucesso. Você será automaticamente conectado ao sistema')->addValue("redirectTo", LinkController::getBaseURL())->serialize());
                Session::login($user);
                //header('Location: '.LinkController::getBaseURL());
            } else {
                $jsonResponse = new JsonResponse();
                print_r($jsonResponse->response(false, 'Falha no cadastro do usuário. Favor tentar novamente')->serialize());
            }
        } catch (Exception $err) {
            $jsonResponse = new JsonResponse();
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
コード例 #9
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$LINK, RequestsPatterns::$TITLE, 'subarea', 'duration', 'type_event')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$LINK, RequestsPatterns::$TITLE, 'subarea', 'duration', 'type_event')) {
        require_once "VideoController.php";
        require_once "VideoDao.php";
        require_once "Video.php";
        require_once "SubArea.php";
        require_once "../core/generics/State.php";
        $controller = new VideoController(new VideoDao(Connection::connect()));
        try {
            $subarea = new SubArea(null, $_POST['subarea']);
            //$state = new State($_POST['state'], null, null);
            $videoLink = $controller->turnLinkToId($_POST[RequestsPatterns::$LINK]);
            $video = new Video($_POST[RequestsPatterns::$TITLE], $videoLink, date("Y-m-d"), $subarea, null, $_POST['type_event'], $_POST['duration']);
            $controller->save($video);
            $jsonResponse = new JsonResponse();
            print_r($jsonResponse->response(TRUE, "Video inserido com sucesso!")->serialize());
        } catch (PDOException $err) {
            $jsonResponse = new JsonResponse();
            print_r($jsonResponse->response(FALSE, $err->getMessage())->serialize());
        } catch (Exception $err) {
            $jsonResponse = new JsonResponse();
            print_r($jsonResponse->response(NULL, $err->getMessage())->serialize());
        }
    } else {
        $jsonResponse = new JsonResponse();
        print_r($jsonResponse->response(NULL, "Todos os campos devem ser preenchidos!")->serialize());
    }
コード例 #10
0
<?php

require_once 'util/RequestsPatterns.php';
if (RequestsPatterns::postParamsSetted('username', 'email')) {
    if (RequestsPatterns::postParamsSent('username', 'email')) {
        require_once 'UserController.php';
        require_once 'UserDao.php';
        require_once 'core/email/Content.php';
        require_once 'core/email/Email.php';
        require_once 'core/email/EmailController.php';
        $userController = new UserController(new UserDao(Connection::connect()));
        $jsonResponse = new JsonResponse();
        try {
            $user = new User(null, $_POST['username']);
            $user->setEmail($_POST['email']);
            if ($userController->newPassword($user)) {
                print_r($jsonResponse->response(true, "Um email foi enviado para você com sua nova senha!")->serialize());
            } else {
                print_r($jsonResponse->response(true, "Falha ao gerar nova senha!")->serialize());
            }
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        $jsonResponse = new JsonResponse();
        print_r($jsonResponse->response(false, "Os campos não podem estar vazios")->serialize());
    }
} else {
    $jsonResponse = new JsonResponse();
    print_r($jsonResponse->response(false, "Parâmetros não configurados")->serialize());
}
コード例 #11
0
<?php

require_once 'util/RequestsPatterns.php';
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted('link', 'to', 'name_to') && RequestsPatterns::postParamsSent('link', 'to', 'name_to')) {
    require_once 'core/email/EmailController.php';
    require_once 'PublicationController.php';
    require_once 'PublicationDao.php';
    require_once 'Publication.php';
    require_once 'Analyse.php';
    require_once 'core/email/Content.php';
    require_once 'core/email/Email.php';
    $emailController = new EmailController();
    $analysisController = new PublicationController(new PublicationDao(Connection::connect()));
    $analysis = $analysisController->getAnAnalysis($_POST['link'], true);
    if ($emailController->setAnalysisEmail($analysis, $_POST['to'], $_POST['name_to'])) {
        print_r($jsonResponse->response(true, "Email enviado com sucesso")->serialize());
    } else {
        print_r($jsonResponse->response(false, "Não foi possível enviar o email")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Alguns campos não foram enviados.")->serialize());
}