<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 
function ebay_revise_item($user_id, $item_id, $revise_price, $amazon_price, $revise_qty, $max_qty, $asin)
{
    $sql_config = "SELECT \n    \t\t\t\teu.dev_name,\n    \t\t\t\teu.app_name,\n    \t\t\t\teu.cert_name,\n    \t\t\t\teu.token,\n    \t\t\t\tec.paypal_address,\n    \t\t\t\tec.return_accept_option,\n    \t\t\t\tec.refund_option,\n    \t\t\t\tec.return_days \n    \t\tFROM \t\n    \t\t\t\tebay_users eu,\n    \t\t\t\tebay_config ec\n    \t\tWHERE \n    \t\t\t\teu.user_id = ec.user_id AND \n    \t\t\t\teu.user_id = {$user_id}\t\t\t\t\n    ";
    $rs_config = mysql_query($sql_config) or die(mysql_error());
    if (mysql_num_rows($rs_config) != 1) {
        die("Database Error - Developer Side");
    }
    $row_config = mysql_fetch_assoc($rs_config);
    $DEVNAME = trim($row_config['dev_name']);
    $APPNAME = trim($row_config['app_name']);
    $CERTNAME = trim($row_config['cert_name']);
    // $token = "AgAAAA**AQAAAA**aAAAAA**rk05VA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AElYCmCJiFqQqdj6x9nY+seQ**y4ICAA**AAMAAA**I+dnHHqjbr1rjZlo8wEbyge8d1Rj73Vd3La+W4FzvDVDYl4cLgvS2pw9bttZX9kkkFTpeRtt+UDuYxU9N6O3FpzN7OklgZaQKMud9sjKb6O3WQYICnjw2KdMlEaeBKrTTmyM31hEcOiTvJB5u/0U0zFLWXvk1Qk6YAPhqTGejzYiwQtqYGtmd0rGtoS+b+46XxRov3saL5cRdOfSSTcHlWY9mtIqWerFpM4ZP0Qbj6xM4azxUa0m0BIZKf70+EbSBoFOaVo4X2k5ysHvSII+1WTbVBNvqgp9PNvgfyoMs+VZZ77Q+Qlfl+kk1pmGJqgqUY854qv0gABzSV5OEbgHIS2v0K2OhcTbo3EgvDX1SbPr/MKGFmC2aeqrVbn/9x5XZKnwPdtqoDwYJKe3sU/tzonToUKfyqldIF1GbJlvh5lgd2dPv+WS29g0wNNKGtPDyrLmQ0cktF0Ymnx5zvT7xffOtE9HweCCCILJeqFgyS7XeBgSY4d4fXcxXtaMaK9c2HFjwnF4v2WKoJ9KYYT9svSsf3ksk4fGzEv6XVPonZQxvyZESJHxQ7SbR/KE0rAB1WZY8N8x0hMu999SEJEse4lYRP7RjVxx82AVZp6MUVExfHSMQcQQL8O5O6wgjkErAHpfd7CzOmaSeyy4HNzWq3liP0WGQCfVXFDGl2YunJL9stIKaA/SrMeOvx5CSAWYUwEnx4OUwKlPpeZot+x98I+6Q1i2K1Paf6jMM6X5j4HGIrtMHgCMqWfM8IkPU+5Q";
    $token = trim($row_config['token']);
    $SiteId = 0;
    $active_user = 8;
    $eBayAPIURL = "https://api.ebay.com/ws/api.dll";
    $COMPATIBILITYLEVEL = '837';
    $paypal_email = trim($row_config['paypal_address']);
    $return_accept_option = trim($row_config['return_accept_option']);
    $refund_option = trim($row_config['refund_option']);
    $return_within_days = trim($row_config['return_days']);
    $sql = "SELECT * FROM user_products WHERE UserID={$active_user} and ItemID={$item_id}";
    $rs = mysql_query($sql);
    $row = mysql_fetch_assoc($rs);
    $sku = $row['SKU'];
    $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);
    if ($posamaz > 0) {
        $url = "http://www.amazon.com/dp/" . $asin;
    } elseif ($poswm > 0) {
        $linkitem = scrap_walmartlink($asin);
        $url = "http://www.walmart.com/" . $linkitem;
    } elseif ($posos > 0) {
        $url = "http://www.overstock.com/search/" . $asin;
    } elseif ($posal > 0) {
        $url = "http://www.aliexpress.com/wholesale?SearchText=" . $asin;
    } elseif ($poshe > 0) {
        $url = "http://search.hayneedle.com/search/index.cfm?Ntt=" . $asin;
    } elseif ($poswa > 0) {
        $url1 = "http://www.wayfair.com/keyword.php?keyword=" . $asin;
        $data = getPage($url1);
        $html = str_get_html($data);
        foreach ($html->find('div[id=sbprodgrid] a') as $item) {
            $url1 = $item->href;
            break;
        }
        $url = $url1;
    } else {
        $url = "http://www.amazon.com/dp/" . $asin;
    }
    if ($row['Qty'] != $revise_qty && $revise_qty > 0 && $row['Price'] == $revise_price) {
        $date = date("d/m/Y h:i:s");
        $message = "" . $date . " eBay Quantity changed from " . $row['Qty'] . " to " . $revise_qty . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a> because max_quantiy = " . $max_qty . "<br>";
        $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        file_put_contents("log.php", $message, FILE_APPEND);
        //mail('*****@*****.**', 'Updating Quantity', $message,$headers);
        mail('*****@*****.**', 'Updating Ebay Quantity', $message, $headers);
        mail('*****@*****.**', 'Updating Ebay Quantity', $message, $headers);
        $post_data = '<?xml version="1.0" encoding="utf-8"?>
  <ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <ErrorLanguage>en_US</ErrorLanguage>
  <Item>    
    <ItemID>' . $item_id . '</ItemID>
    <Quantity>' . $revise_qty . '</Quantity>
   
  </Item>
  <RequesterCredentials>  
  <eBayAuthToken>' . $token . '</eBayAuthToken>
  </RequesterCredentials>
 
  </ReviseItemRequest>';
    } elseif ($row['Qty'] == $revise_qty && $revise_qty > 0 && $row['Price'] != $revise_price) {
        //echo  $ebay_price
        $amzprice = $row['AmazonPrice'];
        $date = date("d/m/Y h:i:s");
        if ($amzprice != $amazon_price) {
            $message = "" . $date . " eBay Price changed from \$" . $row['Price'] . " to \$" . $revise_price . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a>  because Vendor price of <a target='_blank' href=" . $url . ">" . $asin . "</a> change from \$" . $amzprice . " to \$" . $amazon_price . "<br>";
        } else {
            $message = "" . $date . " eBay Price changed from \$" . $row['Price'] . " to \$" . $revise_price . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a> for vendor product <a target='_blank' href=" . $url . ">" . $asin . "</a> priced \$" . $amazon_price . "<br>";
        }
        $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        file_put_contents("log.php", $message, FILE_APPEND);
        mail('*****@*****.**', 'Updating Ebay Price', $message, $headers);
        mail('*****@*****.**', 'Updating Ebay Price', $message, $headers);
        $post_data = '<?xml version="1.0" encoding="utf-8"?>
  <ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <ErrorLanguage>en_US</ErrorLanguage>
  <Item>    
    <ItemID>' . $item_id . '</ItemID>
    <StartPrice>' . $revise_price . '</StartPrice>
      
  </Item>
  <RequesterCredentials>  
  <eBayAuthToken>' . $token . '</eBayAuthToken>
  </RequesterCredentials>
 
  </ReviseItemRequest>';
    } elseif ($row['Qty'] != $revise_qty && $revise_qty > 0 && $row['Price'] != $revise_price) {
        $date = date("d/m/Y h:i:s");
        $amzprice = $row['AmazonPrice'];
        if ($amzprice != $amazon_price) {
            $message1 = "" . $date . " eBay Price changed from \$" . $row['Price'] . " to \$" . $revise_price . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a>  because Vendor price of <a target='_blank' href=" . $url . ">" . $asin . "</a> change from \$" . $amzprice . " to \$" . $amazon_price . "<br>";
        } else {
            $message1 = "" . $date . " eBay Price changed from \$" . $row['Price'] . " to \$" . $revise_price . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a> for vendor product <a target='_blank' href=" . $url . ">" . $asin . "</a> priced \$" . $amazon_price . "<br>";
        }
        $message2 = "" . $date . " eBay Quantity changed from " . $row['Qty'] . " to " . $revise_qty . " for itemid=<a target='_blank' href=http://www.ebay.com/itm/" . $item_id . ">" . $item_id . "</a> because max_quantiy = " . ${$max_qty} . "<br>";
        file_put_contents("log.php", $message1, FILE_APPEND);
        file_put_contents("log.php", $message2, FILE_APPEND);
        $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        mail('*****@*****.**', 'Updating Ebay Price', $message1, $headers);
        mail('*****@*****.**', 'Updating Ebay Quantity', $message2, $headers);
        //mail('*****@*****.**', 'Updating Ebay Price', $message1,$headers);
        //mail('*****@*****.**', 'Updating Ebay Quantity', $message2,$headers);
        mail('*****@*****.**', 'Updating Ebay Price', $message1, $headers);
        mail('*****@*****.**', 'Updating Ebay Quantity', $message2, $headers);
        $post_data = '<?xml version="1.0" encoding="utf-8"?>
  <ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
  <ErrorLanguage>en_US</ErrorLanguage>
  <Item>    
    <ItemID>' . $item_id . '</ItemID>
    <StartPrice>' . $revise_price . '</StartPrice>
	<Quantity>' . $revise_qty . '</Quantity>
	
  </Item>
  <RequesterCredentials>  
  <eBayAuthToken>' . $token . '</eBayAuthToken>
  </RequesterCredentials>
 
  </ReviseItemRequest>';
    }
    $call_name = "ReviseItem";
    $ebayapiheader = array("X-EBAY-API-COMPATIBILITY-LEVEL: {$COMPATIBILITYLEVEL}", "X-EBAY-API-DEV-NAME: {$DEVNAME}", "X-EBAY-API-APP-NAME: {$APPNAME}", "X-EBAY-API-CERT-NAME: {$CERTNAME}", "X-EBAY-API-SITEID: {$SiteId}", "X-EBAY-API-CALL-NAME: " . $call_name);
    $ch = curl_init();
    $res = curl_setopt($ch, CURLOPT_URL, $eBayAPIURL);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    // 0 = Don't give me the return header
    curl_setopt($ch, CURLOPT_HTTPHEADER, $ebayapiheader);
    // Set this for eBayAPI
    curl_setopt($ch, CURLOPT_POST, 1);
    // POST Method
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    //My XML Request
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $body = curl_exec($ch);
    //Send the request
    curl_close($ch);
    // Close the connection
    return $body;
}