<?php
defined(
'main'
)
or
die
(
'no direct access'
);
$title
=
$allgAr
[
'title'
].
' :: Freunde'
;
$hmenu
=
'Freunde'
;
$design
=
new
design (
$title
,
$hmenu
);
$design
->header();
if
(loggedin()) {
if
(isset(
$_POST
[
'sub'
])) {
$name
= escape(
$_POST
[
'name'
],
'string'
);
$fid
= @db_result(db_query(
"SELECT id FROM prefix_user WHERE name = BINARY '"
.
$name
.
"'"
),0);
$msg
=
'Fehler beim Eintragen aufgetreten.<br />'
;
if
(
$fid
> 0) {
if
(db_query(
"INSERT INTO `prefix_friends` (uid,fid) VALUES ({$_SESSION['authid']}, $fid)"
)) {
$msg
=
'Erfolgreich eingetragen.<br />'
;
}
}
echo
$msg
;
}
if
(
$menu
->getA(1) ==
'd'
) {
db_query(
"DELETE FROM `prefix_friends` WHERE uid = {$_SESSION['authid']} AND fid = "
.
$menu
->getE(1));
}
$tpl
=
new
tpl(
'freunde'
);
$tpl
->out(0);
$dif
=
date
(
'Y-m-d H:i:s'
, time() - 60);
$sql
= db_query("SELECT `prefix_friends`.fid, `prefix_user`.name, IF(`prefix_online`.uptime >
'$dif'
,
'online'
,
'offline'
)
as
status FROM `prefix_friends` LEFT JOIN `prefix_user` ON `prefix_friends`.fid = `prefix_user`.id
LEFT JOIN `prefix_online` ON `prefix_friends`.fid = `prefix_online`.uid
WHERE `prefix_friends`.uid = {
$_SESSION
[
'authid'
]} ORDER BY status DESC");
while
(
$r
= db_fetch_assoc(
$sql
)) {
$class
= (
$class
==
'Cmite'
?
'Cnorm'
:
'Cmite'
);
$r
[
'class'
] =
$class
;
$tpl
->set_ar_out(
$r
,1);
}
$tpl
->out(2);
}
else
{
echo
'Nur für angemeldete User.<br />'
;
}
$design
->footer();
?>