Skip to content

Commit

Permalink
CRLF to LF.
Browse files Browse the repository at this point in the history
  • Loading branch information
lincanbin committed May 11, 2018
1 parent a1a3313 commit 2c77772
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 381 deletions.
76 changes: 38 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly
# - hhvm

# https://docs.travis-ci.com/user/reference/trusty#PHP-images
matrix:
include:
- php: 5.2
dist: precise
- php: 5.3.3
dist: precise
# matrix:
# allow_failures:
# - php: hhvm

before_script:
- chmod 777 -R ./
- php -m
- cd build

script:
- php build -n holy_lance
- php -l holy_lance.php
# - php -S 0.0.0.0:8080 &
# - curl -s http://localhost:8080/holy_lance.php?file=init.php
# - curl -s http://localhost:8080/holy_lance.php?file=api.php
- php-cgi -f holy_lance.php file=init.php
- php-cgi -f holy_lance.php file=api.php
- php-cgi -f holy_lance.php file=test_disk.php
- php-cgi -f holy_lance.php file=test_pi.php
- php-cgi -f holy_lance.php file=test_ping.php ip=8.8.8.8
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- nightly
# - hhvm

# https://docs.travis-ci.com/user/reference/trusty#PHP-images
matrix:
include:
- php: 5.2
dist: precise
- php: 5.3.3
dist: precise
# matrix:
# allow_failures:
# - php: hhvm

before_script:
- chmod 777 -R ./
- php -m
- cd build

script:
- php build -n holy_lance
- php -l holy_lance.php
# - php -S 0.0.0.0:8080 &
# - curl -s http://localhost:8080/holy_lance.php?file=init.php
# - curl -s http://localhost:8080/holy_lance.php?file=api.php
- php-cgi -f holy_lance.php file=init.php
- php-cgi -f holy_lance.php file=api.php
- php-cgi -f holy_lance.php file=test_disk.php
- php-cgi -f holy_lance.php file=test_pi.php
- php-cgi -f holy_lance.php file=test_ping.php ip=8.8.8.8
- php-cgi -f holy_lance.php
242 changes: 121 additions & 121 deletions build/build
Original file line number Diff line number Diff line change
@@ -1,122 +1,122 @@
<?php
/*
* Build Tools for Holy Lance
* https://github.com/lincanbin/Holy-Lance
*
* Copyright 2016 Canbin Lin (lincanbin@hotmail.com)
* http://www.94cb.com/
*
* Licensed under the MIT License:
* https://opensource.org/licenses/MIT
*
* A Linux environmental probe.
*/
$args = getopt('n:p:');
$build_file_name = trim(!empty($args['n']) ? trim($args['n']) : "");
$password = trim(!empty($args['p']) ? trim($args['p']) : "");
if (!empty($build_file_name)) {
define("BUILD_FILE_NAME", $build_file_name . ".php");
} else {
define("BUILD_FILE_NAME", "holy_lance.php");
}
define("ENTER_FILE_NAME", "index.php");
define("COMMON_FILE_NAME", "common.php");
$file_buffer = array();
$ignore_dir = array(".git", "build", "screenshot");
$ignore_file = array("../build/build");
$build_extension = array("php", "css", "js");
$old_file_name_list = array();
$new_file_name_list = array();
function add_file_to_buffer($file_name)
{
global $file_buffer, $build_extension, $old_file_name_list, $new_file_name_list;
$old_file_name = $old_file_name_list[$file_name];
$new_file_name = $new_file_name_list[$file_name];
$file_info = pathinfo($file_name);
$file_extension = empty($file_info['extension']) ? '' : $file_info['extension'];
if (in_array($file_extension, $build_extension)){
$file_buffer[$old_file_name]['extension'] = $file_extension;
$file_buffer[$old_file_name]['content'] = file_get_contents($file_name);
foreach ($old_file_name_list as $file_name_key => $old_file_name_value) {
$file_buffer[$old_file_name]['content'] = str_replace($old_file_name_value, $new_file_name_list[$file_name_key], $file_buffer[$old_file_name]['content']);
}
$file_buffer[$old_file_name]['content'] = str_replace(" ", "", $file_buffer[$old_file_name]['content']);
}
}
function listDir($dir)
{
global $ignore_dir, $ignore_file, $old_file_name_list, $new_file_name_list;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ((is_dir($dir . "/" . $file)) && $file != "." && $file != "..") {
if (!in_array($file, $ignore_dir)) {
// echo $file . "\n";
listDir($dir . $file . "/");
}
} else {
if ($file != "." && $file != "..") {
$file_name = $dir . $file;
if (!in_array($file_name, $ignore_file)) {
$old_file_name_list[$file_name] = str_replace("../", "", $file_name);
$new_file_name_list[$file_name] = BUILD_FILE_NAME . "?file=" . urlencode($old_file_name_list[$file_name]);
echo $file_name . "\n";
}
}
}
}
closedir($dh);
}
}
}
listDir("../");
foreach ($old_file_name_list as $file_name => $old_file_name) {
add_file_to_buffer($file_name);
}
$fp = fopen(BUILD_FILE_NAME, 'w');
$entry_file = !empty($file_buffer[ENTER_FILE_NAME]) ? $file_buffer[ENTER_FILE_NAME] : '';
if ($entry_file === '') {
echo 'Entry file not found! ';
exit(1);
}
unset($file_buffer[ENTER_FILE_NAME]);
$common_file = !empty($file_buffer[COMMON_FILE_NAME]) ? $file_buffer[COMMON_FILE_NAME] : '';
if ($common_file === '') {
echo 'Common file not found! ';
exit(2);
}
fwrite($fp, '<?php
define("HAS_BEEN_COMPILED", true);
?>');
$common_file['content'] = str_replace("define('HOLY_LANCE_PASSWORD', '');", "define('HOLY_LANCE_PASSWORD', '" . $password . "');", $common_file['content']);
fwrite($fp, $common_file['content']);
unset($file_buffer[COMMON_FILE_NAME]);
foreach ($file_buffer as $file_name => $file) {
fwrite($fp, '<?php
if (!empty($_GET["file"]) && $_GET["file"] == "' . $file_name . '"):
');
if ($file['extension'] == 'css') {
fwrite($fp, 'header("Content-type: text/css");');
}
if ($file['extension'] == 'js') {
fwrite($fp, 'header("Content-type: text/javascript");');
}
fwrite($fp, '?>');
fwrite($fp, $file['content']);
fwrite($fp, '<?php
exit();
endif;
?>');
}
fwrite($fp, $entry_file['content']);
fclose($fp);
<?php
/*
* Build Tools for Holy Lance
* https://github.com/lincanbin/Holy-Lance
*
* Copyright 2016 Canbin Lin (lincanbin@hotmail.com)
* http://www.94cb.com/
*
* Licensed under the MIT License:
* https://opensource.org/licenses/MIT
*
* A Linux environmental probe.
*/
$args = getopt('n:p:');
$build_file_name = trim(!empty($args['n']) ? trim($args['n']) : "");
$password = trim(!empty($args['p']) ? trim($args['p']) : "");
if (!empty($build_file_name)) {
define("BUILD_FILE_NAME", $build_file_name . ".php");
} else {
define("BUILD_FILE_NAME", "holy_lance.php");
}

define("ENTER_FILE_NAME", "index.php");
define("COMMON_FILE_NAME", "common.php");
$file_buffer = array();
$ignore_dir = array(".git", "build", "screenshot");
$ignore_file = array("../build/build");
$build_extension = array("php", "css", "js");
$old_file_name_list = array();
$new_file_name_list = array();

function add_file_to_buffer($file_name)
{
global $file_buffer, $build_extension, $old_file_name_list, $new_file_name_list;
$old_file_name = $old_file_name_list[$file_name];
$new_file_name = $new_file_name_list[$file_name];
$file_info = pathinfo($file_name);
$file_extension = empty($file_info['extension']) ? '' : $file_info['extension'];
if (in_array($file_extension, $build_extension)){
$file_buffer[$old_file_name]['extension'] = $file_extension;
$file_buffer[$old_file_name]['content'] = file_get_contents($file_name);
foreach ($old_file_name_list as $file_name_key => $old_file_name_value) {
$file_buffer[$old_file_name]['content'] = str_replace($old_file_name_value, $new_file_name_list[$file_name_key], $file_buffer[$old_file_name]['content']);
}
$file_buffer[$old_file_name]['content'] = str_replace(" ", "", $file_buffer[$old_file_name]['content']);
}
}

function listDir($dir)
{
global $ignore_dir, $ignore_file, $old_file_name_list, $new_file_name_list;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ((is_dir($dir . "/" . $file)) && $file != "." && $file != "..") {
if (!in_array($file, $ignore_dir)) {
// echo $file . "\n";
listDir($dir . $file . "/");
}
} else {
if ($file != "." && $file != "..") {
$file_name = $dir . $file;
if (!in_array($file_name, $ignore_file)) {
$old_file_name_list[$file_name] = str_replace("../", "", $file_name);
$new_file_name_list[$file_name] = BUILD_FILE_NAME . "?file=" . urlencode($old_file_name_list[$file_name]);
echo $file_name . "\n";
}
}
}
}
closedir($dh);
}
}
}


