Fix URL catcher for events
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 2 Sep 2006 13:53:37 +0000 (13:53 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sat, 2 Sep 2006 13:53:37 +0000 (13:53 +0000)
Add URL catching for users' free text

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@835 839d8a87-29fc-0310-9880-83ba4fa771e5

modules/events.php
modules/profile.php
templates/fiche.tpl

index 35fe2e9..af01c70 100644 (file)
@@ -176,10 +176,10 @@ class EventsModule extends PLModule
         $page->assign('action', strtolower($action));
 
         if ($action == 'Confirmer') {
-            $texte = preg_replace('/((http|ftp)+(s)?:\/\/[^<>\s]+)/i',
-                                  '<a href=\"\\0\">\\0</a>', $texte);
-            $texte = preg_replace('/([^,\s]+@[^,\s]+)/i',
-                                  '<a href=\"mailto:\\0\">\\0</a>', $texte);
+            $texte = preg_replace('/((?:https?|ftp):\/\/(?:\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i',
+                                  '<a href="\\0">\\0</a>', $texte);
+            $texte = preg_replace('/(?:mailto:)?([a-z0-9.\-+_]+@([\-.+_]?[a-z0-9])+)/i',
+                                  '<a href="mailto:\\0">\\0</a>', $texte);
             require_once 'validations.inc.php';
             $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max,
                                  $peremption, $valid_mesg, S::v('uid'));
index 5e9fcb9..1a6c1b8 100644 (file)
@@ -190,6 +190,8 @@ class ProfileModule extends PLModule
 
         $new   = Env::v('modif') == 'new';
         $user  = get_user_details($login, S::v('uid'), $view);
+        $user['freetext'] = preg_replace('/((?:https?|ftp):\/\/(?:&amp;|\.*,*[a-z@0-9~%$£µ&i#\-+=_\/\?])*)/i',
+                                         '<a href="\\0">\\0</a>', $user['freetext']);
         $title = $user['prenom'] . ' ' . empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'];
         $page->assign('xorg_title', $title);
 
index 10ec182..78689f7 100644 (file)
@@ -116,7 +116,7 @@ function chgMainWinLoc( strPage ) {
       {if $x.gpxs_join}<div><em class="intitule">Groupe(s) X : </em><span>{$x.gpxs_join|smarty:nodefaults}</span></div>{/if}
       {/if}
       {if $x.web}<div><em class="intitule">Site Web : </em><a href="{$x.web}" class='popup'>{$x.web}</a></div>{/if}
-      {if $x.freetext}<div><em class="intitule">Commentaires : </em><br /><span>{$x.freetext|nl2br}</span></div>{/if}
+      {if $x.freetext}<div><em class="intitule">Commentaires : </em><br /><span>{$x.freetext|nl2br|smarty:nodefaults}</span></div>{/if}
     </td>
   </tr>
   {if $x.adr}