OneFile

OneFile is a package of several small PHP-applications or helpers. These were originally developed only for my own usage, because I had for example troubles checking my e-mail while being on vacation (no Eudora), because I did not have a free FTP program on the Macintosh for OsX, or because I had no mySQL server. The OneFile things are also simple. Some design principles are:

Go download it.

To make the code freely available to everyone, I do not claim copyright on my work. Be aware that the code is provided "as is", with absolutely no warranty expressed or implied. Any use is at your own risk. Ow, please mail me (niels [@] bonneville.nl) if you use the software regulary, that would be nice.

I, the author of this work, hereby release it into the public domain. This applies worldwide. In case this is not legally possible: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

OneMail

This small script let you send and receive e-mail without bullshit. Note that there's no local storage, so there is no address book nor spam-filter (perhaps in the future), but on the other hand it can handle a lot of users, and perhaps that's why it is often chosen by webmasters and hosting companies. Since 1.49, spam-assist-signed e-mails are automaticly deleted (you can turn this off if you might want to). Current status: no known errors, only I still have to test the IMAP-stuff, for now it works with IMAP-servers but the folder-stuff is disabled.

Tip: put things like 'onemail.php' in a folder '/email' and rename it to 'index.php'.
You can always e-mail me!
Niels Gorisse

OneFTP

OneFTP is a small FTP-script, which does what you expect it to do. The only thing it has besides the basic stuff, is virtual users, which means that although you only have one FTP-account, you can fake extra accounts. This might be usefull if you do not have your own hosted server but you want to give access to a directory to someone specificly. Note that you often can't upload more than 2MB due to PHP-server-settings.

OneForum

OneForum is a very small basic forum, which uses flat files to save the messages. The code is so small, it nearly fits on one paper. This has the advantage that if there is something you don't like about it, you can easily change it yourself. And it installs as all scripts: upload it, and you're done. For if you need to have a small forum right now.

OnePoll

OnePoll is an open poll-system, usefull to get an answer from a lot of people, but without getting tons of mails or spend an hour reading a forum to get the conclusion. People can add any new options themselves, that's the thing with Onepoll. This really saved me a lot of e-mail-reading; it really works quite well when there are more than 4 persons and you have to decide one thing.

Note: make a subfolder called 'data', and make sure it's chmod'ded to be writable by PHP, because that's where the data is stored. You can put an index.html or a .htaccess there to make sure nobody can read it.

OneSQL

OneSQL (formally known as noSQL) is a small set (11kb) of SQL-like PHP functions to manage a database in an SQL-like way, but without actually having a SQL-server. Everything is stored in flat .csv-formatted files, so putting data into OneSQL or getting data from OneSQL inside a spreadsheet program is a piece of cake. If you are too lazy to setup an SQL-server, or you simply don't have one right now but perhaps later in the future, use OneSQL.

There are 9 primal functions inside OneSQL. Similar SQL-queries are printed above each function. Here they are:


// IF OBJECT_ID($table) IS NOT NULL RETURN 'TRUE' else RETURN 'FALSE'
function nosql_present($table)

// CREATE TABLE '$table' $fields
function nosql_createTable($table,$fields)

// DROP TABLE '$table'
function nosql_dropTable($table)

// SELECT * FROM '$table'
function nosql_selectAllFrom($table)

// SELECT * FROM '$table' WHERE '$property' $comparator '$value'
function nosql_selectAllFromWhere($table,$property,$comparator,$value)

// INSERT INTO '$table' VALUES $record
function nosql_insertInto($table,$record)

// UPDATE '$table' SET '$prop' = '$new' WHERE '$searchfor' = '$value'
function nosql_updateSetWhereEquals($table,$prop,$new,$searchfor,$value)

// DELETE FROM '$table' WHERE '$property' $comparator '$value'
function nosql_deleteFromWhere($table,$property,$comparator,$value)

// mysql_fetch_array($array);  the second argument is optional, which is by default MYSQL_BOTH
function nosql_fetch_array(&$pointer,$how="NOSQL_BOTH")

Example

A small example is listed below here. If you do not understand this, then go and learn PHP first and do not start with OneSQL before you do understand it.


if (!nosql_present("test"))
	nosql_createTable("test",array("name","lastname","birthdate"));

$add[name]="no";
$add[lastname]="SQL";
$add[birthdate]="22 November 2003";
nosql_insertInto("test",$add);

echo "<table>";
$result=nosql_selectAllFromWhere("test","lastname","=","SQL");
nosql_sort($result,"lastname"); // you can leave this line out if you don't want any sorting
while ($record=nosql_fetch_array($result))
   {
   echo "<tr><td>$record[name]</td><td>$record[lastname]</td><td>$record[birthdate]</td></tr>";
   }
echo "</table>";

nosql_updateSetWhereEquals("test","birthday",time(),"name","no");

nosql_deleteFromWhere("test","name","=","no");

There are a few more functions, which have two selection requirements instead of one. And, there is a sorting algorithm. Here they are:


// SELECT * FROM $table WHERE $property $comparator $value        AND $prop2 $comp2 $val2
function nosql_selectAllFromWhereAnd($table,$property,$comparator,$value  ,$prop2,$comp2,$val2)

// UPDATE $table SET $prop=$new WHERE $searchfor=$value         AND $also=$val
function nosql_updateSetWhereEqualsAnd($table,$prop,$new,$searchfor,$value  ,$also,$val)

// DELETE FROM '$table' WHERE '$property' $comparator '$value' AND  '$prop' $comp '$val'
function nosql_deleteFromWhereAnd($table,$property,$comparator,$value,$prop,$comp,$val)

// (SELECT .... FROM $table ) ORDER BY $column $type
// Use between the select() and fetch_array() calls, and use the select() argument.
// Look at the example above, and notice that this method does not return any value, it only alters
// the existing select-result. The last parameter is optional, and is "ASC" by default; change this to
// "DESC" to make it a descending sort.
function nosql_sort($select_result,$column,"ASC")

// (SELECT * FROM $table ) ORDER BY RAND() $LIMIT
// Use between the select() and fetch_array() calls, and use the select() argument.
// This function selects $limit items randomly from a table.
// Note: UNTESTED
function nosql_OrderByRandLimit(&$select_result,$limit)


/*
$query   = array (property,comparator,value)
  OR
$query[] = array (property,comparator,value)

call with
   nosql_selectAllFromWhereArr("inc/db/article",array("property","comperator","value"));
OR
   $query[] = array("property","comperator","value");
   nosql_selectAllFromWhere("inc/db/article",$query);
Note: UNTESTED
*/
function nosql_selectAllFromWhereArr($table,$query)

Your files will be acessible by a simple http:// call. To fix this:

Note: if you want to import a .csv file, first prepare the .csv file with a text-editor so that the line-endings are unix line-endings and not DOS line-endings. The first line is used as names of the colums (look at a OneSQL generated file first).

Furthermore, there's one thing I still have to do, that is: make 100% .csv compatibility by adding "" around a field if it contains ';', not it is simply replaced with something odd, which works perfectly.

Download

Download it here: OneFile1.72.zip (± 100kb)

Last updates: