Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Massive pass to reveal the full powers of groups: use getFilteredOpti…
Browse files Browse the repository at this point in the history
…on() everywhere instead of $this->pluginConfs[]
  • Loading branch information
cdujeu committed Jul 10, 2013
1 parent 0d1ee99 commit 4f47de4
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 193 deletions.
18 changes: 9 additions & 9 deletions core/src/plugins/action.antivirus/class.AntivirusScanner.php
Expand Up @@ -29,7 +29,7 @@ public function scanFile ($oldNode, $newNode) {
if($this->file_size < $this->scan_max_size) {
if($this->scan_all == true) {
if($this->inList()==true) {
if($this->pluginConf["TRACE"] == false) {return;}
if($this->getFilteredOption("TRACE") == false) {return;}
$this->scanLater();
return ;
}else {
Expand All @@ -41,7 +41,7 @@ public function scanFile ($oldNode, $newNode) {
$this->scanNow();
return ;
}else {
if($this->pluginConf["TRACE"] == false) {return;}
if($this->getFilteredOption("TRACE") == false) {return;}
$this->scanLater();
return ;
}
Expand Down Expand Up @@ -75,8 +75,8 @@ private function inList() {
* This function immediatly scans the file, it calls the antivirus command
*/
private function scanNow() {
$command = $this->pluginConf["COMMAND"];
$command = str_replace('$' . 'FILE', '"' . $this->path . '"', $command);
$command = $this->getFilteredOption("COMMAND");
$command = str_replace('$' . 'FILE', escapeshellarg($this->path), $command);

ob_start();
passthru($command, $int);
Expand Down Expand Up @@ -113,7 +113,7 @@ private function scanLater() {
if(file_exists( $this->scan_diff_folder .DIRECTORY_SEPARATOR. 'file_' . $numero)) {
$numero++;
}
else {
else {
$command = 'echo "'. '\"' . $this->path . '\"' . '" >' . $this->scan_diff_folder .DIRECTORY_SEPARATOR. 'file_' . $numero;
passthru($command);
$scanned=true;
Expand Down Expand Up @@ -172,15 +172,15 @@ public function setFileExtension ($nodeObject) {
* This function initializes the extension list
*/
public function setExtensionScan() {
$this->extension_scan = $this->pluginConf["EXT"];
$this->extension_scan = $this->getFilteredOption("EXT");
return ;
}

/**
* this function initializes attribute scan_all
*/
public function setScanAll(){
$extension = $this->pluginConf["EXT"];
$extension = $this->getFilteredOption("EXT");
if(substr($extension, 0, 2) == "*/"){
$this->scan_all = true;
}else{
Expand All @@ -193,15 +193,15 @@ public function setScanAll(){
* this function initializes the trace folder
*/
public function setScanDiffFolder () {
$this->scan_diff_folder = $this->pluginConf["PATH"];
$this->scan_diff_folder = $this->getFilteredOption("PATH");
return ;
}

/**
* this function initializes max size of the scanned file
*/
public function setScanMaxSize () {
$this->scan_max_size = AJXP_Utils::convertBytes($this->pluginConf["SIZE"]);
$this->scan_max_size = AJXP_Utils::convertBytes($this->getFilteredOption("SIZE"));
return ;
}

Expand Down
20 changes: 11 additions & 9 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -474,7 +474,7 @@ function writePubliclet(&$data, $accessDriver, $repository)
* @return string
*/
public function computeHash($outputData, $checkInFolder = null){
$length = $this->pluginConf["HASH_MIN_LENGTH"];
$length = $this->getFilteredOption("HASH_MIN_LENGTH", $this->repository->getId());
$full = md5($outputData);
$starter = substr($full, 0, $length);
if($checkInFolder != null){
Expand Down Expand Up @@ -518,7 +518,7 @@ function computeMinisiteToServerURL(){

function buildPublicletLink($hash){
$addLang = ConfService::getLanguage() != ConfService::getCoreConf("DEFAULT_LANGUAGE");
if($this->pluginConf["USE_REWRITE_RULE"] == true){
if($this->getFilteredOption("USE_REWRITE_RULE", $this->repository->getId()) == true){
if($addLang) return $this->buildPublicDlURL()."/".$hash."-".ConfService::getLanguage();
else return $this->buildPublicDlURL()."/".$hash;
}else{
Expand Down Expand Up @@ -551,7 +551,7 @@ function initPublicFolder($downloadFolder){
@copy(AJXP_INSTALL_PATH."/server/index.html", $downloadFolder."/index.html");
$dlUrl = $this->buildPublicDlURL();
$htaccessContent = "ErrorDocument 404 ".$dlUrl."/404.html\n<Files \".ajxp_*\">\ndeny from all\n</Files>";
if($this->pluginConf["USE_REWRITE_RULE"] == true){
if($this->getFilteredOption("USE_REWRITE_RULE", $this->repository->getId()) == true){
$path = parse_url($dlUrl, PHP_URL_PATH);
$htaccessContent .= '
<IfModule mod_rewrite.c>
Expand Down Expand Up @@ -833,8 +833,9 @@ function createSharedMinisite($httpVars, $repository, $accessDriver){
if(isSet($httpVars["create_guest_user"])){
// Create a guest user
$userId = substr(md5(time()), 0, 12);
if(!empty($this->pluginConf["SHARED_USERS_TMP_PREFIX"])){
$userId = $this->pluginConf["SHARED_USERS_TMP_PREFIX"].$userId;
$pref = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId());
if(!empty($pref)){
$userId = $pref.$userId;
}
$userPass = substr(md5(time()), 13, 24);
$httpVars["user_0"] = $userId;
Expand Down Expand Up @@ -921,6 +922,7 @@ function createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUs
$groups = array();

$index = 0;
$prefix = $this->getFilteredOption("SHARED_USERS_TMP_PREFIX", $this->repository->getId());
while(isSet($httpVars["user_".$index])){
$eType = $httpVars["entry_type_".$index];
$rightString = ($httpVars["right_read_".$index]=="true"?"r":"").($httpVars["right_write_".$index]=="true"?"w":"");
Expand All @@ -936,9 +938,9 @@ function createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUs
}else if(AuthService::userExists($u) && isSet($httpVars["user_pass_".$index])){
throw new Exception("User $u already exists, please choose another name.");
}
if(!AuthService::userExists($u, "w") && !empty($this->pluginConf["SHARED_USERS_TMP_PREFIX"])
&& strpos($u, $this->pluginConf["SHARED_USERS_TMP_PREFIX"])!==0 ){
$u = $this->pluginConf["SHARED_USERS_TMP_PREFIX"] . $u;
if(!AuthService::userExists($u, "w") && !empty($prefix)
&& strpos($u, $prefix)!==0 ){
$u = $prefix . $u;
}
$users[] = $u;
}else{
Expand All @@ -960,7 +962,7 @@ function createSharedRepository($httpVars, $repository, $accessDriver, $uniqueUs
}

// CHECK USER & REPO DOES NOT ALREADY EXISTS
if($this->pluginConf["AVOID_SHARED_FOLDER_SAME_LABEL"]){
if( $this->getFilteredOption("AVOID_SHARED_FOLDER_SAME_LABEL", $this->repository->getId()) == true) {
$repos = ConfService::getRepositoriesList();
foreach ($repos as $obj){
if($obj->getDisplay() == $label && (!isSet($editingRepo) || $editingRepo != $obj)){
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/action.skeleton/class.PluginSkeleton.php
Expand Up @@ -41,10 +41,10 @@ public function parseSpecificContributions(&$contribNode){
$actionXpath=new DOMXPath($contribNode->ownerDocument);
$footerTplNodeList = $actionXpath->query('template[@name="bottom"]', $contribNode);
$footerTplNode = $footerTplNodeList->item(0);
if(!$this->pluginConf["SHOW_CUSTOM_FOOTER"]){
if(!$this->getFilteredOption("SHOW_CUSTOM_FOOTER")){
$contribNode->removeChild($footerTplNode);
}else{
$content = $this->pluginConf["CUSTOM_FOOTER_CONTENT"];
$content = $this->getFilteredOption("CUSTOM_FOOTER_CONTENT");
$content = str_replace("\\n", "<br>", $content);
$cdata = '<div id="optional_bottom_div" style="font-family:arial;padding:10px;">'.$content.'</div>';
$cdataSection = $contribNode->ownerDocument->createCDATASection($cdata);
Expand Down
15 changes: 8 additions & 7 deletions core/src/plugins/action.timestamp/class.TimestampCreator.php
Expand Up @@ -12,18 +12,19 @@ class TimestampCreator extends AJXP_Plugin
function switchAction($action, $httpVars, $fileVars){

$mess = ConfService::getMessages();

//Check if the configuration has been initiated
if(!isSet($this->pluginConf["TIMESTAMP_URL"]) || !isSet($this->pluginConf["USER"]) || !isSet($this->pluginConf["PASS"]) ){

$timestamp_url = $this->getFilteredOption("TIMESTAMP_URL");
$timestamp_login = $this->getFilteredOption("USER");
$timestamp_password = $this->getFilteredOption("PASS");

//Check if the configuration has been initiated
if(empty($timestamp_url) || empty($timestamp_login) || !empty($timestamp_password) ){
throw new AJXP_Exception($mess["timestamp.4"]);
AJXP_Logger::logAction("error", "TimeStamp : configuration is needed");
return false;
}

$timestamp_url = $this->pluginConf["TIMESTAMP_URL"];
$timestamp_login = $this->pluginConf["USER"];
$timestamp_password = $this->pluginConf["PASS"];


//Check if after being initiated, conf. fields have some values
if(strlen($timestamp_url)<2 || strlen($timestamp_login)<2 || strlen($timestamp_password)<2 ){
throw new AJXP_Exception($mess["timestamp.4"]);
Expand Down
5 changes: 3 additions & 2 deletions core/src/plugins/cypher.encfs/class.EncfsMounter.php
Expand Up @@ -81,10 +81,11 @@ public function preProcessMove($actionName, &$httpVars, &$fileVars){
public function switchAction($actionName, $httpVars, $fileVars){

//var_dump($httpVars);
$xmlTemplate = $this->getFilteredOption("ENCFS_XML_TEMPLATE");

switch($actionName){
case "encfs.cypher_folder" :
if(empty($this->pluginConf["ENCFS_XML_TEMPLATE"]) || !is_file($this->pluginConf["ENCFS_XML_TEMPLATE"])){
if(empty($xmlTemplate) || !is_file($xmlTemplate)){
throw new Exception("It seems that you have not set the plugin 'Enfcs XML File' configuration, or the system cannot find it!");
}
$dir = $this->getWorkingPath().AJXP_Utils::decodeSecureMagic($httpVars["dir"]);
Expand All @@ -98,7 +99,7 @@ public function switchAction($actionName, $httpVars, $fileVars){
$clear = dirname($dir).DIRECTORY_SEPARATOR."ENCFS_CLEAR_".basename($dir);

mkdir($raw);
$result = self::initEncFolder($raw, $this->pluginConf["ENCFS_XML_TEMPLATE"], $this->pluginConf["ENCFS_XML_PASSWORD"], $pass);
$result = self::initEncFolder($raw, $xmlTemplate, $this->getFilteredOption("ENCFS_XML_PASSWORD"), $pass);
if($result){
// Mount folder
mkdir($clear);
Expand Down
8 changes: 4 additions & 4 deletions core/src/plugins/editor.diaporama/class.ImagePreviewer.php
Expand Up @@ -51,7 +51,7 @@ public function switchAction($action, $httpVars, $filesVars){
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if(!file_exists($destStreamURL.$file)) return;

if(isSet($httpVars["get_thumb"]) && $this->pluginConf["GENERATE_THUMBNAIL"]){
if(isSet($httpVars["get_thumb"]) && $this->getFilteredOption("GENERATE_THUMBNAIL", $repository->getId())){
$dimension = 200;
if(isSet($httpVars["dimension"]) && is_numeric($httpVars["dimension"])) $dimension = $httpVars["dimension"];
$this->currentDimension = $dimension;
Expand Down Expand Up @@ -116,7 +116,7 @@ public function removeThumbnail($oldFile, $newFile = null, $copy = false){
public function generateThumbnail($masterFile, $targetFile){
$size = $this->currentDimension;
require_once(AJXP_INSTALL_PATH."/plugins/editor.diaporama/PThumb.lib.php");
$pThumb = new PThumb($this->pluginConf["THUMBNAIL_QUALITY"]);
$pThumb = new PThumb($this->getFilteredOption("THUMBNAIL_QUALITY"));
if(!$pThumb->isError()){
$pThumb->remote_wrapper = $this->streamData["classname"];
//AJXP_Logger::debug("Will fit thumbnail");
Expand Down Expand Up @@ -148,11 +148,11 @@ public function extractImageMetadata(&$ajxpNode){
$ajxpNode->is_image = $isImage;
if(!$isImage) return;
$setRemote = false;
$remoteWrappers = $this->pluginConf["META_EXTRACTION_REMOTEWRAPPERS"];
$remoteWrappers = $this->getFilteredOption("META_EXTRACTION_REMOTEWRAPPERS");
if(is_string($remoteWrappers)){
$remoteWrappers = explode(",",$remoteWrappers);
}
$remoteThreshold = $this->pluginConf["META_EXTRACTION_THRESHOLD"];
$remoteThreshold = $this->getFilteredOption("META_EXTRACTION_THRESHOLD");
if(in_array($wrapperClassName, $remoteWrappers)){
if($remoteThreshold != 0 && isSet($ajxpNode->bytesize)){
$setRemote = ($ajxpNode->bytesize > $remoteThreshold);
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/editor.etherpad/class.EtherpadClient.php
Expand Up @@ -28,8 +28,8 @@ class EtherpadClient extends AJXP_Plugin{

public function switchAction($actionName, $httpVars, $fileVars){

$this->baseURL = rtrim($this->pluginConf["ETHERPAD_SERVER"], "/");
$this->apiKey = $this->pluginConf["ETHERPAD_APIKEY"];
$this->baseURL = rtrim($this->getFilteredOption("ETHERPAD_SERVER"), "/");
$this->apiKey = $this->getFilteredOption("ETHERPAD_APIKEY");

if(isSet($httpVars["file"])){

Expand Down
37 changes: 22 additions & 15 deletions core/src/plugins/editor.imagick/class.IMagickPreviewer.php
Expand Up @@ -53,12 +53,13 @@ public function switchAction($action, $httpVars, $filesVars){
if(!$repository->detectStreamWrapper(true)){
return false;
}
if(!is_array($this->pluginConf) || !isSet($this->pluginConf["IMAGE_MAGICK_CONVERT"])){
$convert = $this->getFilteredOption("IMAGE_MAGICK_CONVERT");
if(empty($convert)){
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"]."://".$repository->getId();
$flyThreshold = 1024*1024*intval($this->pluginConf["ONTHEFLY_THRESHOLD"]);
$flyThreshold = 1024*1024*intval($this->getFilteredOption("ONTHEFLY_THRESHOLD", $repository->getId()));

if($action == "imagick_data_proxy"){
$this->extractAll = false;
Expand Down Expand Up @@ -175,7 +176,8 @@ protected function listExtractedJpg($prefix){
protected function listPreviewFiles($file, $prefix){
$files = array();
$index = 0;
if(isset($this->pluginConf["UNOCONV"]) && !empty($this->pluginConf["UNOCONV"])){
$unoconv = $this->getFilteredOption("UNOCONV");
if(!empty($unoconv)){
$officeExt = array('xls', 'xlsx', 'ods', 'doc', 'docx', 'odt', 'ppt', 'pptx', 'odp', 'rtf');
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if(in_array($extension, $officeExt)){
Expand All @@ -199,11 +201,12 @@ protected function listPreviewFiles($file, $prefix){
}

public function generateJpegsCallback($masterFile, $targetFile){
$unoconv = false;
if(isset($this->pluginConf["UNOCONV"]) && !empty($this->pluginConf["UNOCONV"])){
$unoconv = $this->pluginConf["UNOCONV"];
$unoconv = $this->getFilteredOption("UNOCONV");
if(!empty($unoconv)){
$officeExt = array('xls', 'xlsx', 'ods', 'doc', 'docx', 'odt', 'ppt', 'pptx', 'odp', 'rtf');
}
}else{
$unoconv = false;
}

$extension = strtolower(pathinfo($masterFile, PATHINFO_EXTENSION));
$node = new AJXP_Node($masterFile);
Expand Down Expand Up @@ -236,7 +239,7 @@ public function generateJpegsCallback($masterFile, $targetFile){
$unoDoc = str_replace(".jpg", "_unoconv.pdf", $tmpFileThumb);
if(!is_file($tmpFileThumb)){
// Create PDF Version now
$unoconv = "HOME=/tmp ".$this->pluginConf["UNOCONV"]." --stdout -f pdf ".escapeshellarg($masterFile)." > ".escapeshellarg(basename($unoDoc));
$unoconv = "HOME=/tmp ".$unoconv." --stdout -f pdf ".escapeshellarg($masterFile)." > ".escapeshellarg(basename($unoDoc));
exec($unoconv, $out, $return);
}
if(is_file($unoDoc)){
Expand All @@ -258,15 +261,19 @@ public function generateJpegsCallback($masterFile, $targetFile){
}
}

if(!isSet($this->pluginConf["IM_CUSTOM_OPTIONS"])){
$this->pluginConf["IM_CUSTOM_OPTIONS"] = "";
$customOptions = $this->getFilteredOption("IM_CUSTOM_OPTIONS");
$customEnvPath = $this->getFilteredOption("ADDITIONAL_ENV_PATH");
$viewerQuality = $this->getFilteredOption("IM_VIEWER_QUALITY");
$thumbQuality = $this->getFilteredOption("IM_THUMB_QUALITY");
if(empty($customOptions)){
$customOptions = "";
}
if(iSset($this->pluginConf["ADDITIONAL_ENV_PATH"]) && !empty($this->pluginConf["ADDITIONAL_ENV_PATH"])){
putenv("PATH=".getenv("PATH").":".$this->pluginConf["ADDITIONAL_ENV_PATH"]);
if(!empty($customEnvPath)){
putenv("PATH=".getenv("PATH").":".$customEnvPath);
}
$params = ($this->extractAll?"-quality ".$this->pluginConf["IM_VIEWER_QUALITY"]:"-resize 250 ".$this->pluginConf["IM_CUSTOM_OPTIONS"]." -quality ".$this->pluginConf["IM_THUMB_QUALITY"]);
$cmd = $this->pluginConf["IMAGE_MAGICK_CONVERT"]." ".escapeshellarg(($masterFile).$pageLimit)." ".$params." ".escapeshellarg($tmpFileThumb);
AJXP_Logger::logAction("IMagick Command : $cmd");
$params = ($this->extractAll?"-quality ".$viewerQuality:"-resize 250 ".$customOptions." -quality ".$thumbQuality);
$cmd = $this->getFilteredOption("IMAGE_MAGICK_CONVERT")." ".escapeshellarg(($masterFile).$pageLimit)." ".$params." ".escapeshellarg($tmpFileThumb);
AJXP_Logger::debug("IMagick Command : $cmd");
session_write_close(); // Be sure to give the hand back
exec($cmd, $out, $return);
if(is_array($out) && count($out)){
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/editor.pixlr/class.PixlrEditor.php
Expand Up @@ -58,7 +58,7 @@ public function switchAction($action, $httpVars, $filesVars){
$postData = array();
$httpClient->setHandleRedirects(false);
$saveTarget = $target."/fake_save_pixlr.php";
if($this->pluginConf["CHECK_SECURITY_TOKEN"]){
if($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())){
$saveTarget = $target."/fake_save_pixlr_".md5($httpVars["secure_token"]).".php";
}
$params = array(
Expand All @@ -84,7 +84,7 @@ public function switchAction($action, $httpVars, $filesVars){
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if($this->pluginConf["CHECK_SECURITY_TOKEN"]){
if($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())){
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if($token != md5($httpVars["secure_token"])){
Expand Down
11 changes: 5 additions & 6 deletions core/src/plugins/editor.zoho/class.ZohoEditor.php
Expand Up @@ -74,19 +74,18 @@ public function switchAction($action, $httpVars, $filesVars){
$_SESSION["ZOHO_CURRENT_EDITED"] = $destStreamURL.$file;
$_SESSION["ZOHO_CURRENT_UUID"] = md5(rand()."-".microtime());

if($this->pluginConf["USE_ZOHO_AGENT"]){
$saveUrl = $this->pluginConf["ZOHO_AGENT_URL"];
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";
}


$params = array(
'id' => $_SESSION["ZOHO_CURRENT_UUID"],
'apikey' => $this->pluginConf["ZOHO_API_KEY"],
'apikey' => $this->getFilteredOption("ZOHO_API_KEY", $repository->getId()),
'output' => 'url',
'lang' => "en",
//'skey'=> $this->pluginConf["ZOHO_SECRET_KEY"],
'filename' => urlencode(basename($file)),
'persistence' => 'false',
'format' => $extension,
Expand Down Expand Up @@ -143,8 +142,8 @@ public function switchAction($action, $httpVars, $filesVars){
$node->loadNodeInfo();
AJXP_Controller::applyHook("node.before_change", array(&$node));

if($this->pluginConf["USE_ZOHO_AGENT"]){
$data = AJXP_Utils::getRemoteContent($this->pluginConf["ZOHO_AGENT_URL"]."?ajxp_action=get_file&name=".$id);
if($this->getFilteredOption("USE_ZOHO_AGENT",$repository->getId()) ){
$data = AJXP_Utils::getRemoteContent( $this->getFilteredOption("ZOHO_AGENT_URL",$repository->getId())."?ajxp_action=get_file&name=".$id);
if(strlen($data)){
file_put_contents($targetFile, $data);
echo "MODIFIED";
Expand Down

0 comments on commit 4f47de4

Please sign in to comment.