示例#1
0
 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())));
     }
 }
示例#2
0
 protected function _InsertRow()
 {
     if ($this->_CreateKeyNamesTable()) {
         $sql = 'INSERT OR REPLACE INTO ' . FB_KEYNAMES_TABLE . ' (colname,orgname) VALUES (?,?);';
         $sth = $this->db->prepare($sql);
         if ($sth === false) {
             writeErrorLog('Failed compile query:', $sql);
         } else {
             foreach (Config::GetInstance()->postkeymap as $key => $value) {
                 if ($key != $value) {
                     if (!$sth->execute(array($key, $value))) {
                         writeErrorLog('Failed to update table keynames:', $sth->errorInfo());
                     }
                 }
             }
         }
     }
     return DataSave::_InsertRow();
 }
示例#3
0
 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;
 }
示例#4
0
 protected function _CheckFields()
 {
     parent::_CheckFields();
     // check for int/decimal changes
     $rules = Config::GetInstance()->GetConfig('rules');
     foreach ($rules as $name => $format) {
         // table_description is filled before creating missing fields, but in that case
         // the field has been created with the right format
         if ($format->fieldtype == 'number' && isset($this->table_description[$name])) {
             if ($format->decimals == 0 && strpos($this->table_description[$name]['Type'], 'int') === false) {
                 $sql = 'ALTER TABLE ' . $this->_EscapeName($this->table) . ' CHANGE ' . $this->_EscapeName($name) . ' ' . $this->_EscapeName($name) . ' int(11)';
             } elseif ($this->table_description[$name]['Type'] != 'decimal(' . 11 + $format->decimals . ',' . $format->decimals . ')') {
                 $sql = 'ALTER TABLE ' . $this->_EscapeName($this->table) . ' CHANGE ' . $this->_EscapeName($name) . ' ' . $this->_EscapeName($name) . ' decimal(' . (11 + $format->decimals) . ',' . $format->decimals . ');';
             } else {
                 continue;
             }
             $this->_Exec($sql);
         }
     }
     return true;
 }
示例#5
0
 function DataSaveCSV($cfg_section)
 {
     parent::__construct($cfg_section);
 }