0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
cron
/
[
Home
]
File: import_cat.php
<?php include("../configuration.inc.php"); $row = 0; $sql = array(); if (($handle = fopen("categories.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if($row>0) : $num = count($data); for ($c=0; $c < $num; $c++) { $d = utf8_encode($data[$c]); //echo $d. "<br />\n"; $line = explode(';',$d); if(!empty($line[0])) { $parent = 0; $id = intval($line[0]); $nom = $line[1]; } elseif(!empty($line[2])) { $id = intval($line[2]); $nom = $line[3]; $parent = substr($id,0,1); } elseif(!empty($line[4])) { $id = intval($line[4]); $nom = $line[5]; $parent = substr($id,0,2); } $position = substr($id,-1,1); $sql[] = "insert into gaia_categories (id, parent_id, nom_fr, position, etat) values ('".$id."', '".$parent."', '".addslashes($nom)."', '".$position."',1)"; } endif; $row++; } fclose($handle); } mysql_query_override("truncate table gaia_categories"); foreach($sql as $s) mysql_query_override($s); echo '<pre>'; print_r($sql); echo '</pre>';