Beispiel #1
0
function motivateUser($user, $activity)
{
    //TODO: add more messages!
    $message = getMessage($user, $activity);
    //Send Push
    sendPush($message, $user->pushToken);
    //Log
    logMotivation($user, $activity, $message);
}
			<!-- announcement to play -->
			<assign name="cl_callState" expr="cl_dropout_start" />
		<else/>
			<!-- just drop out. Note: perhaps a default announcement? -->
			<assign name="cl_callState" expr="cl_dropout_finish" />
		</if>
		<!-- notify locally and globally that we are out of call -->
		<send data="leftConference" target="session.id" namelist="thisCall newNext newPrior" />
		<send data="dropout" target="session.id" namelist="thisCall" delay="postSessionDelay" />

	</transition>
	
	<!-- we are dropping out -->
	<transition  event="dropout" name="evt" >
		<?php 
sendPush("dropped out");
?>
		<log expr="'Conferre ID ' + destPhone + '/' + thisCall + ' dropout-&gt;exit'" />
		<exit/>

	</transition>	

	<!-- ========================= -->
	<!-- General purpose error handlers -->
	<!-- perhaps less graceful exits -->
	<!-- ========================= -->
	
	<transition event="confDelete" name="evt">
		<if cond="callsLeft == false">
			<destroyconference conferenceid="confID"/>
		</if>
<?php

$to = "co2AjnEL7AY:APA91bGFj0OufwDYCo3J8AI-GJPZhS3JYWYlYu0_0833xlSFNZ-Q7Tnbs_OXEeTC-nViZUZ7ge0LChFjoBnOxICen1D73D0Aman23SUqxV-6YvS78n8eMfZ5FOqoI7OR0iSB0Ei-0h9j";
$title = "Push Notification Title";
$message = "Push Notification Message";
sendPush($to, $title, $message);
function sendPush($to, $title, $message)
{
    define('API_ACCESS_KEY', 'AIzaSyArIVaDQEPRQe8Tl5t69uuw9x0JQw6OWiU');
    $registrationIds = array($to);
    $msg = array('title' => $title, 'message' => $message, 'vibrate' => 0, 'sound' => 0, 'content-available' => 1);
    $fields = array('registration_ids' => $registrationIds, 'data' => $msg);
    $headers = array('Authorization: key=' . API_ACCESS_KEY, 'Content-Type: application/json');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
    $result = curl_exec($ch);
    curl_close($ch);
    echo $result;
}
             // Use mail-function in /lib/php_functions/global.functions.inc.php
             if (!empty($row4['notification_mail_primary'])) {
                 sendMail($row4['notification_mail_primary'], $mailSubject, $mailMessage);
             }
             if (!empty($row4['notification_mail_secondary'])) {
                 sendMail($row4['notification_mail_secondary'], $mailSubject, $mailMessage);
             }
         }
         // Send push
         if ($row4['send_push'] == 1 && !empty($telldusConf['push_user']) && !empty($telldusConf['push_app'])) {
             $pushMessage = "{$row4['push_message']}";
             //$mess = "({$row4['name']}){$row4['device_id']}";
             //$pushMessage = str_replace("%%device%%", $mess, $pushMessage);
             $pushTitle = "{$config['pagetitle']}: {$notifyType} {$lang['Schedule']}.";
             // Use PushOver curl
             sendPush("{$telldusConf['push_app']}", "{$telldusConf['push_user']}", "{$pushTitle}", "{$pushMessage}");
         }
         if ($row4['action_device'] > 0) {
             //action defined
             $params = array('id' => $row4['action_device']);
             if ($row4['action_device_set_state'] == 0) {
                 $reply = $consumer->sendRequest(constant('REQUEST_URI') . '/device/turnOff', $params, 'GET');
             } else {
                 $response = $consumer->sendRequest(constant('REQUEST_URI') . '/device/turnOn', $params, 'GET');
             }
         }
     } else {
         echo "<br>No action this time!";
     }
     //if (take_action)
 }
