示例#1
0
 public function index()
 {
     // STATISTIK
     $dbinbox = Inbox::statistic();
     foreach ($dbinbox as $key) {
         $category[] = $key->periode;
         $inbox[] = $key->total;
     }
     $dbsent = Sent::statistic();
     foreach ($dbsent as $key) {
         $sent[] = $key->total;
     }
     $dbsent_api = Sent::statistic('apis');
     foreach ($dbsent_api as $key) {
         $sent_api[] = $key->total;
     }
     $dbsent_keyword = Sent::statistic('keywords');
     foreach ($dbsent_keyword as $key) {
         $sent_keyword[] = $key->total;
     }
     $dbsent_user = Sent::statistic('users');
     foreach ($dbsent_user as $key) {
         $sent_user[] = $key->total;
     }
     if (\Request::ajax()) {
         $data = [['name' => 'Kotak Masuk', 'data' => $inbox], ['name' => 'Terkirim', 'data' => $sent], ['name' => 'Api', 'data' => $sent_api], ['name' => 'Kata Kunci', 'data' => $sent_keyword], ['name' => 'User', 'data' => $sent_user]];
         return \Response::json($data, 200, [], JSON_NUMERIC_CHECK);
     } else {
         $signal = Modem::select('Signal')->first();
         return view('home')->with('data', ['signal' => $signal['Signal'], 'category' => $category]);
     }
 }
示例#2
0
 public function getInbox()
 {
     $db = Inbox::grouping();
     $response["error"] = FALSE;
     $response["data"] = $db;
     return \Response::json($response);
 }
示例#3
0
 public static function daemon()
 {
     $data = Keyword::where('status', '1')->get();
     foreach ($data as $row) {
         $name = $row['name'];
         $keyword = $row['keyword'];
         $url = $row['url'];
         $joingroup_id = $row['joingroup_id'];
         $text_reply = $row['text_reply'];
         /* Pakai keyword */
         if ($keyword != '') {
             $second_keyword_count = preg_match_all("/\\[([^\\]]*)\\]/", $keyword, $second_keyword_match);
             //[]
             $main_keyword = Keyword::main($keyword);
             $db = Keyword::inbox($main_keyword);
             if ($db) {
                 // Ada inbox yang sesuai keyword
                 foreach ($db as $key) {
                     //set inbox:prosessed to true
                     Inbox::process($key->id);
                     // Action URL request
                     if ($url != '') {
                         unset($query);
                         unset($patterns);
                         unset($replacements);
                         $url_match = Keyword::url($url);
                         $query = ['sender' => urlencode($key->hp), 'message' => urlencode(trim(substr($key->isi, strlen($main_keyword)))), 'content' => urlencode($key->isi), 'time' => urlencode($key->waktu)];
                         foreach ($url_match as $key1) {
                             $patterns[] = '/\\${' . $key1 . '}/';
                             $replacements[] = $query[$key1];
                         }
                         $newurl = preg_replace($patterns, $replacements, $url);
                         //${}
                         /* SECOND KEYWORD [] (belum selesai)*/
                         if ($second_keyword_count > 0) {
                             unset($patterns2);
                             unset($replacements2);
                             $main_keyword_count = strlen($main_keyword);
                             $first = strtok($key->isi, " ");
                             $explode_keyword = explode(']', substr($keyword, strlen($main_keyword)));
                             $delimiter = substr($explode_keyword[1], 0, strpos($explode_keyword[1], '['));
                             foreach ($second_keyword_match[1] as $key2) {
                                 $patterns2[] = '/\\$\\[' . $key2 . '\\]/';
                                 $replacements2[] = $key->isi;
                                 #substr($key->isi, $main_keyword_count);
                             }
                             $newest_url = preg_replace($patterns2, $replacements2, $newurl) . ' (baru)<br>keyword:' . $keyword . '||isi:' . $key->isi . '<br>';
                             $return_url[] = $newest_url;
                         } else {
                             $return_url[] = $newurl;
                         }
                     } else {
                         $return_url[] = '';
                     }
                     // Auto add to contact and group
                     if ($joingroup_id) {
                         $firstname = $keyword ? $keyword : $name;
                         $contactname = $firstname . '-' . substr($key->hp, -3);
                         $cc = new ContactController();
                         $cc->newContact($key->hp, $contactname, $joingroup_id);
                     }
                     // Autoreply
                     if ($text_reply) {
                         Outbox::create(['DestinationNumber' => $key->hp, 'TextDecoded' => $text_reply, 'CreatorID' => 'keywords.' . $row['id']]);
                     }
                 }
             } else {
                 // Inbox tidak ada yang sesuai filter keyword
                 $return_url[] = '';
             }
         } else {
             //maaf keyword salah / tidak sesuai format
             $db = Inbox::where('Processed', 'false')->get();
             // dd($db);
         }
     }
     return $return_url;
 }
示例#4
0
 public function export($hp)
 {
     // $hp = \Input::get('hp');
     $ids = explode(',', $hp);
     // $ida = array_map(function($str){return preg_replace('/^0/', '+62', $str);}, $ids);
     $data = Inbox::conversationExport($ids);
     $contents = view('inbox.export')->with('data', $data);
     $headers = array('Content-Type' => 'application/vnd.ms-excel', 'Content-Disposition' => 'attachment; filename="InboxExport.xls"');
     return \Response::make($contents, 200, $headers);
 }