<?php
//author Arkadiusz Binder 2013-07-30
//todo do przepisania na PHP i dodania opcji generowania Symlinkow 
//todo @2013-08-04 do skonczenia funkcja
//if(file_exists(".config.php")) require_once(".config.php");

/**
 * by plabudda:
 * 
 * 1. install:
 *   - create *.plist file:
 *     # php /Library/Server/Web/Data/Sites/Default/SE/se-dev-pl/bash_perms_make_se.php biuro.biall-net.pl addToLaunchctl
 *   - load by launchctl:
 *     # launchctl load /Library/LaunchDaemons/pl.biallnet.sync_perms.php.plist
 * 
 * 2. uninstall:
 *   - unload from launchctl:
 *     # launchctl unload /Library/LaunchDaemons/pl.biallnet.sync_perms.php.plist
 * 
 * 3. debug:
 *   - debug by www:
 *     /SE/se-dev-pl/bash_perms_make_se.php?DBG=1
 *   - more verbose debug:
 *     /SE/se-dev-pl/bash_perms_make_se.php?DBG=6
 */

define('DS', DIRECTORY_SEPARATOR);
define('APP_PATH_ROOT', dirname(__FILE__));
define('APP_PATH_WWW', dirname(__FILE__));
define('APP_PATH_CONFIG', APP_PATH_ROOT . DS . 'config');


require_once APP_PATH_ROOT . DS . 'se-lib' . DS . 'Lib.php';
Lib::loadClass('V');
Lib::loadClass('Config');
Lib::loadClass('DB');
Lib::loadClass('User');
Lib::loadClass('FoldersConfig');
Lib::loadClass('FileUploader');

