File/src/common.php

Description

Common functions and handling

Every user accecible file should include this file. This will handle everything like security, menu's, headings and footers, multilanguage support, session locking etc.. It also contains a lot of very usefull files.

Includes
 include_once ("settings/settings.php") (line 38)
 require_once ("reg.php") (line 59)
 require_once ("sessionlock.php") (line 54)
 require_once ("lang_".$LANG.".php") (line 51)
 require_once ("log.php") (line 61)
 require_once ("comments/model.php") (line 66)
 require_once ("wizard/wizard.php") (line 85)
 require_once ("security.php") (line 58)
 require_once ("menu/menu.php") (line 65)
 require_once ("monitoring/state.php") (line 64)
 require_once ("menu/menu.php") (line 60)
 require_once ("proc.php") (line 63)
 require_once ("file.php") (line 62)
Functions
AddUri (line 1474)

add a url query-string to an existing uri, the correct way

http://bla becomes http://bla?$query but http://bla?test=1 becomes http://bla?test=1&$query

void AddUri ( $uri,  $query)
  • $uri
  • $query
BrowserFlush (line 1206)

Force the current php outputbuffers to be flushed to the browser.

We might need to output more data for IE.

void BrowserFlush ()
CalcIpRange (line 903)

Calculate the min and max ipadress from a cidr-iprange

  • return: array[0]=lowest ip array[1]=highest ip
array CalcIpRange (string $block)
  • string $block: Ip range in cidr notation: 1.2.3.0/24
CalcMask (line 1363)

calculate netmask from nr of subnetbits

void CalcMask ( $netbits)
  • $netbits
DayName (line 1407)

convert daynumber (0-6) to dayname

void DayName ( $daynr)
  • $daynr
Error (line 1147)

Abort execution of the phpscript and try to display the error $txt to the user in a nice formatted way.

The error will also be logged with LogError().

void Error ( $txt)
  • $txt
Foot (line 464)

Output the htmlcode for the page footer

Call this at the bottom of your page. Will show the logging output and hide the page progressing popup. Also will show the tip that you set with the Tip() function.

void Foot ([int $showlog = 1], [int $hideprogress = 1])
  • int $showlog: When this is 0 the logoutput wont popup and will be suppressed until the next page that has showlog=1.
  • int $hideprogress: If you set this 0 the progress indicator wont be hidden.
GetTimeBlocks (line 1519)

Bepaal een lijst van tijds-blokken voor gebruik in een selectbox $in['from'] starttijd vanaf waar men kan selecteren $in['to'] endtijd die men kan selecteren minimale blokgrootte: 1 week.

void GetTimeBlocks ([ $in = ''])
  • $in
HBar (line 1502)

Horizontale percentage bar, om staafdiagrammen mee te maken

void HBar ( $perc)
  • $perc
Head (line 272)

Output the htmlcode for the page head.

Call this before you output any html. Handles things like menu's, tips and logging popups and page progress indicators.

void Head ([hasharray $errors = ''], [string $showmenu = ''], [int $refresh = 0], [ $onload = ''], string $onload:)
  • hasharray $errors: A hasharray containing the inputfield that has an error. The focus will be set to this field on loading.
  • string $showmenu: If this has the value 'off' the menu will be hidden for the rest of the session.
  • int $refresh: Can contain the number of seconds to automaticly refresh the page.
  • string $onload:: javascript code to execute on load, before all the regular onload stuff <head>
  • $onload
Hostname (line 1484)

Gets current hostname of this machine

void Hostname ()
IncludeLang (line 23)

Include the language file for the specified script.

Usually used in librarys that are accessed from the command line. Usage would be like this litteraly: IncludeLang(__FILE__);

void IncludeLang ( $scriptname)
  • $scriptname
IncludeModules (line 1186)

includes $scriptname from all subdirectorys.

Every subdir in the SCC is a module. It will scan those subdirs for phpfiles named $scriptname and include them. We use this function to dynamicly build menus and stuff.

void IncludeModules ( $scriptname, [ $startdir = &quot;..&quot;])
  • $scriptname
  • $startdir
IsInstalled (line 1354)

Returns true if the packagename is installed.

Only specify the packagename, not the path or version of the package.

void IsInstalled ( $pkgname)
  • $pkgname
LinkButton (line 679)

