Thread: [Astrospaces-commits] SF.net SVN: astrospaces: [90] trunk/functions/user.php
Brought to you by:
p3net
From: <del...@us...> - 2007-08-03 23:08:43
|
Revision: 90 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=90&view=rev Author: deltalabs Date: 2007-08-03 16:08:43 -0700 (Fri, 03 Aug 2007) Log Message: ----------- Finished edit_comment and delete_comment functions Modified Paths: -------------- trunk/functions/user.php Modified: trunk/functions/user.php =================================================================== --- trunk/functions/user.php 2007-08-01 23:42:24 UTC (rev 89) +++ trunk/functions/user.php 2007-08-03 23:08:43 UTC (rev 90) @@ -349,13 +349,60 @@ time() . ',' . $user->data['user_id'] . ',' . $id . ',' . $db->qstr($_POST['body']).')'; if ($db->Execute($_query) === false) { - $error->general('<b>DB Error!</b>', 'session.php - add_comment(): '.$db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - add_comment(): '.$db->ErrorMsg()); return false; } $session->action('2', $id); } } /* + Function Name: delete_comment + Arguments: (int) id -- comment_ID of comment to be deleted + Purpose: Delete comment + */ + function delete_comment($id) + { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid userID', "Invalid userD = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + if($session->is_friend($id)) + { + /* Okay, we have permission to remove this comment */ + $_query = 'DELETE FROM ' . AS_TBL_CMT . ' WHERE comment_id = ' . $id; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'user.php - delete_comment(): '.$db->ErrorMsg()); + return false; + } + } + } + /* + Function Name: edit_comment + Arguments: (int) id -- comment_ID of comment to be edited + Purpose: Edit comment + */ + function edit_comment($id) + { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid userID', "Invalid userD = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + if($session->is_friend($id)) + { + /* Okay, we have permission to edit this comment */ + $_query = 'UPDATE ' . AS_TBL_CMT . ' SET comment = ' . $db->qstr($_POST['body']) . ' WHERE comment_id = ' + . $id; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'user.php - edit_comment(): '.$db->ErrorMsg()); + return false; + } + } + } + /* Function Name: get_username Arguments: (int) id -- User ID Purpose: Fetch username of user based on their unique ID This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <del...@us...> - 2007-08-05 04:25:03
|
Revision: 93 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=93&view=rev Author: deltalabs Date: 2007-08-04 21:25:02 -0700 (Sat, 04 Aug 2007) Log Message: ----------- added remove_friend function Modified Paths: -------------- trunk/functions/user.php Modified: trunk/functions/user.php =================================================================== --- trunk/functions/user.php 2007-08-05 03:43:57 UTC (rev 92) +++ trunk/functions/user.php 2007-08-05 04:25:02 UTC (rev 93) @@ -180,16 +180,16 @@ } else { - $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE user2_id = ' . $user->data['user_id'] . ' AND user2_id = ' . $id . ' AND accepted = 1'; - $_query = $db->Execute($_query); - if($_query->fields[0] > 0) - { - return true; - } - else - { - return false; - } + $_query = 'SELECT count(*) FROM '.AS_TBL_FRIEND.' WHERE user2_id = ' . $user->data['user_id'] . ' AND user2_id = ' . $id . ' AND accepted = 1'; + $_query = $db->Execute($_query); + if($_query->fields[0] > 0) + { + return true; + } + else + { + return false; + } } } } @@ -330,6 +330,36 @@ } } } + /* + Function Name: remove_friend + Arguments: (int) user_id -- user_id of the friend to remove + Purpose: Remove a user from your friends list + */ + function remove_friend($user_id) + { + if (!is_numeric($id) and $id != null) + { + $error->general('Invalid friendID', "Invalid friendID = Possible hack! Input value: \"".$id."\" User Hostname: ".$_SERVER['REMOTE_ADDR']); + return false; + } + + if($user->is_friend($id)) + { + $error->general("Already friend", "Add as friend"); + } + + $_query = 'DELETE FROM ' . AS_TBL_FRIEND . ' WHERE user1_id = ' . $user_id . ' AND user2_id = ' . $user->data['user_id']; + if ($db->Execute($_query) === false) + { + $_query = 'DELETE FROM ' . AS_TBL_FRIEND . ' WHERE user2_id = ' . $user_id . ' AND user1_id = ' . $user->data['user_id']; + if ($db->Execute($_query) === false) + { + $error->general('<b>DB Error!</b>', 'user.php - remove_friend(): '.$db->ErrorMsg()); + return false; + } + } + return true; + } /* Function Name: add_coment Arguments: (int) id -- ID of user who comment is directed to @@ -484,7 +514,7 @@ . $user->data['user_id'] . ', ' . $grp_id . ', ' . ', ' . time(). ')'; if ($db->Execute($_query) === false) { - $error->general('Problem joining group', 'Unknown problem joining group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - join_group(): '.$db->ErrorMsg()); return false; } } @@ -505,7 +535,7 @@ . $user->data['user_id'] . ' AND group_id = ' . $grp_id; if ($db->Execute($_query) === false) { - $error->general('Problem leaving group', 'Unknown problem leaving group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - leave_group(): '.$db->ErrorMsg()); return false; } } @@ -537,7 +567,7 @@ $_query = 'DELETE FROM ' . AS_TBL_GRPRES . ' WHERE group_id = ' . $grp_id . ' AND user_id = ' . $user_id; if ($db->Execute($_query) === false) { - $error->general('Failed to kick user', 'Unknown problem removing user from group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - kick_from_group(): '.$db->ErrorMsg()); return false; } return true; @@ -560,7 +590,7 @@ . '(' . $db->qstr($name) . ', ' . $db->qstr($desc) . ', ' . $user->data['user_id'] . ', ' . time() . ')'; if ($db->Execute($_query) === false) { - $error->general('Problem creating group', 'Unknown problem creating group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - create_group(): '.$db->ErrorMsg()); return false; } return true; @@ -589,7 +619,7 @@ . ' WHERE group_id = ' . $grp_id; if ($db->Execute($_query) === false) { - $error->general('Problem editing group', 'Unknown problem editing group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - edit_group(): '.$db->ErrorMsg()); return false; } return true; @@ -622,7 +652,7 @@ $_query = 'DELETE FROM ' . AS_TBL_GRPS . ' WHERE group_id = ' . $grp_id; if ($db->Execute($_query) === false) { - $error->general('Problem deleting group', 'Unknown problem deleting group: ' . $db->ErrorMsg()); + $error->general('<b>DB Error!</b>', 'user.php - delete_group(): '.$db->ErrorMsg()); return false; } return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <del...@us...> - 2007-08-06 05:12:07
|
Revision: 94 http://astrospaces.svn.sourceforge.net/astrospaces/?rev=94&view=rev Author: deltalabs Date: 2007-08-05 22:12:05 -0700 (Sun, 05 Aug 2007) Log Message: ----------- Finished friends Modified Paths: -------------- trunk/functions/user.php Modified: trunk/functions/user.php =================================================================== --- trunk/functions/user.php 2007-08-05 04:25:02 UTC (rev 93) +++ trunk/functions/user.php 2007-08-06 05:12:05 UTC (rev 94) @@ -353,13 +353,33 @@ { $_query = 'DELETE FROM ' . AS_TBL_FRIEND . ' WHERE user2_id = ' . $user_id . ' AND user1_id = ' . $user->data['user_id']; if ($db->Execute($_query) === false) - { + { $error->general('<b>DB Error!</b>', 'user.php - remove_friend(): '.$db->ErrorMsg()); return false; } } return true; } + /* + Function Name: list_friends + Purpose: get a list of friends of the user + */ + function list_friends() + { + $_query = 'SELECT user1_id FROM ' . AS_TBL_FRIENDS . ' WHERE user2_id = ' . $user->data['user_id'] . ' AND accepted = 1'; + if (($listpart1 = $db->fetch_array($_query)) === false) + { + $error->general('<b>DB Error!</b>', 'user.php - list_friends(): '.$db->ErrorMsg()); + return false; + } + $_query = 'SELECT user2_id FROM ' . AS_TBL_FRIENDS . ' WHERE user1_id = ' . $user->data['user_id'] . ' AND accepted = 1'; + if (($listpart2 = $db->fetch_array($_query)) === false) + { + $error->general('<b>DB Error!</b>', 'user.php - list_friends(): '.$db->ErrorMsg()); + return false; + } + return array_merge($listpart1, $listpart2); + } /* Function Name: add_coment Arguments: (int) id -- ID of user who comment is directed to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |