function mosReadDirectory($path, $filter = '.', $recurse = false, $fullpath = false)
 {
     $arr = array();
     if (!@is_dir($path)) {
         return $arr;
     }
     $handle = opendir($path);
     while ($file = readdir($handle)) {
         $dir = DOCMAN_Compat::mosPathName($path . '/' . $file, false);
         $isDir = is_dir($dir);
         if ($file != "." && $file != "..") {
             if (preg_match("/{$filter}/", $file)) {
                 if ($fullpath) {
                     $arr[] = trim(DOCMAN_Compat::mosPathName($path . '/' . $file, false));
                 } else {
                     $arr[] = trim($file);
                 }
             }
             if ($recurse && $isDir) {
                 $arr2 = DOCMAN_Compat::mosReadDirectory($dir, $filter, $recurse, $fullpath);
                 $arr = array_merge($arr, $arr2);
             }
         }
     }
     closedir($handle);
     asort($arr);
     return $arr;
 }
 function DOCMAN_File($name, $path)
 {
     $path = DOCMAN_Compat::mosPathName($path);
     if (!is_dir($path)) {
         $path = dirname($path);
         // Make sure there's a trailing slash in the path
         $path = DOCMAN_Compat::mosPathName($path);
     }
     $this->name = trim($name);
     $this->path = $path;
     if (strcasecmp(substr($this->name, 0, _DM_DOCUMENT_LINK_LNG), _DM_DOCUMENT_LINK) == 0) {
         $url = substr($this->name, 6);
         if (substr($url, 0, 7) != 'file://') {
             $this->_isLink = true;
             $this->size = 0;
             $this->mime = 'link';
         } else {
             $this->_isLink = false;
             $this->name = DOCMAN_Utils::basename($url);
             $this->path = dirname($url) . '/';
             $this->size = @filesize($url);
             $this->mime = DOCMAN_MIME_Magic::filenameToMIME($url, false);
         }
     } else {
         $this->_isLink = false;
         $this->size = @filesize($this->path . $this->name);
         $this->mime = DOCMAN_MIME_Magic::filenameToMIME($this->name, false);
         $this->name = DOCMAN_Utils::basename($name);
     }
     $this->ext = $this->getExtension();
 }
Esempio n. 3
0
function installTheme($userfile)
{
    DOCMAN_token::check() or die('Invalid Token');
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_DMThemes::showInstallMessage(_DML_NEED_ZLIB, _DML_INSTALLER_ERROR, 'index.php?option=com_docman&task=cpanel');
        exit;
    }
    $installer = new DOCMAN_InstallerTheme();
    $path = DOCMAN_Compat::mosPathName($userfile);
    if (!is_dir($path)) {
        $path = dirname($path);
    }
    if (!$installer->installPackage($path)) {
        showErrorMessage($installer);
        exit;
    }
    HTML_DMThemes::showInstallMessage('', _DML_SUCCESFULLY_INSTALLED . ' ' . $installer->installFilename(), 'index.php?option=com_docman&section=themes');
}
 /**
  * Custom install method
  *
  * @param int $ The id of the module
  * @param string $ The URL option
  * @param int $ The client id
  */
 function uninstall($id)
 {
     $database = JFactory::getDBO();
     // Delete directories
     $path = JPATH_SITE . DS . 'components' . DS . 'com_docman' . DS . 'themes' . DS . $id;
     $id = str_replace('..', '', $id);
     if (trim($id)) {
         if (is_dir($path)) {
             return deldir(DOCMAN_Compat::mosPathName($path));
         } else {
             $this->setError(4, _DML_DIRNOTEXISTS);
             return false;
         }
     } else {
         $this->setError(4, _DML_TEMPLATEEMPTY);
         return false;
     }
 }