Esempio n. 1
1
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     $isBought = $nexmo->buyNumber(Input::get('country_code'), Input::get('number'));
     if ($isBought) {
         Pusherer::trigger('boom', 'update_balance', $nexmo->getBalance());
         $number = new Number();
         $number->number = Input::get('number');
         $number->country_code = Input::get('country_code');
         $number->type = Input::get('type');
         $number->features = explode(',', Input::get('features'));
         $number->save();
         return $number;
     }
     return $this->response->errorInternal();
 }
Esempio n. 2
0
 public static function sendSocket($arrData, $fromCLI = false)
 {
     if (!isset($arrData['message'])) {
         $arrData['message'] = 'Everything is ok!';
     }
     if (!isset($arrData['status'])) {
         $arrData['status'] = 'success';
     }
     if ($fromCLI) {
         if (!isset($arrData['event'])) {
             $arrData['event'] = 'notification';
         }
         Pusherer::trigger('notification', $arrData['event'], $arrData);
     } else {
         $url = URL . '/' . md5(md5('send-message'));
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $url);
         curl_setopt($curl, CURLOPT_HEADER, 0);
         curl_setopt($curl, CURLOPT_PORT, 80);
         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($arrData));
         curl_exec($curl);
     }
 }
Esempio n. 3
0
 public function fire($job, $outbound_id)
 {
     $outbound = Outbound::findOrFail($outbound_id);
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     $response = $nexmo->sendMessage($outbound->from, $outbound->to, $outbound->text, array('status-report-req' => 1, 'client-ref' => $outbound_id));
     $isSent = true;
     if ($response['message-count'] > 0) {
         foreach ($response['messages'] as $message) {
             $outbound_chunk = new OutboundChunk();
             $outbound_chunk->outbound_id = $outbound_id;
             $outbound_chunk->message_id = $message['message-id'];
             $outbound_chunk->status_code = $message['status'];
             $outbound_chunk->price = $message['message-price'];
             $outbound_chunk->save();
             // update balance
             Pusherer::trigger('boom', 'update_balance', $message['remaining-balance']);
             if ($message['status'] > 0) {
                 $isSent = false;
             }
         }
     }
     // update status outbound
     if ($isSent) {
         $outbound->status = 'sent';
         $outbound->save();
     }
     $job->delete();
 }
Esempio n. 4
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($inbound) {
         Pusherer::trigger('boom', 'add_inbound', $inbound);
         Queue::getIron()->addSubscriber('moCallback', array('url' => url('queue/receive')));
         Queue::push('Inbound@moCallback', $inbound->id, 'moCallback');
     });
 }
Esempio n. 5
0
 public function store()
 {
     $message = new Message();
     $message->published_at = new DateTime();
     $message->message = Input::get('message');
     $message = $this->savePicture($message);
     $message->save();
     $renderedMessage = View::make('_message', compact('message'))->render();
     Pusherer::trigger('test_channel', 'my_event', ['message' => $renderedMessage]);
     return Redirect::route('admin');
 }
Esempio n. 6
0
 public function postDeposito()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     $moneda = Input::get('moneda');
     $user_id = Input::get('user_id');
     $consecutivo = Input::get('consecutivo');
     Auth::attempt(array('email' => $email, 'password' => $password));
     if (Auth::check()) {
         setlocale(LC_TIME, "esp");
         $fecha = utf8_encode(strftime("%A, %d de %B de %Y, Hora %H:%M"));
         $fecha_corta = utf8_encode(strftime("%d de %B - %H:%M"));
         $usuario = User::find($user_id);
         $porcentaje = $usuario->porcentaje;
         $moneda_des = $moneda - $moneda * $porcentaje;
         $deposito = new UserAlcanciaDeposito();
         $deposito->user_alcancia_id = $consecutivo;
         $deposito->moneda = $moneda;
         $deposito->moneda_des = $moneda_des;
         $deposito->fecha = $fecha;
         $deposito->fecha_corta = $fecha_corta;
         $deposito->save();
         $uad = UserAlcancia::find($consecutivo)->transacciones->first();
         // si es el primer deposito
         if (empty($uad)) {
             $transaccion = new Transacciones();
             $transaccion->user_id = $user_id;
             $transaccion->valor = $moneda_des;
             $transaccion->tipo = 1;
             $transaccion->origen = $deposito->userAlcancia->alcancia->ubicacion;
             // ubicació de la alcancia
             $transaccion->movimiento = 'Deposito';
             $transaccion->user_alcancia_id = $consecutivo;
             $transaccion->fecha = date('Y-m-d');
             $transaccion->estado = 1;
             $transaccion->save();
         } else {
             $update_transaccion = Transacciones::find($uad->id);
             $suma_moneda = $update_transaccion->valor + $moneda_des;
             $update_transaccion->valor = $suma_moneda;
             $update_transaccion->save();
         }
         $suma = Recursos::getSumaMonedaByUser($user_id);
         $suma = $suma - $suma * $porcentaje;
         $suma_total = $usuario->transacciones->sum('valor');
         Pusherer::trigger('Canal_moneda' . $usuario->email, 'my_event-' . $usuario->email, array('suma' => $suma_total));
         return "Ahorro Guardado Ok";
     } else {
         return "No logueado";
     }
 }
