aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Chatsvc.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-26 18:12:56 +0000
committerMario <mario@mariovavti.com>2022-10-26 18:12:56 +0000
commit40ae6b396f3760c4c4b6e4de776869a88ce07fce (patch)
treee54516ed5ca3d86faf24e1833c1b88294366f7a9 /Zotlabs/Module/Chatsvc.php
parent9c117ffa0546d6131310ae175e16e5ebf63992a1 (diff)
downloadvolse-hubzilla-40ae6b396f3760c4c4b6e4de776869a88ce07fce.tar.gz
volse-hubzilla-40ae6b396f3760c4c4b6e4de776869a88ce07fce.tar.bz2
volse-hubzilla-40ae6b396f3760c4c4b6e4de776869a88ce07fce.zip
fix php warnings
Diffstat (limited to 'Zotlabs/Module/Chatsvc.php')
-rw-r--r--Zotlabs/Module/Chatsvc.php90
1 files changed, 45 insertions, 45 deletions
diff --git a/Zotlabs/Module/Chatsvc.php b/Zotlabs/Module/Chatsvc.php
index d6708d95c..2f2784fc4 100644
--- a/Zotlabs/Module/Chatsvc.php
+++ b/Zotlabs/Module/Chatsvc.php
@@ -1,6 +1,6 @@
<?php /** @file */
-namespace Zotlabs\Module;
+namespace Zotlabs\Module;
require_once('include/security.php');
@@ -9,76 +9,76 @@ use \Zotlabs\Lib as Zlib;
class Chatsvc extends \Zotlabs\Web\Controller {
function init() {
-
+
//logger('chatsvc');
-
+
$ret = array('success' => false);
-
+
\App::$data['chat']['room_id'] = intval($_REQUEST['room_id']);
$x = q("select cr_uid from chatroom where cr_id = %d and cr_id != 0 limit 1",
intval(\App::$data['chat']['room_id'])
);
if(! $x)
json_return_and_die($ret);
-
+
\App::$data['chat']['uid'] = $x[0]['cr_uid'];
-
+
if(! perm_is_allowed(\App::$data['chat']['uid'],get_observer_hash(),'chat')) {
json_return_and_die($ret);
}
-
+
}
-
+
function post() {
-
+
$ret = array('success' => false);
-
+
$room_id = \App::$data['chat']['room_id'];
$text = escape_tags($_REQUEST['chat_text']);
if(! $text)
return;
-
+
$sql_extra = permissions_sql(\App::$data['chat']['uid']);
-
+
$r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
intval(\App::$data['chat']['uid']),
intval(\App::$data['chat']['room_id'])
);
if(! $r)
json_return_and_die($ret);
-
+
$arr = array(
'chat_room' => \App::$data['chat']['room_id'],
'chat_xchan' => get_observer_hash(),
'chat_text' => $text
);
-
+
call_hooks('chat_post',$arr);
-
+
$x = q("insert into chat ( chat_room, chat_xchan, created, chat_text )
values( %d, '%s', '%s', '%s' )",
intval(\App::$data['chat']['room_id']),
dbesc(get_observer_hash()),
dbesc(datetime_convert()),
- dbesc(str_rot47(base64url_encode($arr['chat_text'])))
+ dbesc(str_rot47(base64url_encode($arr['chat_text'])))
);
-
+
$ret['success'] = true;
json_return_and_die($ret);
}
-
+
function get() {
-
- $status = strip_tags($_REQUEST['status']);
+
+ $status = ((isset($_REQUEST['status'])) ? strip_tags($_REQUEST['status']) : '');
$room_id = intval(\App::$data['chat']['room_id']);
$stopped = ((x($_REQUEST,'stopped') && intval($_REQUEST['stopped'])) ? true : false);
-
+
if($status && $room_id) {
-
+
$x = q("select channel_address from channel where channel_id = %d limit 1",
intval(\App::$data['chat']['uid'])
- );
-
+ );
+
$r = q("update chatpresence set cp_status = '%s', cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'",
dbesc($status),
dbesc(datetime_convert()),
@@ -86,27 +86,27 @@ class Chatsvc extends \Zotlabs\Web\Controller {
dbesc(get_observer_hash()),
dbesc($_SERVER['REMOTE_ADDR'])
);
-
- goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id);
+
+ goaway(z_root() . '/chat/' . $x[0]['channel_address'] . '/' . $room_id);
}
-
+
if(! $stopped) {
-
+
$lastseen = intval($_REQUEST['last']);
-
+
$ret = array('success' => false);
-
+
$sql_extra = permissions_sql(\App::$data['chat']['uid']);
-
+
$r = q("select * from chatroom where cr_uid = %d and cr_id = %d $sql_extra",
intval(\App::$data['chat']['uid']),
intval(\App::$data['chat']['room_id'])
);
if(! $r)
json_return_and_die($ret);
-
+
$inroom = array();
-
+
$r = q("select * from chatpresence left join xchan on xchan_hash = cp_xchan where cp_room = %d order by xchan_name",
intval(\App::$data['chat']['room_id'])
);
@@ -120,9 +120,9 @@ class Chatsvc extends \Zotlabs\Web\Controller {
$rv['xchan_url'] = z_root();
$rv['xchan_hidden'] = 1;
$rv['xchan_photo_mimetype'] = 'image/png';
- $rv['xchan_photo_l'] = z_root() . '/' . get_default_profile_photo(300);
- $rv['xchan_photo_m'] = z_root() . '/' . get_default_profile_photo(80);
- $rv['xchan_photo_s'] = z_root() . '/' . get_default_profile_photo(48);
+ $rv['xchan_photo_l'] = z_root() . '/' . get_default_profile_photo(300);
+ $rv['xchan_photo_m'] = z_root() . '/' . get_default_profile_photo(80);
+ $rv['xchan_photo_s'] = z_root() . '/' . get_default_profile_photo(48);
}
@@ -137,13 +137,13 @@ class Chatsvc extends \Zotlabs\Web\Controller {
$status_class = 'online';
break;
}
-
+
$inroom[] = array('img' => zid($rv['xchan_photo_m']), 'img_type' => $rv['xchan_photo_mimetype'],'name' => $rv['xchan_name'], 'status' => $status, 'status_class' => $status_class);
}
}
-
+
$chats = array();
-
+
$r = q("select * from chat left join xchan on chat_xchan = xchan_hash where chat_room = %d and chat_id > %d order by created",
intval(\App::$data['chat']['room_id']),
intval($lastseen)
@@ -152,7 +152,7 @@ class Chatsvc extends \Zotlabs\Web\Controller {
foreach($r as $rr) {
$chats[] = array(
'id' => $rr['chat_id'],
- 'img' => zid($rr['xchan_photo_m']),
+ 'img' => zid($rr['xchan_photo_m']),
'img_type' => $rr['xchan_photo_mimetype'],
'name' => $rr['xchan_name'],
'isotime' => datetime_convert('UTC', date_default_timezone_get(), $rr['created'], 'c'),
@@ -163,22 +163,22 @@ class Chatsvc extends \Zotlabs\Web\Controller {
}
}
}
-
+
$r = q("update chatpresence set cp_last = '%s' where cp_room = %d and cp_xchan = '%s' and cp_client = '%s'",
dbesc(datetime_convert()),
intval(\App::$data['chat']['room_id']),
dbesc(get_observer_hash()),
dbesc($_SERVER['REMOTE_ADDR'])
);
-
+
$ret['success'] = true;
if(! $stopped) {
$ret['inroom'] = $inroom;
$ret['chats'] = $chats;
}
json_return_and_die($ret);
-
+
}
-
-
+
+
}