Exemplo n.º 1
0
 /**
  * constructor, sets up variables
  *
  */
 function __construct()
 {
     parent::__construct();
     /*
        File/dir attributes, each corresponding to a database field.  Useful for use in loops
        If an attribute was added to the table, add it here and possibly add it to
        set_attributes()
     
        set_attributes now uses this array().   07-Dec-01 skeeter
     */
     $this->attributes[] = 'deleteable';
     $this->attributes[] = 'content';
     /*
        Decide whether to use any actual filesystem calls(fopen(), fread(),
        unlink(), rmdir(), touch(), etc.).  If not, then we're working completely
        in the database.
     */
     $conf = CreateObject('phpgwapi.config', 'phpgwapi');
     $conf->read();
     if (isset($conf->config_data['file_store_contents']) && $conf->config_data['file_store_contents']) {
         $file_store_contents = $conf->config_data['file_store_contents'];
     } else {
         $file_store_contents = 'filesystem';
     }
     switch ($file_store_contents) {
         case 'braArkiv':
         case 'filesystem':
             $this->file_actions = 1;
             break;
         default:
             $this->file_actions = 0;
             break;
     }
     if ($this->file_actions) {
         $this->fileoperation = CreateObject("phpgwapi.vfs_fileoperation_{$file_store_contents}");
     }
     $this->acl_default = $conf->config_data['acl_default'];
     // test if the files-dir is inside the document-root, and refuse working if so
     //
     if ($this->file_actions && $this->in_docroot($this->basedir)) {
         $GLOBALS['phpgw']->common->phpgw_header();
         if ($GLOBALS['phpgw_info']['flags']['noheader']) {
             echo parse_navbar();
         }
         echo '<p align="center"><font color="red"><b>' . lang('Path to user and group files HAS TO BE OUTSIDE of the webservers document-root!!!') . "</b></font></p>\n";
         $GLOBALS['phpgw']->common->phpgw_exit();
     }
     /* We store the linked directories in an array now, so we don't have to make the SQL call again */
     if ($GLOBALS['phpgw_info']['server']['db_type'] == 'mssql' || $GLOBALS['phpgw_info']['server']['db_type'] == 'sybase') {
         $query = $GLOBALS['phpgw']->db->query("SELECT directory, name, link_directory, link_name" . " FROM phpgw_vfs WHERE CONVERT(varchar,link_directory) != ''" . " AND CONVERT(varchar,link_name) != ''" . $this->extra_sql(array('query_type' => VFS_SQL_SELECT)), __LINE__, __FILE__);
     } else {
         $query = $GLOBALS['phpgw']->db->query("SELECT directory, name, link_directory, link_name" . " FROM phpgw_vfs WHERE(link_directory IS NOT NULL or link_directory != '')" . " AND(link_name IS NOT NULL or link_name != '')" . $this->extra_sql(array('query_type' => VFS_SQL_SELECT)), __LINE__, __FILE__);
     }
     $this->linked_dirs = array();
     while ($GLOBALS['phpgw']->db->next_record()) {
         $this->linked_dirs[] = $this->Record();
     }
 }
Exemplo n.º 2
0
 /**
  * constructor, sets up variables
  *
  */
 function __construct()
 {
     parent::__construct();
     /*
        File/dir attributes, each corresponding to a database field.  Useful for use in loops
        If an attribute was added to the table, add it here and possibly add it to
        set_attributes ()
     
        set_attributes now uses this array().   07-Dec-01 skeeter
     */
     //			$this->attributes[] = '#NAMEHERE#';
     /* Dav properties */
     //First check if we are asked to use svn ...
     $use_svn = false;
     if (preg_match('/svn[s:][:\\/]\\//', $this->basedir)) {
         $use_svn = true;
         //so the 's' is kept
         $this->basedir = preg_replace('/^svn/', 'http', $this->basedir);
     }
     if (!$this->dav_user) {
         $this->dav_user = isset($GLOBALS['phpgw_info']['user']['userid']) ? (string) $GLOBALS['phpgw_info']['user']['userid'] : '';
     }
     //FIXME pwd has to be clear text.
     if (!$this->dav_pwd) {
         $this->dav_pwd = isset($GLOBALS['phpgw_info']['user']['passwd']) ? (string) $GLOBALS['phpgw_info']['user']['passwd'] : '';
     }
     // For testing purpose:
     //			$this->dav_user = '******';
     //			$this->dav_pwd = 'xxxxxx';
     $parsed_url = parse_url($this->basedir);
     $this->dav_host = $parsed_url['host'];
     $this->dav_port = isset($parsed_url['port']) ? $parsed_url['port'] : '';
     $this->dav_root = $parsed_url['scheme'] . '://';
     $this->dav_root .= $this->dav_host;
     $this->dav_root .= empty($this->dav_port) ? '' : ':' . $this->dav_port;
     if ($use_svn) {
         $this->dav_client = CreateObject('phpgwapi.http_svn_client');
         $this->svn_repository_path = $parsed_url['path'];
     } else {
         $this->dav_client = CreateObject('phpgwapi.http_dav_client');
     }
     $this->dav_client->set_credentials($this->dav_user, $this->dav_pwd);
     $this->dav_client->set_attributes($this->attributes, $this->vfs_property_map);
     $result = $this->dav_client->connect($this->dav_host, $this->dav_port, $parsed_url['scheme'] == 'https');
     if (DEBUG_DAV) {
         echo '<b>DAV client debugging enabled!</b>';
         $this->dav_client->set_debug(DBGTRACE | DBGINDATA | DBGOUTDATA | DBGSOCK | DBGLOW);
     }
     if (!$result) {
         echo '<h2>Cannot connect to the file repository server!</h2>';
         die($this->dav_client->get_body());
     }
     //determine the supported DAV features
     /*			$features = $this->dav_client->dav_features($this->repository);
     			if (!$features || ! in_array( '1', $features) )
     			{
     				die("Error :: The specified file repository: $this->repository doesn't appear to support WebDAV! ");
     			
     			}
     */
     register_shutdown_function(array(&$this, 'vfs_umount'));
     $this->debug('Constructed with debug enabled');
 }