diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..3481b31
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,8 @@
+ErrorDocument 404 index.php
+RewriteEngine On
+
+RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^(.*)/?$ index.php?params=$1 [L,NC]
+
diff --git a/App/application.ini b/App/application.ini
new file mode 100644
index 0000000..d828072
--- /dev/null
+++ b/App/application.ini
@@ -0,0 +1,22 @@
+[App]
+application = forkphp
+phpSettings.display_startup_errors = 1
+phpSettings.display_errors = 1
+[db]
+mysql.maindb.adapter = PDO_MYSQL
+mysql.maindb.username = root
+mysql.maindb.dbname = tomwased
+mysql.maindb.host = localhost
+mysql.maindb.password =
+
+mysql.forkAdmin.adapter = PDO_MYSQL
+mysql.forkAdmin.username = root
+mysql.forkAdmin.dbname = forkAdmin
+mysql.forkAdmin.host = localhost
+mysql.forkAdmin.password =
+[users]
+users.class=users
+
+[layouts]
+layouts.default=default
+layouts.admin=admin
\ No newline at end of file
diff --git a/App/exceptions.ini b/App/exceptions.ini
new file mode 100644
index 0000000..d2d45d5
--- /dev/null
+++ b/App/exceptions.ini
@@ -0,0 +1,9 @@
+[Exceptions]
+exception_1000=Exception %u : Undefined Module %s
+exception_1001=Exception %u : Controller Class not found
+exception_1002=Exception %u : Undefined Controller %s
+exception_1003=Exception %u : Undefined Action %s in %s Controller
+exception_1004=Exception %u : view file %s.phtml not found.
+exception_1005=Exception %u : layout file %s.phtml not found.
+exception_1006="Exception %u : Invalid call to view method from layout.viewRequired property is set to false from Action Object."
+exception_1007="Exception %u : Parameters passed to view in ajax call of %s Action"
\ No newline at end of file
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..7ded0e4
--- /dev/null
+++ b/index.php
@@ -0,0 +1,23 @@
+getPath($url,$host);
+print_r($path);
+/*$ini_array = parse_ini_file("App/application.ini");
+print_r($ini_array);*/
+
+?>
\ No newline at end of file
diff --git a/latest b/latest
new file mode 160000
index 0000000..eaab850
--- /dev/null
+++ b/latest
@@ -0,0 +1 @@
+Subproject commit eaab85002a522d2d5906a4b5fa564fb6db4e3353
diff --git a/layouts/admin.phtml b/layouts/admin.phtml
new file mode 100644
index 0000000..0763bf4
--- /dev/null
+++ b/layouts/admin.phtml
@@ -0,0 +1,240 @@
+appendJS("jquery.min.js");
+$this->appendJS("bootstrap.min.js");
+$this->appendJS("jquery.cookie.js");
+$this->appendJS("jquery.treeview.js");
+$this->appendJS("prism.js");
+$this->appendJS("bootbox-4.1.0.min.js");
+$this->appendJS("admin/admin.js");
+$this->appendJS("../edit_area/edit_area_full.js");
+$this->appendCSS("bootstrap.min.css");
+$this->appendCSS("bootstrap-theme.min.css");
+$this->appendCSS("jquery.treeview.css");
+$this->appendCSS("prism.css");
+$this->appendCSS("admin/style.css");
+
+$obj = new adminlayoutController();
+$user = $obj->test();
+//echo $user;
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
$dirname \n");
+ echo "
\n";
+ while (false !== ($file = readdir($dir_handle)))
+ {
+ if($file!="." && $file!="..")
+ {
+ if (is_dir($path."/".$file))
+ {
+ //Display a list of sub folders.
+ ListFolder($path."/".$file);
+ }
+ else
+ {
+ //Display a list of files.
+ echo "$file ";
+ }
+ }
+ }
+ echo " \n";
+ echo "\n";
+
+ //closing the directory
+ closedir($dir_handle);
+ }
+ echo "
";
+ ListFolder($_SERVER['DOCUMENT_ROOT']."//".$GLOBALS['host']);
+ echo " ";
+ ?>
+
+
+ view(); ?>
+
+
+
+
\ No newline at end of file
diff --git a/layouts/controllers/adminlayoutController.php b/layouts/controllers/adminlayoutController.php
new file mode 100644
index 0000000..347147b
--- /dev/null
+++ b/layouts/controllers/adminlayoutController.php
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/layouts/controllers/defaultlayoutController.php b/layouts/controllers/defaultlayoutController.php
new file mode 100644
index 0000000..53dd8c4
--- /dev/null
+++ b/layouts/controllers/defaultlayoutController.php
@@ -0,0 +1,41 @@
+loadNavData();
+ $libObj = new Fork_Lib();
+ $controller = $libObj->getControllerName();
+ switch ($controller)
+ {
+ case 'index':
+ $data[0]['current']=1;
+ break;
+ case 'about':
+ $data[1]['current']=1;
+ break;
+ case 'experiments':
+ $data[2]['current']=1;
+ break;
+
+ case 'blog':
+ $data[3]['current']=1;
+ break;
+ case 'contact':
+ $data[4]['current']=1;
+ break;
+
+ }
+ return $data;*/
+ }
+ }
+?>
\ No newline at end of file
diff --git a/layouts/default.phtml b/layouts/default.phtml
new file mode 100644
index 0000000..f0867fb
--- /dev/null
+++ b/layouts/default.phtml
@@ -0,0 +1,86 @@
+appendJS("jquery.min.js");
+$this->appendJS("bootstrap.min.js");
+$this->appendJS("jquery.cookie.js");
+$this->appendJS("jquery.treeview.js");
+$this->appendJS("prism.js");
+$this->appendJS("bootbox-4.1.0.min.js");
+
+$this->appendJS("admin/admin.js");
+//$this->appendJS("../edit_area/edit_area_full.js");
+$this->appendCSS("bootstrap.min.css");
+$this->appendCSS("bootstrap-theme.min.css");
+$this->appendCSS("jquery.treeview.css");
+$this->appendCSS("prism.css");
+$this->appendCSS("admin/style.css");
+
+//echo $user;
+?>
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/layouts/defaultfront.phtml b/layouts/defaultfront.phtml
new file mode 100644
index 0000000..a7b3940
--- /dev/null
+++ b/layouts/defaultfront.phtml
@@ -0,0 +1,36 @@
+appendJS("jquery.min.js");
+ $this->appendJS("bootstrap.min.js");
+ $this->appendJS("forklib.js");
+ $this->appendCSS("bootstrap.min.css");
+ $this->appendCSS("bootstrap-theme.min.css");
+ $this->appendCSS("default/style.css");
+ $iconPath= $this->baseUrl().'/img/icon.png';
+ $this->headString(" "); // set icon
+
+?>
+
+
+view(); ?>
\ No newline at end of file
diff --git a/lib/Entities/forkAdmin.php b/lib/Entities/forkAdmin.php
new file mode 100644
index 0000000..3320759
--- /dev/null
+++ b/lib/Entities/forkAdmin.php
@@ -0,0 +1,55 @@
+$property;
+ }
+ }
+
+ public function __set($property, $value) {
+ if (property_exists($this, $property)) {
+ $this->$property = $value;
+ }
+
+ return $this;
+ }
+
+}
+class user_profile extends EntityFramework
+{
+ private $id;
+ private $name;
+ private $user_id;
+ private $img_url;
+ function __construct()
+{
+ $class = __CLASS__;
+parent::__construct('forkAdmin',$class);
+}
+ public function __get($property) {
+ if (property_exists($this, $property)) {
+ return $this->$property;
+ }
+ }
+ public function __set($property, $value) {
+ if (property_exists($this, $property)) {
+ $this->$property = $value;
+ }
+ return $this;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/lib/Entities/maindb.php b/lib/Entities/maindb.php
new file mode 100644
index 0000000..e92f3a4
--- /dev/null
+++ b/lib/Entities/maindb.php
@@ -0,0 +1,31 @@
+$property;
+ }
+ }
+
+ public function __set($property, $value) {
+ if (property_exists($this, $property)) {
+ $this->$property = $value;
+ }
+
+ return $this;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/lib/EntityFramework.php b/lib/EntityFramework.php
new file mode 100644
index 0000000..27ecb7a
--- /dev/null
+++ b/lib/EntityFramework.php
@@ -0,0 +1,197 @@
+table=$table;
+ $this->db=$db;
+ }
+}
+class Entity
+{
+ private $class;
+ private $data;
+ function __construct($object)
+ {
+ if(is_array($object))
+ {
+ if(count($object)>0)
+ {
+ $class=get_class($object[0]);
+ $this->class=$class;
+ $this->data=$object;
+ }
+ }
+ }
+ public function __get($property) {
+ if (property_exists($this, $property)) {
+ return $this->$property;
+ }
+ }
+
+ public function __set($property, $value) {
+ if (property_exists($this, $property)) {
+ $this->$property = $value;
+ }
+ }
+ function where($cond)
+ {
+
+ $data=array();
+ foreach ($this->data as $obj) {
+ $condition = 'if('.$cond.'){return 1;}';
+ $condition = eval($condition);
+ if($condition)
+ {
+ $data[]=$obj;
+ }
+ }
+ $entityObj= new Entity($data);
+ return $entityObj;
+ }
+ function toObject()
+ {
+ $data = array();
+
+ foreach ($this->data as $row) {
+ $data[]=$row;
+ }
+ if(count($data)==1)
+ {
+ $data= $data[0];
+ }
+ return $data;
+ }
+ function toArray()
+ {
+ $data = array();
+ if(count($this->data)>0)
+ {
+ foreach ($this->data as $row) {
+ $class = $this->class;
+ $reflection = new ReflectionClass($class);
+ $objRow=array();
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $field_val=$row->$field_name;
+ if($row->$field_name!="")
+ {
+ $objRow[$field_name]=$field_val;
+ }
+ }
+ $data[]=$objRow;
+ }
+ }
+ if(count($data)==1)
+ {
+ $data=$data[0];
+ }
+ return $data;
+ }
+}
+class DbContext
+{
+
+ function Add($object)
+ {
+ $reflection = new ReflectionClass(get_class($object));
+ $data=array();
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $field_val=$object->$field_name;
+ $data[$field_name]=$field_val;
+ }
+ $rowData= array("table"=>get_class($object),"data"=>$data);
+ $con = new MysqlConnection($object->db);
+ $con->insert($rowData);
+ }
+ function Get($object)
+ {
+ $class = get_class($object);
+ $reflection = new ReflectionClass($class);
+ $data=array();
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $field_val=$object->$field_name;
+ //echo $field_name."_".$field_val."_".$object->$field_name." ";
+ if(isset($field_val))
+ {
+ $data[$field_name]=$field_val;
+ }
+ }
+ $rowData= array("table"=>$class,"condition"=>$data);
+
+ $con = new MysqlConnection($object->db);
+
+ $data=$con->select($rowData);
+ //print_r($data);
+ $objArray=array();
+ foreach ($data as $var) {
+ $obj = new $class();
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $obj->$field_name=$var[$field_name];
+ }
+ $objArray[]=$obj;
+ }
+ $entityObj=new Entity($objArray);
+ return $entityObj;
+
+
+ }
+
+ function Delete($object)
+ {
+ $class = get_class($object);
+ $reflection = new ReflectionClass($class);
+ $data=array();
+ $con = new MysqlConnection($object->db);
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $field_val=$object->$field_name;
+ if($object->$field_name!="")
+ {
+ $data[$field_name]=$field_val;
+ }
+ }
+ $rowData= array("table"=>$class,"condition"=>$data);
+ $obj = new $class();
+ $result = $con->delete($rowData);
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $obj->$field_name=$result[$field_name];
+ }
+ return $obj;
+ }
+ function Update($object)
+ {
+ $class = get_class($object);
+ $reflection = new ReflectionClass($class);
+ $data=array();
+ $con = new MysqlConnection($object->db);
+ foreach( $reflection -> getProperties(ReflectionProperty::IS_PRIVATE) as $field )
+ {
+ $field_name = $field->name;
+ $field_val=$object->$field_name;
+ if($object->$field_name!="")
+ {
+ $data[$field_name]=$field_val;
+ }
+ }
+ $rowData= array("table"=>$class,"data"=>$data,"condition"=>array("id"=>$object->id));
+ $con->update($rowData);
+
+ }
+}
+
+
+?>
\ No newline at end of file
diff --git a/lib/config.php b/lib/config.php
new file mode 100644
index 0000000..9ed3742
--- /dev/null
+++ b/lib/config.php
@@ -0,0 +1,720 @@
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ }
+ catch (PDOException $e)
+ {
+ print "Error!: " . $e->getMessage() . " ";
+ die();
+ }
+ return $con;
+
+ }
+}
+class MysqlConnection
+{
+ private $db;
+ function __construct($db="maindb")
+ {
+ $this->db=$db;
+ }
+
+ public function fetchAll($query)
+ {
+ $dbObj = new sys_config();
+ $connectionObj = $dbObj->getConnection($this->db);
+ $result = mysqli_query($connectionObj,$query);
+ $data_array = array();
+ while ($array = mysqli_fetch_assoc($result))
+ {
+ $data_array[] = $array;
+ }
+ return $data_array;
+ }
+ public function insert($data)
+ {
+
+ $dbObj = new sys_config();
+ $connectionObj = $dbObj->getConnection($this->db);
+ $table=$data['table'];
+ $prep = array();
+ foreach($data['data'] as $k => $v )
+ {
+ $prep[':'.$k] = $v;
+ }
+ $query = $connectionObj->prepare("INSERT INTO $table ( " . implode(', ',array_keys($data['data'])) . ") VALUES (" . implode(', ',array_keys($prep)) . ")");
+ $query->execute($prep);
+ }
+ public function select($data)
+ {
+ $dbObj = new sys_config();
+ $connectionObj = $dbObj->getConnection($this->db);
+ $table=$data['table'];
+ $prep = array();
+ $where=array();
+ foreach($data['condition'] as $k => $v )
+ {
+ $prep[':'.$k] = $v;
+ $where[] = $k."=".":".$k;
+ }
+ if(count($data['condition'])>0)
+ $query = $connectionObj->prepare("SELECT * FROM $table WHERE " . implode(' AND ',array_values($where)) );
+ else
+ $query = $connectionObj->prepare("SELECT * FROM $table " );
+ $query->execute($prep);
+ $res=$query->fetchAll(PDO::FETCH_ASSOC);
+
+ return $res;
+ }
+ public function delete($data)
+ {
+ $dbObj = new sys_config();
+ $connectionObj = $dbObj->getConnection($this->db);
+ $table=$data['table'];
+ $where=array();
+ foreach($data['condition'] as $k => $v )
+ {
+ $prep[':'.$k] = $v;
+ $where[] = $k."=".":".$k;
+ }
+ $query = $connectionObj->prepare("SELECT * FROM $table WHERE " . implode(' AND ',array_values($where)) );
+ $query->execute($prep);
+ $res=$query->fetch(PDO::FETCH_ASSOC);
+ $query = $connectionObj->prepare("DELETE FROM $table WHERE " . implode(' AND ',array_values($where)) );
+ $query->execute($prep);
+ return $res;
+ }
+ public function update($udata)
+ {
+ $dbObj = new sys_config();
+ $connectionObj = $dbObj->getConnection($this->db);
+ $table=$udata['table'];
+ $cond=array();
+ $data=array();
+ foreach($udata['data'] as $k => $v )
+ {
+ $prep[':data'.$k] = $v;
+ $data[] = $k."=".":data".$k;
+ }
+ foreach($udata['condition'] as $k => $v )
+ {
+ $prep[':cond'.$k] = $v;
+ $cond[] = $k."=".":cond".$k;
+ }
+ $query = $connectionObj->prepare("UPDATE $table SET " . implode(',',array_values($data))." WHERE ".implode(' AND ', array_values($cond)) );
+ $query->execute($prep);
+ }
+}
+class Layout
+{
+ private $controllerObj;
+ private $layoutPath;
+ private $lcontroller;
+ private $layoutName;
+ private $layout;
+ private $meta;
+ private $headers;
+ private $view;
+ private $head;
+ private $js;
+ private $css;
+ private $title;
+ public function __construct($cObj,$layoutName)
+ {
+ $this->head=array();
+ $this->js=array();
+ $this->css=array();
+ $this->meta=array();
+ $this->headers=array();
+ $this->controllerObj=$cObj;
+ $this->layoutPath=$layoutName;
+ $host=$GLOBALS['host'];
+ $cpath=$_SERVER['DOCUMENT_ROOT']."/".$host."/layouts/controllers/".$cObj->layout."layoutController.php";
+ $this->title=$this->controllerObj->title;
+ if(file_exists($cpath))
+ {
+ include $cpath;
+ $layoutControllerName=$cObj->layout."layoutController";
+ if(class_exists($layoutControllerName))
+ {
+ $this->lcontroller=new $layoutControllerName();
+ }
+ else
+ {
+ trigger_error($cObj->layout."layoutController Class does't exists.");
+ }
+ }
+ else
+ {
+ //trigger_error($cObj->layout."layoutController is not defined.",E_USER_WARNING);
+ }
+ if($this->controllerObj->viewRequired) // update : view is not included by default , call view() to include
+ {
+
+ if(file_exists($_SERVER['DOCUMENT_ROOT']."/".$host."/modules/".$GLOBALS['forkobj']['module']."/views/".$GLOBALS['forkobj']['controller']."/".$GLOBALS['forkobj']['action'].".phtml"))
+ {
+ ob_start();
+ $lay = include $this->layoutPath;
+
+ $buffer =ob_get_clean();
+ $html = "\n\n";
+ $html .="\n";
+ $html .="".$this->title." \n";
+ $html .=$this->getHeaders()."\n";
+ $html .=$this->headFiles($this->css,$this->js)."\n";
+ $html .="\n\n";
+ echo $html;
+ echo $buffer;
+ echo "\n";
+ //$path=$_SERVER['DOCUMENT_ROOT']."/".$host."/modules/".$GLOBALS['forkobj']['module']."/views/".$GLOBALS['forkobj']['controller']."/".$GLOBALS['forkobj']['action'].".phtml";
+ //create view
+ //$view = new View($this->controllerObj,$path);
+
+ }
+ else
+ {
+
+ $errorObj= new Exceptions("1004",array("module"=>$GLOBALS['forkobj']['module'],"controller"=>$GLOBALS['forkobj']['controller'],"action"=>$GLOBALS['forkobj']['action']));
+ return $errorObj->throwException();// missing view
+ }
+ }
+ else
+ {
+ ob_start();
+ $lay = include $this->layoutPath;
+
+ $buffer =ob_get_clean();
+ $html = "\n";
+ $html .="\n";
+ $html .="".$this->title." \n";
+ $html .=$this->getHeaders()."\n";
+ $html .=$this->headFiles($this->css,$this->js)."\n";
+ $html .="\n\n";
+ echo $html;
+ echo $buffer;
+ echo "\n