Example #1
0
    public function getEserciziUnita($idUnita) {
        $db = JFactory::getDBO();
        $query = $db->getQuery(true);

        try {
            $query->select('c.esercizi');
            $query->from('#__gg_unit_map AS m');
            $query->join('inner', '#__gg_contenuti AS c ON c.id = m.idcontenuto');
            $query->join('inner', '#__gg_unit AS u1 ON u1.id = m.idunita');
            $query->join('inner', '#__gg_unit AS u2 ON u2.id = u1.categoriapadre');
            $query->where('u2.categoria=' . $idUnita);

            $db->setQuery((string) $query);
            $res = $db->loadColumn();
        } catch (Exception $e) {
            debug::exception($e);
        }

        $res = implode(",",$res);
        return $res;
    }
Example #2
0
 public function get_congressi($type) {
     try {
         $type = filter_var($type, FILTER_VALIDATE_INT, array('options' => array('min_range' => self::TYPE_VIRTUALFORUM, 'max_range' => self::TYPE_SPECIALECONGRESSI)));
         if (empty($type))
             throw new BadMethodCallException('Virtual Forum o Speciale Congressi?', E_USER_ERROR);
         $query = 'SELECT 
                 id,
             	congresso,
             	alias
             FROM psn_gg_congressi   
             WHERE pubblicato = 1
             AND tipologia=' . $type . '
             ORDER BY ordinamento DESC';
         $this->_db->setQuery($query);
         debug::msg($query);
         return $this->_db->loadAssocList();
     } catch (Exception $e) {
         debug::exception($e);
         return array();
     }
 }
Example #3
0
 public function get_congresso($id) {
     try {
         debug::vardump($id, 'id'); 
         $id = filter_var($id, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1)));
         if (empty($id))
             throw new BadMethodCallException('Identificativo congresso non specificato o non valido', E_USER_ERROR);
         $query = 'SELECT 
                 c.congresso,
                 c.banner,
                 c.abstract AS abstract_congresso,
                 c.alias AS alias_congresso,
                 i.*
             FROM #__gg_congressi AS c
             LEFT JOIN #__gg_contenuti AS i ON i.id_congresso = c.id
             WHERE c.pubblicato = 1 AND c.id = ' . $id;
         $this->_db->setQuery($query);
         debug::msg($query);
         return $this->_db->loadAssocList();            
     } catch (Exception $e) {
         debug::exception($e);
     }
 } 
Example #4
0
 /**
  * Ritorna la stringa decodificata.
  * La decodifica consiste nella decifratura della stringa generata da @see crypto::encrypt().
  * In caso di errore ritorna una stringa vuota.
  * 
  * @param string $str Se non viene passata nessuna stringa ritorna una stringa vuota.
  * @return strig
  */
 public function decrypt($str)
 {
     try {
         if (empty($str)) {
             throw new InvalidArgumentException('Empty or not valid string as agrument', E_USER_NOTICE);
         }
         if (!isset($this->_cipher)) {
             throw new UnexpectedValueException('Cypher error', E_USER_WARNING);
         }
         if (false === ($iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->_cipher), MCRYPT_RAND))) {
             throw new UnexpectedValueException('Cannot initialize vector IV', E_USER_WARNING);
         }
         $s = mcrypt_generic_init($this->_cipher, $this->_key, $iv);
         if (0 > $s || false === $s) {
             throw new exceptions('Decrypt failure', E_USER_WARNING);
         }
         $dec = rtrim(mdecrypt_generic($this->_cipher, $str), "");
         mcrypt_generic_deinit($this->_cipher);
         return $dec;
     } catch (Exception $e) {
         debug::exception($e);
         return '';
     }
 }
Example #5
0
    public function checkCoupon() {



    	$query = $this->_db->getQuery(true);
    	try {
    		$query->select('count(coupon)');
    		$query->from('#__gg_coupon as u');
    		$query->where("u.id_utente = $this->_userid");
    		$query->where("(data_scadenza > current_date() OR data_scadenza IS NULL)");
    		$query->where("if(durata is not null, DATEDIFF(DATE_ADD(data_utilizzo, INTERVAL durata DAY), current_date()) > 0, true)");
    		$this->_db->setQuery((string) $query, 0, 1);
    		$res = $this->_db->loadResult();
    	} catch (Exception $e) {
    		debug::exception($e);
    	}

    	return $res;
    }
