|
Server IP : 10.111.40.2 / Your IP : 216.73.217.69 Web Server : Apache System : Linux webd002.cluster111.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : comimage ( 586) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/comimage/referencement/demo/tmp/cache/fe/../../../tmp/../plugins/../ecrire/inc/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2016 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
//
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
//
// Gestion du raccourci <math>...</math> en client-serveur
//
// http://code.spip.net/@image_math
function produire_image_math($tex) {
switch ($GLOBALS['traiter_math']) {
// Attention: mathml desactiv'e pour l'instant
case 'mathml':
$ext = '.xhtml';
$server = $GLOBALS['mathml_server'];
break;
case 'tex':
$ext = '.png';
$server = $GLOBALS['tex_server'];
break;
default:
return $tex;
}
// Regarder dans le repertoire local des images TeX et blocs MathML
if (!@is_dir($dir_tex = _DIR_VAR . 'cache-TeX/')) {
@mkdir($dir_tex, _SPIP_CHMOD);
}
$fichier = $dir_tex . md5(trim($tex)) . $ext;
if (!@file_exists($fichier)) {
// Aller chercher l'image sur le serveur
if ($server) {
spip_log($url = $server . '?' . rawurlencode($tex));
include_spip('inc/distant');
recuperer_page($url, $fichier);
}
}
// Composer la reponse selon presence ou non de l'image
$tex = entites_html($tex);
if (@file_exists($fichier)) {
// MathML
if ($GLOBALS['traiter_math'] == 'mathml') {
return join(file("$fichier"), "");
} // TeX
else {
list(, , , $size) = @getimagesize($fichier);
$alt = "alt=\"$tex\" title=\"$tex\"";
return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
}
} else // pas de fichier
{
return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
}
}
// Fonction appelee par propre() s'il repere un mode <math>
// http://code.spip.net/@traiter_math
function traiter_math($letexte, $source = '') {
$texte_a_voir = $letexte;
while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
if (!$fin = strpos($texte_a_voir, "</math>")) {
$fin = strlen($texte_a_voir);
}
$texte_debut = substr($texte_a_voir, 0, $debut);
$texte_milieu = substr($texte_a_voir,
$debut + strlen("<math>"), $fin - $debut - strlen("<math>"));
$texte_fin = substr($texte_a_voir,
$fin + strlen("</math>"), strlen($texte_a_voir));
// Les doubles $$x^2$$ en mode 'div'
while ((preg_match(",[$][$]([^$]+)[$][$],", $texte_milieu, $regs))) {
$echap = "\n<p class=\"spip\" style=\"text-align: center;\">" . produire_image_math($regs[1]) . "</p>\n";
$pos = strpos($texte_milieu, $regs[0]);
$texte_milieu = substr($texte_milieu, 0, $pos)
. code_echappement($echap, $source)
. substr($texte_milieu, $pos + strlen($regs[0]));
}
// Les simples $x^2$ en mode 'span'
while ((preg_match(",[$]([^$]+)[$],", $texte_milieu, $regs))) {
$echap = produire_image_math($regs[1]);
$pos = strpos($texte_milieu, $regs[0]);
$texte_milieu = substr($texte_milieu, 0, $pos)
. code_echappement($echap, $source)
. substr($texte_milieu, $pos + strlen($regs[0]));
}
$texte_a_voir = $texte_debut . $texte_milieu . $texte_fin;
}
return $texte_a_voir;
}
