Skip to content

Commit 7a8430d

Browse files
committed
Fixed sqli in sqlite3
1 parent 3894752 commit 7a8430d

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

assets/php/delegateRegistration.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ function __construct()
5151
$myDateTime = new DateTime( Date( '' ), new DateTimeZone( 'GMT' ) );
5252
$myDateTime->setTimezone( new DateTimeZone( 'Asia/Kolkata' ) );
5353
$date = $myDateTime->format( 'Y-m-d H:i:s' );
54-
$name = $_POST['del-name'];
54+
$name = SQLite3::escapeString($_POST['del-name']);
5555
if ( empty( $_POST['del-email'] ) )
5656
{
5757
$emailerror = "Required Field";
5858
}
5959
else
6060
{
61-
$email = $_POST['del-email'];
61+
$email = SQLite3::escapeString($_POST['del-email']);
6262
if ( !preg_match( "/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email ) )
6363
{
6464
$emailerror = "Invalid Format";
6565
}
6666
}
67-
$org = $_POST['del-org'];
68-
$city = $_POST['del-city'];
67+
$org = SQLite3::escapeString($_POST['del-org']);
68+
$city = SQLite3::escapeString($_POST['del-city']);
6969
if ( !preg_match( '/$^|^[a-zA-Z]+[0-9]*[\. ,]*[a-zA-Z0-9]*$/', $city ) )
7070
{
7171
$cityerror = "City name must start with a letter and can contain only alphanumerics, spaces, periods and commas";
@@ -76,23 +76,23 @@ function __construct()
7676
$arrivalerror = "No arriving date given";
7777
} else {
7878

79-
$arrival = $_POST['del-arrival'];
79+
$arrival = SQLite3::escapeString($_POST['del-arrival']);
8080
}
8181
if ( empty( $_POST['del-depart'] ) ) {
8282
$departureerror = "No departure date given";
8383
} else {
84-
$departure = $_POST['del-depart'];
84+
$departure = SQLite3::escapeString($_POST['del-depart']);
8585
}
8686
$lap = 1;
8787
if ( empty( $_POST['del-accom'] ) ) {
8888
$accom = "0";
8989
} else {
90-
$accom = $_POST['del-accom'];
90+
$accom = SQLite3::escapeString($_POST['del-accom']);
9191
}
9292
if ( empty( $_POST['del-tshirt'] ) ) {
9393
$tshirt = "0";
9494
} else {
95-
$tshirt = $_POST['del-tshirt'];
95+
$tshirt = SQLite3::escapeString($_POST['del-tshirt']);
9696
}
9797

9898
if ( $nameerror == "" && $emailerror == "" && $arrivalerror == "" && $departureerror == "" && $orgerror == "" && $cityerror == "" )

assets/php/speakerRegistration.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
2-
error_reporting( E_ALL );
3-
ini_set( 'display_errors', '1' );
2+
error_reporting(0);
43
# Database Connection
54
class database extends SQLite3
65
{
@@ -54,62 +53,62 @@ function __construct()
5453
$myDateTime = new DateTime( Date( '' ), new DateTimeZone( 'GMT' ) );
5554
$myDateTime->setTimezone( new DateTimeZone( 'Asia/Kolkata' ) );
5655
$date = $myDateTime->format( 'Y-m-d H:i:s' );
57-
$name = $_POST['sp-name'];
56+
$name = SQLite3::escapeString( $_POST['sp-name'] );
5857
if ( empty( $_POST['sp-email'] ) )
5958
{
6059
$emailerror = "Required Field";
6160
}
6261
else
6362
{
64-
$email = $_POST['sp-email'];
63+
$email = SQLite3::escapeString( $_POST['sp-email'] );
6564
if ( !preg_match( "/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email ) )
6665
{
6766
$emailerror = "Invalid Format";
6867
}
6968
}
70-
$org = $_POST['sp-org'];
71-
$city = $_POST['sp-city'];
69+
$org = SQLite3::escapeString( $_POST['sp-org'] );
70+
$city = SQLite3::escapeString( $_POST['sp-city'] );
7271
if ( !preg_match( '/$^|^[a-zA-Z]+[0-9]*[\. ,]*[a-zA-Z0-9]*$/', $city ) )
7372
{
7473
$cityerror = "City name must start with a letter and can contain only alphanumerics, spaces, periods and commas";
7574
}
7675
if ( empty( $_POST['sp-profile'] ) ) {
7776
$profilerror = "No profile";
7877
} else {
79-
$profile = $_POST['sp-profile'];
78+
$profile = SQLite3::escapeString( $_POST['sp-profile'] );
8079
}
8180

8281
if ( empty( $_POST['sp-tshirt'] ) ) {
8382
$tshirt = "0";
8483
} else {
85-
$tshirt = $_POST['sp-tshirt'];
84+
$tshirt = SQLite3::escapeString( $_POST['sp-tshirt'] );
8685
}
8786

8887
if ( empty( $_POST['sp-arrival'] ) ) {
8988
$arrivalerror = "No arriving date given";
9089
} else {
91-
$arrival = $_POST['sp-arrival'];
90+
$arrival = SQLite3::escapeString( $_POST['sp-arrival'] );
9291
}
9392
if ( empty( $_POST['sp-depart'] ) ) {
9493
$departureerror = "No departure date given";
9594
} else {
96-
$departure = $_POST['sp-depart'];
95+
$departure = SQLite3::escapeString( $_POST['sp-depart'] );
9796
}
9897
$lap = 1;
9998
if ( empty( $_POST['sp-accom'] ) ) {
10099
$accom = "0";
101100
} else {
102-
$accom = $_POST['sp-accom'];
101+
$accom = SQLite3::escapeString( $_POST['sp-accom'] );
103102
}
104-
$pretitle = $_POST['sp-title'];
103+
$pretitle = SQLite3::escapeString( $_POST['sp-title'] );
105104
if ( empty( $pretitle ) )
106105
{
107106
$titleerror = "Required Field";
108107
}
109108
else
110109
{
111-
$title = $_POST['sp-title'];
112-
$desc = $_POST['sp-desc'];
110+
$title = SQLite3::escapeString( $_POST['sp-title'] );
111+
$desc = SQLite3::escapeString( $_POST['sp-desc'] );
113112

114113
}
115114
if ( $nameerror == "" && $emailerror == "" && $arrivalerror == "" && $departureerror == "" && $orgerror == "" && $cityerror == "" && $titleerror == "" && $profilerror == "" )
@@ -123,11 +122,11 @@ function __construct()
123122
header( 'location:../../registration_success.html' );
124123
} else {
125124
echo "fail";
126-
// header( 'location:../../registration_fail.html' );
125+
header( 'location:../../registration_fail.html' );
127126
}
128127
} else {
129128
echo "fail";
130-
// header( 'location:../../registration_fail.html' );
129+
header( 'location:../../registration_fail.html' );
131130
}
132131
}
133132
}

0 commit comments

Comments
 (0)