Example #6
0
 /**
  * Invia la mail
  * @return bool
  */
 public function send()
 {
     try {
         if (empty($this->_to)) {
             throw new exceptions('No receivers specified', E_USER_ERROR);
         }
         if (empty($this->_body)) {
             throw new exceptions('No body specified', E_USER_ERROR);
         }
         $to = $cc = $bcc = array();
         for ($i = 0, $tot = count($this->_to); $i < $tot; $i++) {
             switch ($this->_to[$i]['mode']) {
                 case RCPT_BCC:
                     $bcc[] = $this->_to[$i]['mail'];
                     break;
                 case RCPT_CC:
                     $cc[] = $this->_to[$i]['mail'];
                     break;
                 case RCPT_TO:
                 default:
                     $to[] = $this->_to[$i]['mail'];
             }
         }
         $header = $this->header($cc, $bcc);
         $body = '';
         if ($this->_mime == MIME_PLAIN) {
             if (empty($this->_attach)) {
                 $body = $this->_body;
             } else {
                 $body = '--==mixed' . $this->_boundary . PHP_EOL . 'Content-Type: text/html; charset="' . $this->_charset . '"' . PHP_EOL . 'Content-Transfer-Encoding: quoted-printable' . PHP_EOL . $this->_body . PHP_EOL . PHP_EOL;
             }
         } else {
             if (!empty($this->_attach)) {
                 $body .= '--==mixed' . $this->_boundary . PHP_EOL . 'Content-Type: multipart/alternative;' . PHP_EOL . "\t" . 'boundary="==alternative' . $this->_boundary . '"' . PHP_EOL . PHP_EOL;
             }
             $body .= '--==alternative' . $this->_boundary . PHP_EOL . 'Content-Type: text/plain; charset="' . $this->_charset . '"' . PHP_EOL . 'Content-Transfer-Encoding: 7bit' . PHP_EOL . PHP_EOL . strip_tags($this->_body) . PHP_EOL . PHP_EOL;
             // inizia la seconda parte del messaggio in formato html
             $body .= '--==alternative' . $this->_boundary . PHP_EOL . 'Content-Type: text/html; charset="' . $this->_charset . '"' . PHP_EOL . 'Content-Transfer-Encoding: 7bit' . PHP_EOL . PHP_EOL;
             if (!empty($this->_attach)) {
                 foreach (array_keys($this->_attach) as $id) {
                     $this->_body = preg_replace('/' . $id . '/ie', "'cid:'.md5('\$0')", $this->_body);
                 }
             }
             $body .= $this->_body . PHP_EOL . '--==alternative' . $this->_boundary . '--' . PHP_EOL;
         }
         // gli allegati
         foreach ($this->_attach as $id => $attach) {
             $body .= '--==mixed' . $this->_boundary . PHP_EOL . $attach['header'] . PHP_EOL . $attach['data'] . PHP_EOL . PHP_EOL;
         }
         if (!empty($this->_attach)) {
             $body .= '--==mixed' . $this->_boundary . '--' . PHP_EOL;
         }
         if (mail(join(',', $to), $this->_subject, $body, $header)) {
             return 1;
         } else {
             $error = error_get_last();
             throw new exceptions($error['message'], $error['type']);
         }
     } catch (Exception $e) {
         debug::exception($e);
     }
     return 0;
 }
