Ejemplo n.º 1
0
 /**
  * @param array $data
  * @param int $statusCode
  * @return Response
  */
 public static function json(array $data, $statusCode = 200)
 {
     $response = new JsonResponse();
     $response->setContent(json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT));
     $response->setHeader('Content-Type', 'application/json');
     $response->setStatusCode($statusCode);
     return $response;
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 /**
  * Get memus - Makes search bar work.
  */
 public function getMenusAction()
 {
     $menusData = array();
     $systemTableService = $this->get('SystemTableService');
     $menus = $systemTableService->getMenus();
     foreach ($menus as $menu) {
         $menusData[] = array('id' => $menu->getId(), 'name' => $menu->getName());
     }
     $response = new JsonResponse();
     $response->setData($menusData);
     return $response;
 }
 public function updateCostosAction($id, $hash)
 {
     $today = new \DateTime();
     if ($hash != md5($today->format('Y-m-d'))) {
         $logger = $this->get('logger');
         $logger->error('Access denied on updateCostosAction');
         $returnJson = new JsonResponse();
         $returnJson->setData(array('ok' => true));
         return $returnJson;
     }
     $migrationService = $this->get('kinder.migrations');
     $migrationService->updateCostos();
     $returnJson = new JsonResponse();
     $returnJson->setData(array('ok' => true));
     return $returnJson;
 }
Ejemplo n.º 5
0
 public static function datesIncluded()
 {
     if (!isset($_REQUEST[START_DATE], $_REQUEST[END_DATE])) {
         echo JsonResponse::error("Incomplete request parameters!");
         exit;
     }
 }
Ejemplo n.º 6
0
 protected function parseException()
 {
     /** @var APIResponse $response */
     $response = app(APIResponse::class);
     $fe = FlattenException::create($e);
     $data = env("APP_DEBUG", false) ? $fe->toArray() : ["message" => "whoops, something wrong."];
     return JsonResponse::create($data, 500);
 }
Ejemplo n.º 7
0
 function __Construct($dictionary)
 {
     parent::__Construct(get_class());
     $categories = array();
     $list = ServiceCategory::GetAll(array('partnerCode' => Application::PARTNER_CODE, 'parentId' => null), null, $dictionary->getCode());
     foreach ($list as $category) {
         $categories[] = $category->toArray(true);
     }
     $this->jsonData = array('categories' => $categories);
 }
Ejemplo n.º 8
0
 public function run(Request $request)
 {
     $queueRepository = \Contao\Doctrine\ORM\EntityHelper::getRepository('Avisota\\Contao:Queue');
     $queueId = $request->get('id');
     $queue = $queueRepository->find($queueId);
     /** @var \Avisota\Contao\Entity\Queue $queue */
     if (!$queue) {
         header("HTTP/1.0 404 Not Found");
         echo '<h1>404 Not Found</h1>';
         exit;
     }
     $user = \BackendUser::getInstance();
     $user->authenticate();
     try {
         return $this->execute($request, $queue, $user);
     } catch (\Exception $exception) {
         $response = new JsonResponse(array('error' => sprintf('%s in %s:%d', $exception->getMessage(), $exception->getFile(), $exception->getLine())), 500);
         $response->prepare($request);
         return $response;
     }
 }
