<commit_before><?php

if (!empty($_POST["save_exit"]) || !empty($_POST["save"])) {
    if (!empty($_REQUEST["module"]) || !empty($_REQUEST["form_module"])) {
     !empty($_REQUEST["form_module"]) ? $_REQUEST["module"] = $_REQUEST["form_module"]:'';
     !empty($_REQUEST["form_name"]) && !empty($_REQUEST["form_module"]) ? $_POST["itemID"] = $_REQUEST["form_name"]:'';
     
     $moduleObj = msv_get("website.".$_REQUEST["module"]);
     $config_path = $moduleObj->pathConfig;
     
     $_SESSION['location_active'] = $_REQUEST["module"];
     
     $configXML = simplexml_load_file($config_path); 
     
     if (!is_writable($config_path)) {
         msv_message_error("Can't write to file '$config_path'");
		unset($_POST["save"]);
		return;
     }
     
     
     foreach ($configXML->locales->locale as $loc) {
        $attributes = $loc->attributes();
        if ((string)$attributes["name"] == LANG) {
           if (!empty($_REQUEST["form_module"])) { 
            $new_rec = $loc->addChild('field');
            $new_rec->addAttribute('name', $_REQUEST["form_name"]);
            $new_rec->addAttribute('value', $_REQUEST["form_value"]);
           } else { 
            foreach ($loc as $fields) {
                $attributes = $fields->attributes();
                if ((string)$attributes["name"] == $_REQUEST['itemID']) {
                    $attributes["value"] = $_REQUEST['form_value'];
                }
            }
           } 
        }
        
     } 
    // echo("<pre>".htmlspecialchars($configXML->asXML())."</pre>");
     $configXML->asXml($config_path);
   }  
   
   if (!empty($_POST["save_exit"])) {
//	MSV_redirect($this->website->langUrl."/admin/?section=$section");
   } 
}

if (!empty($_POST["save"])) {
	$_REQUEST["edit"] = $_POST["itemID"];
}

if (!empty($_REQUEST["delete"])) {
    if (!empty($_REQUEST["module"])) {
        $_SESSION['location_active'] = $_REQUEST["module"];
        $moduleObj = msv_get("website.".$_REQUEST["module"]);
        $config_path = $moduleObj->pathConfig;
        $configXML = simplexml_load_file($config_path); 
        foreach ($configXML->locales->locale as $loc) {
        $attributes = $loc->attributes();
        if ((string)$attributes["name"] == LANG) {
            unset($loc->xpath('field[@name="'.$_REQUEST["delete"].'"]')[0]->{0});
        }
       } 
     //  echo("<pre>".htmlspecialchars($configXML->asXML())."</pre>");
       $configXML->asXml($config_path);       
    }
    msv_redirect($this->website->langUrl."/admin/?section=$section");
}



if (isset($_REQUEST["add_new"])) {
   $modules = array();
    foreach ($this->website->modules as $module) {
    	$modules[$module] = $module;
    }
 <commit_msg>Hot fix #5<commit_after><?php

if (!empty($_POST["save_exit"]) || !empty($_POST["save"])) {
    if (!empty($_REQUEST["module"]) || !empty($_REQUEST["form_module"])) {
     !empty($_REQUEST["form_module"]) ? $_REQUEST["module"] = $_REQUEST["form_module"]:'';
     !empty($_REQUEST["form_name"]) && !empty($_REQUEST["form_module"]) ? $_POST["itemID"] = $_REQUEST["form_name"]:'';
     
     $moduleObj = msv_get("website.".$_REQUEST["module"]);
     $config_path = $moduleObj->pathConfig;
     
     $_SESSION['location_active'] = $_REQUEST["module"];
     
     $configXML = simplexml_load_file($config_path); 
     
     if (!is_writable($config_path)) {
         msv_message_error("Can't write to file '$config_path'");
		unset($_POST["save"]);
		return;
     }
     
     
     foreach ($configXML->locales->locale as $loc) {
        $attributes = $loc->attributes();
        if ((string)$attributes["name"] == LANG) {
           if (!empty($_REQUEST["form_module"])) { 
            $new_rec = $loc->addChild('field');
            $new_rec->addAttribute('name', $_REQUEST["form_name"]);
            $new_rec->addAttribute('value', $_REQUEST["form_value"]);
           } else { 
            foreach ($loc as $fields) {
                $attributes = $fields->attributes();
                if ((string)$attributes["name"] == $_REQUEST['itemID']) {
                    $attributes["value"] = $_REQUEST['form_value'];
                }
            }
           } 
        }
        
     } 
    // echo("<pre>".htmlspecialchars($configXML->asXML())."</pre>");
     $configXML->asXml($config_path);
   }  
   
   if (!empty($_POST["save_exit"])) {
//	MSV_redirect($this->website->langUrl."/admin/?section=$section");
   } 
}

if (!empty($_POST["save"])) {
	$_REQUEST["edit"] = $_POST["itemID"];
}

if (!empty($_REQUEST["delete"])) {
    if (!empty($_REQUEST["module"])) {
        $_SESSION['location_active'] = $_REQUEST["module"];
        $moduleObj = msv_get("website.".$_REQUEST["module"]);
        $config_path = $moduleObj->pathConfig;
        $configXML = simplexml_load_file($config_path); 
        foreach ($configXML->locales->locale as $loc) {
        $attributes = $loc->attributes();
        if ((string)$attributes["name"] == LANG) {
            $res = $loc->xpath('field[@name="'.$_REQUEST["delete"].'"]');
            $parent = $res[0];
            unset($parent[0]);
        }
       } 
     //  echo("<pre>".htmlspecialchars($configXML->asXML())."</pre>");
       $configXML->asXml($config_path);       
    }
    msv_redirect($this->website->langUrl."/admin/?section=$section");
}



if (isset($_REQUEST["add_new"])) {
   $modules = array();
    foreach ($this->website->modules as $module) {
    	$modules[$module] = $module;
    }
 
{'fraction_non_alphanumeric': 0.2157943067033976, 'fraction_numerical': 0.0009182736455463728, 'mean_word_length': 2.9011461318051577, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3393342', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1673, 'n_words': 214}