示例#1
0
    function __construct($instanceName, $configName=null) {
        //populate the needed connection information from the config.ini file
        $this->instanceName = $instanceName;
        $config = config::getInstance($configName);
        $this->hostname = $config->get('hostname');
        $this->username = $config->get('username');
        $this->password = $config->get('password');
        $this->database = $config->get('database');
        $this->db = mysql_connect($this->hostname, $this->username, $this->password) or die("There was an error conntecting to the database:".$this->database." on server: ".$this->hostname." for user:"******"There was an error selecting the database");
    }
示例#2
0
 private function __construct()
 {
     $this->config = config::getInstance();
     $this->db = db::getInstance();
     $this->adapter = new Smarty();
     $this->adapter->template_dir = $this->config->root_dir . '/temp/templates/';
     $this->adapter->compile_dir = $this->config->root_dir . '/temp/templates_c/';
     $this->adapter->config_dir = $this->config->root_dir . '/temp/configs/';
     $this->adapter->cache_dir = $this->config->root_dir . '/temp/cache/';
     $this->adapter->debugging = $this->config->smarty_debug;
     $this->adapter->caching = TRUE;
     $this->adapter->cache_lifetime = 30;
     $this->adapter->plugins_dir = $this->config->root_dir . '/system/lib/Smarty/libs/plugins';
     $this->adapter->compile_check = TRUE;
     $this->adapter->force_compile = TRUE;
     $this->adapter->register_object('db', $this->db->adapter);
     $this->adapter->register_resource('db', array('smarty_resource_db_source', 'smarty_resource_db_timestamp', 'smarty_resource_db_secure', 'smarty_resource_db_trusted'));
     $this->adapter->register_resource('data', array('smarty_resource_data_source', 'smarty_resource_data_timestamp', 'smarty_resource_data_secure', 'smarty_resource_data_trusted'));
 }
示例#3
0
 public function __construct()
 {
     // parent::__construct();
     config::getInstance();
     config::getConfig();
     $router = new Router();
     $router->explodeUri();
     /*
     apenas para checagem dos caminhos
     //echo '<p>ROUT FILE: '.$routFile.'</p>';
     echo '<pre >';
     echo '<p>ROTA COMPLETA: '.$this->getRoute().'</p>';
     echo '<p>NOME Controller: '.$this->getController().'</p>';
     echo '<p>NOME METODO: '.$this->getAction().'</p>';
     echo '</pre>';
     */
     define('ROUTE', $router->getRoute());
     define('CONTROLLER', $router->getController());
     define('ACTION', $router->getAction());
     $filename = BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . ROUTE . CONTROLLER . '.controller.php';
     if (file_exists($filename)) {
         require_once $filename;
         $_controllerName = CONTROLLER;
         $_controller = new $_controllerName();
         $action = ACTION;
         if (method_exists($_controller, $action)) {
             $_controller->{$action}();
         } else {
             require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
             $errorController = new error404();
             $errorController->index();
         }
     } else {
         require_once BASEPATH . DIRECTORY_SEPARATOR . APPPATH . DIRECTORY_SEPARATOR . CONTROLLERS . DIRECTORY_SEPARATOR . 'error404.controller.php';
         $errorController = new error404();
         $errorController->index();
     }
 }
示例#4
0
 /**
  *
  * @send a message by remote mail server
  *
  */
 public function sendRemote()
 {
     /*** get config values for mail ***/
     $config = config::getInstance();
     /*** headers ***/
     $headers = '';
     $this->stream = fsockopen($config->config_values['mail']['smtp_server'], $config->config_values['mail']['smtp_port'], $errno, $errstr, 1);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "220") {
         echo $res . 'stream fail<br />';
     }
     // Introduce ourselves
     fputs($this->stream, 'HELO ' . $config->config_values['mail']['smtp_server'] . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "250") {
         echo $res . 'helo fail<br />';
     }
     // Envelope from
     fputs($this->stream, 'MAIL FROM: ' . $this->mail_from_email . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "250") {
         echo $res . 'mail from fail<br />';
     }
     // Envelope to
     fputs($this->stream, 'RCPT TO: ' . $this->mail_to_email . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "250") {
         echo $res . 'to fail<br />';
     }
     // The message
     fputs($this->stream, "DATA" . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "354") {
         echo $res . 'data fail';
     }
     // Send To:, From:, Subject:, other headers, blank line, message, and finish
     // with a period on its own line.
     fputs($this->stream, 'To: ' . $this->mail_to_name . ' <' . $this->mail_to_email . '>' . $this->eol . 'From: ' . $this->mail_from_name . ' <' . $this->mail_from_email . '>' . $this->eol . 'Subject: ' . $this->mail_subject . $this->eol . $headers . $this->eol . $this->eol . $this->mail_message . $this->eol . '.' . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "250") {
         echo $res . 'send fail<br />';
     }
     // Say bye bye
     fputs($this->stream, 'QUIT' . $this->eol);
     $res = fgets($this->stream, 256);
     if (substr($res, 0, 3) != "221") {
         echo $res . 'quit fail<br />';
     }
 }