Server : Apache System : Linux webd348.cluster026.gra.hosting.ovh.net 5.15.148-ovh-vps-grsec-zfs-classid #1 SMP Thu Feb 8 09:41:04 UTC 2024 x86_64 User : hednacluml ( 122243) PHP Version : 8.3.9 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Directory : /home/hednacluml/jobs/plugins-dist/textwheel/inc/ |
<?php /* * transforme un raccourci de ressource en un lien minimaliste * * */ define('_EXTRAIRE_RESSOURCES', ',' . '<"?(https?://|[^\s][\w -]+\.[\w -]+)[^<]*>' . ',UimsS'); /* pipeline pour typo */ function tw_post_typo($t) { if (strpos($t, '<') !== false) { $t = preg_replace_callback(_EXTRAIRE_RESSOURCES, 'tw_traiter_ressources', $t); } return $t; } /* pipeline pour propre */ function tw_pre_liens($t) { if (strpos($t, '<') !== false) { $t = preg_replace_callback(_EXTRAIRE_RESSOURCES, 'tw_traiter_ressources', $t); // echapper les autoliens eventuellement inseres (en une seule fois) if (strpos($t, '<html>') !== false) { $t = echappe_html($t); } } return $t; } function tw_traiter_ressources($r) { $html = null; include_spip('inc/lien'); $url = explode(' ', trim($r[0], '<>')); $url = $url[0]; # <http://url/absolue> if (preg_match(',^https?://,i', $url)) { $html = PtoBR(propre("<span class='ressource spip_out'><[->" . $url . ']></span>')); } # <url/relative> else { if (false !== strpos($url, '/')) { $html = PtoBR(propre("<span class='ressource spip_in'><[->" . $url . ']></span>')); } # <fichier.rtf> else { if ( preg_match(',\.([^.]+)$,', $url, $regs) and file_exists($f = _DIR_IMG . $regs[1] . '/' . $url) ) { $html = PtoBR(propre("<span class='ressource spip_in'><[" . $url . '->' . $f . ']></span>')); } else { $html = PtoBR(propre("<span class='ressource'><" . $url . '></span>')); } } } return '<html>' . $html . '</html>'; }