function html($to, $toName, $from, $fromName, $subject, $body) { $mail = new mailer(); if (defined('mail_from')) { $mail->From = mail_from; $mail->AddReplyTo($from, $fromName); } else { $mail->From = $from; } $mail->FromName = $fromName; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $body; switch (gettype($to)) { case 'string': $mail->AddAddress($to, $toName); break; case 'array': foreach ($to as $toKey => $thisTo) { $mail->AddAddress($thisTo, $toName[$toKey]); } break; default: trigger_error('invalid type for address field'); } if (!$mail->Send()) { trigger_error("Message could not be sent. Mailer Error: " . $mail->ErrorInfo); } }
public function exec($data) { $response_array = array(); $name = ucwords($data['name']); $email = $data['email']; $phone = $data['phone'] != "" ? $data['phone'] : "-"; $message = $data['message']; // NOTIFY RECEIVER BY EMAIL // Generate Email BODY $html = file_get_contents(BASE_PATH . 'email_template/contact'); $html = htmlspecialchars($html); $html = str_replace('[NAME]', $name, $html); $html = str_replace('[EMAIL]', $email, $html); $html = str_replace('[PHONE]', $phone, $html); $html = str_replace('[MESSAGE]', $message, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = SUPPORT_NAME; $mailer->AddReplyTo($email, $name); $mailer->AddAddress(CONTACT_EMAIL); $mailer->IsHTML(true); $mailer->Subject = "NEW message from {$email} via 1STG Contact Form."; $mailer->Body = $body; if (!$mailer->Send()) { $response_array['r'] = "false"; $response_array['msg'] = "Technical Error: " . $mailer->ErrorInfo; } else { $response_array['r'] = "true"; $response_array['msg'] = "Your message has been successfully submit."; } return $response_array; }
public function addagent_exec($data) { $response_array = array(); foreach ($data as $key => $value) { if ($value == "") { $data[$key] = NULL; } } $agent = new user(); $data['fullname'] = strtoupper($data['fullname']); $data['agent_id'] = $agent->generateID(); $data['tmp_password'] = strtoupper(hash::create('crc32', uniqid(), HASH_PASSWORD_KEY)); $data['activate_code'] = $agent->generateActivationCode($data['email']); $acc_type = $data['acc_type']; switch ($acc_type) { case "aa": $ads_pin_limit = 1; $available_pin = 1; break; case "ad": $ads_pin_limit = 15; $available_pin = 15; break; case "ed": $ads_pin_limit = 20; $available_pin = 20; break; case "ep": $ads_pin_limit = 40; $available_pin = 40; break; default: $ads_pin_limit = "unlimited"; $available_pin = 40; break; } $data['ads_pin_limit'] = $ads_pin_limit; $data['available_pin'] = $available_pin; $data['address'] = ucwords($data['address']); $data['mobile'] = str_replace("-", "", $data['mobile']); $data['mobile'] = str_replace(" ", "", $data['mobile']); $data['mobile'] = str_replace("+6", "", $data['mobile']); $data['mobile'] = "+6" . $data['mobile']; if (!empty($data['phone'])) { $data['phone'] = str_replace("-", "", $data['phone']); $data['phone'] = str_replace(" ", "", $data['phone']); $data['phone'] = str_replace("+6", "", $data['phone']); $data['phone'] = "+6" . $data['phone']; } $checkEmail = $agent->checkEmail($data['email']); $checkCEmail = $agent->checkCdata($data['email'], $data['cemail']); $checkUsername = $data['chkusername']; $validUplineSponsor = FALSE; $sponsorId = $data['sponsor_id']; $uplineId = $data['lv1']; if ($sponsorId != $uplineId) { $upline_data = $this->db->select("user_accounts", "lv1,lv2,lv3,lv4,lv5,lv6,lv7,lv8,lv9,lv10", "agent_id = '{$uplineId}'", "fetch"); foreach ($upline_data as $value) { if ($value == $sponsorId) { $validUplineSponsor = TRUE; } } } else { $validUplineSponsor = TRUE; } //GENERATE ADS PIN if ($acc_type == "aa") { $ads_pin = "1000000"; } else { $ads_pin = $agent->getRegPin(); } $data['ads_pin'] = $ads_pin; if (!$checkCEmail) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Confirm Email</b> not match!</div>"; } elseif (!$checkEmail) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Email</b> already exist!</div>"; } elseif ($checkUsername == 0) { $response_array['r'] = "false"; $response_array['msg'] = "<div>Please <b>Check Username</b> availability!<div>"; } elseif ($checkUsername == '-1') { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Username</b> not available! Please choose another username.<div>"; } elseif (!$validUplineSponsor) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Sponsor ID: {$sponsorId}</b> not related with <b>Upline ID: {$uplineId}</b>. Please make sure <b>Upline ID</b> is under correct <b>Sponsor ID</b> network.<div>"; } else { $link = BASE_PATH . 'join/verify?a=' . $data['activate_code'] . '&s=' . $data['username']; unset($data['cemail']); unset($data['chkusername']); // Insert into Database $this->db->insert("user_accounts", $data); // Generate Email BODY $html = file_get_contents(BASE_PATH . 'email_template/activation'); $html = htmlspecialchars($html); $html = str_replace('[USERNAME]', ucfirst($data['username']), $html); $html = str_replace('[ACTIVATION_CODE]', $link, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = SUPPORT_NAME; $mailer->AddAddress($data['email']); $mailer->IsHTML(true); $mailer->Subject = "Email verification to " . $data['email']; $mailer->Body = $body; if (!$mailer->Send()) { $response_array['r'] = "false"; $response_array['msg'] = "Mailer Error: " . $mailer->ErrorInfo; } else { $response_array['r'] = "true"; $response_array['msg'] = BASE_PATH . "mynetwork/addagent_success/" . $data['agent_id']; } } return $response_array; }
public function savePayment($data) { $response_array = array(); foreach ($data as $key => $value) { if ($value == "") { $data[$key] = NULL; } } $agent_id = $data['agent_id']; $data['from_acc'] = ucwords($data['from_acc']); $data['ref'] = ucwords($data['ref']); $dateTime = $data['payment_date'] . " " . $data['payment_time']; $dateNow = $data['date_submit']; $acc_type = $this->db->select("user_accounts", "acc_type", "agent_id = '{$agent_id}'", "fetch"); $acc_type = $acc_type['acc_type']; $ads_pin = $data['ads_pin']; if ($acc_type != "pb") { $pin_data = $this->db->select("user_accounts", "*", "agent_id = '{$ads_pin}'", "fetch"); $pin_acc_type = $pin_data['acc_type']; switch ($acc_type) { case "ep": $pinValid = $pin_acc_type == "admin" ? TRUE : FALSE; break; default: $hasReseller = $this->db->count("user_accounts", "payment = '2' AND (acc_type = 'ep' OR acc_type = 'ed') AND available_pin > '0'"); if ($hasReseller > 0) { $pinValid = $pin_acc_type == "admin" ? FALSE : TRUE; } else { $pinValid = $pin_acc_type == "admin" ? TRUE : FALSE; } break; } } else { $pinValid = TRUE; } if ($acc_type != "pb" and $ads_pin == NULL) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Advertisement Pin</b> cannot be empty.</div>"; } elseif (!$pinValid) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Advertisement Pin</b> not valid. Executive partner should use Administrator Pin.</div>"; } elseif ($data['payment_price'] > $data['amount']) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Amount</b> not enough.</div>"; } elseif ($dateTime > $dateNow) { $response_array['r'] = "false"; $response_array['msg'] = "<div><b>Payment Date</b> not valid.</div>"; } else { $data['payment_bal'] = $data['payment_price'] - $data['amount']; $paymentExist = user::checkExist("user_payment", "agent_id = '{$agent_id}' AND status = '0'"); if ($acc_type != "pb") { // Deduct Advertisement Pin from reseller $pin_owner = $this->db->select("user_accounts", "acc_type,available_pin", "agent_id = '{$ads_pin}'", "fetch"); if ($pin_owner['acc_type'] != 'admin' and $pin_owner['acc_type'] != 'md') { $pin_balance = $pin_owner['available_pin'] - 1; $data3['available_pin'] = $pin_balance; $this->db->update("user_accounts", $data3, "agent_id = '{$ads_pin}'"); } $data2['ads_pin'] = $data['ads_pin']; } $data2['payment'] = 1; // Update Advertisement Pin in user account $this->db->update("user_accounts", $data2, "agent_id = '{$agent_id}'"); unset($data['ads_pin']); // Insert into Database if (!$paymentExist) { $this->db->insert("user_payment", $data, "agent_id = '{$agent_id}'"); } else { $this->db->update("user_payment", $data, "agent_id = '{$agent_id}' AND status = '0'"); } // GENERATE EMAIL TO ADMIN $userdata = $this->db->select("user_accounts", "*", "agent_id = '{$agent_id}'", "fetch"); $site_setting = $this->db->select("site_settings", "*", "name = 'company_name'", "fetch"); $fullname = ucwords(strtolower($userdata['fullname'])); $agent_id = $data['agent_id']; $payment_for = $data['payment_for']; $date_time = $data['payment_date'] . " " . $data['payment_time']; $date_time = date("d M Y / H:i:s", strtotime($date_time)); $from_acc = strtoupper($data['from_acc']); $to_acc = user::getBanks($data['to_acc'], "fetch"); $to_acc = strtoupper($to_acc['code']) . " [" . $site_setting['param'] . "] - " . $to_acc['acc_no']; $pay_method = user::getPaymentMethod($data['payment_type'], "fetch"); $pay_method = $pay_method['pay_method']; $ref = $data['ref'] != NULL ? $data['ref'] : "-"; $amount = "RM" . number_format($data['amount']); // Generate Email BODY $html = file_get_contents(BASE_PATH . 'email_template/payment_received'); $html = htmlspecialchars($html); $html = str_replace('[FULLNAME]', $fullname, $html); $html = str_replace('[AGENT_ID]', $agent_id, $html); $html = str_replace('[PAYMENT_FOR]', $payment_for, $html); $html = str_replace('[DATE_TIME]', $date_time, $html); $html = str_replace('[FROM_ACC]', $from_acc, $html); $html = str_replace('[TO_ACC]', $to_acc, $html); $html = str_replace('[PAYMENT_TYPE]', $pay_method, $html); $html = str_replace('[REF]', $ref, $html); $html = str_replace('[AMOUNT]', $amount, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = SUPPORT_NAME; $mailer->AddAddress(FINANCE_EMAIL); $mailer->IsHTML(true); $mailer->Subject = "NEW Payment Received [" . $fullname . "]"; $mailer->Body = $body; $mailer->Send(); // Response $response_array['r'] = "true"; $response_array['msg'] = BASE_PATH . "setup/complete"; } return $response_array; }
public function payment_review_exec($data) { $response_array = array(); $data['auth_datetime'] = date("Y-m-d H:i:s"); $agent_id = $data['agent_id']; $payment_id = $data['id']; $userdata = user::getUserData("agent_id", $agent_id); foreach ($data as $key => $value) { if ($value == "") { $data[$key] = NULL; } } // Update Payment Data $payment_data['id'] = $payment_id; $payment_data['agent_id'] = $agent_id; $payment_data['status'] = $data['status']; $payment_data['auth_datetime'] = $data['auth_datetime']; $payment_data['remarks'] = $data['remarks']; $this->db->update("user_payment", $payment_data, "id = {$payment_id} and agent_id = {$agent_id}"); // Update Agent Payment Status $pin_id = $data['ads_pin']; switch ($data['status']) { case "1": $agent_payment['payment'] = 1; break; case "2": $agent_payment['payment'] = 2; break; default: $pin_owner = $this->db->select("user_accounts", "available_pin, acc_type", "agent_id = '{$pin_id}'", "fetch"); if ($pin_owner['acc_type'] != 'admin' and $pin_owner['acc_type'] != 'md') { $pin_data['available_pin'] = $pin_owner['available_pin'] + 1; $this->db->update("user_accounts", $pin_data, "agent_id = '{$pin_id}'"); } $agent_payment['payment'] = 0; break; } $this->db->update("user_accounts", $agent_payment, "agent_id = {$agent_id}"); // Generate commission if ($data['status'] == 2) { $commData = array(); $commData['agent_id'] = $data['agent_id']; $commData['acc_type'] = $userdata['acc_type']; $commData['date'] = $userdata['dt_join']; commission::generatePDICommission($commData); commission::generateGDICommission($commData); commission::generateGAICommission($commData); commission::generateAPRCommission($commData); } // Generate Email To Agent $redirectLink = BASE_PATH . "management/payment"; if ($data['status'] == 2) { $payment_details = $this->db->select("user_payment", "id, agent_id, amount, payment_type, payment_for", "id = '{$payment_id}'", "fetch"); $username = ucwords($userdata['username']); $fullname = ucwords(strtolower($userdata['fullname'])); $email = $userdata['email']; $mobile = $userdata['mobile']; $order_no = $payment_details['id'] . "-" . $payment_details['agent_id']; $amount = "RM" . number_format($payment_details['amount']); $pay_method = user::getPaymentMethod($payment_details['payment_type'], "fetch"); $pay_method = $pay_method['pay_method']; $auth_datetime = date("d M Y / H:i:s", strtotime($data['auth_datetime'])); $payment_for = $payment_details['payment_for']; // Generate Email BODY $html = file_get_contents(BASE_PATH . 'email_template/payment_complete'); $html = htmlspecialchars($html); $html = str_replace('[USERNAME]', $username, $html); $html = str_replace('[FULLNAME]', $fullname, $html); $html = str_replace('[EMAIL]', $email, $html); $html = str_replace('[MOBILE]', $mobile, $html); $html = str_replace('[ORDER_NO]', $order_no, $html); $html = str_replace('[AMOUNT]', $amount, $html); $html = str_replace('[PAY_METHOD]', $pay_method, $html); $html = str_replace('[AUTH_DATETIME]', $auth_datetime, $html); $html = str_replace('[PAYMENT_FOR]', $payment_for, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = SUPPORT_NAME; $mailer->AddAddress($email); $mailer->IsHTML(true); $mailer->Subject = "Payment has been approved [" . $order_no . "]"; $mailer->Body = $body; $mailer->Send(); $response_array['r'] = "true"; $response_array['msg'] = $redirectLink; } return $response_array; }
public function addNew_exec($data) { $response_array = array(); $data['agent_id'] = session::get(AGENT_SESSION_NAME); $data['comp_name'] = ucwords($data['comp_name']); $data['comp_reg_no'] = ucfirst($data['comp_reg_no']); $data['comp_address'] = ucwords($data['comp_address']); if ($data['comp_state'] == "oth") { $data['comp_state'] = $data['state_other']; } unset($data['state_other']); $data['website'] = strtolower($data['website']); $data['tag'] = strtolower($data['tag']); $data['p_fullname'] = ucwords(strtolower($data['p_fullname'])); $data['p_pos'] = ucwords(strtolower($data['p_pos'])); $agent_id = $data['agent_id']; for ($x = 1; $x <= 5; $x++) { $userID = $this->db->select("user_accounts", "sponsor_id", "agent_id = {$agent_id}", "fetch"); $agent_id = $userID['sponsor_id']; $data['lv' . $x] = $agent_id; } // Generate Confirmation Code $supplier = new user(); $data['confcode'] = $supplier->generateActivationCode($data['comp_email']); foreach ($data as $key => $value) { if ($value == "") { $data[$key] = NULL; } } $insert = $this->db->insert("supplier", $data); if (!$insert) { $response_array['r'] = "false"; $response_array['msg'] = "Oopps! Looks like there is some technical error while process your supplier registration. Please re-submit the form or refresh your browser."; } else { // Generate Email BODY $link = BASE_PATH . 'supp/verify?a=' . $data['confcode'] . '&s=' . $data['username']; $html = file_get_contents(BASE_PATH . 'email_template/supplier_activation'); $html = htmlspecialchars($html); $html = str_replace('[USERNAME]', $data['username'], $html); $html = str_replace('[ACTIVATION_CODE]', $link, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = WYW_SUPPORT_NAME; $mailer->AddAddress($data['comp_email']); $mailer->IsHTML(true); $mailer->Subject = "Email verification to " . $data['comp_email'] . " for Free Supplier registration."; $mailer->Body = $body; $send = $mailer->Send(); if (!$send) { $response_array['r'] = "false"; $response_array['msg'] = "Mailer Error: " . $mailer->ErrorInfo; } else { $response_array['r'] = "true"; $response_array['msg'] = BASE_PATH . "supplier?r=success&t=addnew&a=" . $data['comp_name']; } } return $response_array; }
function resend_details($email = FALSE) { if (!$email) { return FALSE; } else { // Email temporary password $data = user::getUserData('email', $email); $sponsorData = user::getUserData('agent_id', $data['sponsor_id']); $sponsor_fullname = $sponsorData['fullname']; if ($sponsorData['wyw_email'] != NULL) { $sponsor_email = $sponsorData['wyw_email'] . '@whatyouwant.my1'; } else { $sponsor_email = $sponsorData['email']; } $sponsor_mobile = $sponsorData['mobile']; $company_name = $this->db->select("site_settings", "*", "name = 'company_name'", "fetch"); $company_name = $company_name['param']; $agent_id = $data['agent_id']; $acc_type_code = $data['acc_type']; $acc_type_detail = user::getAccType($acc_type_code); $acc_type = $acc_type_detail['label']; $acc_price = number_format($acc_type_detail['price']); $agent_fullname = ucwords(strtolower($data['fullname'])); $agent_username = $data['username']; $agent_tmp_password = $data['tmp_password']; $support_email = SUPPORT_EMAIL; // Generate email body $html = file_get_contents(BASE_PATH . 'email_template/activation_success'); $html = htmlspecialchars($html); $html = str_replace('[AGENT_ID]', $agent_id, $html); $html = str_replace('[ACC_TYPE]', $acc_type, $html); $html = str_replace('[ACC_PRICE]', $acc_price, $html); $html = str_replace('[FULLNAME]', $agent_fullname, $html); $html = str_replace('[USERNAME]', $agent_username, $html); $html = str_replace('[TMP_PASSWORD]', $agent_tmp_password, $html); $html = str_replace('[SPONSOR_FULLNAME]', $sponsor_fullname, $html); $html = str_replace('[SPONSOR_EMAIL]', $sponsor_email, $html); $html = str_replace('[SPONSOR_MOBILE]', $sponsor_mobile, $html); $html = str_replace('[SUPPORT_EMAIL]', $support_email, $html); $html = str_replace('[COMPANY_NAME]', $company_name, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = SUPPORT_NAME; $mailer->AddAddress($data['email']); $mailer->IsHTML(true); $mailer->Subject = "Welcome to 1STG Entrepreneurship Program."; $mailer->Body = $body; return $mailer->Send(); } }
function resend_activation($data = FALSE) { if (!$data) { return FALSE; } else { $link = BASE_PATH . 'supp/verify?a=' . $data['confcode'] . '&s=' . $data['username']; // Generate Email BODY $html = file_get_contents(BASE_PATH . 'email_template/supplier_activation'); $html = htmlspecialchars($html); $html = str_replace('[USERNAME]', $data['username'], $html); $html = str_replace('[ACTIVATION_CODE]', $link, $html); $html = html_entity_decode($html); $body = $html; // Send Email $mailer = new mailer(); $mailer->IsSMTP(); // set mailer to use SMTP $mailer->Port = EMAIL_PORT; $mailer->Host = EMAIL_HOST; // specify main and backup server $mailer->SMTPAuth = true; // turn on SMTP authentication $mailer->Username = NOREPLY_EMAIL; // SMTP username $mailer->Password = NOREPLY_PASS; // SMTP password $mailer->From = NOREPLY_EMAIL; $mailer->FromName = WYW_SUPPORT_NAME; $mailer->AddAddress($data['comp_email']); $mailer->IsHTML(true); $mailer->Subject = "Email verification to " . $data['comp_email'] . " for Free Supplier registration."; $mailer->Body = $body; return $mailer->Send(); } }
function sendMail($address, $name, $subject, $message) { global $config; if ($config['allowemails']) { // instantiate the class $mail = new mailer(); // Set the subject $mail->Subject = $subject; // Body $mail->Body = str_replace(array("<br", "<br />"), "\r\n", $message); // Add an address to send to. $mail->AddAddress($address, $name); $mail->Send(); $mail->ClearAddresses(); $mail->ClearAttachments(); } }