<?php require_once('includes/requirecompere.inc.php'); require_once('includes/requirepost.inc.php'); $action_save=TPOST('save'); $action_addentry=TPOST('addentry'); $action_tidyup=TPOST('tidyup'); $data=array(); $data['entrycount']=TPOST('entrycount'); $data['from']=TPOST('from'); $data['to']=TPOST('to'); $data['ordinal']=TPOST('ordinal'); if ($action_addentry) { $data['entrycount']+=5; $_SESSION['reserv.inputcache.domain']='textreplace'; $_SESSION['reserv.inputcache.data']=$data; $_SESSION['reserv.inputcache.errorareas']=array(); redirect("qx-cmd-textreplace.manage-op-revise.html"); } else if ($action_tidyup) { $_SESSION['reserv.inputcache.domain']='textreplace'; $_SESSION['reserv.inputcache.data']=$data; $_SESSION['reserv.inputcache.errorareas']=array(); redirect("qx-cmd-textreplace.manage-op-revise.html"); } else if ($action_save) { $ordinals=$data['ordinal']; asort($ordinals); $from_arr=$data['from']; $to_arr=$data['to']; $trtable=simplexml_load_string('<?xml version="1.0" encoding="utf-8" ?><trtable/>'); foreach ($ordinals as $key=>$ordinal) { if ($from_arr[$key]) { $trrule=$trtable->addChild('rule'); $trrule->addChild('from',$from_arr[$key]); $trrule->addChild('to',$to_arr[$key]); } } $dest_file=compute_user_path(current_mb_id(),$Config->Paths['user.base'].'/','/trt.xml'); @mkdir(dirname($dest_file),0744,true); file_put_contents($dest_file,$trtable->asXML()); redirect("qx-cmd-textreplace.manage-op-saved.ok.html"); purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); } else redirect("qx-cmd-textreplace.manage.html"); ?>