Subversion Repositories Applications.papyrus

Compare Revisions

No changes between revisions

Ignore whitespace Rev 830 → Rev 831

/trunk/client/phorum/bibliotheque/phorum/mods/smileys/defaults.php
New file
0,0 → 1,14
<?php
// A simple helper script that will setup initial module
// settings in case one of these settings is missing.
 
if(!defined("PHORUM") && !defined("PHORUM_ADMIN")) return;
 
if (! isset($PHORUM['mod_smileys']) ||
! isset($PHORUM['mod_smileys']['prefix']) ||
! isset($PHORUM['mod_smileys']['smileys'])) {
require_once("./mods/smileys/smileyslib.php");
$PHORUM['mod_smileys'] = phorum_mod_smileys_initsettings();
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/smileyslib.php
New file
0,0 → 1,244
<?php
 
// A library of common functions and definitions for
// the smileys mod. This library is only loaded when
// initializing or saving module settings.
 
if(!defined("PHORUM") && !defined("PHORUM_ADMIN")) return;
 
// A match for filtering files that are accepted as smiley images.
define('MOD_SMILEYS_IMAGE_MATCH', '/^.+\.(gif|png|jpg|jpeg)$/i');
 
// A match for matching absolute file paths. Paths that I could think of:
// UNIX path /...
// URL proto://...
// Windows path X:\... or X:/...
// Windows net path \\...
define('MOD_SMILEYS_ABSPATH_MATCH', '!^/|^\w+://|^\w:[/\\\\]|^\\\\\\\\!i');
 
// The default smiley prefix path.
global $MOD_SMILEY_DEFAULT_PREFIX;
$MOD_SMILEY_DEFAULT_PREFIX = './mods/smileys/images/';
 
// The default list of smileys to install upon initial setup.
global $MOD_SMILEY_DEFAULT_SMILEYS;
$MOD_SMILEY_DEFAULT_SMILEYS = array(
"(:P)" => "smiley25.gif spinning smiley sticking its tongue out",
"(td)" => "smiley23.gif thumbs up",
"(tu)" => "smiley24.gif thumbs down",
":)-D" => "smiley15.gif smileys with beer",
">:D<" => "smiley14.gif the finger smiley",
"(:D" => "smiley12.gif smiling bouncing smiley",
"8-)" => "smilie8.gif eye rolling smiley",
":)o" => "smiley16.gif drinking smiley",
"::o" => "smilie10.gif eye popping smiley",
"B)-" => "smilie7.gif smoking smiley",
":(" => "smilie2.gif sad smiley",
":)" => "smilie1.gif smiling smiley",
":?" => "smiley17.gif moody smiley",
":D" => "smilie5.gif grinning smiley",
":P" => "smilie6.gif tongue sticking out smiley",
":S" => "smilie11.gif confused smiley",
":X" => "smilie9.gif angry smiley",
":o" => "smilie4.gif yawning smiley",
";)" => "smilie3.gif winking smiley",
"B)" => "cool.gif cool smiley",
"X(" => "hot.gif hot smiley",
);
 
/**
* Sets up initial settings for the smileys mod or upgrades
* the settings from old versions.
* @return modinfo - Updated module information.
*/
function phorum_mod_smileys_initsettings()
{
$PHORUM = $GLOBALS["PHORUM"];
global $MOD_SMILEY_DEFAULT_PREFIX;
global $MOD_SMILEY_DEFAULT_SMILEYS;
$modinfo = isset($PHORUM["mod_smileys"]) ? $PHORUM["mod_smileys"] : array();
 
// Keep track if we need to store settings in the database.
$do_db_update = false;
 
// Set default for the image prefix path.
if(! isset($modinfo['prefix'])) {
$modinfo['prefix'] = $MOD_SMILEY_DEFAULT_PREFIX;
// So phorum_mod_smileys_available() sees it right away.
$GLOBALS["PHORUM"]["mod_smileys"]["prefix"] = $MOD_SMILEY_DEFAULT_PREFIX;
$do_db_update = true;
}
 
// Set a default list of smileys or upgrade from existing smiley mod.
if (! isset($modinfo['smileys']))
{
$modinfo['smileys'] = array();
 
// Check if we have smileys from the previous version of the
// smiley mod. These were stored at the same level as the
// settings.
$upgrade_list = array();
if (isset($PHORUM["mod_smileys"])) {
foreach ($PHORUM["mod_smileys"] as $id => $smiley) {
if (is_numeric($id)) {
$upgrade_list[$id] = $smiley;
}
}
}
 
// We have an existing list of smileys to upgrade. Move the
// smileys to their new location.
if (count($upgrade_list)) {
foreach ($upgrade_list as $id => $smiley) {
unset($modinfo[$id]);
$modinfo["smileys"][$id] = $smiley;
}
$do_db_update = true;
}
// Set an initial list of smileys.
else {
foreach ($MOD_SMILEY_DEFAULT_SMILEYS as $search => $data) {
list($smiley, $alt) = preg_split('/\s+/', $data, 2);
$modinfo["smileys"][] = array(
"search" => $search,
"alt" => $alt,
"smiley" => $smiley,
"uses" => 2,
);
}
$do_db_update = true;
}
}
 
// Store the changed settings in the database. Errors are
// silently ignored here, to keep them away from end-users.
if ($do_db_update) {
list($modinfo, $message) = phorum_mod_smileys_store($modinfo);
$GLOBALS["PHORUM"]["mod_smileys"] = $modinfo;
return $modinfo;
}
}
 
/**
* Reads in the list of available smiley images.
* @return smileys - An array of smiley image filenames.
*/
function phorum_mod_smileys_available()
{
$PHORUM = $GLOBALS["PHORUM"];
 
$available_smileys = array();
if(file_exists($PHORUM['mod_smileys']['prefix'])){
$d = dir($PHORUM['mod_smileys']['prefix']);
while($entry=$d->read()) {
if(preg_match(MOD_SMILEYS_IMAGE_MATCH, $entry)) {
$available_smileys[$entry]=$entry;
}
}
}
asort($available_smileys);
return $available_smileys;
}
 
/**
* Compiles replacement arrays for the smileys mod and stores the
* data for the module in the database.
* @param modinfo - The configuration array for mod_smileys.
* @return result - An array containing two elements:
* updated module info or NULL on failure and
* a message that can be displayed to the user.
*/
function phorum_mod_smileys_store($modinfo)
{
// Get the current list of available smiley images.
$available_smileys = phorum_mod_smileys_available();
 
// Sort the smileys by length. We need to do this to replace the
// longest smileys matching strings first. Else for example the
// smiley ":)-D" could end up as (smileyimage)-D, because ":)"
// was replaced first.
uasort($modinfo["smileys"],'phorum_mod_smileys_sortbylength');
 
// Create and fill replacement arrays for subject and body.
$smiley_subject_key = array();
$smiley_subject_val = array();
$smiley_body_key = array();
$smiley_body_val = array();
$seen_images = array();
foreach ($modinfo["smileys"] as $id => $smiley)
{
// Check if the smiley image is available. Skip and keep track
// of missing smiley images.
$active = isset($available_smileys[$smiley["smiley"]]) ? true : false;
$modinfo["smileys"][$id]['active'] = $active;
if (! $active) continue;
 
// Check if the smiley image has been seen before. If is has, mark
// the current smiley as being an alias. This is used in the editor
// smiley help, to show only one version of a smiley image.
$is_alias = isset($seen_images[$smiley["smiley"]]) ? true : false;
$seen_images[$smiley["smiley"]] = 1;
$modinfo["smileys"][$id]["is_alias"] = $is_alias;
 
// Create HTML image code for the smiley.
$prefix = $modinfo["prefix"];
$src = htmlspecialchars("$prefix{$smiley['smiley']}");
$alttxt = empty($smiley['alt']) ? $smiley["search"] : $smiley["alt"];
$alt = htmlspecialchars($alttxt);
$img = "<img class=\"mod_smileys_img\" src=\"$src\" alt=\"$alt\" title=\"$alt\"/>";
 
// Below we use htmlspecialchars() on the search string.
// This is done, because the smiley mod is run after formatting
// by Phorum, so characters like < and > are HTML escaped.
 
// Body only replace (0) or subject and body replace (2).
if ($smiley['uses'] == 0 || $smiley['uses'] == 2) {
$smiley_body_key[] = htmlspecialchars($smiley['search']);
$smiley_body_val[] = $img;
}
 
// Subject only replace (1) or subject and body replace (2).
if ($smiley['uses'] == 1 || $smiley['uses'] == 2) {
$smiley_subject_key[] = htmlspecialchars($smiley['search']);
$smiley_subject_val[] = $img;
}
}
 
// Store replacement arrays in the module settings.
$modinfo["replacements"] = array(
"subject" => count($smiley_subject_key)
? array($smiley_subject_key, $smiley_subject_val)
: NULL,
"body" => count($smiley_body_key)
? array($smiley_body_key, $smiley_body_val)
: NULL
);
 
// For quickly determining if the smiley replacements must be run.
$modinfo["do_smileys"] = $modinfo["replacements"]["subject"] != NULL ||
$modinfo["replacements"]["body"] != NULL;
 
// Store the module settings in the database.
if (! phorum_db_update_settings(array("mod_smileys" => $modinfo))) {
return array(NULL, "Saving the smiley settings to the database failed.");
} else {
return array($modinfo, "The smiley settings were successfully saved.");
}
}
 
/**
* A callback function for sorting smileys by their search string length.
* usage: uasort($array_of_smileys, 'phorum_mod_smileys_sortbylength');
*/
function phorum_mod_smileys_sortbylength($a, $b) {
if (isset($a["search"]) && isset($b["search"])) {
if (strlen($a["search"]) == strlen($b["search"])) {
return strcmp($a["search"], $b["search"]);
} else {
return strlen($a["search"]) < strlen($b["search"]);
}
} else {
return 0;
}
}
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/cool.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/cool.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/rolleyes.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/rolleyes.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/laughing.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/laughing.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie1.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie1.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie2.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie2.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley12.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley12.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie3.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie3.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/confused.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/confused.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie4.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie4.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley14.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley14.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/kissing.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/kissing.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie5.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie5.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie6.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie6.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley15.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley15.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smile.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smile.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie7.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie7.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley16.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley16.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie8.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie8.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley17.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley17.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/footinmouth.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/footinmouth.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie9.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie9.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/lipsaresealed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/lipsaresealed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/undecided.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/undecided.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/embarrassed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/embarrassed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/frowning.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/frowning.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/crying.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/crying.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/baringteeth.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/baringteeth.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/suprised.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/suprised.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sleepy.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sleepy.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/tounge.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/tounge.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley23.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley23.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley24.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley24.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/wink.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/wink.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley25.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smiley25.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/thinking.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/thinking.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/innocent.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/innocent.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/angry.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/angry.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/disappointed.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/disappointed.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie10.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie10.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie11.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/smilie11.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/nerd.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/nerd.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sick.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/sick.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/hot.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/images/hot.gif
New file
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/settings.php
New file
0,0 → 1,349
<?php
 
if(!defined("PHORUM_ADMIN")) return;
 
require_once("./include/admin/PhorumInputForm.php");
require_once("./mods/smileys/smileyslib.php");
require_once("./mods/smileys/defaults.php");
 
// The definition of the possible uses for a smiley.
$PHORUM_MOD_SMILEY_USES = array(
0 => "Body",
1 => "Subject",
2 => "Body + Subject",
);
 
// ---------------------------------------------------------------------------
// Handle actions for sent form data.
// ---------------------------------------------------------------------------
 
// The action to perform.
$action = isset($_POST["action"]) ? $_POST["action"] : "";
 
// Keep track if the settings must be saved in the database.
$do_db_update = false;
 
// Keep track of error and success messages.
$error="";
$okmsg = "";
 
// Initialize smiley_id parameter.
$smiley_id = isset($_POST["smiley_id"]) ? $_POST["smiley_id"] : "NEW";
 
// ACTION: Changing the mod_smileys settings.
if (empty($error) && $action == "edit_settings") {
$_POST["prefix"] = trim($_POST["prefix"]);
// Is the field filled in?
if (empty($_POST["prefix"])) {
$error = "Please, fill in the smiley prefix path";
// Deny absolute paths.
} elseif (preg_match(MOD_SMILEYS_ABSPATH_MATCH, $_POST["prefix"])) {
$error = "The smiley path must be a path, relative to Phorum's " .
"installation directory";
// Is the specified prefix a directory?
} elseif (!is_dir($_POST["prefix"])) {
$error = "The smiley prefix path " .
'"' . htmlspecialchars($_POST["prefix"]) . '" ' .
" does not exist";
}
 
// All is okay. Set the prefix path in the config.
if (empty($error))
{
// Make sure the prefix path ends with a "/".
if (substr($_POST["prefix"], -1, 1) != '/') {
$_POST["prefix"] .= "/";
}
 
$PHORUM["mod_smileys"]["prefix"] = $_POST["prefix"];
 
$okmsg = "The smiley settings have been saved successfully";
$do_db_update = true;
}
}
 
// ACTION: Adding or updating smileys.
if (empty($error) && $action == "edit_smiley")
{
// Trim whitespace from form input fields.
foreach (array("search","smiley","alt") as $field) {
if (isset($_POST[$field])) $_POST[$field] = trim($_POST[$field]);
}
 
// Check if the search string is entered.
if (empty($_POST["search"]))
$error = "Please enter the string to match";
// Check if a replace smiley is selected.
elseif (empty($_POST["smiley"]))
$error = "Please, select a smiley to replace the string " .
htmlspecialchars($_POST["search"]) . " with";
// Check if the smiley doesn't already exist.
if (empty($error)) {
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
if ($smiley["search"] == $_POST["search"] &&
$_POST["smiley_id"] != $id) {
$error = "The smiley " .
'"' . htmlspecialchars($_POST["search"]) . '" ' .
"already exists";
break;
}
}
}
 
// All fields are okay. Update the smiley list.
if (empty($error))
{
$item = array(
"search" => $_POST["search"],
"smiley" => $_POST["smiley"],
"alt" => $_POST["alt"],
"uses" => $_POST['uses']
);
 
if ($smiley_id == "NEW") {
$PHORUM["mod_smileys"]["smileys"][]=$item;
$okmsg = "The smiley has been added successfully";
} else {
$PHORUM["mod_smileys"]["smileys"][$smiley_id]=$item;
$okmsg = "The smiley has been updated successfully";
}
 
$do_db_update = true;
}
}
 
