-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathview_ebay_data_old.php
251 lines (206 loc) · 9.81 KB
/
view_ebay_data_old.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
require_once('head.php');
require ('inc.db.php');
include('ebayFunctions.php');
include "simple_html_dom.php";
?>
<body>
<?php
require_once('blocks/menu.php');
$select = "SELECT * FROM user_products WHERE UserID=$active_user ORDER BY sort";
$result = mysql_query($select);
$count = mysql_num_rows($result);
if ($count == 0)
{
?>
<div id="ErrorMsg" class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
Sorry! No Ebay Listings Found...
</div>
<p><strong>Products Unavailable</strong></p>
<?php
} else {
?>
<h3>Amazon-eBay Listing(<?php echo $count;?>)</h3>
<table class="table table-bordered">
<tr>
<th style="width:100px;">eBay ID</th>
<th style="width:90px;">ItemNumber</th>
<th style="width:320px;">Ebay Title</th>
<th style="width:65px;">eBay Qty</th>
<th style="width:70px;">Vendor Qty</th>
<th style="width:70px;">Current eBay Price</th>
<th style="width:80px;">Rec. Price</th>
<th style="width:80px;">Vendor Price</th>
<th style="width:65px;">Profit %</th>
<th style="width:120px;">Set Profit</th>
</tr>
<?php
while ($row_product = mysql_fetch_array($result)) {
$ebay_id = $row_product['ItemID'];
$ebay_title = $row_product['Title'];
$ebay_qty = $row_product['Qty'];
$ebay_price = $row_product['Price'];
$item_url = $row_product['ItemUrl'];
$amazon_price = $row_product['AmazonPrice'];
$sku=$row_product['SKU'];
// if($ebay_qty< 0 ) continue;
$pattern = '/^AMZ/';
$posamaz=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$pattern = '/^WM/';
$poswm=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$pattern = '/^OS/';
$posos=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$pattern = '/^AL/';
$posal=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$pattern = '/^HN/';
$poshe=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$pattern = '/^WF/';
$poswa=preg_match($pattern,$sku, $matches, PREG_OFFSET_CAPTURE);
$profit_ratio = $row_product['ProfitRatio'];
$amazon_quantity = $row_product['AmazonQty'];
$max_quantity = $row_product['MaxQty'];
// $azon_price=$row_product['azonprice'];
$sql_asin = "SELECT asins,item_id FROM ebay_asin WHERE item_id = '$ebay_id' ";
$rs_asin = mysql_query($sql_asin);
$row_asin = mysql_fetch_array($rs_asin);
$asin = $row_asin['asins'];
/*if(empty($asin)){
$sql_asin = "DELETE FROM user_products WHERE ItemID = '$ebay_id' ";
mysql_query($sql_asin);
}*/
?>
<tr>
<td><?php echo '<a href="' . $item_url . '" target="_blank">' . $ebay_id . '</a>'; ?></td>
<td><?php echo '<a href="' . $row_product['VendorUrl'] . '" target="_blank">' . $row_product['SKU'] . '</a>'; ?></td>
<!-- <?php if($poswm>0) {?>
<td><?php
$tasin=explode('-',$asin);
$linkitem=scrap_walmartlink($tasin[0]);
echo '<a href=http://www.walmart.com/'. $linkitem . ' target="_blank">' . $tasin[0] . '</a>'; ?></td>
<?php
}
elseif($posos>0) {?>
<td><?php echo '<a href=http://www.overstock.com/search/' . $asin . ' target="_blank">' . $asin . '</a>'; ?></td>
<?php }
elseif($posamaz>0) {?>
<td><?php echo '<a href=http://www.amazon.com/dp/' . $asin . ' target="_blank">' . $asin . '</a>'; ?></td>
<?php $filename='http://ezon.org/cl/ezonlister/uploads/amazon/'.$asin.'.jpg';
}
elseif($posal>0) {?>
<td><?php echo '<a href=http://www.aliexpress.com/wholesale?SearchText=' . $asin . ' target="_blank">' . $asin . '</a>'?></td>;
<?php $filename='http://ezon.org/cl/ezonlister/uploads/aliexpress/'.$asin.'.jpg';
}
elseif($poshe>0){
?>
<td><?php echo '<a href=http://search.hayneedle.com/search/index.cfm?Ntt=' . $asin . ' target="_blank">' . $asin . '</a>'?></td>;
<?php
}
elseif($poswa>0){
$url="http://www.wayfair.com/keyword.php?keyword=".$asin;
$data=getPage($url);
$html = str_get_html($data);
foreach($html->find('div[id=sbprodgrid] a') as $item) {
$url=$item->href;
break;
}
?>
<td><?php echo '<a href='.$url.' target="_blank">' . $asin . '</a>'; ?></td>
<?php
}
else {?>
<td><?php echo '<a href=http://www.amazon.com/dp/' . $asin . ' target="_blank">' . $asin . '</a>'; ?></td>
<?php }
?>
--> <td><?php echo $ebay_title; ?></td>
<td><span id="quantity_<?php echo $ebay_id;?>"><?php echo $ebay_qty; ?></span></td>
<td><?php echo $amazon_quantity;?></td>
<?php if($poswm>0) {
$asin=$tasin[0];
}?>
<!-- <td><span id="maxquantity_<?php echo $ebay_id;?>"><?php echo $max_quantity;?></span></td> -->
<td><span id="ebayprice_<?php echo $ebay_id;?>" ><?php echo $ebay_price; ?></span></td>
<td><?php
if(strpos($row_product['VendorUrl'], 'http://www.wayfair.com/') === false)
echo number_format($amazon_price*(1+$profit_ratio/100)/0.85, 2, '.', '');
else
echo '---';
?></td>
<td><?php echo $amazon_price; ?></td>
<td><span id="profitratio_<?php echo $ebay_id;?>" ><?php echo $profit_ratio;?></td>
<!-- <td style="width: 120px;">
<input type="text" id="maxqtybox_<?php
echo $active_user."_".$ebay_id."_".$asin;
?>" value="<?php echo $max_quantity;?>" style="width:40px;float: left;"/>
<input type="submit" class="btn btn-info" value="Save" onclick="update_max_qty(maxqtybox_<?php echo $active_user."_".$ebay_id."_".$asin;?>)" style="margin-left: 5px;"/>
</td>
--> <td style="width: 125px;">
<input type="text" id="profitextbox_<?php
echo $active_user."_".$ebay_id."_".$asin;
?>" value="<?php echo $profit_ratio;?>" style="width:40px;float: left;"/>
<input type="submit" id="<?php echo $asin."_".$ebay_id;?>" class="btn btn-info" value="Save" onclick="update_profit_ratio(profitextbox_<?php echo $active_user."_".$ebay_id."_".$asin;?>)" style="margin-left: 10px;"/>
</td>
</tr>
<?php
}
}
function scrap_walmartlink($itemid){
$url="http://www.walmart.com/search/search-ng.do?search_query=".$itemid;
$data=postForm($url);
$link="";
//echo $data;die;
$html=str_get_html($data);
if($html){
foreach($html->find('a[class=js-product-title]') as $title)
{
$link=$title->href;
break;
}
}
return $link;
}
function postForm($url)
{
$ch = curl_init();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; // browsers keep this blank.
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* $proxyfile = dirname(__FILE__)."/pro/pro.txt";
$file = fopen($proxyfile, "r");
$i = 0;
while (!feof($file)) {
$proxies_array[] = fgets($file);
}
fclose($file);
$random_key = array_rand($proxies_array);
$random_proxy = $proxies_array[$random_key];
$random_proxy = trim(str_replace("<br />","",$random_proxy));
$new_proxy = explode(":", $random_proxy);
//$random_proxy="192.69.250.210:24084";
//$loginpassw = $new_proxy[2].":".$new_proxy[3];
curl_setopt($ch, CURLOPT_PROXY, $random_proxy);
*/
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if($info['http_code']!=200){$result=false;}
// $result = ($info['http_code']!=200) ? false : $result;
sleep(2);
return $result;
}
?>
</table>
</body>