Exemplo n.º 1
0
    /**
     * constructor
     *
     */
    function __construct()
    {
    	//check if the session folder read and writable
    		$dir = new file();
	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
	        {
	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
	           {
	              die('Unable to create session folder.');
	           }
	        }
    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
    		{
    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
    		}    		
    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
    		{
    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
    		}
    	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
        $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
        $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
        $this->gcLogFile = $this->dir  . $this->gcLogFileName;
       	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
        $this->init();    	
    }
Exemplo n.º 2
0
 /**
  * get the file according to the search keywords
  *
  */
 function doSearch($baseFolderPath = null)
 {
     $baseFolderPath = addTrailingSlash(backslashToSlash(is_null($baseFolderPath) ? $this->rootFolder : $baseFolderPath));
     $dirHandler = @opendir($baseFolderPath);
     if ($dirHandler) {
         while (false !== ($file = readdir($dirHandler))) {
             if ($file != '.' && $file != '..') {
                 $path = $baseFolderPath . $file;
                 if (is_file($path)) {
                     $isValid = true;
                     $fileTime = @filemtime($path);
                     $fileSize = @filesize($path);
                     if ($this->searchkeywords['name'] !== '' && @eregi($this->searchkeywords['name'], $file) === false) {
                         $isValid = false;
                     }
                     if ($this->searchkeywords['mtime_from'] != '' && $fileTime < @strtotime($this->searchkeywords['mtime_from'])) {
                         $isValid = false;
                     }
                     if ($this->searchkeywords['mtime_to'] != '' && $fileTime > @strtotime($this->searchkeywords['mtime_to'])) {
                         $isValid = false;
                     }
                     if ($this->searchkeywords['size_from'] != '' && $fileSize < @strtotime($this->searchkeywords['size_from'])) {
                         $isValid = false;
                     }
                     if ($this->searchkeywords['size_to'] != '' && $fileSize > @strtotime($this->searchkeywords['size_to'])) {
                         $isValid = false;
                     }
                     if ($isValid && isListingDocument($path)) {
                         $finalPath = $path;
                         $objFile = new file($finalPath);
                         $tem = $objFile->getFileInfo();
                         $obj = new manager($finalPath, false);
                         $obj->setSessionAction($this->sessionAction);
                         $selectedDocuments = $this->sessionAction->get();
                         $fileType = $obj->getFileType($finalPath);
                         foreach ($fileType as $k => $v) {
                             $tem[$k] = $v;
                         }
                         $tem['path'] = backslashToSlash($finalPath);
                         $tem['type'] = is_dir($finalPath) ? 'folder' : 'file';
                         /*$tem['size'] = transformFileSize($tem['size']);
                         		$tem['ctime'] = date(DATE_TIME_FORMAT, $tem['ctime']);
                         		$tem['mtime'] = date(DATE_TIME_FORMAT, $tem['mtime']);*/
                         $tem['flag'] = array_search($tem['path'], $selectedDocuments) !== false ? $this->sessionAction->getAction() == "copy" ? 'copyFlag' : 'cutFlag' : 'noFlag';
                         $tem['url'] = getFileUrl($tem['path']);
                         $this->rootFolderInfo['file']++;
                         $manager = null;
                         $this->files[] = $tem;
                         $tem = null;
                     }
                 } elseif (is_dir($path) && $this->searchkeywords['recursive']) {
                     $this->doSearch($path);
                     // For Chamilo this line replaces $this->Search($baseFolderPath); to run the search recursively from the root directory
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 $history->add($sessionImageInfo);
 if (CONFIG_SYS_DEMO_ENABLE) {
     //demo only
     if (isset($originalSessionImageInfo) && sizeof($originalSessionImageInfo)) {
         $imagePath = $sessionDir . $originalSessionImageInfo['info']['name'];
     } else {
         $imagePath = $sessionDir . uniqid(md5(time())) . "." . getFileExt($_POST['path']);
     }
 } else {
     if ($isSaveAsRequest) {
         //save as request
         //check save to folder if exists
         if (isset($_POST['save_to']) && strlen($_POST['save_to'])) {
             $imagePath = $originalImage;
         } else {
             $imagePath = addTrailingSlash(backslashToSlash($_POST['save_to'])) . $_POST['new_name'] . "." . getFileExt($_POST['path']);
         }
         if (!file_exists($_POST['save_to']) || !is_dir($_POST['save_to'])) {
             $error = IMG_SAVE_AS_FOLDER_NOT_FOUND;
         } elseif (file_exists($imagePath)) {
             $error = IMG_SAVE_AS_NEW_IMAGE_EXISTS;
         } elseif (!preg_match("/^[a-zA-Z0-9_\\- ]+\$/", $_POST['new_name'])) {
             $error = IMG_SAVE_AS_ERR_NAME_INVALID;
         }
     } else {
         //save request
         $imagePath = $originalImage;
     }
 }
 if ($image->saveImage($imagePath)) {
     if (CONFIG_SYS_DEMO_ENABLE) {
Exemplo n.º 4
0
 function delete($file, $recursive = false, $type = false)
 {
     $file = $this->fixPath($file);
     if ('f' === $type || $this->isFile($file)) {
         return $this->link->delete($file);
     }
     if (!$recursive) {
         return $this->link->rmdir($file);
     }
     //At this point its a folder, and we're in recursive mode
     $file = addTrailingSlash($file);
     $filelist = $this->dirlist($file, true);
     $retval = true;
     if (is_array($filelist)) {
         //false if no files, So check first.
         foreach ($filelist as $filename => $fileinfo) {
             if (!$this->delete($file . $filename, $recursive, $fileinfo['type'])) {
                 $retval = false;
             }
         }
     }
     if ($this->exists($file) && !$this->link->rmdir($file)) {
         $retval = false;
     }
     return $retval;
 }
Exemplo n.º 5
0
 public static function getThumbURL($phpThumbParams, $onpub_dir_phpthumb = '')
 {
     global $PHPTHUMB_CONFIG;
     $vendor_dir = addTrailingSlash(dirname(dirname(dirname(__DIR__))));
     $phpthumb_config_file = $vendor_dir . 'james-heinrich/phpthumb/phpThumb.config.php';
     if (!$onpub_dir_phpthumb) {
         $onpub_dir_phpthumb = '../vendor/james-heinrich/phpthumb/';
     }
     if (file_exists($phpthumb_config_file)) {
         require_once $phpthumb_config_file;
         if (isset($PHPTHUMB_CONFIG['high_security_enabled']) && $PHPTHUMB_CONFIG['high_security_enabled']) {
             return $onpub_dir_phpthumb . 'phpThumb.php?' . $phpThumbParams . '&hash=' . md5($phpThumbParams . $PHPTHUMB_CONFIG['high_security_password']);
         }
     }
     return $onpub_dir_phpthumb . 'phpThumb.php?' . $phpThumbParams;
 }
Exemplo n.º 6
0
 /**
  * get the list of files and folders under this current fold
  *	@return array
  */
 function getFileList()
 {
     $outputs = array();
     $files = array();
     $folders = array();
     $tem = array();
     $dirHandler = @opendir($this->currentFolderPath);
     if ($dirHandler) {
         while (false !== ($file = readdir($dirHandler))) {
             if ($file != '.' && $file != '..') {
                 $flag = $this->flags['no'];
                 if ($this->sessionAction->getFolder() == $this->currentFolderPath) {
                     //check if any flag associated with this folder or file
                     $folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
                     if (in_array($folder . $file, $this->sessionAction->get())) {
                         if ($this->sessionAction->getAction() == "copy") {
                             $flag = $this->flags['copy'];
                         } else {
                             $flag = $this->flags['cut'];
                         }
                     }
                 }
                 $path = $this->currentFolderPath . $file;
                 if (is_dir($path) && isListingDocument($path)) {
                     $this->currentFolderInfo['subdir']++;
                     if (!$this->calculateSubdir) {
                     } else {
                         $folder = $this->getFolderInfo($path);
                         $folder['flag'] = $flag;
                         $folders[$file] = $folder;
                         $outputs[$file] = $folders[$file];
                     }
                 } elseif (is_file($path) && isListingDocument($path)) {
                     $obj = new file($path);
                     $tem = $obj->getFileInfo();
                     if (sizeof($tem)) {
                         $fileType = $this->getFileType($file);
                         foreach ($fileType as $k => $v) {
                             $tem[$k] = $v;
                         }
                         $this->currentFolderInfo['size'] += $tem['size'];
                         $this->currentFolderInfo['file']++;
                         $tem['path'] = backslashToSlash($path);
                         $tem['type'] = "file";
                         $tem['flag'] = $flag;
                         $files[$file] = $tem;
                         $outputs[$file] = $tem;
                         $tem = array();
                         $obj->close();
                     }
                 }
             }
         }
         if ($this->forceFolderOnTop) {
             uksort($folders, "strnatcasecmp");
             uksort($files, "strnatcasecmp");
             $outputs = array();
             foreach ($folders as $v) {
                 $outputs[] = $v;
             }
             foreach ($files as $v) {
                 $outputs[] = $v;
             }
         } else {
             uksort($outputs, "strnatcasecmp");
         }
         @closedir($dirHandler);
     } else {
         trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
     }
     return $outputs;
 }
Exemplo n.º 7
0
} elseif (empty($_POST['new_folder'])) {
    $error = ERR_FOLDER_NAME_EMPTY;
} elseif (!preg_match("/^[a-zA-Z0-9_\\- ]+\$/", $_POST['new_folder'])) {
    $error = ERR_FOLDER_FORMAT;
} else {
    if (empty($_POST['currentFolderPath']) || !isUnderRoot($_POST['currentFolderPath'])) {
        $error = ERR_FOLDER_PATH_NOT_ALLOWED;
    } elseif (file_exists(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'])) {
        $error = ERR_FOLDER_EXISTS;
    } else {
        include_once CLASS_FILE;
        $file = new file();
        if ($file->mkdir(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], 0775)) {
            include_once CLASS_MANAGER;
            $manager = new manager(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder'], false);
            $pathInfo = $manager->getFolderInfo(addTrailingSlash($_POST['currentFolderPath']) . $_POST['new_folder']);
            foreach ($pathInfo as $k => $v) {
                switch ($k) {
                    case "ctime":
                    case "mtime":
                    case "atime":
                        $v = date(DATE_TIME_FORMAT, $v);
                        break;
                    case 'name':
                        $info .= sprintf(", %s:'%s'", 'short_name', shortenFileName($v));
                        break;
                    case 'cssClass':
                        $v = 'folderEmpty';
                        break;
                }
                $info .= sprintf(", %s:'%s'", $k, $v);
Exemplo n.º 8
0
/**
 * Make a link to an entry, using the settings for how they should be formed.
 *
 * @param mixed $data
 * @param string $weblog
 * @param string $anchor
 * @param string $parameter
 * @param boolean $para_weblog
 */
function makeFilelink($data = "", $weblog = "", $anchor = "comm", $parameter = "", $para_weblog = false)
{
    global $PIVOTX;
    // Set the weblog, if it isn't set already.
    if ($weblog == "") {
        $weblog = $PIVOTX['weblogs']->getCurrent();
    }
    // Set $entry (and $code)
    if (empty($data)) {
        // Using current entry - the db object must exist and be set
        $template_vars = $PIVOTX['template']->get_template_vars();
        $uid = $template_vars['uid'];
    } elseif (is_array($data)) {
        // Using passed/inputed entry
        $entry = $data;
        $uid = $entry['uid'];
    } elseif (is_numeric($data)) {
        $uid = $data;
        // Using the entry with the given $code
        // If it's not the current one, we need to load it
        if (!isset($PIVOTX['db']) || $uid != $PIVOTX['db']->entry['uid']) {
            $fl_db = new db(FALSE);
            $fl_db->read_entry($uid);
            $entry = $fl_db->entry;
        } else {
            $entry = $PIVOTX['db']->entry;
        }
    } else {
        debug('Entry code must be an integer/numeric - no output.');
        return;
    }
    $site_url = getDefault($PIVOTX['weblogs']->get($weblog, 'site_url'), $PIVOTX['paths']['site_url']);
    $site_url = addTrailingSlash($site_url);
    switch ($PIVOTX['config']->get('mod_rewrite')) {
        // Mod rewrite disabled..
        case "0":
        case "":
            $filelink = sprintf("%s?e=%s%s", $site_url, $uid, $parameter);
            break;
            // archive/2005/04/20/title_of_entry
        // archive/2005/04/20/title_of_entry
        case "1":
            $name = $entry['uri'];
            $archiveprefix = makeURI(getDefault($PIVOTX['config']->get('localised_archive_prefix'), "archive"));
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$archiveprefix}/{$yr}/{$mo}/{$da}/{$name}";
            break;
            // archive/2005-04-20/title_of_entry
        // archive/2005-04-20/title_of_entry
        case "2":
            $name = $entry['uri'];
            $archiveprefix = makeURI(getDefault($PIVOTX['config']->get('localised_archive_prefix'), "archive"));
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$archiveprefix}/{$yr}-{$mo}-{$da}/{$name}";
            break;
            // entry/1234
        // entry/1234
        case "3":
            $entryprefix = makeURI(getDefault($PIVOTX['config']->get('localised_entry_prefix'), "entry"));
            $filelink = $site_url . "{$entryprefix}/{$uid}";
            break;
            // entry/1234/title_of_entry
        // entry/1234/title_of_entry
        case "4":
            $name = $entry['uri'];
            $entryprefix = makeURI(getDefault($PIVOTX['config']->get('localised_entry_prefix'), "entry"));
            $filelink = $site_url . "{$entryprefix}/{$uid}/{$name}";
            break;
            // 2005/04/20/title_of_entry
        // 2005/04/20/title_of_entry
        case "5":
            $name = $entry['uri'];
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$yr}/{$mo}/{$da}/{$name}";
            break;
            // 2005-04-20/title_of_entry
        // 2005-04-20/title_of_entry
        case "6":
            $name = $entry['uri'];
            list($yr, $mo, $da, $ho, $mi) = preg_split("/[ :-]/", $entry['date']);
            $filelink = $site_url . "{$yr}-{$mo}-{$da}/{$name}";
            break;
    }
    // Add a weblog parameter if asked for, or if multiple weblogs
    if ($para_weblog || paraWeblogNeeded($weblog)) {
        if ($PIVOTX['config']->get('mod_rewrite')) {
            // we treat it as an extra 'folder'
            $filelink .= "/" . para_weblog($weblog);
        } else {
            $filelink .= "&amp;w=" . para_weblog($weblog);
        }
    }
    $filelink = fixPath($filelink);
    $filelink = str_replace("%1", $code, $filelink);
    $filelink = formatDate("", $filelink, $entry['title']);
    if ($anchor != "") {
        $filelink .= "#" . $anchor;
    }
    // Check if there's a hook set, and if so call it. This hook has no 'return' value.
    if ($PIVOTX['extensions'] && $PIVOTX['extensions']->hasHook('make_link#entries')) {
        $PIVOTX['extensions']->executeHook('make_link#entries', $filelink, array('uri' => $entry['uri'], 'title' => $entry['title'], 'uid' => $entry['uid'], 'date' => $entry['date'], 'w' => $weblog));
    }
    return $filelink;
}
Exemplo n.º 9
0
  /**
   * get the parent path of the specified path
   *
   * @param string $path
   * @return string 
   */
  function getParentFolderPath($path)
  {
  	$realPath = addTrailingSlash(backslashToSlash(getRealPath($path)));
  	$parentRealPath =  addTrailingSlash(backslashToSlash(dirname($realPath)));
  	$differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath)));
  	$parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath));
/*  	echo $realPath . "<br>";
  	echo $parentRealPath . "<br>";
  	echo $differentPath . "<br>";
  	echo $parentPath . "<br>";*/
  	if(isUnderRoot($parentPath))
  	{
  		return $parentPath;
  	}else 
  	{
  		return CONFIG_SYS_DEFAULT_PATH;
  	}
  }
Exemplo n.º 10
0
 function isDir($path)
 {
     $cwd = $this->cwd();
     $result = @ftp_chdir($this->link, addTrailingSlash($path));
     if ($result && $path == $this->cwd() || $this->cwd() != $cwd) {
         @ftp_chdir($this->link, $cwd);
         return true;
     }
     return false;
 }
Exemplo n.º 11
0
 public function getFullPath()
 {
     return addTrailingSlash($this->website->imagesDirectory) . $this->fileName;
 }
Exemplo n.º 12
0
 public function display()
 {
     $osections = new OnpubSections($this->pdo);
     $owebsites = new OnpubWebsites($this->pdo);
     $oarticles = new OnpubArticles($this->pdo);
     $oimages = new OnpubImages($this->pdo);
     $owsmaps = new OnpubWSMaps($this->pdo);
     $queryOptions = new OnpubQueryOptions();
     $queryOptions->includeArticles = TRUE;
     $queryOptions->includeContent = FALSE;
     try {
         $this->osection = $osections->get($this->osection->ID, $queryOptions);
         $website = $owebsites->get($this->osection->websiteID);
         $numOfArticles = $oarticles->count();
         $queryOptions = new OnpubQueryOptions();
         $queryOptions->orderBy = "fileName";
         $queryOptions->order = "ASC";
         $images = $oimages->select($queryOptions);
         $wsmap = new OnpubWSMap();
         $wsmap->websiteID = $this->osection->websiteID;
         $wsmap->sectionID = $this->osection->ID;
         $this->visible = $owsmaps->getID($wsmap);
         $wsmaps = $owsmaps->select(NULL, NULL, $this->osection->ID);
         $queryOptions = new OnpubQueryOptions();
         $queryOptions->orderBy = "name";
         $queryOptions->order = "ASC";
         if (sizeof($wsmaps)) {
             $websites = $owebsites->select($queryOptions);
         } else {
             $websites = array();
         }
     } catch (PDOException $e) {
         throw $e;
     }
     $widget = new OnpubWidgetHeader("Section " . $this->osection->ID . " - " . $this->osection->name, ONPUBAPI_SCHEMA_VERSION, $this->pdo);
     $widget->display();
     en('<form id="onpub-form" action="index.php" method="post">');
     en('<div>');
     en('<div class="yui3-g">');
     en('<div class="yui3-u-1-2">');
     if ($this->osection->name === NULL) {
         en('<h3 class="onpub-field-header">Name</h3><p><input type="text" maxlength="255" size="40" name="name" value=""> <img src="' . ONPUBGUI_IMAGE_DIRECTORY . 'exclamation.png" align="top" alt="Required field" title="Required field"></p>');
     } else {
         en('<h3 class="onpub-field-header">Name</h3><p><input type="text" maxlength="255" size="40" name="name" value="' . htmlentities($this->osection->name) . '"></p>');
     }
     en('</div>');
     en('<div class="yui3-u-1-2">');
     if ($this->visible !== NULL) {
         en('<h3 class="onpub-field-header">Visibility</h3>');
         en('<p><input type="checkbox" id="id_visible" name="visible" value="1" checked="checked"> <label for="id_visible">De-select to hide this section from the Frontend.</label></p>');
     } else {
         en('<h3 class="onpub-field-header">Visibility</h3>');
         en('<p><input type="checkbox" id="id_visible" name="visible" value="1"> <label for="id_visible">Select to show this section on the Frontend.</label></p>');
     }
     en('</div>');
     en('</div>');
     en('<div class="yui3-g">');
     en('<div class="yui3-u-1-2">');
     if ($this->osection->parentID) {
         $sectionIDs = array($this->osection->parentID);
     } else {
         $sectionIDs = array();
     }
     $widget = new OnpubWidgetSections();
     $widget->sectionIDs = $sectionIDs;
     $widget->websites = array($website);
     $widget->osections = $osections;
     $widget->heading = "Parent Section";
     $widget->multiple = FALSE;
     $widget->fieldName = "parentID";
     $widget->osection = $this->osection;
     $widget->display();
     en('</div>');
     en('<div class="yui3-u-1-2">');
     en('<h3 class="onpub-field-header">Website</h3><p><a href="index.php?onpub=EditWebsite&amp;websiteID=' . $website->ID . '" title="Edit">' . $website->name . '</a></p>');
     en('</div>');
     en('</div>');
     en('<div class="yui3-g">');
     en('<div class="yui3-u-1-2">');
     if ($numOfArticles) {
         $widget = new OnpubWidgetArticles($this->pdo, $this->osection);
         $widget->display();
     } else {
         en('<h3 class="onpub-field-header">Visible Articles</h3><p>');
         en('There are 0 articles in the database. <a href="index.php?onpub=NewArticle">New Article</a>.</p>');
     }
     en('</div>');
     en('<div class="yui3-u-1-2">');
     $widget = new OnpubWidgetImages("Image", $this->osection->imageID, $images);
     $widget->display();
     en('</div>');
     en('</div>');
     if ($this->osection->url) {
         $go = ' <a href="' . $this->osection->url . '" target="_blank"><img src="' . ONPUBGUI_IMAGE_DIRECTORY . 'world_go.png" border="0" align="top" alt="Go" title="Go" width="16" height="16"></a>';
     } else {
         $go = '';
     }
     en('<div class="yui3-g">');
     en('<div class="yui3-u-1-2">');
     en('<h3 class="onpub-field-header">Static Link</h3><p><small>The Frontend will link this section to the path or URL entered below.<br>Leave blank to use auto-generated Frontend URLs.</small><br><input type="text" maxlength="255" size="40" name="url" value="' . htmlentities($this->osection->url) . '">' . $go . '</p>');
     en('</div>');
     en('<div class="yui3-u-1-2">');
     if (sizeof($wsmaps)) {
         $websitesMap = array();
         foreach ($websites as $website) {
             $websitesMap["{$website->ID}"] = $website;
         }
         $urlLabel = sizeof($wsmaps) > 1 ? 'URLs' : 'URL';
         en('<h3 class="onpub-field-header">Frontend ' . $urlLabel . '</h3>');
         en('<p>');
         en('<small>This section is displayed by the Frontend at the ' . $urlLabel . ' listed below.</small><br>');
         for ($i = 0; $i < sizeof($wsmaps); $i++) {
             $wsmap = $wsmaps[$i];
             $website = $websitesMap["{$wsmap->websiteID}"];
             $frontendURL = addTrailingSlash($website->url) . 'index.php?s=' . $wsmap->sectionID;
             en('&bull; <a href="' . $frontendURL . '" target="_blank">' . $frontendURL . '</a>');
             if ($i + 1 != sizeof($wsmaps)) {
                 en('<br>');
             }
         }
         en('</p>');
     }
     en('</div>');
     en('</div>');
     en('<div class="yui3-g">');
     en('<div class="yui3-u-1-2">');
     en('<h3 class="onpub-field-header">Created</h3><p>' . $this->osection->getCreated()->format('M j, Y g:i:s A') . '</p>');
     en('</div>');
     en('<div class="yui3-u-1-2">');
     en('<h3 class="onpub-field-header">Modified</h3><p>' . $this->osection->getModified()->format('M j, Y g:i:s A') . '</p>');
     en('</div>');
     en('</div>');
     en('<input type="submit" value="Save" id="selectAll"> <input type="button" value="Delete" id="deleteSection">');
     en('<input type="hidden" name="onpub" value="EditSectionProcess">');
     en('<input type="hidden" name="sectionID" value="' . $this->osection->ID . '">');
     en('<input type="hidden" name="websiteID" value="' . $this->osection->websiteID . '">');
     en('</div>');
     en('</form>');
     $widget = new OnpubWidgetFooter();
     $widget->display();
 }
Exemplo n.º 13
0
 /**
  * get the list of files and folders under this current fold
  * 	@return array
  */
 function getFileList()
 {
     $outputs = array();
     $files = array();
     $folders = array();
     $tem = array();
     $to_group_id = api_get_group_id();
     global $is_user_in_group;
     $dirHandler = @opendir($this->getCurrentFolderPath());
     if ($dirHandler) {
         while (false !== ($file = readdir($dirHandler))) {
             if ($file != '.' && $file != '..') {
                 $flag = $this->flags['no'];
                 if ($this->sessionAction->getFolder() == $this->getCurrentFolderPath()) {
                     //check if any flag associated with this folder or file
                     $folder = addTrailingSlash(backslashToSlash($this->getCurrentFolderPath()));
                     if (in_array($folder . $file, $this->sessionAction->get())) {
                         if ($this->sessionAction->getAction() == "copy") {
                             $flag = $this->flags['copy'];
                         } else {
                             $flag = $this->flags['cut'];
                         }
                     }
                 }
                 $path = $this->getCurrentFolderPath() . $file;
                 if (is_dir($path) && isListingDocument($path)) {
                     $this->currentFolderInfo['subdir']++;
                     //fix count left folders for Chamilo
                     $deleted_by_Chamilo_folder = '_DELETED_';
                     $css_folder_Chamilo = 'css';
                     $hotpotatoes_folder_Chamilo = 'HotPotatoes_files';
                     $chat_files_Chamilo = 'chat_files';
                     $certificates_Chamilo = 'certificates';
                     //show group's directory only if I'm member. Or if I'm a teacher.
                     //@todo: check groups not necessary because the student dont have access to main folder documents (only to document/group or document/shared_folder).
                     //Teachers can access to all groups ?
                     $group_folder = '_groupdocs';
                     $hide_doc_group = false;
                     if (preg_match("/{$group_folder}/", $path)) {
                         $hide_doc_group = true;
                         if ($is_user_in_group || $to_group_id != 0 && api_is_allowed_to_edit()) {
                             $hide_doc_group = false;
                         }
                     }
                     if (preg_match("/{$deleted_by_Chamilo_folder}/", $path) || preg_match("/{$css_folder_Chamilo}/", $path) || preg_match("/{$hotpotatoes_folder_Chamilo}/", $path) || preg_match("/{$chat_files_Chamilo}/", $path) || preg_match("/{$certificates_Chamilo}/", $path) || $hide_doc_group || $file[0] == '.') {
                         $this->currentFolderInfo['subdir'] = $this->currentFolderInfo['subdir'] - 1;
                     }
                     //end fix for Chamilo
                     if (!$this->calculateSubdir) {
                     } else {
                         $folder = $this->getFolderInfo($path);
                         $folder['flag'] = $flag;
                         $folders[$file] = $folder;
                         $outputs[$file] = $folders[$file];
                     }
                 } elseif (is_file($path) && isListingDocument($path)) {
                     $obj = new file($path);
                     $tem = $obj->getFileInfo();
                     if (sizeof($tem)) {
                         $fileType = $this->getFileType($file);
                         foreach ($fileType as $k => $v) {
                             $tem[$k] = $v;
                         }
                         $this->currentFolderInfo['size'] += $tem['size'];
                         $this->currentFolderInfo['file']++;
                         //fix count left files for Chamilo
                         $deleted_by_Chamilo_file = ' DELETED ';
                         // ' DELETED ' not '_DELETED_' because in $file['name'] _ is replaced with blank see class.manager.php
                         if (preg_match("/{$deleted_by_Chamilo_file}/", $tem['name']) || $tem['name'][0] == '.') {
                             $this->currentFolderInfo['file'] = $this->currentFolderInfo['file'] - 1;
                         }
                         ///end fix for Chamilo
                         //Try a course file
                         $tem['path'] = backslashToSlash($path);
                         $pos = strpos($this->getCurrentFolderPath(), 'courses/');
                         if ($pos === false) {
                             //try my_files
                             $pos = strpos($this->getCurrentFolderPath(), 'main/');
                             $tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
                         } else {
                             $tem['public_path'] = api_get_path(WEB_PATH) . substr($this->getCurrentFolderPath(), $pos, strlen($this->getCurrentFolderPath())) . $file;
                         }
                         $tem['type'] = "file";
                         $tem['flag'] = $flag;
                         $files[$file] = $tem;
                         $outputs[$file] = $tem;
                         $tem = array();
                         $obj->close();
                     }
                 }
             }
         }
         if ($this->forceFolderOnTop) {
             uksort($folders, "strnatcasecmp");
             uksort($files, "strnatcasecmp");
             $outputs = array();
             foreach ($folders as $v) {
                 $outputs[] = $v;
             }
             foreach ($files as $v) {
                 $outputs[] = $v;
             }
         } else {
             uksort($outputs, "strnatcasecmp");
         }
         @closedir($dirHandler);
     } else {
         trigger_error('Unable to locate the folder ' . $this->getCurrentFolderPath(), E_NOTICE);
     }
     return $outputs;
 }
Exemplo n.º 14
0
 /**
  * Calculates the link for a given weblog
  *
  * @param string $value
  * @param string $weblogname
  */
 function _getLink($weblogname, $value)
 {
     global $PIVOTX;
     $link = trim($value);
     if ($link == '') {
         if ($PIVOTX['config']->get('mod_rewrite') == 0) {
             $link = $PIVOTX['paths']['site_url'] . '?w=' . $weblogname;
         } else {
             $prefix = getDefault($PIVOTX['config']->get('localised_weblog_prefix'), "weblog");
             $link = $PIVOTX['paths']['site_url'] . $prefix . "/" . $weblogname;
         }
     } else {
         $ext = getExtension(basename($link));
         if ($ext == '') {
             $link = addTrailingSlash($link);
         }
     }
     return $link;
 }
Exemplo n.º 15
0
 /**
  * Helper function for autoComplete()
  *
  * @param string $path
  * @param string $additional_path
  * @param string $match
  * @return array
  */
 protected static function autoCompleteFindFiles($path, $additional_path, $match)
 {
     $allowed = array("gif", "jpg", "jpeg", "png", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "flv", "avi", "mp3");
     $path = addTrailingSlash($path);
     $files = array();
     $dir = dir($path);
     while (false !== ($entry = $dir->read())) {
         $entries[] = $entry;
     }
     $dir->close();
     foreach ($entries as $entry) {
         $fullname = $path . $entry;
         if ($entry != '.' && $entry != '..' && is_dir($fullname)) {
             // Recursively parse the folder below it.
             $files = array_merge($files, self::autoCompleteFindFiles($fullname, $additional_path . $entry . "/", $match));
         } else {
             if (is_file($fullname) && strpos($fullname, $match) !== false && in_array(strtolower(getExtension($entry)), $allowed) && strpos($fullname, ".thumb.") === false) {
                 // Add the file to our array of matches.
                 $files[] = $additional_path . $entry;
             }
         }
     }
     return $files;
 }
Exemplo n.º 16
0
function unPackToWorkingDir($updateZip)
{
    if (empty($updateZip)) {
        return false;
    }
    $workingDir = APP_ROOT . '/updates';
    $updatesFolder = $GLOBALS['FileSystemObj']->findFolder($workingDir);
    //Clean up contents of upgrade directory beforehand.
    $updatesFolderFiles = $GLOBALS['FileSystemObj']->dirList($updatesFolder);
    if (!empty($updatesFolderFiles)) {
        $temp = basename($updateZip);
        foreach ($updatesFolderFiles as $file) {
            if ($temp != $file['name']) {
                $GLOBALS['FileSystemObj']->delete($updatesFolder . $file['name'], true);
            }
        }
    }
    //We need a working directory
    //removing the extention
    $updateZipParts = explode('.', basename($updateZip));
    if (count($updateZipParts) > 1) {
        array_pop($updateZipParts);
    }
    $tempFolderName = implode('.', $updateZipParts);
    if (empty($tempFolderName)) {
        return false;
    }
    $remoteWorkingDir = $updatesFolder . $tempFolderName;
    $workingDir = addTrailingSlash($workingDir) . $tempFolderName;
    // Clean up working directory
    if ($GLOBALS['FileSystemObj']->isDir($remoteWorkingDir)) {
        $GLOBALS['FileSystemObj']->delete($remoteWorkingDir, true);
    }
    // Unzip package to working directory
    $result = $GLOBALS['FileSystemObj']->unZipFile($updateZip, $remoteWorkingDir);
    //TODO optimizations, Copy when Move/Rename would suffice?
    // Once extracted, delete the package.
    @unlink($updateZip);
    if ($result == false) {
        $GLOBALS['FileSystemObj']->delete($remoteWorkingDir, true);
        return false;
    }
    return array('source' => $workingDir, 'remoteSource' => $remoteWorkingDir);
}
Exemplo n.º 17
0
            // Added by Ivan Tcholakov, 22-JUL-2009.
            // For integration with the editor's dialig system.
            var oEditor = null;
            if (!window.opener && window.parent) {
                // The file manager is inside a dialog.
                oEditor = window.parent.InnerDialogLoaded();
            }
            //end hack
        }
        var globalSettings = {'upload_init': false};
        var queryString = '<?php 
echo makeQueryString(array('path'));
?>
';
        var paths = {'root': '<?php 
echo addTrailingSlash(backslashToSlash(CONFIG_SYS_ROOT_PATH));
?>
', 'root_title': '<?php 
echo LBL_FOLDER_ROOT;
?>
'};

        <!-- Chamilo hack for breadcrumb into shared folders -->
        var shared_folder = '<?php 
echo get_lang('UserFolders');
?>
';

        <?php 
$course_session = array();
if (isset($currentPath)) {
Exemplo n.º 18
0
if (!defined('_PS_ADMIN_DIR_')) {
    define('_PS_ADMIN_DIR_', getcwd() . '/../');
}
require_once _PS_ADMIN_DIR_ . '/../config/config.inc.php';
require_once _PS_ADMIN_DIR_ . '/init.php';
/**
 * ajax save name
 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
 * @link www.phpletter.com
 * @since 22/May/2007
 *
 */
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php";
$error = '';
$path = addTrailingSlash(backslashToSlash($_POST['folder'])) . $_POST['name'];
if (CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE) {
    $error = SYS_DISABLED;
} elseif (isset($_POST['save_as_request'])) {
    if (!preg_match('/^[a-zA-Z0-9_\\-.]+$/', $_POST['name'])) {
        $error = TXT_SAVE_AS_ERR_NAME_INVALID;
    } elseif (array_search(strtolower(getFileExt($_POST['name'])), getValidTextEditorExts()) === false) {
        $error = TXT_DISALLOWED_EXT;
    } elseif (!isUnderRoot($_POST['folder'])) {
        $error = ERR_FOLDER_PATH_NOT_ALLOWED;
    } else {
        if (!empty($_POST['save_as_request'])) {
            //save as request
            if (file_exists($path)) {
                $error = TXT_FILE_EXIST;
            } else {
Exemplo n.º 19
0
/**
 * Output a slideshow feed as a template
 *
 * @param array $params
 * @return string
 */
function smarty_slideshow($params)
{
    global $PIVOTX, $slideshow_config;
    static $slideshowcount = 0;
    $js_insert = <<<EOF
<script type="text/javascript">
jQuery(window).bind("load", function(){
    jQuery("div#pivotx-slideshow-%count%").slideView(%parms%);
    setTimeout('slideNext_%count%()', %timeout%);
});

function slideNext_%count%() {

    if( typeof slideNext_%count%.currentslide == 'undefined' ) {
        slideNext_%count%.currentslide = 0;
    }

    var slidewidth = jQuery("div#pivotx-slideshow-%count%").find("li").find("img").width();
    var amountofslides = %amount% - 1; 

    if (amountofslides > slideNext_%count%.currentslide) {
        slideNext_%count%.currentslide++;
    } else {
        slideNext_%count%.currentslide = 0;
    }

    var xpos = (-slidewidth * slideNext_%count%.currentslide);
    jQuery("div#pivotx-slideshow-%count%").find("ul").animate({ left: xpos}, 1200, "easeInOutExpo");  

    setTimeout('slideNext_%count%()', %timeout%);

}
</script>
EOF;
    $params = clean_params($params);
    foreach (array('timeout', 'folder', 'width', 'height', 'limit', 'orderby', 'popup', 'recursion', 'nicenamewithdirs', 'iptcindex', 'iptcencoding') as $key) {
        if (isset($params[$key])) {
            ${$key} = $params[$key];
        } else {
            ${$key} = getDefault($PIVOTX['config']->get('slideshow_' . $key), $slideshow_config['slideshow_' . $key]);
        }
    }
    $imagefolder = addTrailingSlash($PIVOTX['paths']['upload_base_path'] . $folder);
    $ok_extensions = explode(",", "jpg,jpeg,png,gif");
    if (!file_exists($imagefolder) || !is_dir($imagefolder)) {
        debug("Image folder {$imagefolder} does not exist.");
        echo "Image folder {$imagefolder} does not exist.";
        return "";
    } else {
        if (!is_readable($imagefolder)) {
            debug("Image folder {$imagefolder} is not readable.");
            echo "Image folder {$imagefolder} is not readable.";
            return "";
        }
    }
    $images = array();
    $key = "";
    if ($recursion == 'no') {
        $dirs = array($imagefolder);
    } else {
        $dirs = slideshowGetDirs($imagefolder, $recursion);
        if ($recursion == 'all') {
            array_unshift($dirs, $imagefolder);
        }
    }
    foreach ($dirs as $folder) {
        $dir = dir($folder);
        while (false !== ($entry = $dir->read())) {
            if (in_array(strtolower(getExtension($entry)), $ok_extensions)) {
                if (strpos($entry, ".thumb.") > 0) {
                    continue;
                }
                $entry = $folder . $entry;
                if ($orderby == 'date_asc' || $orderby == 'date_desc') {
                    $key = filemtime($entry) . rand(10000, 99999);
                    $images[$key] = $entry;
                } else {
                    $images[] = $entry;
                }
            }
        }
        $dir->close();
    }
    if ($orderby == 'date_asc') {
        ksort($images);
    } else {
        if ($orderby == 'date_desc') {
            ksort($images);
            $images = array_reverse($images);
        } else {
            if ($orderby == 'alphabet') {
                natcasesort($images);
            } else {
                shuffle($images);
            }
        }
    }
    // Cut it to the desired length..
    $images = array_slice($images, 0, $limit);
    // Built the parms
    $tooltip = getDefault($PIVOTX['config']->get('slideshow_tooltip'), $slideshow_config['slideshow_tooltip']);
    $ttopacity = getDefault($PIVOTX['config']->get('slideshow_ttopacity'), $slideshow_config['slideshow_ttopacity']);
    $uibefore = getDefault($PIVOTX['config']->get('slideshow_uibefore'), $slideshow_config['slideshow_uibefore']);
    $zc = getDefault($PIVOTX['config']->get('slideshow_zc'), $slideshow_config['slideshow_zc']);
    $zcimg = '';
    if (isset($zc)) {
        $zcimg = '&amp;zc=' . $zc;
    }
    if ($tooltip == 1) {
        $parms = "{toolTip: true";
    } else {
        $parms = "{toolTip: false";
    }
    $parms .= ", ttOpacity: " . $ttopacity;
    if ($uibefore == 1) {
        $parms .= ", uiBefore: true}";
    } else {
        $parms .= ", uiBefore: false}";
    }
    $js_insert = str_replace('%timeout%', $timeout, $js_insert);
    $js_insert = str_replace('%count%', $slideshowcount, $js_insert);
    $js_insert = str_replace('%amount%', count($images), $js_insert);
    $js_insert = str_replace('%parms%', $parms, $js_insert);
    $PIVOTX['extensions']->addHook('after_parse', 'insert_before_close_head', $js_insert);
    // If a specific popup type is selected execute the callback.
    if ($popup != 'no') {
        $callback = $popup . "IncludeCallback";
        if (function_exists($callback)) {
            $PIVOTX['extensions']->addHook('after_parse', 'callback', $callback);
        } else {
            debug("There is no function '{$callback}' - the popups won't work.");
        }
    }
    $output = "\n<div id=\"pivotx-slideshow-{$slideshowcount}\" class=\"svw\">\n<ul>\n";
    foreach ($images as $image) {
        $file = $image;
        $image = str_replace($PIVOTX['paths']['upload_base_path'], '', $image);
        $image = str_replace(DIRECTORY_SEPARATOR, '/', $image);
        $nicefilename = formatFilename($image, $nicenamewithdirs);
        $title = false;
        if ($iptcindex) {
            getimagesize($file, $iptc);
            if (is_array($iptc) && $iptc['APP13']) {
                $iptc = iptcparse($iptc['APP13']);
                $title = $iptc[$iptcindex][0];
                if ($iptcencoding) {
                    $title = iconv($iptcencoding, 'UTF-8', $title);
                }
                $title = cleanAttributes($title);
            }
        }
        if (!$title) {
            $title = $nicefilename;
        }
        $line = "<li>\n";
        if ($popup != 'no') {
            $line .= sprintf("<a href=\"%s%s\" class=\"{$popup}\" rel=\"slideshow\" title=\"%s\">\n", $PIVOTX['paths']['upload_base_url'], $image, $title);
        }
        $line .= sprintf("<img src=\"%sincludes/timthumb.php?src=%s&amp;w=%s&amp;h=%s%s\" " . "alt=\"%s\" width=\"%s\" height=\"%s\" />\n", $PIVOTX['paths']['pivotx_url'], rawurlencode($image), $width, $height, $zcimg, $title, $width, $height);
        if ($popup != 'no') {
            $line .= "</a>";
        }
        $line .= "</li>\n";
        $output .= $line;
    }
    $output .= "</ul>\n</div>\n";
    $slideshowcount++;
    return $output;
}
Exemplo n.º 20
0
 public function delete()
 {
     $oimages = new OnpubImages($this->pdo);
     $owebsites = new OnpubWebsites($this->pdo);
     $this->oimage = $oimages->get($this->oimage->ID);
     $website = $owebsites->get($this->oimage->websiteID);
     try {
         $oimages->delete($this->oimage->ID);
     } catch (PDOException $e) {
         throw $e;
     }
     if (file_exists(addTrailingSlash($website->imagesDirectory) . $this->oimage->fileName)) {
         unlink(addTrailingSlash($website->imagesDirectory) . $this->oimage->fileName);
     }
 }
Exemplo n.º 21
0
 /**
  * Copy a file, or recursively copy a folder and its contents
  * @author      Aidan Lister <*****@*****.**>
  * @author      Paul Scott
  * @version     1.0.1
  * @param       string   $source    Source path
  * @param       string   $dest      Destination path
  * @return      bool     Returns TRUE on success, FALSE on failure
  */
 function copyTo($source, $dest)
 {
     $source = removeTrailingSlash(backslashToSlash($source));
     $dest = removeTrailingSlash(backslashToSlash($dest));
     if (!file_exists($dest) || !is_dir($dest)) {
         if (!$this->mkdir($dest)) {
             $this->_debug('Unable to create folder (' . $dest . ")");
             return false;
         }
     }
     // Copy in to your self?
     if (getAbsPath($source) == getAbsPath($dest)) {
         $this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest));
         return false;
     }
     // Simple copy for a file
     if (is_file($source)) {
         $dest = addTrailingSlash($dest) . basename($source);
         if (file_exists($dest)) {
             return false;
         } else {
             return copy($source, $dest);
         }
     } elseif (is_dir($source)) {
         // Loop through the folder
         if (file_exists(addTrailingSlash($dest) . basename($source))) {
             return false;
         } else {
             if (!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source))) {
                 if (!$this->mkdir(addTrailingSlash($dest) . basename($source))) {
                     $this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")");
                     return false;
                 }
             }
             $handle = opendir($source);
             while (false !== ($readdir = readdir($handle))) {
                 if ($readdir != '.' && $readdir != '..') {
                     $path = addTrailingSlash($source) . '/' . $readdir;
                     $this->copyTo($path, addTrailingSlash($dest) . basename($source));
                 }
             }
             closedir($handle);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 22
0
 public function process()
 {
     $oimages = new OnpubImages($this->pdo);
     $owebsites = new OnpubWebsites($this->pdo);
     if ($this->overwrite !== NULL) {
         // An image overwrite is being requested.
         $image = new OnpubImage();
         $image->websiteID = $this->websiteID;
         $image->fileName = $this->overwriteFileName;
         try {
             $this->imageID = $oimages->getID($image);
         } catch (PDOException $e) {
             throw $e;
         }
         try {
             $website = $owebsites->get($this->websiteID);
         } catch (PDOException $e) {
             throw $e;
         }
         if ($this->overwrite) {
             // Overwrite the existing image file with the temp one.
             if (rename(addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName . ONPUBGUI_TMP_IMG_SUFFIX, addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName)) {
                 // Update the image's modified timestamp in the DB.
                 try {
                     $image = $oimages->get($this->imageID);
                 } catch (PDOException $e) {
                     throw $e;
                 }
                 try {
                     $oimages->update($image);
                 } catch (PDOException $e) {
                     throw $e;
                 }
             }
         } else {
             // Remove the temporary image file.
             unlink(addTrailingSlash($website->imagesDirectory) . $this->overwriteFileName . ONPUBGUI_TMP_IMG_SUFFIX);
         }
         return;
     }
     if (!ini_get("file_uploads")) {
         $message = "File uploads are disabled in the current PHP configuration.";
         throw new Exception($message, ONPUBGUI_ERROR_IMAGE_TYPE);
     }
     for ($i = 0; $i < sizeof($this->imageFiles['name']); $i++) {
         if ($this->imageFiles['name'][$i]) {
             if (!$this->isValidImage($this->imageFiles['name'][$i])) {
                 $message = "<i>" . $this->imageFiles['name'][$i] . "</i> is an unsupported image file type.";
                 throw new Exception($message, ONPUBGUI_ERROR_IMAGE_TYPE);
             }
             $image = new OnpubImage();
             $image->websiteID = $this->websiteID;
             $image->fileName = $this->imageFiles['name'][$i];
             try {
                 $this->imageID = $oimages->getID($image);
             } catch (PDOException $e) {
                 throw $e;
             }
             try {
                 $website = $owebsites->get($image->websiteID);
             } catch (PDOException $e) {
                 throw $e;
             }
             if ($this->imageID) {
                 // Image exists, write the file to the images directory with a temp
                 // name, and prompt the user to overwrite existing file.
                 if (is_uploaded_file($this->imageFiles['tmp_name'][$i])) {
                     if (@move_uploaded_file($this->imageFiles['tmp_name'][$i], addTrailingSlash($website->imagesDirectory) . $this->imageFiles['name'][$i] . ONPUBGUI_TMP_IMG_SUFFIX)) {
                         throw new Exception($this->imageFiles['name'][$i], ONPUBGUI_ERROR_IMAGE_EXISTS);
                     } else {
                         $imagesDirectory = $website->imagesDirectory;
                         $message = "Unable to move <i>" . $this->imageFiles['tmp_name'][$i] . "</i> to <i>" . addTrailingSlash($imagesDirectory) . $this->imageFiles['name'][$i] . ONPUBGUI_TMP_IMG_SUFFIX . "</i>.";
                         throw new Exception($message, ONPUBGUI_ERROR_MOVE_UPLOADED_FILE);
                     }
                 }
             } else {
                 // Image does not exsist, copy to images folder and insert in to DB.
                 if (is_uploaded_file($this->imageFiles['tmp_name'][$i])) {
                     if (!@move_uploaded_file($this->imageFiles['tmp_name'][$i], addTrailingSlash($website->imagesDirectory) . $this->imageFiles['name'][$i])) {
                         $imagesDirectory = $website->imagesDirectory;
                         $message = "Unable to move <i>" . $this->imageFiles['tmp_name'][$i] . "</i> to <i>" . addTrailingSlash($imagesDirectory) . $this->imageFiles['name'][$i] . "</i>.";
                         throw new Exception($message, ONPUBGUI_ERROR_MOVE_UPLOADED_FILE);
                     }
                     try {
                         $this->imageID = $oimages->insert($image);
                     } catch (PDOException $e) {
                         throw $e;
                     }
                 } else {
                     $imagesDirectory = $website->imagesDirectory;
                     $message = "<i>" . $this->imageFiles['name'][$i] . "</i> file size is larger than the current PHP configuration allows.";
                     throw new Exception($message, ONPUBGUI_ERROR_FILE_SIZE);
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajax File Manager</title>
<!--<script type="text/javascript" src="jscripts/ajaxfilemanager_c.js"></script>-->
<script type="text/javascript" src="jscripts/jquery.js"></script>
<script type="text/javascript" src="jscripts/form.js"></script>
<script type="text/javascript" src="jscripts/select.js"></script>
<script type="text/javascript" src="jscripts/thickbox.js"></script>
<script type="text/javascript" src="jscripts/calendar.js"></script>
<script type="text/javascript" src="jscripts/contextmenu.js"></script>
<script type="text/javascript" src="jscripts/media.js"></script>
<script type="text/javascript" src="jscripts/ajaxfileupload.js"></script>
<script type="text/javascript" src="jscripts/ajaxfilemanager.js"></script>
<script type="text/javascript">
	var globalSettings = {'upload_init':false};
	var queryString = '<?php echo makeQueryString(array('path')); ?>';
	var paths = {'root':'<?php echo addTrailingSlash(backslashToSlash(CONFIG_SYS_ROOT_PATH)); ?>', 'root_title':'<?php echo LBL_FOLDER_ROOT; ?>'};
	var parentFolder = {};
	var urls = {
			'upload':'<?php echo CONFIG_URL_UPLOAD; ?>',
			'preview':'<?php echo CONFIG_URL_PREVIEW; ?>',
			'cut':'<?php echo CONFIG_URL_CUT; ?>',
			'copy':'<?php echo CONFIG_URL_COPY; ?>',
			'paste':'<?php echo CONFIG_URL_FILE_PASTE; ?>',
			'delete':'<?php echo CONFIG_URL_DELETE; ?>',
			'rename':'<?php echo CONFIG_URL_SAVE_NAME; ?>',
			'thumbnail':'<?php echo CONFIG_URL_IMG_THUMBNAIL;  ?>',
			'create_folder':'<?php echo CONFIG_URL_CREATE_FOLDER; ?>',
			'text_editor':'<?php echo  CONFIG_URL_TEXT_EDITOR; ?>',
			'image_editor':'<?php echo  CONFIG_URL_IMAGE_EDITOR; ?>',
			'download':'<?php echo CONFIG_URL_DOWNLOAD; ?>',
			'present':'<?php echo getCurrentUrl(); ?>',
Exemplo n.º 24
0
} elseif (!rename(removeTrailingSlash($_POST['original_path']), addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'])) {
    $error = ERR_RENAME_FAILED;
} else {
    //update record of session if image exists in session for cut or copy
    include_once CLASS_SESSION_ACTION;
    $sessionAction = new SessionAction();
    $selectedDocuments = $sessionAction->get();
    if (removeTrailingSlash($sessionAction->getFolder()) == getParentPath($_POST['original_path']) && sizeof($selectedDocuments)) {
        if (($key = array_search(basename($_POST['original_path']), $selectedDocuments)) !== false) {
            $selectedDocuments[$key] = $_POST['name'];
            $sessionAction->set($selectedDocuments);
        }
    } elseif (removeTrailingSlash($sessionAction->getFolder()) == removeTrailingSlash($_POST['original_path'])) {
        $sessionAction->setFolder($_POST['original_path']);
    }
    $path = addTrailingSlash(getParentPath($_POST['original_path'])) . $_POST['name'];
    if (is_file($path)) {
        include_once CLASS_FILE;
        $file = new file($path);
        $fileInfo = $file->getFileInfo();
        $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
    } else {
        include_once CLASS_MANAGER;
        $manager = new manager($path, false);
        $fileInfo = $manager->getFolderInfo();
        $fileInfo['mtime'] = date(DATE_TIME_FORMAT, $fileInfo['mtime']);
    }
    event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_PATH, $_POST['original_path']);
    event_system(LOG_MY_FOLDER_CHANGE, LOG_MY_FOLDER_NEW_PATH, $path);
}
echo "{";
Exemplo n.º 25
0
    $error = SYS_DISABLED;
} elseif (empty($_GET['current_folder_path'])) {
    $error = ERR_NOT_DEST_FOLDER_SPECIFIED;
} elseif (!file_exists($_GET['current_folder_path']) || !is_dir($_GET['current_folder_path'])) {
    $error = ERR_DEST_FOLDER_NOT_FOUND;
} elseif (!isUnderRoot($_GET['current_folder_path'])) {
    $error = ERR_DEST_FOLDER_NOT_ALLOWED;
} else {
    include_once CLASS_MANAGER;
    include_once CLASS_SESSION_ACTION;
    $sessionAction = new SessionAction();
    include_once DIR_AJAX_INC . "class.manager.php";
    $manager = new manager();
    $manager->setSessionAction($sessionAction);
    $selectedDocuments = $sessionAction->get();
    $destFolderPath = addTrailingSlash(backslashToSlash($_GET['current_folder_path']));
    if (sizeof($selectedDocuments)) {
        //get all files within the destination folder
        $allDocs = array();
        if ($fh = @opendir($_GET['current_folder_path'])) {
            while (($file = readdir($fh)) && $file != '.' && $file != '..') {
                $allDocs[] = getRealPath($destFolderPath . $file);
            }
        }
        include_once CLASS_FILE;
        $file = new file();
        //check if all files are allowed to cut or copy
        foreach ($selectedDocuments as $doc) {
            if (file_exists($doc) && isUnderRoot($doc)) {
                if (array_search(getRealPath($doc), $allDocs) === false || CONFIG_OVERWRITTEN) {
                    if (CONFIG_OVERWRITTEN) {
Exemplo n.º 26
0
             if (!$is_allowed_to_edit && DocumentManager::check_readonly($_course, api_get_user_id(), $chamiloPath)) {
                 $error = get_lang('CantDeleteReadonlyFiles');
                 //From Chamilo to Ajaxfilemanager
             } else {
                 $deleted = DocumentManager::delete_document($_course, $chamiloPath, $base_work_dir);
                 //deleted by Chamilo
                 //$file->delete(addTrailingSlash(backslashToSlash($doc))); // disabled deleted by ajaxfilemanager
             }
         } else {
             $error = get_lang('ProtectFolder');
             //From Chamilo to Ajaxfilemanager
         }
     } else {
         $file->delete(addTrailingSlash(backslashToSlash($doc)));
         //deleted by ajaxfilemanager
         event_system(LOG_USER_PERSONAL_DOC_DELETED, 'document_path', addTrailingSlash(backslashToSlash($doc)));
         event_system(LOG_MY_FOLDER_DELETE, LOG_MY_FOLDER_PATH, $doc);
     }
     //////end bridge to Chamilo
 } elseif (is_file($doc) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $doc)) {
     /////////////bridge to Chamilo by Juan Carlos Ra�a Trabado
     if (!empty($_course['path'])) {
         //find path
         $mainPath = '../../../../../../../courses/' . $_course['path'] . '/document/';
         //get Chamilo
         $fullPath = $doc;
         //get Ajaxfilemanager
         $chamiloPath = substr($fullPath, strlen($mainPath) - strlen($fullPath) - 1);
         //find base_work_dir
         $course_dir = $_course['path'] . "/document";
         //get Chamilo
Exemplo n.º 27
0
  function getCurrentFolderPath()
  {
  		$folderPathIndex = 'path';
  		$lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
		if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) )
		{
			$currentFolderPath = $_GET[$folderPathIndex];
		}
		elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
		{
			$currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex];
		}else
		{
			$currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
		}
		
		$currentFolderPath = (isUnderRoot($currentFolderPath)?backslashToSlash((addTrailingSlash($currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
		
		//keep track of this folder path in session 
		$_SESSION[$lastVisitedFolderPathIndex] = $currentFolderPath;
		

		if(!file_exists($currentFolderPath))
		{
			die(ERR_FOLDER_NOT_FOUND . $currentFolderPath);
		}  	
  }
Exemplo n.º 28
0
function getFileSystemMethod($args = array(), $context = false)
{
    $method = defined('FS_METHOD') ? FS_METHOD : false;
    //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
    if (!$method && function_exists('getmyuid') && function_exists('fileowner')) {
        if (!$context) {
            $context = APP_ROOT . '/updates';
        }
        $context = addTrailingSlash($context);
        $tempFileName = $context . 'tempWriteTest_' . time();
        $tempHandle = @fopen($tempFileName, 'w');
        if ($tempHandle) {
            if (getmyuid() == @fileowner($tempFileName)) {
                $method = 'direct';
            }
            @fclose($tempHandle);
            @unlink($tempFileName);
        }
    }
    //if ( ! $method && isset($args['connectionType']) && 'ssh' == $args['connectionType'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
    if (!$method && defined('APP_FTP_USE_SFTP') && APP_FTP_USE_SFTP == 1) {
        $method = 'SFTPExt';
    }
    if (!$method && extension_loaded('ftp')) {
        $method = 'FTPExt';
    }
    //if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
    return $method;
}
    if (!file_exists($_GET['delete'])) {
        $error = ERR_FILE_NOT_AVAILABLE;
    } elseif (!isUnderRoot($_GET['delete'])) {
        $error = ERR_FOLDER_PATH_NOT_ALLOWED;
    } else {
        include_once CLASS_FILE;
        $file = new file();
        if (is_dir($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, getBaseName($_GET['delete']))) {
            $file->delete(addTrailingSlash(backslashToSlash($_GET['delete'])));
        } elseif (is_file($_GET['delete']) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, getBaseName($_GET['delete'])) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, getBaseName($_GET['delete']))) {
            $file->delete($_GET['delete']);
        }
    }
} else {
    if (!isset($_POST['selectedDoc']) || !is_array($_POST['selectedDoc']) || sizeof($_POST['selectedDoc']) < 1) {
        $error = ERR_NOT_FILE_SELECTED;
    } else {
        include_once CLASS_FILE;
        $file = new file();
        foreach ($_POST['selectedDoc'] as $doc) {
            if (file_exists($doc) && isUnderRoot($doc)) {
                if (is_dir($doc) && isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $doc)) {
                    $file->delete(addTrailingSlash(backslashToSlash($doc)));
                } elseif (is_file($doc) && isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $doc) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $doc)) {
                    $file->delete($doc);
                }
            }
        }
    }
}
echo "{error:'" . $error . "'}";
Exemplo n.º 30
0
Arquivo: api.php Projeto: 0x17de/SimGa
function loadImages($other)
{
    assertAllowedFilePath($other);
    $path = addTrailingSlash(getBaseImagePath() . $other);
    assertIsDir($path);
    $result = array('path' => $path, 'images' => array(), 'folders' => array());
    // List all images in directory with selected properties
    $dir = opendir($path);
    while ($filename = readdir($dir)) {
        if (strlen($filename) == 0 || $filename[0] == "." || $filename[0] == "_") {
            continue;
        }
        $filepath = $path . $filename;
        if (is_file($filepath)) {
            if (!hasKnownImageExtension($filename)) {
                continue;
            }
            $size = getimagesize($filepath);
            array_push($result['images'], array('filename' => $filename, 'width' => $size[0], 'height' => $size[1], 'name' => null));
        } elseif (is_dir($filepath)) {
            $coverFilename = getCoverForFolder($filepath);
            if ($coverFilename != null) {
                array_push($result['folders'], array('name' => $filename, 'cover' => $coverFilename));
            }
            // @TODO: add first or configured image as folder image
        }
    }
    echo json_encode($result);
}