Пример #1
0
 public static function GetInstance()
 {
     if (!isset(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
         // use the sqlite version for S_Drive, else use the mysql version
         if (Config::GetInstance()->sdrive) {
             include CARTREVISION . '/phphosted/database_sqlite.cls.php';
         } else {
             include CARTREVISION . '/phphosted/database_mysql.cls.php';
         }
     }
     return self::$instance;
 }
Пример #2
0
 private function _Connect()
 {
     // connect to the database
     if ($this->db === false) {
         if (Config::GetInstance()->sdrive) {
             $this->db = new DataAccessSQLite('save_sqlite');
             // attach the transaction database if the form uses payments
             if (Config::GetInstance()->UsePayments()) {
                 $dbfile = TransactionLogger::GetInstance()->GetSqliteFile();
                 if (empty($dbfile) || !file_exists($dbfile)) {
                     writeErrorLog('Tried to attach transaction log, but file is not defined or doesn\'t exist:', $dbfile);
                 } else {
                     $this->transacts = $this->db->AttachTransActions($dbfile);
                 }
             }
         } else {
             $this->db = new DataAccessMySQL('save_database');
         }
     }
 }
Пример #3
0
 public function saveCartToDB()
 {
     $data = $this->getCartInstance()->exportCart();
     $data['status'] = 'redirect';
     $data['testmode'] = -1;
     // get existing order reference in case this is an update instead of a new transaction
     $transactid = Config::GetInstance()->GetSessionVariable(ORDERREFKEY);
     if (!TransactionLogger::GetInstance()->saveData($data, $transactid)) {
         // unset the session variable to ensure the cart scripts don't use empty values
         Config::GetInstance()->UnsetSessionVariable(ORDERREFKEY);
         Config::GetInstance()->UnsetSessionVariable(CC_FB_CARTID);
         writeErrorLog('Failed to write transaction details to the database', TransactionLogger::GetInstance()->getError());
         return false;
     }
     // add the transaction id to the session for the cart
     Config::GetInstance()->SetSessionVariable(ORDERREFKEY, $transactid);
     // store a copy for FB, avoids the need to including the cart when getting feedback from a gateway
     Config::GetInstance()->SetSessionVariable(CC_FB_CARTID, $transactid);
     return $transactid;
 }
Пример #4
0
 public function DropTransactions()
 {
     // nothing to do if the form doesn't have payments associated
     if (!Config::GetInstance()->UsePayments()) {
         return;
     }
     TransactionLogger::GetInstance()->dropData();
 }