-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck-eof-master.php
executable file
·51 lines (43 loc) · 1.8 KB
/
check-eof-master.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
<?php
/**************************************************************
* Simple Desk Project - www.simpledesk.net *
***************************************************************
* An advanced help desk modification built on SMF *
***************************************************************
* *
* * Copyright 2022 - SimpleDesk.net *
* *
* This file and its contents are subject to the license *
* included with this distribution, license.txt, which *
* states that this software is New BSD Licensed. *
* Any questions, please contact SimpleDesk.net *
* *
***************************************************************
* SimpleDesk Version: 2.1 Beta 1 *
* File Info: check-eof-master.php *
**************************************************************/
// Stuff we will ignore.
$ignoreFiles = array(
'\.github/',
'/buildTools/',
);
$curDir = '.';
if (isset($_SERVER['argv'], $_SERVER['argv'][1]))
$curDir = $_SERVER['argv'][1];
$foundBad = false;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($curDir, FilesystemIterator::UNIX_PATHS)) as $currentFile => $fileInfo)
{
// Only check PHP
if ($fileInfo->getExtension() !== 'php')
continue;
foreach ($ignoreFiles as $if)
if (preg_match('~' . $if . '~i', $currentFile))
continue 2;
$result = trim(shell_exec('php buildTools/check-eof.php ' . $currentFile . ' 2>&1'));
if (!preg_match('~Error:([^$]+)~', $result))
continue;
$foundBad = true;
fwrite(STDERR, $result . "\n");
}
if (!empty($foundBad))
exit(1);