function messages($args)
 {
     list($id) = $args;
     $nn = new PushNotCamp();
     $nn->getByID($id);
     self::template(stripslashes($nn->camp_msg));
 }
예제 #2
0
 function pushnot()
 {
     echo "Searching for campaign ...<br><br>";
     $mode = addslashes($_GET['mode']);
     $hour = " AND camp_hour = " . date("G");
     if ($mode == "all") {
         $hour = "";
         echo "getting all campaign for today..<br><br>";
     } else {
         echo "getting campaign for " . date("G") . " o'clock.. <br><br>";
     }
     $psn = new PushNotCamp();
     //echo "camp_start = CURDATE() AND camp_active = 1 AND camp_status = 0 $hour";
     $arrPSN = $psn->getWhere("camp_start = CURDATE() AND camp_active = 1 AND camp_status = 0 {$hour}");
     //        pr($arrPSN);
     //action
     $action = addslashes($_GET['act']);
     if ($action == "push") {
         if (count($arrPSN) > 0) {
             //translate psn
             foreach ($arrPSN as $psn) {
                 self::kerjakan($psn);
                 $psn->camp_status = 1;
                 $psn->load = 1;
                 //TBD uncomment line dibawah kalau production
                 $psn->save();
                 echo "<hr>";
             }
         } else {
             echo "no campaign was found ..<br><br>";
         }
     } else {
         echo "no action is defined <br><br>";
     }
 }
예제 #3
0
 function doPushByDevIDwithFile()
 {
     /*
      * apa yang dibutuhkan
      */
     //        $client_id = addslashes($_POST['client_id']);
     $app_id = addslashes($_POST['app_id']);
     $key = addslashes($_POST['key']);
     $ipaddress = $_SERVER['REMOTE_ADDR'];
     //        pr($_POST['devs']);
     $app = new AppAccount();
     if ($app_id == "" || $key == "") {
         $json['status_code'] = 0;
         echo json_encode($json);
         die;
     } else {
         $app->getByID($app_id);
         //            $acc = new Account();
         //            $acc->getByID($app->app_client_id);
         if ($app->app_token != $key) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong key";
             echo json_encode($json);
             die;
         }
         if ($app->app_allowed_ip != "" && $app->app_allowed_ip != $ipaddress) {
             $json['status_code'] = 0;
             $json['status_message'] = "wrong ip, your ip is " . $ipaddress;
             echo json_encode($json);
             die;
         }
     }
     $start = addslashes($_POST['start']);
     $dest_url = addslashes($_POST['devs']);
     $devs = file_get_contents($dest_url);
     $client_camp_id = addslashes($_POST['camp_id']);
     $camp_name = addslashes($_POST['camp_name']);
     $camp_title = addslashes($_POST['camp_title']);
     //yg hrs ada cuman camp_title
     $camp_msg = addslashes($_POST['camp_msg']);
     $camp_url = addslashes($_POST['camp_url']);
     $camp_create_by = "API_" . $ipaddress;
     $camp_active = 1;
     $camp_status = 0;
     $camp_send_date = leap_mysqldate();
     $array_ids = explode(",", $devs);
     $isTest = addslashes($_POST['isTest']);
     //check pulsa
     if (count($array_ids) > $app->app_pulsa) {
         $json['status_code'] = 0;
         $json['status_message'] = "Pulsa tidak cukup";
         echo json_encode($json);
         die;
     } else {
         //  check isTest , test max ke 2 devices
         if ($isTest != "") {
             if (count($array_ids) > 5) {
                 $json['status_code'] = 0;
                 $json['status_message'] = "Test can only use 5 IDS";
                 echo json_encode($json);
                 die;
             }
         }
         //create local campaign
         $cm = new PushNotCamp();
         $cm->camp_client_id = $client_camp_id;
         //ini buat id nya di client
         $cm->camp_app_id = $app_id;
         $cm->camp_start = leap_mysqldate();
         $cm->camp_hour = 0;
         $cm->camp_name = $camp_name;
         $cm->camp_title = $camp_title;
         $cm->camp_msg = $camp_msg;
         $cm->camp_url = $camp_url;
         $cm->camp_create_by = $camp_create_by;
         $cm->camp_active = $camp_active;
         $cm->camp_status = $camp_status;
         $cm->camp_dev_ids = $devs;
         $camp_id = $cm->save();
         $cm->camp_id = $camp_id;
         $res = self::push($app, $array_ids, $camp_title, $camp_url, $camp_id);
         $json = self::processGCM($res, $app_id, $cm, $array_ids, $app, $isTest);
         echo json_encode($json);
         die;
     }
 }
 function pusher()
 {
     IMBAuth::checkOAuth();
     //        pr($_POST);
     if ($_POST['ids'] == "") {
         die("Please insert Customer ID");
     }
     if ($_POST['camp_id'] == "") {
         die("Please insert Campaign ID");
     }
     $ids = addslashes($_POST['ids']);
     $ps = new PushNotCamp();
     $ps->getByID(addslashes($_POST['camp_id']));
     $exp = explode(",", $ids);
     $arrAcc = array();
     foreach ($exp as $ac) {
         $arrAcc[] = trim(rtrim($ac));
     }
     //from acc get device ID
     Pusher::sendUsingAccountArray($arrAcc, $ps, 1);
     //1 for testing
 }
 function pusher()
 {
     IMBAuth::checkOAuth();
     //        pr($_POST);
     //        if($_POST['ids'] == "")die("Please insert Customer ID");
     if ($_POST['camp_id'] == "") {
         die("Please insert Campaign ID");
     }
     //        $ids = addslashes($_POST['ids']);
     $ps = new PushNotCamp();
     $ps->getByID(addslashes($_POST['camp_id']));
     $app = new AppAccount();
     $app->getByID($ps->camp_client_id);
     $arrAcc = $ps->camp_client_id;
     //from acc get device ID
     Pusher::sendUsingArrayAcc($arrAcc, $ps, $app, 1);
     //1 for testing
 }
