2012-02-25 23:45:20 +01:00
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en"
lang="en" dir="ltr">
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
< title > < / title >
<!-- metadata -->
< meta name = "generator" content = "Offline" / >
< meta name = "version" content = "Offline 0.1" / >
<!-- style sheet links -->
< link rel = "stylesheet" media = "all" type = "text/css" href = "../../../css/all.css" / >
< link rel = "stylesheet" media = "screen" type = "text/css" href = "../../../css/screen.css" / >
< link rel = "stylesheet" media = "print" type = "text/css" href = "../../../css/print.css" / >
< / head >
< body >
< div class = "dokuwiki export" >
2015-06-08 16:57:58 +02:00
< h1 class = "sectionedit1" id = "extended_functions" > Extended functions< / h1 >
2012-02-25 23:45:20 +01:00
< div class = "level1" >
< / div >
2015-06-08 16:57:58 +02:00
<!-- EDIT1 SECTION "Extended functions" [1 - 34] -->
< h2 class = "sectionedit2" id = "presentation" > Presentation< / h2 >
2012-02-25 23:45:20 +01:00
< div class = "level2" >
< p >
2016-03-22 12:19:17 +01:00
When < a href = "../../documentation/2.0/writingrulesand_headers.html" class = "wikilink1" title = "documentation:2.0:writingrulesand_headers" > writing rules and headers< / a > , you can use Perl expressions that will be evaluated in a jail, to prevent bad code execution.
2012-02-25 23:45:20 +01:00
< / p >
< p >
This is also true for:
< / p >
< ul >
2016-03-22 12:19:17 +01:00
< li class = "level1" > < div class = "li" > < a href = "../../documentation/2.0/portalmenu.html#menu_modules" class = "wikilink1" title = "documentation:2.0:portalmenu" > Menu modules activation rules< / a > < / div >
2012-02-25 23:45:20 +01:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level1" > < div class = "li" > < a href = "../../documentation/2.0/formreplay.html" class = "wikilink1" title = "documentation:2.0:formreplay" > Form replay data< / a > < / div >
2012-02-25 23:45:20 +01:00
< / li >
< li class = "level1" > < div class = "li" > Macros< / div >
< / li >
< li class = "level1" > < div class = "li" > Issuer databases use rules< / div >
< / li >
< li class = "level1" > < div class = "li" > etc.< / div >
< / li >
< / ul >
< p >
Inside this jail, you can access to:
< / p >
< ul >
2015-06-08 16:57:58 +02:00
< li class = "level1" > < div class = "li" > Core Perl subroutines (split, pop, map, etc.)< / div >
2012-02-25 23:45:20 +01:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level1" > < div class = "li" > < a href = "../../documentation/2.0/customfunctions.html" class = "wikilink1" title = "documentation:2.0:customfunctions" > Custom functions< / a > < / div >
2012-02-25 23:45:20 +01:00
< / li >
< li class = "level1" > < div class = "li" > The < a href = "http://perldoc.perl.org/MIME/Base64.html" class = "urlextern" title = "http://perldoc.perl.org/MIME/Base64.html" rel = "nofollow" > encode_base64< / a > subroutine< / div >
< / li >
2014-07-21 14:36:50 +02:00
< li class = "level1" > < div class = "li" > Environment variables, in some cases (through %ENV)< / div >
2012-02-25 23:45:20 +01:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level1" > < div class = "li" > < a href = "#request_informations" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > Informations about current request< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level1" > < div class = "li" > < a href = "#extended_functions_list" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > Extended functions< / a > :< / div >
2014-07-21 14:36:50 +02:00
< ul >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#date" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > date< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#checklogonhours" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > checkLogonHours< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#checkdate" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > checkDate< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#basic" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > basic< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#unicode2iso" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > unicode2iso< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#iso2unicode" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > iso2unicode< / a > < / div >
2014-07-21 14:36:50 +02:00
< / li >
2016-03-22 12:19:17 +01:00
< li class = "level2" > < div class = "li" > < a href = "#groupmatch" title = "documentation:2.0:extendedfunctions ↵" class = "wikilink1" > groupMatch< / a > < / div >
2015-10-05 16:53:35 +02:00
< / li >
2014-07-21 14:36:50 +02:00
< / ul >
2012-02-25 23:45:20 +01:00
< / li >
< / ul >
< p >
< p > < div class = "notetip" > To know more about the jail, check < a href = "http://perldoc.perl.org/Safe.html" class = "urlextern" title = "http://perldoc.perl.org/Safe.html" rel = "nofollow" > Safe module documentation< / a > .
< / div > < / p >
< / p >
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT2 SECTION "Presentation" [35 - 1108] -->
2015-06-08 16:57:58 +02:00
< h2 class = "sectionedit3" id = "request_informations" > Request informations< / h2 >
2014-07-21 14:36:50 +02:00
< div class = "level2" >
< p >
The following data about the current request are available through functions :
< / p >
< ul >
< li class = "level1" > < div class = "li" > hostname< / div >
< / li >
2015-06-08 16:57:58 +02:00
< li class = "level1" > < div class = "li" > remote_ip: the client < abbr title = "Internet Protocol" > IP< / abbr > address< / div >
2014-07-21 14:36:50 +02:00
< / li >
2015-06-08 16:57:58 +02:00
< li class = "level1" > < div class = "li" > uri: < abbr title = "Uniform Resource Locator" > URL< / abbr > path< / div >
2014-07-21 14:36:50 +02:00
< / li >
2015-06-08 16:57:58 +02:00
< li class = "level1" > < div class = "li" > uri_with_args: < abbr title = "Uniform Resource Locator" > URL< / abbr > path with query string< / div >
2014-07-21 14:36:50 +02:00
< / li >
2015-06-08 16:57:58 +02:00
< li class = "level1" > < div class = "li" > unparsed_uri: < abbr title = "Uniform Resource Locator" > URL< / abbr > path, before < abbr title = "Uniform Resource Locator" > URL< / abbr > decoding< / div >
2014-07-21 14:36:50 +02:00
< / li >
< li class = "level1" > < div class = "li" > args: the query string< / div >
< / li >
< li class = "level1" > < div class = "li" > method: the request method (GET, POST etc.)< / div >
< / li >
< li class = "level1" > < div class = "li" > header_in(“Your-Request-Header”): any request header< / div >
< / li >
< / ul >
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT3 SECTION "Request informations" [1109 - 1515] -->
2015-06-08 16:57:58 +02:00
< h2 class = "sectionedit4" id = "extended_functions_list" > Extended Functions List< / h2 >
2012-02-25 23:45:20 +01:00
< div class = "level2" >
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT4 SECTION "Extended Functions List" [1516 - 1552] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit5" id = "date" > date< / h3 >
2012-02-25 23:45:20 +01:00
< div class = "level3" >
< p >
2014-07-21 14:36:50 +02:00
Returns the date, in format YYYYMMDDHHMMSS, local time by default, GMT by calling
2012-02-25 23:45:20 +01:00
< / p >
2014-07-21 14:36:50 +02:00
< pre class = "code" > date(1)< / pre >
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT5 SECTION "date" [1553 - 1672] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit6" id = "checklogonhours" > checkLogonHours< / h3 >
2014-07-21 14:36:50 +02:00
< div class = "level3" >
2012-02-25 23:45:20 +01:00
< p >
2014-07-21 14:36:50 +02:00
This function will check the day and the hour of current request, and compare it to allowed days and hours. It returns 1 if this match, 0 else.
All e
2012-02-25 23:45:20 +01:00
By default, the allowed days and hours is an hexadecimal value, representing each hour of the week. A day has 24 hours, and a week 7 days, so the value contains 168 bits, converted into 42 hexadecimal characters. Sunday is the first day.
< / p >
< p >
For example, for a full access, excepted week-end:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > 000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000< / pre >
2012-02-25 23:45:20 +01:00
< p >
2016-03-22 12:19:17 +01:00
< p > < div class = "notetip" > The < a href = "../../documentation/2.0/authldap.html#schema_extension" class = "wikilink1" title = "documentation:2.0:authldap" > LDAP schema extension< / a > can be used to store this value. You can also use the binary value from the logonHours attribute of Active Directory
2012-02-25 23:45:20 +01:00
< / div > < / p >
< / p >
< p >
Functions parameters:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > logon_hours< / strong > : string representing allowed logon hours (GMT)< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > syntax< / strong > (optional): < code > hexadecimal< / code > (default) or < code > octetstring< / code > < / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > time_correction< / strong > (optional): hours to add or to subtract< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > default_access< / strong > (optional): what result to return if < strong > logon_hours< / strong > is empty< / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > checkLogonHours($ssoLogonHours)< / pre >
2012-02-25 23:45:20 +01:00
< p >
If you use the binary value (Active Directory), use this:
< / p >
2014-07-21 14:36:50 +02:00
< pre class = "code" > All e
2015-06-08 16:57:58 +02:00
checkLogonHours($ssoLogonHours, ' octetstring' )< / pre >
2012-02-25 23:45:20 +01:00
< p >
You can also configure jetlag (if all of your users use the same timezone):
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > checkLogonHours($ssoLogonHours, ' ' , ' +2' )< / pre >
2012-02-25 23:45:20 +01:00
< p >
If you manage different timezones, you have to take the jetlag into account in ssoLogonHours values, or use the $_timezone parameter. This parameter is set by the portal and use javascript to get the connected user timezone. It should works on every browser:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > checkLogonHours($ssoLogonHours, ' ' , $_timezone)< / pre >
2012-02-25 23:45:20 +01:00
< p >
You can modify the default behavior for people without value in ssoLogonHours. Indeed, by default, users without logon hours values are rejected. You can allow these users instead of reject them:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > checkLogonHours($ssoLogonHours, ' ' , ' ' , ' 1' )< / pre >
2012-02-25 23:45:20 +01:00
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT6 SECTION "checkLogonHours" [1673 - 3610] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit7" id = "checkdate" > checkDate< / h3 >
2012-02-25 23:45:20 +01:00
< div class = "level3" >
< p >
This function will check the date of current request, and compare it to a start date and an end date. It returns 1 if this match, 0 else.
< / p >
< p >
2016-03-22 12:19:17 +01:00
< p > < div class = "notetip" > The < a href = "../../documentation/2.0/authldap.html#schema_extension" class = "wikilink1" title = "documentation:2.0:authldap" > LDAP schema extension< / a > can be used to store these values
2012-02-25 23:45:20 +01:00
< / div > < / p >
< / p >
< p >
2015-06-08 16:57:58 +02:00
The date format is the LDAP date syntax, for example for the 1st March 2009:
2012-02-25 23:45:20 +01:00
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > 20090301000000Z< / pre >
2012-02-25 23:45:20 +01:00
< p >
Functions parameters:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > start< / strong > : Start date (GMT)< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > end< / strong > : End date (GMT)< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > default_access< / strong > (optional): what result to return if < strong > start< / strong > and < strong > end< / strong > are empty< / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > checkDate($ssoStartDate, $ssoEndDate)< / pre >
2012-02-25 23:45:20 +01:00
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT7 SECTION "checkDate" [3611 - 4238] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit8" id = "basic" > basic< / h3 >
2012-02-25 23:45:20 +01:00
< div class = "level3" >
< p >
2016-03-22 12:19:17 +01:00
< p > < div class = "noteimportant" > This function is not compliant with < a href = "../../documentation/2.0/safejail.html" class = "wikilink1" title = "documentation:2.0:safejail" > Safe jail< / a > , you will need to disable the jail to use it.
2012-02-25 23:45:20 +01:00
< / div > < / p >
< / p >
< p >
2016-03-22 12:19:17 +01:00
This function builds the < code > Authorization< / code > HTTP header used in < a href = "../../documentation/2.0/applications/authbasic.html" class = "wikilink1" title = "documentation:2.0:applications:authbasic" > HTTP Basic authentication scheme< / a > . It will force conversion from UTF-8 to ISO-8859-1 of user and password data.
2012-02-25 23:45:20 +01:00
< / p >
< p >
Functions parameters:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > user< / strong > < / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > password< / strong > < / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > basic($uid,$_password)< / pre >
2012-02-25 23:45:20 +01:00
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT8 SECTION "basic" [4239 - 4701] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit9" id = "unicode2iso" > unicode2iso< / h3 >
2012-02-25 23:45:20 +01:00
< div class = "level3" >
< p >
2016-03-22 12:19:17 +01:00
< p > < div class = "noteimportant" > This function is not compliant with < a href = "../../documentation/2.0/safejail.html" class = "wikilink1" title = "documentation:2.0:safejail" > Safe jail< / a > , you will need to disable the jail to use it.
2012-02-25 23:45:20 +01:00
< / div > < / p >
< / p >
< p >
2015-06-08 16:57:58 +02:00
This function convert a string from UTF-8 to ISO-8859-1.
2012-02-25 23:45:20 +01:00
< / p >
< p >
Functions parameters:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > string< / strong > < / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > unicode2iso($name)< / pre >
2012-02-25 23:45:20 +01:00
< / div >
2015-10-05 16:53:35 +02:00
<!-- EDIT9 SECTION "unicode2iso" [4702 - 5006] -->
2015-06-08 16:57:58 +02:00
< h3 class = "sectionedit10" id = "iso2unicode" > iso2unicode< / h3 >
2012-02-25 23:45:20 +01:00
< div class = "level3" >
< p >
2016-03-22 12:19:17 +01:00
< p > < div class = "noteimportant" > This function is not compliant with < a href = "../../documentation/2.0/safejail.html" class = "wikilink1" title = "documentation:2.0:safejail" > Safe jail< / a > , you will need to disable the jail to use it.
2012-02-25 23:45:20 +01:00
< / div > < / p >
< / p >
< p >
2015-06-08 16:57:58 +02:00
This function convert a string from ISO-8859-1 to UTF-8.
2012-02-25 23:45:20 +01:00
< / p >
< p >
Functions parameters:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > string< / strong > < / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
2015-06-08 16:57:58 +02:00
< pre class = "code" > iso2unicode($name)< / pre >
2012-02-25 23:45:20 +01:00
2015-10-05 16:53:35 +02:00
< / div >
<!-- EDIT10 SECTION "iso2unicode" [5007 - 5311] -->
< h3 class = "sectionedit11" id = "groupmatch" > groupMatch< / h3 >
< div class = "level3" >
< p >
this function allows to parse the < code > $hGroups< / code > variable to check if a value is present inside a group attribute.
< / p >
< p >
Function parameter:
< / p >
< ul >
< li class = "level1" > < div class = "li" > < strong > groups< / strong > : < code > $hGroups< / code > variable< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > attribute< / strong > : Name of group attribute< / div >
< / li >
< li class = "level1" > < div class = "li" > < strong > value< / strong > : Value to check< / div >
< / li >
< / ul >
< p >
Simple usage example:
< / p >
< pre class = "code" > groupMatch($hGroups, ' description' , ' Service 1' )< / pre >
2012-02-25 23:45:20 +01:00
< / div >
2015-06-08 16:57:58 +02:00
< / div > <!-- closes <div class="dokuwiki export"> -->