Merge branch 'master' of mojotrollz.eu:system

Conflicts:
	sai/modules/saimod_sys_locale/saimod_sys_locale.php
	sai/page/default_page/default_page.php
This commit is contained in:
messerbill 2013-09-25 13:09:18 +02:00
commit e9d3240c58
35 changed files with 849 additions and 409 deletions

View File

@ -7,11 +7,11 @@ class api {
public static function run($verifyclassname,$apiclassname,$params,$group = self::DEFAULT_GROUP,$strict = true,$default = false){
//Verify Class
if(!class_exists($verifyclassname)){
throw new \SYSTEM\LOG\ERROR("Verify Class given to the api does not exist.");}
throw new \SYSTEM\LOG\ERROR("Verify Class given to the api does not exist: '".$verifyclassname."'");}
//API Class
if(!class_exists($apiclassname)){
throw new \SYSTEM\LOG\ERROR("API Class given to the api does not exist.");}
throw new \SYSTEM\LOG\ERROR("API Class given to the api does not exist: '".$apiclassname."'");}
//check parameters
if( !isset($params) || !is_array($params) || count($params) <= 0){
@ -84,13 +84,13 @@ class api {
$commands[count($commands)-1][1] != $item[\SYSTEM\DBD\APITable::FIELD_PARENTVALUE]){
continue;}
//all parameters are required
//all parameters are NOT required - just continue
if(!isset($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
throw new \SYSTEM\LOG\ERROR('Parameter missing: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME]);}
continue;}
//verify parameter
if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) ||
!$verifyclassname->$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]($params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
if( !method_exists($verifyclassname, $item[\SYSTEM\DBD\APITable::FIELD_VERIFY]) ||
!call_user_func(array($verifyclassname,$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]),$params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]])){
throw new \SYSTEM\LOG\ERROR('Parameter type missmacht or Missing Verifier. Param: '.$item[\SYSTEM\DBD\APITable::FIELD_NAME].' Verifier: '.$item[\SYSTEM\DBD\APITable::FIELD_VERIFY]);}
$parameters_opt[] = array($item, $params[$item[\SYSTEM\DBD\APITable::FIELD_NAME]]);
@ -99,8 +99,8 @@ class api {
//strict check
if( $strict &&
count($params) != (count($parameters) + count($commands)) ){
throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid');}
count($params) != (count($parameters) + count($commands) + count($parameters_opt)) ){
throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid: '.$_SERVER["REQUEST_URI"]);}
//Function Name
$call_funcname = "";
@ -137,7 +137,7 @@ class api {
private static function getApiTree($group){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME_PG .' WHERE `'.\SYSTEM\DBD\APITable::FIELD_GROUP.'` = '.$group.' ORDER BY "'.\SYSTEM\DBD\APITable::FIELD_ID.'"');
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME_PG .' WHERE "'.\SYSTEM\DBD\APITable::FIELD_GROUP.'" = '.$group.' ORDER BY "'.\SYSTEM\DBD\APITable::FIELD_ID.'"');
} else {
$res = $con->query('SELECT * FROM '.\SYSTEM\DBD\APITable::NAME_MYS.' WHERE `'.\SYSTEM\DBD\APITable::FIELD_GROUP.'` = '.$group.' ORDER BY '.\SYSTEM\DBD\APITable::FIELD_ID);
}

View File

@ -18,13 +18,13 @@ class api_login {
*/
public static function call_account_action_login($username, $password_sha, $password_md5){
return \SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $username, $password_sha, $password_md5);}
return \SYSTEM\SECURITY\Security::login($username, $password_sha, $password_md5);}
public static function call_account_action_logout(){
return \SYSTEM\SECURITY\Security::logout();}
public static function call_account_action_isloggedin(){
return \SYSTEM\SECURITY\Security::isLoggedIn();}
public static function call_account_action_check($rightid){
return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(),$rightid);}
return \SYSTEM\SECURITY\Security::check($rightid);}
public static function call_account_action_create($username, $password_sha, $email, $locale){
return \SYSTEM\SECURITY\Security::create(\SYSTEM\system::getSystemDBInfo(), $username, $password_sha, $email, $locale);}
return \SYSTEM\SECURITY\Security::create($username, $password_sha, $email, $locale);}
}

View File

@ -3,17 +3,6 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/page','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/page/default_page','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/page/default_module','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_login','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_log','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_security','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_mod','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_config','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_calls','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_locale','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/modules/saimod_sys_cache','SYSTEM\SAI');
require_once dirname(__FILE__).'/modules/autoload_modules.php';
require_once dirname(__FILE__).'/modules/register_modules.php';

View File

@ -0,0 +1,13 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__),'SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_sai','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_login','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_log','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_security','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_mod','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_config','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_calls','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_locale','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_cache','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_docu','SYSTEM\SAI');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_sys_todo','SYSTEM\SAI');

View File

@ -1,12 +1,13 @@
<?php
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_sai');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_login');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_log');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_security');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_mod');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_config');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_calls');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_locale');
\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_cache');
//\SYSTEM\SAI\sai::getInstance()->register_sys('\SYSTEM\SAI\saimod_sys_docu');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_sai');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_login');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_log');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_security');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_mod');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_config');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_calls');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_locale');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_cache');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_todo');
\SYSTEM\SAI\sai::register_sys('\SYSTEM\SAI\saimod_sys_docu');

View File

