public function areas()
 {
     $areas = $this->dao->getAreas();
     if ($areas->count() > 0) {
         return $this->returnJson($areas);
     }
     $json = new JsonResponse();
     return $json->response(false, "Nenhuma área encontrada!")->serialize();
 }
Example #2
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());
}
<?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());
}
Example #4
0
                                <tr>
                                    <th>Título</th>
                                    <th>link</th>
                                    <th>Tema</th>
                                    <th>Estado</th>                                    
                                    <?if(LinkController::link() != "analysis"):?>
                                    <th>Tipo do Evento</th>
                                    <?else:?>
                                    <th>Data</th>
                                    <?endif?>
                                </tr>
                            </thead>
                            <tbody>                                
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
<?}else{    
    try{        
        $_REQUEST['no-must-online'] = true;
        include LinkController::rest();
    }catch(Exception $err){
        $json = new JsonResponse();
        print_r($json->response(false, $err->getMessage())->serialize());
    }
}
?>
<?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());
}
$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());
}
        //$countryMap);
        $statistic = new Statistic();
        $grouper = new DataGrouper();
        $controller = new DatacenterController($service, $statistic, $jsonResponse, $grouper, $factory);
        $reader = new Spreadsheet_Excel_Reader($_FILES['Planilha']['tmp_name']);
        try {
            $inputFile = new ExcelInputFile($reader);
            if (insertingValuesForInternationalTrade($subgroup)) {
                //$typeCountry = 'origin';
                $response = $controller->saveValues($inputFile, $subgroup, $font, $origin, $destiny, $coffeType, $variety, $typeCountry, true);
            } else {
                $response = $controller->saveValues($inputFile, $subgroup, $font, $origin, $destiny, $coffeType, $variety, $typeCountry);
            }
            print_r($response);
        } catch (WrongFormatException $exception) {
            print_r($jsonResponse->response(false, $exception->getMessage())->withoutHeader()->serialize());
        } catch (Exception $exception) {
            print_r($jsonResponse->response(false, $exception->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());
}
?>
<?
function insertingValuesForInternationalTrade($subgroup){
   $subgroups = array(1,2,3,4,5,6);
   return (in_array($subgroup, $subgroups));
}
        $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());
        }
    } else {
        $jsonResponse = new JsonResponse();
        print_r($jsonResponse->response(false, 'Parâmetros não podem estar vazios')->serialize());
    }
} else {
    $jsonResponse = new JsonResponse();
    print_r($jsonResponse->response(false, 'Parâmetros não configurados. Comunique o desenvovledor.')->serialize());
}
<?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());
}
Example #10
0
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());
    }
} else {
    $jsonResponse = new JsonResponse();
    print_r($jsonResponse->response(FALSE, "Os parâmetros não foram configurados. Comunique o desenvolvedor.")->serialize());
}
Example #11
0
<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$ID)) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$ID)) {
        require_once 'NewsController.php';
        require_once 'NewsDao.php';
        $controller = new NewsController(new NewsDao(Connection::connect()));
        try {
            if ($controller->delete($_POST[RequestsPatterns::$ID])) {
                print_r($jsonResponse->response(true, "Feed excluído com sucesso!")->serialize());
            } else {
                print_r($jsonResponse->response(false, "Falha ao excluir feed!")->serialize());
            }
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "O identificador da notícia não pode estar vazio!")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não enviados")->serialize());
}
<?php

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';
$id_country = $_POST['id'];
$country = new Country();
$country->setId($id_country);
$json = new JsonResponse();
$dao = new GenericDao(Connection::connect());
$controller = new Controller($dao);
try {
    if ($controller->deleteCountry($country)) {
        print_r($json->response(true, "País excluído com sucesso!")->serialize());
    } else {
        print_r($json->response(false, "Falha ao excluir o país.")->serialize());
    }
} catch (Exception $err) {
    print_r($json->response(false, $err->getMessage())->serialize());
}
<?php

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();
$dao = new GenericDao(Connection::connect());
$controller = new Controller($dao);
$country_id = $_REQUEST['country'];
$object = new Country($_POST['name']);
$object->setId($country_id);
if (isset($_POST['reexport']) && $_POST['reexport'] == true) {
    $object->setReexport();
}
if ($controller->editCountry($object)) {
    print_r($json->response(true, "País editado com sucesso!")->serialize());
} else {
    print_r($json->response(false, "O país não foi editado!")->serialize());
}
     $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 ());
         }else{
             if($controller->createNewDestinyCountry($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 ());
         }
     }catch(Exception $err){
         print_r($json->response(false, $err->getMessage())->serialize());
     }
 }else{
     print_r($json->response(false, "Os campos não podem estar vazios.")->serialize());
    if (RequestsPatterns::postParamsSent('id', 'type')) {
        require_once 'PublicationController.php';
        require_once 'PublicationDao.php';
        require_once 'Publication.php';
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        if ($_POST['type'] == 'analysis') {
            require_once 'Analyse.php';
            $publication = new Analyse(null);
        } elseif ($_POST['type'] == 'paper') {
            require_once 'Paper.php';
            $publication = new Paper(null);
        }
        $publication->setId($_POST['id']);
        try {
            if ($controller->delete($publication)) {
                print_r($jsonResponse->response(true, "Publicação excluída com sucesso")->serialize());
            } else {
                print_r($jsonResponse->response(false, "Falha ao excluir a publicação.")->serialize());
            }
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Os parâmetros não podem estar vazios")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não configurados")->serialize());
}
?>

