Created
June 12, 2017 15:07
-
-
Save supertassu/7bd02ab3ba4c1625340505f4ac9efb96 to your computer and use it in GitHub Desktop.
licensing system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
if (!(isset($_GET["pl"]))) die("error"); | |
if (!(isset($_GET["token"]))) die("error"); | |
$handle = @fopen("someplugin.txt", "r"); | |
if ($handle && $_GET["pl"] == "someplugin") { | |
while (($buffer = fgets($handle, 4096)) !== false) { | |
if (strcmp(trim($buffer), $_GET["token"]) == 0) { | |
echo "ok"; | |
} | |
} | |
if (!feof($handle)) { | |
echo "error: unexpected fgets() fail\n"; | |
} | |
fclose($handle); | |
} else { | |
echo "error"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String token = ...; | |
try { | |
boolean license = false; | |
URL oracle = new URL("http://your.server/api.php?pl=someplugin&token=" + token); | |
BufferedReader in = new BufferedReader( | |
new InputStreamReader(oracle.openStream())); | |
String inputLine; | |
while ((inputLine = in.readLine()) != null) { | |
if (inputLine.contains("ok")) { | |
license = true; | |
getLogger().info("License ok"); | |
} | |
} | |
in.close(); | |
if (!license) { | |
getLogger().info("== [ == ] == [ == ] =="); | |
getLogger().info("UNKNOWN LICENSE KEY!"); | |
getLogger().info("== [ == ] == [ == ] =="); | |
getPluginLoader().disablePlugin(this); | |
return; | |
} | |
} | |
catch (Exception ex) { | |
ex.printStackTrace(); | |
getLogger().info("== [ == ] == [ == ] =="); | |
getLogger().info("COULD NOT CONTACT LICENSING SERVERS"); | |
getLogger().info("== [ == ] == [ == ] =="); | |
getPluginLoader().disablePlugin(this); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
key1 | |
key2 | |
key3 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment