Forums / General Questions / Connecting to the database for Ajax Search... Making it safe.

Connecting to the database for Ajax Search... Making it safe.

Views: 1,046

Results 1 to 6 of 6
22 Dec 2013, 6:58 PM
#1
ultimate_zc avatar

ultimate_zc

Zen Follower

Join Date:
Jun 2008
Location:
Osprey, Florida
Posts:
147
Plugin Contributions:
7

Connecting to the database for Ajax Search... Making it safe.

I'm working on an Ajax Search plugin. As of right now I have search.php file which I'm uploading to the root level of the server. In order for the plugin to work, I need to connect to the database therefore I'm adding the settings for sever, user, database name and database password from configure.php.

Thus far it works either of the following two ways

I just add:

include('includes/configure.php');

or add :

define('DB_SERVER', 'localhost');
define('DB_SERVER_USERNAME', 'root');
define('DB_SERVER_PASSWORD', 'root');
define('DB_DATABASE', 'database');

The ideal would be to use the first example since there would be no need to modify the file but regardless, I'm concerned about exposing any settings that could compromise the safety of the website.

How can I make this file safe from intrusion other than just setting the permissions to read only?

Is either of these examples above safer than the other?

Thanks for any advice.

22 Dec 2013, 7:13 PM
#2
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Connecting to the database for Ajax Search... Making it safe.

ultimate_zc:

I'm working on an Ajax Search plugin. As of right now I have search.php file which I'm uploading to the root level of the server. In order for the plugin to work, I need to connect to the database therefore I'm adding the settings for sever, user, database name and database password from configure.php.

Thus far it works either of the following two ways

I just add:

include('includes/configure.php');

> 
> or add :
> 
> ```php
define('DB_SERVER', 'localhost');
define('DB_SERVER_USERNAME', 'root');
define('DB_SERVER_PASSWORD', 'root');
define('DB_DATABASE', 'database');

The ideal would be to use the first example since there would be no need to modify the file but regardless, I'm concerned about exposing any settings that could compromise the safety of the website.

How can I make this file safe from intrusion other than just setting the permissions to read only?

Is either of these examples above safer than the other?

Thanks for any advice.

I always use

require('includes/application_top.php');

// whatever code

require('includes/application_bottom.php');

22 Dec 2013, 7:20 PM
#3
ultimate_zc avatar

ultimate_zc

Zen Follower

Join Date:
Jun 2008
Location:
Osprey, Florida
Posts:
147
Plugin Contributions:
7

Re: Connecting to the database for Ajax Search... Making it safe.

That works pretty good too, thanks.

Is it safe? Should I move that file into a folder along with an index.html? I think that just by setting the file to read only should work but I'm hoping to hear a better suggestion.

22 Dec 2013, 7:52 PM
#4
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Connecting to the database for Ajax Search... Making it safe.

ultimate_zc:

That works pretty good too, thanks.

Is it safe? Should I move that file into a folder along with an index.html? I think that just by setting the file to read only should work but I'm hoping to hear a better suggestion.

check these out:
http://www.zen-cart.com/docs/phpdoc-1-5-0/initSystem/_includes---application_top.php.html

http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials#InitSystem

22 Dec 2013, 8:23 PM
#5
ultimate_zc avatar

ultimate_zc

Zen Follower

Join Date:
Jun 2008
Location:
Osprey, Florida
Posts:
147
Plugin Contributions:
7

Re: Connecting to the database for Ajax Search... Making it safe.

Can't thank you enough.

Happy Holidays!

22 Dec 2013, 8:25 PM
#6
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Connecting to the database for Ajax Search... Making it safe.

ultimate_zc:

Can't thank you enough.

Happy Holidays!

Happy Holidays to you!