| 
<?
if($_GET['step']==2){
 echo "<h2>Step 2</h2>";
 echo "If You got error 'Maximum execution time' error, please download file from http://googs.me/ip/ip_database.csv and upload in step one.";
 if(!$_GET['file']){
 $file="http://googs.me/ip/ip_database.csv";
 }else{
 $file=$_GET['file'];
 }
 if($f=file($file)){
 include('ip2c_config.php');
 if($db=mysql_connect($db_host, $db_login, $db_pass)){
 if(!mysql_select_db($db_database)){
 echo "Error - please create database $db_database";
 }else{
 mysql_query("CREATE TABLE `$db_table` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `ip_start` INT NOT NULL ,
 `ip_end` INT NOT NULL ,
 `2l_country` VARCHAR( 2 ) NOT NULL ,
 `3l_country` VARCHAR( 3 ) NOT NULL ,
 `country` VARCHAR( 255 ) NOT NULL
 ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;");
 for($i=0;$i<count($f);$i++){
 $d=explode(",",$f[$i]);
 mysql_query("INSERT INTO $db_table SET ip_start='{$d[0]}',ip_end='{$d[1]}',2l_country='{$d[4]}',3l_country='{$d[5]}',country='".str_replace("\n","",$d[6])."'");
 }
 echo "<br/><br/>install complete.";
 exit;
 }
 }else{
 echo "Error - database connect.";
 }
 }else{
 echo "Error - cannot download file http://googs.me/ip/ip_database.csv, please try download http://googs.me/ip/ip_database.csv or write to [email protected] or [email protected].";
 }
 }
 if($_POST['submit']){
 $conf='
 /*
 
 IP 2 Country class on MySQL
 2011.01
 Kacper Zbonikowski - POLAND
 mobile +48 501079176 email: [email protected]
 Free to non-comercial use
 
 
 if you use ip_database.csv please add http://webnet77.com/ link on your site
 
 
 */
 $db_host="'.$_POST['host'].'";
 $db_login="'.$_POST['login'].'";
 $db_pass="'.$_POST['pass'].'";
 $db_database="'.$_POST['database'].'";
 $db_table="'.$_POST['table'].'";
 ';
 if($fp = fopen('ip2c_config.php', 'w')){
 fwrite($fp, '<?'.$conf.'?>');
 fclose($fp);
 if($_FILES['csv']['tmp_name'])header("Location: install.php?step=2&file=".$_FILES['csv']['tmp_name']);
 header("Location: install.php?step=2");
 }else{
 echo "Error, cannot write to file ip2c_config.php .<br/>\nPlease write this:<br/>\n<br/>\n<code><?".nl2br($conf)."?></code><br/>\n<br/>\nto ip2c_config.php and go to <a href='install.php?step=2'>install.php?step=2</a>";
 }
 }
 ?>
 <h2>Step 1</h2>
 <form action="#" method="POST" enctype="multipart/form-data">
 <fieldset>
 <legend>DB info:</legend>
 Database host: <input type="text" name="host"/><br/>
 Database login: <input type="text" name="login"/><br/>
 Database password: <input type="text" name="pass"/><br/>
 Database name:<input type="text" name="database"/><br/>
 Database table name:<input type="text" name="table"/><br/>
 File (if you download ip_database.csv)<input type="file" name="csv"/><br/>
 <input type="submit" name="submit"/>
 </fieldset>
 </form>
 |