if (isset($_SERVER["argv"][1])) {
	$_SERVER['SERVER_NAME'] = $_SERVER["argv"][1];
}
else if (empty($_SERVER["argv"]) && V::get('task', '', $_GET) == 'task') {
	SyncPerms::run($_SERVER["argv"][0], $_SERVER["argv"][1], 'nextTask', null);
}
else if (empty($_SERVER["argv"]) && V::get('task', '', $_GET) == 'newFiles') {
	SyncPerms::run($_SERVER["argv"][0], $_SERVER["argv"][1], 'newFiles', null);
}
else if (empty($_SERVER["argv"]) && V::get('DBG', '', $_GET, 'int') > 10) {
	/* Test file perms, change by user _www:
		$ ls -le 123.test/t4.txt
			-rw-r--r--+ 1 plabudda  staff  0  7 paź 23:10 123.test/t4.txt
			 0: group:workgroup inherited allow read,write,execute,append
			 1: user:_www inherited allow read,write,execute,append
	 * Perms was inherited from parent dir:
		$ drwxr-xr-x+ 7 plabudda  staff  238  7 paź 23:10 .
			 0: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,chown,file_inherit,directory_inherit
			 1: user:_www allow list,add_file,search,add_subdirectory,delete_child,chown,file_inherit,directory_inherit
	 * 
	 */

	$file = "/Users/plabudda/bup/123.test/t4.txt";
	exec("ls -le {$file}", $out, $outVal);
	echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('cmd'=>"ls -le {$file}", 'out'=>$out, 'outVal'=>$outVal));echo'</pre>';

	exec("chown _www {$file}", $out, $outVal);
	echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('cmd'=>"chown _www {$file}", 'out'=>$out, 'outVal'=>$outVal));echo'</pre>';

	exec("chmod +a \"user:kraskowskil allow read\" {$file}", $out, $outVal);
	echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('cmd'=>"chmod +a \"user:kraskowskil allow read\" {$file}", 'out'=>$out, 'outVal'=>$outVal));echo'</pre>';
}
else if (empty($_SERVER["argv"]) && V::get('DBG', '', $_GET, 'int') > 5) {
	$filesWithPerms = array(
		0 => "total 54512",
		1 => "-rwxrwx---@  1 kraskowskil  workgroup   3268608 Sep 30 13:36 Bez nazwy-1.indd",
		2 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		3 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		4 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		5 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		6 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		7 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		8 => "-rwxrwx---@  1 kraskowskil  workgroup   1703696 Sep 30 13:36 Bez nazwy-1.pdf",
		9 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		10 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		11 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		12 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		13 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		14 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		15 => "drwxrwx---+ 28 kraskowskil  workgroup       952 Oct  3 16:31 files",
		16 => " 0: user:kraskowskil allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		17 => " 1: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		18 => " 2: user:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		19 => "-rwxrwx---@  1 kraskowskil  workgroup   2527481 Oct  2 14:37 infografika.ai",
		20 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		21 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		22 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		23 => "-rwxrwx---@  1 kraskowskil  workgroup  14864384 Oct  7 16:05 katalog_biall-net.indd",
		24 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		25 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		26 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		27 => "-rwxrwx---@  1 kraskowskil  workgroup   1568645 Oct  3 14:45 katalog_biall-net.pdf",
		28 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		29 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		30 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		31 => "-rwxrwx---@  1 kraskowskil  workgroup   2596864 Sep 30 15:27 okladkii.indd",
		32 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		33 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		34 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		35 => "-rwxrwx---@  1 kraskowskil  workgroup   1369255 Sep 30 15:27 okladkii.pdf",
		36 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		37 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		38 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		39 => "",
		40 => "./files:",
		41 => "total 320224",
		42 => "-rwxrwx---@  1 kraskowskil  workgroup   2205050 Oct  2 12:09 2 strona-05-04-04.eps",
		43 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		44 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		45 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		46 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		47 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		48 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		49 => "-rwxrwx---@  1 kraskowskil  workgroup   2203910 Oct  2 12:06 2 strona-05-04.eps",
		50 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		51 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		52 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		53 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		54 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		55 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		56 => "-rwxrwx---@  1 kraskowskil  workgroup   1689006 Sep 30 15:44 2 strona-05.eps",
		57 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		58 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		59 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		60 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		61 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		62 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		63 => "-rwxrwx---@  1 kraskowskil  workgroup     20336 Oct  3 11:30 295062_520407511316102_217586070_n.jpg",
		64 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		65 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		66 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		67 => "-rwxrwx---@  1 kraskowskil  workgroup     37838 Oct  3 11:35 C0122306.jpg",
		68 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		69 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		70 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		71 => "-rwxrwx---@  1 kraskowskil  workgroup    465726 Oct  2 10:35 help_icon-20.eps",
		72 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		73 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		74 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		75 => "-rwxrwx---@  1 kraskowskil  workgroup   1031704 Sep 25 14:05 icon.ai",
		76 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		77 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		78 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		79 => "-rwxrwx---@  1 kraskowskil  workgroup   1050878 Sep 25 14:38 icon.eps",
		80 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		81 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		82 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		83 => "drwxrwx---+ 33 kraskowskil  workgroup      1122 Oct  4 16:26 icons",
		84 => " 0: user:kraskowskil allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		85 => " 1: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		86 => " 2: user:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		87 => "drwxrwx---+ 18 kraskowskil  workgroup       612 Sep 30 14:59 ideas",
		88 => " 0: user:kraskowskil allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		89 => " 1: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		90 => " 2: user:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		91 => "-rwxrwx---@  1 kraskowskil  workgroup    483118 Sep 30 10:35 internet_icon.eps",
		92 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		93 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		94 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		95 => "drwxrwx---+  5 kraskowskil  workgroup       170 Oct  3 15:36 mapka",
		96 => " 0: user:kraskowskil allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		97 => " 1: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		98 => " 2: user:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		99 => "-rwxrwx---@  1 kraskowskil  workgroup   3525022 Oct  2 12:17 mapka-03.eps",
		100 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		101 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		102 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		103 => "-rwxrwx---@  1 kraskowskil  workgroup    332462 Oct  2 09:36 network_icon.eps",
		104 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		105 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		106 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		107 => "drwxrwx---+ 38 kraskowskil  workgroup      1292 Sep 30 15:22 okĹadki",
		108 => " 0: user:kraskowskil allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		109 => " 1: group:workgroup allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		110 => " 2: user:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit",
		111 => "-rwxrwx---@  1 kraskowskil  workgroup    467090 Oct  2 10:50 sprawiedliwosc_icon-25.eps",
		112 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		113 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		114 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		115 => "-rwxrwx---@  1 kraskowskil  workgroup    475402 Sep 30 10:36 tel_icon.eps",
		116 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		117 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		118 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		119 => "-rwxrwx---@  1 kraskowskil  workgroup    538178 Sep 30 10:35 telefon_icon.eps",
		120 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		121 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		122 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		123 => "-rwxrwx---@  1 kraskowskil  workgroup  35522224 Sep 25 14:26 tlo.psd",
		124 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		125 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		126 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		127 => "-rwxrwx---@  1 kraskowskil  workgroup  39249644 Sep 25 14:29 tlo2.psd",
		128 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		129 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		130 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		131 => "-rwxrwx---@  1 kraskowskil  workgroup  40306893 Sep 25 14:36 tlo3.psd",
		132 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		133 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		134 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		135 => "-rwxrwx---@  1 kraskowskil  workgroup    982067 Sep 25 16:09 vector biall-katalog.ai",
		136 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		137 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		138 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		139 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		140 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		141 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		142 => "-rwxrwx---@  1 kraskowskil  workgroup   1745198 Sep 25 14:01 vector_icon-02.eps",
		143 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		144 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		145 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		146 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		147 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		148 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		149 => "-rwxrwx---@  1 kraskowskil  workgroup  30854359 Oct  3 16:31 vector_icon.ai",
		150 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		151 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		152 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		153 => "-rwxrwx---@  1 kraskowskil  workgroup    466622 Oct  2 11:13 wzrost_icon-26.eps",
		154 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		155 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		156 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		157 => "",
		158 => "./files/icons:",
		159 => "total 67864",
		160 => "-rwxrwx---@ 1 kraskowskil  workgroup   997806 Oct  4 16:26 ikonki-01.eps",
		161 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		162 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		163 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		164 => "-rwxrwx---@ 1 kraskowskil  workgroup   996502 Oct  4 16:26 ikonki-02.eps",
		165 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		166 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		167 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		168 => "-rwxrwx---@ 1 kraskowskil  workgroup  1092438 Oct  4 16:26 ikonki-03.eps",
		169 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		170 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		171 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		172 => "-rwxrwx---@ 1 kraskowskil  workgroup   997674 Oct  4 16:26 ikonki-04.eps",
		173 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		174 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		175 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		176 => "-rwxrwx---@ 1 kraskowskil  workgroup   995578 Oct  4 16:26 ikonki-05.eps",
		177 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		178 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		179 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		180 => "-rwxrwx---@ 1 kraskowskil  workgroup   995402 Oct  4 16:26 ikonki-06.eps",
		181 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		182 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		183 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		184 => "-rwxrwx---@ 1 kraskowskil  workgroup   995298 Oct  4 16:26 ikonki-07.eps",
		185 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		186 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		187 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		188 => "-rwxrwx---@ 1 kraskowskil  workgroup  1000758 Oct  4 16:26 ikonki-08.eps",
		189 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		190 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		191 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		192 => "-rwxrwx---@ 1 kraskowskil  workgroup   999030 Oct  4 16:26 ikonki-09.eps",
		193 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		194 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		195 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		196 => "-rwxrwx---@ 1 kraskowskil  workgroup   995542 Oct  4 16:26 ikonki-10.eps",
		197 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		198 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		199 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		200 => "-rwxrwx---@ 1 kraskowskil  workgroup   996810 Oct  4 16:26 ikonki-11.eps",
		201 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		202 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		203 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		204 => "-rwxrwx---@ 1 kraskowskil  workgroup   997534 Oct  4 16:26 ikonki-12.eps",
		205 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		206 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		207 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		208 => "-rwxrwx---@ 1 kraskowskil  workgroup   995674 Oct  4 16:26 ikonki-13.eps",
		209 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		210 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		211 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		212 => "-rwxrwx---@ 1 kraskowskil  workgroup  1002458 Oct  4 16:26 ikonki-14.eps",
		213 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		214 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		215 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		216 => "-rwxrwx---@ 1 kraskowskil  workgroup   997478 Oct  4 16:26 ikonki-15.eps",
		217 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		218 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		219 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		220 => "-rwxrwx---@ 1 kraskowskil  workgroup  1000090 Oct  4 16:26 ikonki-16.eps",
		221 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		222 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		223 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		224 => "-rwxrwx---@ 1 kraskowskil  workgroup   995934 Oct  4 16:26 ikonki-17.eps",
		225 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		226 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		227 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		228 => "-rwxrwx---@ 1 kraskowskil  workgroup   998298 Oct  4 16:26 ikonki-18.eps",
		229 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		230 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		231 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		232 => "-rwxrwx---@ 1 kraskowskil  workgroup   998362 Oct  4 16:26 ikonki-19.eps",
		233 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		234 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		235 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		236 => "-rwxrwx---@ 1 kraskowskil  workgroup   997602 Oct  4 16:26 ikonki-20.eps",
		237 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		238 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		239 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		240 => "-rwxrwx---@ 1 kraskowskil  workgroup   997114 Oct  4 16:26 ikonki-21.eps",
		241 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		242 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		243 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		244 => "-rwxrwx---@ 1 kraskowskil  workgroup   996854 Oct  4 16:26 ikonki-22.eps",
		245 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		246 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		247 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		248 => "-rwxrwx---@ 1 kraskowskil  workgroup  1103014 Oct  4 16:26 ikonki-23.eps",
		249 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		250 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		251 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		252 => "-rwxrwx---@ 1 kraskowskil  workgroup   991438 Oct  4 16:26 ikonki-24.eps",
		253 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		254 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		255 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		256 => "-rwxrwx---@ 1 kraskowskil  workgroup   991430 Oct  4 16:26 ikonki-25.eps",
		257 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		258 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		259 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		260 => "-rwxrwx---@ 1 kraskowskil  workgroup   991438 Oct  4 16:26 ikonki-26.eps",
		261 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		262 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		263 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		264 => "-rwxrwx---@ 1 kraskowskil  workgroup   991438 Oct  4 16:26 ikonki-27.eps",
		265 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		266 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		267 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		268 => "-rwxrwx---@ 1 kraskowskil  workgroup   991438 Oct  4 16:26 ikonki-28.eps",
		269 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		270 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		271 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		272 => "-rwxrwx---@ 1 kraskowskil  workgroup  1249471 Oct  4 16:25 ikonki.ai",
		273 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		274 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		275 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		276 => "-rwxrwx---@ 1 kraskowskil  workgroup  5194002 Oct  4 16:26 ikonki.eps",
		277 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		278 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		279 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		280 => "",
		281 => "./files/ideas:",
		282 => "total 8768",
		283 => "-rwxrwx---@ 1 kraskowskil  workgroup  3768091 Sep 27 14:57 3paski_luk.ai",
		284 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		285 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		286 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		287 => "-rwxrwx---@ 1 kraskowskil  workgroup    28477 Sep 25 09:14 400_F_49095520_EHpfz0T9xsrz4Qcos2X7b1VvSlvygWUk.jpg",
		288 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		289 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		290 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		291 => "-rwxrwx---@ 1 kraskowskil  workgroup    39349 Sep 25 09:13 400_F_49756688_8HTjP8kkooigl0EnxgTqR1DvjF2cqNWp.jpg",
		292 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		293 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		294 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		295 => "-rwxrwx---@ 1 kraskowskil  workgroup    29025 Sep 25 09:08 400_F_51706259_O0PU1efa5QurjxRCRNxGMHDt6f8fDCLS.jpg",
		296 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		297 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		298 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		299 => "-rwxrwx---@ 1 kraskowskil  workgroup    26788 Sep 25 09:14 400_F_51706705_HDERAFHA1Os1qTla9K0HxHxzIc5quX62.jpg",
		300 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		301 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		302 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		303 => "-rwxrwx---@ 1 kraskowskil  workgroup    41271 Sep 25 09:14 400_F_52552977_Pl4vTWyxrRZ4iaJuCCfZiTLeSYfN43iJ.jpg",
		304 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		305 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		306 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		307 => "-rwxrwx---@ 1 kraskowskil  workgroup    43872 Sep 25 09:14 400_F_53777430_KiOaUrNdOxswacYuVn0SwOAc90JWwRG7.jpg",
		308 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		309 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		310 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		311 => "-rwxrwx---@ 1 kraskowskil  workgroup    38987 Sep 25 09:13 400_F_54486482_2TZGny09uCMtw6erZaWDiR5gJQjRWIrP.jpg",
		312 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		313 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		314 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		315 => "-rwxrwx---@ 1 kraskowskil  workgroup    34531 Sep 25 09:14 400_F_55830018_xkWqEtY7JcsVZ9Wtdeh6JaFQUmRzD9E0.jpg",
		316 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		317 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		318 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		319 => "-rwxrwx---@ 1 kraskowskil  workgroup    21752 Sep 25 09:14 400_F_56095979_QYYraAruFiboCn2cU35DKdUuB6CVqyW7.jpg",
		320 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		321 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		322 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		323 => "-rwxrwx---@ 1 kraskowskil  workgroup    14273 Sep 27 12:25 FotoliaComp_51237043_N1KrwIvq3YyjEZA1WY9QG3O7JbB3fqYs.jpg",
		324 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		325 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		326 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		327 => "-rwxrwx---@ 1 kraskowskil  workgroup     8760 Sep 25 08:53 FotoliaComp_55911652_7qoklD7AAjujfZmnRrGD4ILjjr0ywEet.jpg",
		328 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		329 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		330 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		331 => "-rwxrwx---@ 1 kraskowskil  workgroup     7643 Sep 25 08:52 FotoliaComp_55912081_ranuB1khyEoqTiI1zy47waHKqo5winoP.jpg",
		332 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		333 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		334 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		335 => "-rwxrwx---@ 1 kraskowskil  workgroup     7937 Sep 25 08:55 FotoliaComp_56265582_E5MFDyTJnOpPzdiTjCEt9E5zwEfkLptQ.jpg",
		336 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		337 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		338 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		339 => "-rwxrwx---@ 1 kraskowskil  workgroup   347866 Sep 27 13:20 dott_infographic.jpg",
		340 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		341 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		342 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		343 => "",
		344 => "./files/mapka:",
		345 => "total 150200",
		346 => "-rwxrwx---@ 1 kraskowskil  workgroup  30354351 Oct  3 13:47 mapka.ai",
		347 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		348 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		349 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		350 => "-rwxrwx---@ 1 kraskowskil  workgroup  46537842 Oct  3 13:47 mapka.eps",
		351 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		352 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		353 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		354 => "",
		355 => "./files/okładki:",
		356 => "total 1632",
		357 => "-rwxrwx---@ 1 kraskowskil  workgroup   9257 Sep 30 15:18 csumx3PP.jpg.part",
		358 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		359 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		360 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		361 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		362 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		363 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		364 => "-rwxrwx---@ 1 kraskowskil  workgroup  12933 Sep 30 15:12 fotolia_29446398.jpg",
		365 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		366 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		367 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		368 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		369 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		370 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		371 => "-rwxrwx---@ 1 kraskowskil  workgroup  13501 Sep 30 15:17 fotolia_29447320.jpg",
		372 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		373 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		374 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		375 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		376 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		377 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		378 => "-rwxrwx---@ 1 kraskowskil  workgroup  12557 Sep 30 15:12 fotolia_29447379.jpg",
		379 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		380 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		381 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		382 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		383 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		384 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		385 => "-rwxrwx---@ 1 kraskowskil  workgroup  14641 Sep 30 15:13 fotolia_37429269.jpg",
		386 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		387 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		388 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		389 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		390 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		391 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		392 => "-rwxrwx---@ 1 kraskowskil  workgroup  14776 Sep 30 15:12 fotolia_37429319.jpg",
		393 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		394 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		395 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		396 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		397 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		398 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		399 => "-rwxrwx---@ 1 kraskowskil  workgroup  17084 Sep 30 15:18 fotolia_37877043.jpg",
		400 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		401 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		402 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		403 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		404 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		405 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		406 => "-rwxrwx---@ 1 kraskowskil  workgroup  15858 Sep 30 15:17 fotolia_37877044.jpg",
		407 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		408 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		409 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		410 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		411 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		412 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		413 => "-rwxrwx---@ 1 kraskowskil  workgroup  15595 Sep 30 15:18 fotolia_37877055.jpg",
		414 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		415 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		416 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		417 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		418 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		419 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		420 => "-rwxrwx---@ 1 kraskowskil  workgroup   7658 Sep 30 15:01 fotolia_40810341.jpg",
		421 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		422 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		423 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		424 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		425 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		426 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		427 => "-rwxrwx---@ 1 kraskowskil  workgroup   8255 Sep 30 15:12 fotolia_40941077.jpg",
		428 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		429 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		430 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		431 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		432 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		433 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		434 => "-rwxrwx---@ 1 kraskowskil  workgroup   9257 Sep 30 15:18 fotolia_41414049.jpg",
		435 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		436 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		437 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		438 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		439 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		440 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		441 => "-rwxrwx---@ 1 kraskowskil  workgroup   9036 Sep 30 15:17 fotolia_41414192.jpg",
		442 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		443 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		444 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		445 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		446 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		447 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		448 => "-rwxrwx---@ 1 kraskowskil  workgroup   7160 Sep 30 15:00 fotolia_42917170.jpg",
		449 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		450 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		451 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		452 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		453 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		454 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		455 => "-rwxrwx---@ 1 kraskowskil  workgroup  11022 Sep 30 15:12 fotolia_44067256.jpg",
		456 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		457 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		458 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		459 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		460 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		461 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		462 => "-rwxrwx---@ 1 kraskowskil  workgroup   8336 Sep 30 15:12 fotolia_52178094.jpg",
		463 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		464 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		465 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		466 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		467 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		468 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		469 => "-rwxrwx---@ 1 kraskowskil  workgroup   8656 Sep 30 15:12 fotolia_52420666.jpg",
		470 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		471 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		472 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		473 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		474 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		475 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		476 => "-rwxrwx---@ 1 kraskowskil  workgroup   8282 Sep 30 15:00 fotolia_55915200.jpg",
		477 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		478 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		479 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		480 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		481 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		482 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		483 => "-rwxrwx---@ 1 kraskowskil  workgroup   8599 Sep 30 15:00 fotolia_55915205.jpg",
		484 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		485 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		486 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		487 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		488 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		489 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		490 => "-rwxrwx---@ 1 kraskowskil  workgroup   8070 Sep 30 15:00 fotolia_55915214.jpg",
		491 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		492 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		493 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		494 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		495 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		496 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		497 => "-rwxrwx---@ 1 kraskowskil  workgroup   9807 Sep 30 15:01 fotolia_56010256.jpg",
		498 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		499 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		500 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		501 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		502 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		503 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		504 => "-rwxrwx---@ 1 kraskowskil  workgroup  10966 Sep 30 15:00 fotolia_56276809.jpg",
		505 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		506 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		507 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		508 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		509 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		510 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		511 => "-rwxrwx---@ 1 kraskowskil  workgroup   7704 Sep 30 15:03 fotolia_56517534.jpg",
		512 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		513 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		514 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		515 => " 3: user:kraskowskil inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		516 => " 4: group:workgroup inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		517 => " 5: user:_www inherited allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		518 => "-rwxrwx---@ 1 kraskowskil  workgroup  44802 Sep 30 14:40 stock-photo-12942297-smiling-business-man-speaking-over-a-phone.jpg",
		519 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		520 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		521 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		522 => "-rwxrwx---@ 1 kraskowskil  workgroup  43787 Sep 30 14:39 stock-photo-13171306-business-man-speaking-over-cellphone-with-colleagues-at-the-back.jpg",
		523 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		524 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		525 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		526 => "-rwxrwx---@ 1 kraskowskil  workgroup  39562 Sep 30 14:40 stock-photo-15199787-attentive-businessman-on-the-phone-with-colleague-in-background.jpg",
		527 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		528 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		529 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		530 => "-rwxrwx---@ 1 kraskowskil  workgroup  47620 Sep 30 14:53 stock-photo-15372082-executive-viewing-presentation-on-laptop.jpg",
		531 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		532 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		533 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		534 => "-rwxrwx---@ 1 kraskowskil  workgroup  35984 Sep 30 14:40 stock-photo-15416214-businessman-communicating-through-headset.jpg",
		535 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		536 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		537 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		538 => "-rwxrwx---@ 1 kraskowskil  workgroup  39520 Sep 30 14:55 stock-photo-15525740-couple-shopping-online.jpg",
		539 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		540 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		541 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		542 => "-rwxrwx---@ 1 kraskowskil  workgroup  37231 Sep 30 14:57 stock-photo-26891071-bringing-in-some-extra-eyes-on-the-project.jpg",
		543 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		544 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		545 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		546 => "-rwxrwx---@ 1 kraskowskil  workgroup  51777 Sep 30 14:37 stock-photo-3265037-businessman-happily-working.jpg",
		547 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		548 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		549 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		550 => "-rwxrwx---@ 1 kraskowskil  workgroup  45278 Sep 30 14:39 stock-photo-7007516-businessman-talking-on-telephone-in-office.jpg",
		551 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		552 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		553 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		554 => "-rwxrwx---@ 1 kraskowskil  workgroup  45685 Sep 30 14:39 stock-photo-7271704-happy-young-businesswoman-talking-on-phone.jpg",
		555 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		556 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		557 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		558 => "-rwxrwx---@ 1 kraskowskil  workgroup  46491 Sep 30 14:39 stock-photo-7701331-businessman-talking-on-telephone-sitting-by-computer.jpg",
		559 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		560 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		561 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		562 => "-rwxrwx---@ 1 kraskowskil  workgroup  29477 Sep 30 14:52 stock-photo-7722369-working-on-the-computer.jpg",
		563 => " 0: user:kraskowskil allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		564 => " 1: group:workgroup allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
		565 => " 2: user:_www allow read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown",
	);
	echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$filesWithPerms (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($filesWithPerms);echo'</pre>';
	$filesWithPermsTree = array();
	$lastName = '';
	$folderParent = '';
	foreach ($filesWithPerms as $line) {
		if (substr($line, 0, 1) == '-' || substr($line, 0, 1) == 'd') {// file name
			$fileParts = array();
			$filePartsArr = explode(' ', $line);
			foreach ($filePartsArr as $vPart) {
				if (!empty($vPart)) {
					$fileParts[] = $vPart;
				}
			}
			while (count($fileParts) > 9) {
				$lastPart = array_pop($fileParts);
				$prevPart = array_pop($fileParts);
				array_push($fileParts, "{$prevPart} {$lastPart}");
			}
			$file = new stdClass();
			$file->name = $fileParts[8];
			$file->path = array();
			if ($folderParent) $file->path[] = $folderParent;
			$file->path[] = $fileParts[8];
			$file->path = implode('/', $file->path);
			$file->owner = $fileParts[2];
			$file->group = $fileParts[3];
			$file->perms = $fileParts[0];
			$file->isDir = (substr($line, 0, 1) == 'd');
			$file->permsExtended = array();
			$filesWithPermsTree[$file->name] = $file;
			$lastName = $file;
		}
		else if (substr($line, 0, 1) == ' ') {// extended perm line
			$filesWithPermsTree[$file->name]->permsExtended[] = trim($line);
		}
		else if (substr($line, 0, 2) == './' && substr($line, -1) == ':') {// folder
			$folderParent = substr($line, 2, -1);
		}
		else if (substr($line, 0, 5) == 'total') {
			continue;
		}
		else if (empty($line)) {
			$folderParent = '';
			continue;
		}
	}
	echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$filesWithPermsTree (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($filesWithPermsTree);echo'</pre>';
	die('.OEF DBG > 5');
}
else if (empty($_SERVER["argv"]) && V::get('DBG', '', $_GET, 'int') > 0) {
	SyncPerms::run($_SERVER["argv"][0], $_SERVER["argv"][1], $arg2, $arg3);
}
else {
	die("\n The second argument should be server domain - e.g. biuro.kike.pl \n");
}

if (!empty($_SERVER["argv"][0]) && !empty($_SERVER["argv"][1])) {
	$arg2 = (!empty($_SERVER["argv"][2]))? $_SERVER["argv"][2] : null;
	$arg3 = (!empty($_SERVER["argv"][3]))? $_SERVER["argv"][3] : null;

	//bash_perms_make_se($_SERVER["argv"][0], $_SERVER["argv"][1], $arg2, $arg3);
	SyncPerms::run($_SERVER["argv"][0], $_SERVER["argv"][1], $arg2, $arg3);
}


require(APP_PATH_ROOT."/superedit-SEF.php");
//require_once(".config.php");

function group_clear($FILE_URL) {
	//	echo "\n chmod -N ".$FILE_URL; 
	system("chmod -N {$FILE_URL}");
}


function make_proj_perm($LINK_PROJ, $PR_GROUP, $PR_CLASS, $PR_L_AP_US, $PR_L_AP_US_MAN, $PR_DESC) {
	$CHMOD="0770";
	/*
	#SRC166-copy
	*/

	echo "160: chmod -R ".$CHMOD." ".$LINK_PROJ." CLASS:".$PR_CLASS.", PR_GROUP:".$PR_GROUP." ,  PR_L_AP_US:".$PR_L_AP_US." PR_L_AP_US_MAN:".$PR_L_AP_US_MAN."  ";
	system(" chmod -R ".$CHMOD."  ".$LINK_PROJ." ");
	if( empty($PR_GROUP)) $PR_GROUP='workgroup';
	if(!empty($PR_L_AP_US)) {
	echo "\n chown -R ".$PR_L_AP_US." ".$LINK_PROJ;
	system("chown -R ".$PR_L_AP_US." ".$LINK_PROJ);
	} else if(!empty($PR_L_AP_US_MAN)) { 
	echo "\n chown -R ".$PR_L_AP_US_MAN." ".$LINK_PROJ;
	system("chown -R ".$PR_L_AP_US_MAN." ".$LINK_PROJ);
	}

	if(!empty($PR_GROUP)  &&  ($PR_GROUP!="N/S;")) {
		echo "\n163: chgrp -R ".$PR_GROUP." ".$LINK_PROJ." ";
		system("chgrp  ".$PR_GROUP." ".$LINK_PROJ." ");  
		echo "\nCzyszcze group_clear ".$LINK_PROJ." ";
		group_clear($LINK_PROJ);
		system("chmod -R +a \"user:_www allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PROJ." ");  
		echo "\n167: chmod +a group:".$PR_GROUP." allow read... ";
		system("chmod -R +a \"group:".$PR_GROUP." allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PROJ." ");  
		//#dodanie tylko widoku plikow
		if (!empty($PR_CLASS)) {
			system("chmod -R  +a \"group:".$PR_CLASS." allow execute,list,readattr,readsecurity,file_inherit,directory_inherit\" ".$LINK_PROJ." ");  
		}
		echo "\n177 dodanie usera z PR_L_AP_US oraz PR_L_AP_US_MAN";
		if (!empty($PR_L_AP_US)) {
			system("chmod -R +a \"user:".$PR_L_AP_US." allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PROJ." ");  
		}
		if (!empty($PR_L_AP_US_MAN) && ($PR_L_AP_US_MAN!='NULL')) {
			system("chmod -R +a \"user:${PR_L_AP_US_MAN} allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PROJ." "); 
		}
	} else {
		echo "\nUnknown group ".$PR_GROUP." making clear for ".$LINK_PROJ." ";
		echo "\nCzyszcze group_clear ".$LINK_PROJ." ";
		group_clear($LINK_PROJ);
		if (!empty($PR_CLASS)) {
			system("chmod -R +a \"group:".$PR_CLASS." allow execute,list,readattr,readsecurity,file_inherit,directory_inherit\" ".$LINK_PROJ." ");  
		}
		echo "\n227: chmod -R +a \"user:_www allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\"  ".$LINK_PROJ." ";
		system("chmod -R +a \"user:_www allow add_file,search,add_subdirectory,delete_child,read,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PROJ." ");
	}  
	//	 #SRC166EOF-copy
}
 
 
function bash_perms_make_se($arg0, $arg1, $arg2, $arg3) {
/*
#!/bin/sh
#author Arkadiusz Binder 2013-07-23 

#plan
#1.odczytaj konfig typ labudda - baza, pliki pisma/projekty
#2.dla kazdego projektu rekursywnie ustaw chgrp=A_ADM_COMPANY
#3.dla kazdego projektu ustaw permy crhgrp=A_ADM_COMPANY

#CONFIG look for .cnf--folders.[hostname].ini.php
#CONFIG look for .cnf--zasob_[DbZasobId]-[hostname].ini.php

#plan 2 - jezeli jest plik w /config/.bash_perms_make_se.timestamp , 
#to dzialamy tak, ze szukamy plikow, ktore sie zmienily od tego momenu
#dla nich tylko zmieniamy uprawnienia 
#a) szukamy jakie sa wogole projekty w uzyciu ${PROJECTS_USED[@]}
#b) jak zalatwimy jakis  z tych projektow to robimy unsed ${PROJECT_USED[$PROJ]}
#c) potem robimy dla wszystkich zmiennych for var in ${PROJECT_USED[@]} - wyzwalamy funkcje $0 -force ${var} - czyli dokladamy po sprawie, ktorej nie znalezlismy
#d) trzeba tez znalezc wszystkie sprawy, ktore ulegly zmianie od ostatniego czasu i dla nich zrobic force
# profile : [ ! ${PR_GROUP} ] PR_GROUP='workgroup'

export PATH=$PATH:/opt/local/lib/mysql55/bin:/usr/local/mysql/bin:/Library/Server/Web/Sites/Default/SE/utils:/Library/Server/Web/Data/Sites/Default/SE/utils:/Library/Server/Web/Data/Sites/Default/SE/se-dev/utils

#funkcja czysci uprawnienia dla parametru $1 w filesystemie afs - dla wszysktich grup
*/

	$PROJ_mount_point = FoldersConfig::get('IN7_MK_BAZA_DYSTRYBUCJI_COLUMN', 'mount_point');
	$PISMA_mount_point = FoldersConfig::get('IN7_DZIENNIK_KORESP_COLUMN', 'mount_point');

	if (empty($PROJ_mount_point) || empty($PISMA_mount_point)) {
		die('Error in config for folders!');
	}
	else {
		echo "\n PROJ_mount_point = {$PROJ_mount_point} and PISMA_mount_point = {$PISMA_mount_point}";
	}


	system("echo \"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
	<key>Disabled</key>
    <false/>  
    <key>Label</key>
    <string>pl.biallnet.se.bash_perm</string>
    <key>UserName</key>
    <string>root</string>
    <key>ProgramArguments</key>
    <array>
       <string>php</string>
        <string>{$arg0}</string>
        <string>{$arg1}</string>
    </array>
    <key>StartInterval</key>
    <integer>60</integer>
</dict>
</plist>


\" > /Library/LaunchDaemons/pl.biallnet.se.bash_perm.php.plist");


 	$LAST_TIMESTAMP = file_get_contents(APP_PATH_ROOT . DS .'config' . DS . '.bash_perms_make_se.timestamp');
	$LAST_TIMESTAMP = str_replace(array("\n", "\r"), '', $LAST_TIMESTAMP);
	echo "\n read_timestamp:".$LAST_TIMESTAMP." arg3:".$arg3;


if(($arg2 != "-force" ) && (!empty($LAST_TIMESTAMP))) {
 	 echo "file exists - changing perms only to newer files : ";
	 echo "Finding newer Project files than (".$LAST_TIMESTAMP.")";
	// LAST_TIMESTAMP=`cat ${1}/.bash_perms_make_se.timestamp`
 	 echo "a) szukamy jakie sa wogole projekty w uzyciu -> {PROJECTS_USED[@]}";
		$sql="select t1.ID from IN7_MK_BAZA_DYSTRYBUCJI as t1 
		where t1.A_STATUS!='DELETED' ; ";
		$res=DB::query($sql);
		while($h=DB::fetch_array($res)) {
			$PROJECTS_USED[$h['ID']]=$h['ID'];
		}

	
       $PATH_CNT=explode('/',$PROJ_mount_point);
       $PATH_CNT=count($PATH_CNT);
       

	exec("find ".$PROJ_mount_point." -newer ".APP_PATH_ROOT . DS .'config' . DS . '.bash_perms_make_se.timestamp',$ID_PROJ_ARR);


  	print_r($ID_PROJ_ARR);
  	



 foreach($ID_PROJ_ARR as $ID_PROJ) { 





   exec("date  \"+%s\" > ".APP_PATH_ROOT . DS .'config' . DS .".bash_perms_make_se.timestamp");
   echo "\n ID_PROJ: ".$ID_PROJ." number ".$PATH_CNT." " ;

       $FOLDER_CUT=explode("/",$ID_PROJ);
       $FOLDER=$FOLDER_CUT[$PATH_CNT];
       list($ID)=explode(".",$FOLDER);
       
       if(isset($PROJECTS_USED[$ID])) { //kasujemy z listy rekord - oznaczmay, ze ustalilismy dla tego projektu permy
       		unset($PROJECTS_USED[$ID]); 
       } // else {
      // 	 continue ; 
      // }
       
		$sql="select t1.ID
				, t1.A_ADM_COMPANY
				, t1.A_CLASSIFIED
				, t1.L_APPOITMENT_USER
				, concat_ws('', t2.L_APPOITMENT_USER) as T2_L_APPOITMENT_USER
				, left(concat(t1.M_DISTRIBUTOR, '_', t1.M_DIST_DESC), 50) as DESCR
			from IN7_MK_BAZA_DYSTRYBUCJI as t1
				left join IN7_MK_BAZA_DYSTRYBUCJI as t2 on (t1.P_ID=t2.ID)
			where t1.ID='".$ID."'
		";
		$res2=DB::query($sql);
		//echo " SQL*".$sql."*  rows : ".$rows."\n";
		while($h2=DB::fetch_array($res2)) {

				$PR_GROUP=$h2['A_ADM_COMPANY'];
				$PR_CLASS=$h2['A_CLASSIFIED'];
				$PR_L_AP_US=$h2['L_APPOITMENT_USER'];
				$PR_L_AP_US_MAN=$h2['T2_L_APPOITMENT_USER'];
				$PR_DESC=str_replace($_SESSION['CONFIG']['BAD_FILE_SIGNS'],$_SESSION['CONFIG']['OK_FILE_SIGNS'],$h2['DESCR']);
  				$LINK_PROJ=$ID_PROJ;
     echo "\nFFFFFolder is ".$FOLDER_CUT[$PATH_CNT]." and id is (".$ID.")\n ***DESC(".$PR_DESC.")";


	
		
		       
		make_proj_perm($LINK_PROJ,$PR_GROUP,$PR_CLASS,$PR_L_AP_US,$PR_L_AP_US_MAN,$PR_DESC);
  
  
	// #EOF Find newer
 
		
  		}
 	}



 
// echo "c) szukanie edytowanych projektow uzytych"

 	$sql="select t1.ID from IN7_MK_BAZA_DYSTRYBUCJI as t1 where unix_timestamp(A_RECORD_UPDATE_DATE)>'".$LAST_TIMESTAMP."' ; ";
	$res3=DB::query($sql);
	echo "\n *sql*".$sql."**";
	while($h3=DB::fetch_array($res3)) {

	echo "\neditied project found ".$h3['ID']." - add to array - after ".$LAST_TIMESTAMP;
	ECHO "\n php ".$arg0." ".$arg1." -force ".$h3['ID']." ";
	bash_perms_make_se($arg0,$arg1,'-force',$h3['ID']);
// 	done
	}

// 		 [ ${#PROJECTS_USED[@]} -gt 0 ] && echo "Szukam uzytych projektow , ktore moze nie maja folderow: ${#PROJECTS_USED[@]}   "
		if(count($PROJECTS_USED)>0) {
//			  for var in ${PROJECTS_USED[@]} ; do
			  foreach($PROJECTS_USED as $var) {
//			    ls -d ${mount_point}/${PROJ_mount_point}/${var}.* >/dev/null 2>/dev/null || {
					exec("ls -d ".$PROJ_mount_point."/".$var.".* >/dev/null 2>/dev/null",$out,$exit_find);
					if($exit_find==1) {
						$stdout="";
			     		echo "\n Brak projektu ".$var." - uruchamiam bash_perms_make_se(".$arg0." ".$arg1." -force ".$var.") ";		
			     	  	bash_perms_make_se($arg0,$arg1,'-force',$var);
			     	 
			     	 }
//			     }
//		  	  done
			  }
		}

}
else {
 exec("date  \"+%s\" > ".APP_PATH_ROOT . DS .'config' . DS .".bash_perms_make_se.timestamp");


// date "+%s" > ${1}/.bash_perms_make_se.timestamp
 
 		$SQL_LIMIT="";
	if(isset($arg3)) {
		echo "\nForced limit to only one project ".$arg3;
		$SQL_LIMIT=" and t1.ID='".$arg3."' ";
	} else {
	 echo "\nNot found ".APP_PATH_ROOT . DS .'config' . DS . '.bash_perms_make_se.timestamp file - making perms to any files in PROJECTS and LETTERS';

	}
		$sql="select t1.ID,t1.A_ADM_COMPANY,t1.A_CLASSIFIED,t1.L_APPOITMENT_USER,concat_ws('',t2.L_APPOITMENT_USER) as T2_L_APPOITMENT_USER,left(concat(t1.M_DISTRIBUTOR,'_',t1.M_DIST_DESC),50)  as DESCR from IN7_MK_BAZA_DYSTRYBUCJI as t1 
		left join IN7_MK_BAZA_DYSTRYBUCJI as t2 on t1.P_ID=t2.ID
		 where t1.A_STATUS!='DELETED' ".$SQL_LIMIT;
		$res2=DB::query($sql);
		echo " SQL*".$sql."*  rows : ".$rows."\n ";
		while($h2=DB::fetch_array($res2)) {
				$PR_ID=$h2['ID'];
				$PR_GROUP=$h2['A_ADM_COMPANY'];
				$PR_CLASS=$h2['A_CLASSIFIED'];
				$PR_L_AP_US=$h2['L_APPOITMENT_USER'];
				$PR_L_AP_US_MAN=$h2['T2_L_APPOITMENT_USER'];
				$PR_DESC=str_replace($_SESSION['CONFIG']['BAD_FILE_SIGNS'],$_SESSION['CONFIG']['OK_FILE_SIGNS'],$h2['DESCR']);
  				$LINK_PROJ=$PROJ_mount_point."/".$PR_ID.".*";


		$FILE_EXIST=0;
		exec("ls -d ".$LINK_PROJ." 2>/dev/null ",$LINK_PROJ_CUST,$stderr);
		if($stderr==0) {
			 $LINK_PROJ_CUST=$LINK_PROJ_CUST[0];
		 	 echo "\n152:jest katalog (".$LINK_PROJ.")  ".$LINK_PROJ_CUST."  \n mkdir -p ".$LINK_PROJ_CUST."/PISMA_LINK  \n";
		 	 system("mkdir -p ".$LINK_PROJ_CUST."/PISMA_LINK");
			 $FILE_EXIST=1;
		} else {
		 	  echo "\n155:brak katalogu (".$stderr.")(".$stdout.") ".$PR_ID." for ".$PR_DESC." bedzie : mkdir ".$PROJ_mount_point."/".$PR_ID.".".$PR_DESC ;
			  system("mkdir ".$PROJ_mount_point."/".$PR_ID.".".$PR_DESC);
		  	  $FILE_EXIST=1;
		 	  system("mkdir -p  ".$LINK_PROJ_CUST."/PISMA_LINK");
		}
		if($FILE_EXIST==1) {
			  make_proj_perm($LINK_PROJ,$PR_GROUP,$PR_CLASS,$PR_L_AP_US,$PR_L_AP_US_MAN,$PR_DESC);
		}
		
		
		
		$sql="select ID,K_TYP_KORESP from IN7_DZIENNIK_KORESP where ID_PROJECT=".$PR_ID." ; ";
		$res4=DB::query($sql);
		//echo " SQL*".$sql."*  rows : ".$rows."\n";
		while($h4=DB::fetch_array($res4)) {
				$PR_ID=$h2['ID'];
				$LINK_PISMO=$PISMA_mount_point."/".$h4['K_TYP_KORESP']."/".$h4['ID'].".*";
				$FILE_EXIST=0;
		
					#teraz pisma
			 		//for PISMO in `echo "select concat(ID,'#;#',K_TYP_KORESP) from IN7_DZIENNIK_KORESP where ID_PROJECT=${PR_ID} ; "|mysql  -s -u${DB_USER} -p${DB_PASS} -h${DB_HOST} -D${DB_NAME}  |sed 's/\ /_/g' ` ; do
					//echo "175:PISMO is ${PISMO}"
					//PISMO_ID=`echo ${PISMO} |awk -F'#;#' '{ print $1 }'`
					//PISMO_GDZIE=`echo ${PISMO} |awk -F'#;#' '{ print $2 }'`
					//LINK_PISMO="${mount_point}/${PISMA_mount_point}/${PISMO_GDZIE}/${PISMO_ID}.*"
			
					
					exec("ls ".$LINK_PISMO." 2>/dev/null >/dev/null",$stdout,$stderr);
					if($stderr==0) {
					 echo "\njest pismo ".$LINK_PISMO ;
					
					 	  //make_proj_perm($LINK_PISMO,$PR_GROUP,$PR_CLASS,$PR_L_AP_US,$PR_L_AP_US_MAN,$PR_DESC);
					
					   echo "\n177:chmod -R 0770 ".$LINK_PISMO ;
					   system("chmod -R 0770 ".$LINK_PISMO);	
					   		 if(!empty($PR_GROUP)  && ($PR_GROUP!="N/S;"))  { 
					        	 echo "\n180:chgrp -R ".$PR_GROUP." ".$LINK_PISMO." ";
							 	system("chgrp -R ".$PR_GROUP." ".$LINK_PISMO);
							 
								//		 echo "Czyszcze group_clear ${LINK_PROJ} "
								 group_clear($LINK_PISMO);
								//		 echo "183:ONLY APPEND chmod -R +a user:_www allow (..) ${LINK_PISMO}  "
								 system("chmod -R +a \"user:_www allow add_file,search,add_subdirectory,read,readattr,append,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit\" ".$LINK_PISMO);    
									     echo "\n185:ONLY READ!! chmod -R +a group:".$PR_GROUP." allow read... ".$LINK_PISMO." ";
							 	 system("chmod -R +a \"group:".$PR_GROUP." allow add_file,append,search,add_subdirectory,read,readattr,readextattr,readsecurity,file_inherit,directory_inherit\" ".$LINK_PISMO);  
								
								//robie symlinki
//								 system("ln ".$LINK_PISMO." ".$LINK_PROJ_CUST."/PISMA_LINK/");
							} 
						} else {
					 	 echo "\n194: brak pism dla dziennika ".$LINK_PISMO;
					// #FILE_EXIST=0
				   		}
					     
			 		
		
		 }		
	
	
	
	
	}

}

} //eof func


class SyncPerms {

	public static function getLastRunDate() {
		if (($argFromDate = V::get('_fromDate', '', $_GET)) != '') {
			// Format: 2013-10-07 23:46
			if (strlen($argFromDate) == 16
					&& substr($argFromDate, 4, 1) == '-'
					&& substr($argFromDate, 7, 1) == '-'
					&& substr($argFromDate, 10, 1) == '-'
					&& substr($argFromDate, 13, 1) == ':'
					&& is_numeric(str_replace(array('-', ':'), '', $argFromDate))
			) {
				$lastRunDate = mktime(substr($argFromDate, 11, 2), substr($argFromDate, 14, 2), 0, substr($argFromDate, 5, 2), substr($argFromDate, 8, 2), substr($argFromDate, 0, 4));
				$lastRunDate = date("Y-m-d H:i", $lastRunDate);
			}
		}
		if (!$lastRunDate) {
			$lastRunDate = mktime(date("H") - 1, date("i"), date("s"), date("n"), date("j"), date("Y"));
			$lastRunDate = date("Y-m-d H:i", $lastRunDate);
		}
		//$lastRunDate = '2013-09-01 01:00';
echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">lastRunDate (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($lastRunDate);echo'</pre>';
		return $lastRunDate;
	}

	public static function installTable() {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}

		$sql = "
			CREATE TABLE IF NOT EXISTS `_SYNC_FILE_PERMS` (
				`ID` int(11) NOT NULL AUTO_INCREMENT,
				`ID_PROJECT` int(11) NOT NULL,
				`L_APPOITMENT_USER` varchar(64) DEFAULT '',
				`A_ADM_COMPANY` varchar(64) NOT NULL DEFAULT '',
				`A_CLASSIFIED` varchar(64) NOT NULL DEFAULT '',
				`PARENT_L_APPOITMENT_USER` varchar(64) NOT NULL DEFAULT '',
				`A_LAST_SYNC` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
				`A_SYNCHRONIZED` tinyint(4) NOT NULL DEFAULT '0',
				PRIMARY KEY (`ID`),
				UNIQUE KEY `ID_PROJECT` (`ID_PROJECT`)
			) ENGINE=MyISAM  DEFAULT CHARSET=latin2 ;
		";
		$db->query($sql);
	}

	public static function run($script_name, $domain, $arg2, $arg3) {
		if ($arg2 == 'addToLaunchctl') {
			system("echo \"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
	<key>Disabled</key>
		<false/>  
		<key>Label</key>
		<string>pl.biallnet.sync_perms.php</string>
		<key>UserName</key>
		<string>root</string>
		<key>ProgramArguments</key>
		<array>
			 <string>php</string>
				<string>{$_SERVER["argv"][0]}</string>
				<string>{$_SERVER["argv"][1]}</string>
		</array>
		<key>StartInterval</key>
		<integer>60</integer>
</dict>
</plist>

\" > /Library/LaunchDaemons/pl.biallnet.sync_perms.php.plist");
			echo "Run By Root: launchctl load /Library/LaunchDaemons/pl.biallnet.sync_perms.php.plist\n";
		}
		else if ($arg2 == 'newFiles') {
			$time = new stdClass();
			$time->start = time();
			self::fixLastModifiedFiles();
			self::saveTask(-1);
		}
		else if ($arg2 == 'nextTask') {
			$time = new stdClass();
			$time->start = time();

			self::installTable();
			self::generateTasksNewRecords();
			self::generateTasksUpdated();

			$limit = V::get('_limit', 1, $_GET, 'int');
			for ($i = 0; $i < $limit; $i++) {
				$time->cur = time();
				if ($time->cur - $time->start > 60 * 5) {
					if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:2px solid red;text-align:left;">Force-break time('.($time->cur - $time->start).') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';echo'</pre>';}
					break;
				}

				$task = self::getTask();
				if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">time('.($time->cur - $time->start).') task (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($task);echo'</pre>';}
				if (!$task) {
					break;
				}

				self::executeTask($task);

				self::saveTask($task->ID_PROJECT);
			}
		}
		else {
			self::installTable();

			$fixedProjIds = self::fixLastModifiedByFiles();
			self::fixLastModifiedByDB($fixedProjIds);
		}
	}

	public static function generateTasksUpdated() {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}
		$sqlTest = "select p.ID, p.`L_APPOITMENT_USER`, p.`A_ADM_COMPANY`, p.`A_CLASSIFIED`, s. * 
			from `_SYNC_FILE_PERMS` as s, `IN7_MK_BAZA_DYSTRYBUCJI` as p, `IN7_MK_BAZA_DYSTRYBUCJI` as pp
			where
				s.`ID_PROJECT`=p.`ID` and pp.`ID`=p.`P_ID`
				and (
					s.`L_APPOITMENT_USER`!=p.`L_APPOITMENT_USER`
					or s.`A_ADM_COMPANY`!=p.`A_ADM_COMPANY`
					or s.`A_CLASSIFIED`!=p.`A_CLASSIFIED`
					or s.`PARENT_L_APPOITMENT_USER`!=pp.`L_APPOITMENT_USER`
				)
		";

		$sql = "update `_SYNC_FILE_PERMS` as s, `IN7_MK_BAZA_DYSTRYBUCJI` as p, `IN7_MK_BAZA_DYSTRYBUCJI` as pp
			set
				s.`L_APPOITMENT_USER`=p.`L_APPOITMENT_USER`
				, s.`A_ADM_COMPANY`=p.`A_ADM_COMPANY`
				, s.`A_CLASSIFIED`=p.`A_CLASSIFIED`
				, s.`PARENT_L_APPOITMENT_USER`=pp.`L_APPOITMENT_USER`
				, s.`A_SYNCHRONIZED`=0
			where
				s.`ID_PROJECT`=p.`ID` and pp.`ID`=p.`P_ID`
				and (
					s.`L_APPOITMENT_USER`!=p.`L_APPOITMENT_USER`
					or s.`A_ADM_COMPANY`!=p.`A_ADM_COMPANY`
					or s.`A_CLASSIFIED`!=p.`A_CLASSIFIED`
					or s.`PARENT_L_APPOITMENT_USER`!=pp.`L_APPOITMENT_USER`
				)
		";
		$res = $db->query($sql);
	}

	public static function generateTasksNewRecords() {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}
		$sql = "insert ignore into `_SYNC_FILE_PERMS` (`ID_PROJECT`, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`, `PARENT_L_APPOITMENT_USER`)
			values (-1, '', '', '', '');
		";
		$res = $db->query($sql);

		$sql = "insert ignore into `_SYNC_FILE_PERMS` (`ID_PROJECT`, `L_APPOITMENT_USER`, `A_ADM_COMPANY`, `A_CLASSIFIED`, `PARENT_L_APPOITMENT_USER`)
			select p.`ID`, p.`L_APPOITMENT_USER`, p.`A_ADM_COMPANY`, p.`A_CLASSIFIED`, pp.`L_APPOITMENT_USER`
			from `IN7_MK_BAZA_DYSTRYBUCJI` as p
				left join `IN7_MK_BAZA_DYSTRYBUCJI` as pp on (pp.`ID`=p.`P_ID`)
			where p.`A_STATUS`!='DELETED'
		";
		$res = $db->query($sql);
	}

	/**
	 * Znajdź najstarszy aktualizowany projekt.
	 */
	public static function getTask() {
		$task = null;
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}
		$sql = "select s.*
				, p.`L_APPOITMENT_USER` as p__L_APPOITMENT_USER
				, p.`A_ADM_COMPANY` as p__A_ADM_COMPANY
				, p.`A_CLASSIFIED` as p__A_CLASSIFIED
				, pp.`L_APPOITMENT_USER` as p__PARENT_L_APPOITMENT_USER
				, p.`M_DIST_DESC` as p__M_DIST_DESC
			from `_SYNC_FILE_PERMS` as s
				left join `IN7_MK_BAZA_DYSTRYBUCJI` as p on(p.`ID`=s.`ID_PROJECT`)
				left join `IN7_MK_BAZA_DYSTRYBUCJI` as pp on(pp.`ID`=p.`P_ID`)
			where s.`A_SYNCHRONIZED`=0
			order by s.`A_LAST_SYNC` asc, s.`ID` asc
			limit 1
		";
		$res = $db->query($sql);
		if ($r = $db->fetch($res)) {
			$task = $r;
		}
		return $task;
	}

	public static function getLastFilesTime() {
		$lastFilesTime = null;
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}
		$sql = "select s.`A_LAST_SYNC`
			from `_SYNC_FILE_PERMS` as s
			where s.`ID_PROJECT`=-1
		";
		$res = $db->query($sql);
		if ($r = $db->fetch($res)) {
			$lastFilesTime = $r->A_LAST_SYNC;
		}

		if (!$lastFilesTime) {
			$lastFilesTime = mktime(date("H"), date("i") - 10, date("s"), date("n"), date("j"), date("Y"));
			$lastFilesTime = date("Y-m-d H:i", $lastFilesTime);
		}
		return $lastFilesTime;
	}

	public static function saveTask($idProject) {
		$task = null;
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}
		$sql = "update `_SYNC_FILE_PERMS` as s
			set s.`A_SYNCHRONIZED`=1
				, s.`A_LAST_SYNC`=NOW()
			where s.`ID_PROJECT`={$idProject}
		";
		$res = $db->query($sql);
		return $task;
	}

	public static function executeTask($task) {
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">executeTask (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($task);echo'</pre>';}

		$confTblName = 'IN7_MK_BAZA_DYSTRYBUCJI_COLUMN';
		$PROJ_mount_point = FoldersConfig::get($confTblName, 'mount_point');

		$project = new stdClass();
		$project->ID = $task->ID_PROJECT;
		$project->L_APPOITMENT_USER = $task->p__L_APPOITMENT_USER;
		$project->A_ADM_COMPANY = $task->p__A_ADM_COMPANY;
		$project->A_CLASSIFIED = $task->p__A_CLASSIFIED;
		$project->PARENT_L_APPOITMENT_USER = $task->p__PARENT_L_APPOITMENT_USER;
		$project->M_DIST_DESC = $task->p__M_DIST_DESC;

		$folderConf = FoldersConfig::getAll($confTblName);
		$uploader = new FileUploader($confTblName, $project);
		$errMsg = '';
		if (!$uploader->setConfig($folderConf, $errMsg)) {
			trigger_error("Error: folders config!", E_USER_NOTICE);
			die("Error: folders config!");
		}
		$uploader->findFolder();
		$mainFolder = $uploader->getDestFolder();
		if(V::get('DBG', '', $_GET, 'int') > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">generated folderName('.$project->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';var_dump($uploader);echo'</pre>';}
		if (!$mainFolder) {
			$mainFolder = $uploader->generateFolderName();
			$mainFolderPath = rtrim($PROJ_mount_point, '/') . '/' . $mainFolder;
			if(V::get('DBG', '', $_GET, 'int') > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">generated folderName('.$project->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array($mainFolder, $mainFolderPath));echo'</pre>';}

			exec("mkdir {$mainFolderPath}");
			mkdir($mainFolderPath, 0770, true);
			@chmod($mainFolderPath, 0770);
			if (!file_exists($mainFolderPath)) {
				trigger_error("Error: Nie udało się utworzyć folderu! ({$mainFolder})", E_USER_NOTICE);
				return false;
			}
			$requirePermsExt = self::getRequiredPermsExtByRecord($project);
			$file = new stdClass();
			$file->name = $mainFolder;
			$file->path = $mainFolder;
			$file->owner = '';
			$file->group = '';
			$file->perms = '';
			$file->isDir = true;
			$file->permsExt = array();
			$cmdList = self::fixFilePerms($file, $requirePermsExt, "{$PROJ_mount_point}/" . addslashes($mainFolder), $project);
			if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">cmdList-P('.$project->ID.') fixFilePerms (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}
		}
		else {
			$cmdList = self::fixProject($project, $mainFolder, $PROJ_mount_point);
			if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">cmdList-P('.$project->ID.') fixProject (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}

			$cmdKorepList = self::fixProjectKoresp($project);
			if (!empty($cmdKorepList)) {
				if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">cmdList-P('.$project->ID.') fixProjectKoresp (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdKorepList);echo'</pre>';}
				foreach ($cmdKorepList as $vCmd) {
					$cmdList[] = $vCmd;
				}
			}
			// TODO: $cmdDrukiList = self::fixProjectDruki($project, $mainFolder, $PROJ_mount_point);
		}
		if (!empty($cmdList)) {
			foreach ($cmdList as $vCmd) {
				if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Exec-cmdList-P('.$project->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($vCmd);echo'</pre>';}
				exec($vCmd, $out, $outValue);
				if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Done-cmdList-P('.$project->ID.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array($outValue, $out));echo'</pre>';}
				if ($outValue != 0) {
					trigger_error("Error-cmd: {$vCmd}", E_USER_NOTICE);
				}
			}
		}
	}

	public static function getRequiredPermsExtByRecord($project) {
		$requirePermsExt = array();
		if (!$project->L_APPOITMENT_USER && !$project->A_ADM_COMPANY) {// no owner, no write group
			// TODO: group PODMIOT
			$requirePermsExt["group:workgroup"] = array('write', 'read');
		}
		else {
			if ($project->L_APPOITMENT_USER) {
				$requirePermsExt["user:{$project->L_APPOITMENT_USER}"] = array('write', 'read');
			}

			if (!empty($project->A_ADM_COMPANY) && $project->A_ADM_COMPANY == $project->A_CLASSIFIED) {
				$requirePermsExt["group:{$project->A_ADM_COMPANY}"] = array('read', 'write');
			}
			else if (empty($project->A_ADM_COMPANY) && empty($project->A_CLASSIFIED)) {
				$requirePermsExt["group:workgroup"] = array('write', 'read');
			}
			else {
				if ($project->A_ADM_COMPANY) {
					$requirePermsExt["group:{$project->A_ADM_COMPANY}"] = array('write');
				}
				if ($project->A_CLASSIFIED) {
					$requirePermsExt["group:{$project->A_CLASSIFIED}"] = array('read');
				}
			}
		}

		// add parent owner
		if (!empty($project->PARENT_L_APPOITMENT_USER) && $project->PARENT_L_APPOITMENT_USER != $project->L_APPOITMENT_USER) {
			$requirePermsExt["user:{$project->PARENT_L_APPOITMENT_USER}"] = array('write', 'read');
		}

		// add user:_www perms read, write
		$requirePermsExt["user:_www"] = array('write', 'read');

		return $requirePermsExt;
	}

	/**
	 * Used for files added/modified by samba/afp.
	 * 
	 * Last execute time is stored as ID_PROJECT = -1 in _SYNC_FILE_PERMS
	 * @see getLastFilesTime
	 */
	public static function fixLastModifiedFiles() {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}

		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">fixLastModifiedFiles (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("fixLastModifiedFiles");echo'</pre>';}

		$PROJ_mount_point = FoldersConfig::get('IN7_MK_BAZA_DYSTRYBUCJI_COLUMN', 'mount_point');
		$PISMA_mount_point = FoldersConfig::get('IN7_DZIENNIK_KORESP_COLUMN', 'mount_point');

		$foundProjectFiles = array();
		$lastRunDate = self::getLastFilesTime();
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$lastRunDate (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($lastRunDate);echo'</pre>';}
		//exec("cd {$PROJ_mount_point}; find . -newermt '{$lastRunDate}' ", $foundPaths);
		exec("cd {$PROJ_mount_point}; find . -newermt '{$lastRunDate}' -type f -exec ls -lea '{}' \;", $filesWithPerms);
		if (!empty($filesWithPerms)) {
			$filesWithPermsTree = array();
			$lastName = '';
			foreach ($filesWithPerms as $line) {
				if (substr($line, 0, 1) == '-') {// file name
					$fileParts = array();
					$filePartsArr = explode(' ', $line);
					foreach ($filePartsArr as $vPart) {
						if (!empty($vPart) || $vPart === '0') {
							$fileParts[] = $vPart;
						}
					}
					while (count($fileParts) > 9) {
						$lastPart = array_pop($fileParts);
						$prevPart = array_pop($fileParts);
						array_push($fileParts, "{$prevPart} {$lastPart}");
					}

					$file = new stdClass();

					if (!isset($fileParts[8])) {
						echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Error parse file name (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('line'=>$line, 'fileParts'=>$fileParts));echo'</pre>';
						//continue;
					}

					$file->name = end($fileParts);
					$file->path = end($fileParts);
					$file->owner = $fileParts[2];
					$file->group = $fileParts[3];
					$file->perms = $fileParts[0];
					$file->isDir = (substr($line, 0, 1) == 'd');
					$file->permsExt = array();
					$filesWithPermsTree[$file->name] = $file;
					$lastName = $file->name;
				}
				else if (substr($line, 0, 1) == ' ') {// extended perm line
					if ($lastName == '..') {
						continue;
					}
					$filesWithPermsTree[$file->name]->permsExt[] = trim($line);
				}
				else {// parse error
					$lastName = '..';
				}
			}

			foreach ($filesWithPermsTree as $vFile) {
				$vFile->path = ltrim($vFile->path, './');
				$vFile->path = explode('/', $vFile->path);
				$vFile->projectFolder = array_shift($vFile->path);
				$vFile->path = implode('/', $vFile->path);
				$projId = explode('.', $vFile->projectFolder);
				$projId = reset($projId);
				if (is_numeric($projId) && $projId > 0) {
					$foundProjectFiles[$projId][] = $vFile;
				}
			}
		}
		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">filesWithPerms (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($filesWithPerms);echo'</pre>';}
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">foundProjectFiles (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($foundProjectFiles);echo'</pre>';}

		if (!empty($foundProjectFiles)) {
			$sql = "select p.`ID`
					, p.`L_APPOITMENT_USER`
					, p.`A_ADM_COMPANY`
					, p.`A_CLASSIFIED`
					, pp.`L_APPOITMENT_USER` as PARENT_L_APPOITMENT_USER
				from IN7_MK_BAZA_DYSTRYBUCJI as p
					left join IN7_MK_BAZA_DYSTRYBUCJI as pp on (pp.ID=p.P_ID)
				where p.`ID` in (" . implode(',', array_keys($foundProjectFiles)) . ")
			";
			$res = $db->query($sql);
			while ($r = $db->fetch($res)) {

				$requirePermsExt = self::getRequiredPermsExtByRecord($r);

				foreach ($foundProjectFiles[$r->ID] as $vFile) {
					$cmdList = self::fixFilePerms($vFile, $requirePermsExt, "{$PROJ_mount_point}/" . addslashes($vFile->projectFolder), $r);
					if (!empty($cmdList)) {
						if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$cmdList P('.$r->ID.') total('.count($cmdList).') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}
					} else {
						if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$cmdList P('.$r->ID.') total('.count($cmdList).') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}
					}
				}
			}
		}
	}


	/**
	 * TODO: RMME
	 * @returns array - last modified project ids.
	 */
	public static function fixLastModifiedByFiles() {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}

		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">fixLastModifiedByFiles (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("fixLastModifiedByFiles");echo'</pre>';}

		/*
		 * $ man find:
			-newer file
					True if the current file has a more recent last modification time than file.

			-newerXY file
					True if the current file has a more recent last access time (X=a), inode creation time (X=B), change time (X=c),
					or modification time (X=m) than the last access time (Y=a), inode creation time (Y=B), change time (Y=c), or mod-
					ification time (Y=m) of file.  In addition, if Y=t, then file is instead interpreted as a direct date specifica-
					tion of the form understood by cvs(1).  Note that -newermm is equivalent to -newer.
		 * 
		 * $ man chmod:
			 -i      Removes the 'inherited' bit from all entries in the named file(s) ACLs.
		 *
		 * chmod -a "admin allow write" file1  # remove line
		 * chmod -a# 1 file1                   # remove line at position 1
		 * 
		 * chmod +a nie zmienia modify date: find . -newermt '2013-10-07 ...'
		 */
		// find /Library/Server/Web/Data/Sites/Default/PLIKI/PROJEKTY -newermt '2013-10-07 16:20'

		$PROJ_mount_point = FoldersConfig::get('IN7_MK_BAZA_DYSTRYBUCJI_COLUMN', 'mount_point');
		$PISMA_mount_point = FoldersConfig::get('IN7_DZIENNIK_KORESP_COLUMN', 'mount_point');

		$foundProjectIds = array();
		$lastRunDate = self::getLastRunDate();
		exec("cd {$PROJ_mount_point}; find . -newermt '{$lastRunDate}' ", $foundPaths);
		if (!empty($foundPaths)) {
			foreach ($foundPaths as $path) {
				$path = ltrim($path, './');
				$folder = explode('/', $path);
				$folder = reset($folder);
				$projId = explode('.', $folder);
				$projId = reset($projId);
				if (is_numeric($projId)) {
					$foundProjectIds[$projId] = $folder;
				}
			}
		}
		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">foundPaths (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($foundPaths);echo'</pre>';}
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">foundProjectIds (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($foundProjectIds);echo'</pre>';}

		if (!empty($foundProjectIds)) {
			$sql = "select p.`ID`
					, p.`L_APPOITMENT_USER`
					, p.`A_ADM_COMPANY`
					, p.`A_CLASSIFIED`
					, pp.`L_APPOITMENT_USER` as PARENT_L_APPOITMENT_USER
				from IN7_MK_BAZA_DYSTRYBUCJI as p
					left join IN7_MK_BAZA_DYSTRYBUCJI as pp on (pp.ID=p.P_ID)
				where p.`ID` in (" . implode(',', array_keys($foundProjectIds)) . ")
			";
			$res = $db->query($sql);
			while ($r = $db->fetch($res)) {
				$mainFolder = $foundProjectIds[$r->ID];

				$cmdList = self::fixProject($r, $mainFolder, $PROJ_mount_point);
				if (!empty($cmdList)) {
					if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$cmdList P('.$r->ID.') total('.count($cmdList).') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}
				} else {
					if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$cmdList P('.$r->ID.') total('.count($cmdList).') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($cmdList);echo'</pre>';}
				}
			}
		}
		return array_keys($foundProjectIds);
	}

	/**
	 * TODO: RMME
	 */
	public static function fixLastModifiedByDB($fixedProjIds) {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}

		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">fixLastModifiedByDB (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r("fixLastModifiedByDB");echo'</pre>';}

		$sqlWhereAdd = '';
		if (!empty($fixedProjIds)) {
			$sqlWhereAdd = " and p.`ID` not in (" . implode(',', $fixedProjIds) . ") ";
		}

		$projectList = array();
		$lastRunDate = self::getLastRunDate();
		$sql = "select p.`ID`
				, p.`L_APPOITMENT_USER`
				, p.`A_ADM_COMPANY`
				, p.`A_CLASSIFIED`
				, pp.`L_APPOITMENT_USER` as PARENT_L_APPOITMENT_USER
			from IN7_MK_BAZA_DYSTRYBUCJI as p
				left join IN7_MK_BAZA_DYSTRYBUCJI as pp on (pp.ID=p.P_ID)
			where
				(	p.`A_RECORD_UPDATE_DATE`>'{$lastRunDate}'
					or p.`A_RECORD_CREATE_DATE`>'{$lastRunDate}'
				)
				{$sqlWhereAdd}
		";
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
		$res = $db->query($sql);
		while ($r = $db->fetch($res)) {
			$projectList[$r->ID] = $r;
		}

		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">projectList (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($projectList);echo'</pre>';}

	}

	public static function fixProjectKoresp($project) {
		$db = DB::getDB();
		if (!$db) {
			die("DB Error: No DB!");
		}

		$PISMA_mount_point = FoldersConfig::get('IN7_DZIENNIK_KORESP_COLUMN', 'mount_point');
		$PISMA_mount_point = rtrim($PISMA_mount_point, '/');
		$pismaList = array();
		// $PISMA_mount_point / {TYP_KORESP} / {ID} . *
		$sql = "select k.`ID`
				, k.`K_TYP_KORESP`
			from `IN7_DZIENNIK_KORESP` as k
			where k.`ID_PROJECT`={$project->ID}
		";
		$res = $db->query($sql);
		while ($r = $db->fetch($res)) {
			$pismaList[$r->ID] = $r->K_TYP_KORESP;
		}

		if (empty($pismaList)) {
			return false;
		}
		$lsCmd = array();
		foreach ($pismaList as $kID => $vTyp) {
			$lsCmd[] = "{$vTyp}/{$kID}.*";
		}
		if (empty($lsCmd)) {
			return false;
		}
		$lsCmd = 'ls -le ' . implode($lsCmd, ' ');
		if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Koreps lsCmd (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($lsCmd);echo'</pre>';}

		exec("cd {$PISMA_mount_point}; {$lsCmd} ", $filesWithPerms);
		if (!empty($filesWithPerms)) {
			$filesWithPermsTree = array();
			$lastName = '';
			foreach ($filesWithPerms as $line) {
				if (substr($line, 0, 1) == '-') {// file name
					$fileParts = array();
					$filePartsArr = explode(' ', $line);
					foreach ($filePartsArr as $vPart) {
						if (!empty($vPart) || $vPart === '0') {
							$fileParts[] = $vPart;
						}
					}
					while (count($fileParts) > 9) {
						$lastPart = array_pop($fileParts);
						$prevPart = array_pop($fileParts);
						array_push($fileParts, "{$prevPart} {$lastPart}");
					}

					$file = new stdClass();

					if (!isset($fileParts[8])) {
						echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Error parse file name (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('line'=>$line, 'fileParts'=>$fileParts));echo'</pre>';
						//continue;
					}

					$file->name = end($fileParts);
					$file->path = end($fileParts);
					$file->owner = $fileParts[2];
					$file->group = $fileParts[3];
					$file->perms = $fileParts[0];
					$file->isDir = (substr($line, 0, 1) == 'd');
					$file->permsExt = array();
					$filesWithPermsTree[$file->name] = $file;
					$lastName = $file->name;
				}
				else if (substr($line, 0, 1) == ' ') {// extended perm line
					if ($lastName == '..') {
						continue;
					}
					$filesWithPermsTree[$file->name]->permsExt[] = trim($line);
				}
				else {// parse error
					$lastName = '..';
				}
			}
		}
		if(V::get('DBG', '', $_GET, 'int') > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">filesWithPerms (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($filesWithPerms);echo'</pre>';}
		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">filesWithPermsTree (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): '."path: {$PROJ_mount_point}\n";print_r($filesWithPermsTree);echo'</pre>';}

		$cmdList = array();
		$requirePermsExt = self::getRequiredPermsExtByRecord($project);
		foreach ($filesWithPermsTree as $kFileName => $vFile) {
			$cmdFile = self::fixFilePerms($vFile, $requirePermsExt, "{$PISMA_mount_point}", $project);
			if (!empty($cmdFile)) {
				foreach ($cmdFile as $vCmd) {
					$cmdList[] = $vCmd;
				}
			}
		}
		return $cmdList;
	}

	public static function fixProject($r, $mainFolder, $PROJ_mount_point) {
		if ($r->ID == 1695) {// TODO: 8853 pliki w katalog - stary HANDLOWY
			if(V::get('DBG', '', $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TODO: pomin - za dużo plików ('.$r->ID.'/'.$mainFolder.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($r);echo'</pre>';}
			return false;
		}

		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">r('.$r->ID.'/'.$mainFolder.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($r);echo'</pre>';}

		$requirePermsExt = self::getRequiredPermsExtByRecord($r);

		//make_proj_perm($LINK_PROJ, $PR_GROUP, $PR_CLASS, $PR_L_AP_US, $PR_L_AP_US_MAN, $PR_DESC);

		$filesWithPerms = array();
		exec("cd \"{$PROJ_mount_point}/" . addslashes($mainFolder) . "\"; ls -Rlea . ", $filesWithPerms);
		if(V::get('DBG', '', $_GET, 'int') > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$filesWithPerms (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($filesWithPerms);echo'</pre>';}
		$filesWithPermsTree = array();

		$lastName = '';
		$folderParent = '';
		foreach ($filesWithPerms as $line) {
			if (substr($line, 0, 1) == '-' || substr($line, 0, 1) == 'd') {// file name
				$fileParts = array();
				$filePartsArr = explode(' ', $line);
				foreach ($filePartsArr as $vPart) {
					if (!empty($vPart) || $vPart === '0') {
						$fileParts[] = $vPart;
					}
				}
				while (count($fileParts) > 9) {
					$lastPart = array_pop($fileParts);
					$prevPart = array_pop($fileParts);
					array_push($fileParts, "{$prevPart} {$lastPart}");
				}

				if (end($fileParts) == '..' || (end($fileParts) == '.' && $folderParent)) {
					$lastName = '..';
					continue;
				}

				$file = new stdClass();

				if (!isset($fileParts[8])) {
					echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">Error parse file name (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('line'=>$line, 'fileParts'=>$fileParts));echo'</pre>';
					//continue;
				}

				$file->name = end($fileParts);
				$file->path = array();
				if ($folderParent) $file->path[] = $folderParent;
				$file->path[] = end($fileParts);
				$file->path = implode('/', $file->path);
				$file->owner = $fileParts[2];
				$file->group = $fileParts[3];
				$file->perms = $fileParts[0];
				$file->isDir = (substr($line, 0, 1) == 'd');
				$file->permsExt = array();
				$filesWithPermsTree[$file->name] = $file;
				$lastName = $file;
			}
			else if (substr($line, 0, 1) == ' ') {// extended perm line
				if ($lastName == '..') {
					continue;
				}
				$filesWithPermsTree[$file->name]->permsExt[] = trim($line);
			}
			else if (substr($line, 0, 2) == './' && substr($line, -1) == ':') {// folder
				$folderParent = substr($line, 2, -1);
			}
			else if (substr($line, 0, 5) == 'total') {
				continue;
			}
			else if (empty($line)) {
				$folderParent = '';
				continue;
			}
		}
		if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$filesWithPermsTree (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($filesWithPermsTree);echo'</pre>';}

		// check perms
		/*
files:
W		read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown
W		read,write,execute,append,readattr,writeattr,readextattr,writeextattr,readsecurity
R		read,      execute,       readattr,          readextattr,             readsecurity

dir:
W		list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown,file_inherit,directory_inherit
W		list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,                    file_inherit,directory_inherit
R		list,         search,                              readattr,          readextattr,             readsecurity,                    file_inherit,directory_inherit
		 */
		$cmdList = array();
		foreach ($filesWithPermsTree as $kFileName => $vFile) {
			$cmdFile = self::fixFilePerms($vFile, $requirePermsExt, "{$PROJ_mount_point}/" . addslashes($mainFolder), $r);
			if (!empty($cmdFile)) {
				foreach ($cmdFile as $vCmd) {
					$cmdList[] = $vCmd;
				}
			}
		}
		return $cmdList;
	}

	public static function fixFilePerms($vFile, $requirePermsExt, $mainPath, $r) {
		$vReqPermsExt = array();
		foreach ($requirePermsExt as $kPermObj => $vPerms) {
			$vReqPermsExt[$kPermObj] = array();
			foreach ($vPerms as $vPerm) {
				if ($vFile->isDir) {
					if ($vPerm == 'read') {
						$vReqPermsExt[$kPermObj]['list'] = 0;
						$vReqPermsExt[$kPermObj]['search'] = 0;
						$vReqPermsExt[$kPermObj]['readattr'] = 0;
						$vReqPermsExt[$kPermObj]['readextattr'] = 0;
						$vReqPermsExt[$kPermObj]['readsecurity'] = 0;
						$vReqPermsExt[$kPermObj]['file_inherit'] = 0;
						$vReqPermsExt[$kPermObj]['directory_inherit'] = 0;
					}
					else if ($vPerm == 'write') {
						$vReqPermsExt[$kPermObj]['add_file'] = 0;
						$vReqPermsExt[$kPermObj]['add_subdirectory'] = 0;
						$vReqPermsExt[$kPermObj]['delete_child'] = 0;
						$vReqPermsExt[$kPermObj]['writeattr'] = 0;
						$vReqPermsExt[$kPermObj]['writeextattr'] = 0;
						$vReqPermsExt[$kPermObj]['writesecurity'] = 0;
						$vReqPermsExt[$kPermObj]['chown'] = 0;
					}
				}
				else {
					if ($vPerm == 'read') {
						$vReqPermsExt[$kPermObj]['read'] = 0;
						$vReqPermsExt[$kPermObj]['execute'] = 0;
						$vReqPermsExt[$kPermObj]['readattr'] = 0;
						$vReqPermsExt[$kPermObj]['readextattr'] = 0;
						$vReqPermsExt[$kPermObj]['readsecurity'] = 0;
					}
					else if ($vPerm == 'write') {
						$vReqPermsExt[$kPermObj]['write'] = 0;
						$vReqPermsExt[$kPermObj]['append'] = 0;
						$vReqPermsExt[$kPermObj]['writeattr'] = 0;
						$vReqPermsExt[$kPermObj]['writeextattr'] = 0;
						$vReqPermsExt[$kPermObj]['writesecurity'] = 0;
						$vReqPermsExt[$kPermObj]['chown'] = 0;
					}
				}
			}
		}

		$permsToRemove = array();
		foreach ($vFile->permsExt as $vPermExtLine) {
			$vPermExtArr = explode(' ', $vPermExtLine);
			$vPermExt = new stdClass();
			$vPermExt->nr = trim($vPermExtArr[0], ' :');
			$vPermExt->permObj = $vPermExtArr[1];
			$vPermExt->perms = '';
			if (count($vPermExtArr) == 4) {
				$vPermExt->perms = explode(',', $vPermExtArr[3]);
			}
			else if (count($vPermExtArr) == 5 && $vPermExtArr[2] == 'inherited') {
				$vPermExt->perms = explode(',', $vPermExtArr[4]);
			}
			else {
				echo "Error: Perm Ext Line format! ({$vPermExtLine})";
				continue;
			}

			$permFound = false;
			foreach ($vReqPermsExt as $kPermObj => $vPerms) {
				if (false !== strpos($vPermExtLine, $kPermObj)) {
					foreach ($vPerms as $kPerm => $vPermChecked) {
						if (in_array($kPerm, $vPermExt->perms)) {
							$vReqPermsExt[$kPermObj][$kPerm] = 1;
							$permFound = true;
						}
					}
				}
			}
			if (!$permFound) {
				$permsToRemove[] = $vPermExt->nr;
			}
			//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$vReqPermsExt('.$vFile->name.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($vReqPermsExt);echo'</pre>';
		}

		if (!empty($permsToRemove)) {
			if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:300px;overflow:auto;border:1px solid red;text-align:left;">TO-rm('.$r->ID.'): $permsToRemove('.$vFile->name.') isDir('.$vFile->isDir.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('permsToRemove'=>$permsToRemove, 'vFile->permsExt'=>$vFile->permsExt, 'r'=>$r));echo'</pre>';}
			$permsToRemove = array_reverse($permsToRemove);
			foreach ($permsToRemove as $vPermInd) {
				$cmdList []= "chmod -a# {$vPermInd} \"{$mainPath}/{$vFile->path}\" ";
			}
		}

		$permsToAdd = array();
		foreach ($vReqPermsExt as $kPermObj => $vPerms) {
			foreach ($vPerms as $kPerm => $vPermChecked) {
				if (!$vPermChecked) {
					$permsToAdd[$kPermObj][$kPerm] = 1;
				}
			}
		}
		if (!empty($permsToAdd)) {
			if(V::get('DBG', '', $_GET, 'int') > 1){echo'<pre style="max-height:300px;overflow:auto;border:1px solid red;text-align:left;">TO-add('.$r->ID.'): $permsToAdd('.$vFile->name.') isDir('.$vFile->isDir.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r(array('permsToAdd'=>$permsToAdd, 'vFile->permsExt'=>$vFile->permsExt, 'r'=>$r));echo'</pre>';}
			foreach ($permsToAdd as $kPermObj => $vPerms) {
				$cmdList []= "chmod +a \"{$kPermObj} allow " . implode(',', array_keys($vPerms)) . "\" \"{$mainPath}/{$vFile->path}\" ";
			}
		}
		return $cmdList;
	}

}

//dodatkowo synchronizacja automatyczna uprawnien
//SEF('KIKE_MIGRACJA_KIKE_AUTH');
//if(strstr($_SESSION['SYSTEM_PROFILE_STRING'],'KIKE' ))  KIKE_MIGRACJA_KIKE_AUTH($LAST_TIMESTAMP);

?>