function prepareAndPush($con, $alluseridforpush, $userid, $msgpayload)
{
    //print_r($alluseridforpush);
    $arrayOfDeviceId = array();
    $stralluseridforpush = implode(",", $alluseridforpush);
    //แปลง userid ให้เป็น string เพื่อไปคิวรี่
    //echo $stralluseridforpush;
    $queryallDeviceId = $con->query("SELECT distinct `device_id` FROM `user_deviceid` where `user_id` in ({$stralluseridforpush})");
    if ($queryallDeviceId->num_rows > 0) {
        //เชคว่า userid มีออกมาในระบบรึป่าว
        while ($row = $queryallDeviceId->fetch_assoc()) {
            //echo $row['device_id'];
            array_push($arrayOfDeviceId, $row['device_id']);
        }
        //หาชื่อของผู้ส่งจาก userid ของคนที่ส่ง
        $querysendername = $con->query("SELECT * FROM `user` WHERE `user`.`user_id` = '{$userid}';");
        if ($querysendername->num_rows > 0) {
            $row = $querysendername->fetch_assoc();
            $sendername = $row['firstname'] . ' ' . $row['lastname'] . '(' . $row['nickname'] . ')';
        } else {
            $sendername = 'undefind';
        }
        //เตรียมข้อมูลไว้ส่ง push
        $title = $msgpayload;
        $msg = $sendername;
        //ส่ง push ด้วยข้อมูลตามที่กำหนดไว้ข้างต้น เก็บค่าการส่งไว้ใน $msgstatus
        $msgstatus = sendPush($arrayOfDeviceId, $title, $msg);
    } else {
        $msgstatus = "no device to send push";
    }
    return $msgstatus;
}
$mode = $_GET['mode'];
switch ($mode) {
    case 1:
        //registrazione
        $usr = $_GET['usr'];
        $idkey = $_GET['idkey'];
        $tel = $_GET['tel'];
        $imei = $_GET['imei'];
        controllaRegistra($usr, $idkey, $tel, $imei);
        break;
    case 2:
        //Invio Sms
        $sender = $_GET['snd'];
        $reciver = $_GET['rcv'];
        $msg = $_GET['msg'];
        sendPush($sender, $reciver, $msg);
        break;
    case 3:
        //ControlloRegistrazione
        $number = $_GET['tel'];
        isRegistered($number);
        break;
    case 4:
        //Notifica Messaggio Ricevuto
        $sender = $_GET['snd'];
        $reciver = $_GET['rcv'];
        $idkey = $_GET['idkey'];
        notificaRicevuta($sender, $reciver, $idkey);
        break;
    case 5:
        //Setta status
Beispiel #7
0
function __process_post($post)
{
    // finding similar matches
    $areaRange = $post->area / 5;
    $priceRange = $post->price / 5;
    $ptype = $post->post_type == 1 ? 2 : 1;
    $similars = Post::where('property_type', $post->property_type)->whereRaw('abs(' . $post->area . ' - area) <= ' . $areaRange)->whereRaw('abs(' . $post->price . ' - price) <= ' . $priceRange)->where('num_rooms', '>=', $post->num_rooms)->where('post_type', $post->post_type)->where('id', '<>', $post->id)->where('user_id', '<>', $post->user_id)->get();
    foreach ($similars as $s) {
        $dist = distance($post->lat, $post->lng, $s->lat, $s->lng, 'K');
        $sp = new SimilarPost();
        $sp->post_from = $post->id;
        $sp->post_to = $s->id;
        $sp->dist = $dist;
        $sp->state = 0;
        $sp->save();
        if ($post->num_rooms == $s->num_rooms) {
            SimilarPost::where('post_to', $post->id)->where('post_from', $s->id)->delete();
            $ssp = new SimilarPost();
            $ssp->post_to = $post->id;
            $ssp->post_from = $s->id;
            $ssp->dist = $dist;
            $ssp->state = 0;
            $ssp->save();
        }
    }
    // finding matchings
    $matchings = Post::where('property_type', $post->property_type)->whereRaw('abs(' . $post->area . ' - area) <= ' . $areaRange)->whereRaw('abs(' . $post->price . ' - price) <= ' . $priceRange)->where('num_rooms', '>=', $post->num_rooms)->where('post_type', $ptype)->where('id', '<>', $post->id)->where('user_id', '<>', $post->user_id)->get();
    $devices = array();
    foreach ($matchings as $m) {
        $dist = distance($post->lat, $post->lng, $m->lat, $m->lng, 'K');
        $match = MatchingPost::where('post_from', $post->id)->where('post_to', $m->id)->first();
        if ($match == NULL) {
            $match = new MatchingPost();
            $match->post_from = $post->id;
            $match->post_to = $m->id;
            $match->dist = $dist;
            $match->state = 0;
            $match->save();
        } else {
            $nmatch = new MatchingPost();
            $nmatch->post_from = $post->id;
            $nmatch->post_to = $m->id;
            $nmatch->dist = $dist;
            $nmatch->state = $match->state;
            $nmatch->save();
            $match->delete();
            $match = $nmatch;
        }
        if ($post->num_rooms == $m->num_rooms) {
            $amatch = MatchingPost::where('post_from', $m->id)->where('post_to', $post->id)->first();
            if ($amatch == NULL) {
                $amatch = new MatchingPost();
                $amatch->post_from = $m->id;
                $amatch->post_to = $post->id;
                $amatch->dist = $dist;
                $amatch->state = 0;
                $amatch->save();
            } else {
                $anmatch = new MatchingPost();
                $anmatch->post_from = $m->id;
                $anmatch->post_to = $post->id;
                $anmatch->dist = $dist;
                $anmatch->state = $amatch->state;
                $anmatch->save();
                $amatch->delete();
            }
        }
        if ($match->state == 0 && $dist < 5) {
            // send notification to post owners within 5 km (distance between post and post)
            $user = $m->user;
            // unset($devices);
            // $devices = array();
            // foreach ($user->logins as $login){
            //     if ($login->push_type == 2){
            //         if ($login->push_token == NULL || strlen($login->push_token) < 10){
            //         continue;
            //         }
            //         $devices[] = $login->push_token;
            //     }
            // }
            $match->state = 1;
            $match->save();
            $message = array('message' => $post->user->full_name . ' has just created a post that matches your post', 'post_id' => $match->post_to, 'post_from' => $match->post_from);
            // sendGCMMessage($devices, $message);
            sendPush($user->logins, $message);
        }
    }
}
Beispiel #8
0
 function push_test($f3, $params)
 {
     $message = array('message' => 'Test Custom Push', 'post_id' => 12345, 'post_from' => 54321);
     $logins = Login::all();
     //$logins = Login::where('push_type', 1)->get();
     //echo json_encode($logins);
     $rids = [];
     foreach ($logins as $login) {
         $rids[] = $login->push_token;
     }
     // sendGCMMessage($devices, $message);
     echo json_encode($rids);
     //sendAPNMessage($rids, $message);
     sendPush($logins, $message);
 }
        }
        //หาชื่อของผู้ส่งจาก userid ของคนที่ส่ง
        $querysendername = $con->query("SELECT * FROM `user` WHERE `user`.`user_id` = '{$userid}';");
        if ($querysendername->num_rows > 0) {
            $row = $querysendername->fetch_assoc();
            $sendername = $row['firstname'] . ' ' . $row['lastname'] . '(' . $row['nickname'] . ')';
        } else {
            $sendername = 'undefind';
        }
        //หาข้อมูล message body มาเพื่อส่ง push
        $querymessage = $con->query("SELECT * FROM `message` WHERE `message`.`message_id` = '{$msgid}';");
        if ($querymessage->num_rows > 0) {
            $row2 = $querymessage->fetch_assoc();
            $msgpayload = $row2['message_body'];
        } else {
            $msgpayload = 'undefind';
        }
        //เตรียมข้อมูลไว้ส่ง push
        $title = $msgpayload;
        $msg = $sendername;
        //ส่ง push ด้วยข้อมูลตามที่กำหนดไว้ข้างต้น เก็บค่าการส่งไว้ใน $msgstatus
        $msgstatus = sendPush($arrayOfDeviceId, $title, $msg);
        $response = array("status" => "success", "description" => "resend push complete", "push" => $msgstatus);
    } else {
        $response = array("status" => "failed", "description" => "no unAck user");
    }
} else {
    //not found user id
    $response = array("status" => "failed", "description" => "missing permission token");
}
echo json_encode($response);
Beispiel #10
0
 /**
  * Send the Push
  */
 function send_push()
 {
     if (!is_user_logged_in() || !current_user_can('manage_options') || !isset($_POST[CINDA_PREFIX . 'push_action'])) {
         return 0;
     }
     if ("parse" == $_POST[CINDA_PREFIX . 'push_action']) {
         require_once CINDA_DIR . 'vendors/Parse/push.php';
         $data = array();
         $where = array();
         $devices = array();
         if (isset($_POST[CINDA_PREFIX . "push_send_to_cid"]) && !empty($_POST[CINDA_PREFIX . "push_send_to_cid"])) {
             global $wpdb;
             $devices = $wpdb->get_col($wpdb->prepare("SELECT m.meta_value FROM " . $wpdb->prefix . "post_meta WHERE m.meta_key = '" . CINDA_PREFIX . "endpoint' AND m.post_id IN (SELECT id_volunteer FROM " . CINDA_TABLE_SUSCRIPTIONS_NAME . " WHERE id_campaign = " . $_POST[CINDA_PREFIX . "push_send_to_cid"] . ")"));
             if (!is_array($devices)) {
                 $devices = array();
             }
         }
         if (isset($_POST[CINDA_PREFIX . "push_title"])) {
             $data['alert'] = $_POST[CINDA_PREFIX . "push_title"];
         }
         if (isset($_POST["pushmessage"])) {
             $data["content"] = $_POST["pushmessage"];
         }
         if (isset($_POST[CINDA_PREFIX . "push_active_campaign"]) && isset($_POST[CINDA_PREFIX . "push_cid"])) {
             $data['cid'] = $_POST[CINDA_PREFIX . "push_cid"];
         }
         $result = sendPush($data, $devices);
     }
 }