PDA

View Full Version : Requesting a script review (TextDatabase)


Michiel
06-21-2004, 11:36 PM
Hi,

since March this year I've been working on a php class that acts as a text database. I recently released version 1.2 and together with that I translated the manual in english.

Since building the class has been great fun for me and has turned out to be very educational, I decided that others should benifit from my work as well.

However, the class is all but finished and therefore I'd like to ask you to visit my website and review my work. Please inform me of the things I do well and the things I do wrong. Do you spot safety issues? Can you find ways to improve the performance etc. etc.

I hope to receive some usefull feedback either via this board or via email, that I can use to improve my class. Please visit MilesTextDB homepage (http://www.mileswebdesign.nl/MilesTextDB/) for more information and a downloadable zipfile with the class.


Cheers, Michiel

Y-STU-K
06-21-2004, 11:44 PM
thats awesome :) thats proper cool in fact, is it ok if i use this in some of my sites?

raf
06-22-2004, 07:58 AM
Hmm. This is kinda reinventing the wheel ...
SQLite has far more functionalitys : http://www.php.net/sqlite
and there must be a few hundred other textbased db-classes around. So it might have been educational and fun for you, but i think there are better alternatives available.

As for security, i think this will be a bit of a problem:

function CreateDatabase($sDatabase) {
$_sDir = $this->_aConfig['path'].$sDatabase;
if(is_dir($_sDir)) {
return false;
}
else {
$_sDir = $_sDir.'/';
mkdir($_sDir, 0777);
return true;
}
}

since it give all rights to anyone on this directory.

i would chmod it back after creating the directory. And then each time you want to create a table, chmod it to 0777, and back to read only afterwards. Before inserting or updating, chmod to 0644 etc.

not a big expert on permissions, but you'll need to check out which chmod codes also work for windows (or include the OS in your configsection and then select the appropriate code for that OS when required)

carl_mcdade
06-22-2004, 03:16 PM
Nice code!

You can check out the one I have helped with (Built some extra SQL parser functions) here:http://www.heroforhire.net/textDB/

Open the files and check out the SQL parser. It will give you some other ideas about improving yours. The code is under BSD licensing so feel free to use it.

I have built an entire CMS around this text file database. Unlike most I feel that text file dbs have a place even with SQLite and embedded MySQL around. Mostly because text files are not server dependant. If PHP works then your database works. No worrying about the web hosts particular configuration hanging you up. Also these type of dbs are faster than people think. Not everyone wants to hook into a database server for 500 records.