Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 39ee02b

Browse files
author
chrisisbeef
committed
Repackaging Source
1 parent 539b8b5 commit 39ee02b

File tree

3 files changed

+80
-35
lines changed

3 files changed

+80
-35
lines changed

build-functions.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,36 @@ function getDirectoryTree( $outerDir, $filters = array() ){
231231
}
232232

233233
function getRelativePath( $a ) {
234-
$o = "";
234+
$o = "";
235235
if ( is_array($a) ) {
236236
foreach( $a as $e ) {
237237
$o .= getRelativePath( $e );
238238
}
239239
}
240240
return $o.$a;
241241
}
242+
243+
function microtime_float() {
244+
list($usec,$sec) = explode(" ",microtime());
245+
return ((float)$usec + (float)$sec);
246+
}
247+
248+
function copydir( $src, $dst ) {
249+
$filelist = get_files($src);
250+
foreach($filelist as $i=>$file) {
251+
$dir_name = substr( $file, 0, strrpos( $file, '/' ) );
252+
if ( !is_dir($dir_name) ) {
253+
echo("- Creating Directory: $dir_name\n");
254+
mkdir($dir_name);
255+
}
256+
257+
$dst_file = substr( $file, strlen( $src )+1 );
258+
echo("- $file (".filesize($file)." bytes) => $dst$dst_file");
259+
copy( $file, $dst.$dst_file );
260+
if ( filesize($file) == filesize($dst.$dst_file) )
261+
echo("\t[OK]\n");
262+
else
263+
echo("\t[ERROR]\n");
264+
}
265+
}
242266
?>

build-properties.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/*
3+
* OWASP Enterprise Security API (ESAPI)
4+
*
5+
* This file is part of the Open Web Application Security Project (OWASP)
6+
* Enterprise Security API (ESAPI) project. For details, please see
7+
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
8+
*
9+
* Copyright (c) 2008 - The OWASP Foundation
10+
*
11+
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
12+
* LICENSE before you use, modify, and/or redistribute this software.
13+
*/
14+
15+
$DOCUMENTATION_DIR = "documentation/";
16+
$SOURCE_DIR = "src/main/javascript";
17+
$RESOURCES_DIR = "src/main/resources";
18+
$OUTPUT_DIR = "dist/";
19+
$OUTPUT_RESOURCES = "resources/";
20+
$OUTPUT_DOCUMENTATION = "docs/";
21+
$OUTPUT_FILE = "esapi.js";
22+
$OUTPUT_FILE_COMPRESSED = "esapi-compressed.js";
23+
24+
$JDK_HOME = "/home/cschmidt/jdk1.6.0_14/";
25+
$YUI_COMPRESSOR_JAR = "lib/yuicompressor-2.4.2.jar";
26+
$TMP_DIR = "tmp/";
27+
28+
$LICENSE_TEXT =
29+
"/*
30+
* OWASP Enterprise Security API (ESAPI)
31+
*
32+
* This file is part of the Open Web Application Security Project (OWASP)
33+
* Enterprise Security API (ESAPI) project. For details, please see
34+
* <a href=\"http://www.owasp.org/index.php/ESAPI\">http://www.owasp.org/index.php/ESAPI</a>.
35+
*
36+
* Copyright (c) 2008 - The OWASP Foundation
37+
*
38+
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
39+
* LICENSE before you use, modify, and/or redistribute this software.
40+
*/\n";
41+
?>

build.php

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,20 @@
1313
*/
1414

1515
include('./build-functions.php');
16+
include('./build-properties.php');
1617

17-
$DOCUMENTATION_DIR = "documentation/";
18-
$SOURCE_DIR = "src/main/javascript";
19-
$RESOURCES_DIR = "src/main/resources/";
20-
$OUTPUT_DIR = "dist/";
21-
$OUTPUT_RESOURCES = "resources/";
22-
$OUTPUT_DOCUMENTATION = "docs/";
23-
$OUTPUT_FILE = "esapi.js";
24-
$OUTPUT_FILE_COMPRESSED = "esapi-compressed.js";
25-
26-
$JDK_HOME = "/home/cschmidt/jdk1.6.0_14/";
27-
$YUI_COMPRESSOR_JAR = "lib/yuicompressor-2.4.2.jar";
28-
$TMP_DIR = "tmp/";
18+
$build_start = microtime_float();
2919

