Example #1
0
 public static function MatchRule($rule, $controller)
 {
     $subject = $_SERVER['REQUEST_URI'];
     $rulematch = $rule->getAttribute('match');
     /* Check if the app is running in a subdir */
     $subdir = Configuration::Query('/configuration/domain/@subdir');
     if ($subdir && $subdir->item(0)->nodeValue != '') {
         $rulematch = '^\\/' . $subdir->item(0)->nodeValue . $rulematch;
         // echo $rulematch;
         // die;
     } else {
         $rulematch = '^' . $rulematch;
     }
     $pattern = '#' . $rulematch . '#';
     $replace = $rule->getAttribute('args') != '' ? $rule->getAttribute('args') : false;
     $method = $rule->getAttribute('apply');
     if (preg_match($pattern, $subject, $matches)) {
         if ($replace) {
             $args = preg_replace($pattern, $replace, $subject);
             $args = str_replace('?', '', $args);
             $args = explode('&', $args);
             $namedArgs = array();
             foreach ($args as $argument) {
                 $thisArg = explode('=', $argument);
                 if (isset($thisArg[0]) && isset($thisArg[1])) {
                     $namedArgs[$thisArg[0]] = $thisArg[1];
                 }
             }
             call_user_func_array(array((string) $controller, (string) $method), $namedArgs);
         } else {
             call_user_func(array((string) $controller, (string) $method));
         }
         die;
     }
 }
Example #2
0
 public function GetFolderName()
 {
     //$conf = Configuration::GetConfiguration();
     $devices = Configuration::Query('/configuration/devices/device');
     $generic = '';
     foreach ($devices as $rule) {
         $name = $rule->getAttribute('name');
         if ($name != 'desktop') {
             $match = (bool) preg_match("/" . $this->devices[$name] . "/i", $this->userAgent);
             if ($match) {
                 return $rule->getAttribute('directory');
                 exit;
             }
         }
     }
     // return desktop
     $desktop = Configuration::Query('/configuration/devices/device[@default="1"]');
     return $desktop->item(0)->getAttribute('directory');
 }
Example #3
0
 /**
  *	Deferred Publication
  *	
  *	@return void
  */
 public static function deferredPublication()
 {
     $modules = Configuration::Query('/configuration/modules/module');
     foreach ($modules as $module) {
         if (method_exists($module->getAttribute('controller'), 'PublishContent')) {
             $moduleController = $module->getAttribute('controller');
             // Pregunta si el modulo no hereda de Element para no hacer tantas consultas a la base
             if (!is_subclass_of($moduleController, 'ElementController')) {
                 $moduleController::PublishContent();
             }
         }
     }
     die;
 }
Example #4
0
*	Register php files to autoload from classes directories
*/
spl_autoload_extensions('.php');
spl_autoload_register();
ini_set("memory_limit", "128M");
/**
*	Set Error reporting
*/
error_reporting(E_STRICT | E_ALL);
ini_set('track_errors', 1);
/* Set application path */
PathManager::SetApplicationPath(dirname(dirname(__FILE__)));
/**
*	Load Configuration
*/
Configuration::LoadConfiguration();
/**
*	We will handle Errors
*/
set_error_handler(array('Error', 'ErrorHandler'));
set_exception_handler(array('Error', 'ExceptionHandler'));
/**
*	default timezone should be in configuration
*/
date_default_timezone_set(Configuration::Query('/configuration/timezone')->item(0)->nodeValue);
/**
* Start Session
*/
session_set_cookie_params(0, '/', '', 0, 1);
ini_set('session.cookie_httponly', 1);
Session::Start();
Example #5
0
 private static function SendEmail($address, $html, $subject, $rtte = false)
 {
     $tcpNode = Configuration::Query('/configuration/smtp');
     $server = $tcpNode->item(0)->nodeValue;
     $mail = new PHPMailer(true);
     try {
         $mail->Host = $server;
         // SMTP server
         $mail->Port = 25;
         // set the SMTP port for the GMAIL server
         $mail->AddAddress($address);
         $rtte = $rtte !== false ? $rtte . ' ' : '';
         $rtte .= Configuration::GetSenderName();
         $mail->SetFrom(Configuration::GetSender(), utf8_decode($rtte));
         $mail->Subject = $subject;
         $mail->MsgHTML(utf8_decode($html));
         $mail->Send();
     } catch (Exception $e) {
         echo $e->getMessage();
         // El mensaje no se pudo enviar
     }
 }
Example #6
0
 public static function isAdmin()
 {
     $conf = Configuration::Query('/configuration/adminpath');
     $manager = $_SERVER['PHP_SELF'];
     /* Ruta del archivo ejecutado */
     $adminFolder = $conf->item(0)->nodeValue;
     if (stristr($manager, $adminFolder)) {
         return true;
     } else {
         return false;
     }
 }