Output a button with text $name that links to $url when clicked.

Don't use this inside forms!

void LinkButton (string $name, string $url, [string $confirm = ''], [int $enabled = 1], [int $secure = 0])
  • string $name: The text to appear in the button
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $enabled: Set this to 0 to make a disabled button.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkDefault (line 712)

Output a normal link with text $data that links to $url.

See also our wide variety of other link-functions :)

void LinkDefault (string $url, string $title, string $data, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $title: The text to appear as tooltip when hoovering over the url.
  • string $data: The htmldata or text that the user can click on.
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Alert (line 848)

Output a ALERT-status-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_Alert (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkIcon_Caution (line 839)

Output a CAUTION-status-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_Caution (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkIcon_Close (line 858)

Output close icon that links to $url.

void LinkIcon_Close (string $url, [string $confirm = ''])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
LinkIcon_Del (line 753)

Output a delete-icon that links to $url

void LinkIcon_Del (string $url, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Disable (line 774)

Output a disable-icon that links to $url

void LinkIcon_Disable (string $url, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Enable (line 763)

Output a enable-icon that links to $url

void LinkIcon_Enable (string $url, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Error (line 821)

Output a error-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_Error (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkIcon_Info (line 803)

Output a information-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_Info (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkIcon_OK (line 830)

Output a OK-status-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_OK (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkIcon_Start (line 784)

Output a start-icon that links to $url

void LinkIcon_Start (string $url, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Stop (line 794)

Output a stop-icon that links to $url

void LinkIcon_Stop (string $url, [string $confirm = ''], [int $secure = 0])
  • string $url: url to redirect to
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkIcon_Warn (line 812)

Output a warning-icon that links to $url, and shows $desc when user hovers over it.

void LinkIcon_Warn (string $url, [string $desc = ''])
  • string $url: url to redirect to
  • string $desc: Description to show when hovering over it.
LinkImage (line 743)

Output an image that links to $url.

See also our wide variety of other link-functions :)

void LinkImage (string $url, string $image, [string $confirm = ''], [int $secure = 0], string $data)
  • string $url: url to redirect to
  • string $image: the image to use.
  • string $data: The htmldata or text that the user can click on.
  • string $confirm: Use a confirmation java-popup, with the specified text.
  • int $secure: Set this to 1 to use a secure confirmation form, instead of a simple java-popup.
LinkupdownButton (line 873)

Display a grapical up/down button that links to $url

void LinkupdownButton (string $url, [string $updown = 'up'], [int $enabled = '1'], [string $confirm = ''])
  • string $url: url to redirect to
  • string $updown: Make this 'down' or 'up' for arrow graphic.
  • int $enabled: Make this 0 to disable (grayout) the selectbox
  • string $confirm: If this text is defined it will be displayed as a confirmation popup-box.
MonthName (line 1424)

convert monthnumber (1-12) to monthname

void MonthName ( $monthnr)
  • $monthnr
NiceBytes (line 927)

Returns a clearer view of the number of bytes

  • return: the number of kilo/megabytes
string NiceBytes (integer $bytes, [integer $round = 2], [integer $showformat = 1], [integer $showbytes = 1])
  • integer $bytes: the number of bytes
  • integer $round: the number of decimals (defaults to 2)
  • integer $showformat: show the format (KB MB etc) use 0 to disable
  • integer $showbytes: show the bytes (used only if you need the format of a bytes
OutputPdf (line 160)

Internal function, called as output buffer hook to convert output to pdf with htmlbook TODO: niet voorbereid op 2 aanroepen parallel, exress niet gedaan zodat /tmp niet volloopt bij problemen.

Dit probleem is niet meer van toepassing als we straks de hele SCC locken bij een request.

void OutputPdf ( $buffer)
  • $buffer
Progress (line 1232)

Display progress updates to the user in real time.

Use this for stuff that takes a long time. It also is called automaticly when the page is loading and when a script Logs something using the normal logging funtions. The implementation might seem quite hackish, but works perfectly. Use loadcomplete=1 to mark the pageloading as complete (in case of redirects) This is usefull to prevent our 'connection error' dialog from popping up. It also works in console mode. The function is intelligent: it will recognize percentage numbers and show them in the percentage bar.

void Progress ($scroller: $txt, [ $loadcomplete = 0], [ $scroller = 0])
  • $scroller: $txt: set this to 1 to add stuff in the scrolling progress window area, instead of the progress status bar.
  • $loadcomplete
  • $scroller
ProgressBar (line 1493)

Render a progressbar with pure html code

void ProgressBar ( $perc)
  • $perc
Redirect (line 605)

Redirect to an absolute or relative url

This function will always work. If the headers are already sent it will use META-tags to do a refresh/redirect.

void Redirect ( $url)
  • $url
RedirectViaPage (line 650)

redirect to $url but via a seperate processing page, showing the $txt for $time seconds.

void RedirectViaPage ( $time,  $txt,  $url)
  • $time
  • $txt
  • $url
RedirectViaYesNo (line 663)

Redirect to $url via a yes/no confirmation page. It will ask the user to accept the $txt and then redirect to $url. It will use a 'secure' form, so that the page cant be submitted twice.

If you have something very important that needs confirmation, always use this and dont use java popups!

void RedirectViaYesNo ( $txt,  $url)
  • $txt
  • $url
Seconds2TextRounded (line 1381)

Convert the number of seconds to a humanreadable text.

It will dynamicly round the time: It wont show the minutes and seconds when the time is several hours for example.

void Seconds2TextRounded ( $seconds)
  • $seconds
TestConnect (line 1132)

checks connection to a port, returns false when it works, otherwise an error string.

void TestConnect ( $hostname,  $port, [ $timeout = 10])
  • $hostname
  • $port
  • $timeout
Time2Text (line 1450)

convert timestamp to human readable time text TODO: date/time formattion localisation

void Time2Text ( $stamp, [ $precision = 't'])
  • $stamp
  • $precision
Tip (line 258)

set a tip for this page Call this before you call foot().

The tip will be remembered during the whole session, and a tip-button that the user can click will appear. In wizard mode the tip will always appear.

void Tip ( $desc)
  • $desc
Title (line 214)

set page title and update history tracker

Call this before you call head()

void Title ( $title)
  • $title
ValidDomain (line 1042)

return true if the domainname-syntax is valid

The miniumum number of 'fields' for a domainname is 2.

void ValidDomain ( $domain)
  • $domain
ValidEmail (line 1065)

return true if the email-address syntax is valid

void ValidEmail ( $address)
  • $address
ValidFQDN (line 1055)

return true if the FQDN, fully qualified domainname is valid

The miniumum number of 'fields' for a FQDN is 3.

void ValidFQDN ( $domain)
  • $domain
ValidHostname (line 1025)

return true if the hostname-syntax is valid

The miniumum number of 'fields' a hostname is 1.

void ValidHostname ( $domain)
  • $domain
ValidHTTPMethod (line 1125)

return true if $methode is a HTTP header method : PUT/GET/CONNECT/...

See also RFC2616

void ValidHTTPMethod ( $method)
  • $method
ValidIP (line 964)

return true if ip $adress is valid

void ValidIP ( $adress)
  • $adress
ValidMac (line 1015)

return true if the $mac is valid.

void ValidMac ( $mac)
  • $mac
ValidNetmask (line 971)

return true if $netmask (255.255.0.0 notation) is valid

void ValidNetmask ( $netmask)
  • $netmask
ValidNetworkInterface (line 1004)

return true if the given interface is valid.

Format: Interface excists in $ALL_ZONES.

void ValidNetworkInterface ( $interface)
  • $interface
ValidPasswd (line 1093)

return true if the password-syntax is valid

TODO: te beperkt, uitzoeken of dit uitgebreider kan!

void ValidPasswd ( $passwd)
  • $passwd
ValidPort (line 1107)

return true if $port is a valid network port number

void ValidPort ( $port)
  • $port
ValidSmbShareName (line 1114)

return true if smbsharename has the correct syntax

void ValidSmbShareName ( $share)
  • $share
ValidSubnet (line 995)

return true if the $subnet is valid.

In CIDR format: 1.2.3.0/24

void ValidSubnet ( $subnet)
  • $subnet
ValidUser (line 1076)

return true if the username-syntax is valid

void ValidUser ( $user)
  • $user
ValidVarname (line 1100)

return true if the variabellename-syntax is valid

void ValidVarname ( $name)
  • $name

Documentation generated on Tue, 06 Jan 2009 12:38:12 +0100 by phpDocumentor 1.4.1