Passed
Push — 1.11.x ( efc14f...a62b75 )
by
unknown
11:29
created

main/cron/lang/check_parse_lang.php (1 issue)

1
<?php
2
/* For licensing terms, see /license.txt */
3
/**
4
 * Script to check that no language file has parse errors.
5
 *
6
 * @package chamilo.cron.lang
7
 */
8
/**
9
 * Includes and declarations.
10
 */
11
//die();
12
require_once '../../inc/global.inc.php';
13
$path = api_get_path(SYS_LANG_PATH).'english';
14
ini_set('memory_limit', '128M');
15
/**
16
 * Main code.
17
 */
18
$terms = [];
19
$list = SubLanguageManager::get_lang_folder_files_list($path);
20
$langs = scandir(api_get_path(SYS_LANG_PATH));
21
foreach ($langs as $lang) {
22
    $dir = api_get_path(SYS_LANG_PATH).$lang;
23
    if (is_dir($dir) && substr($lang, 0, 1) != '.' && !empty($lang)) {
24
        echo "$lang...";
25
        $ok = true;
26
        foreach ($list as $entry) {
27
            $file = $dir.'/'.$entry;
28
            $out = [];
29
            if (is_file($file)) {
30
                //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true));
31
                @exec('php -l '.$file, $out);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for exec(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

31
                /** @scrutinizer ignore-unhandled */ @exec('php -l '.$file, $out);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
32
                if (substr($out[0], 0, 2) != 'No') {
33
                    echo $out[0]."\n";
34
                    $ok = false;
35
                }
36
            }
37
        }
38
        if ($ok) {
39
            echo "OK\n";
40
        }
41
    }
42
}
43
echo "Done\n";
44