Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imldeployment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
Imldeployment
Commits
fd6d6eea
Commit
fd6d6eea
authored
10 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
queryparam class: php8 only; added variable types; short array syntax
parent
b8488569
No related branches found
No related tags found
1 merge request
!66
php8 only; added variable types; short array syntax; remove glyphicons
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/deployment/classes/projectlist.class.php
+5
-5
5 additions, 5 deletions
public_html/deployment/classes/projectlist.class.php
public_html/deployment/classes/queryparam.class.php
+41
-24
41 additions, 24 deletions
public_html/deployment/classes/queryparam.class.php
with
46 additions
and
29 deletions
public_html/deployment/classes/projectlist.class.php
+
5
−
5
View file @
fd6d6eea
...
...
@@ -9,7 +9,7 @@
---------------------------------------------------------------------
Axel <axel.hahn@unibe.ch>
2013-11-08 Axel
2024-08-2
8
Axel php8 only; added variable types; short array syntax
2024-08-2
9
Axel php8 only; added variable types; short array syntax
###################################################################### */
require_once
'base.class.php'
;
...
...
This diff is collapsed.
Click to expand it.
public_html/deployment/classes/queryparam.class.php
+
41
−
24
View file @
fd6d6eea
<?php
/**
* Wrapping class to access $_GET|$_POST|$_SESSION variables with validation
* of a value
*
* @example
* Ensure that https://example.com/?page=<VALUE> will be accepted only if
* <VALUE> matches /^[a-z]*$/
* <code>queryparam::get('page', '/^[a-z]*$/');</code>
*
* Axel <axel.hahn@unibe.ch>
* 2024-08-29 Axel php8 only; added variable types; short array syntax
*/
class
queryparam
{
class
queryparam
{
/**
*
r
et
urn
value of a a given scope variable (e.g. $_GET|$_POST|$_SESSION) if it exists.
*
G
et value of a a given scope variable (e.g. $_GET|$_POST|$_SESSION) if it exists.
* It will return NULLL if the value does not match an optional regex or type.
*
* @param array $aScope array of scope variables
* @param string $sVarname name of post or get variable (POST has priority)
* @param string $sRegexMatch set a regex that must match
* @param string $sType force type: false|int
* @return mixed NULL|value
*/
static
public
function
getvar
(
$aScope
,
$sVarname
,
$sRegexMatch
=
false
,
$sType
=
false
){
static
public
function
getvar
(
array
$aScope
,
string
$sVarname
,
string
$sRegexMatch
=
''
,
string
$sType
=
''
):
mixed
{
// check if it exist
if
(
!
isset
(
$aScope
[
$sVarname
]))
{
return
NULL
;
...
...
@@ -44,7 +58,8 @@ class queryparam{
* @param string $sType force type: false|int
* @return mixed NULL|value
*/
static
function
get
(
$sVarname
,
$sRegexMatch
=
false
,
$sType
=
false
)
{
static
function
get
(
string
$sVarname
,
string
$sRegexMatch
=
''
,
string
$sType
=
''
):
mixed
{
return
self
::
getvar
(
$_GET
,
$sVarname
,
$sRegexMatch
,
$sType
);
}
...
...
@@ -56,7 +71,8 @@ class queryparam{
* @param string $sType force type: false|int
* @return mixed NULL|value
*/
static
function
getorpost
(
$sVarname
,
$sRegexMatch
=
false
,
$sType
=
false
)
{
static
function
getorpost
(
string
$sVarname
,
string
$sRegexMatch
=
''
,
string
$sType
=
''
):
mixed
{
// $this->logAdd(__METHOD__."($sVarname, $sRegexMatch, $sType) start");
// check if it exist
...
...
@@ -84,7 +100,8 @@ class queryparam{
* @param string $sType force type: false|int
* @return mixed NULL|value
*/
static
function
post
(
$sVarname
,
$sRegexMatch
=
false
,
$sType
=
false
)
{
static
function
post
(
string
$sVarname
,
string
$sRegexMatch
=
''
,
string
$sType
=
''
):
mixed
{
return
self
::
getvar
(
$_POST
,
$sVarname
,
$sRegexMatch
,
$sType
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment