I have created a simple to use solution that you can generate special keys for your Appgini generated application and you can use this to lock or deactivate the application remotely in 3 simple steps.
STEP ONE
Create a free account HERE
Log in and create an app. Each app you create will have a special key generated for it and you will use this in step two below.
You can also modify your application key status to Inactive, this way your Appgini application will be locked in a way users can't use it anymore.
STEP TWO
Go to your hooks folder and find a file called header-extras.php and paste the following code in there.
Code: Select all
<?php
#Provide your app_key below. Get your appkey by creatinga free account here: https://payherokenya.com/appcontrol
$keyjson= json_encode(array('app_key' =>'#yourkeyhere'));
#Send request to server.
$result=sendRequest("https://payherokenya.com/appcontrol/app/controller.php",$keyjson);
$resp=json_decode($result);
$status=$resp->response->status;
$message=$resp->response->message;
#If server returns inactive status, an error alert will be shown with your preffered message to the users.
if ($status=="Inactive") {
# code...
echo error_message("<b>".$message."</b>");exit;
}
What this code does is it checks from our remote server if the key is Inactive and it will lock it and display an error message you will set in step one.
STEP THREE
Go to hooks folder and find a file named _global.php and paste in the following code at the very end:
Code: Select all
function sendRequest($url,$data){
//Initiate cURL.
$ch = curl_init($url);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//Set the content type to application/json.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept:application/json'));
//Dont return result to screen,store in a variable.
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
//Execute the request.
$result = curl_exec($ch);
return $result;
}
That is it. You can now be able to lock your Appgini generated application remotely when the need arises. Feel free to try it out and give suggestions on how to improve my solution.