// GET based actions.
if (empty($error) && isset($_GET["smiley_id"]))
{
// ACTION: Deleting a smiley from the list.
if (isset($_GET["delete"])) {
unset($PHORUM["mod_smileys"]["smileys"][$_GET["smiley_id"]]);
$do_db_update = true;
$okmsg = "The smiley has been deleted successfully";
}
 
// ACTION: Startup editing a smiley from the list.
if (isset($_GET["edit"])) {
$smiley_id = $_GET["smiley_id"];
}
}
 
 
// ---------------------------------------------------------------------------
// Do database updates.
// ---------------------------------------------------------------------------
 
// Changes have been made to the smileys configuration.
// Store these changes in the database.
if (empty($error) && $do_db_update)
{
list($modinfo, $message) = phorum_mod_smileys_store($PHORUM["mod_smileys"]);
if ($modinfo == NULL) {
$error = $message;
} else {
if (empty($okmsg)) $okmsg = $message;
$PHORUM["mod_smileys"] = $modinfo;
 
// Back to the startscreen
unset($_POST);
$smiley_id = 'NEW';
}
}
 
 
// ---------------------------------------------------------------------------
// Display the settings page
// ---------------------------------------------------------------------------
 
// Get the current list of available smiley images.
$available_smileys = phorum_mod_smileys_available();
 
// Javascript for displaying a smiley preview when a smiley image
// is selected from the drop down box.
?>
<script type="text/javascript">
function change_image(new_image) {
var div = document.getElementById("preview_div");
var img = document.getElementById("preview_image");
if (new_image.length == 0) {
new_image = "./images/trans.gif";
div.style.display = 'none';
} else {
new_image = "<?php print $PHORUM["mod_smileys"]["prefix"]?>" + new_image;
div.style.display = 'block';
}
img.src =new_image;
}
</script>
<?php
 
// Display the result message.
if (! empty($error)) {
phorum_admin_error($error);
} elseif (! empty($okmsg)) {
phorum_admin_okmsg($okmsg);
}
 
// Count things.
$total_smileys = 0;
$inactive_smileys = 0;
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
$total_smileys ++;
if (! $smiley["active"]) $inactive_smileys ++;
}
 
// Display a warning in case there are no smiley images available.
if (! count($available_smileys)) {
phorum_admin_error(
"<strong>Warning:</strong><br/>" .
"No smiley images were found in your current smiley prefix " .
"path. Please place some smileys in the directory " .
htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) .
" or change your prefix path to point to a directory " .
"containing smiley images.");
} elseif ($inactive_smileys) {
phorum_admin_error(
"<strong>Warning:</strong><br/>" .
"You have $inactive_smileys smiley(s) configured for which the " .
"image file was not found (marked as \"UNAVAILBLE\" in the list " .
"below). Delete the smiley(s) from the list or place the missing " .
"images in the directory \"" .
htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) . "\". After " .
"placing new smiley images, click \"Save settings\" to update " .
"the smiley settings.");
}
 
// Create the smiley settings form.
if ($smiley_id == "NEW")
{
$frm = new PhorumInputForm ("", "post", 'Save settings');
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "smileys");
$frm->hidden("action", "edit_settings");
$frm->addbreak("Smiley Settings");
$row = $frm->addrow("Smiley Prefix Path", $frm->text_box("prefix", $PHORUM["mod_smileys"]["prefix"], 50));
$frm->addhelp($row,
"Set the smiley image prefix path",
"This option can be used to set the path to the directory where
you have stored your smileys. This path must be relative to the
directory in which you installed the Phorum software. Absolute
paths cannot be used here.");
$frm->show();
}
 
// No smiley images in the current prefix path? Then do not show the
// rest of the forms. Let the admin fix this issue first.
if (!count($available_smileys)) return;
 
