Created
July 19, 2012 09:26
-
-
Save 1900/3142649 to your computer and use it in GitHub Desktop.
Revisions
-
1900 renamed this gist
Aug 30, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
1900 created this gist
Jul 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,123 @@ <?php error_reporting(E_ALL ^ E_NOTICE); //FUNCTION: Connect to PostgreSql database //create a connection to postgresql database set_time_limit(0); ini_set("memory_limit", "200M"); pg_connect("host=localhost dbname=comds user=root password=root") or die('Could not connect:'.pg_last_error()); $handle = fopen("http://192.168.0.10/log/demo/log.txt", "r"); while (!feof($handle)) { $buffer = fgets($handle, 10960); $arr = json_decode($buffer, true); $id100 = $arr["data"]; $arr2 = json_decode($id100, true); $id = $arr2["TotalExp"]; $id2 = $arr2["FirstLoginTime"]; $id3 = $arr2["TotalDollorGet"]; $id4 = $arr2["TodayGameTime"]; $id5 = $arr2["TodayTCrystalLose"]; $id6 = $arr2["Crystal"]; $id7 = $arr2["TodayGoldGet"]; $id8 = $arr2["TodayGoldLose"]; $id9 = $arr2["Cracked"]; $id10 = $arr2["WeaponList"]; $id11 = $arr2["TodayExp"]; $id12 = $arr2["TodayIapInfo"]; $id13 = $arr2["Gold"]; $id14 = $arr2["Level"]; $id15 = $arr2["GameActiveTime"]; $id16 = $arr2["TotalGoldGet"]; $id17 = $arr2["UILastId"]; $id18 = $arr2["HireoutSelfTimes"]; $id19 = $arr2["TotalGameTime"]; $id20 = $arr2["TodayTCrystalGet"]; $id21 = $arr["deviceid"]; $id22 = $arr["gamename"]; $id24 = $arr["createdate"]; $s = 0; foreach ((array) $arr as $item => $value) { //Warning: Invalid argument supplied for foreach $s = count($value); } for ($i = 0; $i < $s; $i++) { $TotalExp = $id; $FirstLoginTime = $id2; $TotalDollorGet = $id3; $TodayGameTime = $id4; $TodayTCrystalLose = $id5; $Crystal = $id6; $TodayGoldGet = $id7; $TodayGoldLose = $id8; $Cracked = $id9; $WeaponList = $id10; $TodayExp = $id11; $TodayIapInfo = $id12; $Gold = $id13; $Level = $id14; $GameActiveTime = $id15; $TotalGoldGet = $id16; $UILastId = $id17; $HireoutSelfTimes = $id18; $TotalGameTime = $id19; $TodayTCrystalGet = $id20; $deviceid = $id21; $gamename = $id22; $createdate = $id24; $date = substr($id24,0,10); pg_query("INSERT INTO comds ( totalexp, firstlogintime, totaldollorget, todaygametime, todaytcrystallose, crystal, todaygoldget, todaygoldlose, cracked, weaponlist, todayexp, todayiapinfo, gold, level, gameactivetime, totalgoldget, uilastid, hireoutselftimes, totalgametime, todaytcrystalget, deviceid, gamename, createdate, date, whatday) VALUES('$TotalExp', '$FirstLoginTime', '$TotalDollorGet', '$TodayGameTime', '$TodayTCrystalLose', '$Crystal', '$TodayGoldGet', '$TodayGoldLose', '$Cracked', '$WeaponList', '$TodayExp', '$TodayIapInfo', '$Gold','$Level', '$GameActiveTime', '$TotalGoldGet', '$UILastId', '$HireoutSelfTimes', '$TotalGameTime', '$TodayTCrystalGet', '$deviceid', '$gamename', '$createdate', '$date', '$FirstLoginTime')") or die(pg_last_error()); } } fclose($handle); print "Import successful!<br>"; ?>