@ -2,7 +2,7 @@
namespace SYSTEM\SAI;
class saimod_sys_cache extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
public static function sai_mod__SYSTEM_SAI_saimod_sys_cache(){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT COUNT(*)as "count" FROM system.cache');
@ -39,10 +39,10 @@ class saimod_sys_cache extends \SYSTEM\SAI\SaiModule {
return 'success';
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_cache">Cache</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_cache">Cache</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_cache_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_cache_flag_js(){}
}

View File

@ -2,52 +2,44 @@
namespace SYSTEM\SAI;
class saimod_sys_calls extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
$result = '<h3>Api Calls</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'flag'.'</th>'.'<th>'.'parentID'.'</th>'.'<th>'.'parentValue'.'</th>'.'<th>'.'name'.'</th>'.'<th>'.'allowedValues'.'</th>'.'</tr>';
public static function sai_mod__SYSTEM_SAI_saimod_sys_calls(){
$last_group = -1;
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.api_calls ORDER BY "ID" ASC;');
$res = $con->query('SELECT * FROM system.api ORDER BY "group", "ID" ASC;');
} else {
$res = $con->query('SELECT * FROM system_api_calls ORDER BY ID ASC;');
$res = $con->query('SELECT * FROM system_api ORDER BY "group", "ID" ASC;');
}
$result = "";
while($r = $res->next()){
$result .= '<tr class="'.self::tablerow_class($r['flag']).'">'.'<td>'.$r['ID'].'</td>'.'<td>'.$r['flag'].'</td>'.'<td>'.$r['parentID'].'</td>'.'<td>'.$r['parentValue'].'</td>'.'<td>'.$r['name'].'</td>'.'<td>'.$r['allowedValues'].'</td>'.'</tr>';}
$result .= '</table>';
$result .= '<h3>Page Calls</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'flag'.'</th>'.'<th>'.'parentID'.'</th>'.'<th>'.'parentValue'.'</th>'.'<th>'.'name'.'</th>'.'<th>'.'allowedValues'.'</th>'.'</tr>';
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.page_calls ORDER BY "ID" ASC;');
} else {
$res = $con->query('SELECT * FROM system_page_calls ORDER BY ID ASC;');
if($last_group != $r['group']){
$last_group = $r['group'];
if($last_group != -1){
$result .= '</table>';}
$result .= '<h3>Api Table for Group '.$r["group"].'</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Group'.'</th>'.'<th>'.'Type'.'</th>'.'<th>'.'ParentID'.'</th>'.'<th>'.'ParentValue'.'</th>'.'<th>'.'Name'.'</th>'.'<th>'.'Verify'.'</th>'.'</tr>';
}
$result .= '<tr class="'.self::tablerow_class($r['type']).'">'.'<td>'.$r['ID'].'</td>'.'<td>'.$r['group'].'</td>'.'<td>'.$r['type'].'</td>'.'<td>'.$r['parentID'].'</td>'.'<td>'.$r['parentValue'].'</td>'.'<td>'.$r['name'].'</td>'.'<td>'.$r['verify'].'</td>'.'</tr>';
}
while($r = $res->next()){
$result .= '<tr class="'.self::tablerow_class($r['flag']).'">'.'<td>'.$r['ID'].'</td>'.'<td>'.$r['flag'].'</td>'.'<td>'.$r['parentID'].'</td>'.'<td>'.$r['parentValue'].'</td>'.'<td>'.$r['name'].'</td>'.'<td>'.$r['allowedValues'].'</td>'.'</tr>';}
$result .= '</table>';
$result .= '</table>';
return $result;
}
private static function tablerow_class($flag){
if($flag == 1){
return 'info';}
return 'success';
switch($flag){
case 0: return 'info';
case 1: return '';
default: return 'success';
}
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_calls">Calls</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_calls">API Calls</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_calls_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_calls_flag_js(){}
}

View File

@ -2,7 +2,7 @@
namespace SYSTEM\SAI;
class saimod_sys_config extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
public static function sai_mod__SYSTEM_SAI_saimod_sys_config(){
$result = '<h3>Sys Config</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'Config ID'.'</th>'.'<th>'.'Config Name'.'</th>'.'<th>'.'Value'.'</th>'.'</tr>';
@ -19,6 +19,8 @@ class saimod_sys_config extends \SYSTEM\SAI\SaiModule {
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_DBNAME. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_DBNAME'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DB_DBNAME). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_NAVIMG. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_NAVIMG'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_NAVIMG). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS'. '</td>'.'<td>'.implode(',',\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS)). '</td>'.'</tr>';
$result .= '<tr>'.'<td>'.\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG. '</td>'.'<td>'.'\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG'. '</td>'.'<td>'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG). '</td>'.'</tr>';
@ -26,10 +28,10 @@ class saimod_sys_config extends \SYSTEM\SAI\SaiModule {
return $result;
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_config">Config</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_config">Config</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_config_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_config_flag_js(){}
}

View File

@ -0,0 +1,15 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_docu extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu(){
return "todo";
}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_docu">Docu</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_docu_flag_js(){}
}

View File

@ -9,7 +9,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
return \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS);
}
public static function html_content(){
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale(){
$entries = array_merge($_POST,$_GET);
if(isset($entries[self::INPUT_VAR])){
return self::html_content_entry_edit($entries[self::INPUT_VAR]);
@ -19,7 +19,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
public static function html_content_table(){
$result = '<h3>Locale String</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;" >'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Category'.'</th>';
foreach (self::getLanguages() as $lang){
@ -36,10 +36,10 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
$res = $con->query('SELECT * FROM system_locale_string ORDER BY category ASC;');
}
while($r = $res->next()){
$result .= '<tr>'.'<td>'.$r["id"].'<br><input type="submit" class="btn-danger" value="delete" delete_ID="'.$r["id"].'">'.'</td>'.'<td>'.$r["category"].'</td>';
$result .= '<tr>'.'<td>'.$r["id"].'<br><input type="submit" class="btn-danger" value="delete" delete_ID="'.$r["id"].'">'.'<input type="submit" class="btn" value="edit" name="'.$r["id"].'">'.'</td>'.'<td>'.$r["category"].'</td>';
foreach ($languages as $columns){
//echo "+tututututututut:".$r[$columns]."nochmal tututututututut";
$result .= '<td>'.$r[$columns].'<br><input type="submit" class="btn" value="edit" lang="'.$columns.'" name="'.$r["id"].'" onclick="javascript:init__SYSTEM_SAI_saimod_sys_locale();">'.'</td>';
$result .= '<td>'.$r[$columns].'</td>';
//$_POST[$r["id"]] = $r[$columns];
}
@ -51,53 +51,47 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
return $result;
}
public static function html_content_entry_edit($entry){
//$wysiwyg_root = 'http://mojotrollz.eu/web/system/sai/modules/saimod_sys_locale/wysiwyg';
//include 'http://mojotrollz.eu/web/system/sai/modules/saimod_sys_locale/wysiwyg/php/init.php';
$result =
'<h3>'.$entry.'</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr><form method="post">';
'<tr>';
foreach (self::getLanguages() as $lang){
$result .= '<th>'.$lang.'</th>';
$languages[] = $lang;
}
$result .= '</tr>';
$result .= '</tr>';
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = $con->prepare('edit', 'SELECT * FROM system_locale_string WHERE id=? ORDER BY "category" ASC;', array($entry));
$editor_id = 0;
$res = null;
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'edit',
'SELECT * FROM system.locale_string WHERE id = $1 ORDER BY "category" ASC;',
array($entry));
} else {
$res = $con->prepare( 'edit',
'SELECT * FROM system_locale_string WHERE id = ? ORDER BY "category" ASC;',
array($entry));
}
while($r = $res->next()){
$result .= "<tr>";
foreach ($languages as $columns){
//echo "+tututututututut:".$r[$columns]."nochmal tututututututut";
//echo wysiwyg($editor_id, $entry, $r[$columns]);
$editor_id++;
$result .= '<td><textarea
onclick="tinymce.init({
mode : "textareas",
theme : "simple"
});">'.$r[$columns].'</textarea><br><input type="submit" class="btn" value="edit" lang="'.$columns.'" name="'.$r["id"].'" onclick="javascript:init__SYSTEM_SAI_saimod_sys_locale();"><br></td>';
$result .= '<td><input type="textarea" value="'.$r[$columns].'"><br><input type="submit" class="btn" value="edit" lang="'.$columns.'" name="'.$r["id"].'" onclick="javascript:init__SYSTEM_SAI_saimod_sys_locale();"><br></td>';
//$_POST[$r["id"]] = $r[$columns];
}
$result .= "</tr>";
}
$result .= '</form>';
return $result;
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_locale">DB Text</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_locale">DB Text</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){return \SYSTEM\LOG\JsonResult::toString(
array(
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/saimod_sys_locale_submit.js')
));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_locale_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/saimod_sys_locale_submit.js')));}
}

