[Phonehome-commits] r39 - in trunk/server: . common css

lauren at garage.maemo.org lauren at garage.maemo.org
Sat Oct 18 07:31:27 EEST 2008


Author: lauren
Date: 2008-10-18 07:31:26 +0300 (Sat, 18 Oct 2008)
New Revision: 39

Added:
   trunk/server/device_add.php
Modified:
   trunk/server/common/header.php
   trunk/server/css/main.css
   trunk/server/profile.php
   trunk/server/register.php
Log:
adding profile and device management

Modified: trunk/server/common/header.php
===================================================================
--- trunk/server/common/header.php	2008-10-18 00:53:39 UTC (rev 38)
+++ trunk/server/common/header.php	2008-10-18 04:31:26 UTC (rev 39)
@@ -12,8 +12,7 @@
 // logged in user
 else{
 	echo "<a href='/'>HOME</a> | <a href='profile.php'>PROFILE</a> | 
-		<a href='gpsdata.php'>GPS DATA</a> | <a href='images.php'>IMAGES</a> |
-		<a href='logout.php'>LOG OUT</a>
+		<a href='gpsdata.php'>GPS DATA</a> | <a href='images.php'>IMAGES</a> | <a href='logout.php'>LOG OUT</a>
 		<span style='margin-left:100px;color:#fff;'>-[ ".get_uname()." logged in ]-</span>";
 }
 

