public function jumploaderInstallApplet($params) { if (is_file($this->getBaseDir() . "/jumploader_z.jar")) { return "ERROR: The applet is already installed!"; } $fileData = AJXP_Utils::getRemoteContent("http://jumploader.com/jar/jumploader_z.jar"); if (!is_writable($this->getBaseDir())) { file_put_contents(AJXP_CACHE_DIR . "/jumploader_z.jar", $fileData); return "ERROR: The applet was downloaded, but the folder plugins/uploader.jumploader is not writeable. Applet is located in the cache folder, please put it manually in the plugin folder."; } else { file_put_contents($this->getBaseDir() . "/jumploader_z.jar", $fileData); return "SUCCESS: Installed applet successfully!"; } }
public function postProcess($action, $httpVars, $params) { $jsonData = json_decode($params["ob_output"], true); if ($jsonData != false) { $url = $jsonData["publiclet_link"]; $elementId = $jsonData["element_id"]; } else { $url = $params["ob_output"]; $elementId = -1; } $BITLY_USER = $this->getFilteredOption("BITLY_USER"); $BITLY_APIKEY = $this->getFilteredOption("BITLY_APIKEY"); if (empty($BITLY_USER) || empty($BITLY_APIKEY)) { print $url; $this->logError("Config", "Bitly Shortener : you must drop the conf.shorten.bitly.inc file inside conf.php and set the login/api key!"); return; } $bitly_login = $BITLY_USER; $bitly_api = $BITLY_APIKEY; $format = 'json'; $version = '2.0.1'; $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $bitly_api . '&format=' . $format; $response = AJXP_Utils::getRemoteContent($bitly); $json = json_decode($response, true); if (isset($json['results'][$url]['shortUrl'])) { print $json['results'][$url]['shortUrl']; $this->updateMetaShort($httpVars["file"], $elementId, $json['results'][$url]['shortUrl']); } else { print $url; } }
public function postProcess($action, $httpVars, $params) { $url = $params["ob_output"]; if (!isset($this->pluginConf["BITLY_USER"]) || !isset($this->pluginConf["BITLY_APIKEY"])) { print $url; AJXP_Logger::logAction("error", "Bitly Shortener : you must drop the conf.shorten.bitly.inc file inside conf.php and set the login/api key!"); return; } $bitly_login = $this->pluginConf["BITLY_USER"]; $bitly_api = $this->pluginConf["BITLY_APIKEY"]; $format = 'json'; $version = '2.0.1'; $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $bitly_api . '&format=' . $format; $response = AJXP_Utils::getRemoteContent($bitly); $json = json_decode($response, true); if (isset($json['results'][$url]['shortUrl'])) { print $json['results'][$url]['shortUrl']; $this->updateMetaShort($httpVars["file"], $json['results'][$url]['shortUrl']); } else { print $url; } }
public function downloadArchive() { $this->archive = $this->workingFolder . "/" . basename($this->archiveURL); if ($this->debugMode && is_file($this->archive)) { return "Already downloaded"; } if (self::$context) { $content = file_get_contents($this->archiveURL, null, self::$context); } else { $content = AJXP_Utils::getRemoteContent($this->archiveURL); } if ($content === false || strlen($content) == 0) { throw new Exception("Error while downloading"); } file_put_contents($this->archive, $content); return "File saved in " . $this->archive; }
public function postProcess($action, $httpVars, $params) { $type = $this->getFilteredOption("SHORTEN_TYPE"); if (empty($type)) { return; } $jsonData = json_decode($params["ob_output"], true); $elementId = -1; if ($jsonData != false) { $url = $jsonData["publiclet_link"]; $elementId = $jsonData["element_id"]; } else { $url = $params["ob_output"]; } switch (intval($type["shorten_type"])) { case 0: if (!isset($type["ADFLY_TYPE"]) || !isset($type["ADFLY_APIKEY"]) || !isset($type["ADFLY_UID"]) || !isset($type["ADFLY_DOMAIN"])) { print $url; $this->logError("Config", "adFly Shortener : you must set the api key!"); return; } $adfly_type = $type["ADFLY_TYPE"]; $adfly_api = $type["ADFLY_APIKEY"]; $adfly_uid = $type["ADFLY_UID"]; $adfly_dom = $type["ADFLY_DOMAIN"]; $adfly = 'http://api.adf.ly/api.php?key=' . $adfly_api . '&uid=' . $adfly_uid . '&advert_type=' . $adfly_type . '&domain=' . $adfly_dom . '&url=' . urlencode($url); $response = AJXP_Utils::getRemoteContent($adfly); $response = strip_tags($response, '<body>'); $response = strip_tags($response); if (isset($response)) { print $response; $this->updateMetaShort($httpVars["file"], $elementId, $response); } else { print $url; } break; case 1: if (!isset($type["BITLY_USER"]) || !isset($type["BITLY_APIKEY"])) { print $url; $this->logError("Config", "Bitly Shortener : you must drop the conf.shorten.bitly.inc file inside conf.php and set the login/api key!"); return; } $bitly_login = $type["BITLY_USER"]; $bitly_api = $type["BITLY_APIKEY"]; $format = 'json'; $version = '2.0.1'; $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $bitly_api . '&format=' . $format; $response = AJXP_Utils::getRemoteContent($bitly); $json = json_decode($response, true); if (isset($json['results'][$url]['shortUrl'])) { print $json['results'][$url]['shortUrl']; $this->updateMetaShort($httpVars["file"], $elementId, $json['results'][$url]['shortUrl']); } else { print $url; } break; case 2: if (!isset($type["GOOGL_APIKEY"])) { print $url; $this->logError("Config", "Goo.gl Shortener : you must set the api key!"); return; } $data = array('longUrl' => $url, 'key' => $type["GOOGL_APIKEY"]); $options = array('http' => array('method' => 'POST', 'content' => json_encode($data), 'header' => "Content-Type: application/json\r\n" . "Accept: application/json\r\n")); $goourl = 'https://www.googleapis.com/urlshortener/v1/url'; $context = stream_context_create($options); $result = file_get_contents($goourl, false, $context); $json = (array) json_decode($result); if (isset($json['id'])) { print $json['id']; $this->updateMetaShort($httpVars["file"], $elementId, $json['id']); } else { print $url; } break; case 3: if (!isset($type["POST_APIKEY"])) { print $url; $this->logError("Config", "po.st Shortener : you must set the api key!"); return; } $post_api = $type["POST_APIKEY"]; $post = 'http://po.st/api/shorten?longUrl=' . urlencode($url) . '&apiKey=' . $post_api . '&format=txt'; $response = AJXP_Utils::getRemoteContent($post); if (isset($response)) { print $response; $this->updateMetaShort($httpVars["file"], $elementId, $response); } else { print $url; } break; case 4: if (!isset($type["YOURLS_DOMAIN"])) { print $url; $this->logError("Config", "yourls Shortener : you must set the domain name"); return; } if (!isset($type["YOURLS_APIKEY"])) { print $url; $this->logError("Config", "yourls Shortener : you must set the api key"); return; } $useidn = false; if (isset($type["YOURLS_USEIDN"])) { $useidn = $type["YOURLS_USEIDN"]; } $yourls_domain = $type["YOURLS_DOMAIN"]; $yourls_api = $type["YOURLS_APIKEY"]; $yourls = 'http://' . $yourls_domain . '/yourls-api.php?signature=' . $yourls_api . '&action=shorturl&format=simple&url=' . urlencode($url); $response = AJXP_Utils::getRemoteContent($yourls); if (isset($response)) { $shorturl = $response; if ($useidn) { // WARNING: idn_to_utf8 requires php-idn module. // WARNING: http_build_url requires php-pecl-http module. $purl = parse_url($shorturl); $purl['host'] = idn_to_utf8($purl['host']); $shorturl = http_build_url($purl); } print $shorturl; $this->updateMetaShort($httpVars["file"], $elementId, $shorturl); } else { print $url; } break; } }
public function switchAction($action, $httpVars, $filesVars) { if (!isset($this->actions[$action])) { return false; } $repository = ConfService::getRepository(); if (!$repository->detectStreamWrapper(true)) { return false; } $streamData = $repository->streamData; $destStreamURL = $streamData["protocol"] . "://" . $repository->getId(); if ($action == "post_to_zohoserver") { $sheetExt = explode(",", "xls,xlsx,ods,sxc,csv,tsv"); $presExt = explode(",", "ppt,pps,odp,sxi"); $docExt = explode(",", "doc,docx,rtf,odt,sxw"); require_once AJXP_BIN_FOLDER . "/http_class/http_class.php"; $selection = new UserSelection($repository, $httpVars); // Backward compat if (strpos($httpVars["file"], "base64encoded:") !== 0) { $file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"])); } else { $file = $selection->getUniqueFile(); } $target = base64_decode($httpVars["parent_url"]); $tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file); $tmp = SystemTextEncoding::fromUTF8($tmp); $node = new AJXP_Node($destStreamURL . $file); AJXP_Controller::applyHook("node.read", array($node)); $this->logInfo('Preview', 'Posting content of ' . $file . ' to Zoho server'); $extension = strtolower(pathinfo(urlencode(basename($file)), PATHINFO_EXTENSION)); $httpClient = new http_class(); $httpClient->request_method = "POST"; $secureToken = $httpVars["secure_token"]; $_SESSION["ZOHO_CURRENT_EDITED"] = $destStreamURL . $file; $_SESSION["ZOHO_CURRENT_UUID"] = md5(rand() . "-" . microtime()); if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) { $saveUrl = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId()); } else { $saveUrl = $target . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/save_zoho.php"; } $b64Sig = $this->signID($_SESSION["ZOHO_CURRENT_UUID"]); $params = array('id' => $_SESSION["ZOHO_CURRENT_UUID"], 'apikey' => $this->getFilteredOption("ZOHO_API_KEY", $repository->getId()), 'output' => 'url', 'lang' => "en", 'filename' => urlencode(basename($file)), 'persistence' => 'false', 'format' => $extension, 'mode' => 'normaledit', 'saveurl' => $saveUrl . "?signature=" . $b64Sig); $service = "exportwriter"; if (in_array($extension, $sheetExt)) { $service = "sheet"; } else { if (in_array($extension, $presExt)) { $service = "show"; } else { if (in_array($extension, $docExt)) { $service = "exportwriter"; } } } $arguments = array(); $httpClient->GetRequestArguments("https://" . $service . ".zoho.com/remotedoc.im", $arguments); $arguments["PostValues"] = $params; $arguments["PostFiles"] = array("content" => array("FileName" => $tmp, "Content-Type" => "automatic/name")); $err = $httpClient->Open($arguments); if (empty($err)) { $err = $httpClient->SendRequest($arguments); if (empty($err)) { $response = ""; while (true) { $body = ""; $error = $httpClient->ReadReplyBody($body, 1000); if ($error != "" || strlen($body) == 0) { break; } $response .= $body; } $result = trim($response); $matchlines = explode("\n", $result); $resultValues = array(); foreach ($matchlines as $line) { list($key, $val) = explode("=", $line, 2); $resultValues[$key] = $val; } if ($resultValues["RESULT"] == "TRUE" && isset($resultValues["URL"])) { header("Location: " . $resultValues["URL"]); } else { echo "Zoho API Error " . $resultValues["ERROR_CODE"] . " : " . $resultValues["WARNING"]; echo "<script>window.parent.setTimeout(function(){parent.hideLightBox();}, 2000);</script>"; } } $httpClient->Close(); } } else { if ($action == "retrieve_from_zohoagent") { $targetFile = $_SESSION["ZOHO_CURRENT_EDITED"]; $id = $_SESSION["ZOHO_CURRENT_UUID"]; $ext = pathinfo($targetFile, PATHINFO_EXTENSION); $node = new AJXP_Node($targetFile); $node->loadNodeInfo(); AJXP_Controller::applyHook("node.before_change", array(&$node)); $b64Sig = $this->signID($id); if ($this->getFilteredOption("USE_ZOHO_AGENT", $repository->getId())) { $url = $this->getFilteredOption("ZOHO_AGENT_URL", $repository->getId()) . "?ajxp_action=get_file&name=" . $id . "&ext=" . $ext . "&signature=" . $b64Sig; $data = AJXP_Utils::getRemoteContent($url); if (strlen($data)) { file_put_contents($targetFile, $data); echo "MODIFIED"; } } else { if (is_file(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext)) { copy(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext, $targetFile); unlink(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.zoho/agent/files/" . $id . "." . $ext); echo "MODIFIED"; } } $this->logInfo('Edit', 'Retrieved content of ' . $node->getUrl()); AJXP_Controller::applyHook("node.change", array(null, &$node)); } } }