docu
This commit is contained in:
parent
18a6cd5cdf
commit
7e23259aa7
@ -1,5 +1,32 @@
|
|||||||
system
|
SYSTEM
|
||||||
======
|
======
|
||||||
System - PHP Framework
|
SYSTEM - PHP Framework
|
||||||
|
|
||||||
Licensed under MIT
|
Licensed under MIT
|
||||||
|
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Description
|
||||||
|
-----------
|
||||||
|
|
||||||
|
SYSTEM is a PHP Lightweight Framework.
|
||||||
|
|
||||||
|
You can obtain a copy from <https://github.com/gebhardtdasense/system/>
|
||||||
|
|
||||||
|
SYSTEM provides several management techiques and general purpose funcionality
|
||||||
|
for a PHP Environment. All features of system are optional for using, altho
|
||||||
|
might be dependent on other features or standarts SYSTEM provides.
|
||||||
|
|
||||||
|
Following funcionality is provided by SYSTEM:
|
||||||
|
|
||||||
|
* api - php post/get input validation and handling
|
||||||
|
* cache - cache using the database as storage for images/other data
|
||||||
|
* config - configuration of a SYSTEM environment, can be extended for project purposes
|
||||||
|
* db - database connection, query and prepare functionality, supporting MYSQL and POSTGRESQL, QQ
|
||||||
|
* docu - register documentation right were it is - show it in the backend
|
||||||
|
* files - file management & external access api
|
||||||
|
* log - exceptionhandling - including dbwrite options
|
||||||
|
* page - html page generation scheme
|
||||||
|
* sai - Admininterface
|
||||||
|
* security - Userlogin, register, rights, (email), session management
|
||||||
|
* system - autoload, database texts, path generation, systemconfig, time
|
||||||
@ -1,6 +1,6 @@
|
|||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
Copyright (c) 2013 TU-Darmstadt, Ulf Gebhardt
|
Copyright (c) 2014 Ulf Gebhardt
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@ -1,27 +1,6 @@
|
|||||||
##Getting started
|
##Getting started
|
||||||
|
|
||||||
SYSTEM is a PHP Lightweight Framework.
|
This is an introduction how to setup a webpage with system
|
||||||
|
|
||||||
You can obtain a copy from https://github.com/gebhardtdasense/system/
|
|
||||||
|
|
||||||
SYSTEM provides several management techiques and general purpose funcionality
|
|
||||||
for a PHP Environment. All features of system are optional for using, altho
|
|
||||||
might be dependent on other features or standarts SYSTEM provides.
|
|
||||||
|
|
||||||
Following funcionality is provided by SYSTEM:
|
|
||||||
|
|
||||||
* api - php post/get input validation and handling
|
|
||||||
* cache - cache using the database as storage for images/other data
|
|
||||||
* config - configuration of a SYSTEM environment, can be extended for
|
|
||||||
project purposes
|
|
||||||
* db - database connection, query and prepare functionality,
|
|
||||||
supporting MYSQL and POSTGRESQL
|
|
||||||
* docu - register documentation right were it is - show it in the backend
|
|
||||||
* log - exceptionhandling - including dbwrite options
|
|
||||||
* page - html page generation scheme
|
|
||||||
* sai - Admininterface
|
|
||||||
* security - Userlogin, register, rights, (email), session management
|
|
||||||
* system - autoload, database texts, path generation, systemconfig, time
|
|
||||||
|
|
||||||
##Setup
|
##Setup
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,69 @@
|
|||||||
|
SYSTEM API
|
||||||
|
----------
|
||||||
|
|
||||||
|
The SYSTEM-Api allows you to validate post/get/jsonpost parameters to function-calls.
|
||||||
|
This allows you to direct calls to your website to a class which can process those
|
||||||
|
calls in a typesave maner.
|
||||||
|
|
||||||
|
WARNING: This Method breaks inheritance in some use-cases!
|
||||||
|
|
||||||
|
How it Works
|
||||||
|
------------
|
||||||
|
|
||||||
|
Mapping of URLs to Functions -> thats it basicly
|
||||||
|
|
||||||
|
The URL
|
||||||
|
|
||||||
|
http://mypage.net/api.php?call=test&action=bla¶m1=1¶m2=abc
|
||||||
|
|
||||||
|
maps to
|
||||||
|
|
||||||
|
public static function call_test_action_bla($param1,$param2){}
|
||||||
|
|
||||||
|
if you set your database properly:
|
||||||
|
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1, 0, 0, -1, NULL, 'call', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (2, 0, 0, 1, 'test', 'action', NULL);
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (3, 0, 2, 2, 'bla', 'param1', 'UINT');
|
||||||
|
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (4, 0, 2, 2, 'bla', 'param2', 'STRING');
|
||||||
|
|
||||||
|
(note that the params are on the same level of the tree)
|
||||||
|
now you just need a php class with your function
|
||||||
|
|
||||||
|
<?php
|
||||||
|
class my_api {
|
||||||
|
public static function call_test_action_bla($param1,$param2){}
|
||||||
|
}
|
||||||
|
|
||||||
|
and an endpoint
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once '../system/autoload.inc.php'; //SYSTEM Classes
|
||||||
|
require_once 'myproject/autoload.inc.php'; //Project Classes
|
||||||
|
|
||||||
|
require_once 'config.php';
|
||||||
|
SYSTEM\system::start($myproject_config);
|
||||||
|
\SYSTEM\system::include_ExceptionShortcut();
|
||||||
|
\SYSTEM\system::include_ResultShortcut();
|
||||||
|
\SYSTEM\system::register_errorhandler_dbwriter();
|
||||||
|
\SYSTEM\system::register_errorhandler_jsonoutput();
|
||||||
|
|
||||||
|
echo \SYSTEM\API\api::run('\SYSTEM\API\verify','my_api',array_merge($_POST,$_GET));
|
||||||
|
new \SYSTEM\LOG\COUNTER("API was called sucessfully.");
|
||||||
|
|
||||||
|
check out the important line - note the use of the standartverifier - inherit it to make more verifiers available.
|
||||||
|
|
||||||
|
echo \SYSTEM\API\api::run('\SYSTEM\API\verify','my_api',array_merge($_POST,$_GET));
|
||||||
|
|
||||||
|
To enable jsonpost use this in your endpoint:
|
||||||
|
|
||||||
|
//Direct JSON Input
|
||||||
|
$json = json_decode(file_get_contents("php://input"), true);
|
||||||
|
if(!$json){
|
||||||
|
$json = array_merge($_POST,$_GET);}
|
||||||
|
|
||||||
|
//Construct the api with the dasense specific ApiVerfy Class verify_dasense and the call handler for da-sense api-calls api_dasense
|
||||||
|
//the class api_dasense contains all stuff you would seek in the index -> look there
|
||||||
|
echo \SYSTEM\API\api::run('my_verify', 'api_dasense',$json, 25);
|
||||||
|
|
||||||
|
note the use of api group 25 - this allows you to construct several apis.
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
cache
|
||||||
|
-----
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
config
|
||||||
|
------
|
||||||
76
docu/system/system.db.qq.md
Normal file
76
docu/system/system.db.qq.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
QQ Objects
|
||||||
|
----------
|
||||||
|
|
||||||
|
Referenz: <https://github.com/ulfgebhardt/system/tree/master/db/qq>
|
||||||
|
|
||||||
|
QQ-Objekte können von zwei verschiedenen Klassen erben:
|
||||||
|
|
||||||
|
- QQ (quick query)
|
||||||
|
- QP (quick prepare)
|
||||||
|
|
||||||
|
Class Definitions:
|
||||||
|
|
||||||
|
class MY_QUERY_QQ extends \SYSTEM\DB\QQ {}
|
||||||
|
class MY_QUERY_QP extends \SYSTEM\DB\QP {}
|
||||||
|
|
||||||
|
|
||||||
|
Je nachdem was du benutzt kannst du in deinem SQL String $1,$2,$3...
|
||||||
|
benutzen oder nicht (prepare hat $1..., query hat das nicht).
|
||||||
|
Folglich mache alle Querys ohne Paramter als QQ, alle mit als QP Klasse!
|
||||||
|
|
||||||
|
Der Unterschied der Klassen ist einfach, dass bei allen Funktionen von QP
|
||||||
|
ein array mit den Parametern übergeben werden muss.
|
||||||
|
|
||||||
|
Es gibt 4 Funktionen
|
||||||
|
|
||||||
|
- QQ (selber über die daten loopen)
|
||||||
|
- Q1 (geb mir genau eine zeile)
|
||||||
|
- QA (geb mir alle Zeilen)
|
||||||
|
- QI (Insert/Delete... -> returns true)
|
||||||
|
|
||||||
|
Q1
|
||||||
|
--
|
||||||
|
|
||||||
|
MY_QUERY_QQ::Q1()
|
||||||
|
-> array(feld1 => value, feld2 => value...)
|
||||||
|
|
||||||
|
MY_QUERY_QP::Q1(array(param1,param2,...))
|
||||||
|
-> array(feld1 => value, feld2 => value...)
|
||||||
|
|
||||||
|
QA
|
||||||
|
--
|
||||||
|
|
||||||
|
MY_QUERY_QQ::QA()
|
||||||
|
-> array(array(feld1 => value, feld2 => value...), array(feld1 => ...))
|
||||||
|
MY_QUERY_QP::QA(array(param1,param2,...))
|
||||||
|
-> array(array(feld1 => value, feld2 => value...), array(feld1 => ...))
|
||||||
|
|
||||||
|
QI
|
||||||
|
--
|
||||||
|
|
||||||
|
MY_QUERY_QQ::QI()
|
||||||
|
-> true/false
|
||||||
|
MY_QUERY_QP::QI(array(param1,param2,...))
|
||||||
|
-> true/false
|
||||||
|
|
||||||
|
QQ
|
||||||
|
--
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
$rows = MY_QUERY_QQ::QQ();
|
||||||
|
while($row = $rows->next()){ //1. über alle loopen
|
||||||
|
$row[field1] = 5;
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
-> QQ Benutzen, um das Datenbank Ergebnis auszuschmücken ohne zweimal über
|
||||||
|
das ergebniss zu loopen:
|
||||||
|
|
||||||
|
Wrong
|
||||||
|
-----
|
||||||
|
$result = array();
|
||||||
|
$rows = MY_QUERY_QQ::QA(); // 1. über alle loppen
|
||||||
|
foreach($rows as $row){ // 2. über alle loopen
|
||||||
|
$row[field1] = 5;
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SYSTEM\SECURITY;
|
namespace SYSTEM\SECURITY;
|
||||||
|
|
||||||
class RIGHTS {
|
class RIGHTS {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user