Skip to content

Commit ac76e70

Browse files
authored
Merge pull request #276 from ostepu/version_0.6.0
Version 0.6.0
2 parents fbd86d1 + 0a1107a commit ac76e70

File tree

458 files changed

+12566
-7115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

458 files changed

+12566
-7115
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Assistants/Test/
1111
.project
1212
DB/CHelp/cache/
1313
UI/include/Config.php
14-
UI/Images/head_logo_hover.jpg
14+
UI/Images/head_logo_hover.png
1515
Assistants/vendor/
1616
install/vendor/
1717
vendor/

.htaccess

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,18 @@ RewriteRule ^(/?)$ %{REQUEST_URI}UI/ [R,L]
1818
<ifmodule mod_filter.c>
1919
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
2020
</ifmodule>
21-
</ifmodule>
21+
</ifmodule>
22+
23+
<IfModule mod_expires.c>
24+
# Enable expirations
25+
ExpiresActive On
26+
ExpiresByType image/jpg "access plus 1 month"
27+
ExpiresByType image/jpeg "access plus 1 month"
28+
ExpiresByType image/png "access plus 1 month"
29+
ExpiresByType image/gif "access plus 1 month"
30+
ExpiresByType text/css "access plus 1 month"
31+
ExpiresByType application/javascript "access plus 1 month"
32+
<FilesMatch "\.(php)$">
33+
ExpiresByType text/css "access plus 1 day"
34+
</FilesMatch>
35+
</IfModule>

Assistants/CConfig.php

Lines changed: 74 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,22 @@ public function setPrefix( $value )
7777
private $_noInfo = false;
7878
private $_noHelp = false;
7979
private $_defaultLanguage = null;
80+
private $_getAndHead = false;
81+
private $_allowOptions = false;
8082

