<?php

/*$host = "ftp.lci.in";

$user = "androidappp";

$pass = "A!ms99AA";

$dbname = "androidappp";

$dbconnect = @mysql_connect($host,$user,$pass);

$selectdb = @mysql_select_db($dbname,$dbconnect);*/

extract($_GET);

//echo "hello";

echo $_GET['file'];

echo "<br>";

$input_cnt=0;$info_cnt=0;$img_cnt=0;$marker_cnt=0;

try

{

$dbh = new PDO("sqlite:test11");

$connection_1 = mysql_connect("androidappp.db.4594972.hostedresource.com", "androidappp", "A!ms99AA") or die(mysql_error());

mysql_select_db("androidappp", $connection_1) or die(mysql_error());

echo "Handle has been created ...... <br><br>";



}

catch(PDOException $e)

{

echo $e->getMessage();

echo "<br><br>Database -- NOT -- loaded successfully .. ";

die( "<br><br>Query Closed !!! $error");

}





/*$result = mysql_query("select * from info", $connection_1);

//$res = mysql_fetch_array($result);

while($res = mysql_fetch_array($result))

{

$x = $res["con"];

echo $x;

}

*/

echo "Database loaded successfully ....<br>";

$sql_input = "SELECT * FROM input_form where sync='false'";

$rs_input = $dbh->query($sql_input);

if($sql_input) {echo"input_form with false <br>";}

$rs_input->setFetchMode(PDO::FETCH_ASSOC);

while ($row = $rs_input->fetch()) {

$id = $row["id"];

$ward_office = $row["ward_office"];

$survey_sheet_no = $row["survey_sheet_no"];

$ward = $row["ward"];

$date = $row["current_date"];

$sub_area = $row["sub_area"];

$mseb = $row["mseb"];

$plot_no = $row["plot_no"];

$society_name = $row["society_name"];

$landmark = $row["landmark"];

$pincode = $row["pincode"];

$city = $row["city"];

$state = $row["state"];

$country = $row["country"];

$owner = $row["owner"];

$house_no = $row["house_no"];

$plot_area = $row["plot_area"];

$type = $row["type"];

$miscellaneous = $row["miscellaneous"];

$informer = $row["informer"];

$surveyor = $row["surveyor"];

$sync = $row["sync"];



echo $date;

$sql1=mysql_query("insert into input_form(ward_office,survey_sheet_no,ward,current_date1,sub_area,plot_no,society_name,landmark,pincode,city,state,country,owner,house_no,plot_area,type,miscellaneous,informer,surveyor,sync)values('$ward_office','$survey_sheet_no','$ward','$date','$sub_area','$plot_no','$society_name','$landmark','$pincode','$city','$state','$country','$owner','$house_no','$plot_area','$type','$miscellaneous','$informer','$surveyor',$sync)",$connection_1);

if($sql1){echo "successfully executed input_form <br>";}

$Field11 = 'true';



$sql = "UPDATE input_form

SET sync=?

WHERE id=?";

$q = $dbh->prepare($sql);

$q->execute(array($Field11,$id));

if($q){echo "update input_form success<br>";}

$input_cnt++;

}



$sql = "SELECT * FROM info where sync='false'";

$rs = $dbh->query($sql);

if($sql) {echo"info with false <br>";}

$rs->setFetchMode(PDO::FETCH_ASSOC);

while ($row = $rs->fetch()) {

$pid = $row["pid"];

$tree_name = $row["tree_name"];

$scientific_name = $row["scientific_name"];

$width = $row["width"];

$height = $row["height"];

$age = $row["age"];

$con = $row["con"];

$lng = $row["lng"];

$lat = $row["lat"];

$aid = $row["aid"];

$sync = $row["sync"];



$sql1=mysql_query("insert into info(tree_name,scientific_name,width,height,age,con,lng,lat,aid,sync)values('$tree_name','$scientific_name','$width','$height','$age','$con','$lng','$lat','$aid','$sync')",$connection_1);

if($sql1){echo "successfully executed info <br>";}

$Field11 = 'true';



$sql = "UPDATE info

SET sync=?

WHERE pid=?";

$q = $dbh->prepare($sql);

$q->execute(array($Field11,$pid));

if($q){echo "update info success<br>";}

$info_cnt++; }





$sql = "SELECT * FROM image_path where sync='false'";

$rs = $dbh->query($sql);

if($sql) {echo"image_path with false <br>";}

$rs->setFetchMode(PDO::FETCH_ASSOC);

while ($row = $rs->fetch()) {

$pic_id = $row["pic_id"];

$aid = $row["aid"];

$img_path = $row["img_path"];

$sync = $row["sync"];

$img = explode('\\',$img_path);

echo $img[2];

$str = 'images/'.$img[2];

$sql1=mysql_query("insert into image_path(aid,img_path,sync)values('$aid','$str','$sync')",$connection_1);

echo "insert into image_path(aid,img_path,sync)values('$aid','$str'','$sync')";

if($sql1){echo "successfully executed image_path <br>";}

$Field11 = 'true';



$sql = "UPDATE image_path

SET sync=?

WHERE pic_id=?";

$q = $dbh->prepare($sql);

$q->execute(array($Field11,$pic_id));

if($q){echo "update image_path success<br>";}

$img_cnt++;

}



$i = 1;

$sql = "SELECT * FROM markers where sync='false'";

$rs = $dbh->query($sql);

if($sql) {echo"markers with false <br>";}

$rs->setFetchMode(PDO::FETCH_ASSOC);

while ($row = $rs->fetch()) {

$id = $row["id"];

$lat = $row["lat"];

$lng = $row["lng"];

$aid = $row["aid"];

$sync = $row["sync"];



$sql1=mysql_query("insert into markers(lat,lng,aid,sync)values('$lat','$lng','$aid','$sync')",$connection_1);

if($sql1){echo "successfully executed markers <br>";}

$Field11 = 'true';



$sql = "UPDATE markers

SET sync=?

WHERE id=?";

$q = $dbh->prepare($sql);

$q->execute(array($Field11,$id));

if($q){echo "update markers success<br> ".$i;}

$marker_cnt++;

$i++;

}



?>



<script language="javascript" type="text/javascript">

alert("Total "+<?php $input_cnt ?> "plot records are uploded.\n Total"+<?php $info_cnt?> "tree records are uploaded. \n Total "+<?php $img_cnt?> "images are uploaded. \n Total "+<?php $marker_cnt ?> "geo location records are uploaded. \n");

window.location="file_upload.php";

</script>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>



<body>



</body>

</html>