// Create the smiley adding and editing form.
if (isset($_POST["smiley_id"])) {
$search = $_POST["search"];
$smiley = $_POST["smiley"];
$alt = $_POST["alt"];
$uses = $_POST["uses"];
}
if ($smiley_id == "NEW") {
$title = "Add a new smiley";
$submit = "Add smiley";
 
// Fill initial form data for creating smileys.
if (! isset($_POST["smiley_id"])) {
$search = "";
$smiley = "";
$alt = "";
$uses = 2;
}
} else {
$title = "Update a smiley";
$submit = "Update smiley";
 
// Fill initial form data for editing smileys.
if (! isset($_POST["smiley_id"])) {
$smileydata = $PHORUM["mod_smileys"]["smileys"][$smiley_id];
$search = $smileydata["search"];
$smiley = $smileydata["smiley"];
$alt = $smileydata["alt"];
$uses = $smileydata["uses"];
}
}
$frm = new PhorumInputForm ("", "post", $submit);
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "smileys");
$frm->hidden("smiley_id", $smiley_id);
$frm->hidden("action", "edit_smiley");
$frm->addbreak($title);
$frm->addrow("Smiley string to match", $frm->text_box("search", $search, 20));
$row = $frm->addrow("Image to replace the string with", $frm->select_tag("smiley", array_merge(array(''=>'Select smiley ...'),$available_smileys), $smiley, "onChange=\"change_image(this.options[this.selectedIndex].value);\"") . "&nbsp;&nbsp;<div style=\"display:none;margin-top:5px\" id=\"preview_div\"><strong>Preview: </strong><img src=\"images/trans.gif\" id=\"preview_image\" /></div>");
$frm->addhelp($row,
"Smiley replacement image",
"The drop down list shows all images that were found in your
smiley prefix path. If you want to add your own smileys, simply place
them in \"" . htmlspecialchars($PHORUM["mod_smileys"]["prefix"]) . "\"
and reload this page.");
$frm->addrow("ALT tag for the image", $frm->text_box("alt", $alt, 40));
$frm->addrow("Used for", $frm->select_tag("uses", $PHORUM_MOD_SMILEY_USES, $uses));
$frm->show();
 
// Make the preview image visible in case a $smiley is set.
if (!empty($smiley)) {?>
<script type="text/javascript">
change_image('<?php print addslashes($smiley) ?>');
</script><?php
}
 
// Show the configured list of smileys.
if ($smiley_id == "NEW")
{
print "<hr class=\"PhorumAdminHR\" />";
 
if (count($PHORUM["mod_smileys"]["smileys"]))
{ ?>
<table cellspacing="1" class="PhorumAdminTable" width="100%">
<tr>
<td class="PhorumAdminTableHead">String</td>
<td class="PhorumAdminTableHead">Image file</td>
<td class="PhorumAdminTableHead">Image</td>
<td class="PhorumAdminTableHead">ALT tag</td>
<td class="PhorumAdminTableHead">Used for</td>
<td class="PhorumAdminTableHead">&nbsp;</td>
</tr>
<?php
 
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $item)
{
$used_for_txt = $PHORUM_MOD_SMILEY_USES[$item['uses']];
foreach ($item as $key => $val) {
$item[$key] = htmlspecialchars($val);
}
$action_url = "$_SERVER[PHP_SELF]?module=modsettings&mod=smileys&smiley_id=$id";
 
print "<tr>\n";
print " <td class=\"PhorumAdminTableRow\">{$item["search"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\">{$item["smiley"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\" align=\"center\">";
if ($item["active"]) {
print "<img src=\"{$PHORUM["mod_smileys"]["prefix"]}{$item["smiley"]}\"/></td>\n";
} else {
print "<div style=\"color:red\">UNAVAILBLE</div>";
}
print " <td class=\"PhorumAdminTableRow\">{$item["alt"]}</td>\n";
print " <td class=\"PhorumAdminTableRow\" style=\"white-space:nowrap\">$used_for_txt</td>\n";
print " <td class=\"PhorumAdminTableRow\">" .
"<a href=\"$action_url&edit=1\">Edit</a>&nbsp;&#149;&nbsp;" .
"<a href=\"$action_url&delete=1\">Delete</a></td>\n";
print "</tr>\n";
}
 
print "</table>\n";
 
} else {
 
print "Currently, you have no smiley replacements configured.";
 
}
 
// For a more clear end of page.
print "<br/><br/><br/>";
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/info.txt
New file
0,0 → 1,4
hook: after_header|phorum_mod_smileys_after_header
hook: format|phorum_mod_smileys_format
title: Smiley Replacement Mod
desc: This module allows admins to define smiley replacements in messages.
/trunk/client/phorum/bibliotheque/phorum/mods/smileys/smileys.php
New file
0,0 → 1,50
<?php
 
if(!defined("PHORUM")) return;
 
require_once("./mods/smileys/defaults.php");
 
function phorum_mod_smileys_after_header()
{
$PHORUM = $GLOBALS["PHORUM"];
 
// Return immediately if we have no active smiley replacements.
if (!isset($PHORUM["mod_smileys"])||!$PHORUM["mod_smileys"]["do_smileys"]){
return $data;
} ?>
 
<style type="text/css">
.mod_smileys_img {
vertical-align: bottom;
margin: 0px 3px 0px 3px;
}
</style> <?php
}
 
function phorum_mod_smileys_format($data)
{
$PHORUM = $GLOBALS["PHORUM"];
 
// Return immediately if we have no active smiley replacements.
if (!isset($PHORUM["mod_smileys"])||!$PHORUM["mod_smileys"]["do_smileys"]){
return $data;
}
 
// Run smiley replacements.
$replace = $PHORUM["mod_smileys"]["replacements"];
foreach ($data as $key => $message)
{
// Do subject replacements.
if (isset($replace["subject"]) && isset($message["subject"])) {
$data[$key]['subject'] = str_replace ($replace["subject"][0] , $replace["subject"][1], $message['subject'] );
}
// Do body replacements.
if (isset($replace["body"]) && isset($message["body"])) {
$data[$key]['body'] = str_replace ($replace["body"][0] , $replace["body"][1], $message['body'] );
}
}
 
return $data;
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/editor_tools.php
New file
0,0 → 1,16
<?php
 
if(!defined("PHORUM")) return;
 
require_once("./mods/smileys/defaults.php");
 
function phorum_mod_smileys_editor_tools()
{
$PHORUM = $GLOBALS["PHORUM"];
 
if ($PHORUM["mods"]["smileys"]) {
include("./mods/editor_tools/smileys_panel.php");
}
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/lang/dutch.php
New file
0,0 → 1,4
<?php
$PHORUM["DATA"]["LANG"]["AddSmiley"] = "Smiley invoegen";
$PHORUM["DATA"]["LANG"]["LoadingSmileys"] = "smileys inlezen";
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/lang/english.php
New file
0,0 → 1,4
<?php
$PHORUM["DATA"]["LANG"]["AddSmiley"] = "Smileys";
$PHORUM["DATA"]["LANG"]["LoadingSmileys"] = "loading smileys";
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/lang/german.php
New file
0,0 → 1,4
<?php
$PHORUM["DATA"]["LANG"]["AddSmiley"] = "Smiley einfügen";
$PHORUM["DATA"]["LANG"]["LoadingSmileys"] = "Smileys einlesen";
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/lang/dutch_informal.php
New file
0,0 → 1,4
<?php
$PHORUM["DATA"]["LANG"]["AddSmiley"] = "Smiley invoegen";
$PHORUM["DATA"]["LANG"]["LoadingSmileys"] = "smileys inlezen";
?>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/smileys_js.php
New file
0,0 → 1,115
<?php if(!defined("PHORUM")) return; ?>
 
<script type="text/javascript">
 
/* ------------------------------------------------------------------------
* Javascript functions for Smiley tools.
* ------------------------------------------------------------------------
*/
 
var smileys_state = -1;
var smileys_count = 0;
var loaded_count = 0;
var loadingobj;
 
function toggle_smileys()
{
// On the first request to open the smiley help, load all smiley images.
if (smileys_state == -1)
{
// Load smiley images.
<?php
$smileys_count = 0;
$c = '';
foreach ($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
if (! $smiley["active"] || $smiley["is_alias"] || $smiley["uses"] == 1) continue;
$smileys_count ++;
$src = htmlspecialchars($prefix . $smiley['smiley']);
$c.="document.getElementById('smiley-button-{$id}').src='$src';\n";
}
print "smileys_count = $smileys_count;\n$c\n";
?>
 
smileys_state = 0;
}
 
// Toggle smiley panel.
smileys_state = ! smileys_state;
if (smileys_state) show_smileys(); else hide_smileys();
}
 
function show_smileys()
{
// We wait with displaying the smiley help until all smileys are loaded.
if (loaded_count < smileys_count) return false;
 
document.getElementById('phorum_mod_editor_tools_smileys').style.display = 'block';
document.getElementById('phorum_mod_editor_tools_smileys_dots').style.display = 'none';
return false;
}
 
function hide_smileys()
{
document.getElementById('phorum_mod_editor_tools_smileys').style.display = 'none';
document.getElementById('phorum_mod_editor_tools_smileys_dots').style.display = 'inline';
return false;
}
 
function phorum_mod_smileys_insert_smiley(string)
{
var area = document.getElementById("phorum_textarea");
string = unescape(string);
if (area)
{
if (area.createTextRange) /* MSIE */
{
area.focus(area.caretPos);
area.caretPos = document.selection.createRange().duplicate();
curtxt = area.caretPos.text;
area.caretPos.text = string + curtxt;
}
else /* Other browsers */
{
var pos = area.selectionStart;
area.value =
area.value.substring(0,pos) +
string +
area.value.substring(pos);
area.focus();
area.selectionStart = pos + string.length;
area.selectionEnd = area.selectionStart;
}
} else {
alert('There seems to be a technical problem. The textarea ' +
'cannot be found in the page. ' +
'The textarea should have id="phorum_textarea" in the ' +
'definition for this feature to be able to find it. ' +
'If you are not the owner of this forum, then please ' +
'alert the forum owner about this.');
}
}
 
function phorum_mod_smileys_load_smiley (imgobj)
{
loadingobj = document.getElementById('phorum_mod_editor_tools_smileys_loading');
 
// Another smiley image was loaded. If we have loaded all
// smiley images, then show the smileys panel.
if (imgobj.src != '') {
loaded_count ++;
imgobj.onload = '';
if (loaded_count == smileys_count) {
loadingobj.style.display = 'none';
show_smileys();
} else {
// Visual feedback for the user while loading the images.
loadingobj.style.display = 'inline';
loadingobj.innerHTML = "("
+ "<?php print $PHORUM["DATA"]["LANG"]["LoadingSmileys"]; ?> "
+ Math.floor(loaded_count/smileys_count*100) + "%)";
}
}
}
 
</script>
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/info.txt
New file
0,0 → 1,4
hook: lang|
hook: tpl_editor_before_textarea|phorum_mod_smileys_editor_tools
title: Editor tools
desc: This module implements editor tools to help users with writing their messages. For now, the module has implemented an easy way to add smileys to messages (the smileys mod has to be enabled for this to work). The next thing that will be implemented is a tool for BBcode.
/trunk/client/phorum/bibliotheque/phorum/mods/editor_tools/smileys_panel.php
New file
0,0 → 1,51
<?php
if(!defined("PHORUM")) return;
$PHORUM = $GLOBALS["PHORUM"];
$prefix = $PHORUM["mod_smileys"]["prefix"];
 
include("./mods/editor_tools/smileys_js.php");
 
?>
 
<style type="text/css">
#phorum_mod_editor_tools_panel { display: none; }
#phorum_mod_editor_tools_smileys_dots { display: inline; }
#phorum_mod_editor_tools_smileys_loading { display: none; }
#phorum_mod_editor_tools_smileys { display: none; padding: 0px 5px 5px 5px; }
#phorum_mod_editor_tools_smileys img {
margin: 0px 7px 0px 0px;
vertical-align: bottom;
cursor: pointer;
cursor: hand;
}
</style>
 
<div id="phorum_mod_editor_tools_panel"
class="PhorumStdBlockHeader PhorumNarrowBlock">
 
<a href="javascript:toggle_smileys()">
<b><?php print $PHORUM["DATA"]["LANG"]["AddSmiley"]?></b>
</a>
<div id="phorum_mod_editor_tools_smileys_dots"><b>...</b></div>
<div id="phorum_mod_editor_tools_smileys_loading">
(<?php print $PHORUM["DATA"]["LANG"]["LoadingSmileys"]; ?>)
</div>
 
<div id="phorum_mod_editor_tools_smileys"> <?php
// Create a list of stub smiley images. The real images are only
// loaded when the user opens the smiley panel.
foreach($PHORUM["mod_smileys"]["smileys"] as $id => $smiley) {
if (! $smiley["active"] || $smiley["is_alias"] || $smiley["uses"] == 1) continue;
print "<img id=\"smiley-button-$id\" onclick=\"phorum_mod_smileys_insert_smiley('" . urlencode($smiley["search"]) . "')\" onload=\"phorum_mod_smileys_load_smiley(this)\" src=\"\"/>";
} ?>
</div>
 
</div>
 
<script type="text/javascript">
// Display the smileys panel. This way browsers that do not
// support javascript (but which do support CSS) will not
// show the smileys panel (since the default display style for the
// smileys panel is 'none').
document.getElementById("phorum_mod_editor_tools_panel").style.display = 'block';
</script>
/trunk/client/phorum/bibliotheque/phorum/mods/markdown.php
New file
0,0 → 1,1408
<?php
 
#
# Markdown - A text-to-HTML conversion tool for web writers
#
# Copyright (c) 2004-2005 John Gruber
# <http://daringfireball.net/projects/markdown/>
#
# Copyright (c) 2004-2005 Michel Fortin - PHP Port
# <http://www.michelf.com/projects/php-markdown/>
#
 
 
global $MarkdownPHPVersion, $MarkdownSyntaxVersion,
$md_empty_element_suffix, $md_tab_width,
$md_nested_brackets_depth, $md_nested_brackets,
$md_escape_table, $md_backslash_escape_table,
$md_list_level;
 
$MarkdownPHPVersion = '1.0.1c'; # Fri 9 Dec 2005
$MarkdownSyntaxVersion = '1.0.1'; # Sun 12 Dec 2004
 
 
#
# Global default settings:
#
$md_empty_element_suffix = " />"; # Change to ">" for HTML output
$md_tab_width = 4;
 
#
# WordPress settings:
#
$md_wp_posts = true; # Set to false to remove Markdown from posts.
$md_wp_comments = true; # Set to false to remove Markdown from comments.
 
 
# -- WordPress Plugin Interface -----------------------------------------------
/*
Plugin Name: Markdown
Plugin URI: http://www.michelf.com/projects/php-markdown/
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a>
Version: 1.0.1c
Author: Michel Fortin
Author URI: http://www.michelf.com/
*/
if (isset($wp_version)) {
# More details about how it works here:
# <http://www.michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/>
# Post content and excerpts
if ($md_wp_posts) {
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
add_filter('the_content', 'Markdown', 6);
add_filter('get_the_excerpt', 'Markdown', 6);
add_filter('get_the_excerpt', 'trim', 7);
add_filter('the_excerpt', 'md_add_p');
add_filter('the_excerpt_rss', 'md_strip_p');
remove_filter('content_save_pre', 'balanceTags', 50);
remove_filter('excerpt_save_pre', 'balanceTags', 50);
add_filter('the_content', 'balanceTags', 50);
add_filter('get_the_excerpt', 'balanceTags', 9);
function md_add_p($text) {
if (strlen($text) == 0) return;
if (strcasecmp(substr($text, -3), '<p>') == 0) return $text;
return '<p>'.$text.'</p>';
}
function md_strip_p($t) { return preg_replace('{</?[pP]>}', '', $t); }
}
# Comments
if ($md_wp_comments) {
remove_filter('comment_text', 'wpautop');
remove_filter('comment_text', 'make_clickable');
add_filter('pre_comment_content', 'Markdown', 6);
add_filter('pre_comment_content', 'md_hide_tags', 8);
add_filter('pre_comment_content', 'md_show_tags', 12);
add_filter('get_comment_text', 'Markdown', 6);
add_filter('get_comment_excerpt', 'Markdown', 6);
add_filter('get_comment_excerpt', 'md_strip_p', 7);
global $md_hidden_tags;
$md_hidden_tags = array(
'<p>' => md5('<p>'), '</p>' => md5('</p>'),
'<pre>' => md5('<pre>'), '</pre>'=> md5('</pre>'),
'<ol>' => md5('<ol>'), '</ol>' => md5('</ol>'),
'<ul>' => md5('<ul>'), '</ul>' => md5('</ul>'),
'<li>' => md5('<li>'), '</li>' => md5('</li>'),
);
function md_hide_tags($text) {
global $md_hidden_tags;
return str_replace(array_keys($md_hidden_tags),
array_values($md_hidden_tags), $text);
}
function md_show_tags($text) {
global $md_hidden_tags;
return str_replace(array_values($md_hidden_tags),
array_keys($md_hidden_tags), $text);
}
}
}
 
 
# -- bBlog Plugin Info --------------------------------------------------------
function identify_modifier_markdown() {
global $MarkdownPHPVersion;
return array(
'name' => 'markdown',
'type' => 'modifier',
'nicename' => 'Markdown',
'description' => 'A text-to-HTML conversion tool for web writers',
'authors' => 'Michel Fortin and John Gruber',
'licence' => 'GPL',
'version' => $MarkdownPHPVersion,
'help' => '<a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a>'
);
}
 
# -- Smarty Modifier Interface ------------------------------------------------
function smarty_modifier_markdown($text) {
return Markdown($text);
}
 
# -- Textile Compatibility Mode -----------------------------------------------
# Rename this file to "classTextile.php" and it can replace Textile anywhere.
if (strcasecmp(substr(__FILE__, -16), "classTextile.php") == 0) {
# Try to include PHP SmartyPants. Should be in the same directory.
@include_once 'smartypants.php';
# Fake Textile class. It calls Markdown instead.
class Textile {
function TextileThis($text, $lite='', $encode='', $noimage='', $strict='') {
if ($lite == '' && $encode == '') $text = Markdown($text);
if (function_exists('SmartyPants')) $text = SmartyPants($text);
return $text;
}
}
}
 
 
# -- Phorum Module Info --------------------------------------------------------
/* phorum module info
hook: format|phorum_Markdown
title: Markdown
desc: Markdown syntax allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by John Gruber.<br />http://daringfireball.net/projects/markdown/syntax<br />http://www.michelf.com/projects/php-markdown/
*/
function phorum_Markdown ($data)
{
foreach($data as $key=>$message){
if(!empty($message["body"])){
$message["body"] = str_replace('<br phorum="true" />', '', $message["body"]);
$data[$key]["body"] = Markdown($message["body"]);
}
}
return ($data);
}
 
 
#
# Globals:
#
 
# Regex to match balanced [brackets].
# Needed to insert a maximum bracked depth while converting to PHP.
$md_nested_brackets_depth = 6;
$md_nested_brackets =
str_repeat('(?>[^\[\]]+|\[', $md_nested_brackets_depth).
str_repeat('\])*', $md_nested_brackets_depth);
 
# Table of hash values for escaped characters:
$md_escape_table = array(
"\\" => md5("\\"),
"`" => md5("`"),
"*" => md5("*"),
"_" => md5("_"),
"{" => md5("{"),
"}" => md5("}"),
"[" => md5("["),
"]" => md5("]"),
"(" => md5("("),
")" => md5(")"),
">" => md5(">"),
"#" => md5("#"),
"+" => md5("+"),
"-" => md5("-"),
"." => md5("."),
"!" => md5("!")
);
# Create an identical table but for escaped characters.
$md_backslash_escape_table;
foreach ($md_escape_table as $key => $char)
$md_backslash_escape_table["\\$key"] = $char;
 
 
function Markdown($text) {
#
# Main function. The order in which other subs are called here is
# essential. Link and image substitutions need to happen before
# _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the <a>
# and <img> tags get encoded.
#
# Clear the global hashes. If we don't clear these, you get conflicts
# from other articles when generating a page which contains more than
# one article (e.g. an index page that shows the N most recent
# articles):
global $md_urls, $md_titles, $md_html_blocks;
$md_urls = array();
$md_titles = array();
$md_html_blocks = array();
 
# Standardize line endings:
# DOS to Unix and Mac to Unix
$text = str_replace(array("\r\n", "\r"), "\n", $text);
 
# Make sure $text ends with a couple of newlines:
$text .= "\n\n";
 
# Convert all tabs to spaces.
$text = _Detab($text);
 
# Strip any lines consisting only of spaces and tabs.
# This makes subsequent regexen easier to write, because we can
# match consecutive blank lines with /\n+/ instead of something
# contorted like /[ \t]*\n+/ .
$text = preg_replace('/^[ \t]+$/m', '', $text);
 
# Turn block-level HTML blocks into hash entries
$text = _HashHTMLBlocks($text);
 
# Strip link definitions, store in hashes.
$text = _StripLinkDefinitions($text);
 
$text = _RunBlockGamut($text);
 
$text = _UnescapeSpecialChars($text);
 
return $text . "\n";
}
 
 
function _StripLinkDefinitions($text) {
#
# Strips link definitions from text, stores the URLs and titles in
# hash references.
#
global $md_tab_width;
$less_than_tab = $md_tab_width - 1;
 
# Link defs are in the form: ^[id]: url "optional title"
$text = preg_replace_callback('{
^[ ]{0,'.$less_than_tab.'}\[(.+)\]: # id = $1
[ \t]*
\n? # maybe *one* newline
[ \t]*
<?(\S+?)>? # url = $2
[ \t]*
\n? # maybe one newline
[ \t]*
(?:
(?<=\s) # lookbehind for whitespace
["(]
(.+?) # title = $3
[")]
[ \t]*
)? # title is optional
(?:\n+|\Z)
}xm',
'_StripLinkDefinitions_callback',
$text);
return $text;
}
function _StripLinkDefinitions_callback($matches) {
global $md_urls, $md_titles;
$link_id = strtolower($matches[1]);
$md_urls[$link_id] = _EncodeAmpsAndAngles($matches[2]);
if (isset($matches[3]))
$md_titles[$link_id] = str_replace('"', '&quot;', $matches[3]);
return ''; # String that will replace the block
}
 
 
function _HashHTMLBlocks($text) {
global $md_tab_width;
$less_than_tab = $md_tab_width - 1;
 
# Hashify HTML blocks:
# We only want to do this for block-level HTML tags, such as headers,
# lists, and tables. That's because we still want to wrap <p>s around
# "paragraphs" that are wrapped in non-block-level tags, such as anchors,
# phrase emphasis, and spans. The list of tags we're looking for is
# hard-coded:
$block_tags_a = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'.
'script|noscript|form|fieldset|iframe|math|ins|del';
$block_tags_b = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|'.
'script|noscript|form|fieldset|iframe|math';
 
# First, look for nested blocks, e.g.:
# <div>
# <div>
# tags for inner block must be indented.
# </div>
# </div>
#
# The outermost tags must start at the left margin for this to match, and
# the inner nested divs must be indented.
# We need to do this before the next, more liberal match, because the next
# match will start at the first `<div>` and stop at the first `</div>`.
$text = preg_replace_callback("{
( # save in $1
^ # start of line (with /m)
<($block_tags_a) # start tag = $2
\\b # word break
(.*\\n)*? # any number of lines, minimally matching
</\\2> # the matching end tag
[ \\t]* # trailing spaces/tabs
(?=\\n+|\\Z) # followed by a newline or end of document
)
}xm",
'_HashHTMLBlocks_callback',
$text);
 
#
# Now match more liberally, simply from `\n<tag>` to `</tag>\n`
#
$text = preg_replace_callback("{
( # save in $1
^ # start of line (with /m)
<($block_tags_b) # start tag = $2
\\b # word break
(.*\\n)*? # any number of lines, minimally matching
.*</\\2> # the matching end tag
[ \\t]* # trailing spaces/tabs
(?=\\n+|\\Z) # followed by a newline or end of document
)
}xm",
'_HashHTMLBlocks_callback',
$text);
 
# Special case just for <hr />. It was easier to make a special case than
# to make the other regex more complicated.
$text = preg_replace_callback('{
(?:
(?<=\n\n) # Starting after a blank line
| # or
\A\n? # the beginning of the doc
)
( # save in $1
[ ]{0,'.$less_than_tab.'}
<(hr) # start tag = $2
\b # word break
([^<>])*? #
/?> # the matching end tag
[ \t]*
(?=\n{2,}|\Z) # followed by a blank line or end of document
)
}x',
'_HashHTMLBlocks_callback',
$text);
 
# Special case for standalone HTML comments:
$text = preg_replace_callback('{
(?:
(?<=\n\n) # Starting after a blank line
| # or
\A\n? # the beginning of the doc
)
( # save in $1
[ ]{0,'.$less_than_tab.'}
(?s:
<!
(--.*?--\s*)+
>
)
[ \t]*
(?=\n{2,}|\Z) # followed by a blank line or end of document
)
}x',
'_HashHTMLBlocks_callback',
$text);
 
