Permalink
Browse files

bugs fixes

  • Loading branch information...
Greg0 committed Feb 16, 2013
0 parents commit 1b6e10cadb3cc252d6ee051ba01036d0e0e450ea
No changes.
@@ -0,0 +1 @@
[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"},{"pozdro":"asd","pa":"345"}]
@@ -0,0 +1,13 @@
<?php
define('JSONDB', 1);
function __autoload($class)
{
if (file_exists('includes/'.$class.'.class.php'))
{
require_once 'includes/'.$class.'.class.php';
}
}
?>
@@ -0,0 +1,36 @@
<?php
defined('JSONDB') or die('Permission denied!');
/**
* Core class of JSONDB project
*
* @author Grzegorz Kuźnik
* @copyright (c) 2013, Grzegorz Kuźnik
*/
abstract class Core {
public $data;
public $name;
protected $set;
public function __set($name, $value)
{
$this->set->{$name} = $value;
}
public function save()
{
array_push($this->data, $this->set);
File::put($this->name, json_encode($this->data));
}
public function find_all()
{
return $this->data;
}
}
?>
@@ -0,0 +1,25 @@
<?php
defined('JSONDB') or die('Permission denied!');
/**
* File managing class of JSONDB project
*
* @author Grzegorz Kuźnik
* @copyright (c) 2013, Grzegorz Kuźnik
*/
class File {
public static function get($name, $type='data')
{
return file_get_contents(JSONDB_DATA_PATH.$name.'.'.$type.'.json');
}
public static function put($name, $data, $type='data')
{
return file_put_contents(JSONDB_DATA_PATH.$name.'.'.$type.'.json', $data);
}
}
?>
@@ -0,0 +1,16 @@
<?php
class JDBException extends Exception {
public function __construct($message, $code=0)
{
parent::__construct($message,$code);
}
public function __toString()
{
return $this->message;
}
}
?>
@@ -0,0 +1,33 @@
<?php
defined('JSONDB') or die('Permission denied!');
/**
* Core class of JSONDB project
*
* @author Grzegorz Kuźnik
* @copyright (c) 2013, Grzegorz Kuźnik
*/
class Jsondb extends Core {
public static function factory($name)
{
$self = new Jsondb;
$self->name = $name;
try {
if (!file_exists(JSONDB_DATA_PATH.$self->name.'.data.json'))
throw new JDBException('Failed to load data file');
$self->data = json_decode(File::get($self->name));
}
catch (JDBException $exc) {
echo $exc;
}
return $self;
}
}
?>
@@ -0,0 +1,15 @@
<?php
require_once 'includes/config.php';
define('JSONDB_DATA_PATH', realpath(dirname(__FILE__)).'/data/');
$users = Jsondb::factory('users');
$users->pozdro = 'asd';
$users->pa = '345';
$users->save();
var_dump($users);
?>
@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_54
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=true
web.root=.
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>JSONDB</name>
</data>
</configuration>
</project>

0 comments on commit 1b6e10c

Please sign in to comment.