public static function sendLog($message) { return; if ($_SERVER["SERVER_NAME"] != "localhost") { } Yii::import('ext.ElephantIO.Client'); if (!is_string($message)) { $message = NodeLogger::renderJSON($message); } //$elephant = new Client('http://pukul.in:10001', 'socket.io', 1, false, true, true); $elephant = new Client('http://localhost:8000', 'socket.io', 1, false, true, true); $elephant->init(); $elephant->emit('newmessage', date("Y-m-d H:i:s") . "\n" . $message); $elephant->close(); //echo "SEND MESSAGE ".$message; }
public static function sendLog($message) { $fields_string = ""; if (!is_string($message)) { $message = NodeLogger::renderJSON($message); } $fields = array('message' => $message); foreach ($fields as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://localhost:1337/ws"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); $output = curl_exec($ch); curl_close($ch); }