3020
rmdirr($OUTPUT_DIR);
3121
if ( !is_dir($TMP_DIR) ) mkdir($TMP_DIR, 0700);
3222
mkdir($OUTPUT_DIR, 0700);
3323

3424
echo("Building Uncompressed File: $OUTPUT_DIR$OUTPUT_FILE\n\r");
35-
25+
$time_start = microtime_float();
3626
$fpOut = fopen( $OUTPUT_DIR.$OUTPUT_FILE, "w" );
3727

28+
fwrite( $fpOut, $LICENSE_TEXT );
29+
3830
$src = get_files( $SOURCE_DIR );
3931
foreach( $src as $i=>$fn ) {
4032
echo("- Reading $fn\n");
@@ -43,14 +35,16 @@
4335
while(!feof($fp)) {
4436
$contents .= fgets($fp);
4537
}
38+
$contents = substr( $contents, strpos( $contents, "*/" ) + 2 );
4639
fwrite( $fpOut, $contents );
4740
fclose($fp);
4841
}
4942

50-
echo("Finished building $OUTPUT_DIR$OUTPUT_FILE (".filesize($fpOut)." bytes): Took " );
43+
echo("Finished building $OUTPUT_DIR$OUTPUT_FILE (".filesize($OUTPUT_DIR.$OUTPUT_FILE)." bytes): Took ".( microtime_float() - $time_start )."s\n\n" );
5144
fclose($fpOut);
5245

5346
echo("Building Compressed File: $OUTPUT_DIR$OUTPUT_FILE_COMPRESSED\n\r");
47+
$time_start = microtime_float();
5448

5549
Minify_YUICompressor::$jarFile = $YUI_COMPRESSOR_JAR;
5650
Minify_YUICompressor::$tempDir = $TMP_DIR;
@@ -69,33 +63,19 @@
6963
fwrite( $fp, $compressed );
7064
fclose($fp);
7165

66+
echo("Finished building $OUTPUT_DIR$OUTPUT_FILE_COMPRESSED (".filesize($OUTPUT_DIR.$OUTPUT_FILE_COMPRESSED)." bytes): Took ".( microtime_float() - $time_start )."s\n\n" );
67+
7268
mkdir($OUTPUT_DIR.'resources');
7369
echo("Copying Resources to $OUTPUT_DIR$OUTPUT_RESOURCES\n");
7470

7571
$dir = dir($RESOURCES_DIR);
76-
while (false !== $entry = $dir->read()) {
77-
// Skip pointers
78-
if ($entry == '.' || $entry == '..' || $entry == '.svn' ) {
79-
continue;
80-
}
81-
echo("- Copying $entry to $OUTPUT_DIR.$OUTPUT_RESOURCES.$entry\n");
82-
copy( $RESOURCES_DIR.$entry, $OUTPUT_DIR.$OUTPUT_RESOURCES.$entry );
83-
}
84-
$dir->close();
72+
copydir($RESOURCES_DIR,$OUTPUT_DIR.$OUTPUT_RESOURCES);
8573

8674
mkdir($OUTPUT_DIR.$OUTPUT_DOCUMENTATION);
87-
$dir = dir($DOCUMENTATION_DIR);
88-
while (false !== $entry = $dir->read()) {
89-
// Skip pointers
90-
if ($entry == '.' || $entry == '..' || $entry == '.svn' ) {
91-
continue;
92-
}
93-
echo("- Copying $entry to $OUTPUT_DIR.$OUTPUT_DOCUMENTATION.$entry\n");
94-
copy( $RESOURCES_DIR.$entry, $OUTPUT_DIR.$OUTPUT_DOCUMENTATION.$entry );
95-
}
96-
$dir->close();
75+
copydir($DOCUMENTATION_DIR,$OUTPUT_DIR.$OUTPUT_DOCUMENTATION);
9776

98-
echo("Cleaning Up\n");
77+
echo("\nCleaning Up\n\n");
9978
rmdir($TMP_DIR);
10079

80+
echo("Build complete took ".(microtime_float()-$build_start)."s\n\n\r");
10181
?>

0 commit comments

Comments
 (0)