|
Revision 2, 1.5 kB
(checked in by sven, 3 years ago)
|
importing elgg-0.1.1a
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
if (isset($_REQUEST['action'])) { |
|---|
| 6 |
switch($_REQUEST['action']) { |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
case "friend": if (isset($_REQUEST['friend_id']) && logged_on) { |
|---|
| 10 |
$friend_id = (int) $_REQUEST['friend_id']; |
|---|
| 11 |
$friend = db_query("select * from users where ident = $friend_id"); |
|---|
| 12 |
if (sizeof($friend) > 0) { |
|---|
| 13 |
$friendalready = db_query("select * from friends |
|---|
| 14 |
where owner = " . $_SESSION['userid'] . " |
|---|
| 15 |
and friend = $friend_id"); |
|---|
| 16 |
if (sizeof($friendalready) == 0) { |
|---|
| 17 |
db_query("insert into friends |
|---|
| 18 |
set owner = " . $_SESSION['userid'] . ", |
|---|
| 19 |
friend = $friend_id"); |
|---|
| 20 |
$messages[] = $friend[0]->name . " was added to your friends list."; |
|---|
| 21 |
} |
|---|
| 22 |
} |
|---|
| 23 |
} |
|---|
| 24 |
break; |
|---|
| 25 |
|
|---|
| 26 |
case "unfriend": if (isset($_REQUEST['friend_id']) && logged_on) { |
|---|
| 27 |
$friend_id = (int) $_REQUEST['friend_id']; |
|---|
| 28 |
$friend = db_query("select * from users where ident = $friend_id"); |
|---|
| 29 |
if (sizeof($friend) > 0) { |
|---|
| 30 |
db_query("delete from friends |
|---|
| 31 |
where owner = " . $_SESSION['userid'] . " |
|---|
| 32 |
and friend = $friend_id"); |
|---|
| 33 |
$messages[] = $friend[0]->name . " was removed from your friends."; |
|---|
| 34 |
} |
|---|
| 35 |
} |
|---|
| 36 |
break; |
|---|
| 37 |
|
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
?> |
|---|