https://community.kde.org/api.php?action=feedcontributions&user=Snizzo&feedformat=atomKDE Community Wiki - User contributions [en]2024-03-29T13:50:43ZUser contributionsMediaWiki 1.40.2https://community.kde.org/index.php?title=Ocs-server/Gfx4/XML_utilities&diff=72113Ocs-server/Gfx4/XML utilities2016-06-06T15:38:49Z<p>Snizzo: </p>
<hr />
<div>Gfx contains some XML utilities.<br />
<br />
* '''static bool EXMLParser::is_assoc($array)''' -> checks if $array is associative or not<br />
* '''static array EXMLParser::to_array($contents, $force_multiple=array())''' -> converts an xml tree to an associative array</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Paginator&diff=71986Ocs-server/Gfx4/Paginator2016-05-23T11:26:58Z<p>Snizzo: Created page with "Gfx provides a nice class for paginating results from a database. This is useful when we want to show our users results in multiple pages. '''It currently works with Bootstrap..."</p>
<hr />
<div>Gfx provides a nice class for paginating results from a database. This is useful when we want to show our users results in multiple pages. '''It currently works with Bootstrap classes.'''<br />
<br />
Brief example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$jobs = new EModel('gfx_jobs');<br />
$jobs->add_condition('person='.EUser::id());<br />
<br />
$paginator = new EPaginator($jobs);<br />
<br />
$results = $paginator->get_results();<br />
<br />
var_dump($results); //echoing results<br />
<br />
echo $paginator->get_links(); //printing paginator<br />
?><br />
</syntaxhighlight><br />
<br />
'''Note: it's currently indipendent from database implementation as long as there's a working EModel driver.'''</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=71985Ocs-server/Gfx42016-05-23T11:21:53Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Editing config files programmatically | Editing config files programmatically]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/User management | User management]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/Paginator | Paginator]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [[Ocs-server/Gfx4/Utilities | Utilities]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Models&diff=71981Ocs-server/Gfx4/Models2016-05-23T10:33:30Z<p>Snizzo: </p>
<hr />
<div>The '''EModel''' class contains various facilities for querying databases and performing standard tasks like SELECT, INSERT, UPDATE and DELETE. So, for example, if you're writing a class that interfaces with the "posts" class in your database, you should create a file name "posts.model.php" in the "model" directory. GFX already knows that there are models there.<br />
This is a convention when creating models directly binded to a database table but feel free to create models with custom names. There is no particular restriction on Model's use.<br />
<br />
Every model should be name following this syntax <tablename>.model.php in order to be automatically loaded by gfx as a model. Then you can write your code that basically queries the database and returns the correct data, along with all manipulations done.<br />
<br />
Think of a Model of an object that has to return data that should already human understandable if seen raw.<br />
<br />
This is an example of a basic model class:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
class ArticlesModel extends EModel<br />
{<br />
public function __construct()<br />
{<br />
parent::__construct("articles");<br />
}<br />
<br />
public function getAll()<br />
{<br />
$data = $this->find("*");<br />
return $data;<br />
}<br />
}<br />
?><br />
</syntaxhighlight><br />
------------------<br />
EModel works with conditions that stays still after a query has been executed.<br />
<br />
* '''EModel::add_condition($c);''' //example: $model->add_condition('a=1'); $model->find('*');<br />
* '''EModel::clear_conditions();''' //example: $model->clear_conditions();<br />
* '''EModel::set_limit($limit);''' //$limit being an integer<br />
* '''EModel::clear_limit();'''<br />
* '''EModel::set_ascending();'''<br />
* '''EModel::set_descending();'''<br />
* '''EModel::order_by($field=array());''' //example: $model->order_by(array('id','name');<br />
* '''EModel::clear_ordering();'''<br />
------------------<br />
EModel class wraps many of the operations that can be made to a database. Here is a list of the most useful methods of EModel:<br />
* '''EModel::fields()''':<br />
Returns all fields contained in table structure<br />
----------<br />
* '''EModel::insert($fields=array())''':<br />
Being $field and associative array $key => $value with the correct data.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
//let's assume the page will receive 2 GET parameters, one with key 'name' and one with key 'password'<br />
$name = EHeader::db_get('name');<br />
$password = EHeader::db_get('password');<br />
<br />
$e = new EModel('users'); //'users' is the name of the table that contains a column called 'name' and one called 'password'<br />
$e->insert(array('name' => $name, 'password' => $password));<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::count($fields=array())''':<br />
Performs a '''COUNT()''' of a '''SELECT''' query. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->count('name', 'where password=$password');<br />
//$result contains exactly the number of rows returned, it beings of course an integer<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::is_there($fields=array())''':<br />
Checks if a query returns more than a row and returns '''true''' or '''false'''. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->is_there('name', 'where password=$password');<br />
//$result contains true or false, whether the query result has at least one row or not<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::delete()''':<br />
Wraps a DELETE query and deletes rows following $where conditions to be put at the end of the query. $howmany is used to put a limit to the rows being deleted.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->delete('password=$password', 1);<br />
//this time the '''WHERE''' statement hasn't to be manually added to the $where parameter<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::update($fields=array())''':<br />
The same as EModel::insert(), just for updating fields. For security reasons is good practice to specify $allowed_fields() with only allowed fields.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->update('password=$password', array('name'));<br />
//only name will be updated, even if password is defined<br />
}<br />
?><br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/get_post_headers&diff=71975Ocs-server/Gfx4/get post headers2016-05-23T10:24:07Z<p>Snizzo: </p>
<hr />
<div>GFX provides a class that automatically handles and parse GET and POST data.<br />
So instead of directly accessing those arrays you should use EHeader.<br />
----------<br />
If you have to output your data you can use:<br />
<br />
'''EHeader::out_get(string $name);'''<br><br />
'''EHeader::out_post(string $name);'''<br><br />
-----------------<br />
If you have to insert your data into database and you need them to be safe you can use:<br />
<br />
'''EHeader::db_get(string $name);'''<br><br />
'''EHeader::db_post(string $name);'''<br><br />
<br />
These are now obsolete:<br><br />
'''EHeader::secure_get(string $name);'''<br><br />
'''EHeader::secure_post(string $name);'''<br><br />
------------------<br />
If you need all your data to be safe you can easily do:<br />
<br />
'''EHeader::safeAll();'''<br />
------------------<br />
You can also set GET and POST manually using:<br />
<br />
'''EHeader::add_get(string $key, string $value);'''<br><br />
'''EHeader::add_post(string $key, string $value);'''<br><br />
--------------<br />
You can check existance of GET and POST manually using:<br />
<br />
'''EHeader::exists_get(string $key);'''<br><br />
'''EHeader::exists_post(string $key);'''<br><br />
--------------<br />
You can use this class to get/set cookie data via:<br />
<br />
'''EHeader::get_cookie(string $key);'''<br><br />
'''EHeader::set_cookie(string $key, $value);'''<br><br />
'''EHeader::del_cookie(string $key);'''<br><br />
<br />
This can result particularly useful when you need to use EModel's insert and update<br />
but not all the data comes from user request.<br />
----------------<br />
If you want to take those variables fast and you can't decide you can choose<br />
the unsafe way using:<br />
<br />
'''EHeader::get(string $key);'''<br><br />
'''EHeader::post(string $key);'''<br><br />
----------------<br />
If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2)<br />
you can use this handy method to have that added to the module's stack.<br />
<br><br />
'''EHeader::add_from_string(string $str);'''<br />
----------------<br />
You can get the script page with all exta data(''&data=example?...'') erased by using:<br />
<br><br />
'''EHeader::erase_get_data(string $url);'''<br />
-----------------<br />
EHeader can be configure in the generic config file of gfx, which can be located<br />
here: ''gfx3/config/generic.conf.php''.<br />
<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
protectheaders|yes<br />
protectheaders|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/get_post_headers&diff=71974Ocs-server/Gfx4/get post headers2016-05-23T10:23:55Z<p>Snizzo: </p>
<hr />
<div>GFX provides a class that automatically handles and parse GET and POST data.<br />
So instead of directly accessing those arrays you should use EHeader.<br />
----------<br />
If you have to output your data you can use:<br />
<br />
'''EHeader::out_get(string $name);'''<br><br />
'''EHeader::out_post(string $name);'''<br><br />
-----------------<br />
If you have to insert your data into database and you need them to be safe you can use:<br />
<br />
'''EHeader::db_get(string $name);'''<br><br />
'''EHeader::db_post(string $name);'''<br><br />
<br />
These are now obsolete:<br />
'''EHeader::secure_get(string $name);'''<br><br />
'''EHeader::secure_post(string $name);'''<br><br />
------------------<br />
If you need all your data to be safe you can easily do:<br />
<br />
'''EHeader::safeAll();'''<br />
------------------<br />
You can also set GET and POST manually using:<br />
<br />
'''EHeader::add_get(string $key, string $value);'''<br><br />
'''EHeader::add_post(string $key, string $value);'''<br><br />
--------------<br />
You can check existance of GET and POST manually using:<br />
<br />
'''EHeader::exists_get(string $key);'''<br><br />
'''EHeader::exists_post(string $key);'''<br><br />
--------------<br />
You can use this class to get/set cookie data via:<br />
<br />
'''EHeader::get_cookie(string $key);'''<br><br />
'''EHeader::set_cookie(string $key, $value);'''<br><br />
'''EHeader::del_cookie(string $key);'''<br><br />
<br />
This can result particularly useful when you need to use EModel's insert and update<br />
but not all the data comes from user request.<br />
----------------<br />
If you want to take those variables fast and you can't decide you can choose<br />
the unsafe way using:<br />
<br />
'''EHeader::get(string $key);'''<br><br />
'''EHeader::post(string $key);'''<br><br />
----------------<br />
If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2)<br />
you can use this handy method to have that added to the module's stack.<br />
<br><br />
'''EHeader::add_from_string(string $str);'''<br />
----------------<br />
You can get the script page with all exta data(''&data=example?...'') erased by using:<br />
<br><br />
'''EHeader::erase_get_data(string $url);'''<br />
-----------------<br />
EHeader can be configure in the generic config file of gfx, which can be located<br />
here: ''gfx3/config/generic.conf.php''.<br />
<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
protectheaders|yes<br />
protectheaders|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Models&diff=71889Ocs-server/Gfx4/Models2016-05-20T13:32:21Z<p>Snizzo: </p>
<hr />
<div>The '''EModel''' class contains various facilities for querying databases and performing standard tasks like SELECT, INSERT, UPDATE and DELETE. So, for example, if you're writing a class that interfaces with the "posts" class in your database, you should create a file name "posts.model.php" in the "model" directory. GFX already knows that there are models there.<br />
This is a convention when creating models directly binded to a database table but feel free to create models with custom names. There is no particular restriction on Model's use.<br />
<br />
Every model should be name following this syntax <tablename>.model.php in order to be automatically loaded by gfx as a model. Then you can write your code that basically queries the database and returns the correct data, along with all manipulations done.<br />
<br />
Think of a Model of an object that has to return data that should already human understandable if seen raw.<br />
<br />
This is an example of a basic model class:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
class ArticlesModel extends EModel<br />
{<br />
public function __construct()<br />
{<br />
parent::__construct("articles");<br />
}<br />
<br />
public function getAll()<br />
{<br />
$data = $this->find("*");<br />
return $data;<br />
}<br />
}<br />
?><br />
</syntaxhighlight><br />
------------------<br />
EModel works with conditions that stays still after a query has been executed.<br />
<br />
* '''EModel::add_condition($c);''' //example: $model->add_condition('a=1'); $model->find('*');<br />
* '''EModel::clear_conditions();''' //example: $model->clear_conditions();<br />
* '''EModel::set_limit($limit);''' //$limit being an integer<br />
* '''EModel::set_ascending();'''<br />
* '''EModel::set_descending();'''<br />
* '''EModel::order_by($field=array());''' //example: $model->order_by(array('id','name');<br />
------------------<br />
EModel class wraps many of the operations that can be made to a database. Here is a list of the most useful methods of EModel:<br />
* '''EModel::fields()''':<br />
Returns all fields contained in table structure<br />
----------<br />
* '''EModel::insert($fields=array())''':<br />
Being $field and associative array $key => $value with the correct data.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
//let's assume the page will receive 2 GET parameters, one with key 'name' and one with key 'password'<br />
$name = EHeader::db_get('name');<br />
$password = EHeader::db_get('password');<br />
<br />
$e = new EModel('users'); //'users' is the name of the table that contains a column called 'name' and one called 'password'<br />
$e->insert(array('name' => $name, 'password' => $password));<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::count($fields=array())''':<br />
Performs a '''COUNT()''' of a '''SELECT''' query. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->count('name', 'where password=$password');<br />
//$result contains exactly the number of rows returned, it beings of course an integer<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::is_there($fields=array())''':<br />
Checks if a query returns more than a row and returns '''true''' or '''false'''. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->is_there('name', 'where password=$password');<br />
//$result contains true or false, whether the query result has at least one row or not<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::delete()''':<br />
Wraps a DELETE query and deletes rows following $where conditions to be put at the end of the query. $howmany is used to put a limit to the rows being deleted.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->delete('password=$password', 1);<br />
//this time the '''WHERE''' statement hasn't to be manually added to the $where parameter<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::update($fields=array())''':<br />
The same as EModel::insert(), just for updating fields. For security reasons is good practice to specify $allowed_fields() with only allowed fields.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->update('password=$password', array('name'));<br />
//only name will be updated, even if password is defined<br />
}<br />
?><br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Global_and_local_configuration&diff=71887Ocs-server/Gfx4/Global and local configuration2016-05-20T13:22:58Z<p>Snizzo: /* Generic.conf.php */</p>
<hr />
<div>GFX use a class to load config every time from a bunch of files. You can also<br />
create your config and find them placed under EConfig.<br />
<br />
Most of the gfx-related configurations are on the file '''/config/generic.conf.php'''. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.<br />
<br />
If you edit your /config/database.conf.php like this:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight><br />
<br />
You will automatically find them mapped into an associative array:<br />
<syntaxhighlight lang="php"><br />
EConfig::$data["database"]["name"];<br />
</syntaxhighlight><br />
<br />
Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name.<br />
<br />
Also note that PHP code in config files will just be ignored, so it's good practice to put<br />
a '''die();''' on the first line so no one will be able to see your inner configuration.<br />
<br />
You can also use multi value properties like this:<br />
--------------<br />
'''Filename: /config/myname.conf.php'''<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
info|Claudio|Desideri|kde<br />
</syntaxhighlight><br />
<br />
If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values.<br />
You can iterate on it using:<br />
<syntaxhighlight lang="php"><br />
foreach(EConfig::$data["myname"]["info"] as $item){<br />
echo $item;<br />
}<br />
</syntaxhighlight><br />
<br />
This will print:<br />
Claudio<br />
Desideri<br />
kde<br />
<br />
And via code that will be accessible using:<br />
<syntaxhighlight lang="php"><br />
$info = EConfig::$data["myname"]["info"];<br />
$info[0];<br />
$info[1];<br />
$info[2];<br />
</syntaxhighlight><br />
---------<br />
===Generic.conf.php===<br />
Each website (or subsite) must have a ''generic.conf.php'' file inside the ''config'' folder. These are the properties that can be setted through generic:<br />
* '''render''': can be "yes" or "no"<br />
* '''protectheaders''': can be "yes" or "no"<br />
* '''database''': can be "yes" or "no"<br />
* '''databasedriver''': can be "EMysql" or "ESQLite"<br />
* '''rewrite''': can be "yes" or "no"<br />
* '''users''': can be "yes" or "no"<br />
* '''mvc''': can be "yes" or "no"<br />
* '''errormode''': can be "normal", "formatted", "file" or "suppressed"<br />
* '''enabled''': can be "yes" or "protected"<br />
* '''password''': password of your choice<br />
<br />
Example of a ''generic.conf.php'' file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
render|yes<br />
protectheaders|yes<br />
database|yes<br />
databasedriver|EMysql<br />
rewrite|yes<br />
users|no<br />
mvc|yes<br />
errormode|normal<br />
enabled|protected<br />
password|esempio<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Database&diff=71886Ocs-server/Gfx4/Database2016-05-20T13:21:47Z<p>Snizzo: </p>
<hr />
<div>In Gfx database is abstracted using the multipurpose class EModel which queries the correct database driver.<br />
More database drivers are coming, though. Mysql driver is fully functional, sqlite driver is work in progress.<br />
<br />
Small reference:<br />
<br />
* '''EMysql::q($sql_query)''' -> execute $sql_query<br />
* '''EMysql::sq($sql_query)''' -> execute $sql_query and returns the first result. Useful for counts etc. <br />
* '''EMysql::table_exists($table)''' -> check if table exists and return boolean.<br />
* '''EMysql::last_insert_id()''' -> returns the id of the last inserted row.<br />
<br />
Database functionalities can be enabled/disabled in the generic config file ("config/generic.conf.php"):<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
database|yes<br />
database|no<br />
databasedriver|EMysql<br />
</syntaxhighlight><br />
<br />
'''databasedriver''' can also be ESQLite, but support for SQLite database is still not complete. To use the correct database abstraction please use EModel class (standalone o subclassed).<br />
<br />
------<br />
===database.conf.php===<br />
Example of a valid configuration file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/get_post_headers&diff=71884Ocs-server/Gfx4/get post headers2016-05-20T12:40:39Z<p>Snizzo: </p>
<hr />
<div>GFX provides a class that automatically handles and parse GET and POST data.<br />
So instead of directly accessing those arrays you should use EHeader.<br />
----------<br />
If you have to output your data you can use:<br />
<br />
'''EHeader::out_get(string $name);'''<br><br />
'''EHeader::out_post(string $name);'''<br><br />
-----------------<br />
If you have to insert your data into database and you need them to be safe you can use:<br />
<br />
'''EHeader::secure_get(string $name);'''<br><br />
'''EHeader::secure_post(string $name);'''<br><br />
------------------<br />
If you need all your data to be safe you can easily do:<br />
<br />
'''EHeader::safeAll();'''<br />
------------------<br />
You can also set GET and POST manually using:<br />
<br />
'''EHeader::add_get(string $key, string $value);'''<br><br />
'''EHeader::add_post(string $key, string $value);'''<br><br />
--------------<br />
You can check existance of GET and POST manually using:<br />
<br />
'''EHeader::exists_get(string $key);'''<br><br />
'''EHeader::exists_post(string $key);'''<br><br />
--------------<br />
You can use this class to get/set cookie data via:<br />
<br />
'''EHeader::get_cookie(string $key);'''<br><br />
'''EHeader::set_cookie(string $key, $value);'''<br><br />
'''EHeader::del_cookie(string $key);'''<br><br />
<br />
This can result particularly useful when you need to use EModel's insert and update<br />
but not all the data comes from user request.<br />
----------------<br />
If you want to take those variables fast and you can't decide you can choose<br />
the unsafe way using:<br />
<br />
'''EHeader::get(string $key);'''<br><br />
'''EHeader::post(string $key);'''<br><br />
----------------<br />
If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2)<br />
you can use this handy method to have that added to the module's stack.<br />
<br><br />
'''EHeader::add_from_string(string $str);'''<br />
----------------<br />
You can get the script page with all exta data(''&data=example?...'') erased by using:<br />
<br><br />
'''EHeader::erase_get_data(string $url);'''<br />
-----------------<br />
EHeader can be configure in the generic config file of gfx, which can be located<br />
here: ''gfx3/config/generic.conf.php''.<br />
<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
protectheaders|yes<br />
protectheaders|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/User_management&diff=71874Ocs-server/Gfx4/User management2016-05-18T15:10:01Z<p>Snizzo: </p>
<hr />
<div>The EUser static class (with static methods) allows you to easily handle user management on your website. Admin panel will support also for easy gfx users management.<br />
<br />
Small reference:<br />
<br />
* '''bool EUser::login($nick,$pass)''' -> attempts a login with given credentials<br />
* '''void EUser::logout()''' -> Performs a logout() call on whatever user is logged. <br />
* '''void EUser::gdeny($group)''' -> Denies access to this page to all users belonging to $group<br />
* '''void EUser::gallow($group)''' -> Allows access to this page to all users belonging to $group<br />
* '''bool EUser::logged()''' -> returns true if user is logged else false<br />
* '''bool EUser::is_already_present_login()''' -> returns true if login is already present else false<br />
* '''bool EUser::is_already_present_email()''' -> returns true if email is already present else false<br />
* '''string EUser::password()''' -> returns user's password <br />
* '''string EUser::mail()''' -> returns user's mail<br />
* '''string EUser::id()''' -> returns user's id<br />
* '''string EUser::group()''' -> returns user's group<br />
* '''void EUser::register($nick, $pass, $group)''' -> attempts a registration to gfx user system with given $nick, $pass and $group</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Models&diff=71873Ocs-server/Gfx4/Models2016-05-18T13:28:37Z<p>Snizzo: </p>
<hr />
<div>The '''EModel''' class contains various facilities for querying databases and performing standard tasks like SELECT, INSERT, UPDATE and DELETE. So, for example, if you're writing a class that interfaces with the "posts" class in your database, you should create a file name "posts.model.php" in the "model" directory. GFX already knows that there are models there.<br />
This is a convention when creating models directly binded to a database table but feel free to create models with custom names. There is no particular restriction on Model's use.<br />
<br />
Every model should be name following this syntax <tablename>.model.php in order to be automatically loaded by gfx as a model. Then you can write your code that basically queries the database and returns the correct data, along with all manipulations done.<br />
<br />
Think of a Model of an object that has to return data that should already human understandable if seen raw.<br />
<br />
This is an example of a basic model class:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
class ArticlesModel extends EModel<br />
{<br />
public function __construct()<br />
{<br />
parent::__construct("articles");<br />
}<br />
<br />
public function getAll()<br />
{<br />
$data = $this->find("*");<br />
return $data;<br />
}<br />
}<br />
?><br />
</syntaxhighlight><br />
------------------<br />
EModel works with conditions that stays still after a query has been executed.<br />
<br />
* '''EModel::add_condition($c);''' //example: $model->add_condition('a=1'); $model->find('*');<br />
* '''EModel::clear_conditions();''' //example: $model->clear_conditions();<br />
------------------<br />
EModel class wraps many of the operations that can be made to a database. Here is a list of the most useful methods of EModel:<br />
* '''EModel::fields()''':<br />
Returns all fields contained in table structure<br />
----------<br />
* '''EModel::insert($allowed_fields=array())''':<br />
Attempts to do an automatic insert in the table. EModel will look into GET / POST parameters passed to the page, and if the name of the parameter is the same of the column in the table, that will have the correct value when inserted. For security reasons every field that will use this "automatic" feature must be inserted in the $allowed_fields array when insert() is called.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
//let's assume the page will receive 2 GET parameters, one with key 'name' and one with key 'password'<br />
if(isset($_GET['name']) and isset($_GET['password'])){<br />
$e = new EModel('users'); //'users' is the name of the table that contains a column called 'name' and one called 'password'<br />
$e->insert(array('name', 'password')); //allow both fields<br />
//now table is inserted with a new element that has correct name and password, also when other fields are present<br />
//and matching but not allowed<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::count($field="id", $where="")''':<br />
Performs a '''COUNT()''' of a '''SELECT''' query. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->count('name', 'where password=$password');<br />
//$result contains exactly the number of rows returned, it beings of course an integer<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::is_there($field="", $where="")''':<br />
Checks if a query returns more than a row and returns '''true''' or '''false'''. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->is_there('name', 'where password=$password');<br />
//$result contains true or false, whether the query result has at least one row or not<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::delete($where="", $howmany="")''':<br />
Wraps a DELETE query and deletes rows following $where conditions to be put at the end of the query. $howmany is used to put a limit to the rows being deleted.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->delete('password=$password', 1);<br />
//this time the '''WHERE''' statement hasn't to be manually added to the $where parameter<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::update($where="", $allowed_fields=array())''':<br />
The same as EModel::insert(), just for updating fields. For security reasons is good practice to specify $allowed_fields() with only allowed fields.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->update('password=$password', array('name'));<br />
//only name will be updated, even if password is defined<br />
}<br />
?><br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Models&diff=71872Ocs-server/Gfx4/Models2016-05-18T13:27:36Z<p>Snizzo: </p>
<hr />
<div>The '''EModel''' class contains various facilities for querying databases and performing standard tasks like SELECT, INSERT, UPDATE and DELETE. So, for example, if you're writing a class that interfaces with the "posts" class in your database, you should create a file name "posts.model.php" in the "model" directory. GFX already knows that there are models there.<br />
This is a convention when creating models directly binded to a database table but feel free to create models with custom names. There is no particular restriction on Model's use.<br />
<br />
Every model should be name following this syntax <tablename>.model.php in order to be automatically loaded by gfx as a model. Then you can write your code that basically queries the database and returns the correct data, along with all manipulations done.<br />
<br />
Think of a Model of an object that has to return data that should already human understandable if seen raw.<br />
<br />
This is an example of a basic model class:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
class ArticlesModel extends EModel<br />
{<br />
public function __construct()<br />
{<br />
parent::__construct("articles");<br />
}<br />
<br />
public function getAll()<br />
{<br />
$data = $this->find("*");<br />
return $data;<br />
}<br />
}<br />
?><br />
</syntaxhighlight><br />
------------------<br />
EModel works with conditions that stays still after a query has been executed.<br />
<br />
EModel::add_condition($c); //example: $model->add_condition('a=1'); $model->find('*');<br />
EModel::clear_conditions(); //example: $model->clear_conditions();<br />
------------------<br />
EModel class wraps many of the operations that can be made to a database. Here is a list of the most useful methods of EModel:<br />
* '''EModel::fields()''':<br />
Returns all fields contained in table structure<br />
----------<br />
* '''EModel::insert($allowed_fields=array())''':<br />
Attempts to do an automatic insert in the table. EModel will look into GET / POST parameters passed to the page, and if the name of the parameter is the same of the column in the table, that will have the correct value when inserted. For security reasons every field that will use this "automatic" feature must be inserted in the $allowed_fields array when insert() is called.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
//let's assume the page will receive 2 GET parameters, one with key 'name' and one with key 'password'<br />
if(isset($_GET['name']) and isset($_GET['password'])){<br />
$e = new EModel('users'); //'users' is the name of the table that contains a column called 'name' and one called 'password'<br />
$e->insert(array('name', 'password')); //allow both fields<br />
//now table is inserted with a new element that has correct name and password, also when other fields are present<br />
//and matching but not allowed<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::count($field="id", $where="")''':<br />
Performs a '''COUNT()''' of a '''SELECT''' query. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->count('name', 'where password=$password');<br />
//$result contains exactly the number of rows returned, it beings of course an integer<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::is_there($field="", $where="")''':<br />
Checks if a query returns more than a row and returns '''true''' or '''false'''. $field is the field to select. Additional parameters can be added at the end of the query with $where parameter.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$result = $e->is_there('name', 'where password=$password');<br />
//$result contains true or false, whether the query result has at least one row or not<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::delete($where="", $howmany="")''':<br />
Wraps a DELETE query and deletes rows following $where conditions to be put at the end of the query. $howmany is used to put a limit to the rows being deleted.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->delete('password=$password', 1);<br />
//this time the '''WHERE''' statement hasn't to be manually added to the $where parameter<br />
}<br />
?><br />
</syntaxhighlight><br />
----------<br />
* '''EModel::update($where="", $allowed_fields=array())''':<br />
The same as EModel::insert(), just for updating fields. For security reasons is good practice to specify $allowed_fields() with only allowed fields.<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php<br />
$e = new EModel('users');<br />
$e->update('password=$password', array('name'));<br />
//only name will be updated, even if password is defined<br />
}<br />
?><br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/User_management&diff=69030Ocs-server/Gfx4/User management2016-05-09T11:10:12Z<p>Snizzo: Created page with "The EUser static class (with static methods) allows you to easily handle user management on your website. Admin panel will support also for easy gfx users management. Small r..."</p>
<hr />
<div>The EUser static class (with static methods) allows you to easily handle user management on your website. Admin panel will support also for easy gfx users management.<br />
<br />
Small reference:<br />
<br />
* '''bool EUser::login($nick,$pass)''' -> attempts a login with given credentials<br />
* '''void EUser::logout()''' -> Performs a logout() call on whatever user is logged. <br />
* '''void EUser::gdeny($group)''' -> Denies access to this page to all users belonging to $group<br />
* '''void EUser::gallow($group)''' -> Allows access to this page to all users belonging to $group<br />
* '''bool EUser::logged()''' -> returns true if user is logged else false<br />
* '''string EUser::password()''' -> returns user's password <br />
* '''string EUser::mail()''' -> returns user's mail<br />
* '''string EUser::id()''' -> returns user's id<br />
* '''string EUser::group()''' -> returns user's group<br />
* '''void EUser::register($nick, $pass, $group)''' -> attempts a registration to gfx user system with given $nick, $pass and $group</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=69029Ocs-server/Gfx42016-05-09T11:00:09Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Editing config files programmatically | Editing config files programmatically]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/User management | User management]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [[Ocs-server/Gfx4/Utilities | Utilities]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Utilities&diff=68121Ocs-server/Gfx4/Utilities2016-05-06T10:39:54Z<p>Snizzo: Created page with "Utility class contains some utilities still not inserted in dedicated classes. ==Output flow control== * '''static void Utility::hide_output()''' -> collects every output tha..."</p>
<hr />
<div>Utility class contains some utilities still not inserted in dedicated classes.<br />
<br />
==Output flow control==<br />
* '''static void Utility::hide_output()''' -> collects every output that will be normally sent to standard output<br />
* '''static string Utility::show_output()''' -> return a string containing all the previosly collected output<br />
* '''static void Utility::redirect($page)''' -> redirects the browser to $page</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=68120Ocs-server/Gfx42016-05-06T10:38:47Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Editing config files programmatically | Editing config files programmatically]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [[Ocs-server/Gfx4/Utilities | Utilities]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/XML_utilities&diff=68119Ocs-server/Gfx4/XML utilities2016-05-06T10:35:30Z<p>Snizzo: </p>
<hr />
<div>Gfx contains some XML utilities.<br />
<br />
* '''static bool XMLParser::is_assoc($array)''' -> checks if $array is associative or not<br />
* '''static array XMLParser::to_array($contents, $force_multiple=array())''' -> converts an xml tree to an associative array</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/XML_utilities&diff=68118Ocs-server/Gfx4/XML utilities2016-05-06T10:26:23Z<p>Snizzo: </p>
<hr />
<div>Gfx contains some XML utilities.<br />
<br />
* '''static bool XMLParser::is_assoc($array)''' -> checks if $array is associative or not<br />
* '''static array XMLParser::to_array($contents, $force_multiple=array())''' -> converts an xml tree to an associative array<br />
<br />
* '''static void XMLParser::hide_output()''' -> collects every output that will be normally sent to standard output<br />
* '''static string XMLParser::show_output()''' -> return a string containing all the previosly collected output</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Editing_config_files_programmatically&diff=67890Ocs-server/Gfx4/Editing config files programmatically2016-05-05T15:48:07Z<p>Snizzo: Created page with "GFX provides a handy class that lets you edit config files programmatically to create easy admin modes and settings managers. All changes are made in ram before being saved t..."</p>
<hr />
<div>GFX provides a handy class that lets you edit config files programmatically to create easy admin modes and settings managers.<br />
<br />
All changes are made in ram before being saved to disk with the save() method. Remember to call save(), or your changes will be lost at the end of object's life.<br />
<br />
<syntaxhighlight lang="php"><br />
<?php<br />
//constructor, $namefile can be empty<br />
$config = new EConfigFile($namefile);<br />
//set $key with $value<br />
$config->set($key, $value);<br />
//get $value associated to $key<br />
$config->get($key);<br />
//delete $key from config file<br />
$config->del($key);<br />
//apply modifications, save<br />
$config->save();<br />
?><br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=67886Ocs-server/Gfx42016-05-05T15:27:53Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Editing config files programmatically | Editing config files programmatically]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Global_and_local_configuration&diff=67303Ocs-server/Gfx4/Global and local configuration2016-05-03T09:14:28Z<p>Snizzo: /* Generic.conf.php */</p>
<hr />
<div>GFX use a class to load config every time from a bunch of files. You can also<br />
create your config and find them placed under EConfig.<br />
<br />
Most of the gfx-related configurations are on the file '''/config/generic.conf.php'''. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.<br />
<br />
If you edit your /config/database.conf.php like this:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight><br />
<br />
You will automatically find them mapped into an associative array:<br />
<syntaxhighlight lang="php"><br />
EConfig::$data["database"]["name"];<br />
</syntaxhighlight><br />
<br />
Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name.<br />
<br />
Also note that PHP code in config files will just be ignored, so it's good practice to put<br />
a '''die();''' on the first line so no one will be able to see your inner configuration.<br />
<br />
You can also use multi value properties like this:<br />
--------------<br />
'''Filename: /config/myname.conf.php'''<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
info|Claudio|Desideri|kde<br />
</syntaxhighlight><br />
<br />
If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values.<br />
You can iterate on it using:<br />
<syntaxhighlight lang="php"><br />
foreach(EConfig::$data["myname"]["info"] as $item){<br />
echo $item;<br />
}<br />
</syntaxhighlight><br />
<br />
This will print:<br />
Claudio<br />
Desideri<br />
kde<br />
<br />
And via code that will be accessible using:<br />
<syntaxhighlight lang="php"><br />
$info = EConfig::$data["myname"]["info"];<br />
$info[0];<br />
$info[1];<br />
$info[2];<br />
</syntaxhighlight><br />
---------<br />
===Generic.conf.php===<br />
Each website (or subsite) must have a ''generic.conf.php'' file inside the ''config'' folder. These are the properties that can be setted through generic:<br />
* '''render''': can be "yes" or "no"<br />
* '''protectheaders''': can be "yes" or "no"<br />
* '''database''': can be "yes" or "no"<br />
* '''rewrite''': can be "yes" or "no"<br />
* '''users''': can be "yes" or "no"<br />
* '''mvc''': can be "yes" or "no"<br />
* '''errormode''': can be "normal", "formatted", "file" or "suppressed"<br />
* '''enabled''': can be "yes" or "protected"<br />
* '''password''': password of your choice<br />
<br />
Example of a ''generic.conf.php'' file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
render|yes<br />
protectheaders|yes<br />
database|yes<br />
rewrite|yes<br />
users|no<br />
mvc|yes<br />
errormode|normal<br />
enabled|protected<br />
password|esempio<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Global_and_local_configuration&diff=67302Ocs-server/Gfx4/Global and local configuration2016-05-03T09:14:16Z<p>Snizzo: /* Generic.conf.php */</p>
<hr />
<div>GFX use a class to load config every time from a bunch of files. You can also<br />
create your config and find them placed under EConfig.<br />
<br />
Most of the gfx-related configurations are on the file '''/config/generic.conf.php'''. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.<br />
<br />
If you edit your /config/database.conf.php like this:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight><br />
<br />
You will automatically find them mapped into an associative array:<br />
<syntaxhighlight lang="php"><br />
EConfig::$data["database"]["name"];<br />
</syntaxhighlight><br />
<br />
Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name.<br />
<br />
Also note that PHP code in config files will just be ignored, so it's good practice to put<br />
a '''die();''' on the first line so no one will be able to see your inner configuration.<br />
<br />
You can also use multi value properties like this:<br />
--------------<br />
'''Filename: /config/myname.conf.php'''<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
info|Claudio|Desideri|kde<br />
</syntaxhighlight><br />
<br />
If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values.<br />
You can iterate on it using:<br />
<syntaxhighlight lang="php"><br />
foreach(EConfig::$data["myname"]["info"] as $item){<br />
echo $item;<br />
}<br />
</syntaxhighlight><br />
<br />
This will print:<br />
Claudio<br />
Desideri<br />
kde<br />
<br />
And via code that will be accessible using:<br />
<syntaxhighlight lang="php"><br />
$info = EConfig::$data["myname"]["info"];<br />
$info[0];<br />
$info[1];<br />
$info[2];<br />
</syntaxhighlight><br />
---------<br />
===Generic.conf.php===<br />
Each website (or subsite) must have a ''generic.conf.php'' file inside the ''config'' folder. These are the properties that can be setted through generic:<br />
* '''render''': can be "yes" or "no"<br />
* '''protectheaders''': can be "yes" or "no"<br />
* '''database''': can be "yes" or "no"<br />
* '''rewrite''': can be "yes" or "no"<br />
* '''users''': can be "yes" or "no"<br />
* '''mvc''': can be "yes" or "no"<br />
* '''errormode''': can be "normal", "formatted", "file" or "suppressed"<br />
* '''enabled''': can be "yes" or "no"<br />
* '''password''': password of your choice<br />
<br />
Example of a ''generic.conf.php'' file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
render|yes<br />
protectheaders|yes<br />
database|yes<br />
rewrite|yes<br />
users|no<br />
mvc|yes<br />
errormode|normal<br />
enabled|protected<br />
password|esempio<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/Configuring_a_webserver_as_host&diff=44390Ocs-server/Install/Configuring a webserver as host2015-10-01T14:51:52Z<p>Snizzo: /* Ubuntu */</p>
<hr />
<div>== Target system ==<br />
This guide is inteded to use with Ubuntu and may use Ubuntu only commands. It can be adapted to other distros however. If you want to help adding support for other distributions please feel free to edit this page.<br />
<br />
== Install distribution packages ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="cpp"><br />
sudo apt-get install libapache2-mod-php5 mysql-server php5-mysql phpmyadmin php5-gd php5-curl<br />
</syntaxhighlight><br />
<br />
== Enable URL rewriting ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="php"><br />
sudo a2enmod rewrite<br />
</syntaxhighlight><br />
<br />
Now open your server configuration file with your preferred text editor:<br />
<syntaxhighlight lang="php"><br />
sudo nano /etc/apache2/apache2.conf<br />
</syntaxhighlight><br />
Now change those line of code when Directory is / or /var/www:<br />
<syntaxhighlight lang="php"><br />
AllowOverride None <br />
</syntaxhighlight><br />
with:<br />
<syntaxhighlight lang="php"><br />
AllowOverride All <br />
</syntaxhighlight><br />
<br />
And restart your web server:<br />
<syntaxhighlight lang="php"><br />
sudo service apache2 restart<br />
</syntaxhighlight><br />
<br />
== Get latest source ==<br />
Grab a copy of ocs-server by cloning our public repository into the DocumentRoot of your server. Keep in mind the OCS protocol is made to work on the document root of this type: http://www.example.com or this: http://localhost. If you have other websites on the same server, we suggest you to put it in a subdomain like http://ocs.example.com.<br />
<br />
Navigate to your DocumentRoot:<br />
<syntaxhighlight lang="cpp"><br />
cd /var/www/html<br />
</syntaxhighlight><br />
<br />
Clone ocs-server git repository:<br />
<syntaxhighlight lang="cpp"><br />
sudo git clone git://anongit.kde.org/ocs-server.git<br />
</syntaxhighlight><br />
<br />
Copy everything to your server root:<br />
<syntaxhighlight lang="cpp"><br />
sudo cp -r ocs-server/. .<br />
</syntaxhighlight><br />
<br />
Remove your duplicate ocs-server folder:<br />
<syntaxhighlight lang="cpp"><br />
sudo rm -rf /var/www/html/ocs-server<br />
</syntaxhighlight><br />
<br />
And restart again your web server, just to be sure:<br />
<syntaxhighlight lang="php"><br />
sudo service apache2 restart<br />
</syntaxhighlight><br />
<br />
== Final result ==<br />
Ocs-server should be installed and working. Check the homepage, usually [http://localhost/ http://localhost/] or your domain of choice. In the homepage there are several useful links for both end-users and developers. You are ready to follow the [[Ocs-server/Install/First run wizard| First run wizard]] tutorial.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/Configuring_a_webserver_as_host&diff=44389Ocs-server/Install/Configuring a webserver as host2015-10-01T14:51:36Z<p>Snizzo: /* Get latest source */</p>
<hr />
<div>== Target system ==<br />
This guide is inteded to use with Ubuntu and may use Ubuntu only commands. It can be adapted to other distros however. If you want to help adding support for other distributions please feel free to edit this page.<br />
<br />
== Install distribution packages ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="cpp"><br />
sudo apt-get install libapache2-mod-php5 mysql-server php5-mysql phpmyadmin php5-gd php5-curl<br />
</syntaxhighlight><br />
<br />
== Enable URL rewriting ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="php"><br />
sudo a2enmod rewrite<br />
</syntaxhighlight><br />
<br />
Now open your server configuration file with your preferred text editor:<br />
<syntaxhighlight lang="php"><br />
sudo nano /etc/apache2/apache2.conf<br />
</syntaxhighlight><br />
Now change those line of code when Directory is / or /var/www:<br />
<syntaxhighlight lang="php"><br />
AllowOverride None <br />
</syntaxhighlight><br />
with:<br />
<syntaxhighlight lang="php"><br />
AllowOverride All <br />
</syntaxhighlight><br />
<br />
== Get latest source ==<br />
Grab a copy of ocs-server by cloning our public repository into the DocumentRoot of your server. Keep in mind the OCS protocol is made to work on the document root of this type: http://www.example.com or this: http://localhost. If you have other websites on the same server, we suggest you to put it in a subdomain like http://ocs.example.com.<br />
<br />
Navigate to your DocumentRoot:<br />
<syntaxhighlight lang="cpp"><br />
cd /var/www/html<br />
</syntaxhighlight><br />
<br />
Clone ocs-server git repository:<br />
<syntaxhighlight lang="cpp"><br />
sudo git clone git://anongit.kde.org/ocs-server.git<br />
</syntaxhighlight><br />
<br />
Copy everything to your server root:<br />
<syntaxhighlight lang="cpp"><br />
sudo cp -r ocs-server/. .<br />
</syntaxhighlight><br />
<br />
Remove your duplicate ocs-server folder:<br />
<syntaxhighlight lang="cpp"><br />
sudo rm -rf /var/www/html/ocs-server<br />
</syntaxhighlight><br />
<br />
And restart again your web server, just to be sure:<br />
<syntaxhighlight lang="php"><br />
sudo service apache2 restart<br />
</syntaxhighlight><br />
<br />
== Final result ==<br />
Ocs-server should be installed and working. Check the homepage, usually [http://localhost/ http://localhost/] or your domain of choice. In the homepage there are several useful links for both end-users and developers. You are ready to follow the [[Ocs-server/Install/First run wizard| First run wizard]] tutorial.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/Configuring_a_webserver_as_host&diff=44388Ocs-server/Install/Configuring a webserver as host2015-10-01T14:51:11Z<p>Snizzo: /* Ubuntu */</p>
<hr />
<div>== Target system ==<br />
This guide is inteded to use with Ubuntu and may use Ubuntu only commands. It can be adapted to other distros however. If you want to help adding support for other distributions please feel free to edit this page.<br />
<br />
== Install distribution packages ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="cpp"><br />
sudo apt-get install libapache2-mod-php5 mysql-server php5-mysql phpmyadmin php5-gd php5-curl<br />
</syntaxhighlight><br />
<br />
== Enable URL rewriting ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="php"><br />
sudo a2enmod rewrite<br />
</syntaxhighlight><br />
<br />
Now open your server configuration file with your preferred text editor:<br />
<syntaxhighlight lang="php"><br />
sudo nano /etc/apache2/apache2.conf<br />
</syntaxhighlight><br />
Now change those line of code when Directory is / or /var/www:<br />
<syntaxhighlight lang="php"><br />
AllowOverride None <br />
</syntaxhighlight><br />
with:<br />
<syntaxhighlight lang="php"><br />
AllowOverride All <br />
</syntaxhighlight><br />
<br />
== Get latest source ==<br />
Grab a copy of ocs-server by cloning our public repository into the DocumentRoot of your server. Keep in mind the OCS protocol is made to work on the document root of this type: http://www.example.com or this: http://localhost. If you have other websites on the same server, we suggest you to put it in a subdomain like http://ocs.example.com.<br />
<br />
Navigate to your DocumentRoot:<br />
<syntaxhighlight lang="cpp"><br />
cd /var/www/html<br />
</syntaxhighlight><br />
<br />
Clone ocs-server git repository:<br />
<syntaxhighlight lang="cpp"><br />
sudo git clone git://anongit.kde.org/ocs-server.git<br />
</syntaxhighlight><br />
<br />
Copy everything to your server root:<br />
<syntaxhighlight lang="cpp"><br />
sudo cp -r ocs-server/. .<br />
</syntaxhighlight><br />
<br />
Remove your duplicate ocs-server folder:<br />
<syntaxhighlight lang="cpp"><br />
sudo rm -rf /var/www/html/ocs-server<br />
</syntaxhighlight><br />
<br />
== Final result ==<br />
Ocs-server should be installed and working. Check the homepage, usually [http://localhost/ http://localhost/] or your domain of choice. In the homepage there are several useful links for both end-users and developers. You are ready to follow the [[Ocs-server/Install/First run wizard| First run wizard]] tutorial.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/Configuring_a_webserver_as_host&diff=44387Ocs-server/Install/Configuring a webserver as host2015-10-01T14:49:11Z<p>Snizzo: /* Get latest source */</p>
<hr />
<div>== Target system ==<br />
This guide is inteded to use with Ubuntu and may use Ubuntu only commands. It can be adapted to other distros however. If you want to help adding support for other distributions please feel free to edit this page.<br />
<br />
== Install distribution packages ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="cpp"><br />
sudo apt-get install libapache2-mod-php5 mysql-server php5-mysql phpmyadmin php5-gd php5-curl<br />
</syntaxhighlight><br />
<br />
== Enable URL rewriting ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="php"><br />
sudo a2enmod rewrite<br />
</syntaxhighlight><br />
<br />
Now open your server configuration file with your preferred text editor:<br />
<syntaxhighlight lang="php"><br />
sudo nano /etc/apache2/apache2.conf<br />
</syntaxhighlight><br />
Now change those line of code when Directory is / or /var/www:<br />
<syntaxhighlight lang="php"><br />
AllowOverride None <br />
</syntaxhighlight><br />
with:<br />
<syntaxhighlight lang="php"><br />
AllowOverride All <br />
</syntaxhighlight><br />
And restart your web server:<br />
<syntaxhighlight lang="php"><br />
sudo service apache2 restart<br />
</syntaxhighlight><br />
<br />
== Get latest source ==<br />
Grab a copy of ocs-server by cloning our public repository into the DocumentRoot of your server. Keep in mind the OCS protocol is made to work on the document root of this type: http://www.example.com or this: http://localhost. If you have other websites on the same server, we suggest you to put it in a subdomain like http://ocs.example.com.<br />
<br />
Navigate to your DocumentRoot:<br />
<syntaxhighlight lang="cpp"><br />
cd /var/www/html<br />
</syntaxhighlight><br />
<br />
Clone ocs-server git repository:<br />
<syntaxhighlight lang="cpp"><br />
sudo git clone git://anongit.kde.org/ocs-server.git<br />
</syntaxhighlight><br />
<br />
Copy everything to your server root:<br />
<syntaxhighlight lang="cpp"><br />
sudo cp -r ocs-server/. .<br />
</syntaxhighlight><br />
<br />
Remove your duplicate ocs-server folder:<br />
<syntaxhighlight lang="cpp"><br />
sudo rm -rf /var/www/html/ocs-server<br />
</syntaxhighlight><br />
<br />
== Final result ==<br />
Ocs-server should be installed and working. Check the homepage, usually [http://localhost/ http://localhost/] or your domain of choice. In the homepage there are several useful links for both end-users and developers. You are ready to follow the [[Ocs-server/Install/First run wizard| First run wizard]] tutorial.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/First_run_wizard&diff=44386Ocs-server/Install/First run wizard2015-10-01T14:35:26Z<p>Snizzo: /* Where to start */</p>
<hr />
<div>== Where to start ==<br />
In order to follow this tutorial, you should have completed the [[Ocs-server/Install/Configuring a webserver as host| Configuring a webserver as host]] tutorial, and therefore having a configured webserver and a copy of ocs-server installed and working. You should see a welcoming page if you go on your local domain like [http://localhost http://localhost].<br />
<br />
If you don't see the welcoming page, make sure no '''index.html''' is present in the root of your web server. If your system is a standard *buntu installation, you can delete the standard index page by doing:<br />
<syntaxhighlight lang="php"><br />
sudo rm /var/www/html/index.html<br />
</syntaxhighlight><br />
Then, check again: [http://localhost http://localhost].<br />
<br />
On this page follow the link that point to the "First run wizard".<br />
[[File:Ocs_firstrun.png|400px|thumb|center|Press on "first run wizard!"]]<br />
<br />
== Step 1: configuring database ==<br />
The first run wizard will ask you for a valid database configuration. You have to provide the name of the database, the host in which is located, user and password used for the connection, of an already installed MySQL server. You can try your config with the "Try config" button until a green text will appear saying that a successful connection has been made.<br />
On this page follow the link that point to the "First run wizard".<br />
[[File:Ocs_step1.png|600px|thumb|center|Everything is fine here]]<br />
<br />
== Step 2: configuring OCS parameters ==<br />
The second step is about configuring pure OCS parameters. Since there is no clear explanation about those parameters on the internet we'll try to explain here one by one:<br />
* Server ID: just affects client's libraries, it's the name that will be shown when connecting.<br />
* Name: same as Server ID<br />
* Website: shown as the website that contains the api. e.g. opendesktop.org<br />
* Host: the actual host of the OCS api: e.g. host.opendesktop.org (without /v1)<br />
* V1 location: the complete location of the basic OCS call. This would be for example: http://host.opendesktop.org/v1 . This is the base for every query made by the client. For example to retrieve all the content the call will be http://host.opendesktop.org/v1/content/data .<br />
* Terms of use URL: human readable terms of use. There is no format restriction on these. You can point that to a webpage or to a pdf, still we encourage to use html or txt format.<br />
* Register new user URL: This is optional and it's the URL that points to the human-readable webpage that let a new user to be registered on your OCS server. Take in account that, as described in the protocol specs, new users can also register using OCS calls from every client.<br />
* E-mail of admin: the system administrator email<br />
* Protocol: choose between http and https. Changing this won't install and configure the SSL module on the webserver for you, so be sure to select the appropriate entry for your configuration.<br />
* Output: choose between responding to client in XML or JSON. We're working on the possibility to having both of them.<br />
<br />
This will generate a file called providers.xml that will provide clients with all the information needed to query your server, so be careful on this part. <br />
[[File:Ocs_step2.png|600px|thumb|center|Automatic configurator in action]]<br />
<br />
Then a quick preview of the providers.xml file will be generated. A preview of the /v1/config call also is available. If you see a nice XML formatted output with /v1/config it means your server is now working properly.<br />
[[File:Ocs_step2_1.png|450px|thumb|center|Previews of config]]<br />
<br />
== Step 3: setting admin password ==<br />
The last part of the tutorial will ask you to set an admin password, that will be asked everytime you'll try to access the admin area via http://example.com/admin . For more security, you can also erase the "admin" folder entirely and put it there just when needed, or restricts that folder the be accessible only from localhost and so on.<br />
[[File:Ocs_step3.png|600px|thumb|center|Set your admin password]]<br />
<br />
== Conclusions ==<br />
Here we are, you should have your OCS server up and running now! You can use it with any kind of client that supports OCS. We built a webclient sized to KDE's needs that you're free to use, modify and adapt.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Install/Configuring_a_webserver_as_host&diff=44385Ocs-server/Install/Configuring a webserver as host2015-10-01T14:31:57Z<p>Snizzo: /* Get latest source */</p>
<hr />
<div>== Target system ==<br />
This guide is inteded to use with Ubuntu and may use Ubuntu only commands. It can be adapted to other distros however. If you want to help adding support for other distributions please feel free to edit this page.<br />
<br />
== Install distribution packages ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="cpp"><br />
sudo apt-get install libapache2-mod-php5 mysql-server php5-mysql phpmyadmin php5-gd php5-curl<br />
</syntaxhighlight><br />
<br />
== Enable URL rewriting ==<br />
===Ubuntu===<br />
<syntaxhighlight lang="php"><br />
sudo a2enmod rewrite<br />
</syntaxhighlight><br />
<br />
Now open your server configuration file with your preferred text editor:<br />
<syntaxhighlight lang="php"><br />
sudo nano /etc/apache2/apache2.conf<br />
</syntaxhighlight><br />
Now change those line of code when Directory is / or /var/www:<br />
<syntaxhighlight lang="php"><br />
AllowOverride None <br />
</syntaxhighlight><br />
with:<br />
<syntaxhighlight lang="php"><br />
AllowOverride All <br />
</syntaxhighlight><br />
And restart your web server:<br />
<syntaxhighlight lang="php"><br />
sudo service apache2 restart<br />
</syntaxhighlight><br />
<br />
== Get latest source ==<br />
Grab a copy of ocs-server by cloning our public repository into the DocumentRoot of your server. Keep in mind the OCS protocol is made to work on the document root of this type: http://www.example.com or this: http://localhost. If you have other websites on the same server, we suggest you to put it in a subdomain like http://ocs.example.com.<br />
<br />
Navigate to your DocumentRoot:<br />
<syntaxhighlight lang="cpp"><br />
cd /var/www/html<br />
</syntaxhighlight><br />
<br />
Clone ocs-server git repository:<br />
<syntaxhighlight lang="cpp"><br />
sudo git clone git://anongit.kde.org/ocs-server.git<br />
</syntaxhighlight><br />
<br />
Copy everything to your server root:<br />
<syntaxhighlight lang="cpp"><br />
sudo cp -r ocs-server/* .<br />
</syntaxhighlight><br />
<br />
== Final result ==<br />
Ocs-server should be installed and working. Check the homepage, usually [http://localhost/ http://localhost/] or your domain of choice. In the homepage there are several useful links for both end-users and developers. You are ready to follow the [[Ocs-server/Install/First run wizard| First run wizard]] tutorial.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server&diff=44384Ocs-server2015-10-01T14:31:29Z<p>Snizzo: /* Current status of development */</p>
<hr />
<div>[https://projects.kde.org/projects/playground/www/ocs-server ocs-server] is an open source implementation of the [http://en.wikipedia.org/wiki/Open_Collaboration_Services Open Collaboration Services]<br />
<br />
:Mailing List: not present<br />
:IRC Channel: #ocs on freenode<br />
:QuickGit: http://quickgit.kde.org/?p=ocs-server.git<br />
<br />
Ocs-server aims to write a working implementation of the OCS protocol. It's first objective is to provide KDE an open source content distribution system server-side that can take advantage of already existing technologies like libAttica, kNewStuff etc. We're currently using this server (stable version) for the Gluon Project.<br />
<br />
* [Installation] [[Ocs-server/Install/Configuring a webserver as host| Configuring a webserver as host]]<br />
* [Installation] [[Ocs-server/Install/First run wizard| First run wizard]]<br />
<br />
<br />
Hey! Did you know ocs-server is built on top of in-house [[Ocs-server/Gfx4 | Gfx4 web framework]]?<br />
<br />
== Current status of development ==<br />
<br />
'''ocs-server 0.1 technology preview is out!!! [http://gamingfreedom.org/download/ocs-server_0.1_techprev.tar.gz Download]'''<br />
<br />
[UPDATE 1st October 2015]: Our server works partially when using it as primary service provider with KDE instead of opendesktop one. We're now working to mimick the current official server in every aspect, implementing missing calls/attributes that are obscure and/or not documented enough.<br />
<br />
Here is a timeline we're currently following: [https://community.kde.org/Ocs-server/Timeline Feature parity timeline]<br />
-----------------<br />
[UPDATE 1st June 2015]: As for now, we're gathering info about what is needed exactly to have a minimal working server that could replace current third-party software (kde-look) and have it run with "Get Hot New Stuff" software.<br />
We also have a working implementation running for the Gluon Project. Check out our [http://gamingfreedom.org/index.php webclient] or directly query our [http://gamingfreedom.org/v1/config server].<br />
<br />
== Contributing to ocs-server ==<br />
<br />
The ocs-server developers maintain a list of active tasks. We have a todo active on [https://todo.kde.org/?controller=board&action=show&project_id=76 todo.kde.org] As for now, you can talk with us on our IRC channel #ocs on freedone.<br />
<br />
== What about bodega? ==<br />
<br />
We had discussed this concern in a blog post about possible uses of the ocs-server as Plasma content delivery system. Here is an extract of [http://playgfx.blogspot.com/2015/03/ideas-to-restructure-plasma-content.html?showComment=1426326876089#c3121703366432336002 this original comment] written by KDE developer Dan Leinir Turthra Jensen.<br />
<br />
<blockquote><br />
''This project and bodega don't in any real sense have any relationship - they both try to solve similar issues (opendesktop.org is practically unmaintained, has a worrying bus factor, is closed, etc), but take different approaches (ocs-server uses established (though of course not faultless) web technologies and the same web api as the existing solution, bodega attempts to build the complete system from scratch using a developing and at times troublesome technology).''<br />
<br />
''More importantly, though, bodega came about somewhat later in 2012, where the gamingfreedom code began sometime around the 2011 time (though the concept is much older, inherent in the original gamingfreedom vision as developed during 2009) . It just sort of didn't dawn on us until recently that the work would be useful for other people.''<br />
<br />
''So, bodega might be interesting as a side project, a new technology in its own right, where ocs-server is a nearly drop-in solution which should be able to work much easier with the existing functionality already available (we already use attica in gluon, which works fine, so we decided to just replace the problematic part rather than start from scratch).''<br />
</blockquote></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server&diff=44383Ocs-server2015-10-01T14:31:01Z<p>Snizzo: /* Current status of development */</p>
<hr />
<div>[https://projects.kde.org/projects/playground/www/ocs-server ocs-server] is an open source implementation of the [http://en.wikipedia.org/wiki/Open_Collaboration_Services Open Collaboration Services]<br />
<br />
:Mailing List: not present<br />
:IRC Channel: #ocs on freenode<br />
:QuickGit: http://quickgit.kde.org/?p=ocs-server.git<br />
<br />
Ocs-server aims to write a working implementation of the OCS protocol. It's first objective is to provide KDE an open source content distribution system server-side that can take advantage of already existing technologies like libAttica, kNewStuff etc. We're currently using this server (stable version) for the Gluon Project.<br />
<br />
* [Installation] [[Ocs-server/Install/Configuring a webserver as host| Configuring a webserver as host]]<br />
* [Installation] [[Ocs-server/Install/First run wizard| First run wizard]]<br />
<br />
<br />
Hey! Did you know ocs-server is built on top of in-house [[Ocs-server/Gfx4 | Gfx4 web framework]]?<br />
<br />
== Current status of development ==<br />
<br />
'''ocs-server 0.1 technology preview is out!!! [http://gamingfreedom.org/download/ocs-server_0.1_techprev.tar.gz Download]'''<br />
<br />
[UPDATE 1st October 2015]: Our server works partially when using it as primary service provider with KDE instead of opendesktop one. We're now working to mimick the current official server in every aspect, implementing missing calls/attributes that are obscure and/or not documented enough.<br />
<br />
Here is a timeline we're currently following: [https://community.kde.org/Ocs-server/Timeline Feature parity timeline]<br />
<br />
[UPDATE 1st June 2015]: As for now, we're gathering info about what is needed exactly to have a minimal working server that could replace current third-party software (kde-look) and have it run with "Get Hot New Stuff" software.<br />
We also have a working implementation running for the Gluon Project. Check out our [http://gamingfreedom.org/index.php webclient] or directly query our [http://gamingfreedom.org/v1/config server].<br />
<br />
== Contributing to ocs-server ==<br />
<br />
The ocs-server developers maintain a list of active tasks. We have a todo active on [https://todo.kde.org/?controller=board&action=show&project_id=76 todo.kde.org] As for now, you can talk with us on our IRC channel #ocs on freedone.<br />
<br />
== What about bodega? ==<br />
<br />
We had discussed this concern in a blog post about possible uses of the ocs-server as Plasma content delivery system. Here is an extract of [http://playgfx.blogspot.com/2015/03/ideas-to-restructure-plasma-content.html?showComment=1426326876089#c3121703366432336002 this original comment] written by KDE developer Dan Leinir Turthra Jensen.<br />
<br />
<blockquote><br />
''This project and bodega don't in any real sense have any relationship - they both try to solve similar issues (opendesktop.org is practically unmaintained, has a worrying bus factor, is closed, etc), but take different approaches (ocs-server uses established (though of course not faultless) web technologies and the same web api as the existing solution, bodega attempts to build the complete system from scratch using a developing and at times troublesome technology).''<br />
<br />
''More importantly, though, bodega came about somewhat later in 2012, where the gamingfreedom code began sometime around the 2011 time (though the concept is much older, inherent in the original gamingfreedom vision as developed during 2009) . It just sort of didn't dawn on us until recently that the work would be useful for other people.''<br />
<br />
''So, bodega might be interesting as a side project, a new technology in its own right, where ocs-server is a nearly drop-in solution which should be able to work much easier with the existing functionality already available (we already use attica in gluon, which works fine, so we decided to just replace the problematic part rather than start from scratch).''<br />
</blockquote></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Timeline&diff=44349Ocs-server/Timeline2015-09-23T16:45:15Z<p>Snizzo: </p>
<hr />
<div>'''IMPORTANT:''' when "implement all" is written we mean a complete compatibility with the current reference implementation from api.opendesktop.org . The development process will probably follow a 1:1 copy debugging that server requests/response since the current protocol specification isn't in perfect shape.<br />
<br />
* (sep) 23-27: Implement some missing PERSON calls (with possible spec update)<br />
* (sep-oct) 28-4: Implement all missing PERSON calls (with possible spec update)<br />
* (oct) 5-11: Implement some missing CONTENT calls and parameters (with possible spec update)<br />
* (oct) 12-18: Implement all missing CONTENT calls and parameters (with possible spec update)</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Timeline&diff=44348Ocs-server/Timeline2015-09-23T16:44:58Z<p>Snizzo: Created page with "'''IMPORTANT:''' when "implement all" is written we mean a complete compatibility with the current reference implementation from api.opendesktop.org . The development process ..."</p>
<hr />
<div>'''IMPORTANT:''' when "implement all" is written we mean a complete compatibility with the current reference implementation from api.opendesktop.org . The development process will probably follow a 1:1 copy debugging that server requests/response since the current protocol specification isn't in perfect shape.<br />
<br />
(sep) 23-27: Implement some missing PERSON calls (with possible spec update)<br />
(sep-oct) 28-4: Implement all missing PERSON calls (with possible spec update)<br />
(oct) 5-11: Implement some missing CONTENT calls and parameters (with possible spec update)<br />
(oct) 12-18: Implement all missing CONTENT calls and parameters (with possible spec update)</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server&diff=43588Ocs-server2015-07-30T14:46:39Z<p>Snizzo: </p>
<hr />
<div>[https://projects.kde.org/projects/playground/www/ocs-server ocs-server] is an open source implementation of the [http://en.wikipedia.org/wiki/Open_Collaboration_Services Open Collaboration Services]<br />
<br />
:Mailing List: not present<br />
:IRC Channel: #ocs on freenode<br />
:QuickGit: http://quickgit.kde.org/?p=ocs-server.git<br />
<br />
Ocs-server aims to write a working implementation of the OCS protocol. It's first objective is to provide KDE an open source content distribution system server-side that can take advantage of already existing technologies like libAttica, kNewStuff etc. We're currently using this server (stable version) for the Gluon Project.<br />
<br />
* [Installation] [[Ocs-server/Install/Configuring a webserver as host| Configuring a webserver as host]]<br />
* [Installation] [[Ocs-server/Install/First run wizard| First run wizard]]<br />
<br />
<br />
Hey! Did you know ocs-server is built on top of in-house [[Ocs-server/Gfx4 | Gfx4 web framework]]?<br />
<br />
== Current status of development ==<br />
<br />
'''ocs-server 0.1 technology preview is out!!! [http://gamingfreedom.org/download/ocs-server_0.1_techprev.tar.gz Download]'''<br />
<br />
As for now, we're gathering info about what is needed exactly to have a minimal working server that could replace current third-party software (kde-look) and have it run with "Get Hot New Stuff" software.<br />
We also have a working implementation running for the Gluon Project. Check out our [http://gamingfreedom.org/index.php webclient] or directly query our [http://gamingfreedom.org/v1/config server].<br />
<br />
== Contributing to ocs-server ==<br />
<br />
The ocs-server developers maintain a list of active tasks. We have a todo active on [https://todo.kde.org/?controller=board&action=show&project_id=76 todo.kde.org] As for now, you can talk with us on our IRC channel #ocs on freedone.<br />
<br />
== What about bodega? ==<br />
<br />
We had discussed this concern in a blog post about possible uses of the ocs-server as Plasma content delivery system. Here is an extract of [http://playgfx.blogspot.com/2015/03/ideas-to-restructure-plasma-content.html?showComment=1426326876089#c3121703366432336002 this original comment] written by KDE developer Dan Leinir Turthra Jensen.<br />
<br />
<blockquote><br />
''This project and bodega don't in any real sense have any relationship - they both try to solve similar issues (opendesktop.org is practically unmaintained, has a worrying bus factor, is closed, etc), but take different approaches (ocs-server uses established (though of course not faultless) web technologies and the same web api as the existing solution, bodega attempts to build the complete system from scratch using a developing and at times troublesome technology).''<br />
<br />
''More importantly, though, bodega came about somewhat later in 2012, where the gamingfreedom code began sometime around the 2011 time (though the concept is much older, inherent in the original gamingfreedom vision as developed during 2009) . It just sort of didn't dawn on us until recently that the work would be useful for other people.''<br />
<br />
''So, bodega might be interesting as a side project, a new technology in its own right, where ocs-server is a nearly drop-in solution which should be able to work much easier with the existing functionality already available (we already use attica in gluon, which works fine, so we decided to just replace the problematic part rather than start from scratch).''<br />
</blockquote></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/OCS_Client&diff=43580Ocs-server/Gfx4/OCS Client2015-07-30T10:27:24Z<p>Snizzo: Created page with "'''OCSClient''' is a basic HTTP client with support for http authentication, uploading files and get/post requests. It also automatically handles the correct path to OCS serv..."</p>
<hr />
<div>'''OCSClient''' is a basic HTTP client with support for http authentication, uploading files and get/post requests. It also automatically handles the correct path to OCS server and xml parsing, returning an associative array.<br />
<br />
Requires '''cURL''' and '''php5-curl'''.<br />
--------<br />
Here is an example GET post with authentication:<br />
<syntaxhighlight lang="php"><br />
$client = new OCSClient(EConfig::$data["ocs"]["host"]);<br />
$client->set_auth_info("test","password");<br />
$check = $client->get("v1/friend/data/example");<br />
</syntaxhighlight><br />
Check will contain the resulting array.<br />
--------<br />
Example of POST request with postdata.<br />
<syntaxhighlight lang="php"><br />
$postdata = array(<br />
"message" => "would you be my friend?"<br />
);<br />
$client = new OCSClient(EConfig::$data["ocs"]["host"]);<br />
$client->set_auth_info("test","password");<br />
$client->set_post_data($postdata);<br />
$check = $client->post("v1/friend/invite/example ");<br />
</syntaxhighlight><br />
---------<br />
Example of POST request with postdata and upload of a file:<br />
<syntaxhighlight lang="php"><br />
$postdata = array(<br />
"message" => "would you be my friend?"<br />
);<br />
$client = new OCSClient(EConfig::$data["ocs"]["host"]);<br />
$client->set_auth_info("test","password");<br />
$client->set_upload_file($_FILES['inputScreenshot1']['tmp_name']);<br />
$client->set_post_data($postdata);<br />
$check = $client->post("v1/friend/invite/example ");<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=43579Ocs-server/Gfx42015-07-30T10:04:10Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/XML_utilities&diff=43578Ocs-server/Gfx4/XML utilities2015-07-30T10:02:46Z<p>Snizzo: Created page with "Gfx contains some XML utilities. * '''static bool XMLParser::is_assoc($array)''' -> checks if $array is associative or not * '''static array XMLParser::to_array($contents, $f..."</p>
<hr />
<div>Gfx contains some XML utilities.<br />
<br />
* '''static bool XMLParser::is_assoc($array)''' -> checks if $array is associative or not<br />
* '''static array XMLParser::to_array($contents, $force_multiple=array())''' -> converts an xml tree to an associative array</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Network_utilities&diff=43577Ocs-server/Gfx4/Network utilities2015-07-30T09:55:21Z<p>Snizzo: </p>
<hr />
<div>GFX permits also to interact with other APIs and websites through '''ENetworkSocket''' that is an object that makes http requests with get and post data to the specified address.<br />
------------<br />
<syntaxhighlight lang="php"><br />
$s = new ENetworkSocket("http://localhost");<br />
$c = $s->get("index.php");<br />
</syntaxhighlight><br />
This will set content of '''$c''' to the content of ''http://localhost/index.php'' performing a get request.<br />
------------<br />
<syntaxhighlight lang="php"><br />
$postdata = array(<br />
"name" => "john",<br />
"surname" => "smith"<br />
)<br />
<br />
$s = new ENetworkSocket("http://localhost");<br />
$c = $s->post("index.php", $postdata);<br />
</syntaxhighlight><br />
<br />
This will set content of $c to the content of ''http://localhost/index.php'' performing a post request and<br />
sending '''$postdata''' as '''$_POST''' value.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Network_utilities&diff=43497Ocs-server/Gfx4/Network utilities2015-07-28T16:38:54Z<p>Snizzo: Created page with "GFX permits also to interact with other APIs and websites through ENetworkSocket. ENetworkSocket is an object that makes http requests with get and post data to the specified ..."</p>
<hr />
<div>GFX permits also to interact with other APIs and websites through ENetworkSocket.<br />
ENetworkSocket is an object that makes http requests with get and post data to the specified address.<br />
<br />
$s = new ENetworkSocket("http://localhost");<br />
$c = $s->get("index.php");<br />
<br />
This will set content of $c to the content of http://localhost/index.php performing a get request.<br />
<br />
$postdata = array(<br />
"name" => "john",<br />
"surname" => "smith"<br />
)<br />
<br />
$s = new ENetworkSocket("http://localhost");<br />
$c = $s->post("index.php", $postdata);<br />
<br />
This will set content of $c to the content of http://localhost/index.php performing a post request and<br />
sending $postdata as $_POST value.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Image_processing&diff=43496Ocs-server/Gfx4/Image processing2015-07-28T16:05:50Z<p>Snizzo: Created page with "There is a very primitive class that abstacts images called EImage. Makes a thumbnail mantaining the aspect ratio. $maxwidth and $maxheight are just the limits. '''WARNING'''..."</p>
<hr />
<div>There is a very primitive class that abstacts images called EImage.<br />
<br />
Makes a thumbnail mantaining the aspect ratio. $maxwidth and $maxheight are just the limits. '''WARNING''': works only with JPG or PNG and requires php-gd server extension.<br />
<br />
* '''EImage::make_thumbnail($from,$to,$maxwidth,$maxheight)''' -> Makes a thumbnail using $from as origin file, $to as destination and $maxwidth and $maxheight as width and height limits. Keeps proportions untouched.</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Filesystem_utilities&diff=43495Ocs-server/Gfx4/Filesystem utilities2015-07-28T15:57:42Z<p>Snizzo: Created page with "GFX offers a static class as a file system helper. Small reference: '''EFileSystem::get_file_extension(string $filename)''' -> returns string extension<br> '''EFileSystem::ge..."</p>
<hr />
<div>GFX offers a static class as a file system helper. Small reference:<br />
<br />
'''EFileSystem::get_file_extension(string $filename)''' -> returns string extension<br><br />
'''EFileSystem::get_file_name(string $filename)''' -> returns string name<br><br />
'''EFileSystem::rename_file(string $from, string $to)''' -> rename file<br><br />
'''EFileSystem::move_uploaded_file_in($path,$newname)''' -> move uploaded file to $path and change name to $newname<br><br />
'''EFileSystem::get_uploaded_file_name()''' -> returns original uploaded file name.<br></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/get_post_headers&diff=43494Ocs-server/Gfx4/get post headers2015-07-28T15:54:46Z<p>Snizzo: </p>
<hr />
<div>GFX provides a class that automatically handles and parse GET and POST data.<br />
So instead of directly accessing those arrays you should use EHeaderDataParser.<br />
----------<br />
If you have to output your data you can use:<br />
<br />
'''EHeaderDataParser::out_get(string $name);'''<br><br />
'''EHeaderDataParser::out_post(string $name);'''<br><br />
-----------------<br />
If you have to insert your data into database and you need them to be safe you can use:<br />
<br />
'''EHeaderDataParser::secure_get(string $name);'''<br><br />
'''EHeaderDataParser::secure_post(string $name);'''<br><br />
------------------<br />
If you need all your data to be safe you can easily do:<br />
<br />
'''EHeaderDataParser::safeAll();'''<br />
------------------<br />
You can also set GET and POST manually using:<br />
<br />
'''EHeaderDataParser::add_get(string $key, string $value);'''<br><br />
'''EHeaderDataParser::add_post(string $key, string $value);'''<br><br />
--------------<br />
You can check existance of GET and POST manually using:<br />
<br />
'''EHeaderDataParser::exists_get(string $key);'''<br><br />
'''EHeaderDataParser::exists_post(string $key);'''<br><br />
--------------<br />
You can use this class to get/set cookie data via:<br />
<br />
'''EHeaderDataParser::get_cookie(string $key);'''<br><br />
'''EHeaderDataParser::set_cookie(string $key, $value);'''<br><br />
'''EHeaderDataParser::del_cookie(string $key);'''<br><br />
<br />
This can result particularly useful when you need to use EModel's insert and update<br />
but not all the data comes from user request.<br />
----------------<br />
If you want to take those variables fast and you can't decide you can choose<br />
the unsafe way using:<br />
<br />
'''EHeaderDataParser::get(string $key);'''<br><br />
'''EHeaderDataParser::post(string $key);'''<br><br />
----------------<br />
If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2)<br />
you can use this handy method to have that added to the module's stack.<br />
<br><br />
'''EHeaderDataParser::add_from_string(string $str);'''<br />
----------------<br />
You can get the script page with all exta data(''&data=example?...'') erased by using:<br />
<br><br />
'''EHeaderDataParser::erase_get_data(string $url);'''<br />
-----------------<br />
EHeaderDataParser can be configure in the generic config file of gfx, which can be located<br />
here: ''gfx3/config/generic.conf.php''.<br />
<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
protectheaders|yes<br />
protectheaders|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/get_post_headers&diff=43493Ocs-server/Gfx4/get post headers2015-07-28T15:42:42Z<p>Snizzo: Created page with "GFX provides a class that automatically handles and parse GET and POST data. So instead of directly accessing those arrays you should use EHeaderDataParser. ---------- If you ..."</p>
<hr />
<div>GFX provides a class that automatically handles and parse GET and POST data.<br />
So instead of directly accessing those arrays you should use EHeaderDataParser.<br />
----------<br />
If you have to output your data you can use:<br />
<br />
'''EHeaderDataParser::out_get(string $name);'''<br><br />
'''EHeaderDataParser::out_post(string $name);'''<br><br />
-----------------<br />
If you have to insert your data into database and you need them to be safe you can use:<br />
<br />
'''EHeaderDataParser::secure_get(string $name);'''<br><br />
'''EHeaderDataParser::secure_post(string $name);'''<br><br />
------------------<br />
If you need all your data to be safe you can easily do:<br />
<br />
'''EHeaderDataParser::safeAll();'''<br />
------------------<br />
You can also set GET and POST manually using:<br />
<br />
'''EHeaderDataParser::add_get(string $key, string $value);'''<br><br />
'''EHeaderDataParser::add_post(string $key, string $value);'''<br><br />
--------------<br />
You can check existance of GET and POST manually using:<br />
<br />
'''EHeaderDataParser::exists_get(string $key);'''<br><br />
'''EHeaderDataParser::exists_post(string $key);'''<br><br />
--------------<br />
You can use this class to get/set cookie data via:<br />
<br />
'''EHeaderDataParser::get_cookie(string $key);'''<br><br />
'''EHeaderDataParser::set_cookie(string $key, $value);'''<br><br />
'''EHeaderDataParser::del_cookie(string $key);'''<br><br />
<br />
This can result particularly useful when you need to use EModel's insert and update<br />
but not all the data comes from user request.<br />
----------------<br />
If you want to take those variables fast and you can't decide you can choose<br />
the unsafe way using:<br />
<br />
'''EHeaderDataParser::get(string $key);'''<br><br />
'''EHeaderDataParser::post(string $key);'''<br><br />
----------------<br />
If you have a string formed as a standard get key/value list (e.g. example=val&example2=val2)<br />
you can use this handy method to have that added to the module's stack.<br />
<br><br />
'''EHeaderDataParser::add_from_string(string $str);'''<br />
-----------------<br />
EHeaderDataParser can be configure in the generic config file of gfx, which can be located<br />
here: ''gfx3/config/generic.conf.php''.<br />
<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
protectheaders|yes<br />
protectheaders|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Debugging&diff=43490Ocs-server/Gfx4/Debugging2015-07-28T13:56:20Z<p>Snizzo: Created page with "The only debugging tool Gfx provides is a kind of a breakpoint where the stack trace will be printed. It can be called with '''eval(DEBUG_BREAKPOINT);'''"</p>
<hr />
<div>The only debugging tool Gfx provides is a kind of a breakpoint where the stack trace will be printed.<br />
It can be called with '''eval(DEBUG_BREAKPOINT);'''</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Errors_and_logging&diff=43487Ocs-server/Gfx4/Errors and logging2015-07-28T13:54:40Z<p>Snizzo: Created page with "Gfx provides some functions to handle error management and logging with the '''ELog''' class. Short list of static methods that can be used anywhere: * '''ELog::error($e)''' ..."</p>
<hr />
<div>Gfx provides some functions to handle error management and logging with the '''ELog''' class.<br />
<br />
Short list of static methods that can be used anywhere:<br />
* '''ELog::error($e)''' -> prints/writes/ignore an error depending on configuration. Error is critical and will stop the script instantly.<br />
* '''ELog::warning($e)''' -> prints/writes/ignore a warning depending on configuration. Warning is not critical and the script will continue its execution<br />
* '''ELog::d($d)''' -> echoes $d in ''pre'' tags<br />
* '''ELog::pd($d)''' -> var_dumps $d in ''pre'' tags<br />
* '''ELog::clear_log()''' -> erases all the content of log files (''error.log'' and ''warning.log'')</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Database&diff=43486Ocs-server/Gfx4/Database2015-07-28T13:37:28Z<p>Snizzo: Created page with "In Gfx there's the static class EDatabase which, if enabled, loads at the start of the script. It makes uses of a configuration file called ''database.conf.php'' that must con..."</p>
<hr />
<div>In Gfx there's the static class EDatabase which, if enabled, loads at the start of the script. It makes uses of a configuration file called ''database.conf.php'' that must contain correct values of a MySQL database. Works on more db drivers is in the roadmap.<br />
<br />
Small reference:<br />
<br />
* '''EDatabase::q($sql_query)''' -> execute $sql_query<br />
* '''EDatabase::sq($sql_query)''' -> execute $sql_query and returns the first result. Useful for counts etc. <br />
* '''EDatabase::table_exists($table)''' -> check if table exists and return boolean.<br />
* '''EDatabase::last_insert_id()''' -> returns the id of the last inserted row.<br />
<br />
Database functionalities can be enabled/disabled in the generic config file ("config/generic.conf.php"):<br />
Example:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
database|yes<br />
database|no<br />
</syntaxhighlight><br />
<br />
------<br />
===database.conf.php===<br />
Example of a valid configuration file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=43484Ocs-server/Gfx42015-07-28T11:51:02Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [[Ocs-server/Gfx4/3rd party libraries | 3rd party libraries]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/URL_Rewriting&diff=43483Ocs-server/Gfx4/URL Rewriting2015-07-28T11:47:06Z<p>Snizzo: </p>
<hr />
<div>Gfx contains a simple but working url rewriter that works in conjunction with the MVC system. It basically translates an URL asked by the client into a new one elaborated by the server.<br />
<br />
All the rules are in the file ''config/rewrite.conf.php''. This is an example rewrite config file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
/help|/help/index<br />
/yourpath|/install/index<br />
</syntaxhighlight><br />
<br />
Notice how the first URL is the one written by the client and the second one is that one elaborated by the server, when handling the request of a webpage.<br />
<br />
Everything that comes after a controller is usually handled as a parameter, except when you rewrite the URL.<br />
So, for example, calling ''/help/index/arg1/arg2/arg3'' will be directly passed as an argument array to the method '''index($args)''' of the controller '''HelpController'''. Every other standard GET parameter can be passed as usual:<br />
http://www.example.com/help/index?x=5<br />
http://www.example.com/help/index/?x=5<br />
http://www.example.com/help/index/arg1/arg2?x=5<br />
http://www.example.com/help/index/arg1/arg2/?x=5<br />
-------------------<br />
A little example:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
/|/main/index|exact<br />
/help|/help/index|normal<br />
/games|/games/lates|normal<br />
</syntaxhighlight><br />
<br />
And then it will rewrite doing a simple string replace, but internally on the engine.<br />
So in this case ''/help'' will be rewritten internally as ''/help/index'' and therefore<br />
calling the '''index()''' method of the HelpController class defined.<br />
<br />
If more rules are matching for the same url, the one with the longest key will be<br />
used. Example:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
/help/games|/help/games/latest|normal<br />
/help|/help/index|normal<br />
</syntaxhighlight><br />
Only the first rule will be considered, even if it's defined before the second one.<br />
<br />
Every other parameter added after those slashes will be handled as parameter that will<br />
be passed to the controller's method via the '''$args''' array or can be retrieved by '''EController''' public methods. See Controller page for further documentation.<br />
<br />
Example of '''HelpController''':<br />
<syntaxhighlight lang="php"><br />
class HelpController extends EController {<br />
public function index($args){<br />
var_dump($args);<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
Example of user browser opening the page ''www.example.com/help/index/arg1/arg2'':<br />
{<br />
"arg1",<br />
"arg2"<br />
}<br />
<br />
Every other parameter passed as standard GET like ''?var1=val1&var2=val2'' is correctly<br />
set on '''EHeaderDataParser'''.<br />
<br />
This kind of parameter management works also for rewritten URLs. For example it would<br />
exactly be the same if the user calls: ''www.example.com/help/arg1/arg2''<br />
without the "/index" part.<br />
<br />
This is the "normal" rewrite.<br />
-------------------------<br />
The "exact" mode rewrites a URL only if it matches exactly so additional parameters via /<br />
aren't handled and accepted. Normal GET parameters are handled as usual. <br />
<br />
In order to build a nice title (also if it's not useful for your app logic you should use:<br />
<syntaxhighlight lang="php"> <br />
$url = ERewriter::prettify("I'm a terrible title");<br />
</syntaxhighlight><br />
Rewriting can be enabled/disabled via generic.conf.php:<br />
<syntaxhighlight lang="php"><br />
<?php die("You cannot see config in here."); ?><br />
rewrite|yes<br />
rewrite|no<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4/Global_and_local_configuration&diff=43482Ocs-server/Gfx4/Global and local configuration2015-07-28T11:33:03Z<p>Snizzo: </p>
<hr />
<div>GFX use a class to load config every time from a bunch of files. You can also<br />
create your config and find them placed under EConfig.<br />
<br />
Most of the gfx-related configurations are on the file '''/config/generic.conf.php'''. If you create the folder "config" on a subfolder of gfx, that will behave as a subsite on its own, with its MVC, rewriting and libs.<br />
<br />
If you edit your /config/database.conf.php like this:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
name|test<br />
host|localhost<br />
user|root<br />
password|asd<br />
</syntaxhighlight><br />
<br />
You will automatically find them mapped into an associative array:<br />
<syntaxhighlight lang="php"><br />
EConfig::$data["database"]["name"];<br />
</syntaxhighlight><br />
<br />
Note that '''"database"''' is the name of the config file without extensions and '''"name"''' is the variable name.<br />
<br />
Also note that PHP code in config files will just be ignored, so it's good practice to put<br />
a '''die();''' on the first line so no one will be able to see your inner configuration.<br />
<br />
You can also use multi value properties like this:<br />
--------------<br />
'''Filename: /config/myname.conf.php'''<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
info|Claudio|Desideri|kde<br />
</syntaxhighlight><br />
<br />
If you access '''EConfig::$data["myname"]["info"];''' you get an array containing all the values.<br />
You can iterate on it using:<br />
<syntaxhighlight lang="php"><br />
foreach(EConfig::$data["myname"]["info"] as $item){<br />
echo $item;<br />
}<br />
</syntaxhighlight><br />
<br />
This will print:<br />
Claudio<br />
Desideri<br />
kde<br />
<br />
And via code that will be accessible using:<br />
<syntaxhighlight lang="php"><br />
$info = EConfig::$data["myname"]["info"];<br />
$info[0];<br />
$info[1];<br />
$info[2];<br />
</syntaxhighlight><br />
---------<br />
===Generic.conf.php===<br />
Each website (or subsite) must have a ''generic.conf.php'' file inside the ''config'' folder. These are the properties that can be setted through generic:<br />
* '''render''': can be "yes" or "no"<br />
* '''protectheaders''': can be "yes" or "no"<br />
* '''database''': can be "yes" or "no"<br />
* '''rewrite''': can be "yes" or "no"<br />
* '''users''': can be "yes" or "no"<br />
* '''mvc''': can be "yes" or "no"<br />
* '''errormode''': can be "yes" or "no"<br />
* '''enabled''': can be "normal", "formatted", "file" or "suppressed"<br />
* '''password''': password of your choice<br />
<br />
Example of a ''generic.conf.php'' file:<br />
<syntaxhighlight lang="php"><br />
<?php die(); ?><br />
render|yes<br />
protectheaders|yes<br />
database|yes<br />
rewrite|yes<br />
users|no<br />
mvc|yes<br />
errormode|normal<br />
enabled|protected<br />
password|esempio<br />
</syntaxhighlight></div>Snizzohttps://community.kde.org/index.php?title=Ocs-server/Gfx4&diff=43481Ocs-server/Gfx42015-07-28T11:11:49Z<p>Snizzo: </p>
<hr />
<div>Gfx4 is an in-house small web framework born inside KDE, and is thought and extended around the necessities of ocs-server project. It can, however, be and has been used for general web-based projects successfully.<br />
<br />
Official documentation:<br />
* [[Ocs-server/Gfx4/Folders and MVC | Folders and Page Properties]]<br />
* [[Ocs-server/Gfx4/Global and local configuration | Global and local configuration]]<br />
* [[Ocs-server/Gfx4/Models | Models]]<br />
* [[Ocs-server/Gfx4/Views | Views]]<br />
* [[Ocs-server/Gfx4/Controllers | Controllers]]<br />
* [[Ocs-server/Gfx4/URL Rewriting | URL Rewriting]]<br />
* [[Ocs-server/Gfx4/Database | Database]]<br />
* [[Ocs-server/Gfx4/Errors and logging | Errors and logging]]<br />
* [[Ocs-server/Gfx4/Debugging | Debugging]]<br />
* [[Ocs-server/Gfx4/get post headers | GET, POST and header data]]<br />
* [[Ocs-server/Gfx4/Filesystem utilities | Filesystem utilities]]<br />
* [[Ocs-server/Gfx4/Image processing | Image processing]]<br />
* [[Ocs-server/Gfx4/Page properties | Page properties]]<br />
* [[Ocs-server/Gfx4/Network utilities | Network utilities]]<br />
* [[Ocs-server/Gfx4/XML utilities | XML utilities]]<br />
* [[Ocs-server/Gfx4/3rd party libraries | 3rd party libraries]]<br />
* [Optional] [[Ocs-server/Gfx4/OCS Client | OCS Client]]</div>Snizzo