return $text;
}
function _HashHTMLBlocks_callback($matches) {
global $md_html_blocks;
$text = $matches[1];
$key = md5($text);
$md_html_blocks[$key] = $text;
return "\n\n$key\n\n"; # String that will replace the block
}
 
 
function _RunBlockGamut($text) {
#
# These are all the transformations that form block-level
# tags like paragraphs, headers, and list items.
#
global $md_empty_element_suffix;
 
$text = _DoHeaders($text);
 
# Do Horizontal Rules:
$text = preg_replace(
array('{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}mx',
'{^[ ]{0,2}([ ]? -[ ]?){3,}[ \t]*$}mx',
'{^[ ]{0,2}([ ]? _[ ]?){3,}[ \t]*$}mx'),
"\n<hr$md_empty_element_suffix\n",
$text);
 
$text = _DoLists($text);
$text = _DoCodeBlocks($text);
$text = _DoBlockQuotes($text);
 
# We already ran _HashHTMLBlocks() before, in Markdown(), but that
# was to escape raw HTML in the original Markdown source. This time,
# we're escaping the markup we've just created, so that we don't wrap
# <p> tags around block-level tags.
$text = _HashHTMLBlocks($text);
$text = _FormParagraphs($text);
 
return $text;
}
 
 
function _RunSpanGamut($text) {
#
# These are all the transformations that occur *within* block-level
# tags like paragraphs, headers, and list items.
#
global $md_empty_element_suffix;
 
$text = _DoCodeSpans($text);
 
$text = _EscapeSpecialChars($text);
 
# Process anchor and image tags. Images must come first,
# because ![foo][f] looks like an anchor.
$text = _DoImages($text);
$text = _DoAnchors($text);
 
# Make links out of things like `<http://example.com/>`
# Must come after _DoAnchors(), because you can use < and >
# delimiters in inline links like [this](<url>).
$text = _DoAutoLinks($text);
$text = _EncodeAmpsAndAngles($text);
$text = _DoItalicsAndBold($text);
 
# Do hard breaks:
$text = preg_replace('/ {2,}\n/', "<br$md_empty_element_suffix\n", $text);
 
return $text;
}
 
 
function _EscapeSpecialChars($text) {
global $md_escape_table;
$tokens = _TokenizeHTML($text);
 
$text = ''; # rebuild $text from the tokens
# $in_pre = 0; # Keep track of when we're inside <pre> or <code> tags.
# $tags_to_skip = "!<(/?)(?:pre|code|kbd|script|math)[\s>]!";
 
foreach ($tokens as $cur_token) {
if ($cur_token[0] == 'tag') {
# Within tags, encode * and _ so they don't conflict
# with their use in Markdown for italics and strong.
# We're replacing each such character with its
# corresponding MD5 checksum value; this is likely
# overkill, but it should prevent us from colliding
# with the escape values by accident.
$cur_token[1] = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$cur_token[1]);
$text .= $cur_token[1];
} else {
$t = $cur_token[1];
$t = _EncodeBackslashEscapes($t);
$text .= $t;
}
}
return $text;
}
 
 
function _DoAnchors($text) {
#
# Turn Markdown link shortcuts into XHTML <a> tags.
#
global $md_nested_brackets;
#
# First, handle reference-style links: [link text] [id]
#
$text = preg_replace_callback("{
( # wrap whole match in $1
\\[
($md_nested_brackets) # link text = $2
\\]
 
[ ]? # one optional space
(?:\\n[ ]*)? # one optional newline followed by spaces
 
\\[
(.*?) # id = $3
\\]
)
}xs",
'_DoAnchors_reference_callback', $text);
 
