[Phpfreechat-svn] SF.net SVN: phpfreechat: [1140] trunk/src
Status: Beta
Brought to you by:
kerphi
|
From: <ke...@us...> - 2007-08-22 06:38:31
|
Revision: 1140
http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1140&view=rev
Author: kerphi
Date: 2007-08-21 23:38:33 -0700 (Tue, 21 Aug 2007)
Log Message:
-----------
To avoid functions name conflicts : prefix the function and file name with "pfc" or "pfc_"
So that you can be almost sure that the functions pfc uses will not interact with other users libraries.
Modified Paths:
--------------
trunk/src/pfccontainer.class.php
Added Paths:
-----------
trunk/src/pfcurlprocessing.php
Removed Paths:
-------------
trunk/src/urlprocessing.php
Modified: trunk/src/pfccontainer.class.php
===================================================================
--- trunk/src/pfccontainer.class.php 2007-08-21 16:59:45 UTC (rev 1139)
+++ trunk/src/pfccontainer.class.php 2007-08-22 06:38:33 UTC (rev 1140)
@@ -21,7 +21,7 @@
*/
require_once dirname(__FILE__)."/pfccontainerinterface.class.php";
- require_once dirname(__FILE__)."/urlprocessing.php";
+ require_once dirname(__FILE__)."/pfcurlprocessing.php";
/**
* pfcContainer is an abstract class which define interface
@@ -383,7 +383,7 @@
$msgid = $this->_requestMsgId($chan);
// convert URLs to html
- $param = make_hyperlink($param);
+ $param = pfc_make_hyperlink($param);
// format message
$data = "\n";
Copied: trunk/src/pfcurlprocessing.php (from rev 1139, trunk/src/urlprocessing.php)
===================================================================
--- trunk/src/pfcurlprocessing.php (rev 0)
+++ trunk/src/pfcurlprocessing.php 2007-08-22 06:38:33 UTC (rev 1140)
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * Rewritten by Nathan Codding - Feb 6, 2001.
+ * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
+ * to that URL
+ * - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
+ * to http://www.xxxx.yyyy[/zzzz]
+ * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
+ * to that email address
+ * - Only matches these 2 patterns either after a space, or at the beginning of a line
+ *
+ * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
+ * have it require something like xx...@yy... or such. We'll see.
+ */
+function pfc_make_hyperlink($text)
+{
+ $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
+
+ // pad it with a space so we can match things at the start of the 1st line.
+ $ret = ' ' . $text;
+
+ // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
+ // xxxx can only be alpha characters.
+ // yyyy is anything up to the first space, newline, comma, double quote or <
+ //$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
+ $ret = preg_replace("#(^|[\n \]])([\w]+?://[\w\#$%&~/.\-;:=,?@+]*)#ise", "'\\1<a href=\"\\2\" target=\"_blank\">' . pfc_shorten_url('\\2') . '</a>'", $ret);
+
+ // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
+ // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
+ // zzzz is optional.. will contain everything up to the first space, newline,
+ // comma, double quote or <.
+ //$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
+ $ret = preg_replace("#(^|[\n \]])((www|ftp)\.[\w\#$%&~/.\-;:=,?@+]*)#ise", "'\\1<a href=\"http://\\2\" target=\"_blank\">' . pfc_shorten_url('\\2') . '</a>'", $ret);
+
+ // matches an email@domain type address at the start of a line, or after a space.
+ // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
+ //$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
+ $ret = preg_replace("#(^|[\n \]])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#ie", "'\\1<a href=\"mailto:\\2@\\3\">' . pfc_shorten_url('\\2@\\3') . '</a>'", $ret);
+
+ // Remove our padding..
+ $ret = substr($ret, 1);
+
+ return($ret);
+}
+
+/**
+ * Nathan Codding - Feb 6, 2001
+ * Reverses the effects of make_clickable(), for use in editpost.
+ * - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
+ *
+ */
+function pfc_undo_make_hyperlink($text)
+{
+ $text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
+ $text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
+
+ return $text;
+
+}
+
+function pfc_shorten_url($url)
+{
+ $len = strlen($url);
+ $short_url = ($len > 40) ? substr($url, 0, 30) . "..." . substr($url, -7) : $url;
+
+ return $short_url;
+}
+
+?>
Deleted: trunk/src/urlprocessing.php
===================================================================
--- trunk/src/urlprocessing.php 2007-08-21 16:59:45 UTC (rev 1139)
+++ trunk/src/urlprocessing.php 2007-08-22 06:38:33 UTC (rev 1140)
@@ -1,70 +0,0 @@
-<?php
-
-/**
- * Rewritten by Nathan Codding - Feb 6, 2001.
- * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
- * to that URL
- * - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
- * to http://www.xxxx.yyyy[/zzzz]
- * - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
- * to that email address
- * - Only matches these 2 patterns either after a space, or at the beginning of a line
- *
- * Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
- * have it require something like xx...@yy... or such. We'll see.
- */
-function make_hyperlink($text)
-{
- $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
-
- // pad it with a space so we can match things at the start of the 1st line.
- $ret = ' ' . $text;
-
- // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
- // xxxx can only be alpha characters.
- // yyyy is anything up to the first space, newline, comma, double quote or <
- //$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
- $ret = preg_replace("#(^|[\n \]])([\w]+?://[\w\#$%&~/.\-;:=,?@+]*)#ise", "'\\1<a href=\"\\2\" target=\"_blank\">' . shorten_url('\\2') . '</a>'", $ret);
-
- // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
- // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
- // zzzz is optional.. will contain everything up to the first space, newline,
- // comma, double quote or <.
- //$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
- $ret = preg_replace("#(^|[\n \]])((www|ftp)\.[\w\#$%&~/.\-;:=,?@+]*)#ise", "'\\1<a href=\"http://\\2\" target=\"_blank\">' . shorten_url('\\2') . '</a>'", $ret);
-
- // matches an email@domain type address at the start of a line, or after a space.
- // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
- //$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
- $ret = preg_replace("#(^|[\n \]])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#ie", "'\\1<a href=\"mailto:\\2@\\3\">' . shorten_url('\\2@\\3') . '</a>'", $ret);
-
- // Remove our padding..
- $ret = substr($ret, 1);
-
- return($ret);
-}
-
-/**
- * Nathan Codding - Feb 6, 2001
- * Reverses the effects of make_clickable(), for use in editpost.
- * - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
- *
- */
-function undo_make_hyperlink($text)
-{
- $text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
- $text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
-
- return $text;
-
-}
-
-function shorten_url($url)
-{
- $len = strlen($url);
- $short_url = ($len > 40) ? substr($url, 0, 30) . "..." . substr($url, -7) : $url;
-
- return $short_url;
-}
-
-?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|