Skip to content

Commit

Permalink
Merge branch 'master' into issue-89-full-package-script
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed May 6, 2018
2 parents 2f479f1 + 1c2f0c1 commit 4ddba9e
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -21,5 +21,6 @@ install:

script:
- find . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n1 php -lf
- phpcs --standard=PSR1,PSR2 --extensions=php --ignore="/ext_scripts/*,/ext_inc/*,/vendor/*" . || true # Allow failures for now
- phpcs --standard=PSR1,PSR2 --extensions=php -s --exclude=Generic.Files.LineLength modules/about
- phpcs --standard=PSR1,PSR2 --extensions=php -s --ignore="/ext_scripts/*,/ext_inc/*,/vendor/*" . || true # Allow failures for now
- bin/phpunit
2 changes: 2 additions & 0 deletions composer.json
Expand Up @@ -48,6 +48,8 @@
"inc/Functions/CheckValidEmail.php",
"inc/Functions/Debug.php",
"inc/Functions/DependencyPreCheck.php",
"modules/about/Functions/GetTheLinesAndChars.php",
"modules/about/Functions/LetsOpenTheDir.php",
"modules/mastersearch2/Functions/MS2GetDate.php",
"modules/mastersearch2/Functions/MS2GetTime.php",
"modules/mastersearch2/Functions/Text2LSCode.php",
Expand Down
16 changes: 16 additions & 0 deletions modules/about/Functions/GetTheLinesAndChars.php
@@ -0,0 +1,16 @@
<?php

/**
* @param string $file
* @return array
*/
function GetTheLinesAndChars($file)
{
$file_content = file($file);
$data[0] = count($file_content);
for ($i=0; $i < count($file_content); $i++) {
$data[1] += strlen($file_content[$i]);
}

return $data;
}
22 changes: 22 additions & 0 deletions modules/about/Functions/LetsOpenTheDir.php
@@ -0,0 +1,22 @@
<?php

/**
* @param string $dir
* @return void
*/
function LetsOpenTheDir($dir)
{
global $files;

$thedir = opendir($dir);
while (false !== ($content = readdir($thedir))) {
if ($content != "." and $content != "..") {
if (is_dir($dir."/".$content)) {
LetsOpenTheDir($dir."/".$content);
}
if (file_exists($dir."/".$content)) {
$files[] = $dir."/".$content;
}
}
}
}
4 changes: 2 additions & 2 deletions modules/about/design_info.php
@@ -1,8 +1,8 @@
<?php
$xml = new \LanSuite\XML();

$xml_file = @fopen("design/" . $auth["design"] . "/design.xml", "r");
$xml_content = @fread($xml_file, filesize("design/".$auth["design"]."/design.xml"));
$xml_file = fopen("design/" . $auth["design"] . "/design.xml", "r");
$xml_content = fread($xml_file, filesize("design/".$auth["design"]."/design.xml"));

$design_name = $xml->get_tag_content("name", $xml_content);

Expand Down
57 changes: 14 additions & 43 deletions modules/about/generate_file_stats.php
@@ -1,58 +1,29 @@
<?php

$dir = ".";
$dir = ".";

function lets_open_the_dir($dir)
{
global $files;

// Open the design-dir
$thedir = opendir($dir);

// Reading all subdirs from design and fill them into an array
while (false !== ($content = readdir($thedir))) {
if ($content != "." and $content != "..") {
if (is_dir($dir."/".$content)) {
lets_open_the_dir($dir."/".$content);
}
if (file_exists($dir."/".$content)) {
$files[] = $dir."/".$content;
}
}
}
}
function get_the_lines_and_chars($file)
{
$file_content = file($file);
$data[0] = count($file_content);
for ($i=0; $i < count($file_content); $i++) {
$data[1] += strlen($file_content[$i]);
}
return $data;
}

lets_open_the_dir($dir);
LetsOpenTheDir($dir);

foreach ($files as $file) {
if (eregi(".php", $file)) {
$data = get_the_lines_and_chars($file);
if (preg_match(".php", $file)) {
$data = GetTheLinesAndChars($file);
$php_lines += $data[0];
$php_chars += $data[1];
}
if (eregi(".htm", $file)) {
$data = get_the_lines_and_chars($file);
if (preg_match(".htm", $file)) {
$data = GetTheLinesAndChars($file);
$html_lines += $data[0];
$html_chars += $data[1];
}
}
$filecontents = file("modules/about/credits.php");
$fo = fopen("modules/about/credits.php", "w");

$filecontents = file("modules/about/credits.php");
$fo = fopen("modules/about/credits.php", "w");
foreach ($filecontents as $filecontent) {
$filecontent = eregi_replace("<!--PHP-LINES-START-->(.*)<!--PHP-LINES-STOP-->", "<!--PHP-LINES-START-->$php_lines<!--PHP-LINES-STOP-->", $filecontent);
$filecontent = eregi_replace("<!--PHP-CHARS-START-->(.*)<!--PHP-CHARS-STOP-->", "<!--PHP-CHARS-START-->$php_chars<!--PHP-CHARS-STOP-->", $filecontent);
$filecontent = eregi_replace("<!--HTML-LINES-START-->(.*)<!--HTML-LINES-STOP-->", "<!--HTML-LINES-START-->$html_lines<!--HTML-LINES-STOP-->", $filecontent);
$filecontent = eregi_replace("<!--HTML-CHARS-START-->(.*)<!--HTML-CHARS-STOP-->", "<!--HTML-CHARS-START-->$html_chars<!--HTML-CHARS-STOP-->", $filecontent);
$filecontent = preg_replace("<!--PHP-LINES-START-->(.*)<!--PHP-LINES-STOP-->", "<!--PHP-LINES-START-->$php_lines<!--PHP-LINES-STOP-->", $filecontent);
$filecontent = preg_replace("<!--PHP-CHARS-START-->(.*)<!--PHP-CHARS-STOP-->", "<!--PHP-CHARS-START-->$php_chars<!--PHP-CHARS-STOP-->", $filecontent);
$filecontent = preg_replace("<!--HTML-LINES-START-->(.*)<!--HTML-LINES-STOP-->", "<!--HTML-LINES-START-->$html_lines<!--HTML-LINES-STOP-->", $filecontent);
$filecontent = preg_replace("<!--HTML-CHARS-START-->(.*)<!--HTML-CHARS-STOP-->", "<!--HTML-CHARS-START-->$html_chars<!--HTML-CHARS-STOP-->", $filecontent);
fwrite($fo, $filecontent);
}
fclose($fo);
fclose($fo);

0 comments on commit 4ddba9e

Please sign in to comment.