add flutter

This commit is contained in:
Ariska
2026-03-11 15:29:37 +07:00
parent c253e1a370
commit 619d758027
9490 changed files with 135801 additions and 1353 deletions

View File

@@ -24,13 +24,25 @@ class appnotification extends CI_Controller
public function send()
{
$this->load->helper('fcm_v1_helper');
// Validate Firebase token before kirim. If no token, relogin (retry) is done in helper.
if (!fcm_v1_validate_token()) {
$this->session->set_flashdata('error', 'Firebase token tidak valid. Pastikan file ngojol-trial-firebase-adminsdk JSON ada dan dapat dibaca. Silakan coba lagi.');
redirect('appnotification/index');
return;
}
$topic = $this->input->post('topic');
$title = $this->input->post('title');
$message = $this->input->post('message');
$this->notif->send_notif($title, $message, $topic);
$this->session->set_flashdata('send', 'Notifikasi berhasil dikirim');
$ok = $this->notif->send_notif($title, $message, $topic);
if ($ok) {
$this->session->set_flashdata('send', 'Notifikasi berhasil dikirim');
} else {
$this->session->set_flashdata('error', 'Gagal mengirim notifikasi. Firebase token mungkin kedaluwarsa. Silakan coba lagi.');
}
redirect('appnotification/index');
}
}

0
backendpanel/application/controllers/Appsettings.php Normal file → Executable file
View File

View File

0
backendpanel/application/controllers/Dashboard.php Normal file → Executable file
View File

4
backendpanel/application/controllers/Driver.php Normal file → Executable file
View File

@@ -59,6 +59,7 @@ class Driver extends CI_Controller
$this->form_validation->set_rules('tgl_lahir', 'tgl_lahir', 'trim|prep_for_form');
$this->form_validation->set_rules('gender', 'gender', 'trim|prep_for_form');
$this->form_validation->set_rules('alamat_driver', 'alamat_driver', 'trim|prep_for_form');
$this->form_validation->set_rules('reg_id', 'reg_id', 'trim|prep_for_form');
if ($this->form_validation->run() == TRUE) {
@@ -76,7 +77,8 @@ class Driver extends CI_Controller
'tempat_lahir' => html_escape($this->input->post('tempat_lahir', TRUE)),
'tgl_lahir' => html_escape($this->input->post('tgl_lahir', TRUE)),
'gender' => html_escape($this->input->post('gender', TRUE)),
'alamat_driver' => html_escape($this->input->post('alamat_driver', TRUE))
'alamat_driver' => html_escape($this->input->post('alamat_driver', TRUE)),
'reg_id' => html_escape($this->input->post('reg_id', TRUE))
];

0
backendpanel/application/controllers/Error404.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Login.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Mitra.php Normal file → Executable file
View File

View File

0
backendpanel/application/controllers/News.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Partnerjob.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Partnerregion.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Profile.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Promocode.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Promoslider.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Resetpass.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Sendemail.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Services.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Transaction.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Users.php Normal file → Executable file
View File

0
backendpanel/application/controllers/Wallet.php Normal file → Executable file
View File

55
backendpanel/application/controllers/api/Driver.php Normal file → Executable file
View File

