[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/ -> lib-common.php (sommaire)

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.  This file provides all configuration variables needed by Geeklog with a series of includes (see futher down). --- You only need to modify one line in this file! ---

Poids: 6187 lignes (186 kb)
Inclus ou requis: 51 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 89 fonctions

  COM_getBlockTemplate()
  COM_getThemes()
  COM_renderMenu()
  COM_siteHeader()
  COM_siteFooter()
  COM_startBlock()
  COM_endBlock()
  COM_optionList()
  COM_topicList()
  COM_checkList()
  COM_debug()
  COM_rdfUpToDateCheck()
  COM_featuredCheck()
  COM_errorLog()
  COM_accessLog()
  COM_showTopics()
  COM_userMenu()
  COM_adminMenu()
  COM_refresh()
  COM_userComments()
  COM_checkWords()
  COM_killJS()
  COM_handleCode()
  COM_checkHTML()
  COM_undoSpecialChars()
  COM_makesid()
  COM_isEmail()
  COM_emailEscape()
  COM_formatEmailAddress()
  COM_mail()
  COM_olderStuff()
  COM_showBlock()
  COM_showBlocks()
  COM_formatBlock()
  COM_rdfCheck()
  COM_rdfImport()
  COM_allowedHTML()
  COM_getPassword()
  COM_getDisplayName()
  COM_hit()
  COM_emailUserTopics()
  COM_whatsNewBlock()
  COM_formatTimeString()
  COM_showMessage()
  COM_printPageNavigation()
  COM_getUserDateTimeFormat()
  COM_getUserCookieTimeout()
  phpblock_whosonline()
  COM_getMonthFormOptions()
  COM_getDayFormOptions()
  COM_getYearFormOptions()
  COM_getHourFormOptions()
  COM_getMinuteFormOptions()
  COM_getMinuteOptions()
  COM_getAmPmFormSelection()
  COM_makeList()
  COM_checkSpeedlimit()
  COM_updateSpeedlimit()
  COM_clearSpeedlimit()
  COM_buildURL()
  COM_setArgNames()
  COM_getArgument()
  COM_getRate()
  COM_getPermSQL()
  COM_getTopicSQL()
  COM_stripslashes()
  COM_applyFilter()
  COM_sanitizeUrl()
  COM_makeClickableLinks()
  COM_undoClickableLinks()
  COM_highlightQuery()
  COM_dateDiff()
  COM_getCurrentURL()
  COM_onFrontpage()
  COM_isFrontpage()
  COM_sanitizeID()
  COM_numberFormat()
  COM_convertDate2Timestamp()
  COM_getImgSizeAttributes()
  COM_displayMessageAndAbort()
  COM_getTopicImageUrl()
  COM_getLanguageFromBrowser()
  COM_getLanguage()
  COM_getLanguageId()
  COM_getLangSQL()
  phpblock_switch_language()
  COM_switchLocaleSettings()
  COM_truncate()
  COM_handleError()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

COM_getBlockTemplate( $blockname, $which )   X-Ref
Pas de description

COM_getThemes( $all = false )   X-Ref
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.

param: bool    $all    if true, return all themes even if users aren't allowed to change their default themes
return: array           All installed themes

COM_renderMenu( &$header, $plugin_menu )   X-Ref
Create the menu, i.e. replace {menu_elements} in the site header with the
actual menu entries.

param: Template    $header     reference to the header template
param: array       $plugin_menu    array of plugin menu entries, if any

COM_siteHeader( $what = 'menu', $pagetitle = '', $headercode = '' )   X-Ref
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');
$display .= COM_siteHeader(); //Change to COM_siteHeader('none') to not display left blocks
$display .= "Here is your html for display";
$display .= COM_siteFooter(true);  // 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>

param: string  $what       If 'none' then no left blocks are returned, if 'menu' (default) then right blocks are returned
param: string  $pagetitle  optional content for the page's <title>
param: string  $headercode optional code to go into the page's <head>
return: string              Formatted HTML containing the site header

COM_siteFooter( $rightblock = -1, $custom = '' )   X-Ref
Returns the site footer

This loads the proper templates, does variable substitution and returns the
HTML for the site footer.

param: boolean     $rightblock     Whether or not to show blocks on right hand side default is no
param: array       $custom         An array defining custom function to be used to format Rightblocks
return: string  Formated HTML containing site footer and optionally right blocks

COM_startBlock( $title='', $helpfile='', $template='blockheader.thtml' )   X-Ref
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.


param: string      $title      Value to set block title to
param: string      $helpfile   Help file, if one exists
param: string      $template   HTML template file to use to format the block
return: string  Formatted HTML containing block header

COM_endBlock( $template='blockfooter.thtml' )   X-Ref
Closes out COM_startBlock

param: string      $template       HTML template file used to format block footer
return: string  Formatted HTML to close block

COM_optionList( $table, $selection, $selected='', $sortcol=1, $where='' )   X-Ref
Creates a <option> list from a database list for use in forms

Creates option list form field using given arguments

param: string      $table      Database Table to get data from
param: 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.
param: string/array      $selected   Value (from $selection) to set to SELECTED or default
param: int         $sortcol    Which field to sort option list by 0 (value) or 1 (label)
param: string      $where      Optional WHERE clause to use in the SQL Selection
return: string  Formated HTML of option values

COM_topicList( $selection, $selected = '', $sortcol = 1, $ignorelang = false )   X-Ref
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.

param: 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.
param: string      $selected   Value (from $selection) to set to SELECTED or default
param: int         $sortcol    Which field to sort option list by 0 (value) or 1 (label)
return: string  Formated HTML of option values

COM_checkList( $table, $selection, $where='', $selected='' )   X-Ref
Creates a <input> checklist from a database list for use in forms

Creates a group of checkbox form fields with given arguments

param: string      $table      DB Table to pull data from
param: string      $selection  Comma delimited list of fields to pull from table
param: string      $where      Where clause of SQL statement
param: string      $selected   Value to set to CHECKED
return: string  HTML with Checkbox code

COM_debug( $A )   X-Ref
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

param: array       $A      Array to loop through and print values for
return: string  Formated HTML List

COM_rdfUpToDateCheck( $updated_type = '', $updated_topic = '', $updated_id = '' )   X-Ref
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.

param: string  $updated_type   (optional) feed type to update
param: string  $updated_topic  (optional) feed topic to update
param: string  $updated_id     (optional) feed id to update

COM_featuredCheck()   X-Ref
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_errorLog( $logentry, $actionid = '' )   X-Ref
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.

param: string      $logentry       Text to log to error log
param: int         $actionid       1 = write to log file, 2 = write to screen (default) both
return: string  If $actionid = 2 or '' then HTML formatted string (wrapped in block) else nothing

COM_accessLog( $logentry )   X-Ref
Logs message to access.log

This will print a message to the Geeklog access log

param: string      $string         Message to write to access log

COM_showTopics( $topic='' )   X-Ref
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.

param: string    $topic      ID of currently selected topic
return: string                HTML formatted topic list

COM_userMenu( $help='', $title='' )   X-Ref
Shows the user their menu options

This shows the average joe use their menu options. This is the user block on right side

param: string      $help       Help file to show
param: string      $title      Title of Menu

COM_adminMenu( $help = '', $title = '' )   X-Ref
Prints administration menu

This will return the administration menu items that the user has
sufficient rights to -- Admin Block on right side.

param: string      $help       Help file to show
param: string      $title      Menu Title

COM_refresh( $url )   X-Ref
Redirects user to a given URL

This function COM_passes a meta tag to COM_refresh after a form is sent.  This is
necessary because for some reason Nutscrape and PHP4 don't play well with
the header() function COM_100% of the time.

param: string      $url        URL to send user to

COM_userComments( $sid, $title, $type='article', $order='', $mode='', $pid = 0, $page = 1, $cid = false, $delete_option = false )   X-Ref
DEPRECIATED -- see CMT_userComments in lib-comment.php


COM_checkWords( $Message )   X-Ref
This censors inappropriate content

This will replace 'bad words' with something more appropriate

param: string      $Message        String to check
return: string  Edited $Message

COM_killJS( $Message )   X-Ref
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.
param: string  $Message    Text to filter
return: string  $Message with javascript filtered

COM_handleCode( $str )   X-Ref
Handles the part within a [code] ... [/code] section, i.e. escapes all
special characters.

param: string  $str  the code section to encode
return: string  $str with the special characters encoded

COM_checkHTML( $str, $permissions = 'story.edit' )   X-Ref
This function checks html tags.

Checks to see that the HTML tags are on the approved list and
removes them if not.

param: string  $str            HTML to check
param: string  $permissions    comma-separated list of rights which identify the current user as an "Admin"
return: string                  Filtered HTML

COM_undoSpecialChars( $string )   X-Ref
undo function for htmlspecialchars()

This function translates HTML entities created by htmlspecialchars() back
into their ASCII equivalents. Also handles the entities for $, {, and }.

param: string   $string   The string to convert.
return: string   The converted string.

COM_makesid()   X-Ref
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!

return: string  $sid  Story ID

COM_isEmail( $email )   X-Ref
Checks to see if email address is valid.

This function checks to see if an email address is in the correct from.

param: string    $email   Email address to verify
return: boolean            True if valid otherwise false

COM_emailEscape( $string )   X-Ref
Encode a string such that it can be used in an email header

param: string  $string     the text to be encoded
return: string              encoded text

COM_formatEmailAddress( $name, $address )   X-Ref
Takes a name and an email address and returns a string that vaguely
resembles an email address specification conforming to RFC(2)822 ...

param: string  $name       name, e.g. John Doe
param: string  $address    email address only, e.g. john.doe@example.com
return: string              formatted email address

COM_mail( $to, $subject, $message, $from = '', $html = false, $priority = 0, $cc = '' )   X-Ref
Send an email.

All emails sent by Geeklog are sent through this function now.

param: string      $to         recipients name and email address
param: string      $subject    subject of the email
param: string      $message    the text of the email
param: string      $from       (optional) sender of the the email
param: boolean     $html       (optional) true if to be sent as HTML email
param: int         $priority   (optional) add X-Priority header, if > 0
param: string      $cc         (optional) other recipients (name + email)
return: boolean                 true if successful,  otherwise false

COM_olderStuff()   X-Ref
Creates older stuff block

Creates the olderstuff block for display.
Actually updates the olderstuff record in the gl_blocks database.
return: void

COM_showBlock( $name, $help='', $title='' )   X-Ref
Shows a single Geeklog block

This shows a single block and is typically called from
COM_showBlocks OR from plugin code

param: string      $name       Logical name of block (not same as title) -- 'user_block', 'admin_block', 'section_block', 'whats_new_block'.
param: string      $help       Help file location
param: string      $title      Title shown in block header
return: string  HTML Formated block

COM_showBlocks( $side, $topic='', $name='all' )   X-Ref
Shows Geeklog blocks

Returns HTML for blocks on a given side and, potentially, for
a given topic. Currentlly only used by static pages.

param: string      $side       Side to get blocks for (right or left for now)
param: string      $topic      Only get blocks for this topic
param: string      $name       Block name (not used)
return: string  HTML Formated blocks

COM_formatBlock( $A, $noboxes = false )   X-Ref
Formats a Geeklog block

This shows a single block and is typically called from
COM_showBlocks OR from plugin code

param: array     $A          Block Record
param: bool      $noboxes    Set to true if userpref is no blocks
return: string    HTML Formated block

COM_rdfCheck( $bid, $rdfurl, $date, $maxheadlines = 0 )   X-Ref
Checks to see if it's time to import and RDF/RSS block again

Updates RDF/RSS block if needed

param: string  $bid            Block ID
param: string  $rdfurl         URL to get headlines from
param: string  $date           Last time the headlines were imported
param: string  $maxheadlines   max. number of headlines to import
return: void

COM_rdfImport( $bid, $rdfurl, $maxheadlines = 0 )   X-Ref
Syndication import function. Imports headline data to a portal block.

Rewritten December 19th 2004 by Michael Jervis (mike@fuckingbrit.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.

param: string  $bid            Block ID
param: string  $rdfurl         URL to get content from
param: int     $maxheadlines   Maximum number of headlines to display
return: void

COM_allowedHTML( $permissions = 'story.edit', $list_only = false )   X-Ref
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 config.php
(for admins, see also $_CONF['admin_html']).

param: string  $permissions    comma-separated list of rights which identify the current user as an "Admin"
param: boolean $list_only      true = return only the list of HTML tags
return: string  HTML <span> enclosed string

COM_getPassword( $loginname )   X-Ref
Return the password for the given username

Fetches a password for the given user

param: string  $loginname  username to get password for
return: string              Password or ''

COM_getDisplayName( $uid = '', $username='', $fullname='', $remoteusername='', $remoteservice='' )   X-Ref
Return the username or fullname for the passed member id (uid)

Allows the siteAdmin to determine if loginname (username) or fullname
should be displayed.

param: int  $uid  site member id
param: string  $username   Username, if this is set no lookup is done.
param: string  $fullname   Users full name.
param: string  $service    Remote login service.
return: string  Username, fullname or username@Service

COM_hit()   X-Ref
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_emailUserTopics()   X-Ref
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.

return: void

COM_whatsNewBlock( $help = '', $title = '' )   X-Ref
Shows any new information in a block

Return the HTML that shows any new stories, comments, etc

param: string  $help   Help file for block
param: string  $title  Title used in block header
return: string  Return the HTML that shows any new stories, comments, etc

COM_formatTimeString( $time_string, $time, $type = '', $amount = 0 )   X-Ref
Creates the string that indicates the timespan in which new items were found

param: string  $time_string    template string
param: int     $time           number of seconds in which results are found
param: string  $type           type (translated string) of new item
param: int     $amount         amount of things that have been found.

COM_showMessage( $msg, $plugin='' )   X-Ref
Displays a message on the webpage

Pulls $msg off the URL string and gets the corresponding message and returns
it for display on the calling page

param: int     $msg        ID of message to show
param: string  $plugin     Optional Name of plugin to lookup plugin defined message
return: string  HTML block with message

COM_printPageNavigation( $base_url, $curpage, $num_pages,$page_str='page=', $do_rewrite=false, $msg='',$open_ended = '')   X-Ref
Prints Google(tm)-like paging navigation

param: string      $base_url       base url to use for all generated links
param: int         $curpage        current page we are on
param: int         $num_pages      Total number of pages
param: string      $page_str       page-variable name AND '='
param: bool        $do_rewrite     if true, url-rewriting is respected
param: string      $msg            to be displayed with the navigation
param: string      $open_ended     replace next/last links with this
return: string   HTML formatted widget

COM_getUserDateTimeFormat( $date='' )   X-Ref
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

param: string      $date       date to format, otherwise we format current date/time
return: array   array[0] is the formatted date and array[1] is the unixtimestamp.

COM_getUserCookieTimeout()   X-Ref
Returns user-defined cookie timeout

In account preferences users can specify when their long-term cookie expires.
This function returns that value.

return: int Cookie time out value in seconds

phpblock_whosonline()   X-Ref
Shows who is online in slick little block

return: string  HTML string of online users seperated by line breaks.

COM_getMonthFormOptions( $selected = '' )   X-Ref
Gets the <option> values for calendar months

param: string      $selected       Selected month
return: string  HTML Months as option values

COM_getDayFormOptions( $selected = '' )   X-Ref
Gets the <option> values for calendar days

param: string      $selected       Selected day
return: string HTML days as option values

COM_getYearFormOptions( $selected = '' )   X-Ref
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

param: string      $selected       Selected year
return: string  HTML years as option values

COM_getHourFormOptions( $selected = '', $mode = 12 )   X-Ref
Gets the <option> values for clock hours

param: string  $selected   Selected hour
param: int     $mode       12 or 24 hour mode
return: string              HTML string of options

COM_getMinuteFormOptions( $selected = '', $step = 1 )   X-Ref
Gets the <option> values for clock minutes

param: string      $selected   Selected minutes
param: integer     $step       number of minutes between options, e.g. 15
return: string  HTML of option minutes

COM_getMinuteOptions( $selected = '', $step = 1 )   X-Ref
for backward compatibility only
- this function should always have been called COM_getMinuteFormOptions


COM_getAmPmFormSelection( $name, $selected = '' )   X-Ref
Create an am/pm selector dropdown menu

param: string  $name       name of the <select>
param: string  $selected   preselection: 'am' or 'pm'
return: string  HTML for the dropdown; empty string in 24 hour mode

COM_makeList( $listofitems, $classname = '' )   X-Ref
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.

param: array       $listofitems        Items to list out
return: string  HTML unordered list of array items

COM_checkSpeedlimit( $type = 'submit', $max = 1 )   X-Ref
Check if speed limit applies for current IP address.

param: type   string   type of speed limit to check, e.g. 'submit', 'comment'
param: max    int      max number of allowed tries within speed limit
return: int      0 = does not apply, else: seconds since last post

COM_updateSpeedlimit( $type = 'submit' )   X-Ref
Store post info for current IP address.

param: type   string   type of speed limit, e.g. 'submit', 'comment'

COM_clearSpeedlimit( $speedlimit = 60, $type = '' )   X-Ref
Clear out expired speed limits, i.e. entries older than 'x' seconds

param: speedlimit   int      number of seconds
param: type         string   type of speed limit, e.g. 'submit', 'comment'

COM_buildURL( $url )   X-Ref
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)

param: string      $url        URL to try to build crawler friendly URL for
return: string      Rewritten URL

COM_setArgNames( $names )   X-Ref
Wrapper function for URL class so as to not confuse people

This function sets the name of the arguments found in url

param: array   $names  Names of arguments in query string to assign to values
return: boolean         True if successful

COM_getArgument( $name )   X-Ref
Wrapper function for URL class

returns value for specified argument

param: string      $name       argument to get value for
return: string     Argument value

COM_getRate( $occurrences, $timespan )   X-Ref
Occurences / time

This will take a number of occurrences, and number of seconds for the time span and return
the smallest #/time interval

param: int     $occurrences        how many occurrences during time interval
param: int     $timespan           time interval in seconds
return: int Seconds per interval

COM_getPermSQL( $type = 'WHERE', $u_id = 0, $access = 2, $table = '' )   X-Ref
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.

param: string      $type     part of the SQL expr. e.g. 'WHERE', 'AND'
param: int         $u_id     user id or 0 = current user
param: int         $access   access to check for (2=read, 3=r&write)
param: string      $table    table name if ambiguous (e.g. in JOINs)
return: string      SQL expression string (may be empty)

COM_getTopicSQL( $type = 'WHERE', $u_id = 0, $table = '' )   X-Ref
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.

param: string  $type   part of the SQL expr. e.g. 'WHERE', 'AND'
param: int     $u_id   user id or 0 = current user
param: string  $table  table name if ambiguous (e.g. in JOINs)
return: string          SQL expression string (may be empty)

COM_stripslashes( $text )   X-Ref
Strip slashes from a string only when magic_quotes_gpc = on.

param: string  $text  The text
return: string  The text, possibly without slashes.

COM_applyFilter( $parameter, $isnumeric = false )   X-Ref
Filter parameters passed per GET (URL) or POST.

param: string    $parameter   the parameter to test
param: boolean   $isnumeric   true if $parameter is supposed to be numeric
return: string    the filtered parameter (may now be empty or 0)

COM_sanitizeUrl( $url, $allowed_protocols = '', $default_protocol = '' )   X-Ref
Sanitize a URL

param: string  $url                URL to sanitized
param: array   $allowed_protocols  array of allowed protocols
param: string  $default_protocol   replacement protocol (default: http)
return: string                      sanitized URL

COM_makeClickableLinks( $text )   X-Ref
Detect links in a plain-ascii text and turn them into clickable links.
Will detect links starting with "http:", "https:", "ftp:", and "www.".

Derived from a newsgroup posting by Andreas Schwarz in
news:de.comp.lang.php <aieq4p$12jn2i$3@ID-16486.news.dfncis.de>

param: string    $text     the (plain-ascii) text string
return: string    the same string, with links enclosed in <a>...</a> tags

COM_undoClickableLinks( $text )   X-Ref
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.

param: string  $txt    story text
param: string          story text without links

COM_highlightQuery( $text, $query )   X-Ref
Highlight the words from a search query in a given text string.

param: string  $text   the text
param: string  $query  the search query
return: string          the text with highlighted search words

COM_dateDiff( $interval, $date1, $date2 )   X-Ref
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).