Ejemplo n.º 9
0
 public function recv()
 {
     $rawResponse = '';
     do {
         $bytesRead = $this->clientSocket->read($buffer, 1024);
         if ($bytesRead > 0) {
             $rawResponse .= $buffer;
         } else {
             break;
         }
     } while ($rawResponse[strlen($rawResponse) - 1] != '\\n');
     if ($rawResponse) {
         return JsonResponse::parse($rawResponse);
     }
     return null;
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     $subscriptionId = null;
     if (HTTP::IsPost()) {
         $emailAddress = Params::Get('emailAddress');
         $listReference = Params::Get('listReference');
         $source = Params::Get('source', self::DEFAULT_SOURCE);
         if (!Util::ValidateEmail($emailAddress)) {
             $message = 'INVALID EMAIL ADDRESS';
         } else {
             //get list
             $emailList = EmailList::FromReference(Application::PARTNER_CODE, $listReference);
             if (is_null($emailList)) {
                 $message = "INVALID EMAIL LIST [" . $listReference . "]";
             } else {
                 $success = $emailList->subscribe($source, $emailAddress, $user->getId(), $dictionary->getCode(), $message);
             }
             //send welcome email
             if ($success) {
                 //load subscription back up for id
                 $subscription = Subscription::FromEmail($emailList->getId(), $emailAddress);
                 $subscriptionId = $subscription->getId();
                 //load template
                 if ($listReference == 'consumer') {
                     $templateRef = 'subscribe-consumer';
                 } else {
                     $templateRef = 'subscribe-provider';
                 }
                 //TODO: support multiple language emails (just need to deal with inheritance)
                 $template = EmsTemplate::FromReference(Application::PARTNER_CODE, $templateRef, 'EN');
                 //send email
                 Application::SendEmail($template->getFromEmailAddress(), $template->getFromName(), $template->getReplyToEmailAddress(), $emailAddress, $template->getSubject(), $template->getContent(), ContentType::HTML);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'subscriptionId' => $subscriptionId, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         //inputs
         $subscriptionId = Params::GetLong('subscriptionId');
         $name = Params::Get('name');
         //load subscription
         $subscription = new Subscription($subscriptionId);
         $subscription->setName($name);
         $subscription->save();
         $success = true;
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
Ejemplo n.º 12
0
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $siteContact = new SiteContact();
         $siteContact->setUserId($user->getId());
         $siteContact->setTypeId(Params::GetLong('typeId'));
         $siteContact->setContactName(Params::Get('contactName'));
         $siteContact->setContactEmailAddress(Params::Get('contactEmailAddress'));
         $siteContact->setContactPhone(Params::Get('contactPhone'));
         $siteContact->setDictionaryCode($dictionary->getCode());
         $siteContact->setContent(Params::Get('content'));
         if ($siteContact->validate()) {
             $siteContact->save();
             $success = true;
             //notify partner by email
             $partner = new Partner(Application::PARTNER_CODE);
             $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
             $content = "\n";
             $content .= "A new site contact has been submitted on treatnow.co.\n\n";
             $content .= '---------------------------------------------------------------------' . "\n";
             $content .= "Type: " . $siteContact->getTypeName() . "\n";
             $content .= "Contact Name: " . $siteContact->getContactName() . "\n";
             $content .= "Contact Email: " . $siteContact->getContactEmailAddress() . "\n";
             $content .= "Contact Phone: " . $siteContact->getContactPhone() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= $siteContact->getContent() . "\n";
             $content .= '---------------------------------------------------------------------' . "\n\n";
             $content .= "You can manage the contact here: http://manage.zidmi.com/operations/contacts/";
             Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Site Contact', $content);
         } else {
             $message = $siteContact->getValidationError();
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $verificationCode = Params::Get('verificationCode');
         $verifierName = Params::Get('verifierName');
         if (!is_null($verificationCode) && !is_null($verifierName)) {
             $provider = Provider::FromVerificationCode($verificationCode);
             if (!is_null($provider)) {
                 $reference = 'UserId:' . $user->getId();
                 $provider->verify($verifierName, $reference);
                 $success = true;
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
 function __Construct($user, $dictionary)
 {
     parent::__Construct(get_class());
     $success = false;
     $message = '';
     if (HTTP::IsPost()) {
         $verificationCode = Params::Get('verificationCode');
         $verifierName = Params::Get('verifierName');
         $feedback = Params::Get('feedback');
         if (!is_null($verificationCode) && !is_null($verifierName) && !is_null($feedback)) {
             $provider = Provider::FromVerificationCode($verificationCode);
             if (!is_null($provider)) {
                 //add provider event
                 $reference = 'UserId:' . $user->getId();
                 $notes = "Submitted by:" . $verifierName . "\n" . $feedback;
                 $provider->addEvent(ProviderEventType::VERIFICATION_FEEDBACK, $reference, $notes);
                 $success = true;
                 //notify email
                 $partner = new Partner(Application::PARTNER_CODE);
                 $recipientAddress = $partner->getConfigValue(PartnerConfig::COMMS_NOTIFY_EMAIL);
                 $content = "\n";
                 $content .= "Some feedback has been submitted regarding provider data.\n\n";
                 $content .= '---------------------------------------------------------------------' . "\n";
                 $content .= "Provider: " . $provider->getName() . "\n";
                 $content .= "Submitted by: " . $verifierName . "\n";
                 $content .= "Feedback: \n";
                 $content .= $feedback . "\n";
                 $content .= '---------------------------------------------------------------------' . "\n\n";
                 Application::SendEmail('*****@*****.**', 'Zidmi', null, $recipientAddress, 'Provider Verification Feedback', $content);
             }
         }
     } else {
         $message = "NO DATA POSTED";
     }
     //done
     $this->jsonData = array('success' => $success, 'message' => $message);
 }
Ejemplo n.º 15
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());
Ejemplo n.º 16
0
<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2015 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
//$ses=Session::getInstance();
$toReturn = new JsonResponse();
if (isset($_POST['email']) && trim($_POST['email']) != '') {
    // send email to support
    $info['product'] = $_POST['product'];
    $info['version'] = $_POST['version'];
    $info['username'] = $_POST['userName'];
    $info['email'] = $_POST['email'];
    $user = new User($dbConnectionInfo);
    $generateInfo = $user->generatePasswd($info);
    $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $info['product'];
    if ($generateInfo['generated'] == "") {
        // nu are email valid
        $toReturn->set("success", "false");
        $toReturn->set("message", Utils::translate('noEmailFound'));
        //echo "No ";
    } else {
        if ($generateInfo['match']) {
            // generated password
            $template = new Template("./templates/" . __LANGUAGE__ . "/recover.html");
            $confirmationMsg = $template->replace(array("username" => $info['username'], "password" => $generateInfo['generated'], "productName" => $productTranslate));
Ejemplo n.º 17
0
<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once "init.php";
$cfgFile = './config/config.php';
$cfgInstall = '../../install/';
$toReturn = new JsonResponse();
if (file_exists($cfgInstall)) {
    $toReturn->set("installPresent", "true");
} else {
    $toReturn->set("installPresent", "false");
}
if (file_exists($cfgFile) && filesize($cfgFile) > 0) {
    $toReturn->set("configPresent", "true");
} else {
    $toReturn->set("configPresent", "false");
}
echo $toReturn;
Ejemplo n.º 18
0
        $toReturn->set("name", $ses->{$fullUser}->name);
        $toReturn->set("userName", $ses->{$fullUser}->userName);
        $toReturn->set("level", $ses->{$fullUser}->level);
    } else {
        if (strlen(trim($user->msg)) > 0) {
            $toReturn->set("error", $user->msg);
        }
    }
    echo $toReturn;
} elseif (isset($_POST['logOff']) && trim($_POST['logOff']) != '') {
    $ses->errBag = null;
    unset($ses->errBag);
    unset($ses->{$fullUser});
    // 		echo print_r($_POST,true);
} elseif (isset($_POST['check']) && trim($_POST['check']) != '') {
    $toReturn = new JsonResponse();
    $toReturn->set("isAnonymous", "false");
    $toReturn->set("loggedIn", "false");
    if (defined('__GUEST_POST__') && !__GUEST_POST__ && (isset($ses->{$fullUser}) && $ses->{$fullUser}->isAnonymous == 'true')) {
        unset($ses->{$fullUser});
    }
    if (defined('__GUEST_POST__') && __GUEST_POST__ && !isset($ses->{$fullUser})) {
        $user = new User($dbConnectionInfo);
        // user not logged in and guest is allowed to post
        if (!$user->initAnonymous()) {
            $toReturn->set("isAnonymous", "false");
            $toReturn->set("loggedIn", "false");
            $toReturn->set("msg", "1");
            $toReturn->set("msgType", "error");
        } else {
            // anonymous must be logged in
Ejemplo n.º 19
0
<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
$toReturn = new JsonResponse();
if (isset($_POST['id']) && trim($_POST['id']) != '') {
    $realId = base64_decode($_POST['id']);
    //list($id,$date,$action,$newPassword) = explode("|", $realId);
    $args = explode("|", $realId);
    $id = $args[0];
    $date = $args[1];
    $action = "new";
    $newPassword = "";
    if (count($args) > 2) {
        $action = $args[2];
        $newPassword = $args[3];
    }
    $user = new User($dbConnectionInfo);
    //echo "id=".$id." date=".$date;
    $currentDate = date("Y-m-d G:i:s");
    $days = Utils::getTimeDifference($currentDate, $date, 3);
    if ($days > 7) {
        $toReturn->set("error", true);
        $toReturn->set("msg", "Confirmation code expired!");
    } else {
Ejemplo n.º 20
0
 /**
  * Helper method to return a JSON response.
  *
  * @param mixed $data
  *  The data to return as the response.
  * @param int $status
  *  The HTTP status code for this response.
  *
  * @return JsonResponse
  *
  */
 public function toJson($data, $status = 200)
 {
     return JsonResponse::create($data, $status);
 }
Ejemplo n.º 21
0
        if ($response) {
            echo JsonResponse::success("Profile Successfully Updated!");
            exit;
        } else {
            echo JsonResponse::error("Could not update Profile. Please try again!");
            exit;
        }
    } else {
        echo JsonResponse::error("Profile data not set");
        exit;
    }
} elseif ($intent == 'getProfile') {
    if (isset($_REQUEST['userid'])) {
        $userid = $_REQUEST['userid'];
        $userController = new UserController();
        $profile = $userController->getUserProfile($userid);
        if ($profile && is_array($profile)) {
            echo JsonResponse::success($profile);
            exit;
        } else {
            echo JsonResponse::error("Could not fetch user profile. Please try again later.");
            exit;
        }
    } else {
        echo JsonResponse::error("Expected parameter not set");
        exit;
    }
} else {
    echo JsonResponse::error('Invalid intent!');
    exit;
}
Ejemplo n.º 22
0
        $response = $warden->deleteBed($_POST[BedTable::bed_id]);
        if (is_array($response)) {
            echo JsonResponse::error($response[P_MESSAGE]);
            exit;
        } else {
            echo JsonResponse::message(STATUS_OK, "Bed successfully deleted!");
            exit;
        }
    } else {
        echo JsonResponse::error("Incomplete request parameters!");
        exit;
    }
} elseif ($intent == 'deleteWard') {
    if (isset($_POST[WardRefTable::ward_ref_id])) {
        $warden = new WardController();
        $response = $warden->deleteWard($_POST[WardRefTable::ward_ref_id]);
        if (is_array($response)) {
            echo JsonResponse::error($response[P_MESSAGE]);
            exit;
        } else {
            echo JsonResponse::message(STATUS_OK, "Ward deletion successful!");
            exit;
        }
    } else {
        echo JsonResponse::error("Incomplete request parameters!");
        exit;
    }
} else {
    echo JsonResponse::error("Invalid intent!");
    exit;
}
Ejemplo n.º 23
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 ());
Ejemplo n.º 24
0
<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
//$ses=Session::getInstance();
$json = new JsonResponse();
if (isset($_POST['userName']) && trim($_POST['userName']) != '') {
    // send email to support
    $info['username'] = $_POST['userName'];
    $info['name'] = $_POST['name'];
    $info['password'] = $_POST['password'];
    $info['email'] = $_POST['email'];
    $user = new User($dbConnectionInfo);
    $return = $user->insertNewUser($info);
    if ($return->error == "true") {
        echo $return;
    } else {
        $id = base64_encode($user->userId . "|" . $user->date);
        $link = "<a href='" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}'>" . __BASE_URL__ . "oxygen-webhelp/resources/confirm.html?id={$id}</a>";
        $template = new Template("./templates/signUp.html");
        $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $_POST['product'];
        $arrayProducts = $user->getSharedProducts();
        $products = "";
        foreach ($arrayProducts as $productId => $productName) {
            $products .= "\"" . $productName . "\" ";
Ejemplo n.º 25
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 {
Ejemplo n.º 26
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'];
        }
Ejemplo n.º 27
0
 /**
  * Insert new user into database
  *
  * @param array $info containing 'username','name','password','email'
  * @param bool $ldap TRUE for LDAP user
  * @return JsonResponse {"msg","msgType","errorCode"}
  * @throws Exception
  */
 function insertNewUser($info, $ldap = false)
 {
     $this->info['msg'] = "user::false";
     $response = new JsonResponse();
     $response->set("msgType", "error");
     $response->set("error", "true");
     $db = new RecordSet($this->dbConnectionInfo);
     $username = $db->sanitize($info['username']);
     $name = $db->sanitize($info['name']);
     $email = $db->sanitize($info['email']);
     if ($this->isUqFieldViolated('userName', $username)) {
         $response->set("msg", "User name is already taken!");
         $response->set("errorCode", "4");
     } else {
         if ($this->isUqFieldViolated('email', $email) && trim($email) != '') {
             $response->set("msg", "Email is already in the database!");
             $response->set("errorCode", "5");
         } else {
             if (!$this->checkEmail($email) && !$ldap) {
                 $response->set("msg", "Invalid e-mail address!");
                 $response->set("errorCode", "3");
             } else {
                 if (strlen(trim($info['password'])) < 5 && !$ldap) {
                     $response->set("msg", "Password is too short!");
                     $response->set("errorCode", "1");
                 } else {
                     if ($db->sanitize($info['password']) != $info['password']) {
                         $response->set("msg", "Invalid password!");
                         $response->set("errorCode", "2");
                     } else {
                         if (!$ldap) {
                             $password = MD5($db->sanitize($info['password']));
                             $status = 'created';
                         } else {
                             $password = '';
                             $status = 'validated';
                         }
                         $date = date("Y-m-d H:i:s");
                         $sql = "INSERT INTO  users (userId ,userName ,email ,name ,company ,password ,date ,level ,status,notifyAll,notifyReply,notifyPage) VALUES (NULL,'" . $username . "','" . $email . "','" . $name . "','noCompany','" . $password . "','" . $date . "','user','" . $status . "','no','yes','yes');";
                         $rows = $db->Run($sql);
                         $this->info['msg'] = "user::rows::" . $rows;
                         // 			$toReturn=$sql;
                         if ($rows <= 0) {
                             $response->set("msg", $db->m_DBErrorNumber . $db->m_DBErrorMessage . $sql);
                             $response->set("errorCode", "10");
                         } else {
                             $response->set("error", "false");
                             $response->set("errorCode", "0");
                             $this->validate($username, $info['password'], $status);
                         }
                         $db->Close();
                     }
                 }
             }
         }
     }
     return $response;
 }
Ejemplo n.º 28
0
    if ($toSearch == "video") {
        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';
}
Ejemplo n.º 29
0
<?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());
}
Ejemplo n.º 30
0
<?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());
}