rescape($pm['message']) . '",' . $pm['from_status'] . ',' . $pm['to_status'] . ',"' . $pm['file'] . '")'; $rez = $DB->QUR($sql); //echo $sql.PHP_EOL.print_r($rez,1).PHP_EOL; if ($rez) $out['pm']['send'] = 1; $params1['tg']['otkogo_user_id']=$pm['otkogo_user_id']; $params1['tg']['otkogo_user_fio']='Система ЭИОС'; if(isset($_SESSION['user'])&&isset($_SESSION['user']['fio'])) $params1['tg']['otkogo_user_fio']=$_SESSION['user']['fio']; $params1['tg']['komu_user_id']=$pm['komu_user_id']; $params1['tg']['message']=$pm['message']; $params1['tg']['file']=''; PM_SEND_teleg($params1); } return $out; } /** * Отправка сообщениф в телеграм * @param $params (array) * tg(array) otkogo_user_id | komu_user_id | message | file * @return (array) */ function PM_SEND_teleg($params=array()){ GLOBAL $ST,$DB; $out = array(); $sql = 'SELECT id FROM acs_users_telegram WHERE id_user='.$params['tg']['komu_user_id']; $rez = $DB->QUR_SEL($sql); if($rez){ $params['tg']['des']='message_send'; $params['tg']['message'] = strip_tags($params['tg']['message'],'
');

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,'https://teleg.mkgtu.ru/tg/api.php');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params['tg']));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_HEADER, false);
        $server_output = curl_exec($ch);
        $error    = curl_error($ch);
        $errno    = curl_errno($ch);
        curl_close($ch);
    }
    //$params['tg']['otkogo_user_id']=$_SESSION['user']['id'];
    //$params['tg']['komu_user_id']=$to_user;
    //$params['tg']['message']=$message;
    //$params['tg']['file']=$uploadfile;
    return $out;
}