author: Tony Bibbs <tony.bibbs@iowa.gov
param: string $interval Can be:
param: string|int $date1 English date (e.g. 10 Dec 2004) or unixtimestamp
param: string|int $date2 English date (e.g. 10 Dec 2004) or unixtimestamp
return: int Difference of the two dates in the unit of time indicated by the interval

COM_getCurrentURL()   X-Ref
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 ...

return: string  complete URL, e.g. 'http://www.example.com/blah.php?foo=bar'

COM_onFrontpage()   X-Ref
Check if we're on Geeklog's index page.

See if we're on the main index page (first page, no topics selected).

return: bool    true = we're on the frontpage, false = we're not

COM_isFrontpage()   X-Ref
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.


COM_sanitizeID( $id, $new_id = true )   X-Ref
Ensure an ID contains only alphanumeric characters, dots, dashes, or underscores

param: string  $id     the ID to sanitize
param: boolean $new_id true = create a new ID in case we end up with an empty string
return: string          the sanitized ID

COM_numberFormat( $number )   X-Ref
Pas de description

COM_convertDate2Timestamp( $date, $time = '' )   X-Ref
Convert a text based date YYYY-MM-DD to a unix timestamp integer value

param: string  $date   Date in the format YYYY-MM-DD
param: string  $time   Option time in the format HH:MM::SS
return: int             UNIX Timestamp

