/** * Replaces Rsa key pair. The first step: prepare temporary data on the server: * a temporary table in the DB to reencrypt data etc. * * : close the shop? * * It removes the temporary table with the reencrypted data order_person_info, * if it exists. It creates the same one, by copying order info. * It initializes and saves required ancillary variables to the module * settings Offline CC. * */ function ReplaceRSAKeyPairStep1PrepareServerTmpData() { global $application; $table_prefix = $application->getAppIni('DB_TABLE_PREFIX'); $table_suffix = modApiFunc("Payment_Module_Offline_CC", "getTmpTableSuffix"); $table_name = "order_person_data"; $table_name_with_prefix_and_suffix = $table_prefix . $table_name . $table_suffix; $table_name_with_suffix = $table_name . $table_suffix; if (DB_MySQL::DB_isTableExists($table_name_with_prefix_and_suffix)) { /** * Remove old temporary data. It can left if, for example, * the previous data reencryption wasn't completed. */ $db_table_delete = new DB_Table_Delete($table_name_with_suffix); $application->db->PrepareSQL($db_table_delete); $application->db->DB_Exec(); } //Prepare new temporary data for reencrypting. new DB_Table_Clone("Checkout", $table_name, $table_name . $table_suffix); /** * Prepare new optional data storing reencription status. * * The field order_person_data_id has now an attribute auto_increment now, * so just remember that not decrypted, where we stopped last time. * All records with great ID will be considered as not reencrypted. * */ $this->ReplaceRSAKeyPairStep2ReencryptTmpDataOrderPersonDataId = 1; modApiFunc("Payment_Module_Offline_CC", "saveState"); }
/** * DB_Table_Create class constructor. * * @return * @param array $tables array of meta description of the tables. * @ change error messages to error description from resource file */ function DB_Table_Create($tables) { global $application; $table_prefix = $application->getAppIni('DB_TABLE_PREFIX'); foreach ($tables as $table_name => $table_properties) { $table_name = $table_prefix . $table_name; if (DB_MySQL::DB_isTableExists($table_name)) { _fatal(array("CODE" => "CORE_043"), $table_name); } $this->QueryType = DBQUERY_TYPE_CREATE; $this->CreateTable = $table_name; $this->CreateFields = array(); $this->CreateKeys = array(); $this->CreateIndexes = array(); foreach ($table_properties['columns'] as $key => $field) { $this->addField($this->parseFieldName($field), $table_properties['types'][$key]); } if (isset($table_properties['primary']) && sizeof($table_properties['primary']) > 0) { $primary_key = array(); foreach ($table_properties['primary'] as $pk) { array_push($primary_key, $this->parseFieldName($table_properties['columns'][$pk])); } $this->addKey(implode(', ', $primary_key)); } if (isset($table_properties['indexes']) && sizeof($table_properties['indexes']) > 0) { foreach ($table_properties['indexes'] as $index_name => $field_names) { $field_names = str_replace(' ', '', $field_names); $fields = explode(',', $field_names); $index = array(); foreach ($fields as $field) { // , if (is_int($_pos = _ml_strpos($field, '('))) { $_len = _ml_substr($field, $_pos); $_field_without_len = _ml_substr($field, 0, $_pos); array_push($index, $this->parseFieldName($table_properties['columns'][$_field_without_len]) . $_len); } else { array_push($index, $this->parseFieldName($table_properties['columns'][$field])); } } $this->addIndex(implode(', ', $index), $index_name); } } $application->db->getDB_Result($this); } }
/** * Returns Module's version if the module with the specified name is installed. */ function getModuleVersion($moduleName) { global $application; $tables = $this->getTables(); $module_tbl = 'module'; $module_columns = $tables[$module_tbl]['columns']; if (!DB_MySQL::DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . $module_tbl)) { // the table 'module' doesn't exist, so update should not be performed return '0.0.0'; } static $updated_modules = null; if ($updated_modules == null) { $db_select = new DB_Select(); $db_select->addSelectTable($module_tbl); $db_select->addSelectField($module_columns['version'], 'version'); $db_select->WhereValue($module_columns['name'], DB_EQ, $moduleName); $result = $application->db->getDB_Result($db_select); $updated_modules = array(); foreach ($result as $resultItem) { $resultversion[] = $resultItem['version']; } } if (!empty($resultversion)) { return $resultversion[0]; } else { return '0.0.0'; } }