phpmyadmin/scripts/line-counts.sh
Michal Čihař f2bfa7d745 Avoid running shell scripts as CGI
There is really no reason for that besides misconfigured servers.

This is followup for PMASA-2016-54

Signed-off-by: Michal Čihař <michal@cihar.com>
2016-12-08 11:41:42 +01:00

34 lines
639 B
Bash
Executable File

#!/bin/bash
# Do not run as CGI
if [ -n "$GATEWAY_INTERFACE" ] ; then
echo 'Can not invoke as CGI!'
exit 1
fi
cat > js/line_counts.php <<EOF
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* An autogenerated file that stores the line counts of javascript files
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
define('LINE_COUNTS', true);
\$LINE_COUNT = array();
EOF
php_code=""
for file in `find js -name '*.js'` ; do
lc=`wc -l $file | sed 's/\([0-9]*\).*/\1/'`
file=${file:3}
entry="\$LINE_COUNT['$file'] = $lc;"
php_code="$php_code\n$entry"
done
echo -e $php_code >> js/line_counts.php