Example #1
0
 /**
  * Performs database upgrades when required
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function upgrades()
 {
     $installed = ShoppSettings::dbversion();
     // No upgrades required
     if ($installed == ShoppVersion::db()) {
         return;
     }
     shopp_set_setting('shopp_setup', '');
     shopp_set_setting('maintenance', 'on');
     if ($installed < 1100) {
         $this->upgrade_110();
     }
     if ($installed < 1200) {
         $this->upgrade_120();
     }
     if ($installed < 1300) {
         $this->upgrade_130();
     }
     $db = sDB::object();
     file_put_contents(SHOPP_PATH . '/shopp_queries.txt', json_encode($db->queries));
     ShoppSettings()->save('db_version', ShoppVersion::db());
 }
Example #2
0
 public static function instance()
 {
     return sDB::object();
 }
Example #3
0
 /**
  * Decrypts the session data.
  *
  * The session data is passed by reference and will be decrypted
  * as long as a valid encryption key is available (exists in the cookie).
  *
  * When no encryption key cookie is available (usually because of switching
  * from HTTPS to HTTP) an unlock process is fired (handled by a concrete
  * implementation).
  *
  * @since 1.3.6
  *
  * @param array $data The session data to possibly decrypt
  * @return void
  **/
 private function decrypt(&$data)
 {
     $BOF = strlen(self::ENCRYPTION);
     // Set the secured flag if the data is encrypted
     $this->secured = self::ENCRYPTION == substr($data, 0, $BOF);
     if (!$this->secured) {
         return;
     }
     if (empty($_COOKIE[SHOPP_SECURE_KEY])) {
         return $this->unlock();
     }
     // No encryption key available, run unlock handler
     $key = $_COOKIE[SHOPP_SECURE_KEY];
     $db = sDB::object();
     $data = sDB::query("SELECT AES_DECRYPT('" . $db->api->escape(substr($data, $BOF)) . "','{$key}') AS data", 'auto', 'col', 'data');
 }