<?php
/**
* MiniClick
* Gestionnaire de tableau collaboratif
* Copyright (C) 2006 Guillaume Monet <gm@ibreizh.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
*
* @package miniclick
* @version 5.0.0
*/
$handle = fopen(SMARTY_CACHE_DIR."$_POST[file]", "r") or die("Impossible de lire le fichier");

$ret = "";
while (!feof ($handle)) {
        $ligne = fgets($handle);

        $ligne = str_replace("'","\'",$ligne);
        $ligne = str_replace("\"","",$ligne);
        $ligne = str_replace("\n","",$ligne);
	
        $tableau = explode(";", $ligne);
	$count = count($tableau);
	$sql = "INSERT INTO $_POST[module] (";
	$val = " VALUES (";
	for($i = 0 ; $i< $count;$i++){
		if($_POST[row.$i] != "NM"){
			$sql .= "".$_POST[row.$i].",";
			$val .= "'".$tableau[$i]."',";
		}
	}
	$sql = substr($sql,0,-1);
	$val = substr($val,0,-1);
	$sql .= ")";
	$val .= ");";
	echo "$sql.$val";
	mysql_query($sql.$val) ;
}
?>
