<?php
include '../config/database.php';

function httpGet($url)
{
    $ch = curl_init();  
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $output=curl_exec($ch);
    curl_close($ch);
    return $output;
}
define("_URL",'http://150.95.89.148/api/v3/push-system?msg=');
$param1 = $_GET['param1']; // ! ส่งข้อคาม , - ออกจากกลุ่ม
$param2 = $_GET['param2']; // uid bot
$param3 = $_GET['param3']; // uid or gid
$param4 = str_replace(" ","%20",$_GET['param4']); //  uid or text command
$param4 = str_replace("\n","%0A",$param4); //  uid or text command
//input for delete
$product = $_GET['_p']; // product
$version = $_GET['_v']; // version

// $param4 = $_GET['param4']; //  uid or text command
$all_url = _URL.''.$param1.'_'.$param2.'_'.$param3.'_'.$param4;
//push
httpGet($all_url);
//real relete
_Remove_line($param3,$product,$version);
// stop gorupline
_stop_bot($param3,$product,$version);
//!_uc26465be087048ab9e5cccacf84a2c80_u1466ce33fbc9b0c06269688edde6a087_xxxx
print_r($all_url);


//ลบ รายการ ใน ตาราง line ด้วย
function _Remove_line($gid,$product,$version){
	$conn = _connectDB();
	$sql = "DELETE FROM line WHERE line_gid='".$gid."' AND line_product = '".$product."' AND line_version = '".$version."' ";
	echo $sql;
	$conn->query($sql);
}

// สั่ง หยุด บอท ตาราง groupline
function _stop_bot($gid,$product,$version){
	$conn = _connectDB();
	$sql = "UPDATE groupline SET groupline_status='stop'  WHERE groupline_key='".$gid."' AND groupline_products = '".$product."' AND groupline_version = '".$version."' ";
	echo $sql;
	$conn->query($sql);
}

// groupline_key
// groupline_version
// groupline_products
// groupline_access
// groupline_status