-
Notifications
You must be signed in to change notification settings - Fork 19
/
tokopedia_csv4.php
executable file
·119 lines (62 loc) · 2.1 KB
/
tokopedia_csv4.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
session_start();
sleep(1);
ini_set('max_execution_time', 0);
error_reporting(0);
//ambil nilai
require("inc/config.php");
require("inc/fungsi.php");
require("inc/koneksi.php");
nocache;
//nilai
$kunci = balikin($_REQUEST['kunci']);
$filenya = "tokopedia_csv.php";
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$kunci+30persen.csv");
$qdata = mysql_query("SELECT * FROM tokopedia ".
"WHERE kategori <> '' ".
"AND lapaknya = '$kunci' ".
"ORDER BY kategori ASC, ".
"nama ASC");
$rdata = mysql_fetch_assoc($qdata);
//isi *START
ob_start();
//sempurnakan
function titelkuya44($str)
{
$str = trim($str);
$search = array ("'<Berat</dt>'", "'< Merek </dt> Lain-lain'", "'<Kondisi</dt>'", "' kilo'", "'\.'", "'\,'", "'gram'", "' gr'");
$replace = array ("", "", "", "00", "", "", "", "");
$str = preg_replace($search,$replace,$str);
return $str;
}
echo "Kategori,Nama Barang,Stok(Minimal 1),Berat (gram),Harga (Rupiah),Kondisi(Baru/Bekas),Deskripsi,Wajib Asuransi?(Ya/Tidak),URL Gambar 1,URL Gambar 2,URL Gambar 3,URL Gambar 4,URL Gambar 5\n";
do
{
$nomer = $nomer + 1;
$i_kd = nosql($rdata['kd']);
$i_nama = trim(titelkuya44(balikin($rdata['nama'])));
$i_deskripsi = balikin($rdata['isi']);
$i_kategori = balikin($rdata['kategori']);
$i_harga1 = balikin($rdata['harga']);
$i_berat = trim(titelkuya44(balikin($rdata['berat'])));
$i_kondisi = "Baru";
$i_jml_stock = "5";
$i_gambar1 = trim($rdata['img_url']);
//echo "$i_gambar1; $i_nama; $i_harga; $i_berat; $i_kondisi; $i_jml_stock; $i_jml_dilihat; $i_jml_peminat; $i_jml_terjual \n";
//tambahkan 30%
$i_harga22 = round($i_harga1 + ((30 / 100) * $i_harga1));
//cek
$i_harga2i = substr($i_harga22,-2);
//selisihnya
$i_hargku = 100 - $i_harga2i;
$i_harga2 = $i_harga22 + $i_hargku;
echo "$i_kategori,$i_nama. BIASAWAE,$i_jml_stock,$i_berat,$i_harga2,$i_kondisi,\"$i_deskripsi\",Ya,$i_gambar1, , , , , \n";
}
while ($rdata = mysql_fetch_assoc($qdata));
//isi
$content = ob_get_contents();
ob_end_clean();
echo $content;
exit();
?>