Copyright (c) 2003 XT-Commerce -------------------------------------------------------------- based on: (c) 2000-2001 The Exchange Project (earlier name of osCommerce) (c) 2002-2003 osCommercecoding standards (a typical file) www.oscommerce.com Released under the GNU General Public License --------------------------------------------------------------*/ // The Validation of the API Key Success, and the admin wants to save the key // and getting an Update! // First setting the configuration Params set_module_configuration("SAFETERMS_APIKEY", $safeterms_control["API_KEY"]); set_module_configuration("SAFETERMS_APIKEY_LASTVALIDRESULT", $safeterms_control["API_LASTVALID_RESULT"]); set_module_configuration("SAFETERMS_APIKEY_LASTVALIDTIME", $safeterms_control["API_LASTVALID_TIME"]); set_module_configuration("SAFETERMS_RECHTSTEXT_VERSION", "0"); foreach ($safeterms_control["LANGS"] as $language_id => $language_code) { set_module_configuration("SAFETERMS_LANGUAGE_" . strtoupper($language_code), $language_id); } ?> <div id="main"> <div id="logo_safeterms"> <img src="includes/safeterms/images/logo.png" /> </div> <div id="box"> <div id="content_full"> <p style="margin:50px;text-align:center; font-size:20px;"><strong>API Sicherheitsschlüssel wurde gespeichert<br /><br /><a href="safeterms.php" style="font-size:26px;">Weiter zum Rechtstexte Update >>></a></strong></p> </div> <div style="clear:both;"></div> </div> </div>
function safeterms_update() { // First getting the configuration $safeterms_control["API_KEY"] = read_configuration("SAFETERMS_APIKEY"); $safeterms_control["API_LASTVALID_RESULT"] = read_configuration("SAFETERMS_APIKEY_LASTVALIDRESULT"); $safeterms_control["API_LASTVALID_TIME"] = read_configuration("SAFETERMS_APIKEY_LASTVALIDTIME"); $safeterms_control["API_VERSION"] = read_configuration("SAFETERMS_RECHTSTEXT_VERSION"); $safeterms_control["LANGS"] = read_mconfiguration("SAFETERMS_LANGUAGE_"); // NOW WE RUN THROUGHT ALL PROVIDED LANGUAGES foreach ($safeterms_control["LANGS"] as $language_code => $language_id) { $update_error = 0; $update_log = "<p>" . date("d.m.Y - H:i:s") . " Starte Update...</p>\n"; // AGB // Create The Request $request = array(); $request["TYPE"] = "get_agb"; $request["APIKEY"] = $safeterms_control["API_KEY"]; $request["LANG"] = $language_code; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { // The Response was Fine ... Import it; $agb = str_replace("'", "\\'", $response["CONTENT"]); $module_query = xtc_db_query("UPDATE content_manager SET content_text='" . $agb . "' WHERE content_group='3' AND languages_id='" . $language_id . "'"); $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update AGB [ERFOLGREICH]</p>\n"; } else { $update_error = 1; $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update AGB [FEHLGESCHLAGEN]</p>\n"; } // IMPRESSUM // Create The Request $request = array(); $request["TYPE"] = "get_impressum"; $request["APIKEY"] = $safeterms_control["API_KEY"]; $request["LANG"] = $language_code; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { // The Response was Fine ... Import it; $impressum = str_replace("'", "\\'", $response["CONTENT"]); $module_query = xtc_db_query("UPDATE " . TABLE_CONTENT_MANAGER . " SET content_text='" . $impressum . "' WHERE content_group='4' AND languages_id='" . $language_id . "'"); $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update IMPRESSUM [ERFOLGREICH]</p>\n"; } else { $update_error = 1; $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update IMPRESSUM [FEHLGESCHLAGEN]</p>\n"; } // Datenschutz // Create The Request $request = array(); $request["TYPE"] = "get_datenschutz"; $request["APIKEY"] = $safeterms_control["API_KEY"]; $request["LANG"] = $language_code; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { // The Response was Fine ... Import it; $datenschutz = str_replace("'", "\\'", $response["CONTENT"]); $module_query = xtc_db_query("UPDATE " . TABLE_CONTENT_MANAGER . " SET content_text='" . $datenschutz . "' WHERE content_group='2' AND languages_id='" . $language_id . "'"); $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update DATENSCHUTZ [ERFOLGREICH]</p>\n"; } else { $update_error = 1; $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update DATENSCHUTZ [FEHLGESCHLAGEN]</p>\n"; } // Widerrufsrecht // Create The Request $request = array(); $request["TYPE"] = "get_widerruf"; $request["APIKEY"] = $safeterms_control["API_KEY"]; $request["LANG"] = $language_code; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { // The Response was Fine ... Import it; $widerruf = str_replace("'", "\\'", $response["CONTENT"]); $module_query = xtc_db_query("UPDATE " . TABLE_CONTENT_MANAGER . " SET content_text='" . $widerruf . "' WHERE content_group='9' AND languages_id='" . $language_id . "'"); $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update WIDERRUFSBELEHRUNG [ERFOLGREICH]</p>\n"; } else { $update_error = 1; $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update WIDERRUFSBELEHRUNG [FEHLGESCHLAGEN]</p>\n"; } // Batterieverordnung // Create The Request $request = array(); $request["TYPE"] = "get_batterie"; $request["APIKEY"] = $safeterms_control["API_KEY"]; $request["LANG"] = $language_code; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { // Prüfen ob eine Batterieverordnung bereits existiert $batterie = str_replace("'", "\\'", $response["CONTENT"]); $module_query = xtc_db_query("SELECT content_id as batid FROM " . TABLE_CONTENT_MANAGER . " WHERE content_group='999' AND languages_id='" . $language_id . "'"); if (xtc_db_num_rows($module_query) < 1) { // INSERT $module_query = xtc_db_query("INSERT INTO " . TABLE_CONTENT_MANAGER . " VALUES ('','0','0','','" . $language_id . "','Hinweis Batterieverordnung','Hinweis Batterieverordnung','" . $batterie . "','0','1','','1','999','0','','','')"); } else { // UPDATE $batid = xtc_db_fetch_array($module_query); $module_query = xtc_db_query("UPDATE " . TABLE_CONTENT_MANAGER . " SET content_text='" . $batterie . "' WHERE content_id='" . $batid["batid"] . "' LIMIT 1"); } $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update BATTERIEVERORDNUNG [ERFOLGREICH]</p>\n"; } else { $update_error = 1; $update_log .= "<p>" . date("d.m.Y - H:i:s") . " Update BATTERIEVERORDNUNG [FEHLGESCHLAGEN]</p>\n"; } } // Version anpassen wenn kein Fehler aufgetreten ist $request["TYPE"] = "get_version"; $request["APIKEY"] = $safeterms_control["API_KEY"]; // SEND REQUEST & GETTING RESPONSE $response = talkto($request); if ($response["STATUS"] == "SUCCESS" && $response["VALID"] == "TRUE") { set_module_configuration("SAFETERMS_RECHTSTEXT_VERSION", $response["CONTENT"]); } return array($update_error, $update_log); }