I am currently developing a website and a web app (different code) that will share the same data, and this data is stored inside a database. I made it this way:
I have two domains
Domain 1 -> contains the utilities (ie. php files to query the db)
Domain 2 -> contains the website
from domain2
i send a request to http://domain1.com/utilities/php/domain2/get_from_db.php
and this gives me back the result i need.
My fear is that this is no secure, as the files are somehow exposed?
It used to be an empty website, and if you were to navigate to http://domain1.com/ the file structure was visible. I now created an empty index.php
file, so that the file structure is not visible anymore.
I have the impression this is still not really secure, am i correct?
the database files are the following:
config.ini
get_from_db.php
the get_from_db.php
has this code to connect and get the data back from the db:
header("Access-Control-Allow-Origin: http://domain2.com");
$db = new mysqli($host, $config['username'], $config['password'], $config['dbName');
if ($db->connect_errno > 0) {
die('Unable to connect to database [' . $db->connect_error . ']');
}
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
class data
{
public $id = "";
public $col1 = "";
public $col2 = "";
public $col3 = "";
public $col4 = "";
}
$sql = "SELECT * FROM myDb.myTable";
$result = mysqli_query($db, $sql) or die(mysqli_error($db));
$obj = array();
while ($row = $result->fetch_assoc()) {
$col1 = $row['col1'];
$col2 = $row['col2'];
$col3 = $row['col3'];
$col4 = $row['col4'];
$e = new cvdata();
$e->col1 = $skills;
$e->col2 = $hobbies;
$e->col3 = $education;
$e->col4 = $experience;
array_push($obj, $e);
}
echo json_encode($obj);
now, my final question is:
Is this level of security enough? (I mean, I know about login and so on, but this is a very simple project and the data should be available to everyone tries to use the website or the app as it is not sensitive at all (it is just some project's details, that's all))
Thanks for any help, suggestion or advice