View File

@ -1,5 +1,4 @@
function init__SYSTEM_SAI_saimod_sys_log() {
function init__SYSTEM_SAI_saimod_sys_log() {
$('#truncate_table').click(function(){
$.ajax({
@ -10,7 +9,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
if(data == 1){
$('#info_box').html("deleting data...");
$('#truncate_modal').modal('hide');
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log');
$('#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log');
}else{
$('#info_box').html("You do not have the permission to truncate table!");
}
@ -24,7 +23,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
$('img#loader').show();
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log');
$('#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log');
setTimeout("$('img#loader').hide()", 1300);
@ -37,7 +36,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
$(this).addClass('active');
$('#table-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log&filter_error='+$(this).attr('id'));
$('#table-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log&filter_error='+$(this).attr('id'));
}));
}
};

View File

@ -6,7 +6,7 @@ namespace SYSTEM\SAI;
class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
private static function truncate_syslog(){
if(\SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI)){
if(\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI)){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = $con->query('TRUNCATE system.sys_log;');
return true;
@ -41,13 +41,13 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
$now = microtime(true);
$result = '<div id="table-wrapper"><table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'time ago in sec'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>';
'<tr>'.'<th>'.'time ago'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>';
while($r = $res->next()){
//TODO make time conversion on database
if(\SYSTEM\system::isSystemDbInfoPG()){
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td style="word-break: break-all;">'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</td>'.'</tr>';
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.self::time_elapsed_string(strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td style="word-break: break-all;">'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</td>'.'</tr>';
} else {
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - $r['time']).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td style="word-break: break-all;">'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</td>'.'</tr>';
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.self::time_elapsed_string($r['time']).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td style="word-break: break-all;">'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</td>'.'</tr>';
}
}
$result .= '</table></div>';
@ -56,8 +56,35 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
}
private static function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
$a = array( 12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($a as $secs => $str)
{
$d = $etime / $secs;
if ($d >= 1)
{
$r = round($d);
return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
}
}
}
public static function html_content(){
public static function sai_mod__SYSTEM_SAI_saimod_sys_log(){
if( isset($_GET['truncate'])){
@ -122,11 +149,12 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
}
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_log">Log</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_log">Log</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/sai_sys_log.js')));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/saimod_sys_log.js')));}
}

View File

@ -1,13 +1,102 @@
<div class="masthead">
<h3 class="muted">Logout</h3>
<h4 class="text-info">You are logged in</a></h4>
<h4 class="text-info">You are logged in.</h4>
</div>
<div>
<table id="userDetailsTable" class="table table-striped">
<tbody>
<tr>
<th style="width: 200px;">${ua_name}</th>
<td><span id="user_username" /></td>
</tr>
<tr>
<th>${ua_email}</th>
<td>
<span id="user_email" />
<div class="control-group" id="change_user_email" style="display: none;">
<div class="controls">
<input type="email"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_email_input"
data-validation-email-message="${ua_email_format_wrong}"
required data-validation-required-message="${login_password_required}"/>
</div>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</td>
</tr>
<tr>
<th>${ua_password}</th>
<td>
<span id="user_password">****</span>
<div class="control-group" id="change_user_password" style="display: none;">
<div class="control-group controls" id="control-group-password-old">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_old_password"
placeholder="${ua_insert_password}"
minlength="5" data-validation-minlength-message="${login_password_too_short}"
required data-validation-required-message="${login_password_required}"/>
<div id="help-block-old-password" class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_new_password1"
name="user_new_password1"
placeholder="${ua_new_password_first}"
minlength="5" data-validation-minlength-message="${login_password_too_short}"/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_new_password2"
name="user_new_password2"
placeholder="${ua_new_password_second}"
data-validation-matches-match="user_new_password1"
data-validation-matches-message="${register_password_dont_math}"/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</div>
</td>
</tr>
<tr>
<th>${ua_last_active}</th>
<td><span id="user_last_active"></span></td>
</tr>
<tr>
<th>${ua_joindate}</th>
<td><span id="user_joindate"></span></td>
</tr>
<tr>
<th>${ua_locale}</th>
<td>
<span id="user_locale"></span>
<div id="change_user_locale" style="display: none;">
<select size="1" id="change_user_locale_select">
<option value="deDE">deDE</option>
<option value="enUS">enUS</option>
</select>
</div>
</td>
</tr>
<tr>
<th style="width: 200px;">Admin Rights</th>
<td><span id="user_adminrights" />${isadmin}</td>
</tr>
</tbody>
</table>
</div>
<form class="textbox" style="padding:10px" id="logout_form">
<div class="control-group">
<div class="help-block"></div>
<input type="hidden" />
<button class="btn btn-primary" style="clear: left; height: 32px; font-size: 13px;"
type="submit"
id="logout_submit">${logout}</button>
<input type="hidden" />
<button class="btn btn-primary" style="clear: left; height: 32px; font-size: 13px;" type="submit" id="logout_submit">${logout}</button>
</div>
</form>
</form>

View File

@ -0,0 +1,87 @@
<h1>${register}</h1>
<br />
<br />
<form class="textbox" id="register_user_form">
<div class="control-group" id="register_username_control_group">
<table id="userRegisterTable" class="table table-striped">
<tbody>
<tr>
<th style="width: 200px;">${loginUsername}</th>
<td>
<div class="control-group controls">
<input type="text"
size="30"
style="margin-bottom: 15px; float: left;"
id="register_username"
placeholder="${enter_username}"
minlength="3" data-validation-minlength-message="${login_username_too_short}"
required data-validation-required-message="${login_username_required}"/>
<br/>
<div id="register-help-block-username" class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</td>
</tr>
<tr>
<th>E-Mail</th>
<td>
<div class="control-group controls">
<input type="email"
size="30"
style="margin-bottom: 15px; float: left;"
id="register_email"
placeholder="${enter_email}"
data-validation-email-message="${check_mail_format}"
required data-validation-required-message="${email_required}"/>
<br/>
<div id="register-help-block-email" class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</td>
</tr>
<tr>
<th>${loginPassword}</th>
<td>
<div class="control-group" id="change_user_password">
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_register_password1"
name="user_register_password1"
placeholder="${enter_password}"
minlength="5" data-validation-minlength-message="${login_password_too_short}"
required data-validation-required-message="${login_password_required}"/>
<br/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
<div class="control-group controls" style="clear: both">
<input type="password"
size="30"
style="margin-bottom: 15px; float: left;"
id="user_register_password2"
name="user_register_password2"
placeholder="${retype_password}"
data-validation-matches-match="user_register_password1"
data-validation-matches-message="${register_password_dont_math}"/>
<br/>
<div class="help-block" style="float: left; margin-top: 3px;"></div>
</div>
</div>
</td>
</tr>
<tr>
<th>${locale}</th>
<td>
<div id="change_user_locale">
<select size="1" id="register_locale_select">
<option value="deDE">deDE</option>
<option value="enUS">enUS</option>
</select>
</div>
</td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" type="submit"><i class="icon-ok icon-white"></i> ${register}</button>
<button class="btn btn-primary" type="reset" id="btn_user_registration_cancel"><i class="icon-remove icon-white"></i> ${cancel}</button>
</div>
</form>

