$period = $_POST["period"];
switch ($type) {
    case 'load':
        $ecole = $_POST["ecole"];
        $classe = $_POST["classe"];
        print load($ecole, $classe);
        break;
    case 'gfacture':
        $ids = $_POST["ids"];
        foreach ($ids as &$value) {
            $rawdata = get_child_data($value);
            $ar_data = explode("/", $rawdata);
            $fdata = $ar_data[0];
            $clientid = $ar_data[1];
            //print $fdata;
            $factureids .= enterdata($fdata, $clientid, $print0, $period) . ",";
        }
        $factureids = substr($factureids, 0, -1);
        print $factureids;
        break;
}
///////////////functions////////////////
//////function copy from facture_cantine_submit.php///////////
function enterdata($fdata, $clientid, $print0, $period)
{
    $totalfcp = 0;
    $detail = explode("#", $fdata);
    $totalfcp = $detail[1] * $detail[2];
    $totaleuro = $totalfcp / 120;
    $totaleuro = round($totaleuro, 2);
    $today = date("Y-m-d");
<?php

session_start();
//require_once ('error_handler.php');
require_once 'clients_validate_class.php';
$validator = new Validate();
$validationType = '';
if (isset($_GET['validationType'])) {
    $validationType = $_GET['validationType'];
}
isset($_GET['edit']) ? $edit = $_GET['edit'] : ($edit = 0);
if ($validationType == 'php') {
    if ($validator->ValidatePHP($edit)) {
        //ok
        enterdata($edit);
    } else {
        //not ok
        header("Location:clients.php?edit=" . $edit);
    }
} else {
    $response = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . '<response>' . '<result>' . $validator->ValidateAJAX($_POST['inputValue'], $_POST['fieldID']) . '</result>' . '<fieldid>' . $_POST['fieldID'] . '</fieldid>' . '</response>';
    if (ob_get_length()) {
        ob_clean();
    }
    header('Content-Type: text/xml');
    echo $response;
}
function enterdata($edit)
{
    $nomvalue = strtoupper($_POST['txt_Nom']);
    $nomvalue = strtr($nomvalue, utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), 'AAAAACEEEEIIIINOOOOOUUUUYAAAAACEEEEIIIINOOOOOUUUUY');
<?php

session_start();
//require_once ('error_handler.php');
require_once 'config.php';
require_once 'chrono.php';
//chrono update
$rawdata = $_GET['fdata'];
$fdata = explode("\$", $rawdata);
$clientid = $_GET['clientid'];
$period = $_GET['period'];
$communefactureid = enterdata($fdata, $clientid, $period);
$response = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" . "<response>" . "<facturetempid>{$communefactureid}</facturetempid>" . "</response>";
if (ob_get_length()) {
    ob_clean();
}
header('Content-Type: text/xml');
echo $response;
///////////////////////////functions////////////////////////////////////////////
//////duplicate at ecole_global_search_function.php///////////
function enterdata($fdata, $clientid, $period)
{
    $totalfcp = 0;
    for ($counter = 0; $counter < count($fdata); $counter += 1) {
        $detail = explode("#", $fdata[$counter]);
        $totalfcp += $detail[1] * $detail[2];
    }
    $totaleuro = $totalfcp / 120;
    $totaleuro = round($totaleuro, 2);
    $today = date("Y-m-d");
    $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
<?php

require_once 'config.php';
$userid = $_POST['userid'];
$facturecode = $_POST['facturecode'];
$montant = $_POST['montant'];
$obs = htmlentities($_POST['obs']);
$clientid = $_POST['client'];
$typefacture = substr($facturecode, 0, 4);
$factureid = substr($facturecode, 4);
if ($typefacture == "CANT") {
    $enfantid = getenfantid($factureid);
}
$avoirid = enterdata($clientid, $enfantid, $typefacture, $factureid, $montant, $userid, $obs);
/*$response = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>".
			"<response>".
				"<avoirid>$avoirid</avoirid>".
			"</response>";
	if(ob_get_length()) ob_clean();
	header('Content-Type: text/xml');
	
	echo $response;*/
///////////////////////////functions////////////////////////////////////////////
function getenfantid($factureid)
{
    $mysqli = new mysqli(DBSERVER, DBUSER, DBPWD, DB);
    $query = "SELECT `idenfant` FROM `" . DB . "`.`factures_cantine_details` WHERE `idfacture`='{$factureid}';";
    $result = $mysqli->query($query);
    $row = $result->fetch_array(MYSQLI_ASSOC);
    $idenfant = $row['idenfant'];
    $mysqli->close();
    // In PHP 4.1.0 or later, $_FILES should be used instead of $HTTP_POST_FILES.
    if (is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
        $file = $HTTP_POST_FILES['file']['tmp_name'];
        $settings = compact("indent_width", "max_line", "max", "del_line", "highlight", "braces", "file", "find_functions", "indent_mode");
        $beauty =& new phpBeautify($settings);
        $beauty->toHTML();
        if (PEAR::isError($beauty)) {
            echo $beauty->getMessage() . "\n";
        }
    } else {
        echo "Error: no filename or file too large. Filename: " . $HTTP_POST_FILES['file']['name'];
        enterdata();
        exit;
    }
} else {
    enterdata();
    exit;
}
/**
* Send to the browser a Form with instruction to
* beautify a php file.
*/
function enterdata()
{
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
    <html>
    <head>
    <title>Beautify PHP source code</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
session_start();
//require_once ('error_handler.php');
require_once 'config.php';
require_once 'chrono.php';
//chrono update
$rawdata = $_GET['fdata'];
$fdata = explode("\$", $rawdata);
$clientid = $_GET['clientid'];
$period = $_GET['period'];
$py = $_GET['py'];
$edt = $_GET['edt'];
$eau = $_GET['eau'];
$lieu = strtoupper($_GET['lieu']);
$nav = strtoupper($_GET['nav']);
$comptetype = $_GET['comptetype'];
$communefactureid = enterdata($fdata, $clientid, $period, $py, $lieu, $nav, $edt, $eau, $comptetype);
$response = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" . "<response>" . "<facturetempid>{$communefactureid}</facturetempid>" . "</response>";
if (ob_get_length()) {
    ob_clean();
}
header('Content-Type: text/xml');
echo $response;
///////////////////////////functions////////////////////////////////////////////
//////duplicate at ecole_global_search_function.php///////////
function enterdata($fdata, $clientid, $period, $py, $lieu, $nav, $edt, $eau, $comptetype)
{
    $totalfcp = 0;
    for ($counter = 0; $counter < count($fdata); $counter += 1) {
        $detail = explode("#", $fdata[$counter]);
        $totalfcp += $detail[1] * $detail[2];
    }
if ($echelonnage == '0') {
    $montantcfp = $restearegler;
    $montanteuro = $restearegler / 119.332;
    $restearegler = 0;
    $reglement = 1;
} else {
    $montantcfp = $montantech;
    $montanteuro = $montantcfp / 119.332;
    $restearegler = $restearegler - $montantech;
    if ($restearegler == 0) {
        $reglement = 1;
    } else {
        $reglement = 0;
    }
}
$lastid = enterdata($id, $date_paiement, $payeur, $type, $numero_cheque, $organisme, $date_virement, $date_tresor, $info_tresor, $tpe, $montantcfp, $montanteuro, $mode, $echelonnage, $obs, $restearegler, $reglement, $table);
if ($lastid > 0) {
    $response = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" . "<response>" . "<lastid>{$lastid}</lastid>" . "</response>";
    if (ob_get_length()) {
        ob_clean();
    }
    header('Content-Type: text/xml');
} else {
    $response = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>" . "<response>" . "<lastid>0</lastid>" . "</response>";
    if (ob_get_length()) {
        ob_clean();
    }
    header('Content-Type: text/xml');
}
echo $response;
///////////////////////////functions////////////////////////////////////////////
}
fclose($fpinput);
if ($cumliststr && ($printstr == "L" || $printstr == "A")) {
    $tmp = "<ul>{$cumliststr}</ul><p><p>" . $line;
    printhtml($tmp);
    enterdata("b", $tmp);
}
if ($cumtabstr && ($printstr == "T" || $printstr == "A")) {
    $tmp = "{$tab1}{$cumtabstr}{$tab2}" . $line;
    printhtml($tmp);
    enterdata("t", $tmp);
}
if ($cumparastr && ($printstr == "P" || $printstr == "A")) {
    $tmp = $cumparastr . $line;
    printhtml($tmp);
    enterdata("p", $tmp);
}
$sql = "SELECT id, style, text FROM library.rlahdbk ORDER BY id";
$result = mysql_query($sql);
include "err_msg.inc";
$no = mysql_num_rows($result);
echo "Total Entry: {$no}.<br>";
while (list($id, $style, $text) = mysql_fetch_array($result)) {
    //echo "<b>$id: $style</b><br>";
    echo $text;
}
function enterdata($style, $text)
{
    $text = ereg_replace("'", "\\'", $text);
    $text = ereg_replace('"', '\\"', $text);
    $sql = "INSERT INTO library.rlahdbk SET id='null', style='{$style}', text='{$text}';";