Esempio n. 7
0
 public static function boot()
 {
     parent::boot();
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     static::created(function ($number) use($nexmo) {
         Pusherer::trigger('boom', 'add_number', $number);
         // set mo and voice callback url
         Queue::getIron()->addSubscriber('setupNumberCallbackUrl', array('url' => url('queue/receive')));
         Queue::push('Number@setupNumberCallbackUrl', array('nexmo_key' => $nexmo->nexmo_key, 'nexmo_secret' => $nexmo->nexmo_secret, 'country_code' => $number->country_code, 'number' => $number->number), 'setupNumberCallbackUrl');
     });
     static::updating(function ($number) use($nexmo) {
         if ($number->isDirty('voice_callback_type') || $number->isDirty('voice_callback_value')) {
             return $nexmo->updateNumber($number->country_code, $number->number, url('callback/mo'), array('voiceCallbackType' => $number->voice_callback_type, 'voiceCallbackValue' => $number->voice_callback_value, 'voiceStatusCallback' => url('callback/voice')));
         }
         return true;
     });
     static::deleting(function ($number) use($nexmo) {
         return $nexmo->cancelNumber($number->country_code, $number->number);
     });
     static::deleted(function ($number) {
         Pusherer::trigger('boom', 'remove_number', $number);
     });
 }
Esempio n. 8
0
    $img = checkUserAvatar($sender->email, 'small');
    Pusherer::trigger('GlobalMessageChannel', 'newGlobalMessage', array('email' => $sender->email, 'message' => $event->body, 'user_link' => $userLink, 'img' => $img, 'username' => $sender->username));
});
Event::listen('Pluto.Updates.Events.UpdatePublished', function ($event) {
    // $sender =   getUser(1);
    // $receiver = getUser(2);
    // $total_requests = getTotalRequests(2);
    // $img = checkUserAvatar('*****@*****.**');
    // $gender = "Male";
    // $url = Request::root().'/respond-to-friend-request';
    //    Pusherer::trigger('FriendRequestChannel', 'userSentRequest', array('sender_id' => '1', 'img' => $img, 'url' => $url,  'gender' => $gender,  'sender_email' => '*****@*****.**', 'receiver_email' => '*****@*****.**', 'sender_name' => 'Prateek Singh', 'total_req' => $total_requests->count() ));
    $url = Request::root() . '/news-update-check-friendship';
    $update = getUpdateObject($event->type, $event->user_id, $event->post_id);
    switch ($event->type) {
        case 'status':
            Pusherer::trigger('RecentUpdateChannel', 'userDidRecent', array('root_id' => $update->id, 'url' => $url, 'user_id' => $event->user_id, 'type' => $event->type, 'post_id' => $event->post_id));
            break;
        default:
            break;
    }
});
Event::listen('Pluto.FriendRequests.Events.FriendRequestPublished', function ($event) {
    $sender = getUser($event->sender_id);
    $receiver = getUser($event->receiver_id);
    $total_requests = getTotalRequests($event->receiver_id);
    $img = checkUserAvatar($sender->email, 'small');
    $gender = $sender->info->gender;
    $url = Request::root() . '/respond-to-friend-request';
    $userpage = Request::root() . '/' . $sender->username;
    Pusherer::trigger('FriendRequestChannel', 'userSentRequest', array('sender_link' => $userpage, 'sender_id' => $sender->id, 'img' => $img, 'url' => $url, 'gender' => $gender, 'sender_email' => $sender->email, 'receiver_email' => $receiver->email, 'sender_name' => $sender->info->firstname . ' ' . $sender->info->lastname, 'total_req' => $total_requests->count()));
});
Esempio n. 9
0
<?php

Route::post('/pusher/auth', function () {
    $bfacp = App::make('bfadmincp');
    if (Input::has('channel_name') && Input::has('socket_id') && $bfacp->isLoggedIn) {
        $socket = Pusherer::presence_auth(Input::get('channel_name'), Input::get('socket_id'), $bfacp->user->id, ['id' => $bfacp->user->id, 'username' => $bfacp->user->username, 'avatar' => $bfacp->user->gravatar, 'role' => $bfacp->user->roles[0]->name, 'timestamp' => \Carbon\Carbon::now()->getTimestamp()]);
        return Response::make($socket);
    }
    return Response::make('Forbidden', 403);
});
/**
 * Route Model Bindings
 */
Route::model('player', 'BFACP\\Battlefield\\Player');
/**
 * Route API Registering
 */
Route::api(['namespace' => 'BFACP\\Http\\Controllers\\Api', 'version' => 'v1'], function () {
    /*===================================
      =            API Resources          =
      ===================================*/
    Route::group(['prefix' => 'helpers'], function () {
        Route::group(['prefix' => 'adkats'], function () {
            Route::get('special_groups', 'HelpersController@getSpecialGroups');
        });
        Route::get('online/admins', 'HelpersController@onlineAdmins');
        Route::get('ip/{addy}', 'HelpersController@iplookup');
        Route::get('squads', function () {
            $squads = [];
            for ($i = 0; $i <= 32; $i++) {
                $squads[] = ['id' => $i, 'name' => BattlefieldHelper::squad($i)];