Example #7
0
	/**
	 * Allega un file alla mail. Il file di default viene aggiunto come attachment e non inline.
	 *
	 * @param string $filepath Percorso al file da includere.
	 * @param bool $inline Se a vero l'oggetto viene inserito nel corpo della mail. Ad esempio un immagine può essere usata nel codice HTML.
	 */
	public function attach($filepath, $inline=false) {
		try {
			$basename = basename($filepath);
			if (!is_readable($filepath)) {
				throw new Exception('Cannot read file '.$basename, E_USER_ERROR);
			}
			$md5_basename = md5($basename);
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			$mimetype = finfo_file($finfo, realpath($filepath));
			finfo_close($finfo);
			$this->_attach[$basename] = array(
				'header' => 'Content-Type: '.$mimetype.';'. PHP_EOL .
					'Content-Transfer-Encoding: base64'. PHP_EOL .
					'Content-ID: <'.$md5_basename.'>'. PHP_EOL .
					(!$inline ? 'Content-Disposition: attachment; filename="'.$basename.'"' : ''),
				'data' => chunk_split(base64_encode(file_get_contents($filepath)))
			);
		} catch (Exception $e) {
			debug::exception($e);
		}
	}
 /**
  * Come @see easy_smarty::display_template(), ma l'output viene restituito sotto forma di stringa.
  * In caso di errore viene restituita una stringa di errore.
  * @param string $template nome del template da utilizzare.
  * @param string $cache_id identificatore univoco per la copia di cache e di compilazione (default NULL).
  * @param bool $check se TRUE Easy Smarty guarda se il file template &#232; cambiato e lo ricompila (default TRUE). Una volta che l'applicazione viene messa in produzione (quindi i template non cambieranno pi&ugrave;), il passo di check non &#232; pi&ugrave; necessario &#232; consigliabile, per massimizzare  le prestazioni, mettere questo parametro a FALSE.
  * @param bool $cache se TRUE l'output &#232; memorizzato nelle cache (default TRUE).
  * @param int $lifetime tempo di validit&#224; (in secondi) della copia in cache; per default &#232; 120 (2 minuti). $cache deve essere impostato a TRUE perch&#233; $lifetime abbia significato. Un valore di -1 significa cache senza scadenza. Il valore 0 far&#224; s&#236; che la cache venga sempre rigenerata (&#232; utile solo in fase di test, per disabilitare il caching un metodo pi&ugrave; efficiente &#232; impostare $cache a FALSE).
  * @return string
  * @throws Exception
  */
 public function fetch_template($template, $cache_id = null, $check = false, $cache = true, $lifetime = 120) {
     $this->caching = $cache ? 2 : 0;
     $this->compile_check = $check;
     if ($cache) {
         try {
             if (!is_int($lifetime)) {
                 throw new DomainException('Cache lifetime must be a valid int', E_USER_WARNING);
             }
             $this->cache_lifetime = $lifetime;
         } catch (Exception $e) {
             debug::exception($e);
             $this->cache_lifetime = 0;
         }
     }
     if (!$this->templateExists($template)) {
         throw new SmartyException('Template file not found:' . ' ' . $template, E_USER_ERROR);
     }
     return $this->fetch($template, $cache_id, $cache_id);
 }
Example #9
0
  private function _certificate_user_info() {
     try {
              $query = 'SELECT
              p.profile_key,
              p.profile_value
              FROM
              #__user_profiles AS p
              WHERE p.user_id = '. $this->_user_id;
      
                // FB::log($query, "query user info");
            $this->_db->setQuery($query);


            if (false === ($results = $this->_db->loadRowlist()))
                throw new RuntimeException($this->_db->getErrorMsg(), E_USER_ERROR);


         foreach ($results as $v)
         {
            $k = str_replace('profile.', '', $v[0]);

            $profile[$k] = json_decode($v[1], true);
                if($k=='datadinascita'){$tmp = explode("-", $profile[$k]); $profile[$k] = $tmp[2]."-".$tmp[1]."-".$tmp[0]; }

        }
        FB::log($profile,"profile");
    return $profile;
    
    } catch (Exception $e) {
           debug::exception($e);
         }           
        return array();
    }
Example #10
0
 static function bootstrap($controller, $method)
 {
     try {
         if ($controller && $method) {
             define('CURRENT_ACTION', substr($controller . ':' . $method, 2));
             if (property_exists($controller, 'static_class')) {
                 if (method_exists($controller, '__before')) {
                     call_user_func($controller . '::__before');
                 }
                 call_user_func(array($controller, $method), explode('/', URL_REQUEST));
                 if (method_exists($controller, '__after')) {
                     call_user_func($controller, '::__after');
                 }
             } else {
                 $object = new $controller();
                 if (method_exists($controller, '__before')) {
                     $object->__before();
                 }
                 call_user_func_array(array($object, $method), array(explode('/', URL_REQUEST)));
                 if (method_exists($controller, '__after')) {
                     $object->__after();
                 }
             }
         } else {
             throw new Exception('absent controller or method', 101);
         }
     } catch (Exception $e) {
         logger::exception('exception', $e->getCode() . ' : ' . $e->getMessage());
         if (preg_match('/^(similar|product)$/', ENVIRONMENT)) {
             if (http::is_ajax()) {
                 http::json(array('error' => 4, 'message' => $e->getMessage(), 'data' => null));
             } else {
                 http::abort($e->getMessage(), '', 10);
             }
         }
         debug::exception($e);
     }
 }
Example #11
0
/**
 * Funzione di default per la gestione degli errori. Gotta Catch 'Em All.
 * @param int $errno
 * @param string $errstr
 * @param string $errfile
 * @param string $errline
 * @param array $errcontext
 */
function PokemonErrorHandler($errno, $errstr, $errfile = null, $errline = null, $errcontext = null)
{
    debug::exception(new exceptions($errstr, $errno, null, $errline, $errfile));
}