#
# Next, inline-style links: [link text](url "optional title")
#
$text = preg_replace_callback("{
( # wrap whole match in $1
\\[
($md_nested_brackets) # link text = $2
\\]
\\( # literal paren
[ \\t]*
<?(.*?)>? # href = $3
[ \\t]*
( # $4
(['\"]) # quote char = $5
(.*?) # Title = $6
\\5 # matching quote
)? # title is optional
\\)
)
}xs",
'_DoAnchors_inline_callback', $text);
 
return $text;
}
function _DoAnchors_reference_callback($matches) {
global $md_urls, $md_titles, $md_escape_table;
$whole_match = $matches[1];
$link_text = $matches[2];
$link_id = strtolower($matches[3]);
 
if ($link_id == "") {
$link_id = strtolower($link_text); # for shortcut links like [this][].
}
 
if (isset($md_urls[$link_id])) {
$url = $md_urls[$link_id];
# We've got to encode these to avoid conflicting with italics/bold.
$url = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$url);
$result = "<a href=\"$url\"";
if ( isset( $md_titles[$link_id] ) ) {
$title = $md_titles[$link_id];
$title = str_replace(array('*', '_'),
array($md_escape_table['*'],
$md_escape_table['_']), $title);
$result .= " title=\"$title\"";
}
$result .= ">$link_text</a>";
}
else {
$result = $whole_match;
}
return $result;
}
function _DoAnchors_inline_callback($matches) {
global $md_escape_table;
$whole_match = $matches[1];
$link_text = $matches[2];
$url = $matches[3];
$title =& $matches[6];
 
# We've got to encode these to avoid conflicting with italics/bold.
$url = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$url);
$result = "<a href=\"$url\"";
if (isset($title)) {
$title = str_replace('"', '&quot;', $title);
$title = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$title);
$result .= " title=\"$title\"";
}
$result .= ">$link_text</a>";
 
return $result;
}
 
 
function _DoImages($text) {
#
# Turn Markdown image shortcuts into <img> tags.
#
global $md_nested_brackets;
 
#
# First, handle reference-style labeled images: ![alt text][id]
#
$text = preg_replace_callback('{
( # wrap whole match in $1
!\[
('.$md_nested_brackets.') # alt text = $2
\]
 
[ ]? # one optional space
(?:\n[ ]*)? # one optional newline followed by spaces
 
\[
(.*?) # id = $3
\]
 
)
}xs',
'_DoImages_reference_callback', $text);
 
#
# Next, handle inline images: ![alt text](url "optional title")
# Don't forget: encode * and _
 
$text = preg_replace_callback('{
( # wrap whole match in $1
!\[
('.$md_nested_brackets.') # alt text = $2
\]
\( # literal paren
[ \t]*
<?(\S+?)>? # src url = $3
[ \t]*
( # $4
([\'"]) # quote char = $5
(.*?) # title = $6
\5 # matching quote
[ \t]*
)? # title is optional
\)
)
}xs',
'_DoImages_inline_callback', $text);
 
return $text;
}
function _DoImages_reference_callback($matches) {
global $md_urls, $md_titles, $md_empty_element_suffix, $md_escape_table;
$whole_match = $matches[1];
$alt_text = $matches[2];
$link_id = strtolower($matches[3]);
 
if ($link_id == "") {
$link_id = strtolower($alt_text); # for shortcut links like ![this][].
}
 
$alt_text = str_replace('"', '&quot;', $alt_text);
if (isset($md_urls[$link_id])) {
$url = $md_urls[$link_id];
# We've got to encode these to avoid conflicting with italics/bold.
$url = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$url);
$result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($md_titles[$link_id])) {
$title = $md_titles[$link_id];
$title = str_replace(array('*', '_'),
array($md_escape_table['*'],
$md_escape_table['_']), $title);
$result .= " title=\"$title\"";
}
$result .= $md_empty_element_suffix;
}
else {
# If there's no such link ID, leave intact:
$result = $whole_match;
}
 
return $result;
}
function _DoImages_inline_callback($matches) {
global $md_empty_element_suffix, $md_escape_table;
$whole_match = $matches[1];
$alt_text = $matches[2];
$url = $matches[3];
$title = '';
if (isset($matches[6])) {
$title = $matches[6];
}
 
$alt_text = str_replace('"', '&quot;', $alt_text);
$title = str_replace('"', '&quot;', $title);
# We've got to encode these to avoid conflicting with italics/bold.
$url = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$url);
$result = "<img src=\"$url\" alt=\"$alt_text\"";
if (isset($title)) {
$title = str_replace(array('*', '_'),
array($md_escape_table['*'], $md_escape_table['_']),
$title);
$result .= " title=\"$title\""; # $title already quoted
}
$result .= $md_empty_element_suffix;
 
return $result;
}
 
 
function _DoHeaders($text) {
# Setext-style headers:
# Header 1
# ========
#
# Header 2
# --------
#
$text = preg_replace(
array('{ ^(.+)[ \t]*\n=+[ \t]*\n+ }emx',
'{ ^(.+)[ \t]*\n-+[ \t]*\n+ }emx'),
array("'<h1>'._RunSpanGamut(_UnslashQuotes('\\1')).'</h1>\n\n'",
"'<h2>'._RunSpanGamut(_UnslashQuotes('\\1')).'</h2>\n\n'"),
$text);
 
# atx-style headers:
# # Header 1
# ## Header 2
# ## Header 2 with closing hashes ##
# ...
# ###### Header 6
#
$text = preg_replace("{
^(\\#{1,6}) # $1 = string of #'s
[ \\t]*
(.+?) # $2 = Header text
[ \\t]*
\\#* # optional closing #'s (not counted)
\\n+
}xme",
"'<h'.strlen('\\1').'>'._RunSpanGamut(_UnslashQuotes('\\2')).'</h'.strlen('\\1').'>\n\n'",
$text);
 
return $text;
}
 
 
function _DoLists($text) {
#
# Form HTML ordered (numbered) and unordered (bulleted) lists.
#
global $md_tab_width, $md_list_level;
$less_than_tab = $md_tab_width - 1;
 
# Re-usable patterns to match list item bullets and number markers:
$marker_ul = '[*+-]';
$marker_ol = '\d+[.]';
$marker_any = "(?:$marker_ul|$marker_ol)";
 
$markers = array($marker_ul, $marker_ol);
 
foreach ($markers as $marker) {
# Re-usable pattern to match any entirel ul or ol list:
$whole_list = '
( # $1 = whole list
( # $2
[ ]{0,'.$less_than_tab.'}
('.$marker.') # $3 = first list item marker
[ \t]+
)
(?s:.+?)
( # $4
\z
|
\n{2,}
(?=\S)
(?! # Negative lookahead for another list item marker
[ \t]*
'.$marker.'[ \t]+
)
)
)
'; // mx
# We use a different prefix before nested lists than top-level lists.
# See extended comment in _ProcessListItems().
if ($md_list_level) {
$text = preg_replace_callback('{
^
'.$whole_list.'
}mx',
'_DoLists_callback_top', $text);
}
else {
$text = preg_replace_callback('{
(?:(?<=\n\n)|\A\n?)
'.$whole_list.'
}mx',
'_DoLists_callback_nested', $text);
}
}
 
