$_REQUEST, 'Server' => $_SERVER), true)); } } /** * Callback function used to handle an unknown SlideMe licensing event. * * You should customize this function to alert you that you are using an old * version of the licensing API or maybe there is something wrong with your setup. */ function _slideme_default_action() { if(defined('ALERT_EMAIL')) { mail('ALERT_EMAIL', 'Unknown action', print_r(array('Request' => $_REQUEST, 'Server' => $_SERVER), true)); } } /** * Callback function used to handle a SlideME 'acquire' licensing event. * This event is triggered just before the transaction is completed, when * the invoice is prepared for the buyer. * * You should customize this function to generate a license key. * SlideME HTTP-POST you the information about application, developer, transaction and * mobile device in the following fields: * - developer, developer_id * - application, application_id * - transaction_id, price, currency * - device_mac, device_imei * * @return string - a valid licensekey for the specified application */ function _slideme_acquire_action() { // Simple example of generating a license key // BEGIN: Customize here $licensekey = sprintf('%08X-%08X-%08X', crc32($_GET['package_name']), crc32($_GET['device_mac']), crc32($_GET['device_imei'])); // store_licensekey_on_server($licensekey); - call to imaginary function to store the licensekey // END: Customize here return $licensekey; } /** * Callback function used to handle a SlideME 'release' licensing event. * This event is triggered just before the transaction is canceled (for various * reasons: technical, buyer's credit, buyer's explicit request, etc). * * You should customize this function to invalidate a license key. * SlideMe HTTP-POST you the information about application, developer, transaction, * mobile device and the license in the following fields: * - developer, developer_id * - application, application_id * - transaction_id, price, currency * - device_mac, device_imei * - licensekey * * @return null */ function _slideme_release_action() { // Simple example of invalidating a license key // BEGIN: Customize here $licensekey = $_GET['licensekey']; // destroy_licensekey_on_server($licensekey); - call to imaginary function to remove the licensekey // END: Customize here return $licensekey; } /* * ----------------------------- * DO NOT CHANGE BELOW THIS LINE * ----------------------------- */ /** * Callback function used to handle a SlideME 'ping' licensing event. * * Do not change this function. It should always return the license key "[application_id]-[transaction_id]". * * @return string - always return "[application_id]-[transaction_id]". */ function _slideme_ping_action() { return $_GET['application_id'] . '-' . $_GET['transaction_id']; } /* * Request processing */ //error_reporting(E_ERROR); if (defined('HTTP_AUTH_USER')) { if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) { header('WWW-Authenticate: Basic realm="SlideMe App Licensing"'); header('HTTP/1.0 401 Unauthorized'); exit; } if ($_SERVER['PHP_AUTH_USER'] != HTTP_AUTH_USER || $_SERVER['PHP_AUTH_PW'] != HTTP_AUTH_PASS) { header('WWW-Authenticate: Basic realm="SlideMe App Licensing"'); header('HTTP/1.0 401 Unauthorized'); _slideme_http_auth_failure(); exit; } } if(!empty($_GET['action']) && function_exists($callback = '_slideme_' . $_GET['action'] . '_action')) { echo json_encode((object)array('version' => '1.0', 'data' => $callback())); } else { _slideme_default_action(); }