COM_getImgSizeAttributes( $file )   X-Ref
Get the HTML for an image with height & width

param: string  $file   full path to the file
return: string          html that will be included in the img-tag

COM_displayMessageAndAbort( $msg, $plugin = '', $http_status = 200, $http_text = 'OK')   X-Ref
Display a message and abort

param: int     $msg            message number
param: string  $plugin         plugin name, if applicable
param: int     $http_status    HTTP status code to send with the message
param: string  $http_text      Textual version of the HTTP status code

COM_getTopicImageUrl( $imageurl )   X-Ref
Return full URL of a topic icon

param: string  $imageurl   (relative) topic icon URL
return: string              Full URL

COM_getLanguageFromBrowser()   X-Ref
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).

return: string  name of the language file to use or an empty string

COM_getLanguage()   X-Ref
Determine current language

return: string  name of the language file (minus the '.php' extension)

COM_getLanguageId( $language = '' )   X-Ref
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.

param: string  $language   current language file name (optional)
return: string              language ID, e.g 'en'; empty string on error

COM_getLangSQL( $field, $type = 'WHERE', $table = '' )   X-Ref
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.

param: string  $field  name of the "id" field, e.g. 'sid' for stories
param: string  $type   part of the SQL expression, e.g. 'WHERE', 'AND'
param: string  $table  table name if ambiguous, e.g. in JOINs
return: string          SQL expression string (may be empty)

phpblock_switch_language()   X-Ref
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: <?php print phpblock_switch_language(); ?>

return: string  HTML for drop-down or link to switch languages

COM_switchLocaleSettings()   X-Ref
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_truncate( $text, $maxlen, $filler = '' )   X-Ref
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.

param: string  $text   the text string to truncate
param: int     $maxlen max. number of characters in the truncated string
param: string  $filler optional filler string, e.g. '...'
return: string          truncated string

COM_handleError($errno, $errstr, $errfile='', $errline=0, $errcontext='')   X-Ref
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

param: int     $errno      Error Number.
param: string  $errstr     Error Message.
param: string  $errfile    The file the error was raised in.
param: int     $errline    The line of the file that the error was raised at.
param: array   $errcontext An array that points to the active symbol table at the point the error occurred.



Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics