PHP projects sourcecode giveaway (NetFolder, ARMS)

I’ll be giving out sourcecode of my PHP projects for free with hope that I will gain some input from you all.

There are around 10 php projects which will be shared. Okay, the first project will be NetFolder, which is an online efiling system.

NetFolder (online f-filing)
Demo : http://efiling.reeq.my
Username : testing
Password : testing23

I have made two customized version based on this project which is currently being used by my customers.

If you are interested with the project, inform me and I’ll give you the latest updated source code, because I might update the code now and then.

The coding is fairly simple, if you ever read on my previous post regarding oneFace. :) The database itself is only consist of 31 tables. The brand “NetFolder” is reserved, thus you are encouraged to put your own branding if you plan to derive another fork of it.

*Update as of 25th March 2012

Download link :  http://goo.gl/JWcID
Database : /efilingv4/efiling.sql

*Update as of 27th March 2012

ARMS (fixed asset record management system)
Demo : http://reeq.my/arms/
Username : testing
Password : <no password>

There is also customized version of the system which concentrate more on the asset movement and telecommunication equipment record.

If you are interested with the project, inform me and I’ll give you the latest updated source code, because I might update the code now and then.

Download link :  http://goo.gl/AENE8
Database : /arms/arms.sql

ACM(access contol matrix) in oneface

In the nutshell, here’s how simple acm in miniOneFace:

session_start();
include 'prepend.php';
include DBCONFIG;
if(isset($_SESSION['role'])){
$db_connection = new mysqli($DB_OBJ['DB_HOST'],$DB_OBJ['DB_USER'],$DB_OBJ['DB_PASS'],$DB_OBJ['DB_NAME']);
$rs = $db_connection->query("select * from acm_realm where role_id = '".$_SESSION['role']."' AND INSTR('".$_SERVER['PHP_SELF']."',key_pattern)>0");
$d = $rs->fetch_array(MYSQLI_ASSOC);
if($d['id']!=''){
}else{
go(NOT_AUTHORIZED);
exit();
}
mysqli_free_result($rs);
mysqli_close($db_connection);
}else{
go(NOT_LOGIN);
exit();
}

And here’s the of-action (using classic wrapper):


include "_set.php";
include PERSIST;
include DBCONFIG;

$p = new Persist($DB_OBJ);
$p->setTable("acm_realm");

if (e('act')==md5('add_top')){
$p->set("code",e("code"),"s");
$p->set("parent_id",-1,"i");
$p->insert();
go("acm_edit.php?role_id=1&t=".$p->getAutoId());
}
if (e('act')==md5('add_child')){
$p->set("code",e("code"),"s");
$p->set("key_pattern",e("key_pattern"),"s");
$p->set("parent_id",e("parent_id"),"i");
$p->set("role_id",e("role_id"),"i");
$p->insert();
go("acm_edit.php?role_id=".e("role_id")."&t=".e('t'));
}
if (e('act')==md5('update_child')){
$p->set("code",e("code"),"s");
$p->set("key_pattern",e("key_pattern"),"s");
$p->set("role_id",e("role_id"),"i");
$p->setCriteria("id=".e("id"));
$p->update();
go("acm_edit.php?role_id=".e("role_id")."&t=".e('t'));
}
if (e('act')==md5('delete_child')){
$p->set("id",e("id"),"s");
$p->delete();
go("acm_edit.php?role_id=".e("role_id")."&t=".e('t'));
}

with this sample tables :
CREATE TABLE `acm_realm` (
`id` int(11) NOT NULL auto_increment,
`code` varchar(200) default NULL,
`role_id` int(11) default NULL,
`key_pattern` varchar(200) default NULL,
`date_added` datetime default NULL,
`parent_id` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;

CREATE TABLE `acm_role` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) default NULL,
`description` varchar(200) default NULL,
`value` bigint(20) default NULL,
`date_added` datetime default NULL,
`parent_id` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

