/** Load a uncyphered publiclet */
 function loadPubliclet($data)
 {
     // create driver from $data
     $className = $data["DRIVER"] . "AccessDriver";
     if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"]) {
         // Remove the publiclet, it's done
         if (strstr(PUBLIC_DOWNLOAD_FOLDER, $_SERVER["SCRIPT_FILENAME"]) !== FALSE) {
             unlink($_SERVER["SCRIPT_FILENAME"]);
         }
         echo "Link is expired, sorry.";
         exit;
     }
     // Check password
     if (strlen($data["PASSWORD"])) {
         if ($_POST['password'] != $data["PASSWORD"]) {
             echo "<html><head><link rel='stylesheet' type='text/css' href='allz.css'/></head><body><form action='' method='post'><div class='dialogBox' style='display:block;width:20%;left:40%;'><div class='dialogTitle'><img width='16' height='16' align='top' src='public_url.png'>&nbsp;AjaXplorer Public Download</div><div class='dialogContent'>A password is required for this download :<br><input type='password' name='password' style='width:100%;'><br><div class='dialogButtons'><input width='22' height='22' type='image' name='ok' src='dialog_ok_apply.png' title='Download' class='dialogButton'></div></div></div></form></body></html>";
             exit(1);
         }
     }
     $filePath = INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
     if (!is_file($filePath)) {
         die("Warning, cannot find driver for conf storage! ({$name}, {$filePath})");
     }
     require_once $filePath;
     $driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
     $driver->loadManifest();
     $driver->init($data["REPOSITORY"], $data["OPTIONS"]);
     ConfService::setRepository($data["REPOSITORY"]);
     $driver->initRepository();
     $driver->switchAction($data["ACTION"], array("file" => $data["FILE_PATH"]), "");
 }
 /** Load a uncyphered publiclet */
 function loadPubliclet($data)
 {
     // create driver from $data
     $className = $data["DRIVER"] . "AccessDriver";
     if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"]) {
         // Remove the publiclet, it's done
         if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]), realpath(PUBLIC_DOWNLOAD_FOLDER)) !== FALSE) {
             $hash = md5(serialize($data));
             require_once INSTALL_PATH . "/server/classes/class.PublicletCounter.php";
             PublicletCounter::delete($hash);
             unlink($_SERVER["SCRIPT_FILENAME"]);
         }
         echo "Link is expired, sorry.";
         exit;
     }
     // Check password
     if (strlen($data["PASSWORD"])) {
         if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) {
             $content = file_get_contents(INSTALL_PATH . "/client/html/public_links.html");
             $language = "en";
             if (isset($_GET["lang"])) {
                 $language = $_GET["lang"];
             }
             $messages = array();
             if (is_file(INSTALL_PATH . "/client/i18n/{$language}.php")) {
                 include INSTALL_PATH . "/client/i18n/{$language}.php";
                 $messages = $mess;
             }
             if (preg_match_all("/AJXP_MESSAGE(\\[.*?\\])/", $content, $matches, PREG_SET_ORDER)) {
                 foreach ($matches as $match) {
                     $messId = str_replace("]", "", str_replace("[", "", $match[1]));
                     if (isset($messages[$messId])) {
                         $content = str_replace("AJXP_MESSAGE[{$messId}]", $messages[$messId], $content);
                     }
                 }
             }
             echo $content;
             exit(1);
         }
     }
     $filePath = INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php";
     if (!is_file($filePath)) {
         die("Warning, cannot find driver for conf storage! ({$name}, {$filePath})");
     }
     require_once $filePath;
     $driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
     $driver->loadManifest();
     $driver->init($data["REPOSITORY"], $data["OPTIONS"]);
     ConfService::setRepository($data["REPOSITORY"]);
     $driver->initRepository();
     // Increment counter
     $hash = md5(serialize($data));
     require_once INSTALL_PATH . "/server/classes/class.PublicletCounter.php";
     PublicletCounter::increment($hash);
     // Now call switchAction
     //@todo : switchAction should not be hard coded here!!!
     // Re-encode file-path as it will be decoded by the action.
     try {
         $driver->switchAction($data["ACTION"], array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"])), "");
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }