"; while ($data_arr = fgetcsv ($fp, 1000, $SEPARATER_FILE)) { // print line if ($DEBUG_PRINT_INPUT) { print ""; foreach ($data_arr as $data) { print "$data"; } print "\n"; } // split data list($lid,$uid,$cids,$title,$url,$banner,$description, $name,$nameflag,$mail,$mailflag,$company,$addr,$tel,$search, $passwd,$admincomment,$mark,$time_create,$time_update,$hits, $rating,$votes,$comments) = $data_arr; // uid if (empty($uid)) $uid = 1; // admin else $uid = intval($uid); // nameflag, mailflag, hits, rating, votes, comments $nameflag = int_val($nameflag); $mailflag = int_val($mailflag); $hits = int_val($hits); $rating = int_val($rating); $votes = int_val($votes); $comments = int_val($comments); // title, url, banner if (empty($title)) $title = 'no title'; if (empty($url)) $url = 'http://'; if (empty($banner)) $banner = 'http://'; // cids if ($CONVERT_CATEGORY) { $cids_new = ''; $cat_arr = split($SEPARATER_CATEGORY,$cids); foreach ($cat_arr as $cat) { $cid = $cid_arr[$cat]; if ($cid) $cids_new .= '&'.$cid; } if ($cids_new) $cids_new .= '&'; $cids = $cids_new; } // description if ($CONVERT_DESCRIPTION) { $description = str_replace('\n',"\n",$description); } // search $search = "$url $title $company $addr $tel $description $categorys "; if ($nameflag) $search .= "$name "; if ($mailflag) $search .= "$mail "; $search = preg_replace("/\n|\r/",' ',$search); // remove LF code // passwd if (empty($passwd)) $passwd = md5( rand(1000,9999) ); // 4 digits // time $time = time(); if (empty($time_create)) $time_create = $time; if (empty($time_update)) $time_update = $time; $time_print = date("Y/m/d H:i:s",$time_create); // print value if ($DEBUG_PRINT_OUTPUT) { print ""; print "$uid"; print "$cids"; print "$title"; print "$url"; print "$banner"; print "$description"; print "$name"; print "$mail"; print "$company"; print "$addr"; print "$passwd"; print "$time_create"; print "$time_print"; print "$hits"; print "$rating"; print "$votes"; print "\n"; } // add slashe[ $cids = addslashes($cids); $title = addslashes($title); $description = addslashes($description); $name = addslashes($name); $mail = addslashes($mail); $company = addslashes($company); $addr = addslashes($addr); $tel = addslashes($tel); $search = addslashes($search); $passwd = addslashes($passwd); // sql without lid,admincomment,mark,comments $sql = "INSERT INTO $TABLE_LINK (uid,cids,title,url,banner,description, name,nameflag,mail,mailflag,company,addr,tel, search,passwd,time_create,time_update, hits,rating,votes,comments) VALUES ($uid,'$cids','$title','$url','$banner','$description', '$name',$nameflag,'$mail',$mailflag,'$company','$addr','$tel', '$search','$passwd',$time_create,$time_update, $hits,$rating,$votes,$comments )"; if ($DEBUG_PRINT_SQL) print "$sql\n"; // insert mysql if ($DEBUG_MYSQL_INSERT) { $result = mysql_query($sql,$con); if ($result == false) print_error($sql); } } print ""; print ""; fclose ($fp); exit; function int_val($val) { if ($val == '') $val = 0; else $val = intval($val); return $val; } function print_error($sql) { $error = mysql_error(); print "$error
"; print "$sql"; exit; } ?>