Skip to content

Commit

Permalink
cleanup - EOL inconsistency & trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
g0tmi1k committed Sep 10, 2015
1 parent 6312642 commit 912247a
Show file tree
Hide file tree
Showing 64 changed files with 440 additions and 447 deletions.
2 changes: 1 addition & 1 deletion about.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<h2>Development</h2>
<p>Everyone is welcome to contribute and help make DVWA as successful as it can be. All contributors can have their name and link (if they wish) placed in the credits section. To contribute pick an Issue from the Project Home to work on or submit a patch to the Issues list.</p>
</div>
";
Expand Down
4 changes: 2 additions & 2 deletions config/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#$DBMS = 'PGSQL';

# Database variables
# WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
# WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
# Please use a database dedicated to DVWA.

$_DVWA = array();
Expand All @@ -20,7 +20,7 @@
$_DVWA[ 'db_password' ] = 'p@ssw0rd';

# Only needed for PGSQL
$_DVWA[ 'db_port' ] = '5432';
$_DVWA[ 'db_port' ] = '5432';

# ReCAPTCHA Settings
# Get your keys at https://www.google.com/recaptcha/admin/create
Expand Down
20 changes: 10 additions & 10 deletions dvwa/includes/DBMS/DBMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
if ($DBMS == 'MySQL') {
$DBMS = htmlspecialchars(strip_tags($DBMS));
$DBMS_errorFunc = mysql_error();

function escapeString( $var ) {
$var = mysql_real_escape_string( $var );
return $var;
}

function db_login( $user,$pass ) {
$login = "SELECT * FROM `users` WHERE user='$user' AND password='$pass';";

Expand All @@ -35,17 +35,17 @@ function db_login( $user,$pass ) {
elseif ($DBMS == 'PGSQL') {
$DBMS = htmlspecialchars(strip_tags($DBMS));
$DBMS_errorFunc = @pg_last_error();

function escapeString( $var ) {
$var = pg_escape_string( $var );
return $var;
}

function db_login( $user,$pass ) {
$login = "SELECT * FROM users WHERE username='$user' AND password='$pass';";

$result = @pg_query( $login ) or die('<pre>' . pg_last_error() . '</pre>');

if($result && pg_num_rows( $result ) == 1) { // Login Successful...
dvwaMessagePush( "You have logged in as '".$user."'" );
dvwaLogin( $user );
Expand All @@ -67,7 +67,7 @@ function db_login( $user,$pass ) {
<pre>Unable to connect to the database.<br>'.$DBMS_errorFunc.'<br /><br /></pre>
Click <a href="'.DVWA_WEB_PAGE_TO_ROOT.'setup.php">here</a> to setup the database.
</div>';

function dvwaDatabaseConnect() {
global $_DVWA;
global $DBMS;
Expand All @@ -79,13 +79,13 @@ function dvwaDatabaseConnect() {
die( $DBMS_connError );
}
}

elseif ($DBMS == 'PGSQL') {
$dbconn = @pg_connect("host=".$_DVWA[ 'db_server' ]." port=".$_DVWA[ 'db_port' ]." dbname=".$_DVWA[ 'db_database' ]." user=".$_DVWA[ 'db_user' ]." password=".$_DVWA[ 'db_password' ])
$dbconn = @pg_connect("host=".$_DVWA[ 'db_server' ]." port=".$_DVWA[ 'db_port' ]." dbname=".$_DVWA[ 'db_database' ]." user=".$_DVWA[ 'db_user' ]." password=".$_DVWA[ 'db_password' ])
or die( $DBMS_connError );
}
}

// -- END

?>
?>
10 changes: 5 additions & 5 deletions dvwa/includes/DBMS/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@
dvwaPageReload();
}
dvwaMessagePush( "Data inserted into 'users' table." );

// Create guestbook table
$create_tb_guestbook = "CREATE TABLE guestbook (comment_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, comment varchar(300), name varchar(100), PRIMARY KEY (comment_id));";

if( !mysql_query( $create_tb_guestbook ) ){
dvwaMessagePush( "Table could not be created<br />SQL: ".mysql_error() );
dvwaPageReload();
}

dvwaMessagePush( "'guestbook' table was created." );

// Insert data into 'guestbook'
$insert = "INSERT INTO guestbook VALUES
('1','This is a test comment.','test');";

if( !mysql_query( $insert ) ){
dvwaMessagePush( "Data could not be inserted into 'guestbook' table<br />SQL: ".mysql_error() );
dvwaPageReload();
Expand Down
6 changes: 3 additions & 3 deletions dvwa/includes/DBMS/PGSQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

// Connect to server AND connect to the database
$dbconn = @pg_connect("host=".$_DVWA[ 'db_server' ]." port=".$_DVWA[ 'db_port' ]." dbname=".$_DVWA[ 'db_database' ]." user=".$_DVWA[ 'db_user' ]." password=".$_DVWA[ 'db_password' ]);


// Create table 'users'

$drop_table = "DROP TABLE IF EXISTS users;";
Expand Down Expand Up @@ -80,7 +80,7 @@
}

$create_tb_guestbook = "CREATE TABLE guestbook (comment text, name text, comment_id SERIAL PRIMARY KEY);";

if( !pg_query( $create_tb_guestbook ) ){
dvwaMessagePush( "guestbook table could not be created<br />SQL: " . pg_last_error() );
dvwaPageReload();
Expand Down
32 changes: 16 additions & 16 deletions dvwa/includes/dvwaPage.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function dvwaReleaseDateGet() {
}


// Start session functions --
// Start session functions --

function &dvwaSessionGrab() {

Expand Down Expand Up @@ -185,7 +185,7 @@ function dvwaSecurityLevelSet( $pSecurityLevel ) {



// Start message functions --
// Start message functions --
function dvwaMessagePush( $pMessage ) {

$dvwaSession =& dvwaSessionGrab();
Expand Down Expand Up @@ -277,7 +277,7 @@ function dvwaHtmlEcho( $pPage ) {
$menuHtml .= "<ul>{$menuBlockHtml}</ul>";
}


// Get security cookie --
$securityLevelHtml = '';

Expand All @@ -299,7 +299,7 @@ function dvwaHtmlEcho( $pPage ) {
break;
}
// -- END

$phpIdsHtml = '<b>PHPIDS:</b> '.( dvwaPhpIdsIsEnabled() ? 'enabled' : 'disabled' );

$userInfoHtml = '<b>Username:</b> '.( dvwaCurrentUser() );
Expand All @@ -311,7 +311,7 @@ function dvwaHtmlEcho( $pPage ) {
$messagesHtml = "<div class=\"body_padded\">{$messagesHtml}</div>";

}

$systemInfoHtml = "<div align=\"left\">{$userInfoHtml}<br /><b>Security Level:</b> {$securityLevelHtml}<br />{$phpIdsHtml}</div>";

if( $pPage[ 'source_button' ] ) {
Expand All @@ -325,8 +325,8 @@ function dvwaHtmlEcho( $pPage ) {
$systemInfoHtml = dvwaButtonHelpHtmlGet( $pPage[ 'help_button' ] )." $systemInfoHtml";

}


// Send Headers + main HTML code
Header( 'Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
Header( 'Content-Type: text/html;charset=utf-8' ); // TODO- proper XHTML headers...
Expand Down Expand Up @@ -421,7 +421,7 @@ function dvwaHelpHtmlEcho( $pPage ) {
</head>
<body>
<div id=\"container\">
{$pPage['body']}
Expand Down Expand Up @@ -548,7 +548,7 @@ function dvwaDatabaseConnect() {
}

}

elseif ($DBMS == 'PGSQL') {

$dbconn = pg_connect("host=".$_DVWA[ 'db_server' ]." dbname=".$_DVWA[ 'db_database' ]." user=".$_DVWA[ 'db_user' ]." password=".$_DVWA[ 'db_password' ])
Expand All @@ -575,14 +575,14 @@ function dvwaGuestbook(){
$result = mysql_query($query);

$guestbook = '';
while($row = mysql_fetch_row($result)){

while($row = mysql_fetch_row($result)){

if (dvwaSecurityLevelGet() == 'high'){

$name = htmlspecialchars($row[0]);
$comment = htmlspecialchars($row[1]);

}

else {
Expand All @@ -591,10 +591,10 @@ function dvwaGuestbook(){
$comment = $row[1];

}

$guestbook .= "<div id=\"guestbook_comments\">Name: {$name} <br />" . "Message: {$comment} <br /></div>";
}
}

return $guestbook;
}
// -- END
Expand Down
16 changes: 8 additions & 8 deletions dvwa/includes/dvwaPhpIds.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ function dvwaPhpIdsVersionGet() {
return '0.6';
}

// PHPIDS Log parsing function
// PHPIDS Log parsing function
function dvwaReadIdsLog() {

$file_array = file(DVWA_WEB_PAGE_TO_PHPIDS_LOG);

$data = '';

foreach ($file_array as $line_number => $line){
$line = explode(",", $line);
$line = str_replace("\""," ",$line);

$datetime = $line[1];
$vulnerability = $line[3];
$variable = urldecode($line[4]);
$request = urldecode($line[5]);
$ip = $line[6];

$data .= "<div id=\"idslog\"><b>Date/Time:</b> " . $datetime . "<br /><b>Vulnerability:</b> " . $vulnerability . "<br /><b>Request:</b> " . htmlspecialchars($request) . "<br /><b>Variable:</b> " . htmlspecialchars($variable) . "<br /><b>IP:</b> " . $ip . "</div>";
}

Expand All @@ -42,7 +42,7 @@ function dvwaReadIdsLog() {

// Clear PHPIDS log
function dvwaClearIdsLog() {
if (isset($_GET['clear_log'])) {
if (isset($_GET['clear_log'])) {
$fp = fopen(DVWA_WEB_PAGE_TO_PHPIDS_LOG, w);
fclose($fp);
dvwaMessagePush( "PHPIDS log cleared" );
Expand Down Expand Up @@ -76,9 +76,9 @@ function dvwaPhpIdsTrap() {

$compositeLog = new IDS_Log_Composite();
$compositeLog->addLogger(IDS_Log_File::getInstance($init));

$compositeLog->execute($result);

echo 'Hacking attempt detected and logged.';

//echo $result;
Expand All @@ -96,4 +96,4 @@ function dvwaPhpIdsTrap() {
}
}

?>
?>
10 changes: 5 additions & 5 deletions ids_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>PHPIDS Log</h1>
<p>". dvwaReadIdsLog() ."</p>
<br />
<br />
<form action=\"#\" method=\"GET\">
<input type=\"submit\" value=\"Clear Log\" name=\"clear_log\">
</form>
".dvwaClearIdsLog()."
</div>
";

Expand Down
22 changes: 11 additions & 11 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,30 @@
<body>
<div align=\"center\">
<br />
<p><img src=\"".DVWA_WEB_PAGE_TO_ROOT."dvwa/images/login_logo.png\" /></p>
<br />
<form action=\"login.php\" method=\"post\">
<fieldset>
<label for=\"user\">Username</label> <input type=\"text\" class=\"loginInput\" size=\"20\" name=\"username\"><br />
<label for=\"pass\">Password</label> <input type=\"password\" class=\"loginInput\" AUTOCOMPLETE=\"off\" size=\"20\" name=\"password\"><br />
<p class=\"submit\"><input type=\"submit\" value=\"Login\" name=\"Login\"></p>
</fieldset>
</form>
<br />
{$messagesHtml}
Expand All @@ -97,12 +97,12 @@
<br />
<br />
<br />
<br />
<br />
<!-- <img src=\"".DVWA_WEB_PAGE_TO_ROOT."dvwa/images/RandomStorm.png\" /> -->
<p>Damn Vulnerable Web Application (DVWA) is a RandomStorm OpenSource project</p>
</div> <!-- end align div -->
</body>
Expand Down
1 change: 0 additions & 1 deletion logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
dvwaRedirect( 'login.php' );

?>

2 changes: 1 addition & 1 deletion phpinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

phpinfo();

?>
?>
Loading

0 comments on commit 912247a

Please sign in to comment.