[Phonehome-commits] r57 - in branches/server-tmp: . common
pamadio at garage.maemo.org
pamadio at garage.maemo.org
Sat Oct 18 18:31:27 EEST 2008
Author: pamadio
Date: 2008-10-18 18:31:24 +0300 (Sat, 18 Oct 2008)
New Revision: 57
Added:
branches/server-tmp/img/
Modified:
branches/server-tmp/common/useful_stuff.php
branches/server-tmp/ets.php
Log:
test
Modified: branches/server-tmp/common/useful_stuff.php
===================================================================
--- branches/server-tmp/common/useful_stuff.php 2008-10-18 15:30:28 UTC (rev 56)
+++ branches/server-tmp/common/useful_stuff.php 2008-10-18 15:31:24 UTC (rev 57)
@@ -8,7 +8,7 @@
////////////////////////////////////////////////
// xml-rpc param offsets
-define("XMLRPC_USERNAME",0);
+define("XMLRPC_TABLET_ID",0);
define("XMLRPC_PW",1);
define("XMLRPC_LAT",2);
@@ -122,14 +122,15 @@
//-----------------------------------------
function db_connect()
{
+
if (stripos($_SERVER['SERVER_NAME'],"etmaemo.gagnews") !== false){
- @mysql_connect("db.gagfoot.com","et_maemo","melmoth");
- if (@mysql_select_db("db_etmaemo"))
+ mysql_connect("localhost","phonehome","tmppass");
+ if (mysql_select_db("db_etmaemo"))
return true;
}
else {
- @mysql_connect("localhost","et_maemo","melmoth");
- if (@mysql_select_db("db_etmaemo"))
+ mysql_connect("localhost","phonehome","tmppass");
+ if (mysql_select_db("etmaemo"))
return true;
}
Modified: branches/server-tmp/ets.php
===================================================================
--- branches/server-tmp/ets.php 2008-10-18 15:30:28 UTC (rev 56)
+++ branches/server-tmp/ets.php 2008-10-18 15:31:24 UTC (rev 57)
@@ -12,9 +12,10 @@
// check if a given user exists based on mac & password
function get_uid($mac,$pw)
{
- $safe_uname = mysql_real_escape_string($uname);
+ $safe_mac = mysql_real_escape_string($mac);
$safe_pw = mysql_real_escape_string($pw);
- $res = mysql_query("select user_id from users where uname='{$safe_uname}' and pw='{$safe_pw}'");
+ //$res = mysql_query("select user_id from users where uname='{$safe_uname}' and pw='{$safe_pw}'");
+ $res=mysql_query("select d.user_id from devices as d, users as u where d.mac='{$safe_mac}' and u.pw='{$safe_pw}' and u.user_id=d.user_id");
$row = mysql_fetch_assoc($res);
if (!$row)
return 0;
@@ -28,7 +29,7 @@
function rpc_store_location($method_name,$params,$app_data)
{
// get user_id or zero
- $uid = get_uid($params[XMLRPC_USERNAME],$params[XMLRPC_PW]);
+ $uid = get_uid($params[XMLRPC_TABLET_ID],$params[XMLRPC_PW]);
if ($uid == 0)
return false;
@@ -36,9 +37,11 @@
$date_recvd = date("Y-m-d H:i:s",$params[4]);
// write to the db
- mysql_query("insert into gps_infos (user_id,lat,lon,gps_time) values ('{$uid}','{$params[XMLRPC_LAT]}','{$params[XMLRPC_LON]}','{$date_recvd}')";
+ $snt="insert into gps_info (device_id,latitude,longtitude,gps_time) values ('{$uid}','{$params[XMLRPC_LAT]}','{$params[XMLRPC_LON]}','{$date_recvd}')";
+ mysql_query($snt) or die('Error, insert query failed');
- $out=mysql_query($query) or die('Error, insert query failed');
+
+
//print "yo ".$query,
return True;
}
@@ -48,11 +51,11 @@
// store image in user specific directory (created dynamically)
function rpc_store_picture($method_name,$params,$app_data)
{
- $uid = get_uid($params[XMLRPC_USERNAME],$params[XMLRPC_PW]);
+ $uid = get_uid($params[XMLRPC_TABLET_ID],$params[XMLRPC_PW]);
if ($uid == 0)
return false;
- if (!file_exists("img/user{$uid}")
+ if (!file_exists("img/user{$uid}"))
mkdir("img/user{$uid}");
$ts = time();
@@ -63,8 +66,16 @@
return true;
}
+///////////////////////////////////////////////////////////////////////
+// test if the xmlrpc login is working or not.
+function rpc_test_login($method_name,$params,$app_data)
+{
+ $uid = get_uid($params[XMLRPC_TABLET_ID],$params[XMLRPC_PW]);
+ if ($uid == 0)
+ return false;
+ return true;
+}
-
///////////////////////////////////////////////////////////////////////
// here we go...
$xmlrpc_server = xmlrpc_server_create();
@@ -72,9 +83,10 @@
// register the methods it accepts
xmlrpc_server_register_method($xmlrpc_server,"store_location","rpc_store_location");
xmlrpc_server_register_method($xmlrpc_server,"store_picture","rpc_store_picture");
+xmlrpc_server_register_method($xmlrpc_server,"test_login","rpc_test_login");
// get the data from the request & process it
-$request_xml = file_get_contents(("php://input");
+$request_xml = file_get_contents("php://input");
echo xmlrpc_server_call_method($xmlrpc_server,$request_xml,'');
// bye bye
Copied: branches/server-tmp/img (from rev 50, branches/server-pamadio/img)
More information about the Phonehome-commits
mailing list