return $text;
}
function _DoLists_callback_top($matches) {
# Re-usable patterns to match list item bullets and number markers:
$marker_ul = '[*+-]';
$marker_ol = '\d+[.]';
$marker_any = "(?:$marker_ul|$marker_ol)";
$list = $matches[1];
$list_type = preg_match("/$marker_ul/", $matches[3]) ? "ul" : "ol";
$marker_any = ( $list_type == "ul" ? $marker_ul : $marker_ol );
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list = preg_replace("/\n{2,}/", "\n\n\n", $list);
$result = _ProcessListItems($list, $marker_any);
# Trim any trailing whitespace, to put the closing `</$list_type>`
# up on the preceding line, to get it past the current stupid
# HTML block parser. This is a hack to work around the terrible
# hack that is the HTML block parser.
$result = rtrim($result);
$result = "<$list_type>" . $result . "</$list_type>\n";
return $result;
}
function _DoLists_callback_nested($matches) {
# Re-usable patterns to match list item bullets and number markers:
$marker_ul = '[*+-]';
$marker_ol = '\d+[.]';
$marker_any = "(?:$marker_ul|$marker_ol)";
$list = $matches[1];
$list_type = preg_match("/$marker_ul/", $matches[3]) ? "ul" : "ol";
$marker_any = ( $list_type == "ul" ? $marker_ul : $marker_ol );
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list = preg_replace("/\n{2,}/", "\n\n\n", $list);
$result = _ProcessListItems($list, $marker_any);
$result = "<$list_type>\n" . $result . "</$list_type>\n";
return $result;
}
 
 
function _ProcessListItems($list_str, $marker_any) {
#
# Process the contents of a single ordered or unordered list, splitting it
# into individual list items.
#
global $md_list_level;
# The $md_list_level global keeps track of when we're inside a list.
# Each time we enter a list, we increment it; when we leave a list,
# we decrement. If it's zero, we're not in a list anymore.
#
# We do this because when we're not inside a list, we want to treat
# something like this:
#
# I recommend upgrading to version
# 8. Oops, now this line is treated
# as a sub-list.
#
# As a single paragraph, despite the fact that the second line starts
# with a digit-period-space sequence.
#
# Whereas when we're inside a list (or sub-list), that line will be
# treated as the start of a sub-list. What a kludge, huh? This is
# an aspect of Markdown's syntax that's hard to parse perfectly
# without resorting to mind-reading. Perhaps the solution is to
# change the syntax rules such that sub-lists must start with a
# starting cardinal number; e.g. "1." or "a.".
$md_list_level++;
 
# trim trailing blank lines:
$list_str = preg_replace("/\n{2,}\\z/", "\n", $list_str);
 
$list_str = preg_replace_callback('{
(\n)? # leading line = $1
(^[ \t]*) # leading whitespace = $2
('.$marker_any.') [ \t]+ # list marker = $3
((?s:.+?) # list item text = $4
(\n{1,2}))
(?= \n* (\z | \2 ('.$marker_any.') [ \t]+))
}xm',
'_ProcessListItems_callback', $list_str);
 