Modified: trunk/server/css/main.css
===================================================================
--- trunk/server/css/main.css	2008-10-18 00:53:39 UTC (rev 38)
+++ trunk/server/css/main.css	2008-10-18 04:31:26 UTC (rev 39)
@@ -1,5 +1,7 @@
 
 body {margin:0;background:#E6EFB0;}
+input,select {margin:0 1px 4px 0px;}
 
+
 .topdiv {padding:5px;margin-bottom:10px;border-bottom:1px solid #888;background:#B5C98F;}
 .botdiv {padding:5px;margin-top:10px;border-top:1px solid #888;}

Added: trunk/server/device_add.php
===================================================================
--- trunk/server/device_add.php	                        (rev 0)
+++ trunk/server/device_add.php	2008-10-18 04:31:26 UTC (rev 39)
@@ -0,0 +1,78 @@
+<?php
+include 'common/useful_stuff.php';
+if (!db_connect())
+	die();
+
+if ($_uid == 0){
+	header("location:login.php");
+	die();
+}
+
+$errmsg = "";
+$dname = getvar("dname");
+$dstatus = getvar("dstatus");
+$dmac = getvar("dmac");
+$ddesc = getvar("ddesc");
+$doit = getvar("doit");
+if ($doit == "yes"){
+	if ($dname == ""){
+		$errmsg = "Please supply a device name!";
+	}
+	else if ($dmac == ""){
+		$errmsg = "Please enter a mac address!";
+	}
+	else {
+		mysql_query("insert into devices (user_id,status,mac,name,description)
+						values ({$_uid},'{$dstatus}','{$dmac}','{$dname}','{$ddesc}')");
+		header("location:profile.php");
+		die();
+	}
+}
+
+?>
+<html>
+<head>
+<title>ET-MAEMO | Add Device</title>
+<link rel="stylesheet" type="text/css" href="css/main.css">
+</head>
+<body>
+<?php
+include 'common/header.php';
+
+echo "<table width='100%' cellpadding='1' cellspacing='1' border='0'>
+<tr>
+	<td style='vertical-align:top;width:40%;'>
+		<b>Add Device</b>
+		<div style='color:red;'><b>{$errmsg}&nbsp;</b></div>
+		<form method='post' action='{$_SERVER['PHP_SELF']}'>
+		<input type='hidden' name='doit' value='yes'>
+		device name<br><input type='text' name='dname' size='30' value='".stripslashes(htmlentities($dname,ENT_QUOTES))."'>
+		<br>device mac address<br><input type='text' name='dmac' size='30' value='".stripslashes(htmlentities($dmac,ENT_QUOTES))."'>
+		<br>device status<br><select name='dstatus'>";
+		if ($dstatus == "A"){
+			echo "<option value='A' selected>ACTIVE</option><option value='N'>NOT ACTIVE</option>";
+		}
+		else {
+			echo "<option value='A'>ACTIVE</option><option value='N' selected>NOT ACTIVE</option>";
+		}
+		echo "</select>
+		<br>device description<br><textarea name='ddesc' cols='30' rows='3'>".stripslashes(htmlentities($ddesc,ENT_QUOTES))."</textarea>
+		<br><input type='submit' value='Add This Device'>
+		</form>
+	</td>
+	<td style='vertical-align:top;padding-left:30px;'>
+		<b>Notes</b>
+		<p>The name you give should be unique so you can easily identify your devices. The description
+		is completely optional.
+		<p>The status will determine whether or not data will be collected for
+		this device.
+		<p>The MAC Address *must* be unique (mac addresses are supposed to be) and should contain the
+		\":\" characters, ie, 00:34:DE:43:21:AF
+	</td>
+</tr>
+</table>";
+
+include 'common/footer.php';
+?>
+</body>
+</html>

Modified: trunk/server/profile.php
===================================================================
--- trunk/server/profile.php	2008-10-18 00:53:39 UTC (rev 38)
+++ trunk/server/profile.php	2008-10-18 04:31:26 UTC (rev 39)
@@ -8,6 +8,32 @@
 	die();
 }
 
+$errmsg = "";
+$uname = getvar("uname");
+$email = getvar("email");
+$pw = getvar("pw");
+$pwc = getvar("pwc");
+$doit = getvar("doit");
+
+// updating main profile data?
+if ($doit == "prof"){
+
+}
+// else are we doing password?
+else if ($doit == "pw"){
+
+}
+// else first time thru so get existing data
+else {
+	$res = mysql_query("select uname,email from users where user_id={$_uid}");
+	$row = mysql_fetch_assoc($res);
+	if (!$row){
+		header("location:login.php");
+		die();
+	}
+	$uname = $row['uname'];
+	$email = $row['email'];
+}
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
@@ -19,8 +45,46 @@
 <?php
 include 'common/header.php';
 
-echo "<h1>My Profile here</h1>";
+echo "<table width='100%' cellpadding='1' cellspacing='1' border='0'>
+<tr>
+	<td style='vertical-align:top;width:40%;border-right:1px solid #999;'>
+		<b>Change Profile</b>
+		<div style='color:red;'><b>{$errmsg}&nbsp;</b></div>
+		<form method='post' action='{$_SERVER['PHP_SELF']}'>
+		<input type='hidden' name='doit' value='prof'>
+		username<br><input type='text' name='uname' size='30' value='".stripslashes(htmlentities($uname,ENT_QUOTES))."'>
+		<br>email<br><input type='text' name='email' size='30' value='".stripslashes(htmlentities($email,ENT_QUOTES))."'>
+		<br><input type='submit' value='Save Changes'>
+		</form>
 
+		<div style='border-top:1px solid #999;padding-top:10px;margin-top:10px;'>
+			<b>Change Password</b>
+			<div style='color:red;'><b>{$errmsg}&nbsp;</b></div>
+			<form method='post' action='{$_SERVER['PHP_SELF']}'>
+			<input type='hidden' name='doit' value='pw'>
+			password<br><input type='password' name='pw' size='20'>
+			<br>confirm<br><input type='password' name='pwc' size='20'>
+			<br><input type='submit' value='Change Password'>
+			</form>
+		</div>
+
+	</td>
+	<td style='vertical-align:top;padding-left:20px;'>
+		<b>Your Devices</b>
+		<p><a href='device_add.php'>Add a new device &raquo;&raquo;</a><p>";
+		$res = mysql_query("select device_id,status,name,mac from devices where user_id={$_uid} order by name");
+		while ($row = mysql_fetch_assoc($res)){
+			echo "<div style='padding:2px;margin:1px solid #999;'>
+				<a href='device_edit.php?did={$row['device_id']}'>[ edit ]</a>
+				<span style='margin-left:10px;'>{$row['status']}</span>
+				<span style='margin-left:10px;'>{$row['mac']}</span>
+				<span style='margin-left:10px;'>{$row['name']}</span>
+			</div>";
+		}
+	echo "</td>
+</tr>
+</table>";
+
 include 'common/footer.php';
 ?>
 </body>

Modified: trunk/server/register.php
===================================================================
--- trunk/server/register.php	2008-10-18 00:53:39 UTC (rev 38)
+++ trunk/server/register.php	2008-10-18 04:31:26 UTC (rev 39)
@@ -67,7 +67,7 @@
 		<input type='hidden' name='doit' value='yes'>
 		username<br><input type='text' name='uname' size='30' value='".stripslashes(htmlentities($uname,ENT_QUOTES))."'>
 		<br>password<br><input type='password' name='pw' size='20'>
-		<br>confirm password<br><input type='password' name='pwc' size='20'>
+		<br>confirm<br><input type='password' name='pwc' size='20'>
 		<br>email<br><input type='text' name='email' size='30' value='".stripslashes(htmlentities($email,ENT_QUOTES))."'>
 		<br><input type='submit' value='REGISTER'>
 		</form>



More information about the Phonehome-commits mailing list