CREATE TABLE `w_user` (
`usr_id` int(11) NOT NULL auto_increment,
`usr_username` varchar(100) default NULL,
`usr_password` varchar(100) default NULL,
`usr_role` varchar(20) default NULL,
`usr_parentid` int(11) default NULL,
PRIMARY KEY (`usr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

What this acm do is check every request, either it is authorized or not. Checking is done by matching request url with key_pattern(url pattern). And it the request url is not authorized, user will be redirected to unauthorized notice page. In case propagate is not set to true during runtime, oneface can’t use forceLogout() feature, so, we have to check for login status from time to time.

oneface xzilim

It’s been a long time since I wrote my last post here. Okay, it’s 2010, start fresh. Lately, I’ve been concentrating with oneFace research in reeqSolution. Quite an enjoyable moment. Who has imagined that the simple script i wrote back then grows and become a full web framework and intensively used by reeqSolution. Then, lemme share the taste of oneFace. Currently, oneFace support both java and php.

Using persist for direct db manipulation:

$p = new Persist($DB_OBJ);
$p->setTable("tableName");
$p->set("column1",e("request_param1"),"datatype");
$p->set("column2",e("request_param2"),"datatype");
$p->insert();

“datatype” is either “s”,”i”,”d”,”b” (you should familiar with mysqli datatype);

“request_param” is usually the name of the input in form. this handles $GET, $_POST, $_SESSION and $_FILE (file handling will be discuss in next topic)

Persist provides lot of function. Some of inportant function :
getList(), get(), getPagedList(), referCode(), insert(), update(), delete(), getJoinList(), create(), execute(), loadShift() …etc, etc..

Usually in oneface, persist is coupled with ofaction class

typical ofaction for user CRUD

include "_set";
include PERSIST;
include DBCONFIG;
include ONEFACE;

$p1 = new Persist($DB_OBJ); // form-table mapping
$of = $req->getFace(); // oneFace propagator

$p1->setTable("tbl_user");
run($p1,$of); // entry point

// required for of-action class.
function populate(){
$p1->set("usr_id",e("txt_id"),"s");
$p1->set("usr_name",e("txt_name"),"s");
$p1->set("usr_nric",e("txt_nric"),"s");
$p1->set("usr_dob",e("txt_dob"),"s");
$p1->set("usr_pic",e("file_pic"),"b");
$p1->set("usr_address",e("txt_address"),"s");
$p1->set("usr_postcode",e("txt_postcode"),"s");
$p1->set("usr_city",e("txt_city"),"s");
$p1->set("usr_state",e("txt_state"),"s");
$p1->set("usr_email",e("txt_email"),"s");
$p1->set("usr_phone",e("txt_phone"),"s");
$p1->set("usr_date_added",e("txt_date_added"),"s");
}

// required : will be run if action parameter is "add"
function add($p1,$of){
$p1->insert();
$of->closeTab();
$of2 = addTab("user_view.php?id=".$p1->getAutoId());
$of2->focus();
}

// required : will be run if action parameter is "delete"
function delete($p1,$of){
$rv = $p1->delete();
if ($rv){
$of->closeTab();
}else{
$of->notify("Failed to delete data!");
}
}

// required : will be run if action parameter is "update"
function update($p1,$of){
$rv = $p1->update();
$of->notify($rv?"Data Successfully updated!":"Failed to delete data!");
}

// required : left empty for no validation. this method intercept further action.

function validation($p1, $of){
if (e("txt_name") == ''){
$of->message("txt_name","Name cannot be empty!");
}
// other validation
}

as you can see ofaction (OneFace Action Skeleton) provide a controller-like layer. ofaction provides oneface function and persist to deal with oneface front-end. Sometime oneface and persist coupled without being assist by ofaction class, or maybe i should say, can be embedded in front-end. For example, is dynamic datagrid.


$query = e("q");
$p1 = new Persist($DB_OBJ);
$p1->setTable("w_user");
$userlist = $p1->getList($query);
$of = $req->getFace();
$header = array("usr_name"=>"Name",
"usr_age"=>"Age",
"usr_phone"=>"Phone");
$of->setList($userlist, $header);
$of->populate();

There are numbers of oneface Face functions. Some of them are:

addTab(), closeTab(), go(), notify(), activate(), setMasterFaceInfo(), propagateUpdate(), litebox(), forceLogout(), forceRedirect(), addTrigger(), removeTrigger(), setTreeView(), updateTreeView(), pilot(), etc, etc...

So, we have persist dealing with back-end, ofaction become a controller and oneface Faces deals with front-end. From other view, this could be seen as MVC. The different is just, everything in oneface is ajax. You code addTab in server-side, but an optimized  javascript to add new tab and retrieved content via ajax will be sent. New feature as in v3.5 like notify(), forceLogout(), forceRedirect() is using ajax-push thingy (though I don’t really understand how, i know this action is triggered serverside, without the client have to initiate anything.

How to start using oneface?

you have to define oneface region in your page first. Normally I do this:

of_obj = {
"of_trigger" = "div_id",
"of_tabpane" = "div_id",
"of_view" = "div_id",
"of_treeview" = "div_id",
"of_strict_option" = false
}
oneface = new OneFace(of_obj);

Well, for most of oneface-ready template out there, you just have to change of_strict_option to true since most of the region is well defined. The example above is minimal oneface region target just to make it works.

Oneface covers mostly everything from access control, screen for reference code, reporting, admin page, templating, i18n with small blueprint. It’s crazily optimized for performance and speed without affecting the flexibility.

Follow

Get every new post delivered to your Inbox.