Exemplo n.º 1
0
/**
 *	Update domain directory for soecified domain 
 *
 *	@param string $did	domain id
 *	@return bool		return TRUE on success, FALSE on failure
 */
function update_domain_dir($did)
{
    global $data, $_SERWEB;
    $domain_dir = $_SERWEB["serwebdir"] . "domains/" . $did . "/";
    $vf = new Version_file($domain_dir . "versions.ini.php");
    /* Open file containing versions of other files
    	   Do not check for errors here - if there will be error in version file, 
    	   the file will be recreated by values in DB
    	 */
    $vf->open();
    $local_versions = $vf->get_all_files();
    /* get versions of files in DB */
    if (false === ($files = $data->get_latest_file_versions($did, null))) {
        return false;
    }
    /* synchronize directory with DB */
    foreach ($files as $file => $f_prop) {
        if ($f_prop['deleted']) {
            /* file should be deleted */
            if (isset($local_versions[$file])) {
                $vf->remove_file($file);
            }
            if (file_exists($domain_dir . $file)) {
                rm($domain_dir . $file);
            }
        } elseif ($f_prop['dir']) {
            /* directory */
            if (!file_exists($domain_dir . $file)) {
                RecursiveMkdir($domain_dir . $file, 0770);
            }
        } elseif (!isset($local_versions[$file]) or !file_exists($domain_dir . $file) or $local_versions[$file] < $f_prop['version']) {
            /* file should be updated/created */
            $ds =& Domain_settings::singleton($did, $file);
            if (false === $ds->update_local_file($f_prop['version'])) {
                return false;
            }
            $vf->set_version($file, $f_prop['version']);
        }
    }
    $vf->close();
    return true;
}
Exemplo n.º 2
0
 /**
  *	Update version of file in file containing versions of local files
  *	
  *	@param	int		$ver	version
  *	@return	bool			TRUE on success or FALSE on error
  */
 function update_version_file($ver)
 {
     $vf = new Version_file($this->domain_dir . "/" . $this->did . "/versions.ini.php");
     if (false === $vf->open()) {
         return false;
     }
     if (is_null($ver)) {
         //if file has been deleted, remove it from version file
         $vf->remove_file($this->filename);
     } else {
         $vf->set_version($this->filename, $ver);
     }
     if (false === $vf->close()) {
         return false;
     }
     return true;
 }