$md_list_level--;
return $list_str;
}
function _ProcessListItems_callback($matches) {
$item = $matches[4];
$leading_line =& $matches[1];
$leading_space =& $matches[2];
 
if ($leading_line || preg_match('/\n{2,}/', $item)) {
$item = _RunBlockGamut(_Outdent($item));
}
else {
# Recursion for sub-lists:
$item = _DoLists(_Outdent($item));
$item = preg_replace('/\n+$/', '', $item);
$item = _RunSpanGamut($item);
}
 
return "<li>" . $item . "</li>\n";
}
 
 
function _DoCodeBlocks($text) {
#
# Process Markdown `<pre><code>` blocks.
#
global $md_tab_width;
$text = preg_replace_callback('{
(?:\n\n|\A)
( # $1 = the code block -- one or more lines, starting with a space/tab
(?:
(?:[ ]{'.$md_tab_width.'} | \t) # Lines must start with a tab or a tab-width of spaces
.*\n+
)+
)
((?=^[ ]{0,'.$md_tab_width.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
}xm',
'_DoCodeBlocks_callback', $text);
 
return $text;
}
function _DoCodeBlocks_callback($matches) {
$codeblock = $matches[1];
 
$codeblock = _EncodeCode(_Outdent($codeblock));
// $codeblock = _Detab($codeblock);
# trim leading newlines and trailing whitespace
$codeblock = preg_replace(array('/\A\n+/', '/\s+\z/'), '', $codeblock);
 
$result = "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n";
 
return $result;
}
 
 
function _DoCodeSpans($text) {
#
# * Backtick quotes are used for <code></code> spans.
#
# * You can use multiple backticks as the delimiters if you want to
# include literal backticks in the code span. So, this input:
#
# Just type ``foo `bar` baz`` at the prompt.
#
# Will translate to:
#
# <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
#
# There's no arbitrary limit to the number of backticks you
# can use as delimters. If you need three consecutive backticks
# in your code, use four for delimiters, etc.
#
# * You can use spaces to get literal backticks at the edges:
#
# ... type `` `bar` `` ...
#
# Turns to:
#
# ... type <code>`bar`</code> ...
#
$text = preg_replace_callback('@
(?<!\\\) # Character before opening ` can\'t be a backslash
(`+) # $1 = Opening run of `
(.+?) # $2 = The code block
(?<!`)
\1 # Matching closer
(?!`)
@xs',
'_DoCodeSpans_callback', $text);
 
return $text;
}
function _DoCodeSpans_callback($matches) {
$c = $matches[2];
$c = preg_replace('/^[ \t]*/', '', $c); # leading whitespace
$c = preg_replace('/[ \t]*$/', '', $c); # trailing whitespace
$c = _EncodeCode($c);
return "<code>$c</code>";
}
 
 
function _EncodeCode($_) {
#
# Encode/escape certain characters inside Markdown code runs.
# The point is that in code, these characters are literals,
# and lose their special Markdown meanings.
#
global $md_escape_table;
 
# Encode all ampersands; HTML entities are not
# entities within a Markdown code span.
$_ = str_replace('&', '&amp;', $_);
 
# Do the angle bracket song and dance:
$_ = str_replace(array('<', '>'),
array('&lt;', '&gt;'), $_);
 
# Now, escape characters that are magic in Markdown:
$_ = str_replace(array_keys($md_escape_table),
array_values($md_escape_table), $_);
 
return $_;
}
 
 
function _DoItalicsAndBold($text) {
# <strong> must go first:
$text = preg_replace('{
( # $1: Marker
(?<!\*\*) \*\* | # (not preceded by two chars of
(?<!__) __ # the same marker)
)
(?=\S) # Not followed by whitespace
(?!\1) # or two others marker chars.
( # $2: Content
(?:
[^*_]+? # Anthing not em markers.
|
# Balence any regular emphasis inside.
([*_]) (?=\S) .+? (?<=\S) \3 # $3: em char (* or _)
|
(?! \1 ) . # Allow unbalenced * and _.
)+?
)
(?<=\S) \1 # End mark not preceded by whitespace.
}sx',
'<strong>\2</strong>', $text);
# Then <em>:
$text = preg_replace(
'{ ( (?<!\*)\* | (?<!_)_ ) (?=\S) (?! \1) (.+?) (?<=\S) \1 }sx',
'<em>\2</em>', $text);
 
return $text;
}
 
 
function _DoBlockQuotes($text) {
$text = preg_replace_callback('/
( # Wrap whole match in $1
(
^[ \t]*>[ \t]? # ">" at the start of a line
.+\n # rest of the first line
(.+\n)* # subsequent consecutive lines
\n* # blanks
)+
)
/xm',
'_DoBlockQuotes_callback', $text);
 
return $text;
}
function _DoBlockQuotes_callback($matches) {
$bq = $matches[1];
# trim one level of quoting - trim whitespace-only lines
$bq = preg_replace(array('/^[ \t]*>[ \t]?/m', '/^[ \t]+$/m'), '', $bq);
$bq = _RunBlockGamut($bq); # recurse
 
$bq = preg_replace('/^/m', " ", $bq);
# These leading spaces screw with <pre> content, so we need to fix that:
$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
'_DoBlockQuotes_callback2', $bq);
 
return "<blockquote>\n$bq\n</blockquote>\n\n";
}
function _DoBlockQuotes_callback2($matches) {
$pre = $matches[1];
$pre = preg_replace('/^ /m', '', $pre);
return $pre;
}
 
 
function _FormParagraphs($text) {
#
# Params:
# $text - string to process with html <p> tags
#
global $md_html_blocks;
 
# Strip leading and trailing lines:
$text = preg_replace(array('/\A\n+/', '/\n+\z/'), '', $text);
 
$grafs = preg_split('/\n{2,}/', $text, -1, PREG_SPLIT_NO_EMPTY);
 
#
# Wrap <p> tags.
#
foreach ($grafs as $key => $value) {
if (!isset( $md_html_blocks[$value] )) {
$value = _RunSpanGamut($value);
$value = preg_replace('/^([ \t]*)/', '<p>', $value);
$value .= "</p>";
$grafs[$key] = $value;
}
}
 
#
# Unhashify HTML blocks
#
foreach ($grafs as $key => $value) {
if (isset( $md_html_blocks[$value] )) {
$grafs[$key] = $md_html_blocks[$value];
}
}
 
return implode("\n\n", $grafs);
}
 
 
function _EncodeAmpsAndAngles($text) {
# Smart processing for ampersands and angle brackets that need to be encoded.
 
# Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
# http://bumppo.net/projects/amputator/
$text = preg_replace('/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/',
'&amp;', $text);;
 
# Encode naked <'s
$text = preg_replace('{<(?![a-z/?\$!])}i', '&lt;', $text);
 
return $text;
}
 
 
function _EncodeBackslashEscapes($text) {
#
# Parameter: String.
# Returns: The string, with after processing the following backslash
# escape sequences.
#
global $md_escape_table, $md_backslash_escape_table;
# Must process escaped backslashes first.
return str_replace(array_keys($md_backslash_escape_table),
array_values($md_backslash_escape_table), $text);
}
 
 
function _DoAutoLinks($text) {
$text = preg_replace("!<((https?|ftp):[^'\">\\s]+)>!",
'<a href="\1">\1</a>', $text);
 
# Email addresses: <address@domain.foo>
$text = preg_replace('{
<
(?:mailto:)?
(
[-.\w]+
\@
[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
)
>
}exi',
"_EncodeEmailAddress(_UnescapeSpecialChars(_UnslashQuotes('\\1')))",
$text);
 
return $text;
}
 
 
function _EncodeEmailAddress($addr) {
#
# Input: an email address, e.g. "foo@example.com"
#
# Output: the email address as a mailto link, with each character
# of the address encoded as either a decimal or hex entity, in
# the hopes of foiling most address harvesting spam bots. E.g.:
#
# <a href="&#x6D;&#97;&#105;&#108;&#x74;&#111;:&#102;&#111;&#111;&#64;&#101;
# x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;">&#102;&#111;&#111;
# &#64;&#101;x&#x61;&#109;&#x70;&#108;&#x65;&#x2E;&#99;&#111;&#109;</a>
#
# Based by a filter by Matthew Wickline, posted to the BBEdit-Talk
# mailing list: <http://tinyurl.com/yu7ue>
#
$addr = "mailto:" . $addr;
$length = strlen($addr);
 
# leave ':' alone (to spot mailto: later)
$addr = preg_replace_callback('/([^\:])/',
'_EncodeEmailAddress_callback', $addr);
 
$addr = "<a href=\"$addr\">$addr</a>";
# strip the mailto: from the visible part
$addr = preg_replace('/">.+?:/', '">', $addr);
 
return $addr;
}
function _EncodeEmailAddress_callback($matches) {
$char = $matches[1];
$r = rand(0, 100);
# roughly 10% raw, 45% hex, 45% dec
# '@' *must* be encoded. I insist.
if ($r > 90 && $char != '@') return $char;
if ($r < 45) return '&#x'.dechex(ord($char)).';';
return '&#'.ord($char).';';
}
 
 
function _UnescapeSpecialChars($text) {
#
# Swap back in all the special characters we've hidden.
#
global $md_escape_table;
return str_replace(array_values($md_escape_table),
array_keys($md_escape_table), $text);
}
 
 
# _TokenizeHTML is shared between PHP Markdown and PHP SmartyPants.
# We only define it if it is not already defined.
if (!function_exists('_TokenizeHTML')) :
function _TokenizeHTML($str) {
#
# Parameter: String containing HTML markup.
# Returns: An array of the tokens comprising the input
# string. Each token is either a tag (possibly with nested,
# tags contained therein, such as <a href="<MTFoo>">, or a
# run of text between tags. Each element of the array is a
# two-element array; the first is either 'tag' or 'text';
# the second is the actual value.
#
#
# Regular expression derived from the _tokenize() subroutine in
# Brad Choate's MTRegex plugin.
# <http://www.bradchoate.com/past/mtregex.php>
#
$index = 0;
$tokens = array();
 
$match = '(?s:<!(?:--.*?--\s*)+>)|'. # comment
'(?s:<\?.*?\?>)|'. # processing instruction
# regular tags
'(?:<[/!$]?[-a-zA-Z0-9:]+\b(?>[^"\'>]+|"[^"]*"|\'[^\']*\')*>)';
 
$parts = preg_split("{($match)}", $str, -1, PREG_SPLIT_DELIM_CAPTURE);
 
foreach ($parts as $part) {
if (++$index % 2 && $part != '')
$tokens[] = array('text', $part);
else
$tokens[] = array('tag', $part);
}
 
return $tokens;
}
endif;
 
 
function _Outdent($text) {
#
# Remove one level of line-leading tabs or spaces
#
global $md_tab_width;
return preg_replace("/^(\\t|[ ]{1,$md_tab_width})/m", "", $text);
}
 
 
function _Detab($text) {
#
# Replace tabs with the appropriate amount of space.
#
global $md_tab_width;
 
# For each line we separate the line in blocks delemited by
# tab characters. Then we reconstruct every line by adding the
# appropriate number of space between each blocks.
$lines = explode("\n", $text);
$text = "";
foreach ($lines as $line) {
# Split in blocks.
$blocks = explode("\t", $line);
# Add each blocks to the line.
$line = $blocks[0];
unset($blocks[0]); # Do not add first block twice.
foreach ($blocks as $block) {
# Calculate amount of space, insert spaces, insert block.
$amount = $md_tab_width - strlen($line) % $md_tab_width;
$line .= str_repeat(" ", $amount) . $block;
}
$text .= "$line\n";
}
return $text;
}
 
 
function _UnslashQuotes($text) {
#
# This function is useful to remove automaticaly slashed double quotes
# when using preg_replace and evaluating an expression.
# Parameter: String.
# Returns: The string with any slash-double-quote (\") sequence replaced
# by a single double quote.
#
return str_replace('\"', '"', $text);
}
 
 
/*
 
PHP Markdown
============
 
Description
-----------
 
This is a PHP translation of the original Markdown formatter written in
Perl by John Gruber.
 
Markdown is a text-to-HTML filter; it translates an easy-to-read /
easy-to-write structured text format into HTML. Markdown's text format
is most similar to that of plain text email, and supports features such
as headers, *emphasis*, code blocks, blockquotes, and links.
 
Markdown's syntax is designed not as a generic markup language, but
specifically to serve as a front-end to (X)HTML. You can use span-level
HTML tags anywhere in a Markdown document, and you can use block level
HTML tags (like <div> and <table> as well).
 
For more information about Markdown's syntax, see:
 
<http://daringfireball.net/projects/markdown/>
 
 
Bugs
----
 
To file bug reports please send email to:
 
<michel.fortin@michelf.com>
 
Please include with your report: (1) the example input; (2) the output you
expected; (3) the output Markdown actually produced.
 
 
Version History
---------------
 
See the readme file for detailed release notes for this version.
 
1.0.1c - 9 Dec 2005
 
1.0.1b - 6 Jun 2005
 
1.0.1a - 15 Apr 2005
 
1.0.1 - 16 Dec 2004
 
1.0 - 21 Aug 2004
 
 
Author & Contributors
---------------------
 
Original Perl version by John Gruber
<http://daringfireball.net/>
 
PHP port and other contributions by Michel Fortin
<http://www.michelf.com/>
 
 
Copyright and License
---------------------
 
Copyright (c) 2004-2005 Michel Fortin
<http://www.michelf.com/>
All rights reserved.
 
Copyright (c) 2003-2004 John Gruber
<http://daringfireball.net/>
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
 
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
 
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
 
This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
 
*/
?>
/trunk/client/phorum/bibliotheque/phorum/mods/.htaccess
New file
0,0 → 1,11
# By default, no module files may be accessed
# directly from a webbrowser.
Order deny,allow
Deny from all
 
# File types for which we make an exception.
<Files ~ "\.(gif|jpg|jpeg|png)$">
Order allow,deny
Allow from all
</Files>
 
/trunk/client/phorum/bibliotheque/phorum/mods/replace/replace.php
New file
0,0 → 1,39
<?php
 
if(!defined("PHORUM")) return;
 
function phorum_mod_replace ($data)
{
$PHORUM=$GLOBALS["PHORUM"];
 
if(isset($PHORUM["mod_replace"])){
 
foreach($data as $key => $message){
 
if(isset($message["body"])){
 
$body=$message["body"];
foreach($PHORUM["mod_replace"] as $entry){
$entry["replace"]=str_replace(array("<", ">"), array("<", ">"), $entry["replace"]);
if($entry["pcre"]){
$body=preg_replace("/$entry[search]/is", $entry["replace"], $body);
} else {
$body=str_replace($entry["search"], "$entry[replace]", $body);
}
}
$data[$key]["body"]=$body;
}
}
 
}
 
return $data;
 
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/replace/settings.php
New file
0,0 → 1,107
<?php
 
if(!defined("PHORUM_ADMIN")) return;
 
$error="";
$curr="NEW";
 
$match_types = array("string", "PCRE");
 
if(count($_POST) && $_POST["search"]!="" && $_POST["replace"]!=""){
 
$item = array("search"=>$_POST["search"], "replace"=>$_POST["replace"], "pcre"=>$_POST["pcre"]);
 
if($_POST["curr"]!="NEW"){
$PHORUM["mod_replace"][$_POST["curr"]]=$item;
} else {
$PHORUM["mod_replace"][]=$item;
}
 
if(empty($error)){
if(!phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]))){
$error="Database error while updating settings.";
} else {
echo "Replacement Updated<br />";
}
}
}
 
if(isset($_GET["curr"])){
if(isset($_GET["delete"])){
unset($PHORUM["mod_replace"][$_GET["curr"]]);
phorum_db_update_settings(array("mod_replace"=>$PHORUM["mod_replace"]));
echo "Replacement Deleted<br />";
} else {
$curr = $_GET["curr"];
}
}
 
 
if($curr!="NEW"){
extract($PHORUM["mod_replace"][$curr]);
$title="Edit Replacement";
$submit="Update";
} else {
settype($string, "string");
settype($type, "int");
settype($pcre, "int");
$title="Add A Replacement";
$submit="Add";
}
 
include_once "./include/admin/PhorumInputForm.php";
 
$frm =& new PhorumInputForm ("", "post", $submit);
 
$frm->hidden("module", "modsettings");
 
$frm->hidden("mod", "replace");
 
$frm->hidden("curr", "$curr");
 
$frm->addbreak($title);
 
$frm->addrow("String To Match", $frm->text_box("search", $search, 50));
 
$frm->addrow("Replacement", $frm->text_box("replace", $replace, 50));
 
$frm->addrow("Compare As", $frm->select_tag("pcre", $match_types, $pcre));
 
$frm->show();
 
echo "If using PCRE for comparison, \"Sting To Match\" should be a valid PCRE expression. See <a href=\"http://php.net/pcre\">the PHP manual</a> for more information.";
 
if($curr=="NEW"){
 
echo "<hr class=\"PhorumAdminHR\" />";
 
if(count($PHORUM["mod_replace"])){
 
echo "<table border=\"0\" cellspacing=\"1\" cellpadding=\"0\" class=\"PhorumAdminTable\" width=\"100%\">\n";
echo "<tr>\n";
echo " <td class=\"PhorumAdminTableHead\">Search</td>\n";
echo " <td class=\"PhorumAdminTableHead\">Replace</td>\n";
echo " <td class=\"PhorumAdminTableHead\">Compare Method</td>\n";
echo " <td class=\"PhorumAdminTableHead\">&nbsp;</td>\n";
echo "</tr>\n";
 
foreach($PHORUM["mod_replace"] as $key => $item){
echo "<tr>\n";
echo " <td class=\"PhorumAdminTableRow\">".htmlspecialchars($item["search"])."</td>\n";
echo " <td class=\"PhorumAdminTableRow\">".htmlspecialchars($item["replace"])."</td>\n";
echo " <td class=\"PhorumAdminTableRow\">".$match_types[$item["pcre"]]."</td>\n";
echo " <td class=\"PhorumAdminTableRow\"><a href=\"$_SERVER[PHP_SELF]?module=modsettings&mod=replace&curr=$key&?edit=1\">Edit</a>&nbsp;&#149;&nbsp;<a href=\"$_SERVER[PHP_SELF]?module=modsettings&mod=replace&curr=$key&delete=1\">Delete</a></td>\n";
echo "</tr>\n";
}
 
echo "</table>\n";
 
} else {
 
echo "No replacements in list currently.";
 
}
 
}
 
