コード例 #1
0
<?php

gen_load_comment('class.helper.Util');
class Util
{
    static function isal_num($var)
    {
        return preg_match("/^[0-9]+\$/", $var);
    }
    static function isaemail($var)
    {
        return preg_match("/^[a-zA-Z0-9_\\.\\+]+@[a-zA-Z0-9\\.-]+\\.[a-zA-Z]{2,6}\$/", $var);
    }
    static function define_name($name, $value)
    {
        define($name, $value);
    }
    /**
     * generates a simple log for allowing any applications to have their own logging without 
     * object overhead
     * 
     * @param string $title
     * @param string $msg
     * @param bool $output
     * 		if set and set to true will produce an array for useful purposes
     * @return mixed
     * 		if $output = true returns array else bool true
     */
    static function gen_log($title, $msg, $output = false)
    {
        static $log;
コード例 #2
0
<?php

gen_load_comment('scheme.table.links');
class Lnk_Schm
{
    public $lid;
    public $uid;
    public $cid;
    public $title;
    public $content;
    const tbl = "link";
}
class Lnk_tags
{
    public $tid;
    public $lid;
    public $valu;
    const tbl = "link_tags";
}
class Lnk_cat
{
    public $cid;
    public $title;
    const tbl = "link_cat";
}
class Lnk_visits
{
    public $id;
    public $lid;
    public $counter;
    const tbl = "link_visits";
コード例 #3
0
<?php

gen_load_comment('class.helper.Paginate');
/**
 * paginate class is designed to build a list of anchor links based on several parameters
 *
 */
class Paginate
{
    /**
     * _filename is a string for associating the paginated 
     * links to when the link is clicked it goes to this string.
     * 
     */
    private $_filename;
    /**
     * _bond_to is a unique string id  associated with a get variable which will be associated 
     * when a page changes numbers to inform the class, also for get query appendage on 
     * paginated string generation.
     * 
     */
    private $_bond_to;
    /**
     * _page_num is an integer which allows the class to perform a specific action based on it's value.
     * 
     */
    private $_page_num;
    /**
     * _total is an integer value which is used to calculate the number of links associated with the pagination.
     */
    private $_total;
コード例 #4
0
<?php

gen_load_comment('class.model.Control_Users');
class Control_Links extends Model_Links
{
    private $get;
    function __construct($get)
    {
        gen_time('Controllers/Control_Links');
        $this->get = $get;
        parent::__construct();
        $this->index();
    }
    function __destruct()
    {
        gen_time('Controllers/Control_Links');
        parent::__destruct();
    }
    public function test()
    {
    }
    public function index()
    {
        if (SYSDEBUG) {
            echo $this->outputLogHTML();
        }
    }
}
コード例 #5
0
<?php

gen_load_comment('class.helper.Log');
/**
 * Log allows all objects associated with it to share a common interface
 * 
 */
class Log
{
    /**
     * globally shared static among all users of object
     * 
     * @staticvar array $log
     */
    private static $log = array();
    public function __construct($Title = null, $Message = null, $extra = null)
    {
        if (!is_null($Title) && !is_null($Message)) {
            $this->addLogEvent($Title, $Message, $extra);
        }
        gen_time('class/Log');
    }
    public function __destruct()
    {
        gen_time('class/Log');
    }
    /**
     * msg returns simple messages for confirmation debug purposes
     * 
     * @return array
     */
コード例 #6
0
<?php

gen_load_comment('class.model.Model_Posts');
/**
 * Users_Model is designed to aquire or diseminate 
 * all important information to database pertaning 
 * to posts
 * 
 */
class Model_Posts extends DB implements Record
{
    public function __construct()
    {
        gen_time('class/Model_Posts');
        parent::__construct();
    }
    public function __destruct()
    {
        gen_time('class/Model_Posts');
        parent::__destruct();
    }
    public function validate($name, $value)
    {
    }
    public function add_validate(Usr_Schm $rec)
    {
    }
    public function add(Usr_Schm $rec)
    {
    }
    private function edit_util($name, $value)
コード例 #7
0
<?php

gen_load_comment('scheme.table.users');
class Usr_Schm
{
    const uid = 'int';
    const username = '******';
    const password = '******';
    const alias = 'alphanum';
    const email = 'email';
    const active = 'int';
    public $uid = null;
    public $username = null;
    public $password = null;
    public $alias = null;
    public $email = null;
    public $active = null;
    public $activate_key = null;
    const tbl = "user";
    const check = true;
}
class Usrnfo_Schm
{
    public $uid = null;
    public $url = null;
    public $im = null;
    public $name = null;
    const tbl = "user_info";
    const check = false;
}
class Usercat_Schm
コード例 #8
0
<?php

gen_load_comment('class.helper.DB');
/**
 * DB class establises a database connection using 
 * the PDO library and places that connection into 
 * a protected property 
 * 
 */
class DB extends Log
{
    const dbtype = 'mysql';
    const host = 'localhost';
    const dbname = 'code_test';
    const user = '******';
    const password = '******';
    /**
     * Shared common var among all chaning classes to provide consistent access to database during instantiation
     * 
     */
    protected $db;
    /**
     * Static variable only initialized ones in the live of any object intantiating or extending the current class
     * 
     */
    private static $_db = null;
    public function __construct()
    {
        gen_time('class/DB');
        $this->makeConnection();
        parent::__construct();
コード例 #9
0
<?php

gen_load_comment('interface.Record');
/**
 * Record is an abstract class / interface to be 
 * implemented by another class for Model purposes
 * 
 */
interface Record
{
    public function add(Usr_Schm $rec);
    public function edit($id = null, Usr_Schm $usr = null, Usrnfo_Schm $nfo = null);
    public function delete($id = null);
    public function validate($name, $value);
    public function getRecords($limit = null, $offset = null);
    public function getRecord($id = null);
    public function getRecordCount();
}
コード例 #10
0
<?php

gen_load_comment('class.helper.UrlTranslator');
/**
 * Rewrite urls for REST Style services such as
 * /domain.com/controller/var1/val1/var2/val2
 * /domain.com/controller/view/val
 *
 */
class UrlTranslator extends Log
{
    private $args;
    private $rules;
    public function __construct($var)
    {
        gen_time('class/UrlTranslator');
        parent::__construct();
        $this->rules = $var;
        $this->args = self::rest_url_translator();
    }
    public function __destruct()
    {
        gen_time('class/UrlTranslator');
        parent::__destruct();
    }
    /**
     * validate make sure data integrity is met when 
     * allowing users to input information via url query
     * errors on non-validation
     * 
     * @param string $type
コード例 #11
0
<?php

gen_load_comment('scheme.table.posts');
class Pst_Schm
{
    public $pid;
    public $uid;
    public $cid;
    public $title;
    public $content;
    const tbl = "post";
}
class Pst_tags
{
    public $tid;
    public $pid;
    public $valu;
    const tbl = "post_tags";
}
class Pst_cat
{
    public $cid;
    public $title;
    const tbl = "post_cat";
}
class Pst_visits
{
    public $id;
    public $pid;
    public $counter;
    const tbl = "post_visits";
コード例 #12
0
<?php

gen_load_comment('class.model.Model_Users_Category');
/**
 * Users_Model is designed to aquire or diseminate 
 * all important information to database pertaning 
 * to the user
 * 
 */
class Model_Users_Category extends DB implements Record
{
    public function __construct()
    {
        gen_time('class/Model_Users_Category');
        parent::__construct();
    }
    public function __destruct()
    {
        gen_time('class/Model_Users_Cateory');
        parent::__destruct();
    }
    public function add($title)
    {
        $usr_cat_tbl = Usercat_Schm::tbl;
        $sql1 = "INSERT INTO {$usr_cat_tbl} (title) VALUES ('{$title}');";
        $this->addLogEvent('sql', $sql1);
        $stmt1 = $this->db->prepare($sql1);
        $stmt1->execute();
    }
    public function edit($id)
    {
コード例 #13
0
<?php

gen_load_comment('class.model.Model_Registration');
class Model_Registration extends Model_Users
{
    const RegisterFieldError = 1;
    const RegisterEmailExists = 2;
    const RegisterSuccess = 3;
    const RegisterPasswdResetFieldError = 1;
    const RegisterPasswdResetEmailnotExist = 2;
    const RegisterPasswdResetSuccess = 3;
    function __construct()
    {
        gen_time('class/Model_Posts');
        parent::__construct();
    }
    function __destruct()
    {
        gen_time('class/Model_Posts');
        parent::__destruct();
    }
    function checkEmailExistance(Usr_Schm $usr)
    {
        $sql = "SELECT count(u.uid) as count FROM " . Usr_Schm::tbl . " u WHERE u.email='{$usr->email}'";
        $this->addLogEvent('sql', $sql);
        $stmt1 = $this->db->prepare($sql);
        $stmt1->execute();
        $results = $stmt1->fetch(PDO::FETCH_ASSOC);
        return $results['count'];
    }
    function register(Usr_Schm $usr)
コード例 #14
0
<?php

gen_load_comment('class.model.Model_Users');
/**
 * Users_Model is designed to aquire or diseminate 
 * all important information to database pertaning 
 * to the user
 * 
 */
class Model_Users extends DB implements Record
{
    public function __construct()
    {
        gen_time('class/Model_Users');
        parent::__construct();
    }
    public function __destruct()
    {
        gen_time('class/Model_Users');
        parent::__destruct();
    }
    /**
     * Validates the type content based on the name param
     *
     * @param string $name
     * @param mixed $value
     * 		might have int or string value
     * @return bool
     */
    public function validate($name, $value)
    {
コード例 #15
0
<?php

gen_load_comment('class.model.Model_Links');
/**
 * Users_Model is designed to aquire or diseminate 
 * all important information to database pertaning 
 * to the user
 * 
 */
class Model_Links extends DB implements Record
{
    public function __construct()
    {
        gen_time('class/Model_Links');
        parent::__construct();
    }
    public function __destruct()
    {
        gen_time('class/Model_Links');
        parent::__destruct();
    }
    public function validate($name, $value)
    {
    }
    public function add_validate(Usr_Schm $rec)
    {
    }
    public function add(Usr_Schm $rec)
    {
    }
    private function edit_util($name, $value)