<?php

require_once 'UserDao.php';
require_once 'User.php';
$user = new User(Session::getLoggedUser()->name(), Session::getLoggedUser()->username());
$user->setPositions($_POST['apps-position']);
$userdao = new UserDao(Connection::connect());
$jsonResponse = new JsonResponse();
if ($userdao->saveConfig($user)) {
    print_r($jsonResponse->response(true, "Suas configurações foram armazenadas com suceso!")->serialize());
} else {
    print_r($jsonResponse->response(false, "Falha ao salvar configurações do perfil")->serialize());
}
 public function calculateSampleStandardDeviation($group)
 {
     $values = $this->datacenterRepository->getValuesFromAGroup($group);
     $standarDeviation = $this->statistic->sampleStandardDeviation($values);
     return $this->jsonResponse->response(true, null)->addValue("value", $standarDeviation)->withoutHeader()->serialize();
 }
<?php

require_once 'File.php';
require_once 'PublicationController.php';
require_once 'Publication.php';
require_once 'PublicationDao.php';
require_once '../core/generics/SubArea.php';
require_once '../core/generics/State.php';
$jsonResponse = new JsonResponse();
$file = $_FILES['Arquivo'];
$controller = new PublicationController(new PublicationDao(Connection::connect()));
$controller->setPath("../publicacao/");
$publication = new Publication($_POST['title'], new SubArea(null, $_POST['subarea']), new File($file), new State($_POST['state']), null, null);
try {
    $controller->save($publication);
    print_r($jsonResponse->response(true, "Arquivo enviado com sucesso!")->withoutHeader()->serialize());
} catch (Exception $err) {
    print_r($jsonResponse->response(false, $err->getMessage())->withoutHeader()->serialize());
}
require_once 'XmlCharts/Simple/XmlSimpleSeries.php';
require_once 'Configs/SimpleSeriesConfig.php';
?>

<?php 
$period = 0;
if (isset($_GET['period'])) {
    if ($_GET['period'] == null) {
        $period = 6;
    } else {
        $period = $_GET['period'];
    }
} else {
    $period = 6;
}
$quotationCode = $_GET['quotation'];
$storage = new StorageDao(Connection::connect());
$controller = new StorageController($storage);
$config = new SimpleSeriesConfig();
$cotations = $controller->getStorageQuotations($quotationCode, $period);
if ($cotations != null) {
    $config->config($cotations);
    $config->setTitle($quotationCode);
    $xml = "arq_line" . $quotationCode . ".xml";
    $xmlResponse = $config->getChartXml()->buildXml("core/Charts/xml/" . $xml);
    $jsonResponse = new JsonResponse();
    print_r($jsonResponse->response(true, null)->addValue("xml", str_replace("\"", "'", $xmlResponse))->serialize());
} else {
    $jsonResponse = new JsonResponse();
    print_r($jsonResponse->response(false, "Nenhum valor encontrado neste período")->serialize());
}
        requireVideo();
        $proccessSearch = new ProccessVideoSearch($resultSearch);
    } elseif ($toSearch == "paper") {
        requirePaper();
        $proccessSearch = new ProccessPublicationSearch($resultSearch);
    } elseif ($toSearch == 'analysis') {
        requireAnalysis();
        $proccessSearch = new ProccessAnalysisSearch($resultSearch);
    }
    $json = new JsonResponse();
    $json->response(true, $proccessSearch->getResultsFound(), TRUE);
    $json->addValue("searchType", $toSearch);
    print_r($json->serialize());
} else {
    $json = new JsonResponse();
    print_r($json->response(false, "Nenhum registro encontrado")->addValue("searchType", $toSearch)->serialize());
}
?>
<?
function requirePublications(){
    require_once '../core/Publication/Publication.php';
    require_once '../core/generics/SubArea.php';
    require_once '../core/SearchEngine/ProccessPublicationSearch.php';
}

function requireVideo(){
    require_once '../core/Video/Video.php';
    require_once '../core/Video/SubArea.php';
    require_once '../core/SearchEngine/ProccessVideoSearch.php';
}
<?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());
}
    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 {
        print_r($jsonResponse->response(false, "Os campos não podem estar vazios")->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros de envio não foram configurados")->serialize());
}
Example #23
0
<?
}else{    
    if(LinkController::link() == 'login-fail'){
        $_GET['loginfail'] = true;
        include 'login_error.php';
    }elseif(LinkController::link() == 'login-fail/empty'){
        $_GET['empty'] = true;
        include 'login_error.php';
    }else{        
        try{
            require_once "../util/RequestsPatterns.php";
            require_once "../util/JsonResponse.php";
            require_once '../util/SessionAdmin.php';
            require_once 'AdminUser.php';
            //if(LinkController::isRequestToInsertPublication())
                //SessionAdmin::login(new AdminUser("ramonox", "ramonoxido"));            
            include LinkController::restAdmin();
        }catch(Exception $err){
            if(LinkController::isRequestToInsertPublication()){
                $message = $err->getMessage();
                echo '{"status": "'.false.'", "message":"'.$message.'"}';
                print_r($_POST);
            }else{
                $jsonResponse = new JsonResponse();
                print_r($jsonResponse->response(FALSE, $err->getMessage())->serialize());
            }
        }

    }
}
?>