Example #1
0
File: Padl.php Project: vienis/padl
 /**
  * Internal autoloader for spl_autoload_register().
  *
  * @param string $class The class to load
  *
  * @return void
  */
 public static function autoload($class)
 {
     $path = dirname(__FILE__) . '/' . str_replace('\\', '/', $class) . '.php';
     if (!file_exists($path)) {
         return;
     }
     if (self::$initPath && !self::$initialized) {
         self::$initialized = true;
         require self::$initPath;
     }
     require_once $path;
 }
<?php

if (isset($_POST['submit'])) {
    // register autoload
    include_once '../src/PHP5.3/Padl/Padl.php';
    Padl::registerAutoload();
    // gets the data and transform to boolean
    $domain = $_POST['domain'];
    $useMcrypt = $_POST['useMcrypt'] == 'true' ? true : false;
    $useTime = $_POST['useTime'] == 'true' ? true : false;
    $useServer = $_POST['useServer'] == 'true' ? true : false;
    $allowLocal = $_POST['allowLocal'] == 'true' ? true : false;
    // calculates the offset (expire_in)
    $now = mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y'));
    $dateLimit = mktime(23, 59, 59, $_POST['dateLimitMonth'], $_POST['dateLimitDay'], $_POST['dateLimitYear']);
    $expireIn = $dateLimit - $now;
    // instatiate the class
    $padl = new Padl\License($useMcrypt, $useTime, $useServer, $allowLocal);
    // copy the server vars (important for security, see note below)
    $server_array = $_SERVER;
    // set the server vars
    // note this doesn't have to be set, however if not all of your app files are encoded
    // then there would be a possibility that the end user could modify the server vars
    // to fit the key thus making it possible to use your app on any domain
    // you should copy your server vars in the first line of your active script so you can
    // use the unmodified copy of the vars
    $padl->setServerVars($server_array);
    // generate a key with your server details
    $license = $padl->generate($domain, 0, $expireIn);
    header("Content-Type: application/save");
    header("Content-Length:" . strlen($license));