public function incrementDownloadCounter($hash) { PublicletCounter::increment($hash); }
/** 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()); } }
/** * @static * @param Array $data * @return void */ public static function loadPubliclet($data) { // create driver from $data $className = $data["DRIVER"] . "AccessDriver"; $hash = md5(serialize($data)); $u = parse_url($_SERVER["REQUEST_URI"]); $shortHash = pathinfo(basename($u["path"]), PATHINFO_FILENAME); if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"] || $data["DOWNLOAD_LIMIT"] && $data["DOWNLOAD_LIMIT"] > 0 && $data["DOWNLOAD_LIMIT"] <= PublicletCounter::getCount($shortHash)) { // Remove the publiclet, it's done if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]), realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) { PublicletCounter::delete($shortHash); unlink($_SERVER["SCRIPT_FILENAME"]); } echo "Link is expired, sorry."; exit; } // Load language messages $language = ConfService::getLanguage(); if (isset($_GET["lang"])) { $language = basename($_GET["lang"]); } $messages = array(); if (is_file(dirname(__FILE__) . "/res/i18n/" . $language . ".php")) { include dirname(__FILE__) . "/res/i18n/" . $language . ".php"; } else { include dirname(__FILE__) . "/res/i18n/en.php"; } if (isset($mess)) { $messages = $mess; } $AJXP_LINK_HAS_PASSWORD = false; $AJXP_LINK_BASENAME = SystemTextEncoding::toUTF8(basename($data["FILE_PATH"])); AJXP_PluginsService::getInstance()->initActivePlugins(); $customs = array("title", "legend", "legend_pass", "background_attributes_1", "background_attributes_2", "background_attributes_3", "text_color", "background_color", "textshadow_color"); $images = array("button", "background_1", "background_2", "background_3"); $shareCenter = AJXP_PluginsService::findPlugin("action", "share"); $confs = $shareCenter->getConfigs(); foreach ($customs as $custom) { $varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom); ${$varName} = $confs[$varName]; } $dlFolder = realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER")); foreach ($images as $custom) { $varName = "CUSTOM_SHAREPAGE_" . strtoupper($custom); if (!empty($confs[$varName])) { if (strpos($confs[$varName], "plugins/") === 0 && is_file(AJXP_INSTALL_PATH . "/" . $confs[$varName])) { $realFile = AJXP_INSTALL_PATH . "/" . $confs[$varName]; copy($realFile, $dlFolder . "/binary-" . basename($realFile)); ${$varName} = "binary-" . basename($realFile); } else { ${$varName} = "binary-" . $confs[$varName]; if (is_file($dlFolder . "/binary-" . $confs[$varName])) { continue; } $copiedImageName = $dlFolder . "/binary-" . $confs[$varName]; $imgFile = fopen($copiedImageName, "wb"); ConfService::getConfStorageImpl()->loadBinary(array(), $confs[$varName], $imgFile); fclose($imgFile); } } } HTMLWriter::charsetHeader(); // Check password if (strlen($data["PASSWORD"])) { if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) { //AJXP_PluginsService::getInstance()->initActivePlugins(); $AJXP_LINK_HAS_PASSWORD = true; $AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"]; include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php"; $res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>'; AJXP_Controller::applyHook("tpl.filter_html", array(&$res)); echo $res; return; } } else { if (!isset($_GET["dl"])) { //AJXP_PluginsService::getInstance()->initActivePlugins(); include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php"; $res = '<div style="position: absolute;z-index: 10000; bottom: 0; right: 0; color: #666;font-family: HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;font-size: 13px;text-align: right;padding: 6px; line-height: 20px;text-shadow: 0px 1px 0px white;" class="no_select_bg"><br>Build your own box with Pydio : <a style="color: #000000;" target="_blank" href="http://pyd.io/">http://pyd.io/</a><br/>Community - Free non supported version © C. du Jeu 2008-2014 </div>'; AJXP_Controller::applyHook("tpl.filter_html", array(&$res)); echo $res; return; } } $filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php"; if (!is_file($filePath)) { die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})"); } require_once $filePath; $driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]); $driver->loadManifest(); //$hash = md5(serialize($data)); PublicletCounter::increment($shortHash); //AuthService::logUser($data["OWNER_ID"], "", true); AuthService::logTemporaryUser($data["OWNER_ID"], $shortHash); if (isset($data["SAFE_USER"]) && isset($data["SAFE_PASS"])) { // FORCE SESSION MODE AJXP_Safe::getInstance()->forceSessionCredentialsUsage(); AJXP_Safe::storeCredentials($data["SAFE_USER"], $data["SAFE_PASS"]); } $repoObject = $data["REPOSITORY"]; ConfService::switchRootDir($repoObject->getId()); ConfService::loadRepositoryDriver(); AJXP_PluginsService::getInstance()->initActivePlugins(); try { $params = array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"])); if (isset($data["PLUGINS_DATA"])) { $params["PLUGINS_DATA"] = $data["PLUGINS_DATA"]; } if (isset($_GET["ct"]) && $_GET["ct"] == "true") { $mime = pathinfo($params["file"], PATHINFO_EXTENSION); $editors = AJXP_PluginsService::searchAllManifests("//editor[contains(@mimes,'{$mime}') and @previewProvider='true']", "node", true, true, false); if (count($editors)) { foreach ($editors as $editor) { $xPath = new DOMXPath($editor->ownerDocument); $callbacks = $xPath->query("//action[@contentTypedProvider]", $editor); if ($callbacks->length) { $data["ACTION"] = $callbacks->item(0)->getAttribute("name"); if ($data["ACTION"] == "audio_proxy") { $params["file"] = base64_encode($params["file"]); } break; } } } } AJXP_Controller::findActionAndApply($data["ACTION"], $params, null); register_shutdown_function(array("AuthService", "clearTemporaryUser"), $shortHash); } catch (Exception $e) { AuthService::clearTemporaryUser($shortHash); die($e->getMessage()); } }
/** * @static * @param Array $data * @return void */ static function loadPubliclet($data) { // create driver from $data $className = $data["DRIVER"] . "AccessDriver"; $hash = md5(serialize($data)); if ($data["EXPIRE_TIME"] && time() > $data["EXPIRE_TIME"] || $data["DOWNLOAD_LIMIT"] && $data["DOWNLOAD_LIMIT"] > 0 && $data["DOWNLOAD_LIMIT"] <= PublicletCounter::getCount($hash)) { // Remove the publiclet, it's done if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]), realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) { PublicletCounter::delete($hash); unlink($_SERVER["SCRIPT_FILENAME"]); } echo "Link is expired, sorry."; exit; } // Load language messages $language = "en"; if (isset($_GET["lang"])) { $language = $_GET["lang"]; } $messages = array(); if (is_file(dirname(__FILE__) . "/res/i18n/" . $language . ".php")) { include dirname(__FILE__) . "/res/i18n/" . $language . ".php"; $messages = $mess; } else { include dirname(__FILE__) . "/res/i18n/en.php"; } $AJXP_LINK_HAS_PASSWORD = false; $AJXP_LINK_BASENAME = SystemTextEncoding::toUTF8(basename($data["FILE_PATH"])); // Check password if (strlen($data["PASSWORD"])) { if (!isset($_POST['password']) || $_POST['password'] != $data["PASSWORD"]) { $AJXP_LINK_HAS_PASSWORD = true; $AJXP_LINK_WRONG_PASSWORD = isset($_POST['password']) && $_POST['password'] != $data["PASSWORD"]; include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php"; return; } } else { if (!isset($_GET["dl"])) { include AJXP_INSTALL_PATH . "/plugins/action.share/res/public_links.php"; return; } } $filePath = AJXP_INSTALL_PATH . "/plugins/access." . $data["DRIVER"] . "/class." . $className . ".php"; if (!is_file($filePath)) { die("Warning, cannot find driver for conf storage! ({$className}, {$filePath})"); } require_once $filePath; $driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]); $driver->loadManifest(); $hash = md5(serialize($data)); PublicletCounter::increment($hash); AuthService::logUser($data["OWNER_ID"], "", true); if ($driver->hasMixin("credentials_consumer") && isset($data["SAFE_USER"]) && isset($data["SAFE_PASS"])) { // FORCE SESSION MODE AJXP_Safe::getInstance()->forceSessionCredentialsUsage(); AJXP_Safe::storeCredentials($data["SAFE_USER"], $data["SAFE_PASS"]); } $repoObject = $data["REPOSITORY"]; ConfService::switchRootDir($repoObject->getId()); ConfService::loadRepositoryDriver(); ConfService::initActivePlugins(); try { $params = array("file" => SystemTextEncoding::toUTF8($data["FILE_PATH"])); if (isset($data["PLUGINS_DATA"])) { $params["PLUGINS_DATA"] = $data["PLUGINS_DATA"]; } AJXP_Controller::findActionAndApply($data["ACTION"], $params, null); } catch (Exception $e) { die($e->getMessage()); } }