8183
/**
8284
* the CConfig constructor
8385
*
8486
* @param $prefix the prefix, the component works with
8587
*/
86-
public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp = false, $defaultLanguage = 'de' )
88+
public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp = false, $defaultLanguage = 'de', $options=array() )
8789
{
8890
if (!in_array('Slim\Slim', get_declared_classes())){
8991
return;
9092
}
93+
94+
if (isset($options['getAndHead'])) $this->_getAndHead = $options['getAndHead'];
95+
if (isset($options['allowOptions'])) $this->_allowOptions = $options['allowOptions'];
9196

9297
$this->_noInfo = $noInfo;
9398
$this->_noHelp = $noHelp;
@@ -103,11 +108,11 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
103108
$requestUri = $_SERVER['REQUEST_URI'];
104109
$path = str_replace('?' . (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''), '', substr_replace($requestUri, '', 0, strlen((strpos($requestUri, $scriptName) !== false ? $scriptName : str_replace('\\', '', dirname($scriptName))))));
105110

106-
$pregA = @preg_match("%^(/[a-zA-Z0-9_\x7f-\xff]*)?/control$%", $path);
107-
$pregB = @preg_match("%^(/[a-zA-Z0-9_\x7f-\xff]*)?/info/commands(/?)$%", $path);
108-
$pregC = @preg_match("%^(/[a-zA-Z0-9_\x7f-\xff]*)?/info/links(/?)$%", $path);
109-
$pregD = @preg_match("%^(/[a-zA-Z0-9_\x7f-\xff]*)?/info/([a-zA-Z0-9_\x7f-\xff]*)(/?)$%", $path);
110-
$pregE = @preg_match("%^(/[a-zA-Z0-9_\x7f-\xff]*)?/help/([a-zA-Z0-9_\x7f-\xff]*)/%", $path);
111+
$pregA = @preg_match("%^((/[a-zA-Z0-9_\x7f-\xff]*)?|(/profile/[a-zA-Z0-9_\x7f-\xff]*)?)/control$%", $path);
112+
$pregB = @preg_match("%^((/[a-zA-Z0-9_\x7f-\xff]*)?|(/profile/[a-zA-Z0-9_\x7f-\xff]*)?)/info/commands(/?)$%", $path);
113+
$pregC = @preg_match("%^((/[a-zA-Z0-9_\x7f-\xff]*)?|(/profile/[a-zA-Z0-9_\x7f-\xff]*)?)/info/links(/?)$%", $path);
114+
$pregD = @preg_match("%^((/[a-zA-Z0-9_\x7f-\xff]*)?|(/profile/[a-zA-Z0-9_\x7f-\xff]*)?)/info/([a-zA-Z0-9_\x7f-\xff]*)(/?)$%", $path);
115+
$pregE = @preg_match("%^((/[a-zA-Z0-9_\x7f-\xff]*)?|(/profile/[a-zA-Z0-9_\x7f-\xff]*)?)/help/([a-zA-Z0-9_\x7f-\xff]*)/%", $path);
111116

112117
if ( $pregA || $pregB || $pregC || (!$noInfo && $pregD ) || (!$noHelp && $pregE ) ) {
113118

@@ -120,16 +125,25 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
120125

121126
// GET Commands
122127
$this->_app->map(
123-
'(/:pre)/info/commands(/)',
128+
'((/profile)/:pre)/info/commands(/)',
124129
array(
125130
$this,
126131
'commands'
127132
)
128133
)->via('GET','OPTIONS');
134+
135+
// GET Component
136+
$this->_app->map(
137+
'(/:pre)/info/component(/)',
138+
array(
139+
$this,
140+
'component'
141+
)
142+
)->via('GET');
129143

130144
// GET Instruction
131145
$this->_app->get(
132-
'(/:pre)/info/links(/)',
146+
'((/profile)/:pre)/info/links(/)',
133147
array(
134148
$this,
135149
'instruction'
@@ -139,7 +153,7 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
139153
if (!$this->_noInfo){
140154
// GET Info
141155
$this->_app->get(
142-
'(/:pre)/info/:language(/)',
156+
'((/profile)/:pre)/info/:language(/)',
143157
array(
144158
$this,
145159
'info'
@@ -149,7 +163,7 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
149163

150164
// POST Config
151165
$this->_app->post(
152-
'(/:pre)/control',
166+
'((/profile)/:pre)/control',
153167
array(
154168
$this,
155169
'postConfig'
@@ -158,7 +172,7 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
158172

159173
// GET Config
160174
$this->_app->get(
161-
'(/:pre)/control',
175+
'((/profile)/:pre)/control',
162176
array(
163177
$this,
164178
'getConfig'
@@ -168,7 +182,7 @@ public function __construct( $prefix, $callPath = null, $noInfo = false, $noHelp
168182
if (!$this->_noHelp){
169183
// GET Help
170184
$this->_app->get(
171-
'(/:pre)/help/:language/:helpPath+',
185+
'((/profile)/:pre)/help/:language/:helpPath+',
172186
array(
173187
$this,
174188
'getHelp'
@@ -192,8 +206,14 @@ public function info( $pre = '', $language = 'de')
192206
$this->_app->response->setStatus( 200 );
193207
$this->_app->response->setBody( file_get_contents($path.'info/'.$language.'.md') );
194208
}else{
195-
$this->_app->response->setStatus( 404 );
196-
$this->_app->response->setBody( '' );
209+
// wenn die gewollte Datei nicht existiert, suche wenigstens noch "de"
210+
if (file_exists($path.'info/de.md')){
211+
$this->_app->response->setStatus( 200 );
212+
$this->_app->response->setBody( file_get_contents($path.'info/de.md') );
213+
} else {
214+
$this->_app->response->setStatus( 404 );
215+
$this->_app->response->setBody( '' );
216+
}
197217
}
198218
}
199219

@@ -277,12 +297,23 @@ public function commands( $pre = '', $nativeOnly=false, $returnData=false )
277297
$commands = json_decode(file_get_contents(($this->callPath!=null ? $this->callPath.'/':'').'Commands.json'), true);
278298

279299
if (!$nativeOnly){
280-
$commands[] = array('method' => 'get', 'path' => '(/:pre)/info/commands(/)');
281-
$commands[] = array('method' => 'get', 'path' => '(/:pre)/info/links(/)');
282-
if (!$this->_noInfo) $commands[] = array('method' => 'get', 'path' => '(/:pre)/info/:language(/)');
283-
$commands[] = array('method' => 'post', 'path' => '(/:pre)/control');
284-
$commands[] = array('method' => 'get', 'path' => '(/:pre)/control');
285-
if (!$this->_noHelp) $commands[] = array('method' => 'get', 'path' => '(/:pre)/help/:language/path+');
300+
if ($this->_getAndHead){
301+
// wenn ein get angeboten wird, kann auch head genutzt werden
302+
foreach($commands as $command){
303+
if (isset($command['method']) && strtolower($command['method']) == 'get'){
304+
$tmp = array_merge($command,array());
305+
$tmp['method'] = 'head';
306+
$commands[] = $tmp;
307+
}
308+
}
309+
}
310+
311+
$commands[] = array('method' => 'get', 'path' => '((/profile)/:pre)/info/commands(/)');
312+
$commands[] = array('method' => 'get', 'path' => '((/profile)/:pre)/info/links(/)');
313+
if (!$this->_noInfo) $commands[] = array('method' => 'get', 'path' => '((/profile)/:pre)/info/:language(/)');
314+
$commands[] = array('method' => 'post', 'path' => '((/profile)/:pre)/control');
315+
$commands[] = array('method' => 'get', 'path' => '((/profile)/:pre)/control');
316+
if (!$this->_noHelp) $commands[] = array('method' => 'get', 'path' => '((/profile)/:pre)/help/:language/path+');
286317
}
287318

288319
if ($returnData){
@@ -300,6 +331,29 @@ public function commands( $pre = '', $nativeOnly=false, $returnData=false )
300331
}
301332
}
302333

334+
public function component( $pre = '', $nativeOnly=false, $returnData=false )
335+
{
336+
if (file_exists(($this->callPath!=null ? $this->callPath.'/':'').'Component.json')){
337+
if (!$returnData)
338+
$this->_app->response->setStatus( 200 );
339+
340+
$component = json_decode(file_get_contents(($this->callPath!=null ? $this->callPath.'/':'').'Component.json'), true);
341+
342+
if ($returnData){
343+
return $component;
344+
} else
345+
$this->_app->response->setBody( json_encode($component) );
346+
347+
}else{
348+
if ($returnData){
349+
return array();
350+
} else {
351+
$this->_app->response->setStatus( 404 );
352+
$this->_app->response->setBody( '' );
353+
}
354+
}
355+
}
356+
303357
/**
304358
* returns the value of $_used
305359
*

Assistants/DBJson.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ public static function concatObjectLists(
434434
}
435435

436436
/**
437-
* concatenates two arrays by using attribute lists, assoc indizes remain,
438-
* only one secondary object will attached to an primary object
437+
* concatenates two arrays by using attribute lists, assoc indizes remain
439438
*
440439
* @param string[][] $data an array, which represents the data, received sql data
441440
* @param string[][] $prim the structure of objects to which you want to append the new objects

Assistants/DBRequest.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public static function request(
158158
return $query_result;
159159
}
160160

161+
// benutzt die mysqli-Erweiterung, wobei mehrere Anfragen in einem sqlStatement erlaubt sind
161162
public static function request2(
162163
$sqlStatement,
163164
$checkSession,
@@ -312,6 +313,88 @@ public static function request2(
312313
$dbconn = null;
313314
return $query_result;
314315
}
316+
317+
// benutzt die mysqli_query Methode, sodass nur eine einzelne Anfrage ausgewertet wird
318+
public static function request2Single(
319+
$sqlStatement,
320+
$checkSession,
321+
$config = null,
322+
$useDbOperator = false
323+
)
324+
{
325+
326+
if ($config===null){
327+
// loads the mysql server config from file
328+
$config = parse_ini_file(
329+
'config.ini',
330+
TRUE
331+
);
332+
}
333+
334+
//ini_set('mysql.connect_timeout','60');
335+
336+
// creates a new connection to database
337+
if (!isset($config['ZV']['zv_type']) || (isset($config['ZV']['zv_type']) && $config['ZV']['zv_type']=='local')){
338+
$path = (strpos($config['PL']['urlExtern'],$config['DB']['db_path'])===false ? $config['DB']['db_path'] : 'localhost' );
339+
} else
340+
$path = $config['DB']['db_path'];
341+
342+
if (!$useDbOperator){
343+
$dbconn = @mysqli_connect(
344+
$path,
345+
$config['DB']['db_user'],
346+
$config['DB']['db_passwd'],
347+
$config['DB']['db_name']
348+
);
349+
} else {
350+
$dbconn = @mysqli_connect(
351+
$path,
352+
$config['DB']['db_user_operator'],
353+
$config['DB']['db_passwd_operator'],
354+
$config['DB']['db_name']
355+
);
356+
357+
}
358+
359+
if (!$dbconn){
360+
$query_result['errno'] = 10;
361+
return $query_result;
362+
}
363+
364+
// use UTF8
365+
mysqli_set_charset($dbconn,"utf8");
366+
367+
// performs the request
368+
$answ = mysqli_query(
369+
$dbconn,
370+
$sqlStatement,
371+
MYSQLI_USE_RESULT
372+
);
373+
374+
$query_result=array();
375+
376+
if ($answ===false){
377+
$hash='';
378+
$query_result['affectedRows'] = mysqli_affected_rows( $dbconn);
379+
$query_result['insertId'] = mysqli_insert_id( $dbconn);
380+
$query_result['errno'] = mysqli_errno( $dbconn );
381+
$query_result['error'] =mysqli_error( $dbconn );
382+
} else {
383+
$hash='';
384+
$query_result['content'] = DBJson::getRows2( $answ, $hash );
385+
$query_result['numRows'] = count($query_result['content']);
386+
$query_result['hash'] = $hash;
387+
$query_result['affectedRows'] = mysqli_affected_rows( $dbconn);
388+
$query_result['insertId'] = mysqli_insert_id( $dbconn);
389+
$query_result['errno'] = mysqli_errno( $dbconn );
390+
$query_result['error'] =mysqli_error( $dbconn );
391+
}
392+
393+
// closes the connection and returns the result
394+
mysqli_close( $dbconn );
395+
$dbconn = null;
396+
return $query_result;
397+
}
315398

316399
/**
317400
* performs a database query by using a given file

0 commit comments

Comments
 (0)