Initial code using Drupal 6.38
This commit is contained in:
commit
4824608a33
467 changed files with 90887 additions and 0 deletions
9
scripts/code-clean.sh
Normal file
9
scripts/code-clean.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
find . -name "*~" -type f | xargs rm -f
|
||||
find . -name ".#*" -type f | xargs rm -f
|
||||
find . -name "*.rej" -type f | xargs rm -f
|
||||
find . -name "*.orig" -type f | xargs rm -f
|
||||
find . -name "DEADJOE" -type f | xargs rm -f
|
||||
find . -type f | grep -v ".psp" | grep -v ".gif" | grep -v ".jpg" | grep -v ".png" | grep -v ".tgz" | grep -v ".ico" | grep -v "druplicon" | xargs perl -wi -pe 's/\s+$/\n/'
|
||||
find . -type f | grep -v ".psp" | grep -v ".gif" | grep -v ".jpg" | grep -v ".png" | grep -v ".tgz" | grep -v ".ico" | grep -v "druplicon" | xargs perl -wi -pe 's/\t/ /g'
|
194
scripts/code-style.pl
Normal file
194
scripts/code-style.pl
Normal file
|
@ -0,0 +1,194 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use Pod::Usage;
|
||||
use Getopt::Long qw(GetOptions);
|
||||
Getopt::Long::Configure ("bundling");
|
||||
|
||||
my %opt = ( "help" => 0,
|
||||
'debug' => 0,
|
||||
);
|
||||
|
||||
if(!GetOptions(\%opt,
|
||||
'help|?',
|
||||
'debug',
|
||||
)) {
|
||||
pod2usage(-exitval => 1, 'verbose'=>0);
|
||||
}
|
||||
|
||||
pod2usage(-exitval => 0, -verbose => 2) if($opt{'help'});
|
||||
|
||||
$debug = $opt{'debug'};
|
||||
|
||||
$comment = 0; #flag used to signal we're inside /* */
|
||||
$program = 0; #flag used to signal we're inside <?php ?>
|
||||
#read the file
|
||||
while (<>) {
|
||||
$org=$_;
|
||||
s/\\["']//g;
|
||||
# please don't use nested comments for now... thanks!
|
||||
# handles comments // style, but don't mess with http://
|
||||
s/\/\/[^:].*//;
|
||||
# handles comments /**/ on a single line
|
||||
s/\/\*.*\*\///g;
|
||||
# handles comments /**/ over several lines
|
||||
if ($comment == 1) {
|
||||
if (s/.*\*\///) {
|
||||
$comment = 0;
|
||||
}
|
||||
else {
|
||||
next;
|
||||
}
|
||||
}
|
||||
if (s/\/\*.*//) {
|
||||
$comment = 1;
|
||||
}
|
||||
if (/^\s*#/) {
|
||||
next;
|
||||
}
|
||||
|
||||
if (s/<\?php//) {
|
||||
$program = 1;
|
||||
}
|
||||
if (/\?>/) {
|
||||
$program = 0;
|
||||
}
|
||||
|
||||
# enforce "bar". foo() ."bar" syntax
|
||||
if (/^("[^"]*"|[^"])*("[^"]*")\.[^ ]/ && $program) {
|
||||
$msg = "'\".' -> '\". '";
|
||||
}
|
||||
elsif (/^("[^"]*"|[^"])*("[^"]*")\s+\./ && $program) {
|
||||
$msg = "'\" .' -> '\".'";
|
||||
}
|
||||
# enforce "bar". foo() ."bar" syntax
|
||||
elsif (/^("[^"]*"|[^"])*[^ "]\.("[^"]*")/ && $program) {
|
||||
$msg = "'.\"' -> '.\"'";
|
||||
}
|
||||
elsif (/^("[^"]*"|[^"])*[^ "]\.\s+("[^"]*")/ && $program) {
|
||||
$msg = "'. \"' -> '.\"'";
|
||||
}
|
||||
# XHTML requires closing tag
|
||||
elsif (/<br>/i) {
|
||||
$msg = "'<br>' -> '<br />'";
|
||||
}
|
||||
elsif (/\$REQUEST_URI/i) {
|
||||
$msg = "the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead";
|
||||
}
|
||||
elsif (/\"REQUEST_URI\"/i) {
|
||||
$msg = "the use of REQUEST_URI is prone to XSS exploits and does not work on IIS; use request_uri() instead";
|
||||
}
|
||||
|
||||
# XHTML compatibility mode suggests a blank before /
|
||||
# i.e. <br />
|
||||
elsif (/<[a-z][^>]*[^ >]\/>/i) {
|
||||
$msg = "'<foo/".">' -> '<foo />'";
|
||||
}
|
||||
# we write '{' on the same line, not on the next
|
||||
elsif (/^\s*{/ && $program) {
|
||||
$msg = "take '{' to previous line";
|
||||
}
|
||||
elsif (/([a-z])([A-Z])/) {
|
||||
$msg = "no mixed case function or variable names, use lower case and _";
|
||||
}
|
||||
elsif (/<[\/]*[A-Z]+[^>]*>/) {
|
||||
$msg = "XHTML demands tags to be lowercase";
|
||||
}
|
||||
|
||||
# trying to recognize splitted lines
|
||||
# there are only a few valid last characters in programming mode,
|
||||
# only sometimes it is ( if you use if/else with a single statement
|
||||
|
||||
# from here on we need no more strings
|
||||
while (s/^([^"]*)"[^"]*"/$1#/) {};
|
||||
while (s/^([^']*)'[^']*'/$1#/) {};
|
||||
|
||||
# it should be 'if (' all the time
|
||||
if (/(^|[^a-zA-Z])(if|else|elseif|while|foreach|switch|return|for)\(/) {
|
||||
$msg = "'(' -> ' ('";
|
||||
}
|
||||
#elsif (/[^;{}:\s\n]\s*\n*$/ && $program && !/^[\s}]*(if|else)/) {
|
||||
# $msg = "don't split lines";
|
||||
#}
|
||||
elsif (/\}\s*else/) {
|
||||
$msg = "'} else' -> '}\\nelse'";
|
||||
}
|
||||
elsif (/[^{\s\n]\s*\n*$/ && $program && /^\s*(if|else)/) {
|
||||
$msg = "every if/else needs a { at eol";
|
||||
}
|
||||
elsif (/([\(\[]) / && $program) {
|
||||
$msg = "'$1 ' -> '$1'";
|
||||
}
|
||||
elsif (/\S ([\)\]])/ && $program) {
|
||||
$msg = "' $1' -> '$1'";
|
||||
}
|
||||
# but no brackets
|
||||
elsif (/([a-z-A-Z_][a-zA-Z0-9_-]*)\s+\(/ && $program) {
|
||||
if ($1 ne "switch" and $1 ne "if" and $1 ne "while" and $1 ne "foreach" and $1 ne "return" and $1 ne "for" and $1 ne "elseif") {
|
||||
$msg = "'$1 (' -> '$1('";
|
||||
}
|
||||
}
|
||||
# there should be a space before '{'
|
||||
if (/[^ ]{/ && $program) {
|
||||
$msg = "missing space before '{'";
|
||||
}
|
||||
# there should be a space after ','
|
||||
elsif (/[,][^ \n\r]/ && $program) {
|
||||
$msg = "missing space after ','";
|
||||
}
|
||||
# spaces before and after, only foreach may use $foo=>bar
|
||||
elsif (/[^ =|\-|\+](\+|\-)[^ =>|\-|\+]/ && $program && !/foreach/) {
|
||||
$msg = "'$1' -> ' $1 '";
|
||||
}
|
||||
elsif (/[^ =](\*|==|\.=|=>|=|\|\|)[^ =>]/ && $program && !/foreach/) {
|
||||
$msg = "'$1' -> ' $1 '";
|
||||
}
|
||||
# ensure $bar["foo"] and $bar[$foo] and $bar[0]
|
||||
elsif (/\[[^#][^\]]*\]/ && !/\[[0-9\$][^\]]*\]/ && !/\[\]/) {
|
||||
$msg = "only [\"foo\"], [\$foo] or [0] is allowed";
|
||||
}
|
||||
# first try to find missing quotes after = in (X)HTML tags
|
||||
elsif (/<[^>]*=[a-zA-Z0-9][^>]*>/) {
|
||||
$msg = "=... -> =\"...\"";
|
||||
}
|
||||
if (defined $msg) {
|
||||
if ($debug==0) {
|
||||
print $ARGV .":". $. .": $msg : ". $org;
|
||||
}
|
||||
undef $msg;
|
||||
}
|
||||
elsif ($debug==1) {
|
||||
print $org;
|
||||
}
|
||||
} continue {
|
||||
close ARGV if eof;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
code-style.pl - Review drupal code for style
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
code-style.pl [options] <filename>
|
||||
|
||||
Options:
|
||||
|
||||
-? --help detailed help message
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Originally written for Drupal (http://drupal.org/) to ensure stylish
|
||||
code. This program reviews PHP code, and tries to show as many code
|
||||
improvements as possible with no false positives.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
--comment
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
./code-style.pl ../index.php
|
||||
|
||||
=cut
|
3
scripts/cron-curl.sh
Normal file
3
scripts/cron-curl.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
curl --silent --compressed http://example.com/cron.php
|
3
scripts/cron-lynx.sh
Normal file
3
scripts/cron-lynx.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
/usr/bin/lynx -source http://example.com/cron.php > /dev/null 2>&1
|
143
scripts/drupal.sh
Executable file
143
scripts/drupal.sh
Executable file
|
@ -0,0 +1,143 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Drupal shell execution script
|
||||
*
|
||||
* Check for your PHP interpreter - on Windows you'll probably have to
|
||||
* replace line 1 with
|
||||
* #!c:/program files/php/php.exe
|
||||
*
|
||||
* @param path Drupal's absolute root directory in local file system (optional).
|
||||
* @param URI A URI to execute, including HTTP protocol prefix.
|
||||
*/
|
||||
$script = basename(array_shift($_SERVER['argv']));
|
||||
|
||||
if (in_array('--help', $_SERVER['argv'])) {
|
||||
echo <<<EOF
|
||||
|
||||
Execute a Drupal page from the shell.
|
||||
|
||||
Usage: {$script} [OPTIONS] "<URI>"
|
||||
Example: {$script} "http://mysite.org/node"
|
||||
|
||||
All arguments are long options.
|
||||
|
||||
--help This page.
|
||||
|
||||
--root Set the working directory for the script to the specified path.
|
||||
To execute Drupal this has to be the root directory of your
|
||||
Drupal installation, f.e. /home/www/foo/drupal (assuming Drupal
|
||||
running on Unix). Current directory is not required.
|
||||
Use surrounding quotation marks on Windows.
|
||||
|
||||
--verbose This option displays the options as they are set, but will
|
||||
produce errors from setting the session.
|
||||
|
||||
URI The URI to execute, i.e. http://default/foo/bar for executing
|
||||
the path '/foo/bar' in your site 'default'. URI has to be
|
||||
enclosed by quotation marks if there are ampersands in it
|
||||
(f.e. index.php?q=node&foo=bar). Prefix 'http://' is required,
|
||||
and the domain must exist in Drupal's sites-directory.
|
||||
|
||||
If the given path and file exists it will be executed directly,
|
||||
i.e. if URI is set to http://default/bar/foo.php
|
||||
and bar/foo.php exists, this script will be executed without
|
||||
bootstrapping Drupal. To execute Drupal's cron.php, specify
|
||||
http://default/cron.php as the URI.
|
||||
|
||||
|
||||
To run this script without --root argument invoke it from the root directory
|
||||
of your Drupal installation with
|
||||
|
||||
./scripts/{$script}
|
||||
\n
|
||||
EOF;
|
||||
exit;
|
||||
}
|
||||
|
||||
// define default settings
|
||||
$cmd = 'index.php';
|
||||
$_SERVER['HTTP_HOST'] = 'default';
|
||||
$_SERVER['PHP_SELF'] = '/index.php';
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['SERVER_SOFTWARE'] = 'PHP CLI';
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
$_SERVER['QUERY_STRING'] = '';
|
||||
$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
|
||||
|
||||
// toggle verbose mode
|
||||
if (in_array('--verbose', $_SERVER['argv'])) {
|
||||
$_verbose_mode = true;
|
||||
}
|
||||
else {
|
||||
$_verbose_mode = false;
|
||||
}
|
||||
|
||||
// parse invocation arguments
|
||||
while ($param = array_shift($_SERVER['argv'])) {
|
||||
switch ($param) {
|
||||
case '--root':
|
||||
// change working directory
|
||||
$path = array_shift($_SERVER['argv']);
|
||||
if (is_dir($path)) {
|
||||
chdir($path);
|
||||
if ($_verbose_mode) {
|
||||
echo "cwd changed to: {$path}\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "\nERROR: {$path} not found.\n\n";
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (substr($param, 0, 2) == '--') {
|
||||
// ignore unknown options
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// parse the URI
|
||||
$path = parse_url($param);
|
||||
|
||||
// set site name
|
||||
if (isset($path['host'])) {
|
||||
$_SERVER['HTTP_HOST'] = $path['host'];
|
||||
}
|
||||
|
||||
// set query string
|
||||
if (isset($path['query'])) {
|
||||
$_SERVER['QUERY_STRING'] = $path['query'];
|
||||
parse_str($path['query'], $_GET);
|
||||
$_REQUEST = $_GET;
|
||||
}
|
||||
|
||||
// set file to execute or Drupal path (clean URLs enabled)
|
||||
if (isset($path['path']) && file_exists(substr($path['path'], 1))) {
|
||||
$_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = $path['path'];
|
||||
$cmd = substr($path['path'], 1);
|
||||
}
|
||||
else if (isset($path['path'])) {
|
||||
if (!isset($_GET['q'])) {
|
||||
$_REQUEST['q'] = $_GET['q'] = $path['path'];
|
||||
}
|
||||
}
|
||||
|
||||
// display setup in verbose mode
|
||||
if ($_verbose_mode) {
|
||||
echo "Hostname set to: {$_SERVER['HTTP_HOST']}\n";
|
||||
echo "Script name set to: {$cmd}\n";
|
||||
echo "Path set to: {$_GET['q']}\n";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($cmd)) {
|
||||
include $cmd;
|
||||
}
|
||||
else {
|
||||
echo "\nERROR: {$cmd} not found.\n\n";
|
||||
}
|
||||
exit();
|
Reference in a new issue