📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv9.demodesign.com.tr
/
includes
/
shop
📝
helper.php
← Geri Dön
<?php function m_comment_name_hide($data) { $names = explode(' ',$data); $lastname = mb_substr(end($names),0,1,'UTF-8'); return $names[0].'.'.$lastname; } function isValid($secret, $response, $remote) { try { $url = 'https://www.google.com/recaptcha/api/siteverify'; $data = ['secret' => $secret, 'response' => $response, 'remoteip' => $remote]; $options = [ 'http' => [ 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ] ]; $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return json_decode($result)->success; } catch (Exception $e) { return null; } } function m_category_extract($data,$type=false) { $db = new DB(); $return = ''; preg_match_all('#\[(.*?)\]#si',$data,$categories); foreach($categories[1] as $c_id) { $c_data = $db->table('categories')->where('id','=',$c_id)->get(); $c_title = $c_data['data'][0]['title']; $c_sef = $c_data['data'][0]['sef']; if($type=='text') { $return.= ''.$c_title.' / '; } else { $return.= '<a href="'.m_permalink('category',$c_sef).'" title="'.$c_title.'">'.$c_title.'</a> <span></span> '; } } $return = trim($return); $return = rtrim($return,'<span></span>'); $return = rtrim($return,'/'); $return = trim($return); return $return; } function xml2array ( $xmlObject, $out = array () ) { foreach ( (array) $xmlObject as $index => $node ) $out[$index] = ( is_object ( $node ) ) ? xml2array ( $node ) : $node; return $out; } function m_variant_extract($id) { $db = new DB(); $return = ''; $variants = $db->table('product_variants')->where('p_id','=',$id)->get(); foreach($variants['data'] as $variant) { $return.= ''.$variant['title'].':'.$variant['content'].' / '; } $return = trim($return); $return = trim($return,'/'); $return = trim($return); return $return; } function m_ticket_status($status) { switch($status) { case '0': return '<span class="badge bg-warning">'.LG_WAIT_RESPONSE_TICKETS.'</span>'; break; case '1': return '<span class="badge bg-success">'.LG_ANSWERED_TICKETS.'</span>'; break; case '2': return '<span class="badge bg-danger">'.LG_CLOSED.'</span>'; break; } } function m_payment_type($data=false) { if($data) { switch($data) { case '1': return '<span>'.LG_BANK_PAYMENT.'</span>'; break; case '2': return '<span>'.LG_CREDIT_CARD_PAYMENT.'</span>'; break; case '3': return '<span>'.LG_DOOR_PAYMENT.'</span>'; break; } } else { $payment_types = array(); $payment_types[1]['id'] = 1; $payment_types[1]['value'] = LG_BANK_PAYMENT; $payment_types[2]['id'] = 2; $payment_types[2]['value'] = LG_CREDIT_CARD_PAYMENT; $payment_types[3]['id'] = 3; $payment_types[3]['value'] = LG_DOOR_PAYMENT; return $payment_types; } } function m_order_status($status) { switch($status) { case '0': return '<span class="badge bg-warning">'.LG_ORDERS_PENDING_APPROVAL.'</span>'; break; case '1': return '<span class="badge bg-info">'.LG_ORDERS_PENDING_PAYMENT.'</span>'; break; case '2': return '<span class="badge bg-success">'.LG_ORDERS_PREPARE.'</span>'; break; case '3': return '<span class="badge bg-success">'.LG_ORDERS_SHIPPED.'</span>'; break; case '4': return '<span class="badge bg-success">'.LG_ORDERS_DELIVERED.'</span>'; break; case '5': return '<span class="badge bg-warning">'.LG_ORDERS_REFUND.'</span>'; break; case '6': return '<span class="badge bg-danger">'.LG_ORDERS_CANCELED.'</span>'; break; } } function m_sef_unique($table,$sef) { $db = new DB(); $sef_count = $db->table($table)->where('sef','=',$sef)->count(); if($sef_count>1) { $sef_count+1; return $sef.'-'.$sef_count; } else { return $sef; } } function currency_types($id=false,$data=false) { $currency_types = array(); $currency_types[1]['id'] = 1; $currency_types[1]['title'] = '₺ - Türk Lirası'; $currency_types[1]['value'] = 'TL'; $currency_types[1]['global_value'] = 'TRY'; $currency_types[2]['id'] = 2; $currency_types[2]['title'] = '$ - USD'; $currency_types[2]['value'] = '$'; $currency_types[2]['global_value'] = 'USD'; $currency_types[3]['id'] = 3; $currency_types[3]['title'] = '€ - Euro'; $currency_types[3]['value'] = '€'; $currency_types[3]['global_value'] = 'Euro'; $currency_types[4]['id'] = 4; $currency_types[4]['title'] = '£ - Sterlin'; $currency_types[4]['value'] = '£'; $currency_types[4]['global_value'] = 'GBP'; if($id) { return $currency_types[$id][$data]; } else { return $currency_types; } } function null_to_zero($data) { if(trim($data)=='') { return 0; } else { return $data; } } function m_remove_dot($data) { return str_replace('.','',$data); } function cart_control($id,$list=true) { if($list) { if($_SESSION['cart'][$id]['added']=='') { return '<a class="add add_cart addcart" href="javascript:void(0);" rel="'.$id.'" data-type="list">Sepete Ekle</a>'; } else { return '<a class="add add_cart cart_added addcart" href="javascript:void(0);" rel="'.$id.'" data-type="list">Sepetten Sil</a>'; } } } function cart_total() { $db = new DB(); $total = 0; foreach($_SESSION['cart'] as $p_id => $c_p) { $sale_price = $db->table('products')->where('id','=',$p_id)->get_var('sale_price'); $total_product_price = $c_p['count']*$sale_price; $total = $total+$total_product_price; } return m_currency($total); } function cart_count() { return (isset($_SESSION['cart']) && is_array($_SESSION['cart'])) ? count($_SESSION['cart']) : 0; } function cart_info() { $db = new DB(); if(m_setting('coupon_usage')!=1) { $_SESSION['coupon_code']; } $return = array(); $return['sub_total'] = 0; $return['total_tax'] = 0; $return['total_cargo_price'] = 0; $return['products'] = array(); $n = 0; foreach($_SESSION['cart'] as $p_id => $c_p_1) { foreach ($c_p_1 as $c_p) { $product = $db->table('products')->where('id', '=', $p_id)->get_vars(); $return['products'][$n]['id'] = $product['id']; $return['products'][$n]['title'] = $product['title']; $return['products'][$n]['stock_code'] = $product['stock_code']; $return['products'][$n]['tax_percent'] = $product['tax']; $return['products'][$n]['image'] = m_image_url($product['image']); $return['products'][$n]['link'] = m_permalink('product', $product['sef'], $product['id']); $variants = ''; $return['products'][$n]['variantlar'] = []; foreach ($c_p['variants'] as $variant_title => $variant_content) { $variants .= '<b>' . $variant_title . ':</b> ' . $variant_content . '<br>'; array_push($return['products'][$n]['variantlar'],[$variant_title=>$variant_content]); } $return['products'][$n]['variants'] = $variants; $return['products'][$n]['undiscounted_price'] = $product['undiscounted_price']; $return['products'][$n]['currency_type'] = currency_types($product['currency_type'], 'value'); $return['products'][$n]['quantity'] = $c_p['count']; foreach($c_p['variants'] as $vprice){ $varian = $db->table('variants')->where('title','=',$vprice)->get(); $return['products'][$n]['sub_total'] += $c_p['count'] * $varian['data'][0]['price']; $return['products'][$n]['sale_price'] += $varian['data'][0]['price']; } $return['products'][$n]['sale_price'] += $product['sale_price']; $return['products'][$n]['sub_total'] += $c_p['count'] * $product['sale_price']; $return['sub_total'] = $return['sub_total'] + $return['products'][$n]['sub_total']; if ($product['tax_included'] == 0) { $return['products'][$n]['tax'] = m_percent($product['sale_price'], $product['tax']) * $c_p['count']; $return['products'][$n]['sub_total'] = $return['products'][$n]['sub_total'] + $return['products'][$n]['tax']; $return['total_tax'] = $return['total_tax'] + $return['products'][$n]['tax']; } else { $return['products'][$n]['tax'] = m_currency(0); } if ($product['cargo_price'] == 0 or cart_total() >= m_setting('free_cargo_minumum')) { $return['products'][$n]['cargo_price'] = m_currency(0); } elseif (!empty(m_setting('cargo_price'))) { if (!empty($product['cargo_price'])) { $return['products'][$n]['cargo_price'] = $product['cargo_price']; $return['products'][$n]['sub_total'] = $return['products'][$n]['sub_total'] + $return['products'][$n]['cargo_price']; $return['total_cargo_price'] = $return['total_cargo_price'] + $return['products'][$n]['cargo_price']; } else { $return['total_cargo_price'] = '0'; } } else { $return['products'][$n]['cargo_price'] = $product['cargo_price']; $return['products'][$n]['sub_total'] = $return['products'][$n]['sub_total'] + $return['products'][$n]['cargo_price']; $return['total_cargo_price'] = $return['total_cargo_price'] + $return['products'][$n]['cargo_price']; } $return['products'][$n]['sub_total'] = m_currency($return['products'][$n]['sub_total']); $n++; } } $return['total_cargo_price'] = $return['total_cargo_price'] + m_setting('cargo_price'); $return['sub_total'] = $return['sub_total']; if($_SESSION['coupon_code']=='') { $return['coupon_code'] = ''; $return['discount'] = 0; $_SESSION['coupon_code'] = ''; } else { $coupons = $db->table('coupons')->where('coupon_code','=',$_SESSION['coupon_code'])->where('status','=',1)->order('id','desc')->get(); if($coupons['total_count']>0) { $coupon = $coupons['data'][0]; if($return['sub_total']>=$coupon['minumum_order']) { $return['coupon_code'] = $coupon['coupon_code']; if($coupon['discount_type']==0) { $return['coupon_discount_type'] = '% '.$coupon['discount']; $return['sub_total'] = $return['sub_total']-m_percent($return['sub_total'],$coupon['discount']); $return['discount'] = m_percent($return['sub_total'],$coupon['discount']); } else { $return['coupon_discount_type'] = m_currency($coupon['discount']).' '.currency_types(m_setting('currency_type'),'value'); $return['sub_total'] = $return['sub_total']-$coupon['discount']; $return['discount'] = $coupon['discount']; } } else { $_SESSION['coupon_code'] = ''; $return['discount'] = 0; } } else { $_SESSION['coupon_code'] = ''; $return['discount'] = 0; } } $return['sub_total'] = $return['sub_total']; $return['total_tax'] = $return['total_tax']; $return['total_cargo_price'] = $return['total_cargo_price']; $return['total'] = m_currency($return['sub_total']+$return['total_tax']+$return['total_cargo_price']); $return['sub_total'] = m_currency($return['sub_total']); $return['total_tax'] = m_currency($return['total_tax']); $return['total_cargo_price'] = m_currency($return['total_cargo_price']); return $return; } function m_customer_log($transaction) { $db = new DB(); $db->table('customer_logs')->insert(array('u_id'=>m_user('id'),'transaction'=>$transaction,'ip'=>m_ip(),'date'=>$db->now())); } function create_order($customer_address,$payment_type,$status,$notify=false) { $db = new DB(); if($customer_address['total_count']>0 and $payment_type!='') { $c_address = $customer_address['data'][0]; if(m_user_check()) { $customer_id = m_user('id'); $customer_identity = m_user('identity_number'); $customer_email = m_user('email'); } else { $customer_id = 0; $customer_identity = $c_address['identity_number']; $customer_email = $c_address['email']; } $cart_info = cart_info(); $cart_info['sub_total'] = str_replace(",", "", $cart_info['sub_total']); $cart_info['total_tax'] = str_replace(",", "", $cart_info['total_tax']); $cart_info['total_cargo_price'] = str_replace(",", "", $cart_info['total_cargo_price']); $cart_info['coupon_discount'] = str_replace(",", "", $cart_info['coupon_discount']); $cart_info['total'] = str_replace(",", "", $cart_info['total']); $data = [ 'customer' => m_user('id'), 'customer_identity' => $customer_identity, 'customer_email' => $customer_email, 'cargo_name' => $c_address['name'], 'cargo_lastname' => $c_address['lastname'], 'cargo_phone' => $c_address['phone'], 'cargo_country' => $db->table('regions')->where('id','=',$c_address['country'])->get_var('title'), 'cargo_city' => $db->table('regions')->where('id','=',$c_address['city'])->get_var('title'), 'cargo_county' => $db->table('regions')->where('id','=',$c_address['county'])->get_var('title'), 'cargo_address' => $c_address['address'], 'cargo_for_directions' => $c_address['for_directions'], 'sub_total' => $cart_info['sub_total'], 'total_tax' => $cart_info['total_tax'], 'total_cargo_price' => $cart_info['total_cargo_price'], 'coupon_code' => $cart_info['coupon_code'], 'coupon_discount' => $cart_info['discount'], 'total' => $cart_info['total'], 'payment_type' => $payment_type, 'status' => $status, 'date' => $db->now() ]; $o_id = $db->table('orders')->insert($data); foreach($cart_info['products'] as $product) { $product['sale_price'] = str_replace(",", "", $product['sale_price']); $product['sub_total'] = str_replace(",", "", $product['sub_total']); $product['cargo_price'] = str_replace(",", "", $product['cargo_price']); $product['tax'] = str_replace(",", "", $product['tax']); $data = [ 'o_id' => $o_id, 'product_id' => $product['id'], 'product_name' => $product['title'], 'product_stock_code' => $product['stock_code'], 'product_variants' => $product['variants'], 'product_tax_percent' => $product['tax_percent'], 'product_price' => $product['sale_price'], 'product_currency_type' => $product['currency_type'], 'product_quantity' => $product['quantity'], 'product_sub_total' => $product['sub_total'], 'product_cargo_price' => $product['cargo_price'], 'product_total_tax' => $product['tax'] ]; $query = $db->table('order_products')->insert($data); //$data = [ // 'stock' => 'stock -'.$product['quantity'] //]; //$query = $db->table('products')->where('id','=',$product['id'])->update($data); } if(m_setting('order_to_email')!='') { email_send(m_setting('order_to_email'),''.LG_ORDER_DETAILS.' - '.$o_id.'',email_to_order(''.m_user('name').' '.m_user('lastname').'',$o_id,''.$cart_info['total'].' '.currency_types(m_setting('currency_type'),'value').'',strip_tags(m_order_status($status)))); } if($notify) { email_send(m_user('email'),''.LG_ORDER_DETAILS.' - '.$o_id.'',email_order(''.m_user('name').' '.m_user('lastname').'',$o_id,''.$cart_info['total'].' '.currency_types(m_setting('currency_type'),'value').'',strip_tags(m_order_status($status)))); if(m_setting('payment_type')==1 or m_setting('payment_type')==3) { email_send($customer_email,''.LG_ORDER_DETAILS.' - '.$o_id.'',email_order_payment(''.m_user('name').' '.m_user('lastname').'',$o_id,''.$cart_info['total'].' '.currency_types(m_setting('currency_type'),'value').'',strip_tags(m_order_status($status)))); } } if(m_setting('order_to_sms')==1) { netgsm_sms(m_user('phone'),'Sayın '.m_user('name').' '.m_user('lastname').' '.$o_id.' nolu siparisiniz basariyla alinmistir.'); } return $o_id; } else { return false; } } function ticico_license($key) { if(empty($key)) { die("LİSANS KODUNA LÜTFEN SİZE GÖNDERİLEN LİSANS KODUNU GİRİN."); } else { return 1; $site = str_replace("www.", "", $_SERVER["HTTP_HOST"]); $dogrula = wordwrap(strtoupper(md5(sha1(sha1(sha1(md5($site."k22")))))), 4, '-', true); if($dogrula != $key) { die("LİSANS KODU GEÇERLİ DEĞİL, LÜTFEN GEÇERLİ LİSANS KODUNU GİRİN."); } } }
💾 Kaydet
İptal
📝 Yeniden Adlandır
İptal
Kaydet
🔐 Dosya İzinleri (chmod)
İzin Değeri:
Hızlı Seçim:
777
755
644
600
777
= Herkes okur/yazar/çalıştırır
755
= Sahip tam, diğerleri okur/çalıştırır
644
= Sahip okur/yazar, diğerleri okur
600
= Sadece sahip okur/yazar
İptal
Uygula