Procedural File: lib-common.php
Source Location: /public_html/lib-common.php
Page Details:
This is the common library for Geeklog. Through our code, you will see functions with the COM_ prefix (e.g. COM_siteHeader()). Any such functions can be found in this file.
--- You don't need to modify anything in this file! --- WARNING: put any custom hacks in lib-custom.php and not in here. This file is modified frequently by the Geeklog development team. If you put your hacks in lib-custom.php you will find upgrading much easier.
Includes:
require_once($_CONF['path'].'plugins/'.$pi_name.'/functions.inc') [line 7515]
Now include all plugin functions require_once($_CONF['path_language'].$_CONF['language'].'.php') [line 399]
Language include require_once($_CONF['path_system'].'classes/scripts.class.php') [line 308]
Include the Scripts class This provides the ability to set css and javascript. require_once($_CONF['path_system'].'classes/kses.class.php') [line 254]
Ulf Harnhammar's kses class require_once('siteconfig.php') [line 87]
Configuration Include: You do NOT need to modify anything here any more! require_once($_CONF['path_layout'].'functions.php') [line 315]
Include theme functions file which may/may not do anything require_once($_CONF['path_system'].'lib-sessions.php') [line 241]
Session management library require_once($_CONF['path_system'].'lib-mbyte.php') [line 260]
Multibyte functions require_once($_CONF['path_system'].'classes/config.class.php') [line 94]
Configuration class require_once($_CONF['path_system'].'lib-security.php') [line 206]
This is the security library used for application security require_once($_CONF['path_system'].'classes/template.class.php') [line 199]
This is our HTML template class. It is the same one found in PHPLib and is licensed under the LGPL. See that file for details. require_once($_CONF['path_system'].'classes/url.class.php') [line 190]
Include URL class This provides optional URL rewriting functionality. require_once($_CONF['path_system'].'classes/timer.class.php') [line 180]
Include page time -- used to time how fast each page was created require_once($_CONF['path_system'].'lib-plugins.php') [line 173]
Include plugin class. This is a poorly implemented class that was not very well thought out. Still very necessary require_once($_CONF['path_system'].'lib-syndication.php') [line 213]
This is the syndication library used to offer (RSS) feeds. require_once($_CONF['path_system'].'classes/timezoneconfig.class.php') [line 163]
Set the webserver's timezone require_once($_CONF['path_system'].'lib-custom.php') [line 234]
This is the custom library. It is the sandbox for every Geeklog Admin to play in. The lib-custom.php as shipped will never contain required code, so it's safe to always use your own copy. This should hold all custom hacks to make upgrading easier.
Boolean $_COM_VERBOSE [line 56]
array $_GROUPS [line 422]
array $_RIGHTS [line 436]
COM_accessLog [line 2102]
void COM_accessLog(
string $logentry)
|
|
Logs message to access.log This will print a message to the Geeklog access log
Tags:
Parameters
| string |
$logentry |
Message to write to access log |
COM_adminMenu [line 2499]
void COM_adminMenu(
[string $help = ''], [string $title = ''], [string $position = ''])
|
|
Prints administration menu This will return the administration menu items that the user has sufficient rights to -- Admin Block on the left side.
Tags:
Parameters
| string |
$help |
Help file to show |
| string |
$title |
Menu Title |
| string |
$position |
Side being shown on 'left', 'right' or blank. |
COM_allowedHTML [line 3910]
string COM_allowedHTML(
[string $permissions = 'story.edit'], [boolean $list_only = false], [boolean $filter_html_flag = 1])
|
|
Returns what HTML is allowed in content Returns what HTML tags the system allows to be used inside content. You can modify this by changing $_CONF['user_html'] in the configuration (for admins, see also $_CONF['admin_html']).
Tags:
Parameters
| string |
$permissions |
comma-separated list of rights which identify the current user as an "Admin" |
| boolean |
$list_only |
true = return only the list of HTML tags |
| boolean |
$filter_html_flag |
- = returns allowed all html tags, 1 = returns allowed HTML tags only, 2 = returns No HTML Tags Allowed (this is used by plugins if they have a config that overrides Geeklogs filter html settings or do not have a post mode)
|
COM_applyBasicFilter [line 5771]
string COM_applyBasicFilter(
string $parameter, [boolean $isnumeric = false])
|
|
Filter parameters NOTE: Use this function instead of COM_applyFilter for parameters _not_ coming in through a GET or POST request.
Tags:
Parameters
| string |
$parameter |
the parameter to test |
| boolean |
$isnumeric |
true if $parameter is supposed to be numeric |
COM_applyFilter [line 5752]
string COM_applyFilter(
string $parameter, [boolean $isnumeric = false])
|
|
Filter parameters passed per GET (URL) or POST.
Tags:
Parameters
| string |
$parameter |
the parameter to test |
| boolean |
$isnumeric |
true if $parameter is supposed to be numeric |
COM_buildURL [line 5390]
string COM_buildURL(
string $url)
|
|
Wrapper function for URL class so as to not confuse people as this will eventually get used all over the place This function returns a crawler friendly URL (if possible)
Tags:
Parameters
| string |
$url |
URL to try to build crawler friendly URL for |
COM_checkHTML [line 2987]
string COM_checkHTML(
string $str, [string $permissions = 'story.edit'])
|
|
This function checks html tags. Checks to see that the HTML tags are on the approved list and removes them if not.
Tags:
Parameters
| string |
$str |
HTML to check |
| string |
$permissions |
comma-separated list of rights which identify the current user as an "Admin" |
COM_checkInstalled [line 7431]
void COM_checkInstalled(
)
|
|
Check if Geeklog has been installed yet This is a (very) simple check to see if the user already ran the install script. If not, abort and display a nice(r) welcome screen with handy links to the install script and instructions. Inspired by MediaWiki ...
COM_checkList [line 1796]
string COM_checkList(
string $table, string $selection, [string $where = ''], [string $selected = ''], [string $fieldname = ''])
|
|
Creates a <input> checklist from a database list for use in forms Creates a group of checkbox form fields with given arguments
Tags:
Parameters
| string |
$table |
DB Table to pull data from |
| string |
$selection |
Comma delimited list of fields to pull from table |
| string |
$where |
Where clause of SQL statement |
| string |
$selected |
Value to set to CHECKED |
| string |
$fieldname |
Name to use for the checkbox array |
COM_checkSpeedlimit [line 5289]
int COM_checkSpeedlimit(
[string $type = 'submit'], [int $max = 1], [string $property = ''])
|
|
Check if speed limit applies
Tags:
Parameters
| string |
$type |
type of speed limit, e.g. 'submit', 'comment' |
| int |
$max |
max number of allowed tries within speed limit |
| string |
$property |
IP address or other identifiable property |
COM_checkWords [line 2894]
string COM_checkWords(
string $Message)
|
|
This censors inappropriate content This will replace 'bad words' with something more appropriate
Tags:
Parameters
| string |
$Message |
String to check |
COM_clearSpeedlimit [line 5348]
void COM_clearSpeedlimit(
[speedlimit $speedlimit = 60], [type $type = ''])
|
|
Clear out expired speed limits, i.e. entries older than 'x' seconds
Parameters
| speedlimit |
$speedlimit |
int number of seconds |
| type |
$type |
string type of speed limit, e.g. 'submit', 'comment' |
COM_convertDate2Timestamp [line 6276]
int COM_convertDate2Timestamp(
string $date, [string $time = ''])
|
|
Convert a text based date YYYY-MM-DD to a unix timestamp integer value
Tags:
Parameters
| string |
$date |
Date in the format YYYY-MM-DD |
| string |
$time |
Option time in the format HH:MM::SS |
COM_createImage [line 6451]
string COM_createImage(
string $url, [string $alt = ""], [array $attr = array()])
|
|
Create an HTML img
Tags:
Parameters
| string |
$url |
the URL of the image, either starting with http://... or $_CONF['layout_url'] is prepended |
| string |
$alt |
the 'alt'-tag of the image |
| array |
$attr |
an array of optional attributes for the link for example array('title' => 'whatever'); |
COM_createLink [line 6428]
string COM_createLink(
string $content, string $url, [array $attr = array()])
|
|
Create an HTML link
Tags:
Parameters
| string |
$content |
the object to be linked (text, image etc) |
| string |
$url |
the URL the link will point to |
| array |
$attr |
an array of optional attributes for the link for example array('title' => 'whatever'); |
COM_createMetaTags [line 7153]
string COM_createMetaTags(
string $meta_description, string $meta_keywords)
|
|
Create Meta Tags to be used by COM_siteHeader in the headercode variable
Tags:
Parameters
| string |
$meta_description |
the text for the meta description of the page being displayed |
| string |
$meta_keywords |
the text for the meta keywords of the page being displayed |
COM_dateDiff [line 6042]
int COM_dateDiff(
string $interval, string|int $date1, string|int $date2)
|
|
Determines the difference between two dates. This will takes either unixtimestamps or English dates as input and will automatically do the date diff on the more recent of the two dates (e.g. the order of the two dates given doesn't matter).
Tags:
Parameters
| string |
$interval |
Can be: y = year m = month w = week h = hours i = minutes s = seconds |
| string|int |
$date1 |
English date (e.g. 10 Dec 2004) or unixtimestamp |
| string|int |
$date2 |
English date (e.g. 10 Dec 2004) or unixtimestamp |
COM_debug [line 1886]
string COM_debug(
array $array)
|
|
Prints out an associative array for debugging The core of this code has been lifted from phpweblog which is licenced under the GPL. This is not used very much in the code but you can use it if you see fit
Tags:
Parameters
| array |
$array |
Array to loop through and print values for |
COM_displayMessageAndAbort [line 6360]
void COM_displayMessageAndAbort(
int $msg, [string $plugin = ''], [int $http_status = 200], [string $http_text = 'OK'])
|
|
Display a message and abort NOTE: Displays the message and aborts the script.
Parameters
| int |
$msg |
message number |
| string |
$plugin |
plugin name, if applicable |
| int |
$http_status |
HTTP status code to send with the message |
| string |
$http_text |
Textual version of the HTTP status code |
COM_emailEscape [line 3182]
string COM_emailEscape(
string $string)
|
|
Encode a string such that it can be used in an email header
Tags:
Parameters
| string |
$string |
the text to be encoded |
COM_emailUserTopics [line 4110]
void COM_emailUserTopics(
)
|
|
This will email new stories in the topics that the user is interested in In account information the user can specify which topics for which they will receive any new article for in a daily digest.
COM_endBlock [line 1589]
string COM_endBlock(
[string $template = 'blockfooter.thtml'])
|
|
Closes out COM_startBlock
Tags:
Parameters
| string |
$template |
HTML template file used to format block footer |
COM_errorLog [line 2016]
string COM_errorLog(
string $logentry, [int $actionid = ''])
|
|
Logs messages to error.log or the web page or both Prints a well formatted message to either the web page, error log or both.
Tags:
Parameters
| string |
$logentry |
Text to log to error log |
| int |
$actionid |
where 1 = write to log file, 2 = write to screen (default) both |
COM_featuredCheck [line 1968]
void COM_featuredCheck(
)
|
|
Checks and Updates the featured status of all articles. Checks to see if any articles that were published for the future have been published and, if so, will see if they are featured. If they are featured, this will set old featured article (if there is one) to normal
COM_formatBlock [line 3627]
string COM_formatBlock(
array $A, [boolean $noboxes = false])
|
|
Formats a Geeklog block This shows a single block and is typically called from COM_showBlocks OR from plugin code
Tags:
Parameters
| array |
$A |
Block Record |
| boolean |
$noboxes |
Set to true if userpref is no blocks |
COM_formatEmailAddress [line 3225]
string COM_formatEmailAddress(
string $name, string $address)
|
|
Takes a name and an email address and returns a string that vaguely resembles an email address specification conforming to RFC(2)822 ...
Tags:
Parameters
| string |
$name |
name, e.g. John Doe |
| string |
$address |
email address only, e.g. john.doe@example.com |
COM_formatTimeString [line 4505]
void COM_formatTimeString(
string $time_string, int $time, [string $type = ''], [int $amount = 0])
|
|
Creates the string that indicates the timespan in which new items were found
Parameters
| string |
$time_string |
template string |
| int |
$time |
number of seconds in which results are found |
| string |
$type |
type (translated string) of new item |
| int |
$amount |
amount of things that have been found. |
COM_getAmPmFormSelection [line 5210]
string COM_getAmPmFormSelection(
string $name, [string $selected = ''])
|
|
Create an am/pm selector dropdown menu
Tags:
Parameters
| string |
$name |
name of the <select> |
| string |
$selected |
preselection: 'am' or 'pm' |
COM_getArgument [line 5422]
string COM_getArgument(
string $name)
|
|
Wrapper function for URL class returns value for specified argument
Tags:
Parameters
| string |
$name |
argument to get value for |
COM_getBlockTemplate [line 473]
string COM_getBlockTemplate(
string $blockname, string $which, [string $position = ''])
|
|
Return the file to use for a block template. This returns the template needed to build the HTML for a block. This function allows designers to give a block it's own custom look and feel. If no templates for the block are specified, the default blockheader.html and blockfooter.html will be used.
Tags:
Parameters
| string |
$blockname |
corresponds to name field in block table |
| string |
$which |
can be either 'header' or 'footer' for corresponding template |
| string |
$position |
can be 'left', 'right' or blank. If set, will be used to find a side specific override template. |
COM_getCharset [line 6935]
Get the current character set Uses (if available, and in this order) - $LANG_CHARSET (from the current language file)
- $_CONF['default_charset'] (from siteconfig.php)
- 'iso-8859-1' (hard-coded fallback)
Tags:
COM_getCurrentURL [line 6132]
string COM_getCurrentURL(
)
|
|
Try to figure out our current URL, including all parameters. This is an ugly hack since there's no single variable that returns what we want and the variables used here may not be available on all servers and / or setups. Seems to work on Apache (1.3.x and 2.x), IIS, and Zeus ...
Tags:
COM_getDayFormOptions [line 4999]
string COM_getDayFormOptions(
[string $selected = ''])
|
|
Gets the <option> values for calendar days
Tags:
Parameters
| string |
$selected |
Selected day |
COM_getDisplayName [line 4041]
string COM_getDisplayName(
[int $uid = ''], [string $username = ''], [string $fullname = ''], [string $remoteusername = ''], [string $remoteservice = ''])
|
|
Return the username or fullname for the passed member id (uid) Allows the siteAdmin to determine if loginname (username) or fullname should be displayed.
Tags:
Parameters
| int |
$uid |
site member id |
| string |
$username |
Username, if this is set no lookup is done. |
| string |
$fullname |
Users full name. |
| string |
$remoteusername |
Username on remote service |
| string |
$remoteservice |
Remote login service. |
COM_getHourFormOptions [line 5081]
string COM_getHourFormOptions(
[string $selected = ''], [int $mode = 12])
|
|
Gets the <option> values for clock hours
Tags:
Parameters
| string |
$selected |
Selected hour |
| int |
$mode |
12 or 24 hour mode |
COM_getImgSizeAttributes [line 6332]
string COM_getImgSizeAttributes(
string $file)
|
|
Get the HTML for an image with height & width
Tags:
Parameters
| string |
$file |
full path to the file |
COM_getLangSQL [line 6588]
string COM_getLangSQL(
string $field, [string $type = 'WHERE'], [string $table = ''])
|
|
Return SQL expression to request language-specific content Creates part of an SQL expression that can be used to request items in the current language only.
Tags:
Parameters
| string |
$field |
name of the "id" field, e.g. 'sid' for stories |
| string |
$type |
part of the SQL expression, e.g. 'WHERE', 'AND' |
| string |
$table |
table name if ambiguous, e.g. in JOINs |
COM_getLanguage [line 6517]
string COM_getLanguage(
)
|
|
Determine current language
Tags:
COM_getLanguageFromBrowser [line 6483]
string COM_getLanguageFromBrowser(
)
|
|
Try to determine the user's preferred language by looking at the "Accept-Language" header sent by their browser (assuming they bothered to select a preferred language there). Sample header: Accept-Language: en-us,en;q=0.7,de-de;q=0.3
Tags:
COM_getLanguageId [line 6553]
string COM_getLanguageId(
[string $language = ''])
|
|
Determine the ID to use for the current language The $_CONF['language_files'] array maps language IDs to language file names. This function returns the language ID for a certain language file, to be used in language-dependent URLs.
Tags:
Parameters
| string |
$language |
current language file name (optional) |
COM_getLanguageName [line 6725]
string COM_getLanguageName(
)
|
|
Get the name of the current language, minus the character set Strips the character set from $_CONF['language'].
Tags:
COM_getMinuteFormOptions [line 5159]
string COM_getMinuteFormOptions(
[string $selected = ''], [int $step = 1])
|
|
Gets the <option> values for clock minutes
Tags:
Parameters
| string |
$selected |
Selected minutes |
| int |
$step |
number of minutes between options, e.g. 15 |
COM_getMinuteOptions [line 5197]
void COM_getMinuteOptions(
[ $selected = ''], [ $step = 1])
|
|
For backward compatibility only. This function should always have been called COM_getMinuteFormOptions
Tags:
Parameters
COM_getMonthFormOptions [line 4966]
string COM_getMonthFormOptions(
[string $selected = ''])
|
|
Gets the <option> values for calendar months
Tags:
Parameters
| string |
$selected |
Selected month |
COM_getNoScript [line 6751]
string COM_getNoScript(
[boolean $warning = true], [string $noscript_message = ''], [string $link_message = ''])
|
|
Returns text that will display if JavaScript is not enabled in the browser
Tags:
Parameters
| boolean |
$warning |
If true displays default JavaScript recommended warning message If false displays default JavaScript Required message |
| string |
$noscript_message |
Used instead of default message |
| string |
$link_message |
Secondary message that may contain a link |
COM_getPassword [line 4004]
string COM_getPassword(
string $loginname)
|
|
Return the password for the given username Fetches a password for the given user
Tags:
Parameters
| string |
$loginname |
username to get password for |
COM_getPermSQL [line 5580]
string COM_getPermSQL(
[string $type = 'WHERE'], [int $u_id = 0], [int $access = 2], [string $table = ''])
|
|
Return SQL expression to check for permissions. Creates part of an SQL expression that can be used to request items with the standard set of Geeklog permissions.
Tags:
Parameters
| string |
$type |
part of the SQL expr. e.g. 'WHERE', 'AND' |
| int |
$u_id |
user id or 0 = current user |
| int |
$access |
access to check for (2=read, 3=r&write) |
| string |
$table |
table name if ambiguous (e.g. in JOINs) |
COM_getPermTag [line 5509]
int COM_getPermTag(
int $owner_id, int $group_id, int $perm_owner, int $perm_group, int $perm_members, int $perm_anon, [ $u_id = 0], int $uid)
|
|
Check for Tag usuage permissions. This function takes the usuage access info of the autotag passed to it and let's us know if the user has access to use the autotag.
Tags:
Parameters
| int |
$owner_id |
ID of the owner of object |
| int |
$group_id |
ID of group object belongs to |
| int |
$perm_owner |
Permissions the owner has |
| int |
$perm_group |
Permissions the gorup has |
| int |
$perm_members |
Permissions logged in members have |
| int |
$perm_anon |
Permissions anonymous users have |
| int |
$uid |
User ID to get information for. If empty current user. |
| |
$u_id |
|
COM_getRate [line 5440]
int COM_getRate(
int $occurrences, int $timespan)
|
|
Occurences / time This will take a number of occurrences, and number of seconds for the time span and return the smallest #/time interval
Tags:
Parameters
| int |
$occurrences |
how many occurrences during time interval |
| int |
$timespan |
time interval in seconds |
COM_getTextContent [line 7307]
string COM_getTextContent(
string $text)
|
|
Turn a piece of HTML into continuous(!) plain text This function removes HTML tags, line breaks, etc. and returns one long line of text. This is useful for word counts (do an explode() on the result) and for text excerpts.
Tags:
Parameters
| string |
$text |
original text, including HTML and line breaks |
COM_getThemes [line 553]
array COM_getThemes(
[boolean $all = false])
|
|
Gets all installed themes Returns a list of all the directory names in $_CONF['path_themes'], i.e. a list of all the theme names.
Tags:
Parameters
| boolean |
$all |
if true, return all themes even if users aren't allowed to change their default themes |
COM_getTooltip [line 6795]
string COM_getTooltip(
[string $hoverover = ''], [string $text = ''], [string $link = ''], [string $title = ''], [string $template = 'classic'], [string $class = 'gl-tooltip'])
|
|
Returns an text/image that will display a tooltip This tooltip is based on an example from http://downloads.sixrevisions.com/css-tooltips/index.html
Tags:
Parameters
| string |
$hoverover |
Text or image to display for the user to hover their mouse cursor over. |
| string |
$text |
Text for the actual tooltip. Can include HTML. |
| string |
$link |
Link for the tooltip. If passed, then the hoverover text becomes a link. |
| string |
$title |
Text for the tooltip title (if there is one). Can include HTML. |
| string |
$template |
Specify a different template to use (classic, critical, help, information, warning). |
| string |
$class |
Specify a different tooltip class to use. |
COM_getTopicImageUrl [line 6382]
string COM_getTopicImageUrl(
string $imageurl)
|
|
Return full URL of a topic icon
Tags:
Parameters
| string |
$imageurl |
(relative) topic icon URL |
COM_getTopicSQL [line 5665]
string COM_getTopicSQL(
[string $type = 'WHERE'], [int $u_id = 0], [string $table = ''])
|
|
Return SQL expression to check for allowed topics. Creates part of an SQL expression that can be used to only request stories from topics to which the user has access to. Note that this function does an SQL request, so you should cache the resulting SQL expression if you need it more than once.
Tags:
Parameters
| string |
$type |
part of the SQL expr. e.g. 'WHERE', 'AND' |
| int |
$u_id |
user id or 0 = current user |
| string |
$table |
table name if ambiguous (e.g. in JOINs) |
COM_getUserCookieTimeout [line 4835]
int COM_getUserCookieTimeout(
)
|
|
Returns user-defined cookie timeout In account preferences users can specify when their long-term cookie expires. This function returns that value.
Tags:
COM_getUserDateTimeFormat [line 4781]
array COM_getUserDateTimeFormat(
[string $date = ''])
|
|
Returns formatted date/time for user This function COM_takes a date in either unixtimestamp or in english and formats it to the users preference. If the user didn't specify a format the format in the config file is used. This returns an array where array[0] is the formatted date and array[1] is the unixtimestamp
Tags:
Parameters
| string |
$date |
date to format, otherwise we format current date/time |
COM_getYearFormOptions [line 5043]
string COM_getYearFormOptions(
[string $selected = ''], [int $startoffset = -1], [int $endoffset = 5])
|
|
Gets the <option> values for calendar years Returns Option list Containing 5 years starting with current unless @selected is < current year then starts with @selected
Tags:
Parameters
| string |
$selected |
Selected year |
| int |
$startoffset |
Optional (can be +/-) Used to determine start year for range of years |
| int |
$endoffset |
Optional (can be +/-) Used to determine end year for range of years |
COM_handleCode [line 2966]
string COM_handleCode(
string $str)
|
|
Handles the part within a [code] ... [/code] section, i.e. escapes all special characters.
Tags:
Parameters
| string |
$str |
the code section to encode |
COM_handleError [line 6971]
void COM_handleError(
int $errno, string $errstr, [string $errfile = ''], [int $errline = 0], [array $errcontext = ''])
|
|
Handle errors. This function will handle all PHP errors thrown at it, without exposing paths, and hopefully, providing much more information to Root Users than the default white error page. This function will call out to CUSTOM_handleError if it exists, but, be advised, only override this function with a very, very stable function. I'd suggest one that outputs some static, basic HTML. The PHP feature that allows us to do so is documented here: http://uk2.php.net/manual/en/function.set-error-handler.php
Parameters
| int |
$errno |
Error Number. |
| string |
$errstr |
Error Message. |
| string |
$errfile |
The file the error was raised in. |
| int |
$errline |
The line of the file that the error was raised at. |
| array |
$errcontext |
An array that points to the active symbol table at the point the error occurred. |
COM_highlightQuery [line 5989]
string COM_highlightQuery(
string $text, string $query, [string $class = 'highlight'])
|
|
Highlight the words from a search query in a given text string.
Tags:
Parameters
| string |
$text |
the text |
| string |
$query |
the search query |
| string |
$class |
html class to use to highlight |
COM_hit [line 4090]
Adds a hit to the system This function is called in the footer of every page and is used to track the number of hits to the Geeklog system. This information is shown on stats.php
COM_isAnonUser [line 7124]
boolean COM_isAnonUser(
[int $uid = ''])
|
|
Checks to see if a specified user, or the current user if non-specified is the anonymous user.
Tags:
Parameters
| int |
$uid |
ID of the user to check, or none for the current user. |
COM_isEmail [line 3165]
boolean COM_isEmail(
string $email)
|
|
Checks to see if email address is valid. This function checks to see if an email address is in the correct from.
Tags:
Parameters
| string |
$email |
Email address to verify |
COM_isFrontpage [line 6238]
Check if we're on Geeklog's index page [deprecated] Note that this function returns FALSE when we're on the index page. Due to the inverted return values, it has been deprecated and is only provided for backward compatibility - use COM_onFrontpage() instead.
Tags:
COM_killJS [line 2952]
string COM_killJS(
string $Message)
|
|
Takes some amount of text and replaces all javascript events on*= with in This script takes some amount of text and matches all javascript events, on*= (onBlur= onMouseClick=) and replaces them with in*= Essentially this will cause onBlur to become inBlur, onFocus to be inFocus These are not valid javascript events and the browser will ignore them.
Tags:
Parameters
| string |
$Message |
Text to filter |
COM_mail [line 3263]
boolean COM_mail(
string $to, string $subject, string $message, [string $from = ''], [boolean $html = false], [int $priority = 0], [mixed $optional = null])
|
|
Send an email. All emails sent by Geeklog are sent through this function. NOTE: Please note that using CC: will expose the email addresses of all recipients. Use with care.
Tags:
Parameters
| string |
$to |
recipients name and email address |
| string |
$subject |
subject of the email |
| string |
$message |
the text of the email |
| string |
$from |
(optional) sender of the the email |
| boolean |
$html |
(optional) true if to be sent as HTML email |
| int |
$priority |
(optional) add X-Priority header, if > 0 |
| mixed |
$optional |
(optional) other headers or CC: |
COM_makeClickableLinks [line 5925]
string COM_makeClickableLinks(
string $text)
|
|
Detect links in a plain-ascii text and turn them into clickable links. Will detect links starting with "http:", "https:", "ftp:", and "www.".
Tags:
Parameters
| string |
$text |
the (plain-ascii) text string |
COM_makeClickableLinksCallback [line 5958]
string COM_makeClickableLinksCallback(
string $http, string $link)
|
|
Callback function to help format links in COM_makeClickableLinks
Tags:
Parameters
| string |
$http |
set to 'http://' when not already in the url |
| string |
$link |
the url |
COM_makeList [line 5253]
string COM_makeList(
array $listofitems, [string $classname = ''])
|
|
Creates an HTML unordered list from the given array. It formats one list item per array element, using the list.thtml and listitem.thtml templates.
Tags:
Parameters
| array |
$listofitems |
Items to list out |
| string |
$classname |
optional CSS class name for the list |
COM_makesid [line 3148]
Makes an ID based on current date/time This function creates a 17 digit sid for stories based on the 14 digit date and a 3 digit random number that was seeded with the number of microseconds (.000001th of a second) since the last full second. NOTE: this is now used for more than just stories!
Tags:
COM_newTemplate [line 7491]
object An COM_newTemplate(
string $root, [array $options = array()])
|
|
Provide support for drop-in replacable template engines
Tags:
Parameters
| string |
$root |
Path to template root |
| array |
$options |
List of options to pass to constructor |
COM_numberFormat [line 6251]
string COM_numberFormat(
float $number)
|
|
Converts a number for output into a formatted number with thousands- separator, comma-separator and fixed decimals if necessary
Tags:
Parameters
| float |
$number |
Number that will be formatted |
COM_olderStuff [line 3363]
Creates older stuff block Creates the olderstuff block for display. Actually updates the olderstuff record in the gl_blocks database.
COM_onFrontpage [line 6203]
boolean COM_onFrontpage(
)
|
|
Check if we're on Geeklog's index page. See if we're on the main index page (first page, no topics selected).
Tags:
COM_optionList [line 1624]
string COM_optionList(
string $table, string $selection, [string/array $selected = ''], [int $sortcol = 1], [string $where = ''])
|
|
Creates a <option> list from a database list for use in forms Creates option list form field using given arguments
Tags:
Parameters
| string |
$table |
Database Table to get data from |
| string |
$selection |
Comma delimited string of fields to pull The first field is the value of the option and the second is the label to be displayed. This is used in a SQL statement and can include DISTINCT to start. |
| string/array |
$selected |
Value (from $selection) to set to SELECTED or default |
| int |
$sortcol |
Which field to sort option list by 0 (value) or 1 (label) |
| string |
$where |
Optional WHERE clause to use in the SQL Selection |
COM_output [line 7264]
void COM_output(
string $display)
|
|
Sends compressed output to browser. Assumes that $display contains the _entire_ output for a request - no echoes are allowed before or after this function. Currently only supports gzip compression. Checks if zlib compression is enabled in PHP and does uncompressed output if it is.
Parameters
| string |
$display |
Content to send to browser |
COM_printPageNavigation [line 4662]
string COM_printPageNavigation(
string $base_url, int $curpage, int $num_pages, [string $page_str = 'page='], [boolean $do_rewrite = false], [string $msg = ''], [string $open_ended = ''])
|
|
Prints Google(tm)-like paging navigation
Tags:
Parameters
| string |
$base_url |
base url to use for all generated links. If an array, then the current parameter as the first part of the url, and the end is the last part of the url |
| int |
$curpage |
current page we are on |
| int |
$num_pages |
Total number of pages |
| string |
$page_str |
page-variable name AND '=' |
| boolean |
$do_rewrite |
if true, url-rewriting is respected |
| string |
$msg |
to be displayed with the navigation |
| string |
$open_ended |
replace next/last links with this |
COM_rdfCheck [line 3764]
void COM_rdfCheck(
string $bid, string $rdfurl, string $date, [string $maxheadlines = 0])
|
|
Checks to see if it's time to import and RDF/RSS block again Updates RDF/RSS block if needed
Tags:
Parameters
| string |
$bid |
Block ID |
| string |
$rdfurl |
URL to get headlines from |
| string |
$date |
Last time the headlines were imported |
| string |
$maxheadlines |
max. number of headlines to import |
COM_rdfImport [line 3792]
void COM_rdfImport(
string $bid, string $rdfurl, [int $maxheadlines = 0])
|
|
Syndication import function. Imports headline data to a portal block. Rewritten December 19th 2004 by Michael Jervis (mike AT fuckingbrit DOT com). Now utilises a Factory Pattern to open a URL and automaticaly retreive a feed object populated with feed data. Then import it into the portal block.
Tags:
Parameters
| string |
$bid |
Block ID |
| string |
$rdfurl |
URL to get content from |
| int |
$maxheadlines |
Maximum number of headlines to display |
COM_rdfUpToDateCheck [line 1917]
void COM_rdfUpToDateCheck(
[string $updated_type = ''], [string $updated_topic = ''], [string $updated_id = ''])
|
|
Checks to see if RDF file needs updating and updates it if so. Checks to see if we need to update the RDF as a result of an article with a future publish date reaching it's publish time and if so updates the RDF file. NOTE: When called without parameters, this will only check for new entries to include in the feeds. Pass the $updated_XXX parameters when the content of an existing entry has changed.
Tags:
Parameters
| string |
$updated_type |
(optional) feed type to update |
| string |
$updated_topic |
(optional) feed topic to update |
| string |
$updated_id |
(optional) feed id to update |
COM_refresh [line 2864]
string COM_refresh(
string $url)
|
|
Redirects user to a given URL This function does a redirect using a meta refresh. This is (or at least used to be) more compatible than using a HTTP Location: header. NOTE: This does not need to be XHTML compliant. It may also be used in situations where the XHTML constant is not defined yet ...
Tags:
Parameters
| string |
$url |
URL to send user to |
COM_renderMenu [line 593]
void COM_renderMenu(
Template &$header, array $plugin_menu)
|
|
Create the menu, i.e. replace {menu_elements} in the site header with the actual menu entries.
Parameters
| Template |
&$header |
reference to the header template |
| array |
$plugin_menu |
array of plugin menu entries, if any |
COM_renderWikiText [line 7180]
string COM_renderWikiText(
string $wikitext)
|
|
Convert wiki-formatted text to (X)HTML
Tags:
Parameters
| string |
$wikitext |
wiki-formatted text |
COM_resetSpeedlimit [line 5367]
void COM_resetSpeedlimit(
[string $type = 'submit'], [string $property = ''])
|
|
Reset the speedlimit
Parameters
| string |
$type |
type of speed limit to reset, e.g. 'submit' |
| string |
$property |
IP address or other identifiable property |
COM_rootDebugClean [line 7098]
array COM_rootDebugClean(
array $array, [boolean $blank = false])
|
|
Recurse through the error context array removing/blanking password/cookie values in case the "for development" only switch is left on in a production environment. [Not fit for public consumption comments about what users who enable root debug in production should have done to them, and why making this change defeats the point of the entire root debug feature go here.]
Tags:
Parameters
| array |
$array |
Array of state info (Recursive array). |
| boolean |
$blank |
override (wouldn't that blank out everything?) |
COM_sanitizeFilename [line 5905]
string COM_sanitizeFilename(
string $filename, [boolean $allow_dots = false])
|
|
Sanitize a filename. NOTE: This function is pretty strict in what it allows. Meant to be used for files to be included where part of the filename is dynamic.
Tags:
Parameters
| string |
$filename |
the filename to clean up |
| boolean |
$allow_dots |
whether to allow dots in the filename or not |
COM_sanitizeID [line 5881]
string COM_sanitizeID(
string $id, [boolean $new_id = true])
|
|
Ensure an ID contains only alphanumeric characters, dots, dashes, or underscores
Tags:
Parameters
| string |
$id |
the ID to sanitize |
| boolean |
$new_id |
true = create a new ID in case we end up with an empty string |
COM_sanitizeUrl [line 5818]
string COM_sanitizeUrl(
string $url, [array $allowed_protocols = ''], [string $default_protocol = ''])
|
|
Sanitize a URL
Tags:
Parameters
| string |
$url |
URL to sanitized |
| array |
$allowed_protocols |
array of allowed protocols |
| string |
$default_protocol |
replacement protocol (default: http) |
COM_setArgNames [line 5406]
boolean COM_setArgNames(
array $names)
|
|
Wrapper function for URL class so as to not confuse people This function sets the name of the arguments found in url
Tags:
Parameters
| array |
$names |
Names of arguments in query string to assign to values |
COM_setLangIdAndAttribute [line 7209]
void COM_setLangIdAndAttribute(
ref &$template)
|
|
Set the {lang_id} and {lang_attribute} variables for a template NOTE: {lang_attribute} is only set in multi-language environments.
Parameters
| ref |
&$template |
template to use |
COM_showBlock [line 3440]
string COM_showBlock(
string $name, [string $help = ''], [string $title = ''], [string $position = ''])
|
|
Shows a single Geeklog block This shows a single block and is typically called from COM_showBlocks OR from plugin code
Tags:
Parameters
| string |
$name |
Logical name of block (not same as title) -- 'user_block', 'admin_block', 'section_block', 'whats_new_block'. |
| string |
$help |
Help file location |
| string |
$title |
Title shown in block header |
| string |
$position |
Side, 'left', 'right' or empty. |
COM_showBlocks [line 3502]
string COM_showBlocks(
string $side, [string $topic = ''], [string $name = 'all'])
|
|
Shows Geeklog blocks Returns HTML for blocks on a given side and, potentially, for a given topic. Currently only used by static pages.
Tags:
Parameters
| string |
$side |
Side to get blocks for (right or left for now) |
| string |
$topic |
Only get blocks for this topic |
| string |
$name |
Block name (not used) |
COM_showMessage [line 4592]
string COM_showMessage(
int $msg, [string $plugin = ''])
|
|
Displays a message on the webpage Display one of the predefined messages from the $MESSAGE array. If a plugin name is provided, display that plugin's message instead.
Tags:
Parameters
| int |
$msg |
ID of message to show |
| string |
$plugin |
Optional name of plugin to lookup plugin defined message |
COM_showMessageFromParameter [line 4632]
string COM_showMessageFromParameter(
)
|
|
Displays a message, as defined by URL parameters Helper function to display a message, if URL parameters 'msg' and 'plugin' (optional) are defined. Only for GET requests, but that's what Geeklog uses everywhere anyway.
Tags:
COM_showMessageText [line 4557]
string COM_showMessageText(
string $message, [string $title = ''])
|
|
Displays a message text in a "System Message" block
Tags:
Parameters
| string |
$message |
Message text; may contain HTML |
| string |
$title |
(optional) alternative block title |
COM_showTopics [line 2146]
string COM_showTopics(
[string $topic = ''])
|
|
Shows all available topics Show the topics in the system the user has access to and prints them in HTML. This function is used to show the topics in the topics block.
Tags:
Parameters
| string |
$topic |
ID of currently selected topic |
COM_siteFooter [line 1327]
string COM_siteFooter(
[boolean $rightblock = -1], [array $custom = ''])
|
|
Returns the site footer This loads the proper templates, does variable substitution and returns the HTML for the site footer.
Tags:
Parameters
| boolean |
$rightblock |
Whether or not to show blocks on right hand side default is no |
| array |
$custom |
An array defining custom function to be used to format Rightblocks |
COM_siteHeader [line 849]
string COM_siteHeader(
[string $what = 'menu'], [string $pagetitle = ''], [string $headercode = ''])
|
|
Returns the site header This loads the proper templates, does variable substitution and returns the HTML for the site header with or without blocks depending on the value of $what Programming Note: The two functions COM_siteHeader and COM_siteFooter provide the framework for page display in Geeklog. COM_siteHeader controls the display of the Header and left blocks and COM_siteFooter controls the dsiplay of the right blocks and the footer. You use them like a sandwich. Thus the following code will display a Geeklog page with both right and left blocks displayed. <?php
require_once 'lib-common.php';
// Change to COM_siteHeader('none') to not display left blocks
$display .= "Here is your html for display";
// Change to COM_siteFooter() to not display right blocks
echo $display;
? >
Note that the default for the header is to display the left blocks and the default of the footer is to not display the right blocks. This sandwich produces code like this (greatly simplified) // COM_siteHeader
< table>< tr>< td colspan= "3"> Header</ td></ tr>
<tr><td>Left Blocks</td><td>
// Your HTML goes here
Here is your html for display
// COM_siteFooter
</td><td>Right Blocks</td></tr>
<tr><td colspan="3">Footer</td></table>
Tags:
Parameters
| string |
$what |
If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned |
| string |
$pagetitle |
optional content for the page's <title> |
| string |
$headercode |
optional code to go into the page's <head> |
COM_startBlock [line 1546]
string COM_startBlock(
[string $title = ''], [string $helpfile = ''], [string $template = 'blockheader.thtml'])
|
|
Prints out standard block header Prints out standard block header but pulling header HTML formatting from the database. Programming Note: The two functions COM_startBlock and COM_endBlock are used to sandwich your block content. These functions are not used only for blocks but anything that uses that format, e.g. Stats page. They are used like COM_siteHeader and COM_siteFooter but for internal page elements.
Tags:
Parameters
| string |
$title |
Value to set block title to |
| string |
$helpfile |
Help file, if one exists |
| string |
$template |
HTML template file to use to format the block |
COM_stripslashes [line 5733]
string COM_stripslashes(
string $text)
|
|
Strip slashes from a string only when magic_quotes_gpc = on.
Tags:
Parameters
COM_switchLocaleSettings [line 6692]
void COM_switchLocaleSettings(
)
|
|
Switch locale settings When multi-language support is enabled, allow overwriting the default locale settings with language-specific settings (date format, etc.). So in addition to $_CONF['date'] you can have a $_CONF['date_en'], $_CONF['date_de'], etc.
COM_topicArray [line 1742]
array COM_topicArray(
string $selection, [int $sortcol = 0], [boolean $ignorelang = false])
|
|
Return a list of topics in an array (derived from COM_topicList - API may change)
Tags:
Parameters
| string |
$selection |
Comma delimited string of fields to pull The first field is the value of the option and the second is the label to be displayed. This is used in a SQL statement and can include DISTINCT to start. |
| int |
$sortcol |
Which field to sort option list by 0 (value) or 1 (label) |
| boolean |
$ignorelang |
Whether to return all topics (true) or only the ones for the current language (false) |
COM_topicList [line 1713]
string COM_topicList(
string $selection, [string $selected = ''], [int $sortcol = 1], [boolean $ignorelang = false])
|
|
Create and return a dropdown-list of available topics This is a variation of COM_optionList() from lib-common.php. It will add only those topics to the option list which are accessible by the current user.
Tags:
Parameters
| string |
$selection |
Comma delimited string of fields to pull The first field is the value of the option and the second is the label to be displayed. This is used in a SQL statement and can include DISTINCT to start. |
| string |
$selected |
Value (from $selection) to set to SELECTED or default |
| int |
$sortcol |
Which field to sort option list by 0 (value) or 1 (label) |
| boolean |
$ignorelang |
Whether to return all topics (true) or only the ones for the current language (false) |
COM_truncate [line 6912]
string COM_truncate(
string $text, int $maxlen, [string $filler = ''], [int $endchars = 0])
|
|
Truncate a string Truncates a string to a max. length and optionally adds a filler string, e.g. '...', to indicate the truncation. This function is multi-byte string aware, based on a patch by Yusuke Sakata. NOTE: The truncated string may be shorter but will never be longer than $maxlen characters, i.e. the $filler string is taken into account.
Tags:
Parameters
| string |
$text |
the text string to truncate |
| int |
$maxlen |
max. number of characters in the truncated string |
| string |
$filler |
optional filler string, e.g. '...' |
| int |
$endchars |
number of characters to show after the filler |
COM_truncateHTML [line 6850]
string COM_truncateHTML(
string $htmltext, int $maxlen, [string $filler = ''], [int $endchars = 0])
|
|
Truncate a string that contains HTML tags. Will close all HTML tags as needed. Truncates a string to a max. length and optionally adds a filler string, e.g. '...', to indicate the truncation. This function is multi-byte string aware. This function is based on a code snippet by pitje at Snipplr.com. NOTE: The truncated string may be shorter or longer than $maxlen characters. Currently any initial html tags in the truncated string are taken into account. The $filler string is also taken into account but any html tags that are added by this function to close open html tags are not.
Tags:
Parameters
| string |
$htmltext |
the text string which contains HTML tags to truncate |
| int |
$maxlen |
max. number of characters in the truncated string |
| string |
$filler |
optional filler string, e.g. '...' |
| int |
$endchars |
number of characters to show after the filler |
COM_undoClickableLinks [line 5973]
string COM_undoClickableLinks(
string $text)
|
|
Undo the conversion of URLs to clickable links (in plain text posts), e.g. so that we can present the user with the post as they entered them.
Tags:
Parameters
COM_undoSpecialChars [line 3123]
string COM_undoSpecialChars(
string $string)
|
|
undo function for htmlspecialchars() This function translates HTML entities created by htmlspecialchars() back into their ASCII equivalents. Also handles the entities for $, {, and }.
Tags:
Parameters
| string |
$string |
The string to convert. |
COM_updateSpeedlimit [line 5328]
void COM_updateSpeedlimit(
[string $type = 'submit'], [string $property = ''])
|
|
Store post info for speed limit
Parameters
| string |
$type |
type of speed limit, e.g. 'submit', 'comment' |
| string |
$property |
IP address or other identifiable property |
COM_userComments [line 2874]
void COM_userComments(
$sid, $title, [ $type = 'article'], [ $order = ''], [ $mode = ''], [ $pid = 0], [ $page = 1], [ $cid = false], [ $delete_option = false])
|
|
DEPRECIATED -- see CMT_userComments in lib-comment.php
Tags:
Parameters
| |
$sid |
|
| |
$title |
|
| |
$type |
|
| |
$order |
|
| |
$mode |
|
| |
$pid |
|
| |
$page |
|
| |
$cid |
|
| |
$delete_option |
|
COM_userMenu [line 2307]
void COM_userMenu(
[string $help = ''], [string $title = ''], [string $position = ''])
|
|
Shows the user their menu options This shows the average Joe User their menu options. This is the user block on the left side
Tags:
Parameters
| string |
$help |
Help file to show |
| string |
$title |
Title of Menu |
| string |
$position |
Side being shown on 'left', 'right'. Though blank works not likely. |
COM_versionCompare [line 7408]
mixed COM_versionCompare(
string $version1, string $version2, [string $operator = ''])
|
|
Common function used to compare two Geeklog version numbers
Tags:
Parameters
| string |
$version1 |
First version number to be compared |
| string |
$version2 |
Second version number to be sompared |
| string |
$operator |
optional string to define how the two versions are to be compared valid operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne |
COM_versionConvert [line 7339]
string COM_versionConvert(
string $version)
|
|
Common function used to convert a Geeklog version number into a version number that can be parsed by PHP's "version_compare()"
Tags:
Parameters
| string |
$version |
Geeklog version number |
COM_whatsNewBlock [line 4266]
string COM_whatsNewBlock(
[string $help = ''], [string $title = ''], [string $position = ''])
|
|
Shows any new information in a block Return the HTML that shows any new stories, comments, etc
Tags:
Parameters
| string |
$help |
Help file for block |
| string |
$title |
Title used in block header |
| string |
$position |
Position in which block is being rendered 'left', 'right' or blank (for centre) |
phpblock_switch_language [line 6625]
string phpblock_switch_language(
)
|
|
Provide a block to switch languages Provides a drop-down menu (or simple link, if you only have two languages) to switch languages. This can be used as a PHP block or called from within your theme's header.thtml:
Tags:
phpblock_whosonline [line 4858]
string phpblock_whosonline(
)
|
|
Shows who is online in slick little block
Tags:
|