function sendReplyMsg() { $json['bool'] = 0; $json['err'] = "ok"; //$accid = addslashes($_POST['acc_id']); $inboxid = addslashes($_POST['inboxid']); $isi = addslashes($_POST['isi']); // $emai = addslashes($_POST['emai']); /* if ($accid == "") { $json['err'] = Lang::t('lang_id_empty'); }*/ if ($inboxid == "") { $json['err'] = Lang::t('lang_inbox_id_empty'); } if ($isi == "") { $json['err'] = Lang::t('lang_isi_empty'); } if ($json['err'] == "ok") { $in = new ChatMsg(); //$tgl = date("Y-m-d H:i:s"); $in->chat_group_id = $inboxid; //$in->inbox_to = $accid; $in->inbox_from = Account::getMyID(); $in->inbox_msg = $isi; $in->inbox_createdate = leap_mysqldate(); if ($in->save()) { //update inbox $inbox = new ChatGroup(); $inbox->getByID($inboxid); $inbox->inbox_changedate = leap_mysqldate(); $inbox->inbox_anzahlreply++; $inbox->load = 1; //ini hrs di foreach untuk semua member $m = new ChatMember(); $arrMember = $m->getWhere("chat_group_id = '{$inboxid}'"); foreach ($arrMember as $mem) { $accid = $mem->chat_member_id; if ($accid == Account::getMyID()) { continue; } $inbox->addInboxNotifPortal($accid, $inboxid); //cek read didalamnya } if ($inbox->inbox_read) { //update Notif $inbox->inbox_read = 0; } //$inbox->inbox_giliran_read = $accid; $inbox->save(); $json['bool'] = 1; } else { $json['err'] = Lang::t('lang_failed'); } } echo json_encode($json); exit; }
public function insGroup() { $update = isset($_GET['update']) ? addslashes($_GET['update']) : 0; $gid = isset($_GET['gid']) ? addslashes($_GET['gid']) : 0; $gname = isset($_POST['gname']) ? addslashes($_POST['gname']) : die("no gname"); $arrMember = isset($_POST['arrMember']) ? addslashes($_POST['arrMember']) : die("no arrMember"); $exp = explode(",", $arrMember); if (count($exp) < 2) { //minimum of chat group = 2 $json['bool'] = 0; $json['err'] = Lang::t('Chat min 2 person'); echo json_encode($json); die; } //first insert group $g = new ChatGroup(); if ($update) { if ($gid > 0) { $g->getByID($gid); if ($g->inbox_from != Account::getMyID()) { die("hacking attempt"); } else { $g->load = 1; $cg = new ChatMember(); $cg->deleteMemberByGID($gid); } } else { die("hacking attempt 2"); } } $g->inbox_judul = $gname; $g->inbox_from = Account::getMyID(); if (!$update) { $g->inbox_createdate = leap_mysqldate(); } $g->inbox_changedate = leap_mysqldate(); $id = $g->save(); if ($id) { if ($update) { $id = $gid; } foreach ($exp as $mm) { if ($mm == "") { continue; } $m = new ChatMember(); $m->chat_member_id = $mm; $m->chat_group_id = $id; $m->save(); } } $json = array(); $json['bool'] = $id; echo json_encode($json); }