View File

@ -1,34 +1,94 @@
function init__SYSTEM_SAI_saimod_sys_login() {
//jqBootstrapValidation
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get('./api.php?call=account&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
if(data == 1){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.")
}
});
event.preventDefault();
}
});
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get('./api.php?call=account&action=logout', function (data) {
if(data == 1){
$('.help-block').html("Logout successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Logout not successfull.</br>")
}
});
event.preventDefault();
}
//jqBootstrapValidation
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
if(data == 1){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.")
}
});
event.preventDefault();
}
});
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=logout', function (data) {
if(data == 1){
$('.help-block').html("Logout successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Logout not successfull.</br>")
}
});
event.preventDefault();
}
});
$.getJSON(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=userinfo', function(data){
if(data){
$('#user_email_input').attr('value', data.email);
$('span#user_username').text(data.username);
$('span#user_email').text(data.email);
$('span#user_joindate').text(data.joindate);
$('span#user_last_active').text(new Date(data.last_active * 1000).toString('yyyy-MM-dd h:mm:ss'));
$('span#user_locale').text(data.locale);
}
});
$("#register_link").click(function(){
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=registerform',function(){
init__SYSTEM_SAI_saimod_sys_login_register();
});
});
};
function init__SYSTEM_SAI_saimod_sys_login_register(){
$('#btn_user_registration_cancel').click(function(){
loadModuleContent('.SYSTEM.SAI.saimod_sys_login');
});
//jqBootstrapValidation
$("#register_user_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function (form, event, errors) {},
submitSuccess: function($form, event){
var username = document.getElementById('register_username').value;
var email = document.getElementById('register_email').value;
var password = document.getElementById('user_register_password2').value;
var select_locale = document.getElementById('register_locale_select');
var locale = "";
for (var i = 0; i < select_locale.options.length; i++) {
if(select_locale.options[i].selected ){
locale = select_locale.options[i].value;
}
}
//alert(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=register&username='+username+'&password_sha='+$.sha1(password)+'&password_md5='+$.md5(password)+'&email='+email+'&locale='+locale);
$.ajax({
dataType: "json",
url: SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=register&username='+username+'&password='+$.sha1(password)+'&email='+email+'&locale='+locale,
data: null,
success: function (dataCreate) {
if(dataCreate === 1){ // reload -> user will be loged in
window.location.href = location.href.replace(/#/g, "");
}else{ // show errors
//todo
}
}
});
event.preventDefault();
}
});
}

View File

@ -2,15 +2,8 @@
namespace SYSTEM\SAI;
class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
/*
if( isset($_POST['username']) && isset($_POST['password']) &&
\SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $_POST['username'], sha1($_POST['password']), md5($_POST['password']))){
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login_success.tpl'), array());}
*/
class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_login(){
$vars = array();
$vars['login'] = 'Login';
$vars['logout'] = 'Logout';
@ -18,21 +11,46 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
$vars['loginPassword'] = 'Password';
$vars['login_username_too_short'] = 'Username to short.';
$vars['login_password_too_short'] = 'Password to short.';
$vars['isadmin'] = \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) ? "yes" : "no";
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\DBD\locale_string::VALUE_CATEGORY_DASENSE_USERSTATISTICS));
if(\SYSTEM\SECURITY\Security::isLoggedIn()){
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/logout.tpl'), $vars);
} else {
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login.tpl'), $vars);}
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_logout(){
return \SYSTEM\SECURITY\Security::logout();}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_login($username,$password_sha,$password_md5){
return \SYSTEM\SECURITY\Security::login($username, $password_sha, $password_md5);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_register($username,$password,$email, $locale = 'deDE'){
return \SYSTEM\SECURITY\Security::create($username, $password, $email, $locale);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_userinfo(){
$user = \SYSTEM\SECURITY\Security::getUser();
if(!$user){
return;}
return json_encode(array( 'username' => $user->username,
'email' => $user->email,
'joindate' => $user->creationDate,
'locale' => $user->locale,
'last_active' => $user->lastLoginDate));
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_registerform(){
$vars = \SYSTEM\locale::getStrings(\DBD\locale_string::VALUE_CATEGORY_DASENSE);
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/register.tpl'), $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}
public static function right_public(){return true;}
public static function right_right(){return true;}
public static function src_css(){}
public static function src_js(){return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/jqBootstrapValidation.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/sai_sys_login_submit.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/crypto/jquery.md5.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/crypto/jquery.sha1.js')
));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/jqBootstrapValidation.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/sai_sys_login_submit.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/crypto/jquery.md5.js'),
\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'js/crypto/jquery.sha1.js')
));}
}

View File

@ -0,0 +1,10 @@
<div class="tabbable">
<ul class="nav nav-tabs" id="modstab">
<li class="active"><a href="#tab_sys">Sys Mods</a></li>
<li><a href="#tab_project">Project Mods</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_sys">${content_sys}</div>
<div class="tab-pane" id="tab_project">${content_project}</div>
</div>
</div>

View File