listDir("../");

foreach ($old_file_name_list as $file_name => $old_file_name) {
add_file_to_buffer($file_name);
}

$fp = fopen(BUILD_FILE_NAME, 'w');
$entry_file = !empty($file_buffer[ENTER_FILE_NAME]) ? $file_buffer[ENTER_FILE_NAME] : '';
if ($entry_file === '') {
echo 'Entry file not found! ';
exit(1);
}
unset($file_buffer[ENTER_FILE_NAME]);
$common_file = !empty($file_buffer[COMMON_FILE_NAME]) ? $file_buffer[COMMON_FILE_NAME] : '';
if ($common_file === '') {
echo 'Common file not found! ';
exit(2);
}
fwrite($fp, '<?php
define("HAS_BEEN_COMPILED", true);
?>');
$common_file['content'] = str_replace("define('HOLY_LANCE_PASSWORD', '');", "define('HOLY_LANCE_PASSWORD', '" . $password . "');", $common_file['content']);
fwrite($fp, $common_file['content']);
unset($file_buffer[COMMON_FILE_NAME]);
foreach ($file_buffer as $file_name => $file) {
fwrite($fp, '<?php
if (!empty($_GET["file"]) && $_GET["file"] == "' . $file_name . '"):
');
if ($file['extension'] == 'css') {
fwrite($fp, 'header("Content-type: text/css");');
}
if ($file['extension'] == 'js') {
fwrite($fp, 'header("Content-type: text/javascript");');
}
fwrite($fp, '?>');
fwrite($fp, $file['content']);
fwrite($fp, '<?php
exit();
endif;
?>');
}

fwrite($fp, $entry_file['content']);
fclose($fp);

echo "\n\n" . BUILD_FILE_NAME . " has been generated! \npssword: " . $password . "\n\n";
Loading

0 comments on commit 2c77772

Please sign in to comment.