forked from Dolibarr/dolibarr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_filecheck_xml.php
70 lines (63 loc) · 2.47 KB
/
generate_filecheck_xml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/php
<?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file build/generate_filecheck_xml.php
* \ingroup dev
* \brief This script create a xml checksum file
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=dirname(__FILE__).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
// Main
parse_str($argv[1]);
//$outputfile=dirname(__FILE__).'/../htdocs/install/filelist-'.$release.'.xml';
$outputfile=dirname(__FILE__).'/../htdocs/install/filelist.xml';
$fp = fopen($outputfile,'w');
fputs($fp, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
fputs($fp, '<checksum_list>'."\n");
fputs($fp, '<dolibarr_root_dir version="'.$release.'">'."\n");
$dir_iterator = new RecursiveDirectoryIterator(dirname(__FILE__).'/../htdocs/');
$iterator = new RecursiveIteratorIterator($dir_iterator);
// need to ignore document custom etc
$files = new RegexIterator($iterator, '#^(?:[A-Z]:)?(?:/(?!(?:custom|documents|conf|install|nltechno))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
$dir='';
$needtoclose=0;
foreach ($files as $file) {
$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
if ($newdir!=$dir) {
if ($needtoclose)
fputs($fp, '</dir>'."\n");
fputs($fp, '<dir name="'.$newdir.'" >'."\n");
$dir = $newdir;
$needtoclose=1;
}
if (filetype($file)=="file") {
fputs($fp, '<md5file name="'.basename($file).'">'.md5_file($file).'</md5file>'."\n");
}
}
fputs($fp, '</dir>'."\n");
fputs($fp, '</dolibarr_root_dir>'."\n");
fputs($fp, '</checksum_list>'."\n");
fclose($fp);
print "File ".$outputfile." generated\n";
exit(0);