예제 #6
0
 public function deletePush()
 {
     IMBAuth::checkOAuth();
     $id = addslashes($_POST['push_id']);
     $acc_id = addslashes($_POST['acc_id']);
     $user_token = addslashes($_POST['user_token']);
     $acc = new Account();
     $acc->getByID($acc_id);
     //        echo md5($acc->admin_email.$acc->admin_password);
     if (md5($acc->admin_email . $acc->admin_password) != $user_token) {
         $json['status_code'] = 0;
         $json['status_message'] = "Token Mismatched";
         echo json_encode($json);
         die;
     }
     $push = new PushNotCamp();
     $push->getByID($id);
     if ($push->camp_client_id == $acc_id) {
         //delete
         $push->delete($id);
         $this->getMyPushes();
         //            $json['status_code'] = 1;
         //            $json['status_message'] = "Success";
         //            echo json_encode($json);
         //            die();
     } else {
         $json['status_code'] = 0;
         $json['status_message'] = "Ownership Mismatched";
         echo json_encode($json);
         die;
     }
 }
 public function exportIt($return)
 {
     $id = addslashes($_GET['cid']);
     //        echo $id;
     if ($id == "" || $id < 1) {
         die("no id");
     }
     $camp = new PushNotCamp();
     $camp->getByID($id);
     $arrStatus = array("0" => "Not Pushed", "1" => "Pushed");
     if ($camp->camp_app_id != AppAccount::getAppID()) {
         die("camp mismatched");
     }
     //        pr($camp);
     $onDate = "";
     if ($camp->camp_status == 1) {
         $onDate = " on " . indonesian_date($camp->camp_send_date);
     }
     //hitung openrate dll
     $targetedDev = count(explode(",", $camp->camp_dev_ids));
     $gcm = new GCMResult();
     $arrGCM = $gcm->getWhere("camp_id = '{$id}' ORDER BY gcm_date DESC");
     $succ = 0;
     $fail = 0;
     $seen_by = 0;
     foreach ($arrGCM as $cc) {
         $succ += $cc->success;
         $fail += $cc->failure;
         $seen_by += $cc->seen_by;
     }
     $openrate = round($seen_by / $succ * 100, 3);
     $del = round($succ / ($succ + $fail) * 100, 3);
     $filename = urlencode(str_replace(" ", "_", $camp->camp_name)) . "_" . date('Ymd') . ".xls";
     header("Content-Disposition: attachment; filename=\"{$filename}\"");
     header("Content-Type: application/vnd.ms-excel");
     $flag = false;
     print "Campaign Name : \t" . $camp->camp_title;
     //judul
     print "\n";
     print "Status : \t" . $arrStatus[$camp->camp_status] . $onDate;
     //status and delieverd date
     print "\n";
     print "Content : \t" . $camp->camp_title;
     print "\n";
     print "Open Rate : \t" . $openrate;
     print "\n";
     print "Seen By : \t" . $seen_by;
     print "\n";
     print "Deliverable Percentage : \t" . $del;
     print "\n";
     print "Targeted Devices : \t" . $targetedDev;
     print "\n";
     print "Success : \t" . $succ;
     print "\n";
     print "Failed : \t" . $fail;
     print "\n";
     print "\n";
     $logs = new PushLogger();
     $objs = $logs->getWhere("log_camp_id = '{$id}'");
     $filter = explode(",", $logs->exportList);
     foreach ($objs as $key => $obj) {
         foreach ($obj as $name => $value) {
             if (in_array($name, $filter)) {
                 echo Lang::t($name) . "\t";
             }
         }
         break;
     }
     print "\n";
     foreach ($objs as $key => $obj) {
         foreach ($obj as $name => $value) {
             if (in_array($name, $filter)) {
                 echo $value . "\t";
             }
         }
         print "\n";
     }
     exit;
 }
예제 #8
0
 function messages($args)
 {
     list($id) = $args;
     $nn = new PushNotCamp();
     $nn->getByID($id);
     self::templateAppear($nn);
 }