@ -0,0 +1,6 @@
function init__SYSTEM_SAI_saimod_sys_mod() {
$('#modstab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
};

View File

@ -1,33 +1,46 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_mod extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
class saimod_sys_mod extends \SYSTEM\SAI\SaiModule {
public static function html_content_sys(){
$result = '<h3>Sys Mods</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'Classname'.'</th>'.'<th>'.'Public'.'</th>'.'<th>'.'You can Access?'.'</th>'.'</tr>';
$sys_mods = \SYSTEM\SAI\sai::getInstance()->getSysModules();
$sys_mods = \SYSTEM\SAI\sai::getSysModules();
foreach($sys_mods as $mod){
$result .= '<tr>'.'<td>'.$mod.'</td>'.'<td>'.(\call_user_func(array($mod, 'right_public')) ? 'true' : 'false').'</td>'.'<td>'.(\call_user_func(array($mod, 'right_right')) ? 'true' : 'false').'</td>'.'</tr>';}
$result .= '</table>';
$result .= '<h3>Project Mods</h3>'.
return $result;
}
public static function html_content_project(){
$result = '<h3>Project Mods</h3>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'Classname'.'</th>'.'<th>'.'Public'.'</th>'.'<th>'.'You can Access?'.'</th>'.'</tr>';
$mods = \SYSTEM\SAI\sai::getInstance()->getModules();
$mods = \SYSTEM\SAI\sai::getModules();
foreach($mods as $mod){
$result .= '<tr>'.'<td>'.$mod.'</td>'.'<td>'.(\call_user_func(array($mod, 'right_public')) ? 'true' : 'false').'</td>'.'<td>'.(\call_user_func(array($mod, 'right_right')) ? 'true' : 'false').'</td>'.'</tr>';}
$result .= '</table>';
return $result;
return $result;
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_mod(){
$vars=array();
$vars['content_sys'] = self::html_content_sys();
$vars['content_project'] = self::html_content_project();
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_mod/mods.tpl'), $vars);
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_mod">SAI Mods</a></li>';}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_mod">SAI Mods</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){}
public static function src_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_mod_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_mod_flag_js(){
return \SYSTEM\LOG\JsonResult::toString(
array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_mod/saimod_sys_mod.js')));}
}

View File

@ -3,11 +3,11 @@
namespace SYSTEM\SAI;
class saimod_sys_sai extends \SYSTEM\SAI\SaiModule {
public static function html_content(){return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_sai/carousel.tpl'), array());}
public static function html_li_menu(){return '<li class="active"><a href="#" id=".SYSTEM.SAI.saimod_sys_sai">SYSTEM Admin Interface</a></li>';}
public static function sai_mod__SYSTEM_SAI_saimod_sys_sai(){return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_sai/carousel.tpl'), array());}
public static function html_li_menu(){return '<li class="active"><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_sai">SYSTEM Admin Interface</a></li>';}
public static function right_public(){return true;}
public static function right_right(){return true;}
public static function src_css(){}
public static function src_js(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_sai_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_sai_flag_js(){}
}

View File

@ -0,0 +1,3 @@
.tab-content {
clear: none;
}

View File

@ -0,0 +1,6 @@
function init__SYSTEM_SAI_saimod_sys_security() {
$('#securitytab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
};

View File

@ -1,8 +1,30 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
public static function html_content(){
class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
public static function html_content_groups(){
return "No Groups available yet.";
}
public static function html_content_rights(){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.rights ORDER BY "ID" ASC;');
} else {
$res = $con->query('SELECT * FROM system_rights ORDER BY ID ASC;');
}
$result = '<input type="submit" class="btn" value="New Right" newright="1"></br></br>'.
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Name'.'</th>'.'<th>'.'Description'.'</th>'.'<th>'.'Action'.'</th>'.'</tr>';
while($r = $res->next()){
$result .= '<tr>'.'<td>'.$r['ID'].'</td>'.'<td>'.$r['name'].'</td>'.'<td>'.$r['description'].'</td>'.'<td>'.'<input type="submit" class="btn-danger" value="delete" delright="'.$r['ID'].'">'.'<input type="submit" class="btn" value="edit" editright="'.$r['ID'].'">'.'</td>'.'</tr>';
}
$result .= '</table>';
return $result;
}
public static function html_content_users(){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT id,username,email,joindate,locale,last_active,account_flag FROM system.user ORDER BY last_active DESC;');
@ -16,10 +38,18 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
$result = '<table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Username'.'</th>'.'<th>'.'E-Mail'.'</th>'.'<th>'.'JoinDate'.'</th>'.'<th>'.'Locale'.'</th>'.'<th>'.'Last Active'.'</th>'.'<th>'.'Flag'.'</th>'.'<th style="width: 110px;">'.'Rights'.'</th><th>reset password</th>'.'</tr>';
while($r = $res->next()){
$result .= '<tr class="'.self::tablerow_class($r['last_active']).'">'.'<td>'.$r['id'].'</td>'.'<td>'.$r['username'].' <input type="submit" class="btn-danger" value="delete" user="'.$r['id'].'" action="delete">'.'</td>'.'<td>'.$r['email'].'</td>'.'<td>'.$r['joindate'].'</td>'.'<td>'.$r['locale'].'</td>'.'<td>'.$r['last_active'].'</td>'.'<td>'.$r['account_flag'].'</td>'.'<td>'.'<input type="submit" class="btn" value="edit" user="'.$r['id'].'" action="edit"><input type="submit" class="btn-danger" value="delete" user="'.$r['id'].'" action="delete"></td><td><button type="submit" class="btn" value="reset_password" user="'.$r['id'].'" email="'.$r['email'].'">send EMail</button>'.'</td>'.'</tr>';
$result .= '<tr class="'.self::tablerow_class($r['last_active']).'">'.'<td>'.$r['id'].'</td>'.'<td>'.$r['username'].'</td>'.'<td>'.$r['email'].'</td>'.'<td>'.$r['joindate'].'</td>'.'<td>'.$r['locale'].'</td>'.'<td>'.self::time_elapsed_string($r['last_active']).'</td>'.'<td>'.$r['account_flag'].'</td>'.'<td>'.'<input type="submit" class="btn" value="edit" user="'.$r['id'].'" action="edit"><input type="submit" class="btn-danger" value="delete" user="'.$r['id'].'" action="delete"></td><td><button type="submit" class="btn" value="reset_password" user="'.$r['id'].'" email="'.$r['email'].'">send EMail</button>'.'</td>'.'</tr>';
}
$result .= '</table>';
return $result;
return $result;
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_security(){
$vars = array();
$vars['content_users'] = self::html_content_users();
$vars['content_rights'] = self::html_content_rights();
$vars['content_groups'] = self::html_content_groups();
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/security.tpl'), $vars);
}
private static function tablerow_class($last_active){
@ -35,10 +65,40 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
return 'error';
}
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_security">Security</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
private static function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
$a = array( 12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($a as $secs => $str)
{
$d = $etime / $secs;
if ($d >= 1)
{
$r = round($d);
return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
}
}
}
public static function src_css(){}
public static function src_js(){}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_security">Security</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_security_flag_css(){return \SYSTEM\LOG\JsonResult::toString(
array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/saimod_sys_security.css')));}
public static function sai_mod__SYSTEM_SAI_saimod_sys_security_flag_js(){ return \SYSTEM\LOG\JsonResult::toString(
array(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/saimod_sys_security.js')));}
}

View File

@ -0,0 +1,12 @@
<div class="tabbable">
<ul class="nav nav-tabs" id="securitytab">
<li class="active"><a href="#tab_users">Users</a></li>
<li><a href="#tab_rights">Rights</a></li>
<li><a href="#tab_groups">Groups</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_users">${content_users}</div>
<div class="tab-pane" id="tab_rights">${content_rights}</div>
<div class="tab-pane" id="tab_groups">${content_groups}</div>
</div>
</div>

View File

@ -0,0 +1,94 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_todo extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo(){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->query('SELECT * FROM system.todo LEFT JOIN system_user ON system_todo.author = system_user.ID ORDER BY state, time DESC;');
} else {
$res = $con->query('SELECT * FROM system_todo LEFT JOIN system_user ON system_todo.author = system_user.ID ORDER BY state, time DESC;');
}
$result = '<div id="table-wrapper"><table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'Time ago'.'</th>'.'<th>'.'Time'.'</th>'.'<th>'.'Reporttype'.'</th>'.'<th>'.'Message'.'</th>'.'<th>'.'Author'.'</th>'.'<th>'.'Assigned'.'</th>'.'<th>'.'State'.'</th>'.'<th>'.'Action'.'</th>'.'</tr>';
while($row = $res->next()){
$result .= '<tr class="'.self::trclassbytype($row['type']).'">'.
'<td>'.self::time_elapsed_string(strtotime($row['time'])).'</td>'.'<td>'.$row['time'].'</td>'.
'<td>'.self::reporttype($row['type']).'</td>'.
'<td>'.$row['msg_1'].'</td>'.
'<td>'.$row['username'].'</td>'.
'<td>'.'I_S and many more'.'</td>'.
'<td>'.self::state($row['state']).'</td>'.
'<td>'. self::statebtn($row['state']).
'<input type="submit" class="btn" value="edit">'.
'<input type="submit" class="btn" value="assign">'.
'<input type="submit" class="btn-danger" value="delete">'.'</td>'.'</tr>';
}
$result .= '</table>';
return $result;
}
private static function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1)
{
return '0 seconds';
}
$a = array( 12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($a as $secs => $str)
{
$d = $etime / $secs;
if ($d >= 1)
{
$r = round($d);
return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
}
}
}
private static function state($state){
if($state == 1){
return 'Closed';}
return 'Open';}
private static function statebtn($state){
if($state == 1){
return '<input type="submit" class="btn-danger" value="reopen">';}
return '<input type="submit" class="btn-danger" value="close">';}
private static function reporttype($type){
switch($type){
case 0: return 'Feature Request';
case 1: return 'Error Report';
case 2: return 'Unasigned Category';
default: return 'Note';
}
}
private static function trclassbytype($type){
switch($type){
case 0: return 'info';
case 1: return 'error';
case 2: return 'warning';
case 3: return 'success';
default: return '';
}
}
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_todo">ToDo</a></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_flag_css(){}
public static function sai_mod__SYSTEM_SAI_saimod_sys_todo_flag_js(){}
}

View File

@ -1,35 +0,0 @@
<?php
namespace SYSTEM\SAI;
class default_module extends \SYSTEM\PAGE\Page {
private $module = null;
private $post_get = null;
private $css = null;
private $js = null;
public function __construct($module,$post_get){
$this->module = $module;
$this->post_get = $post_get;
$this->css = isset($post_get['css']) ? $post_get['css'] : null;
$this->js = isset($post_get['js']) ? $post_get['js'] : null;
}
public function html(){
if($this->module != null){
$mods = \SYSTEM\SAI\sai::getInstance()->getAllModules();
if( $this->module &&
\array_search($this->module, $mods) !== false &&
( \call_user_func(array($this->module, 'right_public')) ||
\call_user_func(array($this->module, 'right_right')))){
if($this->css != null){
return \call_user_func(array($this->module, 'src_css'));}
if($this->js != null){
return \call_user_func(array($this->module, 'src_js'));}
return \call_user_func(array($this->module, 'html_content'),array($this->post_get));}
}
return "Could not find Module";
}
}

View File

@ -7,7 +7,7 @@ class default_page extends \SYSTEM\PAGE\Page {
private function menu_sys(){
$result = '';
$mods = \SYSTEM\SAI\sai::getInstance()->getSysModules();
$mods = \SYSTEM\SAI\sai::getSysModules();
foreach($mods as $mod){
if(\call_user_func(array($mod, 'right_public')) ||
\call_user_func(array($mod, 'right_right'))){
@ -19,7 +19,7 @@ class default_page extends \SYSTEM\PAGE\Page {
private function menu_proj(){
$result = '';
$mods = \SYSTEM\SAI\sai::getInstance()->getModules();
$mods = \SYSTEM\SAI\sai::getModules();
foreach($mods as $mod){
if(\call_user_func(array($mod, 'right_public')) ||
\call_user_func(array($mod, 'right_right'))){
@ -37,18 +37,11 @@ class default_page extends \SYSTEM\PAGE\Page {
private function js(){
$result = '<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/libs/jquery.min.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/libs/bootstrap.min.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/loadcssjs.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_locale/tinymce/js/tinymce/tinymce.min.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/index.js').'" type="text/javascript"></script>'.
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/sai.js').'" type="text/javascript"></script>'.
'<script src="https://www.google.com/jsapi" type="text/javascript"></script>'.
'<script src="https://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>'.
'<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});</script>'.
'<script type="text/javascript">
tinymce.init({
mode : "textareas",
theme : "simple"
});
</script>';
'<script type="text/javascript">var SAI_ENDPOINT = "'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL).'";</script>';
return $result;
}

View File

@ -1,65 +0,0 @@
var last_id = '';
var scripts_loaded = 0;
var scripts_req = 0;
/** jQuery on document ready */
$(document).ready(function() {
// initialize content
loadModuleContent('.SYSTEM.SAI.saimod_sys_sai');
//load content -> menu
$('#sai_navbar ul li a, #project_navbar ul li a').click(function () {
var id = $(this).attr("id");
if(id !== undefined){
console.log("Module: "+id);
$('#sai_navbar li, #project_navbar li').each(function(){
$(this).removeClass('active');});
$(this).parent().addClass('active');
loadModuleContent(id);
}
});
$('.brand').click(function(){
location.reload();
});
});
function loadModuleContent(id){
last_id = id;
$('div#content-wrapper').load('./?action=developer&sai_mod='+id, function(){
$.getJSON('./?action=developer&sai_mod='+id+'&css=1', function (data) {
if(data){
for(var i=0; i < data['result'].length; i++){
loadCSS(data['result'][i]);}
}
});
$.getJSON('./?action=developer&sai_mod='+id+'&js=1', function (data) {
if(data){
scripts_req = data['result'].length;
for(var i=0; i < data['result'].length; i++){
loadJS(unescape(data['result'][i]));}
}
});
});
}
function script_loaded(){
scripts_loaded += 1;
if(scripts_loaded >= scripts_req){
scripts_loaded = 0;
func = 'init_'+last_id;
//func = jssrc.substring(jssrc.lastIndexOf('/')+1);
func = func.replace(/\./g,'_');
if(typeof window[func] === 'function') {
window[func]();
console.log(func+' called');}
}
}

View File

@ -1,19 +0,0 @@
function loadJS(jssrc) {
if(jssrc){
$.getScript(jssrc).done(function(script, textStatus) {
console.log('Script: '+jssrc+' - '+textStatus );
script_loaded();
})
}
}
function loadCSS(csssrc) {
if(csssrc){
var snode = document.createElement('link');
snode.setAttribute('type','text/css');
snode.setAttribute('rel', 'stylesheet');
snode.setAttribute('href',csssrc);
document.getElementsByTagName('head')[0].appendChild(snode);
console.log('Css: '+csssrc+' loaded.');
}
}

View File

@ -0,0 +1,81 @@
var last_id = '';
var scripts_loaded = 0;
var scripts_req = 0;
/** jQuery on document ready */
$(document).ready(function() {
// initialize content
loadModuleContent('.SYSTEM.SAI.saimod_sys_sai');
//load content -> menu
$('#sai_navbar ul li a, #project_navbar ul li a').click(function () {
var id = $(this).attr("saimenu");
if(id !== undefined){
console.log("Module: "+id);
$('#sai_navbar li, #project_navbar li').each(function(){
$(this).removeClass('active');});
$(this).parent().addClass('active');
loadModuleContent(id);
}
});
$('.brand').click(function(){
location.reload();
});
});
function loadModuleContent(id){
last_id = id;
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod='+id, function(){
$.getJSON(SAI_ENDPOINT+'sai_mod='+id+'&css=1', function (data) {
if(data){
for(var i=0; i < data['result'].length; i++){
loadCSS(data['result'][i]);}
}
});
$.getJSON('./sai.php?sai_mod='+id+'&js=1', function (data) {
if(data){
scripts_req = data['result'].length;
for(var i=0; i < data['result'].length; i++){
loadJS(unescape(data['result'][i]));}
}
});
});
}
function script_loaded(){
scripts_loaded += 1;
if(scripts_loaded >= scripts_req){
scripts_loaded = 0;
func = 'init_'+last_id;
//func = jssrc.substring(jssrc.lastIndexOf('/')+1);
func = func.replace(/\./g,'_');
if(typeof window[func] === 'function') {
window[func]();
console.log(func+' called');}
}
}
function loadJS(jssrc) {
if(jssrc){
$.getScript(jssrc).done(function(script, textStatus) {
console.log('Script: '+jssrc+' - '+textStatus );
script_loaded();
})
}
}
function loadCSS(csssrc) {
if(csssrc){
var snode = document.createElement('link');
snode.setAttribute('type','text/css');
snode.setAttribute('rel', 'stylesheet');
snode.setAttribute('href',csssrc);
document.getElementsByTagName('head')[0].appendChild(snode);
console.log('Css: '+csssrc+' loaded.');
}
}

View File

@ -21,21 +21,18 @@
</ul>
</div>
</div>
<div id="project_navbar" style="width:210px;float:left;">
<div class="navbar-inner">
<ul class="nav nav-list">
${menu_proj}
</ul>
</div>
</div>
<div id="content">
<div id="content-wrapper"></div>
<div id="project_navbar" style="width:210px; float:left;">
<div class="navbar-inner">
<ul class="nav nav-list">
${menu_proj}
</ul>
</div>
</div>
<div id="content" style="float: left;">
<div id="content-wrapper" style="clear: both; overflow: auto; width: 100%; min-width:500px;"></div>
<hr>
<div class="footer">
<p>${copyright}</p>
</div>
<div class="footer"><p>${copyright}</p></div>
</div>
</body>
</html>

View File

@ -2,9 +2,11 @@
namespace SYSTEM\SAI;
abstract class SaiModule {
public static function html_content(){
throw new \RuntimeException("Unimplemented!");}
abstract class SaiModule extends \SYSTEM\API\api_login{
public static function default_page(){
$sai = new \SYSTEM\SAI\default_page();
return $sai->html();}
public static function html_li_menu(){
throw new \RuntimeException("Unimplemented!");}
//true or false -> if true no call to right_right()
@ -13,11 +15,5 @@ abstract class SaiModule {
//check your rights here -> returns true or false
public static function right_right(){
throw new \RuntimeException("Unimplemented!");}
//array with paths as json
public static function src_js(){
throw new \RuntimeException("Unimplemented!");}
//array with paths as json
public static function src_css(){
throw new \RuntimeException("Unimplemented!");}
}

View File

@ -3,37 +3,26 @@
namespace SYSTEM\SAI;
class sai {
private static $modules = array(); //only strings!
private static $modules_sys = array(); //only strings!
private $modules = array(); //only strings!
private $modules_sys = array(); //only strings!
//SINGLETON!
static private $instance = null;
static public function getInstance(){
if (null === self::$instance) {
self::$instance = new self;}
return self::$instance;
}
private function __construct(){}
private function __clone(){}
public function register($module){
public static function register($module){
if( !\class_exists($module) ||
!\is_array($parents = \class_parents($module)) ||
!\array_search('SYSTEM\SAI\SaiModule', $parents)){
throw new \Exception('Problem with your Sysmodule class: '.$module);}
$this->modules[] = $module;}
public function register_sys($module){
array_push(self::$modules,$module);}
public static function register_sys($module){
if( !\class_exists($module) ||
!\is_array($parents = \class_parents($module)) ||
!\array_search('SYSTEM\SAI\SaiModule', $parents)){
throw new \Exception('Problem with your Sysmodule class: '.$module);}
$this->modules_sys[] = $module;}
array_push(self::$modules_sys,$module);}
public function getModules(){
return $this->modules;}
public function getSysModules(){
return $this->modules_sys;}
public function getAllModules(){
return array_merge($this->modules_sys,$this->modules);}
public static function getModules(){
return self::$modules;}
public static function getSysModules(){
return self::$modules_sys;}
public static function getAllModules(){
return array_merge(self::$modules_sys,self::$modules);}
}

View File

@ -8,10 +8,18 @@ class saigui extends \SYSTEM\PAGE\Page {
public function html(){
$pg = array_merge($_POST,$_GET);
if(isset($pg[SAI_MOD_POSTFIELD])){
$mod = new \SYSTEM\SAI\default_module(\str_replace('.', '\\', $pg[SAI_MOD_POSTFIELD]),$pg);
return $mod->html();}
$sai = new \SYSTEM\SAI\default_page();
return $sai->html();
$classname = \str_replace('.', '\\', $pg[SAI_MOD_POSTFIELD]);
$pg[SAI_MOD_POSTFIELD] = \str_replace('.', '_', $pg[SAI_MOD_POSTFIELD]);
$mods = \SYSTEM\SAI\sai::getAllModules();
if( $classname &&
\array_search($classname, $mods) !== false &&
( \call_user_func(array($classname, 'right_public')) ||
\call_user_func(array($classname, 'right_right')))){
return \SYSTEM\API\api::run('\SYSTEM\API\verify', $classname , $pg, 42, false, false);
} else {
return "Could not find Module";}
} else {
return \SYSTEM\API\api::run('\SYSTEM\API\verify', '\SYSTEM\SAI\SaiModule', array(), 42, false, true);}
}
}

View File

@ -15,14 +15,14 @@ class Security {
const AVAILABLE_FAIL = false;
const AVAILABLE_OK = true;
public static function create(\SYSTEM\DB\DBInfo $dbinfo, $username, $password, $email, $locale, $advancedResult=false, $checkAvailable = true){
public static function create($username, $password, $email, $locale, $advancedResult=false, $checkAvailable = true){
self::startSession();
// check availability of username (in non-compatibility mode, otherwise it is already checked in DasenseAccount)
if($checkAvailable && !self::available($dbinfo, $username)){
if($checkAvailable && !self::available($username)){
return self::REGISTER_FAIL;}
$con = new \SYSTEM\DB\Connection($dbinfo);
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$result = $con->prepare('createAccountStmt','INSERT INTO '.\SYSTEM\DBD\UserTable::NAME_PG.
' ('.\SYSTEM\DBD\UserTable::FIELD_USERNAME.','.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.','
@ -37,16 +37,16 @@ class Security {
array( $username , $password, $email, $locale, 1 ));
}
if( !$result || !self::login($dbinfo, $username, $password, $locale)){
if( !$result || !self::login($username, $password, $locale)){
return self::REGISTER_FAIL;}
return ($advancedResult ? $result->next() : self::REGISTER_OK);
}
public static function changePassword(\SYSTEM\DB\DBInfo $dbinfo, $username, $password_sha_old, $password_sha_new){
public static function changePassword($username, $password_sha_old, $password_sha_new){
$con = new \SYSTEM\DB\Connection($dbinfo);
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$result = $con->prepare('',
'SELECT id FROM '.\SYSTEM\DBD\UserTable::NAME_PG.
@ -77,18 +77,16 @@ class Security {
return 1;
}
public static function login(\SYSTEM\DB\DBInfo $dbinfo, $username, $password_sha, $password_md5, $locale=NULL, $advancedResult=false, $password_sha_new=NULL){
public static function login($username, $password_sha, $password_md5, $locale=NULL, $advancedResult=false, $password_sha_new=NULL){
self::startSession();
if(!isset($password_sha)){
self::trackLogins($dbinfo, NULL, self::LOGIN_FAIL);
self::trackLogins(NULL, self::LOGIN_FAIL);
$_SESSION['user'] = NULL;
return self::LOGIN_FAIL;}
$con = new \SYSTEM\DB\Connection($dbinfo);
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(isset($password_md5)){
if(\SYSTEM\system::isSystemDbInfoPG()){
$result = $con->prepare('loginAccountStmt',
@ -141,12 +139,18 @@ class Security {
}else{
$pw = $password_sha;
}
$res = $con->prepare( 'updatePasswordSHAStmt',
'UPDATE '.\SYSTEM\DBD\UserTable::NAME_PG.' SET '.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.' = $1 WHERE '.\SYSTEM\DBD\UserTable::FIELD_ID.' = $2'.' RETURNING '.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.';',
array($pw,$row[\SYSTEM\DBD\UserTable::FIELD_ID]));
unset($result);
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'updatePasswordSHAStmt',
'UPDATE '.\SYSTEM\DBD\UserTable::NAME_PG.' SET '.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.' = $1 WHERE '.\SYSTEM\DBD\UserTable::FIELD_ID.' = $2'.' RETURNING '.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.';',
array($pw,$row[\SYSTEM\DBD\UserTable::FIELD_ID]));
}else{
$res = $con->prepare( 'updatePasswordSHAStmt',
'UPDATE '.\SYSTEM\DBD\UserTable::NAME_MYS.' SET '.\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA.' = ? WHERE '.\SYSTEM\DBD\UserTable::FIELD_ID.' = ?'.';',
array($pw,$row[\SYSTEM\DBD\UserTable::FIELD_ID]));
}
$res = $res->next();
$row[\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA] = $res[\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA];
$row[\SYSTEM\DBD\UserTable::FIELD_PASSWORD_SHA] = $pw;
}
// set session variables
@ -163,12 +167,12 @@ class Security {
if(isset($locale)){
\SYSTEM\locale::set($locale);}
// track succesful user login
self::trackLogins($dbinfo, $row[\SYSTEM\DBD\UserTable::FIELD_ID]);
self::trackLogins($row[\SYSTEM\DBD\UserTable::FIELD_ID]);
return ($advancedResult ? $row : self::LOGIN_OK);
}
private static function trackLogins(\SYSTEM\DB\DBInfo $dbinfo, $userID){
$con = new \SYSTEM\DB\Connection($dbinfo);
private static function trackLogins($userID){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$con->prepare( 'trackLoginAccountStmt',
'UPDATE '.\SYSTEM\DBD\UserTable::NAME_PG.' SET '.\SYSTEM\DBD\UserTable::FIELD_LAST_ACTIVE.'= to_timestamp($1) '.
@ -192,8 +196,8 @@ class Security {
*
* @param String $username
*/
public static function available(\SYSTEM\DB\DBInfo $dbinfo, $username){
$con = new \SYSTEM\DB\Connection($dbinfo);
public static function available($username){
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'availableStmt',
'SELECT COUNT(*) as count FROM '.\SYSTEM\DBD\UserTable::NAME_PG.
@ -215,14 +219,14 @@ class Security {
}
//checks for a right for a logged in user
public static function check(\SYSTEM\DB\DBInfo $dbinfo, $rightid){
public static function check($rightid){
//Not logged in? Go away.
//If you think you need rights for your guests ur doing smth wrong ;-)
$user = null;
if(!($user = self::getUser())){
return false;}
$con = new \SYSTEM\DB\Connection($dbinfo);
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'security_check',
'SELECT COUNT(*) as count FROM '.\SYSTEM\DBD\UserRightsTable::NAME_PG.
@ -271,12 +275,12 @@ class Security {
}
//This functions is called from \SYSTEM\locale::set()
public static function _db_setLocale($dbinfo, $lang){
public static function _db_setLocale($lang){
$user = self::getUser();
if(!$user){
throw new \SYSTEM\LOG\ERROR("You need to be logged in");}
$con = new \SYSTEM\DB\Connection($dbinfo);
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->prepare( 'updateUserLocaleStmt',
'UPDATE '.\SYSTEM\DBD\UserTable::NAME_PG.' SET '.\SYSTEM\DBD\UserTable::FIELD_LOCALE.' = $1 '.