Initial Commit
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
class Default_ErrorController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $_allowedController;
|
||||
protected $_allowedModule;
|
||||
protected $_restModule;
|
||||
protected $_ignoredMessages;
|
||||
protected $_ipManager;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->_allowedController = array('admin', 'index', 'error', 'services');
|
||||
$this->_allowedModule = array('admin', 'default', 'v1', 'monitoring', 'user');
|
||||
$this->_restModule = array('v1','auth');
|
||||
$this->_ignoredMessages = array(
|
||||
"Accesso Scaduto",
|
||||
"Username e/o password non ricevuti.",
|
||||
"I dati inseriti non sono validi",
|
||||
"Le credenziali inserite non sono valide",
|
||||
"Account disattivato. Per informazioni contattare l'amministratore.",
|
||||
"Username inserito inesistente"
|
||||
);
|
||||
$this->_ipManager = new App_Service_IpManager();
|
||||
}
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
$this->_response->clearHeader('Access-Control-Allow-Headers');
|
||||
$this->_response->setHeader('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Origin,Authorization,x-requested-with,Content-Type,X-As-Dev-On,,X-As-Dev-Pw,MongoDbName');
|
||||
|
||||
$this->_response->clearHeader('Access-Control-Allow-Methods');
|
||||
$this->_response->setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, PATCH, DELETE');
|
||||
|
||||
$this->_response->clearHeader('Access-Control-Allow-Origin');
|
||||
$this->_response->setHeader('Access-Control-Allow-Origin', '*');
|
||||
|
||||
$this->_response->clearHeader('Access-Control-Allow-Credentials');
|
||||
$this->_response->setHeader('Access-Control-Allow-Credentials', 'true');
|
||||
|
||||
$this->view->allowedIp = $this->_ipManager->allowedIp();
|
||||
|
||||
$this->view->responseCode = null;
|
||||
}
|
||||
|
||||
public function errorAction()
|
||||
{
|
||||
$errors = $this->_getParam('error_handler');
|
||||
if ($this->_getParam('module') != 'default') {
|
||||
$content = array('status' => false);
|
||||
}
|
||||
|
||||
if (!$errors || !$errors instanceof ArrayObject) {
|
||||
$content['message'] = 'You have reached the error page';
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($errors->type) {
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
|
||||
// 404 error -- controller or action not found
|
||||
$this->getResponse()->setHttpResponseCode(404);
|
||||
$this->view->responseCode = 404;
|
||||
$this->view->title = "Adriatica Sistemi soc. coop. - Pagina non trovata - Errore 404";
|
||||
|
||||
$priority = Zend_Log::NOTICE;
|
||||
if (in_array($this->_getParam('module'), $this->_restModule)) {
|
||||
$content['message'] = 'Page not found';
|
||||
} else {
|
||||
$this->view->message = 'Page not found';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($errors->exception instanceof App_Controller_Errors_WebServiceError) {
|
||||
// web services error
|
||||
$content['message'] = $errors->exception->getMyMessage();
|
||||
$content['errorCode'] = $errors->exception->getErrorCode();
|
||||
|
||||
if ($errors->exception->getErrorDetail()) {
|
||||
$content['errorDetail'] = $errors->exception->getErrorDetail();
|
||||
}
|
||||
|
||||
//Recupero tutti i parametri disponibili sulla richiesta
|
||||
$allParams = $this->getRequest()->getRawBody();
|
||||
if(!$allParams){
|
||||
$allParams = Zend_Json::encode($errors->request->getParams());
|
||||
}
|
||||
|
||||
$dbName = '';$token = ''; $username = '';
|
||||
if(Zend_Registry::isRegistered('TOKEN')){
|
||||
$model = new Application_Model_Generic();
|
||||
$token = Zend_Registry::get('TOKEN');
|
||||
$user = $model->getByColumnName('users', 'token', $token);
|
||||
if($user){
|
||||
$dbName = $user['NomeDB'];
|
||||
$username = $user['username'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->getResponse()->setHttpResponseCode(400);
|
||||
|
||||
//Zend_Registry::get('log')->info(print_r($errors,true));
|
||||
|
||||
if (!in_array($errors->exception->getMessage(), $this->_ignoredMessages))
|
||||
Zend_Registry::get('error_log')
|
||||
->setEventItem('url', $errors->request->getRequestUri())
|
||||
->setEventItem('trace', Zend_Json::encode($errors->exception->getTrace()))
|
||||
->setEventItem('params', $allParams)
|
||||
->setEventItem('db_name', $dbName)
|
||||
->setEventItem('username', $username)
|
||||
->setEventItem('token', $token)
|
||||
->setEventItem('section', 'web_service')
|
||||
->info($content['message']);
|
||||
|
||||
} else {
|
||||
// application error
|
||||
$this->getResponse()->setHttpResponseCode(500);
|
||||
$priority = Zend_Log::CRIT;
|
||||
if (in_array($this->_getParam('module'), $this->_restModule)) {
|
||||
$content['message'] = $errors->exception->getMessage();
|
||||
} else {
|
||||
$this->view->message = $errors->exception->getMessage();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Log exception, if logger available
|
||||
if ($log = $this->getLog()) {
|
||||
$log->log($this->view->message, $priority, $errors->exception);
|
||||
$log->log('Request Parameters', $priority, $errors->request->getParams());
|
||||
}
|
||||
|
||||
// conditionally display exceptions
|
||||
if ($this->getInvokeArg('displayExceptions') == true || in_array($this->_getParam('module'), array('admin','monitoring'))) {
|
||||
if (in_array($this->_getParam('module'), $this->_restModule)) {
|
||||
$content['exception_trace'] = (array)$errors->exception->getTrace();
|
||||
} else {
|
||||
$this->view->exception = $errors->exception;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($this->_getParam('module'), $this->_restModule) && APPLICATION_ENV != 'production') {
|
||||
$content['request'] = (array)$errors->request;
|
||||
} else {
|
||||
$this->view->request = $errors->request;
|
||||
}
|
||||
|
||||
if (in_array($this->_getParam('module'), $this->_restModule)) {
|
||||
$this->_helper->getHelper('layout')->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
$this->getResponse()
|
||||
->setHeader('Content-Type', 'json')
|
||||
->setBody($this->_helper->Globalfunction->safeJsonEncode($content))
|
||||
->sendResponse();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//Registro il log dell'errore
|
||||
//Zend_Registry::get('log')->info(print_r($errors,true));
|
||||
if (in_array($this->_getParam('module'), $this->_allowedModule)
|
||||
&& in_array($this->_getParam('controller'), $this->_allowedController)
|
||||
&& !in_array($errors->exception->getMessage(), $this->_ignoredMessages))
|
||||
Zend_Registry::get('error_log')->setEventItem('url', $errors->request->getRequestUri())
|
||||
->setEventItem('trace', Zend_Json::encode($errors->exception->getTrace()))
|
||||
->setEventItem('params', Zend_Json::encode($errors->request->getParams()))
|
||||
->setEventItem('section', $this->_getParam('module'))
|
||||
->info($errors->exception->getMessage());
|
||||
}
|
||||
|
||||
public function getLog()
|
||||
{
|
||||
$bootstrap = $this->getInvokeArg('bootstrap');
|
||||
if (!$bootstrap->hasResource('Log')) {
|
||||
return false;
|
||||
}
|
||||
$log = $bootstrap->getResource('Log');
|
||||
return $log;
|
||||
}
|
||||
|
||||
public function invalidAction()
|
||||
{
|
||||
$content = $this->_helper->json(array('status' => 'error', 'message' => $this->_getParam('message')));
|
||||
$this->getResponse()
|
||||
->setHeader('Content-Type', 'json')
|
||||
->setBody($content)
|
||||
->sendResponse();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,436 @@
|
||||
<?php
|
||||
|
||||
class Default_IndexController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
/* Proprietà Controller */
|
||||
protected $_urlHelper;
|
||||
protected $_genericModel;
|
||||
protected $_restModel;
|
||||
protected $_authService;
|
||||
protected $_configs;
|
||||
protected $_translate;
|
||||
protected $_ipManager;
|
||||
protected $_VariabiliSito;
|
||||
protected $_rsaCryptor;
|
||||
|
||||
protected App_Service_JsonConfiguration $_datiAziendali;
|
||||
protected App_Service_JsonConfiguration $_parametriSito;
|
||||
|
||||
/* Dati metatag del sito */
|
||||
private $_KEYWORDS;
|
||||
private $_TITLE;
|
||||
private $_DESCRIPTION;
|
||||
|
||||
/* Dati per le sezioni dinamiche del sito */
|
||||
private $_MENUITEM;
|
||||
private $_PAGENAME;
|
||||
private $_SUBTITLE;
|
||||
|
||||
private $_COOKIE_EXPIRE_TIME;
|
||||
private $_COOKIE_SITE_CREDENTIALS;
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->_helper->layout->setLayout('layout');
|
||||
$this->_urlHelper = $this->_helper->getHelper('url');
|
||||
$this->_authService = new App_Service_Auth();
|
||||
$this->_genericModel = new Application_Model_Generic();
|
||||
$this->_restModel = new Application_Model_Rest();
|
||||
$this->_configs = new App_Service_ConfigManager();
|
||||
$this->_translate = Zend_Form::getDefaultTranslator();
|
||||
$this->_ipManager = new App_Service_IpManager();
|
||||
$this->_rsaCryptor = new App_Service_RsaCryptor();
|
||||
|
||||
$this->_VariabiliSito = new App_Service_VariabiliSito();
|
||||
$this->_datiAziendali = new App_Service_JsonConfiguration('dati_aziendali');
|
||||
$this->_parametriSito = new App_Service_JsonConfiguration("parametri_sito");
|
||||
|
||||
$this->_TITLE = "home";
|
||||
$this->_DESCRIPTION = "";
|
||||
$this->_KEYWORDS = "";
|
||||
|
||||
$this->_TITLE = $this->_parametriSito->get('base_title');
|
||||
$this->_DESCRIPTION = "";
|
||||
$this->_KEYWORDS = $this->_parametriSito->get('base_keywords');
|
||||
|
||||
$BASE_COOKIE_STRING = strtolower(Zend_Registry::get('ENVIROMENTS')->get('site_short_id')) . '_';
|
||||
|
||||
$this->_COOKIE_EXPIRE_TIME = time() + (86400 * 30);
|
||||
$this->_COOKIE_SITE_CREDENTIALS = $BASE_COOKIE_STRING . "CREDENTIALS";
|
||||
}
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
|
||||
$action = $this->getRequest()->getActionName();
|
||||
if ($this->_configs->get('interrutore_sito') == 'off' && $action != 'login' && $action != 'authenticate' && $action != 'offline' && !$this->_ipManager->allowedIp()) {
|
||||
$this->_helper->redirector('offline', 'index', 'default');
|
||||
}
|
||||
|
||||
if (Zend_Registry::get('Zend_Locale') == 'it') {
|
||||
$this->view->lang = 'it';
|
||||
} else {
|
||||
$this->view->lang = 'en';
|
||||
}
|
||||
|
||||
$this->view->action = $action;
|
||||
$this->view->controller = $this->getRequest()->getControllerName();
|
||||
|
||||
$this->view->enableTestSdk = $this->_ipManager->controllaAbilitazioneTestSdk();
|
||||
}
|
||||
|
||||
public function postDispatch()
|
||||
{
|
||||
$this->view->title = $this->_TITLE;
|
||||
$this->view->keywords = $this->_KEYWORDS;
|
||||
$this->view->description = $this->_DESCRIPTION;
|
||||
|
||||
$this->view->menuitem = $this->_MENUITEM;
|
||||
$this->view->pagename = $this->_PAGENAME;
|
||||
$this->view->subtitle = $this->_SUBTITLE;
|
||||
|
||||
$this->view->parametriSito = $this->_parametriSito->getAllParams();
|
||||
$this->view->datiAziendali = $this->_datiAziendali->getAllParams();
|
||||
}
|
||||
|
||||
public function offlineAction()
|
||||
{
|
||||
$this->_DESCRIPTION .= "Il Sito è in manutenzuione";
|
||||
if ($this->_configs->get('interrutore_sito') == 'off') {
|
||||
$this->_helper->getHelper('layout')->disableLayout();
|
||||
} else {
|
||||
$this->_helper->redirector('index', 'index');
|
||||
}
|
||||
}
|
||||
|
||||
public function loginAction()
|
||||
{
|
||||
$this->_helper->layout->setLayout('admin');
|
||||
|
||||
$this->view->moduleName = 'default';
|
||||
$this->view->eventLoader = 'login';
|
||||
$this->view->formData = $this->recuperaCredenziali();
|
||||
|
||||
if (isset($this->_authService->getAuth()->getIdentity()->username))
|
||||
$this->_helper->redirector('index', $this->_authService->getAuth()->getIdentity()->role);
|
||||
}
|
||||
|
||||
public function authenticateAction()
|
||||
{
|
||||
$this->_helper->layout->setLayout('admin');
|
||||
|
||||
$this->view->moduleName = 'default';
|
||||
$this->view->eventLoader = 'login';
|
||||
$this->view->formData = $this->recuperaCredenziali();
|
||||
|
||||
if (!$this->getRequest()->isPost()) {
|
||||
return $this->_helper->redirector('index');
|
||||
}
|
||||
|
||||
$form = new Application_Form_Default_Index_Auth_Login();
|
||||
if (!$form->isValid($this->getRequest()->getPost())) {
|
||||
$this->view->error = 'I campi sono richiesti';
|
||||
|
||||
$this->render('login');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->_authService->authenticate($form->getValues())) {
|
||||
$this->view->error = 'Le credenziali non sono valide!';
|
||||
$this->render('login');
|
||||
return false;
|
||||
}
|
||||
|
||||
//memorizzo le credenziali se necessario
|
||||
$data = $form->getValues();
|
||||
if ($data['ricorda_password'] == 'on') {
|
||||
try {
|
||||
$data['password'] = $this->_rsaCryptor->cripta($data['password']);
|
||||
setcookie($this->_COOKIE_SITE_CREDENTIALS, Zend_Json::encode($data), $this->_COOKIE_EXPIRE_TIME, "/");
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
} else {
|
||||
setcookie($this->_COOKIE_SITE_CREDENTIALS, "", $this->_COOKIE_EXPIRE_TIME, "/");
|
||||
}
|
||||
|
||||
//Accesso andato a buon fine
|
||||
|
||||
//Generazione del Token temporaneo per l'accesso
|
||||
$user = $this->_authService->getIdentity();
|
||||
|
||||
if ($user->role !== 'admin') {
|
||||
if ($user->token != null) {
|
||||
$token = $user->token; //Esistente uso quello già presente
|
||||
} else {
|
||||
do { //se non esiste ne genero uno nuovo e controllo che sia univoco
|
||||
$token = hash('sha1', $user->username . date('YmdHis') . mt_rand(5, 10));
|
||||
if ($this->_genericModel->getByColumnName('Users', 'token', $token)) {
|
||||
$exist = true;
|
||||
} else {
|
||||
$exist = false;
|
||||
}
|
||||
$user->token = $token;
|
||||
} while ($exist);
|
||||
}
|
||||
|
||||
$this->_genericModel->update('Users', $user->id, array('UltimoLogin' => date('Y-m-d H:i:s'), 'token' => $token));
|
||||
} else {
|
||||
$this->_genericModel->update('Users', $user->id, array('UltimoLogin' => date('Y-m-d H:i:s')));
|
||||
}
|
||||
|
||||
$this->_genericModel->insert('Accesslog', array('ip' => $_SERVER['REMOTE_ADDR'], 'tipo' => $this->_authService->getIdentity()->role));
|
||||
|
||||
return $this->_helper->redirector('index', 'index', $this->_authService->getIdentity()->role);
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
// $this->_helper->getHelper('layout')->disableLayout();
|
||||
|
||||
/*if (isset($this->_authService->getAuth()->getIdentity()->username))
|
||||
$this->_helper->redirector('index', $this->_authService->getAuth()->getIdentity()->role);
|
||||
else
|
||||
$this->_helper->redirector('login', 'index', 'default');*/
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ========= ELENCO PAGINE STATIC ACTION ===============================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
public function assistenzaAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function caratteristicheAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function acquistaAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function downloadsoftwareAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function copyrightAction()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function privacyAction()
|
||||
{
|
||||
$this->redirect("https://www.iubenda.com/privacy-policy/70038880");
|
||||
}
|
||||
|
||||
public function cookiepolicyAction()
|
||||
{
|
||||
$this->redirect("https://www.iubenda.com/privacy-policy/70038880/cookie-policy");
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ========= ACTION SPECIALI ===========================================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
public function resetpasswordAction()
|
||||
{
|
||||
$this->_helper->layout->setLayout('admin');
|
||||
|
||||
$this->view->moduleName = 'default';
|
||||
$rcode = $this->getParam('rcode', null);
|
||||
$this->view->hideForm = false;
|
||||
$this->view->rcode = $rcode;
|
||||
|
||||
if (!$rcode && $this->getRequest()->isPost()) {
|
||||
|
||||
$email = $this->_getParam('Email', null);
|
||||
if (!$email) {
|
||||
$this->view->errorMessage = "Inserire un email corretta!";
|
||||
return;
|
||||
}
|
||||
|
||||
$users = $this->_genericModel->getByColumnName('Users', 'Email', $email);
|
||||
if (!$users || !$users['stato'] || $users['role'] === 'admin') {
|
||||
$this->view->warningMessage = "Nessuna corrispondenza per l'email inserita.";
|
||||
$this->view->hideForm = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($users['NumeroResetPw'] > 5) {
|
||||
$this->view->warningMessage = "Hai effettuato troppe richieste per il reseet password, attendi 48 ore o contatta l'amministrazione su xxxx";
|
||||
$this->view->hideForm = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//Genero rcode e incremento il numero di richieste già effettuate per il limite max
|
||||
$numeroReset = ($users['NumeroResetPw']) ? $users['NumeroResetPw'] : 0;
|
||||
$numeroReset += 1;
|
||||
$rcode = md5($users['PartitaIva'] . date('YmdHis'));
|
||||
$this->_genericModel->update('Users', $users['id'], array('DataRichiestaResetPw' => date('Y-m-d H:i:s'), 'rcode' => $rcode, 'NumeroResetPw' => $numeroReset));
|
||||
$users['rcode'] = $rcode;
|
||||
|
||||
//Invio email di recupero
|
||||
$this->inviaEmailDiRecuperoPassword($users);
|
||||
|
||||
$this->view->successMessage = "Ti è stata inviata una email per effettuare il reset della password, consulta la tua casella di posta e segui le istruzioni.";
|
||||
$this->view->hideForm = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// FINE RICHIESTA
|
||||
|
||||
// INIZIO RESET PASSWORD
|
||||
|
||||
if ($rcode) {
|
||||
|
||||
//Controllo del codice rcode
|
||||
$utente = $this->_genericModel->getByColumnName('Users', 'rcode', $rcode);
|
||||
if (!$utente) {
|
||||
$this->view->warningMessage = "La richiesta è scaduta, effettuare una nuova richiesta!";
|
||||
$this->view->rcode = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($this->getRequest()->isPost()) {
|
||||
$form = new Application_Form_Default_Index_Auth_ResetPw();
|
||||
if (!$form->isValid($this->getAllParams())) {
|
||||
$this->view->errorMessage = "Ci sono errori di compilazione, controllare i campi!";
|
||||
$this->view->errorForm = $form->getMessages();
|
||||
$this->view->formData = $form->getValues();
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $form->getValues();
|
||||
$nuovaPassword = md5(Zend_Registry::get('ENVIROMENTS')->get('password_salt') . $data['password']);
|
||||
|
||||
//Inserimento nuova password nel db
|
||||
$this->_genericModel->update('Users', $utente['id'], array('password' => $nuovaPassword, 'rcode' => null, 'NumeroResetPw' => 0));
|
||||
$this->view->successMessage = 'La password è stata reimpostata correttamente, effettua un nuovo login <a href="' .
|
||||
$this->_urlHelper->url(array('action' => 'login', 'controller' => 'index'), 'default', true) . '">cliccando qui.</a>';
|
||||
$this->view->hideForm = true;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sendcontactAction()
|
||||
{
|
||||
$this->_helper->getHelper('layout')->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
|
||||
$form = new Application_Form_Index_Contact_Add();
|
||||
if (!$form->isValid($this->getAllParams())) {
|
||||
return $this->getResponse()->setHeader('Content-type', 'application/json;charset=UTF-8')->setBody(Zend_Json::encode(array(
|
||||
'success' => false,
|
||||
'message' => $form->getMessages(),
|
||||
)));
|
||||
}
|
||||
|
||||
try {
|
||||
$emailTemplate = $this->_genericModel->getByColumnName('EmailTemplate', 'Codice', $this->_configs->get('email_contatto_template'));
|
||||
if (!$emailTemplate) {
|
||||
return $this->getResponse()->setHeader('Content-type', 'application/json;charset=UTF-8')->setBody(Zend_Json::encode(array(
|
||||
'success' => false,
|
||||
'message' => "Email template non trovato o non assegnato",
|
||||
)));
|
||||
}
|
||||
|
||||
$this->_helper->Email->sendEmailByTemplate($this->_configs->get('email_primo_contatto'), $emailTemplate, $form->getValues());
|
||||
|
||||
//Incremento il contatore contatti email
|
||||
$numContatti = $this->_VariabiliSito->get('I_Numero_Contatti_Email');
|
||||
$this->_VariabiliSito->set('I_Numero_Contatti_Email', ++$numContatti);
|
||||
|
||||
$response['success'] = true;
|
||||
} catch (Zend_Exception $e) {
|
||||
return $this->getResponse()->setHeader('Content-type', 'application/json;charset=UTF-8')->setBody(Zend_Json::encode(array(
|
||||
'success' => false,
|
||||
'message' => "si è verificato un errore durante l'invio del messaggio",
|
||||
)));
|
||||
}
|
||||
|
||||
$this->getResponse()->setHeader('Content-type', 'application/json;charset=UTF-8')->setBody(Zend_Json::encode($response));
|
||||
} else {
|
||||
$this->getResponse()->setHeader('Content-type', 'application/json;charset=UTF-8')->setBody(Zend_Json::encode(array('success' => false, 'errore' => 'Operazione non consentita')));
|
||||
}
|
||||
}
|
||||
|
||||
public function sitemapAction()
|
||||
{
|
||||
|
||||
$this->_helper->getHelper('layout')->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
header('Content-type: text/xml');
|
||||
header('Pragma: public');
|
||||
header('Cache-control: private');
|
||||
header('Expires: -1');
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
echo '<urlset
|
||||
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
||||
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
|
||||
|
||||
/*echo '<url>';
|
||||
echo '<loc>https://sfdasdas.com/</loc>';
|
||||
echo '<changefreq>monthly</changefreq>';
|
||||
echo '</url>';*/
|
||||
|
||||
echo '</urlset>';
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ========= FUNZIONI PRIVATE DEL CONTROLLER ===========================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
private function recuperaCredenziali()
|
||||
{
|
||||
//Recupero eventuali credenziali memorizzate
|
||||
if (isset($_COOKIE[$this->_COOKIE_SITE_CREDENTIALS])) {
|
||||
$credentials = Zend_Json::decode($_COOKIE[$this->_COOKIE_SITE_CREDENTIALS]);
|
||||
if ($credentials['ricorda_password'] == 'on') {
|
||||
try {
|
||||
$credentials['password'] = $this->_rsaCryptor->decripta($credentials['password']);
|
||||
} catch (Exception $e) {
|
||||
$credentials = array('ricorda_password' => 'off');
|
||||
}
|
||||
return $credentials;
|
||||
}
|
||||
}
|
||||
|
||||
return array('ricorda_password' => 'on');
|
||||
}
|
||||
|
||||
private function inviaEmailDiRecuperoPassword($user)
|
||||
{
|
||||
|
||||
//Invio email per conferma
|
||||
$emailTemplate = $this->_genericModel->getByColumnName('EmailTemplate', 'Codice', 'EMAIL_RECUPERO_PASSWORD');
|
||||
if (!$emailTemplate) {
|
||||
throw new Exception("Errore invio email richiesta recupero password");
|
||||
}
|
||||
|
||||
$params = $user;
|
||||
$params['link'] = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost()
|
||||
. $this->_urlHelper->url(array('rcode' => $params['rcode']), 'resetpassword', true);
|
||||
$this->_helper->Email->sendEmailByTemplate($params['Email'], $emailTemplate, $params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
class Default_ServicesController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
protected $_configs;
|
||||
protected $_ipManager;
|
||||
|
||||
protected $_genericModel;
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->_helper->getHelper('layout')->disableLayout();
|
||||
|
||||
$this->_configs = new App_Service_ConfigManager();
|
||||
$this->_ipManager = new App_Service_IpManager();
|
||||
$this->_genericModel = new Application_Model_Generic();
|
||||
}
|
||||
|
||||
public function preDispatch()
|
||||
{
|
||||
$action = $this->getRequest()->getActionName();
|
||||
if ($this->_configs->get('interrutore_services') == 'off' && $action != 'offline') {
|
||||
$this->_helper->redirector('offline', 'services');
|
||||
}
|
||||
}
|
||||
|
||||
public function postDispatch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function offlineAction()
|
||||
{
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
echo 'I servizi sono al momento disabilitati.';
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$this->_helper->redirector('index', 'index');
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ================ SERVIZI ================================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ========= FUNZIONI CRON DEL CPANEL ===================================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* =====================================================================================================================
|
||||
* ========= FUNZIONI PRIVATE DEL CONTROLLER ===========================================
|
||||
* =====================================================================================================================
|
||||
*/
|
||||
|
||||
private function _errorToLog($e, $message)
|
||||
{
|
||||
Zend_Registry::get('error_log')->setEventItem('url', $this->getRequest()->getRequestUri())
|
||||
->setEventItem('trace', Zend_Json::encode($e->getTrace()))
|
||||
->setEventItem('params', Zend_Json::encode([]))
|
||||
->setEventItem('section', 'services')
|
||||
->info($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user