Changeset 381
- Timestamp:
- 03/30/08 22:31:40 (16 years ago)
- Location:
- plugins/remotelatex
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/remotelatex/_admin.php
r363 r381 1 1 <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 2 2 /***************************************************************\ 3 * This is 'Remote La tex', a plugin for Dotclear *3 * This is 'Remote LaTeX', a plugin for Dotclear * 4 4 * * 5 5 * Copyright (c) 2007-2008 * … … 10 10 * * 11 11 * You should have received a copy of the GNU General Public * 12 * License along with 'Remote La tex' (see COPYING.txt); *12 * License along with 'Remote LaTeX' (see COPYING.txt); * 13 13 * if not, write to the Free Software Foundation, Inc., * 14 14 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 15 15 \***************************************************************/ 16 17 $_menu['Plugins']->addItem('LaTeX','plugin.php?p=remotelatex', 18 null, 19 preg_match('/plugin.php\?p=remotelatex(&.*)?$/',$_SERVER['REQUEST_URI']), 20 $core->auth->check('contentadmin',$core->blog->id)); 16 21 17 22 $core->addBehavior('coreInitWikiPost',array('remoteLatex','coreInitWikiPost')); … … 34 39 self::getSettings($latex_server,$root_path,$root_url); 35 40 36 $file_name = sprintf('%s/%s/%s .png',41 $file_name = sprintf('%s/%s/%s', 37 42 $root_path, 38 43 substr($hash,0,2), … … 40 45 ); 41 46 42 $file_url = sprintf('%s/%s/%s .png',47 $file_url = sprintf('%s/%s/%s', 43 48 $root_url, 44 49 substr($hash,0,2), … … 58 63 $dist_url = $latex_server.rawurlencode($tex); 59 64 60 # Get rendered PNG picture65 # Get rendered PNG image 61 66 if (netHttp::quickGet($dist_url,$file_name) === false) { 62 67 throw new Exception(sprintf( 63 __('Unable to get La teximage from the server %s.'),68 __('Unable to get LaTeX image from the server %s.'), 64 69 html::escapeHTML($latex_server) 65 70 )); 66 71 } 67 72 68 # Verify that we got a correct PNG file 73 # Verify that we got a valid PNG / GIF file 74 $accept_sig = array( 75 "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", # PNG 76 "\x47\x49\x46\x38\x39\x61", # GIF87a 77 "\x47\x49\x46\x38\x37\x61" # GIF89a 78 ); 69 79 $signature = file_get_contents($file_name,false,null,0,8); 70 80 71 if ($signature != "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a") { 72 @unlink($file_name); 73 throw new Exception(__('File is not a valid PNG image')); 81 foreach ($accept_sig as $sig) 82 { 83 if (strncmp($signature,$sig,strlen($sig)) === 0) { 84 return self::getHtml($tex,$file_url); 85 } 74 86 } 87 88 @unlink($file_name); 89 throw new Exception(__('File is not a valid PNG / GIF image')); 75 90 } 76 91 catch (Exception $e) { 77 # If something is wrong, La excode is returned in plain text92 # If something is wrong, LaTeX code is returned in plain text 78 93 #$core->error->add($e->getMessage()); 79 94 return self::getHtml($tex); 80 95 } 81 82 return self::getHtml($tex,$file_url);83 96 } 84 97 … … 95 108 } 96 109 97 public static function getSettings(&$latex_server ,&$root_path,&$root_url)110 public static function getSettings(&$latex_server='',&$root_path='',&$root_url='') 98 111 { 99 112 global $core; 100 113 101 114 $root_path = path::real($core->blog->public_path).'/latex-images'; 102 $root_url = $core->blog->host. 103 path::clean($core->blog->settings->public_url).'/latex-images'; 115 $root_url = path::clean($core->blog->settings->public_url).'/latex-images'; 104 116 105 117 $latex_server = $core->blog->settings->latex_server; … … 111 123 $latex_server, 112 124 'string', 113 'La texserver URL'125 'LaTeX server URL' 114 126 ); 115 127 } -
plugins/remotelatex/_define.php
r363 r381 1 1 <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 2 2 /***************************************************************\ 3 * This is 'Remote La tex', a plugin for Dotclear *3 * This is 'Remote LaTeX', a plugin for Dotclear * 4 4 * * 5 5 * Copyright (c) 2007-2008 * … … 10 10 * * 11 11 * You should have received a copy of the GNU General Public * 12 * License along with 'Remote La tex' (see COPYING.txt); *12 * License along with 'Remote LaTeX' (see COPYING.txt); * 13 13 * if not, write to the Free Software Foundation, Inc., * 14 14 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
Note: See TracChangeset
for help on using the changeset viewer.