@@ -10,6 +10,7 @@ class Driver extends REST_Controller
parent::__construct();
$this->load->helper("url");
$this->load->helper('fcm_v1_helper');
$this->load->database();
$this->load->model('Driver_model');
$this->load->model('Pelanggan_model');
@@ -75,16 +76,28 @@ class Driver extends REST_Controller
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'reg_id' => $decoded_data->token
);
// Only save reg_id (FCM token) when valid. Invalid/placeholder tokens are updated by relogin.
$token_from_regid = isset($decoded_data->reg_id) ? trim((string) $decoded_data->reg_id) : '';
$token_from_token = isset($decoded_data->token) ? trim((string) $decoded_data->token) : '';
$token = $token_from_regid !== '' ? $token_from_regid : $token_from_token;
$reg_id = array();
if ($token !== '' && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($token)) {
$reg_id['reg_id'] = $token;
}
$condition = array(
'password' => sha1($decoded_data->password),
'no_telepon' => $decoded_data->no_telepon,
//'token' => $decoded_data->token
'password' => sha1($decoded_data->password)
);
$check_banned = $this->Driver_model->check_banned($decoded_data->no_telepon);
$login_by_phone = isset($decoded_data->no_telepon) && $decoded_data->no_telepon !== '';
if ($login_by_phone) {
$condition['no_telepon'] = $decoded_data->no_telepon;
} else {
$condition['email'] = $decoded_data->email;
}
$check_banned = $login_by_phone
? $this->Driver_model->check_banned($decoded_data->no_telepon)
: $this->Driver_model->check_banned_by_email($decoded_data->email);
if ($check_banned) {
$message = array(
'message' => 'banned',
@@ -96,9 +109,12 @@ class Driver extends REST_Controller
$message = array();
if ($cek_login->num_rows() > 0) {
$upd_regid = $this->Driver_model->edit_profile($reg_id, $decoded_data->no_telepon);
$no_telepon = $cek_login->row()->no_telepon;
if (!empty($reg_id)) {
$this->Driver_model->edit_profile($reg_id, $no_telepon);
}
$get_pelanggan = $this->Driver_model->get_data_pelanggan($condition);
$this->Driver_model->edit_status_login($decoded_data->no_telepon);
$this->Driver_model->edit_status_login($no_telepon);
$message = array(
'code' => '200',
'message' => 'found',
@@ -133,6 +149,12 @@ class Driver extends REST_Controller
);
$ins = $this->Driver_model->my_location($data);
// When driver sends valid FCM token (reg_id) with location, update so they receive order requests. Invalid/placeholder tokens are updated by relogin.
$reg_id = isset($decoded_data->reg_id) ? trim((string) $decoded_data->reg_id) : '';
if ($reg_id !== '' && isset($decoded_data->id_driver) && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($reg_id)) {
$this->Driver_model->update_driver_reg_id($decoded_data->id_driver, $reg_id);
}
if ($ins) {
$message = array(
'message' => 'location updated',
@@ -360,6 +382,7 @@ class Driver extends REST_Controller
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'accept_post: payload=' . $data);
$data_req = array(
'id_driver' => $dec_data->id,
@@ -372,9 +395,11 @@ class Driver extends REST_Controller
);
$cek_login = $this->Driver_model->get_status_driver($condition);
log_message('debug', 'accept_post: get_status_driver rows=' . $cek_login->num_rows());
if ($cek_login->num_rows() > 0) {
$acc_req = $this->Driver_model->accept_request($data_req);
log_message('debug', 'accept_post: accept_request result=' . json_encode($acc_req));
if ($acc_req['status']) {
$message = array(
'message' => 'berhasil',
@@ -415,6 +440,7 @@ class Driver extends REST_Controller
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'start_post: payload=' . $data);
$data_req = array(
'id_driver' => $dec_data->id,
@@ -422,6 +448,7 @@ class Driver extends REST_Controller
);
$acc_req = $this->Driver_model->start_request($data_req);
log_message('debug', 'start_post: start_request result=' . json_encode($acc_req));
if ($acc_req['status']) {
$message = array(
'message' => 'berhasil',
@@ -455,6 +482,7 @@ class Driver extends REST_Controller
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'finish_post: payload=' . $data);
$data_req = array(
'id_driver' => $dec_data->id,
@@ -467,6 +495,7 @@ class Driver extends REST_Controller
);
$finish_transaksi = $this->Driver_model->finish_request($data_req, $data_tr);
log_message('debug', 'finish_post: finish_request result=' . json_encode($finish_transaksi));
if ($finish_transaksi['status']) {
$message = array(
'message' => 'berhasil',
@@ -863,6 +892,12 @@ class Driver extends REST_Controller
$namafoto = time() . '-' . rand(0, 99999) . ".jpg";
$path = "images/fotodriver/" . $namafoto;
file_put_contents($path, base64_decode($image));
// New driver registrations from older apps do not send an FCM token yet.
// Generate a deterministic placeholder based on email so reg_id is never empty.
// This stays unusable for FCM v1 because fcm_v1_is_valid_device_token() will reject it.
$regIdPlaceholder = 'R' . sprintf('%u', crc32(strtolower(trim((string) $dec_data->email))));
$data_signup = array(
'id' => 'D' . time(),
'nama_driver' => $dec_data->nama_driver,
@@ -878,7 +913,7 @@ class Driver extends REST_Controller
'countrycode' => $dec_data->countrycode,
'gender' => $dec_data->gender,
'alamat_driver' => $dec_data->alamat_driver,
'reg_id' => 12345,
'reg_id' => $regIdPlaceholder,
'status' => 0
);

0
backendpanel/application/controllers/api/Map.php Normal file → Executable file
View File

22
backendpanel/application/controllers/api/Merchant.php Normal file → Executable file
View File

@@ -10,6 +10,7 @@ class Merchant extends REST_Controller
parent::__construct();
$this->load->helper("url");
$this->load->helper('fcm_v1_helper');
$this->load->database();
$this->load->model('Merchantapi_model');
$this->load->model('wallet_model', 'wallet');
@@ -64,9 +65,13 @@ class Merchant extends REST_Controller
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'token_merchant' => $decoded_data->token
);
// Only save FCM token when valid (relogin overwrites invalid/placeholder tokens).
$token = isset($decoded_data->token) ? trim((string) $decoded_data->token) : '';
$token = (isset($decoded_data->reg_id) && trim((string) $decoded_data->reg_id) !== '') ? trim((string) $decoded_data->reg_id) : $token;
$reg_id = array();
if ($token !== '' && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($token)) {
$reg_id['token_merchant'] = $token;
}
$condition = array(
'password' => sha1($decoded_data->password),
@@ -84,7 +89,9 @@ class Merchant extends REST_Controller
$cek_login = $this->Merchantapi_model->get_data_merchant($condition);
$message = array();
if ($cek_login->num_rows() > 0) {
$this->Merchantapi_model->edit_profile_token($reg_id, $decoded_data->no_telepon);
if (!empty($reg_id)) {
$this->Merchantapi_model->edit_profile_token($reg_id, $decoded_data->no_telepon);
}
$get_pelanggan = $this->Merchantapi_model->get_data_merchant($condition);
$message = array(
'code' => '200',
@@ -183,6 +190,11 @@ class Merchant extends REST_Controller
$path = "images/merchant/" . $namafoto;
file_put_contents($path, base64_decode($image));
// Merchant apps prior to FCM v1 do not send a Firebase token on register.
// Generate a deterministic placeholder from email so token_merchant is never empty.
// This value is NOT a real FCM token; Notification_model will ignore it for push.
$tokenPlaceholder = 'R' . sprintf('%u', crc32(strtolower(trim((string) $dec_data->email))));
$data_merchant = array(
'id_fitur' => $dec_data->id_fitur,
'nama_merchant' => $dec_data->nama_merchant,
@@ -197,7 +209,7 @@ class Merchant extends REST_Controller
'phone_merchant' => $dec_data->phone,
'country_code_merchant' => $dec_data->countrycode,
'status_merchant' => '0',
'token_merchant' => time()
'token_merchant' => $tokenPlaceholder
);
$imagektp = $dec_data->foto_ktp;

0
backendpanel/application/controllers/api/Midtrans.php Normal file → Executable file
View File

View File

@@ -48,6 +48,17 @@ class Notification extends REST_Controller
return;
}
$this->load->helper('fcm_v1_helper');
// Always verify FCM token is ready before using Firebase service (as in test / panel send).
if (!fcm_v1_validate_token()) {
$this->response(array(
'code' => '503',
'message' => 'fcm_token_not_ready',
), 200);
return;
}
$target = isset($decoded['target']) ? trim($decoded['target']) : '';
$is_topic = !empty($decoded['is_topic']);
$data = isset($decoded['data']) && is_array($decoded['data']) ? $decoded['data'] : array();

128
backendpanel/application/controllers/api/Pelanggan.php Normal file → Executable file
View File

@@ -10,6 +10,7 @@ class Pelanggan extends REST_Controller
parent::__construct();
$this->load->helper("url");
$this->load->helper('fcm_v1_helper');
$this->load->database();
$this->load->model('Pelanggan_model');
$this->load->model('wallet_model', 'wallet');
@@ -115,16 +116,37 @@ class Pelanggan extends REST_Controller
$data = file_get_contents("php://input");
$decoded_data = json_decode($data);
$reg_id = array(
'token' => $decoded_data->token
);
if (!$decoded_data || !isset($decoded_data->password)) {
$this->response(array('code' => '400', 'message' => 'Invalid request', 'data' => []), 200);
return;
}
// Only save FCM token when valid (relogin overwrites invalid/placeholder tokens).
$token = isset($decoded_data->token) ? trim((string) $decoded_data->token) : '';
$token = (isset($decoded_data->reg_id) && trim((string) $decoded_data->reg_id) !== '') ? trim((string) $decoded_data->reg_id) : $token;
$reg_id = array();
if ($token !== '' && function_exists('fcm_v1_is_valid_device_token') && fcm_v1_is_valid_device_token($token)) {
$reg_id['token'] = $token;
}
$condition = array(
'password' => sha1($decoded_data->password),
'no_telepon' => $decoded_data->no_telepon,
//'token' => $decoded_data->token
'password' => sha1($decoded_data->password)
);
$check_banned = $this->Pelanggan_model->check_banned($decoded_data->no_telepon);
$no_telepon_val = isset($decoded_data->no_telepon) ? trim($decoded_data->no_telepon) : '';
$email_val = isset($decoded_data->email) ? trim($decoded_data->email) : '';
$login_by_phone = $no_telepon_val !== '';
if ($login_by_phone) {
$condition['no_telepon'] = $no_telepon_val;
} else {
if ($email_val === '') {
$this->response(array('code' => '404', 'message' => 'no hp atau password salah!', 'data' => []), 200);
return;
}
$condition['email'] = $email_val;
}
$check_banned = $login_by_phone
? $this->Pelanggan_model->check_banned($no_telepon_val)
: $this->Pelanggan_model->check_banned_user($email_val);
if ($check_banned) {
$message = array(
'message' => 'banned',
@@ -136,7 +158,10 @@ class Pelanggan extends REST_Controller
$message = array();
if ($cek_login->num_rows() > 0) {
$upd_regid = $this->Pelanggan_model->edit_profile($reg_id, $decoded_data->no_telepon);
$no_telepon = $cek_login->row()->no_telepon;
if (!empty($reg_id)) {
$this->Pelanggan_model->edit_profile($reg_id, $no_telepon);
}
$get_pelanggan = $this->Pelanggan_model->get_data_pelanggan($condition);
$message = array(
@@ -206,6 +231,21 @@ class Pelanggan extends REST_Controller
$namafoto = time() . '-' . rand(0, 99999) . ".jpg";
$path = "images/pelanggan/" . $namafoto;
file_put_contents($path, base64_decode($image));
// New users may register from older apps that do not send an FCM token.
// Generate a deterministic placeholder based on email so the column is never empty.
// This placeholder is intentionally SHORT / starting with "R" + digits so
// fcm_v1_is_valid_device_token() will treat it as invalid for push.
$incomingToken = isset($dec_data->token) ? trim((string) $dec_data->token) : '';
if ($incomingToken === '') {
$emailForToken = isset($dec_data->email) ? strtolower(trim((string) $dec_data->email)) : '';
if ($emailForToken !== '') {
$incomingToken = 'R' . sprintf('%u', crc32($emailForToken));
} else {
$incomingToken = 'R' . sprintf('%u', crc32('guest-' . time()));
}
}
$data_signup = array(
'id' => 'P' . time(),
'fullnama' => $dec_data->fullnama,
@@ -216,7 +256,7 @@ class Pelanggan extends REST_Controller
'tgl_lahir' => $dec_data->tgl_lahir,
'countrycode' => $dec_data->countrycode,
'fotopelanggan' => $namafoto,
'token' => $dec_data->token,
'token' => $incomingToken,
);
$signup = $this->Pelanggan_model->signup($data_signup);
if ($signup) {
@@ -831,24 +871,24 @@ class Pelanggan extends REST_Controller
$token = $this->wallet->gettoken($iduser);
$regid = $this->wallet->getregid($iduser);
$tokenmerchant = $this->wallet->gettokenmerchant($iduser);
if ($token == NULL and $tokenmerchant == NULL and $regid != NULL) {
$topic = null;
if ($token == NULL and $tokenmerchant == NULL and $regid != NULL && !empty(trim((string) $regid['reg_id']))) {
$topic = $regid['reg_id'];
} else if ($regid == NULL and $tokenmerchant == NULL and $token != NULL) {
} else if ($regid == NULL and $tokenmerchant == NULL and $token != NULL && !empty(trim((string) $token['token']))) {
$topic = $token['token'];
} else if ($regid == NULL and $token == NULL and $tokenmerchant != NULL) {
} else if ($regid == NULL and $token == NULL and $tokenmerchant != NULL && !empty(trim((string) $tokenmerchant['token_merchant']))) {
$topic = $tokenmerchant['token_merchant'];
}
$title = 'Sukses';
$message = 'Permintaan berhasil dikirim';
$saldo = $this->wallet->getsaldo($iduser);
$this->wallet->ubahsaldo($iduser, $amount, $saldo);
//$this->wallet->ubahstatuswithdrawbyid($id);
$this->wallet->send_notif($title, $message, $topic);
if ($topic !== null) {
$this->wallet->send_notif($title, $message, $topic);
}
/* END EDIT */
$message = array(
@@ -877,12 +917,26 @@ class Pelanggan extends REST_Controller
}
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'list_ride_post REQUEST: ' . $data);
$near = $this->Pelanggan_model->get_driver_ride($dec_data->latitude, $dec_data->longitude, $dec_data->fitur);
$dec_data = json_decode($data);
if (!$dec_data || !isset($dec_data->latitude, $dec_data->longitude, $dec_data->fitur)) {
log_message('error', 'list_ride_post: invalid request, missing latitude/longitude/fitur');
$message = array('data' => [], 'error' => 'Invalid request: latitude, longitude, fitur required');
$this->response($message, 200);
return;
}
$radius_km = null;
if (isset($dec_data->radius_km) && is_numeric($dec_data->radius_km)) {
$radius_km = max(1, min(100, (float) $dec_data->radius_km));
}
$near = $this->Pelanggan_model->get_driver_ride($dec_data->latitude, $dec_data->longitude, $dec_data->fitur, $radius_km);
$drivers = $near->result();
$message = array(
'data' => $near->result()
'data' => $drivers
);
log_message('debug', 'list_ride_post RESPONSE: fitur=' . $dec_data->fitur . ' lat=' . $dec_data->latitude . ' lng=' . $dec_data->longitude . ' radius_km=' . ($radius_km !== null ? $radius_km : 'default') . ' drivers_found=' . count($drivers));
$this->response($message, 200);
}
@@ -910,12 +964,26 @@ class Pelanggan extends REST_Controller
}
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'list_car_post REQUEST: ' . $data);
$near = $this->Pelanggan_model->get_driver_car($dec_data->latitude, $dec_data->longitude, $dec_data->fitur);
$dec_data = json_decode($data);
if (!$dec_data || !isset($dec_data->latitude, $dec_data->longitude, $dec_data->fitur)) {
log_message('error', 'list_car_post: invalid request, missing latitude/longitude/fitur');
$message = array('data' => [], 'error' => 'Invalid request: latitude, longitude, fitur required');
$this->response($message, 200);
return;
}
$radius_km = null;
if (isset($dec_data->radius_km) && is_numeric($dec_data->radius_km)) {
$radius_km = max(1, min(100, (float) $dec_data->radius_km));
}
$near = $this->Pelanggan_model->get_driver_car($dec_data->latitude, $dec_data->longitude, $dec_data->fitur, $radius_km);
$drivers = $near->result();
$message = array(
'data' => $near->result()
'data' => $drivers
);
log_message('debug', 'list_car_post RESPONSE: fitur=' . $dec_data->fitur . ' lat=' . $dec_data->latitude . ' lng=' . $dec_data->longitude . ' radius_km=' . ($radius_km !== null ? $radius_km : 'default') . ' drivers_found=' . count($drivers));
$this->response($message, 200);
}
@@ -946,6 +1014,7 @@ class Pelanggan extends REST_Controller
} else {
$cek = $this->Pelanggan_model->check_banned_user($_SERVER['PHP_AUTH_USER']);
if ($cek) {
log_message('debug', 'request_transaksi_post: banned user ' . $_SERVER['PHP_AUTH_USER']);
$message = array(
'message' => 'fail',
'data' => 'Status User Banned'
@@ -956,6 +1025,7 @@ class Pelanggan extends REST_Controller
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'request_transaksi_post: payload=' . $data);
$data_req = array(
'id_pelanggan' => $dec_data->id_pelanggan,
@@ -977,12 +1047,18 @@ class Pelanggan extends REST_Controller
$request = $this->Pelanggan_model->insert_transaksi($data_req);
if ($request['status']) {
if (isset($request['data'][0]->id)) {
log_message('debug', 'request_transaksi_post: success id_transaksi=' . $request['data'][0]->id . ' id_pelanggan=' . $dec_data->id_pelanggan . ' fitur=' . $dec_data->order_fitur);
} else {
log_message('debug', 'request_transaksi_post: success (no id in data) payload=' . json_encode($request['data']));
}
$message = array(
'message' => 'success',
'data' => $request['data']
);
$this->response($message, 200);
} else {
log_message('error', 'request_transaksi_post: insert_transaksi fail data=' . json_encode($request['data']));
$message = array(
'message' => 'fail',
'data' => $request['data']
@@ -1001,12 +1077,14 @@ class Pelanggan extends REST_Controller
$data = file_get_contents("php://input");
$dec_data = json_decode($data);
log_message('debug', 'check_status_transaksi_post: payload=' . $data);
$dataTrans = array(
'id_transaksi' => $dec_data->id_transaksi
);
$getStatus = $this->Pelanggan_model->check_status($dataTrans);
log_message('debug', 'check_status_transaksi_post: result=' . json_encode($getStatus));
$this->response($getStatus, 200);
}

0
backendpanel/application/controllers/api/Xendit.php Normal file → Executable file
View File

0
backendpanel/application/controllers/index.html Normal file → Executable file
View File

0
backendpanel/application/controllers/notification.php Normal file → Executable file
View File

0
backendpanel/application/controllers/snap.php Normal file → Executable file
View File

0
backendpanel/application/controllers/vtweb.php Normal file → Executable file
View File