📁 PHP Dosya Yöneticisi
/
/
home
/
demodesigncom
/
e-ticaretv12.demodesign.com.tr
/
panel
/
dev
📝
ajax.php
← Geri Dön
<?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) ) { include '../fonksiyon.php'; $ayar = $db->query("SELECT * FROM ayar LIMIT 1")->fetch(PDO::FETCH_ASSOC); if ( !empty($_COOKIE['Sayim']) ) { $uyeID = $_COOKIE['Sayim']; } else { $uyeID = 0; } $query = $db->prepare("SELECT * FROM panel_kullanicilari where id=:id"); $kontrol = $query->execute(array(":id"=>$uyeID)); $kontrol = $query->fetchColumn(); if ( $kontrol != 0 ) { if ( $_GET["q"] == "urunekle" ) { $baslik = htmlspecialchars($_POST['baslik']); $kisa_aciklama = htmlspecialchars($_POST['kisa_aciklama']); $stok_kodu = post('stok_kodu'); $stok = (int)post('stok'); $marka_id = (int)post('marka_id'); $kategori = post('kategori'); $eski_fiyat = post('eski_fiyat'); $fiyat = post('fiyat'); $kdv = (int)post('kdv'); $kargo_fiyati = post('kargo_fiyati'); $aciklama = htmlspecialchars_decode($_POST['aciklama']); $img = post('img'); $islem = $db->prepare("INSERT INTO urun SET baslik = ?, sef = ?, kisa_aciklama = ?, stok_kodu = ?, stok = ?, marka_id = ?, eski_fiyat = ?, fiyat = ?, kdv = ?, kargo_fiyati = ?, aciklama =?"); $islem = $islem->execute(array($baslik,'',$kisa_aciklama,$stok_kodu,$stok,$marka_id,$eski_fiyat,$fiyat,$kdv,$kargo_fiyati,$aciklama)); $urunID = $db->lastInsertId(); $kategoriSor = $db->query("SELECT * FROM kategori WHERE baslik LIKE '%{$kategori}%' Order by id DESC LIMIT 1", PDO::FETCH_ASSOC); if ( $kategoriSor->rowCount() ){ foreach( $kategoriSor as $row ) { $islem = $db->prepare("INSERT INTO urun_kategori SET urun_id = ?, kategori_id = ?"); $islem = $islem->execute(array($urunID,$row['id'])); } } else { $islem = $db->prepare("INSERT INTO kategori SET baslik = ?, sef = ?, ust_kategori = ?, ust_menu = ?, alt_menu = ?, aciklama = ?, kisa_aciklama = ?, sira = ?"); $islem = $islem->execute( array( $kategori, sef($kategori), 0, 0, 0, '<div><br></div>', '', 99999) ); $kategoriID = $db->lastInsertId(); $islem = $db->prepare("INSERT INTO urun_kategori SET urun_id = ?, kategori_id = ?"); $islem = $islem->execute( array( $urunID, $kategoriID) ); } foreach ( $img as $pic ) { if ( !empty($pic) ) { $parts = parse_url($pic); $extension = pathinfo($parts['path'], PATHINFO_EXTENSION); $fileName = md5( date('his') . create_randString(13) ).".".$extension; $path = '../../upload/'; $touch = $path . $fileName; touch($touch); $al = file_get_contents($pic); $kaydet = file_put_contents($touch,$al); $islem = $db->prepare("INSERT INTO urun_img SET urun_id = ?, img = ?"); $islem = $islem->execute(array($urunID,$fileName)); } } if ( is_array($img) ) { if ( count($img) == 0 ) { $islem = $db->prepare("INSERT INTO urun_img SET urun_id = ?, img = ?"); $islem = $islem->execute(array($urunID,'empty-img.png')); } elseif ( count($img) == 1 ) { if ( $img[0] == "" ) { $islem = $db->prepare("INSERT INTO urun_img SET urun_id = ?, img = ?"); $islem = $islem->execute(array($urunID,'empty-img.png')); } } } else { $islem = $db->prepare("INSERT INTO urun_img SET urun_id = ?, img = ?"); $islem = $islem->execute(array($urunID,'empty-img.png')); } $sef = sef($baslik).'-'.$urunID; $islem = $db->prepare("UPDATE urun SET sef = ? WHERE id = ?"); $islem = $islem->execute(array($sef,$urunID)); if ( $islem ) { $array['status'] = 'success'; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Başarılı:</b> Ürün başarıyla eklendi!", type: "success" }); });</script>'; $array['post'] = $_POST; } else { $array['status'] = 'error'; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Hata:</b> İşlem sırasında bir hata ile karşılaştık.<br>Lütfen tekrar deneyiniz!", type: "error" }); });</script>'; } header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "td_cat" ) { $data = '<option value="">Lütfen Seçiniz</option>'; $query = $db->query("SELECT * FROM td_cat", PDO::FETCH_ASSOC); if ( $query->rowCount() ) { foreach ( $query as $row ) { $data .= '<option value="'.$row["categoryId"].'">'.$row["name"].'</option>'; } } $array['cat'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen Trendyol için kategori seçiniz!", type: "info" }); });</script>'; header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "gettdVaryant" ) { $id = $_GET['catID']; $data = ''; include_once '../../eklentiler/trendyol/trendyol.class.php'; $getTdVaryant = get_tdCURL( $id, 0, 7, 0 ); if ( is_array($getTdVaryant) ) { for ( $i=0; $i<count($getTdVaryant); $i++ ) { if ( !empty($getTdVaryant[$i]['required']) and $getTdVaryant[$i]['required'] == 1 ) { if ( is_array($getTdVaryant[$i]["attributeValues"]) ) { if ( count($getTdVaryant[$i]["attributeValues"]) != 0 ) { $data .= '<div class="vr_eleman"><input type="hidden" name="td_varyant[]" value="'. $getTdVaryant[$i]["attribute"]["id"] .'"><input type="hidden" name="td_customVaryant[]" value="0"><label for="trendyolVaryant'.$i.'" class="td-label" style="width:35%;">'. $getTdVaryant[$i]["attribute"]["name"] .'</label><select class="select3" name="td_varyantValue[]" id="trendyolVaryant'.$i.'">'; foreach ( $getTdVaryant[$i]["attributeValues"] as $k ) { $data .= '<option value="'.$k["id"].'">'.$k["name"].'</option>'; } $data .= '</select></div>'; } else { $data .= '<div class="vr_eleman"><input type="hidden" name="td_varyant[]" value="'. $getTdVaryant[$i]["attribute"]["id"] .'"><input type="hidden" name="td_customVaryant[]" value="1"><label for="trendyolVaryant'.$i.'" class="td-label" style="width:35%;">'. $getTdVaryant[$i]["attribute"]["name"] .'</label>'; $data .= '<input name="td_varyantValue[]" id="trendyolVaryant'.$i.'" placeholder="'. $getTdVaryant[$i]["attribute"]["name"] .' bilgisi giriniz." style="width:65%;">'; $data .= '</div>'; } } } } } if ( !empty($data) ) { $array['varyant'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen Trendyol için varyant seçiniz!", type: "info" }); });</script>'; } else { $array['varyant'] = $data; $array['msg'] = ''; } header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "n11_cat" ) { $data = '<option value="">Lütfen Seçiniz</option>'; $query = $db->query("SELECT * FROM n11_cat", PDO::FETCH_ASSOC); if ( $query->rowCount() ) { foreach ( $query as $row ) { $data .= '<option value="'.$row["categoryId"].'">'.$row["name"].'</option>'; } } $array['cat'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen N11 için kategori seçiniz!", type: "info" }); });</script>'; header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "getn11SubCat" ) { $id = $_GET['catID']; $data = ''; include_once '../../eklentiler/n11/N11.class.php'; $n11Params = array( 'appKey' => $ayar["n11AppKey"], 'appSecret' => $ayar["n11AppSecret"] ); $n11 = new N11($n11Params); $getN11SubKategori = $n11->GetSubCategories( $id ); if ( !empty($getN11SubKategori->category->subCategoryList->subCategory) ) { if ( is_array($getN11SubKategori->category->subCategoryList->subCategory) ) { if ( count($getN11SubKategori->category->subCategoryList->subCategory) != 0 ) { $subID = $getN11SubKategori->category->subCategoryList->subCategory[0]->id; $sonraki = array(); $g = $n11->GetSubCategories($subID); if ( $g->result->status == 'success' ) { if ( !empty($g->category->subCategoryList->subCategory) ) { if ( is_array($g->category->subCategoryList->subCategory) ) { if ( count($g->category->subCategoryList->subCategory) != 0 ) { $sonraki[] = 1; } } } else { $sonraki[] = 0; } } else { $sonraki[] = 0; } $rx = 0; foreach ( $sonraki as $r ) { if ( $r == 1 ) { $rx++; } } if ( $rx != 0 ) { $onchange = 'n11SubCats(this)'; } else { $onchange = 'n11Varyant(this)'; } $data .= '<div class="vr_eleman vrJS"><label for="n11SubCat'.$id.'" class="td-label" style="width:35%;">Sub Kategori</label><select class="select3" name="n11SubCat[]" id="n11SubCat'.$id.'" onchange="'.$onchange.'"><option value="">Lütfen seçiniz</option>'; foreach ( $getN11SubKategori->category->subCategoryList->subCategory as $k ) { $data .= '<option value="'.$k->id.'">'.$k->name.'</option>'; } $data .= '</select></div>'; } } } if ( !empty($data) ) { $array['cat'] = $data; $array['sonraki'] = $sonraki; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen N11 için sub kategori seçiniz!", type: "info" }); });</script>'; } else { $array['cat'] = $data; $array['msg'] = ''; } header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "getn11Varyant" ) { $id = $_GET['catID']; $data = ''; include_once '../../eklentiler/n11/N11.class.php'; $n11Params = array( 'appKey' => $ayar["n11AppKey"], 'appSecret' => $ayar["n11AppSecret"] ); $n11 = new N11($n11Params); $getN11Varyant = $n11->GetCategoryAttributes($id); if ( !empty($getN11Varyant->result->status) and $getN11Varyant->result->status == 'success' ) { if ( !empty($getN11Varyant->category->attributeList->attribute) ) { if ( is_array($getN11Varyant->category->attributeList->attribute) ) { if ( count($getN11Varyant->category->attributeList->attribute) != 0 ) { $i = 0; foreach ( $getN11Varyant->category->attributeList->attribute as $value ) { if ( !empty($value->mandatory) ) { if ( $value->mandatory == 1 ) { if ( !empty($value->valueList->value) ) { if ( is_array($value->valueList->value) ) { if ( count($value->valueList->value) != 0 ) { $data .= '<div class="vr_eleman"><input type="hidden" name="n11_varyantID[]" value="'. $value->id .'"><input type="hidden" name="n11_varyant[]" value="'. $value->name .'"><label for="n11Varyant'.$i.'" class="td-label" style="width:35%;">'. $value->name .'</label><select class="select3" name="n11_varyantValue[]" id="n11Varyant'.$i.'" onchange="getName(this)"><option value="">Lütfen seçiniz</option>'; foreach ( $value->valueList->value as $k ) { $data .= '<option value="'.$k->id.'" data-name="'.$k->name.'">'.$k->name.'</option>'; } $data .= '</select></div>'; $i++; } } } } } } } } } } if ( !empty($data) ) { $array['varyant'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen N11 için varyant seçiniz!", type: "info" }); });</script>'; } else { $array['varyant'] = $data; $array['msg'] = ''; } header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "hb_cat" ) { $data = '<option value="">Lütfen Seçiniz</option>'; $query = $db->query("SELECT * FROM hb_cat", PDO::FETCH_ASSOC); if ( $query->rowCount() ) { foreach ( $query as $row ) { $data .= '<option value="'.$row["categoryId"].'">'.$row["name"].'</option>'; } } $array['cat'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen Hepsiburada için kategori seçiniz!", type: "info" }); });</script>'; header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "gethbToken" ) { include_once '../../eklentiler/hepsiburada/hepsiburada.class.php'; $hb_auth = array( "username" => $ayar["hb_username"], "password" => $ayar["hb_password"], "authenticationType" => "INTEGRATOR" ); $hb_query = get_hpCURL( $hb_auth, 1, 1 ); $array['data'] = 'ok'; header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } if ( $_GET["q"] == "gethbVaryant" ) { $id = $_GET['catID']; $data = ''; include_once '../../eklentiler/hepsiburada/hepsiburada.class.php'; $hb_auth = array( "username" => $ayar["hb_username"], "password" => $ayar["hb_password"], "authenticationType" => "INTEGRATOR" ); $getHbVaryant = get_hpCURL( $id, 0, 3 ); if ( !empty($getHbVaryant['variantAttributes']) ) { if ( is_array($getHbVaryant['variantAttributes']) ) { if ( count($getHbVaryant['variantAttributes']) != 0 ) { for ( $i=0; $i<count($getHbVaryant['variantAttributes']); $i++ ) { $k = $getHbVaryant['variantAttributes'][$i]; if ( $k['type'] == 'enum' ) { $montaj = get_hpCURL( array($id,$k['id']), 0, 4 ); $data .= '<div class="vr_eleman"><input type="hidden" name="hb_varyant[]" value="'. $k["id"] .'"><label for="hepsiburadaVaryant'.$i.'" class="td-label" style="width:35%;">'. $k["name"] .'</label><select class="select3" name="hb_varyantValue[]" id="hepsiburadaVaryant'.$i.'">'; foreach ( $montaj as $f ) { $data .= '<option value="'.htmlspecialchars_decode($f["value"]).'">'.$f["value"].'</option>'; } $data .= '</select></div>'; } else { $data .= '<div class="vr_eleman"><input type="hidden" name="hb_varyant[]" value="'. $k["id"] .'"><label for="hepsiburadaVaryant'.$i.'" class="td-label" style="width:35%;">'. $k["name"] .'</label>'; $data .= '<input name="hb_varyantValue[]" id="hepsiburadaVaryant'.$i.'" placeholder="'. $k["name"] .' bilgisi giriniz." style="width:65%;">'; $data .= '</div>'; } } } } } if ( !empty($data) ) { $array['varyant'] = $data; $array['msg'] = '<script type="text/javascript">$(function(){ notif({ msg: "<b>Dikkat:</b> Lütfen Hepsiburada için varyant seçiniz!", type: "info" }); });</script>'; } else { $array['varyant'] = $getHbVaryant; $array['msg'] = ''; } header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } } } else { $array["data"] = 'God Bye!'; header("Content-type: application/json; charset=utf-8"); echo json_encode($array); exit(); } ?>
💾 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