?>
/trunk/client/phorum/bibliotheque/phorum/mods/replace/info.txt
New file
0,0 → 1,3
hook: format|phorum_mod_replace
title: Simple Text Replacement Mod
desc: This module allows admins to define text replacement in messages.
/trunk/client/phorum/bibliotheque/phorum/mods/bbcode/settings.php
New file
0,0 → 1,44
<?php
// this Settings file was hacked together from the example module
// kindly created by Chris Eaton (tridus@hiredgoons.ca)
// Update history:
// Checkboxes added for "links in window" and "anti-spam tags" by Adam Sheik (www.cantonese.sheik.co.uk)
 
if(!defined("PHORUM_ADMIN")) return;
 
// save settings
if(count($_POST)){
$PHORUM["mod_bb_code"]["links_in_new_window"]=$_POST["links_in_new_window"] ? 1 : 0;
$PHORUM["mod_bb_code"]["rel_no_follow"]=$_POST["rel_no_follow"] ? 1 : 0;
$PHORUM["mod_bb_code"]["quote_hook"]=$_POST["quote_hook"] ? 1 : 0;
 
if(!phorum_db_update_settings(array("mod_bb_code"=>$PHORUM["mod_bb_code"]))){
$error="Database error while updating settings.";
}
else {
echo "Settings Updated<br />";
}
}
 
include_once "./include/admin/PhorumInputForm.php";
$frm =& new PhorumInputForm ("", "post", "Save");
$frm->hidden("module", "modsettings");
$frm->hidden("mod", "bbcode"); // this is the directory name that the Settings file lives in
 
if (!empty($error)){
echo "$error<br />";
}
$frm->addbreak("Edit settings for the BBCode module");
$frm->addmessage("When users post links on your forum, you can choose whether they open in a new window.");
$frm->addrow("Open links in new window: ", $frm->checkbox("links_in_new_window", "1", "", $PHORUM["mod_bb_code"]["links_in_new_window"]));
$frm->addmessage("Enable <a href=\"http://en.wikipedia.org/wiki/Blog_spam\" target=\"_blank\">
Google's new anti-spam protocol</a> for links posted on your forums.
<br/>
Note, this doesn't stop spam links being posted, but it does mean that
spammers don't get credit from Google from that link.");
$frm->addrow("Use 'rel=nofollow' anti-spam tag: ", $frm->checkbox("rel_no_follow", "1", "", $PHORUM["mod_bb_code"]["rel_no_follow"]));
$frm->addmessage("As of Phorum 5.1, there is the option to have quoted text altered by modules. Since it only makes sense to have one module modifying the quoted text, you can disable this one part of this module.");
 
$frm->addrow("Enable quote hook", $frm->checkbox("quote_hook", "1", "", $PHORUM["mod_bb_code"]["quote_hook"]));
$frm->show();
?>
/trunk/client/phorum/bibliotheque/phorum/mods/bbcode/info.txt
New file
0,0 → 1,4
hook: format|phorum_bb_code
hook: quote|phorum_bb_code_quote
title: BB Code Phorum Mod
desc: This module converts BB Code into HTML.
/trunk/client/phorum/bibliotheque/phorum/mods/bbcode/bbcode.php
New file
0,0 → 1,150
<?php
 
if(!defined("PHORUM")) return;
 
// BB Code Phorum Mod
function phorum_bb_code($data)
{
$PHORUM = $GLOBALS["PHORUM"];
 
$search = array(
"/\[img\]((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%# ]+?)\[\/img\]/is",
"/\[url\]((http|https|ftp|mailto):\/\/([a-z0-9\.\-@:]+)[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),\#%~ ]*?)\[\/url\]/is",
"/\[url=((http|https|ftp|mailto):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%# ]+?)\](.+?)\[\/url\]/is",
"/\[email\]([a-z0-9\-_\.\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+?)\[\/email\]/ies",
"/\[color=([\#a-z0-9]+?)\](.+?)\[\/color\]/is",
"/\[size=([+\-\da-z]+?)\](.+?)\[\/size\]/is",
"/\[b\](.+?)\[\/b\]/is",
"/\[u\](.+?)\[\/u\]/is",
"/\[i\](.+?)\[\/i\]/is",
"/\[s\](.+?)\[\/s\]/is",
"/\[center\](.+?)\[\/center\]/is",
"/\[hr\]/i",
"/\[code\](.+?)\[\/code\]/is",
"/\[sub\](.+?)\[\/sub\]/is",
"/\[sup\](.+?)\[\/sup\]/is",
);
 
// add extra tags to links, if enabled in the admin settings page
 
$extra_link_tags = "";
 
if(isset($PHORUM["mod_bb_code"])){ // check for settings file before using settings-dependent variables
if ($PHORUM["mod_bb_code"]["links_in_new_window"]){
$extra_link_tags .= "target=\"_blank\" ";
}
if ($PHORUM["mod_bb_code"]["rel_no_follow"]){
$extra_link_tags .= "rel=\"nofollow\" ";
}
}
 
$replace = array(
"<img src=\"$1\" />",
"[<a $extra_link_tags href=\"$1\">$3</a>]",
"<a $extra_link_tags href=\"$1\">$3</a>",
"'<a $extra_link_tags href=\"'.phorum_html_encode('mailto:$1').'\">'.phorum_html_encode('$1').'</a>'",
"<span style=\"color: $1\">$2</span>",
"<span style=\"font-size: $1\">$2</span>",
"<strong>$1</strong>",
"<u>$1</u>",
"<i>$1</i>",
"<s>$1</s>",
"<center class=\"bbcode\">$1</center>",
"<hr class=\"bbcode\" />",
"<pre class=\"bbcode\">$1</pre>",
"<sub class=\"bbcode\">$1</sub>",
"<sup class=\"bbcode\">$1</sup>",
);
 
$quote_search = array(
"/\[quote\]/is",
"/\[quote ([^\]]+?)\]/is",
"/\[quote=([^\]]+?)\]/is",
"/\[\/quote\]/is"
);
 
$quote_replace = array(
"<blockquote class=\"bbcode\">".$PHORUM["DATA"]["LANG"]["Quote"] . ":<div>",
"<blockquote class=\"bbcode\">".$PHORUM["DATA"]["LANG"]["Quote"] . ":<div><strong>$1</strong><br />",
"<blockquote class=\"bbcode\">".$PHORUM["DATA"]["LANG"]["Quote"] . ":<div><strong>$1</strong><br />",
"</div></blockquote>"
);
 
foreach($data as $message_id => $message){
 
if(isset($message["body"])){
 
// do BB Code here
$body = $message["body"];
 
$rnd=substr(md5($body.time()), 0, 4);
 
// convert bare urls into bbcode tags as best we can
// the haystack has to have a space in front of it for the preg to work.
$body = preg_replace("/([^='\"(\[url\]|\[img\])])((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#]+)/i", "$1:$rnd:$2:/$rnd:", " $body");
 
// stip puncuation from urls
if(preg_match_all("!:$rnd:(.+?):/$rnd:!i", $body, $match)){
 
$urls = array_unique($match[1]);
 
foreach($urls as $key => $url){
// stip puncuation from urls
if(preg_match("|[^a-z0-9=&/\+_]+$|i", $url, $match)){
 
$extra = $match[0];
$true_url = substr($url, 0, -1 * (strlen($match[0])));
 
$body = str_replace("$url:/$rnd:", "$true_url:/$rnd:$extra", $body);
 
$url = $true_url;
}
 
$body = str_replace(":$rnd:$url:/$rnd:", "[url]{$url}[/url]", $body);
}
 
}
 
// no sense doing any of this if there is no [ in the body
if(strstr($body, "[")){
 
// convert bare email addresses into bbcode tags as best we can.
$body = preg_replace("/([a-z0-9][a-z0-9\-_\.\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+[a-z0-9])/i", "[email]$1[/email]", $body);
 
// clean up any BB code we stepped on.
$body = str_replace("[email][email]", "[email]", $body);
$body = str_replace("[/email][/email]", "[/email]", $body);
 
// fiddle with white space around quote and code tags.
$body=preg_replace("/\s*(\[\/*(code|quote)\])\s*/", "$1", $body);
 
// run the pregs defined above
$body = preg_replace($search, $replace, $body);
 
// quote has to be handled differently because they can be embedded.
// we only do quote replacement if we have matching start and end tags
if(strstr($body, "[quote") && substr_count($body, "[quote")==substr_count($body, "[/quote]")){
$body = preg_replace($quote_search, $quote_replace, $body);
}
 
 
}
 
 
$data[$message_id]["body"] = $body;
}
}
 
return $data;
}
 
 
function phorum_bb_code_quote ($array)
{
$PHORUM = $GLOBALS["PHORUM"];
 
if(isset($PHORUM["mod_bb_code"]) && $PHORUM["mod_bb_code"]["quote_hook"]){
return "[quote $array[0]]$array[1][/quote]";
}
}
?>
/trunk/client/phorum/bibliotheque/phorum/mods/html/info.txt
New file
0,0 → 1,3
hook: format|phorum_html
title: HTML Phorum Mod
desc: This module allow HTML to be used in posts. This includes allowing special characters (eg. UTF-8) that are HTML encoded. NOTE: Bad HTML input by users could mess up your page layout.
/trunk/client/phorum/bibliotheque/phorum/mods/html/html.php
New file
0,0 → 1,51
<?php
 
if(!defined("PHORUM")) return;
 
// HTML Phorum Mod
function phorum_html($data)
{
$PHORUM = $GLOBALS["PHORUM"];
 
foreach($data as $message_id => $message){
 
if(isset($message["body"])){
 
$body = $message["body"];
 
// restore tags where Phorum has killed them
$body = preg_replace("!&lt;(\/*[a-z].*?)&gt;!i", "<$1>", $body);
 
// restore escaped &
$body = str_replace("&amp;", "&", $body);
 
// strip out javascript events
if(preg_match_all("/<[a-z][^>]+>/i", $body, $matches)){
$tags=array_unique($matches[0]);
foreach($tags as $tag){
$newtag=preg_replace("/\son.+?=[^>]+/i", "$1", $tag);
$body=str_replace($tag, $newtag, $body);
}
}
 
// turn script and meta tags into comments
$body=preg_replace("/<(\/*(script|meta).*?)>/i", "<!--$1-->", $body);
 
// strip any <br phorum=\"true\" /> that got inside certain blocks like tables and pre.
$block_tags="table|pre|xmp";
 
preg_match_all("!(<($block_tags).*?>).+?(</($block_tags).*?>)!ms", $body, $matches);
 
foreach($matches[0] as $block){
$newblock=str_replace("<br phorum=\"true\" />", "", $block);
$body=str_replace($block, $newblock, $body);
}
 
$data[$message_id]["body"] = $body;
}
}
 
return $data;
}
 
?>