Skip to content

Instantly share code, notes, and snippets.

@ssdwho
Created February 23, 2020 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssdwho/365ca6dcad75794f848c528c734b80fb to your computer and use it in GitHub Desktop.
Save ssdwho/365ca6dcad75794f848c528c734b80fb to your computer and use it in GitHub Desktop.
Opencart 3.x - NetGSM iyzico ödeme sonrası SMS ayarı
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Netgsm</name>
<code>netgsm_opencart_module</code>
<version>2.0.0</version>
<author>Netgsm</author>
<link>https://www.netgsm.com.tr</link>
<!-- start file operation -->
<file path="admin/controller/common/column_left.php">
<operation>
<search><![CDATA[if ($marketplace) {]]></search>
<add position="before"><![CDATA[ $marketplace[] = array(
'name' => $this->language->get('<img style="margin-bottom:3px" src="view/image/netgsm/netgsm-icon.png" width="16" height="16"> Netgsm'),
'href' => $this->url->link('extension/module/netgsm', 'user_token=' . $this->session->data['user_token'], true),
'children' => array()
);]]></add>
</operation>
</file>
<file path="catalog/controller/account/register.php">
<operation>
<search><![CDATA[$this->customer->login($this->request->post['email'], $this->request->post['password']);]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if($netgsm_ayarlari['netgsm_status']==1){
if(isset($netgsm_ayarlari['netgsm_newuser_to_customer_control']) and $netgsm_ayarlari['netgsm_newuser_to_customer_control']==1 and $netgsm_ayarlari['netgsm_newuser_to_customer_text']!=''){
$mesaj = str_replace(array('[uye_adi]','[uye_soyadi]','[uye_telefonu]','[uye_epostasi]','[uye_sifresi]'),array($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$this->request->post['email'],$this->request->post['password']),$netgsm_ayarlari['netgsm_newuser_to_customer_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($this->request->post['telephone'],$mesaj);
}
}
if(isset($netgsm_ayarlari['netgsm_newuser_to_admin_control']) and $netgsm_ayarlari['netgsm_newuser_to_admin_control']==1 and $netgsm_ayarlari['netgsm_newuser_to_admin_text']!=''){
$mesaj = str_replace(array('[uye_adi]','[uye_soyadi]','[uye_telefonu]','[uye_epostasi]','[uye_sifresi]'),array($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$this->request->post['email'],$this->request->post['password']),$netgsm_ayarlari['netgsm_newuser_to_admin_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($netgsm_ayarlari['netgsm_newuser_to_admin_no'],$mesaj);
}
if($netgsm_ayarlari['netgsm_status']==1){
if(isset($netgsm_ayarlari['netgsm_rehber_control']) and $netgsm_ayarlari['netgsm_rehber_control']==1 and $netgsm_ayarlari['netgsm_rehber_groupname']!=''){
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$grubakaydet = $netgsmsms->grubakaydet($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$netgsm_ayarlari['netgsm_rehber_groupname']);
}
}
]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/register.php">
<operation>
<search><![CDATA[$this->customer->login($this->request->post['email'], $this->request->post['password']);]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if($netgsm_ayarlari['netgsm_status']==1){
if(isset($netgsm_ayarlari['netgsm_newuser_to_customer_control']) and $netgsm_ayarlari['netgsm_newuser_to_customer_control']==1 and $netgsm_ayarlari['netgsm_newuser_to_customer_text']!=''){
$mesaj = str_replace(array('[uye_adi]','[uye_soyadi]','[uye_telefonu]','[uye_epostasi]','[uye_sifresi]'),array($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$this->request->post['email'],$this->request->post['password']),$netgsm_ayarlari['netgsm_newuser_to_customer_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($this->request->post['telephone'],$mesaj);
}
}
if(isset($netgsm_ayarlari['netgsm_newuser_to_admin_control']) and $netgsm_ayarlari['netgsm_newuser_to_admin_control']==1 and $netgsm_ayarlari['netgsm_newuser_to_admin_text']!=''){
$mesaj = str_replace(array('[uye_adi]','[uye_soyadi]','[uye_telefonu]','[uye_epostasi]','[uye_sifresi]'),array($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$this->request->post['email'],$this->request->post['password']),$netgsm_ayarlari['netgsm_newuser_to_admin_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($netgsm_ayarlari['netgsm_newuser_to_admin_no'],$mesaj);
}
if($netgsm_ayarlari['netgsm_status']==1){
if(isset($netgsm_ayarlari['netgsm_rehber_control']) and $netgsm_ayarlari['netgsm_rehber_control']==1 and $netgsm_ayarlari['netgsm_rehber_groupname']!=''){
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$grubakaydet = $netgsmsms->grubakaydet($this->request->post['firstname'],$this->request->post['lastname'],$this->request->post['telephone'],$netgsm_ayarlari['netgsm_rehber_groupname']);
}
}
]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/success.php">
<operation>
<search><![CDATA[$this->cart->clear();]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
$this->load->model('account/order');
$urunler = $this->model_account_order->getOrderProducts($this->session->data['order_id']);
$urun_adlari = "";
$urun_kodlari = "";
$urun_adetleri = "";
foreach ($urunler as $key => $value) {
if ($key==0){ $ayrac = ''; }else{ $ayrac = ','; }
$urun_adlari .= $ayrac.$value['name'];
$urun_kodlari .= $ayrac.$value['model'];
$urun_adetleri .= $ayrac.$value['quantity'];
}
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_neworder_to_admin_control']) and $netgsm_ayarlari['netgsm_neworder_to_admin_control']==1 and $netgsm_ayarlari['netgsm_neworder_to_admin_text']!=''){
$mesaj = str_replace(array('[siparis_no]','[urun_adlari]','[urun_kodlari]','[urun_adetleri]'),array($this->session->data['order_id'],$urun_adlari,$urun_kodlari,$urun_adetleri),$netgsm_ayarlari['netgsm_neworder_to_admin_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($netgsm_ayarlari['netgsm_neworder_to_admin_no'],$mesaj);
}
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_neworder_to_customer_control']) and $netgsm_ayarlari['netgsm_neworder_to_customer_control']==1 and $netgsm_ayarlari['netgsm_neworder_to_customer_text']!=''){
$this->load->model('account/customer');
if ($this->customer->isLogged()) {
$customer_info = $this->model_account_customer->getCustomer($this->session->data['customer_id']);
$telefon = $customer_info['telephone'];
} else {
$telefon = $this->session->data['guest']['telephone'];
}
$mesaj = str_replace(array('[siparis_no]','[urun_adlari]','[urun_kodlari]','[urun_adetleri]'),array($this->session->data['order_id'],$urun_adlari,$urun_kodlari,$urun_adetleri),$netgsm_ayarlari['netgsm_neworder_to_customer_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($telefon,$mesaj);
}
]]></add>
</operation>
</file>
<file path="catalog/controller/extension/payment/iyzico.php">
<operation>
<search><![CDATA[$this->cart->clear();]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
$this->load->model('account/order');
$urunler = $this->model_account_order->getOrderProducts($this->session->data['order_id']);
$urun_adlari = "";
$urun_kodlari = "";
$urun_adetleri = "";
foreach ($urunler as $key => $value) {
if ($key==0){ $ayrac = ''; }else{ $ayrac = ','; }
$urun_adlari .= $ayrac.$value['name'];
$urun_kodlari .= $ayrac.$value['model'];
$urun_adetleri .= $ayrac.$value['quantity'];
}
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_neworder_to_admin_control']) and $netgsm_ayarlari['netgsm_neworder_to_admin_control']==1 and $netgsm_ayarlari['netgsm_neworder_to_admin_text']!=''){
$mesaj = str_replace(array('[siparis_no]','[urun_adlari]','[urun_kodlari]','[urun_adetleri]'),array($this->session->data['order_id'],$urun_adlari,$urun_kodlari,$urun_adetleri),$netgsm_ayarlari['netgsm_neworder_to_admin_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($netgsm_ayarlari['netgsm_neworder_to_admin_no'],$mesaj);
}
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_neworder_to_customer_control']) and $netgsm_ayarlari['netgsm_neworder_to_customer_control']==1 and $netgsm_ayarlari['netgsm_neworder_to_customer_text']!=''){
$this->load->model('account/customer');
if ($this->customer->isLogged()) {
$customer_info = $this->model_account_customer->getCustomer($this->session->data['customer_id']);
$telefon = $customer_info['telephone'];
} else {
$telefon = $this->session->data['guest']['telephone'];
}
$mesaj = str_replace(array('[siparis_no]','[urun_adlari]','[urun_kodlari]','[urun_adetleri]'),array($this->session->data['order_id'],$urun_adlari,$urun_kodlari,$urun_adetleri),$netgsm_ayarlari['netgsm_neworder_to_customer_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($telefon,$mesaj);
}
]]></add>
</operation>
</file>
<file path="catalog/controller/api/order.php">
<operation>
<search><![CDATA[$this->model_checkout_order->addOrderHistory($order_id, $this->request->post['order_status_id'], $this->request->post['comment'], $this->request->post['notify'], $this->request->post['override']);]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_orderstatus_change_customer_control']) and $netgsm_ayarlari['netgsm_orderstatus_change_customer_control']==1){
$mesajsor = 'netgsm_order_status_text_'.$this->request->post['order_status_id'];
if(isset($netgsm_ayarlari[$mesajsor]) and $netgsm_ayarlari[$mesajsor]!=''){
$aciklama = strip_tags(html_entity_decode($this->request->post['comment']));
$mesaj = str_replace(
[
'[uye_adi]',
'[uye_soyadi]',
'[siparis_no]',
'[aciklama]',
'[uye_telefonu]',
'[uye_epostasi]',
'[toplam_tutar]',
'[ip_adresi]'
],
[
$order_info['firstname'],
$order_info['lastname'],
$this->request->get['order_id'],
$aciklama,
$order_info['telephone'],
$order_info['email'],
number_format((float)$order_info['total'], 2, '.', ''),
$order_info['ip']
], $netgsm_ayarlari[$mesajsor]);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($order_info['telephone'],$mesaj);
}
}
]]></add>
</operation>
</file>
<file path="catalog/controller/account/return.php">
<operation>
<search><![CDATA[$this->response->redirect($this->url->link('account/return/success', '', true));]]></search>
<add position="before"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if($netgsm_ayarlari['netgsm_status']==1 and isset($netgsm_ayarlari['netgsm_order_refund_to_admin_control']) and $netgsm_ayarlari['netgsm_order_refund_to_admin_control']==1 and $netgsm_ayarlari['netgsm_order_refund_to_admin_text']!=''){
$return_id = $this->model_account_return->addReturn($this->request->post);
$siparis = $this->model_account_return->getReturn($return_id);
$mesaj = str_replace(array('[siparis_no]','[uye_adi]','[uye_soyadi]','[uye_telefonu]','[uye_epostasi]','[urun]','[iade_nedeni]','[aciklama]'),
array($siparis['order_id'],$siparis['firstname'],$siparis['lastname'],$siparis['telephone'],$siparis['email'],$siparis['product'],$siparis['reason'],$siparis['comment']),
$netgsm_ayarlari['netgsm_order_refund_to_admin_text']);
$netgsmsms = new Netgsmsms($netgsm_ayarlari['netgsm_user'],$netgsm_ayarlari['netgsm_pass'],$netgsm_ayarlari['netgsm_input_smstitle'], $netgsm_ayarlari['netgsm_turkishChar']);
$smsgonder = $netgsmsms->sendSMS($netgsm_ayarlari['netgsm_order_refund_to_admin_no'],$mesaj);
}
]]></add>
</operation>
</file>
<file path="admin/view/template/sale/order_list.twig">
<operation>
<search><![CDATA[id="button-shipping"]]></search>
<add position="before"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<button id="netgsm-sms" data-smstype="2" data-token="{{ user_token }}" data-toggle="tooltip" title="Netgsm SMS Gönder" class="btn btn-success ladda-button" data-style="zoom-in"><i class="fa fa-comments-o"></i></button>
{% endif %}
]]>
</add>
</operation>
<operation>
<search><![CDATA[<td class="text-right">{{ column_action }}</td>]]></search>
<add position="after"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<td style="display:none">Telefon</td>
{% endif %}
]]>
</add>
</operation>
<operation>
<search><![CDATA[</div></td>]]></search>
<add position="after"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<td style="display:none" id="td[{{ order.order_id}}]">{{ order.telephone }}</td>
{% endif %}
]]>
</add>
</operation>
</file>
<file path="admin/controller/sale/order.php">
<operation>
<search><![CDATA[foreach ($results as $result) {]]></search>
<add position="after"><![CDATA[
if (isset($result['order_id'])) {
$order_info = $this->model_sale_order->getOrder($result['order_id']);
}
]]>
</add>
</operation>
<operation>
<search><![CDATA['shipping_code' => $result['shipping_code'],]]></search>
<add position="after"><![CDATA[
'telephone' => $order_info['telephone'],
]]>
</add>
</operation>
</file>
<file path="admin/controller/sale/order.php">
<operation>
<search><![CDATA[protected function getList() {]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if(isset($netgsm_ayarlari['netgsm_status']))
{
$data['netgsm_status']= $netgsm_ayarlari['netgsm_status'];
if($netgsm_ayarlari['netgsm_status']==1){
//sweetalert
$this->document->addStyle('view/stylesheet/netgsm/netgsmstyle.css');
$this->document->addStyle('view/javascript/netgsm/lib/sweetalert2/dist/sweetalert2.css');
$this->document->addScript('view/javascript/netgsm/lib/sweetalert2/dist/sweetalert2.all.min.js');
//netgsmsms
$this->document->addScript('view/javascript/netgsm/sendsms.js');
}
}
else
{
$data['netgsm_status']=0;
}
]]></add>
</operation>
</file>
<!-- customer bulk -->
<file path="admin/controller/customer/customer.php">
<operation>
<search><![CDATA[protected function getList() {]]></search>
<add position="after"><![CDATA[
$this->load->model('setting/setting');
$netgsm_ayarlari = $this->model_setting_setting->getSetting('netgsm');
if(isset($netgsm_ayarlari['netgsm_status']))
{
$data['netgsm_status']= $netgsm_ayarlari['netgsm_status'];
if($netgsm_ayarlari['netgsm_status']==1){
//sweetalert
$this->document->addStyle('view/stylesheet/netgsm/netgsmstyle.css');
$this->document->addStyle('view/javascript/netgsm/lib/sweetalert2/dist/sweetalert2.css');
$this->document->addScript('view/javascript/netgsm/lib/sweetalert2/dist/sweetalert2.all.min.js');
//netgsmsms
$this->document->addScript('view/javascript/netgsm/sendsms.js');
}
}
else
{
$data['netgsm_status']=0;
}
]]></add>
</operation>
<operation>
<search><![CDATA['customer_group' => $result['customer_group'],]]></search>
<add position="after"><![CDATA[
'telephone' => $result['telephone'],
]]>
</add>
</operation>
</file>
<file path="admin/view/template/customer/customer_list.twig">
<operation>
<search><![CDATA[onclick="$('#filter-customer')]]></search>
<add position="before"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<button id="netgsm-sms" data-smstype="1" data-token="{{ user_token }}" data-toggle="tooltip" title="Netgsm SMS Gönder" class="btn btn-success ladda-button" data-style="zoom-in"><i class="fa fa-comments-o"></i></button>
{% endif %}
]]>
</add>
</operation>
<operation>
<search><![CDATA[<td class="text-left">{% if sort == 'c.date_added' %}<a href="{{ sort_date_added }}" class="{{ order|lower }}">{{ column_date_added }}</a>{% else %}<a href="{{ sort_date_added }}">{{ column_date_added }}</a>{% endif %}</td>]]></search>
<add position="after"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<td style="display:none">Telefon</td>
{% endif %}
]]>
</add>
</operation>
<operation>
<search><![CDATA[<td class="text-left">{{ customer.date_added }}</td>]]></search>
<add position="after"><![CDATA[
{% if netgsm_status and netgsm_status== 1 %}
<td style="display:none" id="td[{{ customer.customer_id }}]">{{ customer.telephone }}</td>
{% endif %}
]]>
</add>
</operation>
</file>
<file path="catalog/controller/api/order.php">
<operation>
<search><![CDATA[class ControllerApiOrder extends Controller {]]></search>
<add position="after"><![CDATA[
private $appkeyforNetgsm = 'GhTrv-43gtIOnQw-4237F';
private $error_permission = 'Uyarı: API erişimine sahip değilsiniz!';
private $error_appkey = 'Uyarı: Bu method sadece Netgsm tarafından kullanılabilir!';
public function getOrderbyCustomer() {
$json = array();
$warning = false;
if(!isset($this->request->post['netgsm_appkey']) || $this->request->post['netgsm_appkey'] != $this->appkeyforNetgsm){
$warning = true;
}
$sorttype = 'order_id';
$sort = 'asc';
$telephone = '';
if(isset($this->request->post['telephone'])){
$telephone = $this->request->post['telephone'];
}
if(isset($this->request->post['sorttype'])){
$sorttype = $this->request->post['sorttype'];
}
if (isset($this->request->post['sort'])){
$sort = $this->request->post['sort'];
}
if (!isset($this->session->data['api_id'])) {
$json['error']['warning'] = $this->error_permission;
} else if($warning == true){
$json['error']['warning'] = $this->error_appkey;
} else {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order as o where o.telephone like '%".$telephone."%' ORDER BY ".$sorttype." ".$sort." limit 3");
$json['success']['orders'] = $query->rows;
$json['success']['num_rows'] = $query->num_rows;
$json['success']['version'] = VERSION;
}
if (isset($this->request->server['HTTP_ORIGIN'])) {
$this->response->addHeader('Access-Control-Allow-Origin: ' . $this->request->server['HTTP_ORIGIN']);
$this->response->addHeader('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
$this->response->addHeader('Access-Control-Max-Age: 1000');
$this->response->addHeader('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function getOrders() {
$json = array();
$warning = false;
if(!isset($this->request->post['netgsm_appkey']) || $this->request->post['netgsm_appkey'] != $this->appkeyforNetgsm){
$warning = true;
}
$addSQL = '';
if (isset($this->request->post['id'])){
$order_id = $this->request->post['id'];
$addSQL = " WHERE order_id = '" . (int)$order_id . "' ";
}
if (!isset($this->session->data['api_id'])) {
$json['error']['warning'] = $this->error_permission;
} else if($warning == true){
$json['error']['warning'] = $this->error_appkey;
} else {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order ".$addSQL. " limit 1");
$json['success']['orders'] = $query->row;
$json['success']['num_rows'] = $query->num_rows;
$json['success']['version'] = VERSION;
}
if (isset($this->request->server['HTTP_ORIGIN'])) {
$this->response->addHeader('Access-Control-Allow-Origin: ' . $this->request->server['HTTP_ORIGIN']);
$this->response->addHeader('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
$this->response->addHeader('Access-Control-Max-Age: 1000');
$this->response->addHeader('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function getOrderStatus() {
$json = array();
$warning = false;
if(!isset($this->request->post['netgsm_appkey']) || $this->request->post['netgsm_appkey'] != $this->appkeyforNetgsm){
$warning = true;
}
$order_status_id = '1';
if (isset($this->request->post['id'])){
$order_status_id = $this->request->post['id'];
}
if (!isset($this->session->data['api_id'])) {
$json['error']['warning'] = $this->error_permission;
} else if($warning == true){
$json['error']['warning'] = $this->error_appkey;
} else {
// load model
$this->load->model('account/order');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "'");
$json['success']['orderstatus'] = $query->row;
$json['success']['num_rows'] = $query->num_rows;
$json['success']['version'] = VERSION;
}
if (isset($this->request->server['HTTP_ORIGIN'])) {
$this->response->addHeader('Access-Control-Allow-Origin: ' . $this->request->server['HTTP_ORIGIN']);
$this->response->addHeader('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
$this->response->addHeader('Access-Control-Max-Age: 1000');
$this->response->addHeader('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function getCustomer()
{
$json = array();
$warning = false;
if(!isset($this->request->post['netgsm_appkey']) || $this->request->post['netgsm_appkey'] != $this->appkeyforNetgsm){
$warning = true;
}
$telephone = '';
$error['telephone'] = false;
if(isset($this->request->post['telephone'])){
$telephone = $this->request->post['telephone'];
} else {
$error['telephone'] = true;
}
if (!isset($this->session->data['api_id'])) {
$json['error']['warning'] = $this->error_permission;
} else if($warning == true){
$json['error']['warning'] = $this->error_appkey;
} else {
$this->load->model('account/order');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer as o where o.telephone like '%".$telephone."%' order by date_added desc limit 3");
if ($error['telephone'] == true){
$json['error']['warning'] = 'Telefon numarası gelmedi!';
} else {
// Clear password and salt password
if (intval($query->num_rows) > 0){
foreach ($query->rows as &$item) {
if (isset($item['password'])){
unset($item['password']);
unset($item['salt']);
}
}
}
$json['success']['customer'] = $query->rows;
$json['success']['num_rows'] = $query->num_rows;
$json['success']['version'] = VERSION;
}
}
if (isset($this->request->server['HTTP_ORIGIN'])) {
$this->response->addHeader('Access-Control-Allow-Origin: ' . $this->request->server['HTTP_ORIGIN']);
$this->response->addHeader('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
$this->response->addHeader('Access-Control-Max-Age: 1000');
$this->response->addHeader('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
]]>
</add>
</operation>
</file>
<file path="catalog/model/account/api.php">
<operation>
<search><![CDATA[$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE `username` = '" . $this->db->escape($username) . "' `key` = '" . $this->db->escape($key) . "' AND status = '1'");]]></search>
<add position="replace"><![CDATA[
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE `username` = '" . $this->db->escape($username) . "' AND `key` = '" . $this->db->escape($key) . "' AND status = '1'");
]]>
</add>
</operation>
</file>
<file path="catalog/controller/api/login.php">
<operation>
<search><![CDATA[$session = new Session($config->get('session_engine'), $registry);]]></search>
<add position="replace"><![CDATA[
$session = new Session($this->config->get('session_engine'), $this->registry);
]]>
</add>
</operation>
</file>
<!-- end file operation -->
</modification>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment