function DataSaveMySQL($cfg_section) { parent::__construct($cfg_section); // note that a connect attempt may throw an exception that may reveal the userid/password try { $this->_Connect(); } catch (PDOException $e) { switch ($e->getCode()) { case 1049: if ($this->_CreateMySqlDb()) { // try to connect again try { $this->_Connect(); } catch (PDOException $e) { writeErrorLog('Connection retry after DB creation failed: [' . $e->getCode() . ']', $e->getMessage()); } } else { writeErrorLog('Failed to create a new database.'); $errors[] = array('err' => _T('Failed to create new database [%s] %s.', array($e->getCode(), $e->getMessage()))); } break; default: writeErrorLog('Problems connecting to MySQL: [' . $e->getCode() . ']', $e->getMessage()); $this->errors[] = array('err' => _T('Failed to open database [%s] %s.', array($e->getCode(), $e->getMessage()))); } } }
function __construct($cfg_section) { parent::__construct($cfg_section); $sqlite_folder = Config::GetInstance()->GetStorageFolder(2); $db = Config::GetInstance()->GetConfig('settings', 'data_settings', $cfg_section); if (!$db) { writeErrorLog('Failed to get configuration data in ' . __CLASS__ . ' for section: ', $cfg_section); $this->errors[] = array('err' => _T('Failed to open database.')); return; } // database names longer than 248 chars won't work // (it seems sqlite has no problem with table names in excess of 450 chars) if (strlen($db->database) > 200) { $dbname = substr($db->database, 0, 200) . md5($db->database); } else { $dbname = $db->database; } try { try { $this->db = new PDO('sqlite:' . $sqlite_folder . $dbname); } catch (PDOException $e) { if (file_exists($sqlite_folder) || !mkdir($sqlite_folder, 0755, true)) { throw $e; } $this->db = new PDO('sqlite:' . $sqlite_folder . $dbname); } } catch (PDOException $e) { // Something happened and couldn't connect to SQLLite writeErrorLog('Problems connecting to SQLite ' . $sqlite_folder . $dbname . ': [' . $e->getCode() . ']', $e->getMessage()); $this->errors[] = array('err' => _T('Failed to open database [%s] %s', array($e->getCode(), $e->getMessage()))); } }
function __construct($cfg_section) { parent::__construct($cfg_section); $this->mailer = new Mailer(); if (Config::GetInstance()->sdrive) { // use sdrive config if available $config['service'] = 'smtp'; $config['smtp']['auth'] = false; $config['smtp']['user'] = ''; $config['smtp']['password'] = ''; $config['smtp']['host'] = Config::GetInstance()->sdrive['smtp_server']; $config['smtp']['port'] = Config::GetInstance()->sdrive['smtp_port']; $config['smtp']['secure'] = ''; $this->mailer->SetConfig($config); // stop our newsletter processing system from rewrite all URLs and adding the tracking image. $this->mailer->extra_header = 'X-GreenArrow-MailClass: noclick'; } else { // check if the user config exists in include path $handle = @fopen(CC_USERCONFIG, 'r', 1); if ($handle) { fclose($handle); include CC_USERCONFIG; if (isset($user_config['mailer'])) { $this->mailer->SetConfig($user_config['mailer']); } } } // generate default from address, remove all characters that aren't alpha numerical to avoid problems global $myName; $name = preg_replace('/[^a-z0-9]/i', '', $myName); // get a server name, we need HTTP_X_FORWARDED_HOST when on sdrive if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { list($server) = explode(',', $_SERVER['HTTP_X_FORWARDED_HOST']); } else { $server = $_SERVER['SERVER_NAME']; } // set the default $this->default_from = $name . '@' . $server; }
function DataSaveCSV($cfg_section) { parent::__construct($cfg_section); }