diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e9b47a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.php
\ No newline at end of file
diff --git a/add_cat.php b/add_cat.php
index ead7171..8bd18dc 100644
--- a/add_cat.php
+++ b/add_cat.php
@@ -158,10 +158,10 @@
} else {
- $name=mysql_real_escape_string($_POST['name']);
- $address=mysql_real_escape_string($_POST['address']);
- $contact1=mysql_real_escape_string($_POST['contact1']);
- $contact2=mysql_real_escape_string($_POST['contact2']);
+ $name=mysqli_real_escape_string($db->conn, $_POST['name']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
+ $contact1=mysqli_real_escape_string($db->conn, $_POST['contact1']);
+ $contact2=mysqli_real_escape_string($db->conn, $_POST['contact2']);
$count = $db->countOf("customer_details", "customer_name='$name'");
if($count==1)
diff --git a/add_category.php b/add_category.php
index e048bfb..a658a5d 100644
--- a/add_category.php
+++ b/add_category.php
@@ -148,8 +148,8 @@
} else {
- $name=mysql_real_escape_string($_POST['name']);
- $address=mysql_real_escape_string($_POST['address']);
+ $name=mysqli_real_escape_string($db->conn, $_POST['name']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
$count = $db->countOf("category_details", "category_name='$name'");
diff --git a/add_customer.php b/add_customer.php
index 42febf3..3c6193d 100644
--- a/add_customer.php
+++ b/add_customer.php
@@ -285,10 +285,10 @@
} else {
- $name=mysql_real_escape_string($_POST['name']);
- $address=mysql_real_escape_string($_POST['address']);
- $contact1=mysql_real_escape_string($_POST['contact1']);
- $contact2=mysql_real_escape_string($_POST['contact2']);
+ $name=mysqli_real_escape_string($db->conn, $_POST['name']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
+ $contact1=mysqli_real_escape_string($db->conn, $_POST['contact1']);
+ $contact2=mysqli_real_escape_string($db->conn, $_POST['contact2']);
$count = $db->countOf("customer_details", "customer_name='$name'");
if($count==1)
diff --git a/add_purchase.php b/add_purchase.php
index 5f55f33..65624b2 100644
--- a/add_purchase.php
+++ b/add_purchase.php
@@ -421,12 +421,12 @@ function balance_amount(){
} else {
$username = $_SESSION['username'];
- $stockid=mysql_real_escape_string($_POST['stockid']);
+ $stockid=mysqli_real_escape_string($db->conn, $_POST['stockid']);
- $bill_no =mysql_real_escape_string($_POST['bill_no']);
- $supplier=mysql_real_escape_string($_POST['supplier']);
- $address=mysql_real_escape_string($_POST['address']);
- $contact=mysql_real_escape_string($_POST['contact']);
+ $bill_no =mysqli_real_escape_string($db->conn, $_POST['bill_no']);
+ $supplier=mysqli_real_escape_string($db->conn, $_POST['supplier']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
+ $contact=mysqli_real_escape_string($db->conn, $_POST['contact']);
$stock_name=$_POST['stock_name'];
$count = $db->countOf("supplier_details", "supplier_name='$supplier'");
@@ -440,11 +440,11 @@ function balance_amount(){
$cost=$_POST['cost'];
$total=$_POST['total'];
$subtotal=$_POST['subtotal'];
- $description=mysql_real_escape_string($_POST['description']);
- $due=mysql_real_escape_string($_POST['duedate']);
- $payment=mysql_real_escape_string($_POST['payment']);
- $balance=mysql_real_escape_string($_POST['balance']);
- $mode=mysql_real_escape_string($_POST['mode']);
+ $description=mysqli_real_escape_string($db->conn, $_POST['description']);
+ $due=mysqli_real_escape_string($db->conn, $_POST['duedate']);
+ $payment=mysqli_real_escape_string($db->conn, $_POST['payment']);
+ $balance=mysqli_real_escape_string($db->conn, $_POST['balance']);
+ $mode=mysqli_real_escape_string($db->conn, $_POST['mode']);
$autoid=$_POST['stockid'];
$autoid1=$autoid;
@@ -484,7 +484,7 @@ function balance_amount(){
}
}
$msg=" Parchase order Added successfully Ref: [". $_POST['stockid']."] !" ;
- header("Location: add_purchase.php?msg=$msg");
+ //header("Location: add_purchase.php?msg=$msg");
}
}
diff --git a/add_sales.php b/add_sales.php
index 0b88a75..8b055a1 100644
--- a/add_sales.php
+++ b/add_sales.php
@@ -12,8 +12,8 @@
-
-
+
+
@@ -469,50 +469,49 @@ function discount_type(){
} else {
$username = $_SESSION['username'];
- $stockid=mysql_real_escape_string($_POST['stockid']);
+ $stockid=mysqli_real_escape_string($db->conn, $_POST['stockid']);
- $bill_no =mysql_real_escape_string($_POST['bill_no']);
- $customer=mysql_real_escape_string($_POST['supplier']);
- $address=mysql_real_escape_string($_POST['address']);
- $contact=mysql_real_escape_string($_POST['contact']);
+ $bill_no =mysqli_real_escape_string($db->conn, $_POST['bill_no']);
+ $customer=mysqli_real_escape_string($db->conn, $_POST['supplier']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
+ $contact=mysqli_real_escape_string($db->conn, $_POST['contact']);
$count = $db->countOf("customer_details", "customer_name='$customer'");
- if($count==0)
- {
- $db->query("insert into customer_details(customer_name,customer_address,customer_contact1) values('$customer','$address','$contact')");
- }
- $stock_name=$_POST['stock_name'];
+ if((int)$count==0)
+ { $db->query("insert into customer_details(customer_name,customer_address,customer_contact1) values('$customer','$address','$contact')");
+ }
+ $stock_name=$_POST['stock_name'];
$quty=$_POST['quty'];
- $date=mysql_real_escape_string($_POST['date']);
+ $date=mysqli_real_escape_string($db->conn, $_POST['date']);
$sell=$_POST['sell'];
$total=$_POST['total'];
$payable=$_POST['subtotal'];
- $description=mysql_real_escape_string($_POST['description']);
- $due=mysql_real_escape_string($_POST['duedate']);
- $payment=mysql_real_escape_string($_POST['payment']);
- $discount=mysql_real_escape_string($_POST['discount']);
+ $description=mysqli_real_escape_string($db->conn, $_POST['description']);
+ $due=mysqli_real_escape_string($db->conn, $_POST['duedate']);
+ $payment=mysqli_real_escape_string($db->conn, $_POST['payment']);
+ $discount=mysqli_real_escape_string($db->conn, $_POST['discount']);
if($discount==""){
$discount=00;
}
- $dis_amount=mysql_real_escape_string($_POST['dis_amount']);
+ $dis_amount=mysqli_real_escape_string($db->conn, $_POST['dis_amount']);
if($dis_amount==""){
- $dis_amount=00;
- }
- $subtotal=mysql_real_escape_string($_POST['payable']);
- $balance=mysql_real_escape_string($_POST['balance']);
- $mode=mysql_real_escape_string($_POST['mode']);
- $tax=mysql_real_escape_string($_POST['tax']);
- if($tax==""){
- $tax=00;
- }
- $tax_dis=mysql_real_escape_string($_POST['tax_dis']);
- $temp_balance = $db->queryUniqueValue("SELECT balance FROM customer_details WHERE customer_name='$customer'");
- $temp_balance = (int) $temp_balance + (int) $balance;
- $db->execute("UPDATE customer_details SET balance=$temp_balance WHERE customer_name='$customer'");
- $selected_date=$_POST['due'];
- $selected_date=strtotime( $selected_date );
- $mysqldate = date( 'Y-m-d H:i:s', $selected_date );
- $due=$mysqldate;
- $max = $db->maxOfAll("id", "stock_entries");
+ $dis_amount=00;
+ }
+ $subtotal=mysqli_real_escape_string($db->conn, $_POST['payable']);
+ $balance=mysqli_real_escape_string($db->conn, $_POST['balance']);
+ $mode=mysqli_real_escape_string($db->conn, $_POST['mode']);
+ $tax=mysqli_real_escape_string($db->conn, $_POST['tax']);
+ if($tax==""){
+ $tax=00;
+ }
+ $tax_dis=mysqli_real_escape_string($db->conn, $_POST['tax_dis']);
+ $temp_balance = $db->queryUniqueValue("SELECT balance FROM customer_details WHERE customer_name='$customer'");
+ $temp_balance = (int) $temp_balance + (int) $balance;
+ $db->execute("UPDATE customer_details SET balance=$temp_balance WHERE customer_name='$customer'");
+ $selected_date=$_POST['due'];
+ $selected_date=strtotime( $selected_date );
+ $mysqldate = date( 'Y-m-d H:i:s', $selected_date );
+ $due=$mysqldate;
+ $max = $db->maxOfAll("id", "stock_entries");
$max=$max+1;
$autoid="SD".$max."";
for($i=0;$iqueryUniqueValue("SELECT quantity FROM stock_avail WHERE name='$name1'");
- if($count >= 1)
+ if((int)$count >= 1)
{
@@ -565,13 +564,11 @@ function discount_type(){
- }
- $msg=" Sales Added successfully Ref: [". $_POST['stockid']."] !" ;
- header("Location: add_sales.php?msg=$msg");
-
-
-
- echo "";
+ }
+ $msg=" Sales Added successfully Ref: [". $_POST['stockid']."] !" ;
+ echo $msg;
+ //header("Location: add_sales.php?msg=$msg");
+ echo "";
//echo "";
//$msg=" Parchase order Added successfully Ref: [". $_POST['stockid']."] !" ;
//header("Location: add_purchase.php?msg=$msg");
diff --git a/add_stock.php b/add_stock.php
index e267247..21aafca 100644
--- a/add_stock.php
+++ b/add_stock.php
@@ -199,12 +199,12 @@ function numbersonly(e){
} else {
- $name=mysql_real_escape_string($_POST['name']);
- $stockid=mysql_real_escape_string($_POST['stockid']);
- $sell=mysql_real_escape_string($_POST['sell']);
- $cost=mysql_real_escape_string($_POST['cost']);
- $supplier=mysql_real_escape_string($_POST['supplier']);
- $category=mysql_real_escape_string($_POST['category']);
+ $name=mysqli_real_escape_string($db->conn, $_POST['name']);
+ $stockid=mysqli_real_escape_string($db->conn, $_POST['stockid']);
+ $sell=mysqli_real_escape_string($db->conn, $_POST['sell']);
+ $cost=mysqli_real_escape_string($db->conn, $_POST['cost']);
+ $supplier=mysqli_real_escape_string($db->conn, $_POST['supplier']);
+ $category=mysqli_real_escape_string($db->conn, $_POST['category']);
$count = $db->countOf("stock_details", "stock_id ='$stockid'");
diff --git a/add_supplier.php b/add_supplier.php
index 53060ca..04e776d 100644
--- a/add_supplier.php
+++ b/add_supplier.php
@@ -162,10 +162,10 @@
} else {
- $name=mysql_real_escape_string($_POST['name']);
- $address=mysql_real_escape_string($_POST['address']);
- $contact1=mysql_real_escape_string($_POST['contact1']);
- $contact2=mysql_real_escape_string($_POST['contact2']);
+ $name=mysqli_real_escape_string($db->conn, $_POST['name']);
+ $address=mysqli_real_escape_string($db->conn, $_POST['address']);
+ $contact1=mysqli_real_escape_string($db->conn, $_POST['contact1']);
+ $contact2=mysqli_real_escape_string($db->conn, $_POST['contact2']);
$count = $db->countOf("supplier_details", "supplier_name='$name'");
if($count==1)
diff --git a/checklogin.php b/checklogin.php
index bf609d7..4b8e021 100644
--- a/checklogin.php
+++ b/checklogin.php
@@ -12,19 +12,15 @@
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
-$myusername = mysql_real_escape_string($myusername);
-$mypassword = mysql_real_escape_string($mypassword);
-
+$myusername = mysqli_real_escape_string($db->conn, $myusername);
+$mypassword = mysqli_real_escape_string($db->conn, $mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'" ;
-$result=mysql_query($sql);
+$result=mysqli_query($db->conn, $sql);
-// Mysql_num_row is counting table row
-$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
-
-if($count==1){
+if($result->num_rows){
// Register $myusername, $mypassword and redirect to file "dashboard.php"
-$row = mysql_fetch_row($result);
+$row = mysqli_fetch_row($result);
$_SESSION['id']=$row[0];
$_SESSION['username']=$row[1];
diff --git a/database_install.php b/database_install.php
index 583cba1..f5a950f 100644
--- a/database_install.php
+++ b/database_install.php
@@ -116,7 +116,7 @@ function select_data(){
$user= trim($_POST['username']);
$pass= trim($_POST['password']);
}
- $link = mysql_connect("$host","$user","$pass");
+ $link = mysqli_connect("$host","$user","$pass");
if (!$link) {
$data="Database Configration is Not vaild";
header("location:instal.php?msg=$data");
diff --git a/deleteselected.php b/deleteselected.php
index a68ebe2..757e16f 100644
--- a/deleteselected.php
+++ b/deleteselected.php
@@ -15,7 +15,7 @@
{
$SQL = "SELECT * FROM $tablename where id=$singleVar";
-$result=mysql_query($SQL) or die(mysql_error());
+$result=mysqli_query($db->conn, $SQL) or die(mysqli_error());
$checkuser=mysql_num_rows($result);
if($checkuser>0) {
@@ -59,7 +59,7 @@
}
- mysql_query("DELETE FROM $tablename WHERE id=$singleVar") or die(mysql_error());
+ mysqli_query($db->conn, "DELETE FROM $tablename WHERE id=$singleVar") or die(mysqli_error());
$i++;
}
diff --git a/etc/GUMP-master/GUMP-master/examples/escaping_mysql_strings.php b/etc/GUMP-master/GUMP-master/examples/escaping_mysql_strings.php
index 47ab499..fd3aa7a 100644
--- a/etc/GUMP-master/GUMP-master/examples/escaping_mysql_strings.php
+++ b/etc/GUMP-master/GUMP-master/examples/escaping_mysql_strings.php
@@ -35,4 +35,4 @@
$validator->filter($_POST, $filters);
-echo mysql_real_escape_string($_POST['password']);
+echo mysqli_real_escape_string($db->conn, $_POST['password']);
diff --git a/init.php b/init.php
index d813304..1be4d10 100644
--- a/init.php
+++ b/init.php
@@ -16,7 +16,7 @@
require "lib/gump.class.php";
- $gump = new GUMP();
+ $gump = new GUMP($config['database'], $config['host'], $config['username'], $config['password']);
// Messages Settings
diff --git a/lib/db.class.php b/lib/db.class.php
index c929580..2000c3f 100644
--- a/lib/db.class.php
+++ b/lib/db.class.php
@@ -11,7 +11,7 @@ class DB
/** Put this variable to true if you want ALL queries to be debugged by default:
*/
var $defaultDebug = false;
-
+ var $conn = null;
/** INTERNAL: The start time, in miliseconds.
*/
var $mtStart;
@@ -24,20 +24,17 @@ class DB
/** Connect to a MySQL database to be able to use the methods below.
*/
- function DB($base, $server, $user, $pass)
- {
+ function __construct($base, $server, $user, $pass) {
+
$this->mtStart = $this->getMicroTime();
$this->nbQueries = 0;
$this->lastResult = NULL;
- $myconnection = mysql_connect($server, $user, $pass);
- $myconnection = mysql_select_db($base) ;
-
+ $this->conn = $myconnection = mysqli_connect($server, $user, $pass, $base);
if ($myconnection==FALSE) {
- $data='Database Connection is Not valid Please Enter The valid database connection';
- header("location:install.php?msg=$data");
- exit;
-
-}
+ $data='Database Connection is Not valid Please Enter The valid database connection';
+ header("location:install.php?msg=$data");
+ exit;
+ }
}
/** Query the database.
@@ -48,7 +45,7 @@ function DB($base, $server, $user, $pass)
function query($query, $debug = -1)
{
$this->nbQueries++;
- $this->lastResult = mysql_query($query) or $this->debugAndDie($query);
+ $this->lastResult = mysqli_query($this->conn, $query) or $this->debugAndDie($query);
$this->debug($debug, $query, $this->lastResult);
@@ -62,7 +59,7 @@ function query($query, $debug = -1)
function execute($query, $debug = -1)
{
$this->nbQueries++;
- mysql_query($query) or $this->debugAndDie($query);
+ mysqli_query($this->conn, $query) or $this->debugAndDie($query);
$this->debug($debug, $query);
}
@@ -75,10 +72,10 @@ function fetchNextObject($result = NULL)
if ($result == NULL)
$result = $this->lastResult;
- if ($result == NULL || mysql_num_rows($result) < 1)
+ if ($result == NULL || mysqli_num_rows($result) < 1)
return NULL;
else
- return mysql_fetch_object($result);
+ return mysqli_fetch_object($result);
}
/** Get the number of rows of a query.
* @param $result The ressource returned by query(). If NULL, the last result returned by query() will be used.
@@ -87,9 +84,9 @@ function fetchNextObject($result = NULL)
function numRows($result = NULL)
{
if ($result == NULL)
- return mysql_num_rows($this->lastResult);
+ return mysqli_num_rows($this->lastResult);
else
- return mysql_num_rows($result);
+ return mysqli_num_rows($result);
}
/** Get the result of the query as an object. The query should return a unique row.\n
* Note: no need to add "LIMIT 1" at the end of your query because
@@ -103,11 +100,11 @@ function queryUniqueObject($query, $debug = -1)
$query = "$query LIMIT 1";
$this->nbQueries++;
- $result = mysql_query($query) or $this->debugAndDie($query);
+ $result = mysqli_query($this->conn, $query) or $this->debugAndDie($query);
$this->debug($debug, $query, $result);
- return mysql_fetch_object($result);
+ return mysqli_fetch_object($result);
}
/** Get the result of the query as value. The query should return a unique cell.\n
* Note: no need to add "LIMIT 1" at the end of your query because
@@ -121,8 +118,8 @@ function queryUniqueValue($query, $debug = -1)
$query = "$query LIMIT 1";
$this->nbQueries++;
- $result = mysql_query($query) or $this->debugAndDie($query);
- $line = mysql_fetch_row($result);
+ $result = mysqli_query($this->conn, $query) or $this->debugAndDie($query);
+ $line = mysqli_fetch_row($result);
$this->debug($debug, $query, $result);
@@ -171,7 +168,7 @@ function countOfAll($table)
function debugAndDie($query)
{
$this->debugQuery($query, "Error");
- die("
".mysql_error()."
");
+ die("
".mysqli_error($this->conn)."
");
}
/** Internal function to debug a MySQL query.\n
* Show the query and output the resulting table if not NULL.
@@ -239,7 +236,7 @@ function debugResult($result)
echo "
".$fields[$i]."
";
echo "";
// END HEADER
- while ($row = mysql_fetch_array($result)) {
+ while ($row = mysqli_fetch_array($result)) {
echo "
";
for ($i = 0; $i < $numFields; $i++)
echo "
".htmlentities($row[$i])."
";
diff --git a/lib/db.help.txt b/lib/db.help.txt
index 0d5d69a..0d773ad 100644
--- a/lib/db.help.txt
+++ b/lib/db.help.txt
@@ -13,7 +13,7 @@ $db = new DB($base, $server, $user, $pass);
/************************** Basic Queries: **********************************/
-// Do a query (return the same as mysql_query):
+// Do a query (return the same as mysqli_query($db->conn, ):
$result = $db->query("SELECT * FROM People");
$result = $db->query("SELECT * FROM People", true); // With DEBUG
diff --git a/lib/gump.class.php b/lib/gump.class.php
index 3b68ae3..2b7c4cb 100644
--- a/lib/gump.class.php
+++ b/lib/gump.class.php
@@ -15,11 +15,14 @@ class GUMP
protected $validation_rules = array();
// Filter rules for execution
- protected $filter_rules = array();
+ protected $filter_rules = array();
+ var $conn = null;
// Instance attribute containing errors from last run
protected $errors = array();
-
+ function __construct($base, $server, $user, $pass) {
+ $this->conn = $myconnection = mysqli_connect($server, $user, $pass, $base);
+ }
// ** ------------------------- Validation Data ------------------------------- ** //
public static $basic_tags = "