<?php
error_reporting(-1);
if (isset($_GET['ecid'], $_GET['service'])) {
$EMPTY ='';
$ECID = $_GET['ecid'];
$con = mysqli_connect('localhost', 'iskomzig_dhru', 'Unendlichk31+*', 'iskomzig_rpion');
$SERVICE = $_GET['service'];

$result = mysqli_query($con,"select * from Wo_UserOrders WHERE product_id='".$SERVICE."' AND address_id='".$ECID."'");





if(mysqli_num_rows($result) > 0 ){

    $found = "AUTHORIZED";	
}

else {
    $found="UNAUTHORIZED";
}
echo $found;
}
if (isset($_GET['reg'])){
    $cd = stripslashes($_GET['reg']);

// Show the msg, if the code string is empty
if (empty($cd))
    echo "Nothing to write";

// if the code string is not empty then open the target file and put form data in it
else
{
	$con = mysqli_connect('localhost', 'iskomzig_dhru', 'Unendlichk31+*', 'iskomzig_rpion');
    //$file = fopen("serials.log", "a");
   // fwrite($file, $cd . PHP_EOL );
   $SERVICE = $_GET['service'];
$ECID = $_GET['reg'];
   $result2 = mysqli_query($con,"select * from Wo_UserOrders WHERE product_id='".$SERVICE."' AND address_id='".$ECID."'");




if(mysqli_num_rows($result2) > 0 ){

     $found = "ECID Already Registered!";	
} else {
	mysqli_query($con,"INSERT INTO Wo_UserOrders (user_id, product_owner_id, product_id, address_id, price, commission, final_price,units,tracking_url,tracking_id,status,time)VALUES('6', '1', '".$_GET['service']."', '".$_GET['reg']."','0', '0','0','0','','','placed','1686078858')");
 $found = "ECID registered Successfully!";
}

    echo $found;

}
}

if (isset($_GET['del'])){
    $cd = stripslashes($_GET['del']);


if (empty($cd))
    echo "Nothing to delete";

else
{
	$con = mysqli_connect('localhost', 'iskomzig_dhru', 'Unendlichk31+*', 'iskomzig_rpion');

   $SERVICE = $_GET['service'];
$ECID = $_GET['del'];
$result2 = mysqli_query($con,"select * from Wo_UserOrders WHERE product_id='".$SERVICE."' AND address_id='".$ECID."'");




if(mysqli_num_rows($result2) > 0 ){
    mysqli_query($con,"DELETE FROM Wo_UserOrders WHERE product_id='".$SERVICE."' AND address_id='".$ECID."'");
     $found = "ECID Deleted!";	
} else {
 $found = "ECID not found!";
}

    echo $found;

}
}
