allow_url_fopenがOffの場合にエスケープ
@@ -1,7 +1,7 @@ | ||
1 | 1 | <?php |
2 | 2 | /*------------------------------------------------------------------------------+ |
3 | - <meta http-equiv="Content-Type" content="text/php; charset=utf-8"> | |
4 | - | |
3 | + <meta http-equiv="Content-Type" content="text/php; charset=utf-8"> | |
4 | + | |
5 | 5 | text2html てきでこ Akio Tenman. <http://text2html.sourceforge.jp/> |
6 | 6 | Copyright (C) 2008 Akio Tenman <tenman@users.sourceforge.jp> |
7 | 7 |
@@ -21,19 +21,19 @@ | ||
21 | 21 | //このアプリで、外部API等を参照する場合、allow_url_fopenはtrueである必要があります。 |
22 | 22 | |
23 | 23 | mb_language( 'Japanese' ); |
24 | - | |
24 | + | |
25 | 25 | if(preg_match("/^[A-z]:.+/",__FILE__)){ |
26 | - $separater = '\\'; | |
26 | + $separater = '\\'; | |
27 | 27 | }else{ |
28 | - $separater = '/'; | |
28 | + $separater = '/'; | |
29 | 29 | } |
30 | - | |
31 | - if(!isset($text2html_url)){ | |
32 | - $text2html_url = "http://". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']).$separater; | |
30 | + | |
31 | + if(!isset($text2html_url)){ | |
32 | + $text2html_url = "http://". $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']).'/'; | |
33 | 33 | } |
34 | 34 | |
35 | - if(!isset($text2html_dir_path)){ | |
36 | - $text2html_dir_path = dirname(dirname(__FILE__)).$separater; | |
35 | + if(!isset($text2html_dir_path)){ | |
36 | + $text2html_dir_path = dirname(dirname(__FILE__)).$separater; | |
37 | 37 | } |
38 | 38 | |
39 | 39 | if(!isset($cache)){ |
@@ -51,7 +51,7 @@ | ||
51 | 51 | |
52 | 52 | //画像保管用ディレクトリ |
53 | 53 | define("TEXTTOHTML_IMAGE_DIR_PATH", $text2html_dir_path."images{$separater}"); |
54 | - define("TEXTTOHTML_IMAGE_DIR_URL", $text2html_url."images{$separater}"); | |
54 | + define("TEXTTOHTML_IMAGE_DIR_URL", $text2html_url.'images/'); | |
55 | 55 | //イメージコピー用スクリプト |
56 | 56 | define("TEXTTOHTML_COPY_IMG_WIDTH","100"); |
57 | 57 | define("IMAGE_IMPORT_PATH", $text2html_dir_path."import{$separater}"); |
@@ -75,7 +75,9 @@ | ||
75 | 75 | define("HTML_RULE_CONFIG_FILE_PATH",TEXTTOHTML_SCRIPTS_DIR_PATH."html.ini"); |
76 | 76 | define("TEXTTOHTML_FONT_DIR_PATH",$text2html_dir_path."font{$separater}"); |
77 | 77 | define("TEXTTOHTML_FONTS_PATH",TEXTTOHTML_FONT_DIR_PATH."fonts.inc"); |
78 | + | |
78 | 79 | |
80 | + | |
79 | 81 | //MEMO |
80 | 82 | /*----------------------------------------------------------------------+ |
81 | 83 | * get_querys()で使用する配列の説明。 |
@@ -123,47 +125,47 @@ | ||
123 | 125 | var $attr; |
124 | 126 | var $content_attr; |
125 | 127 | var $description; |
126 | - var $copy_target; | |
127 | - var $copy_uri; | |
128 | + var $copy_target; | |
129 | + var $copy_uri; | |
128 | 130 | |
129 | 131 | |
130 | - function trans($document){ | |
132 | + function trans($document){ | |
131 | 133 | |
132 | - $document = str_replace(array("\r"),"\n",$document); | |
133 | - $document = $this->tag_br($document); | |
134 | - $this->document = $this->tag_clear($document); | |
134 | + $document = str_replace(array("\r"),"\n",$document); | |
135 | + $document = $this->tag_br($document); | |
136 | + $this->document = $this->tag_clear($document); | |
135 | 137 | } |
136 | 138 | |
137 | 139 | function delete_break($matches){ |
138 | 140 | $result = ""; |
139 | - | |
140 | - foreach($matches as $key=>$match){ | |
141 | - if($key==0){ | |
142 | - $result .= str_replace("\n","",$match); | |
143 | - } | |
144 | - } | |
145 | - | |
146 | - $result = preg_replace("/\s{2,}/"," ",$result); | |
147 | - | |
148 | - return $result; | |
141 | + | |
142 | + foreach($matches as $key=>$match){ | |
143 | + if($key==0){ | |
144 | + $result .= str_replace("\n","",$match); | |
145 | + } | |
146 | + } | |
147 | + | |
148 | + $result = preg_replace("/\s{2,}/"," ",$result); | |
149 | + | |
150 | + return $result; | |
149 | 151 | } |
150 | 152 | |
151 | 153 | function tag_br($text){ |
152 | - $text = str_replace("\r","",$text); | |
153 | - $text = preg_replace("/\s=/","=",$text); | |
154 | - $text = preg_replace_callback("/[^(code:)](<[^>]+\s{2,}[^>]+>)/usi",array($this, 'delete_break'),$text); | |
154 | + $text = str_replace("\r","",$text); | |
155 | + $text = preg_replace("/\s=/","=",$text); | |
156 | + $text = preg_replace_callback("/[^(code:)](<[^>]+\s{2,}[^>]+>)/usi",array($this, 'delete_break'),$text); | |
155 | 157 | |
156 | - return $text; | |
158 | + return $text; | |
157 | 159 | |
158 | 160 | } |
159 | 161 | |
160 | 162 | function get_querys($text){ |
161 | 163 | |
162 | - if(ini_get("allow_url_fopen") == false){ | |
164 | + if(ini_get("allow_url_fopen") == false){ | |
165 | + | |
166 | + return $text; | |
167 | + } | |
163 | 168 | |
164 | - return $text; | |
165 | - } | |
166 | - | |
167 | 169 | //重複名の誤変換を避けるために、文字数の長い順にソート |
168 | 170 | $get_querys = array( |
169 | 171 | /*キー名は10文字未満*/ |
@@ -210,22 +212,22 @@ | ||
210 | 212 | 'url'=>'http://www.odekake.biz/branch/?date=+++E_KEYWORD+++', |
211 | 213 | "response"=>"+++CONTENTS+++\n"), |
212 | 214 | ); |
213 | - | |
215 | + | |
214 | 216 | uksort($get_querys,"text2html_cmp"); |
215 | 217 | |
216 | 218 | if(isset($get_querys)){ |
217 | 219 | foreach($get_querys as $key=>$val){ |
218 | 220 | if(preg_match_all("/($key>\()([^\)]+)(\))/u", $text, $matches, PREG_SET_ORDER)){ |
219 | - | |
221 | + | |
220 | 222 | foreach($matches as $key=>$match){ |
221 | - | |
223 | + | |
222 | 224 | $cache = use_cache($matches[$key][0]); |
223 | 225 | if($cache[0]){ |
224 | - | |
225 | - $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
226 | + | |
227 | + $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
226 | 228 | }else{ |
227 | - | |
228 | - $enc = mb_convert_encoding($match[2],$val['charset'],"auto"); | |
229 | + | |
230 | + $enc = mb_convert_encoding($match[2],$val['charset'],"auto"); | |
229 | 231 | $no_enc = mb_convert_encoding($match[2],"UTF-8","auto"); |
230 | 232 | $no_enc = str_replace("\n","",$no_enc); |
231 | 233 |
@@ -233,7 +235,7 @@ | ||
233 | 235 | |
234 | 236 | case('link'): |
235 | 237 | |
236 | - $enc = urlencode($enc); | |
238 | + $enc = urlencode($enc); | |
237 | 239 | $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); |
238 | 240 | $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']); |
239 | 241 | $replacement = trim($replacement); |
@@ -241,24 +243,24 @@ | ||
241 | 243 | |
242 | 244 | case('contents'): |
243 | 245 | |
244 | - $enc = urlencode($enc); | |
245 | - $target = mb_convert_encoding($val['url'],"UTF-8","auto"); | |
246 | - $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$target); | |
247 | - $host = parse_url($target); | |
248 | - $host = $host['host']; | |
249 | - | |
246 | + $enc = urlencode($enc); | |
247 | + $target = mb_convert_encoding($val['url'],"UTF-8","auto"); | |
248 | + $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$target); | |
249 | + $host = parse_url($target); | |
250 | + $host = $host['host']; | |
251 | + | |
250 | 252 | try{ |
251 | 253 | |
252 | 254 | if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){ |
253 | - | |
255 | + | |
254 | 256 | throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。'); |
255 | 257 | } |
256 | - | |
258 | + | |
257 | 259 | socket_set_timeout($fp, 3); |
258 | 260 | fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n"); |
259 | - $replacement = mb_convert_encoding(file_get_contents($target),"UTF-8","auto"); | |
260 | - $stat = socket_get_status($fp); | |
261 | - | |
261 | + $replacement = mb_convert_encoding(file_get_contents($target),"UTF-8","auto"); | |
262 | + $stat = socket_get_status($fp); | |
263 | + | |
262 | 264 | if ($stat["timed_out"]) { |
263 | 265 | |
264 | 266 | throw new Exception('タイムアウトしました。'); |
@@ -267,77 +269,77 @@ | ||
267 | 269 | fclose($fp); |
268 | 270 | |
269 | 271 | }catch (Exception $e) { |
270 | - | |
272 | + | |
271 | 273 | $errstr = mb_convert_encoding($errstr,"UTF-8","auto"); |
272 | 274 | echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n"; |
273 | 275 | } |
274 | 276 | |
275 | 277 | break; |
276 | - | |
278 | + | |
277 | 279 | case('query'): |
278 | 280 | |
279 | - $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); | |
280 | - $querys = explode("&",$enc); | |
281 | - $enc = ""; | |
281 | + $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); | |
282 | + $querys = explode("&",$enc); | |
283 | + $enc = ""; | |
284 | + | |
285 | + foreach($querys as $query){ | |
286 | + | |
287 | + preg_match("/([^=]+)(=)(.+)/", $query, $hit); | |
288 | + | |
289 | + if($hit){ | |
290 | + $enc .= '&'.urlencode($hit[1]).$hit[2].urlencode($hit[3]); | |
291 | + } | |
292 | + | |
293 | + } | |
282 | 294 | |
283 | - foreach($querys as $query){ | |
295 | + $enc = str_replace("\n","",$enc); | |
296 | + $no_enc = ""; | |
297 | + $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']); | |
284 | 298 | |
285 | - preg_match("/([^=]+)(=)(.+)/", $query, $hit); | |
286 | - | |
287 | - if($hit){ | |
288 | - $enc .= '&'.urlencode($hit[1]).$hit[2].urlencode($hit[3]); | |
289 | - } | |
290 | - | |
291 | - } | |
292 | - | |
293 | - $enc = str_replace("\n","",$enc); | |
294 | - $no_enc = ""; | |
295 | - $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']); | |
296 | - | |
297 | 299 | break; |
298 | 300 | |
299 | 301 | case('contents_rebuild'): |
300 | 302 | |
301 | - $enc = urlencode($enc); | |
303 | + $enc = urlencode($enc); | |
302 | 304 | $replacement = mb_convert_encoding($val['response'],"UTF-8","auto"); |
303 | - $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['url']); | |
305 | + $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['url']); | |
304 | 306 | |
305 | - $host = parse_url($target); | |
306 | - $host = $host['host']; | |
307 | - | |
307 | + $host = parse_url($target); | |
308 | + $host = $host['host']; | |
309 | + | |
308 | 310 | try{ |
309 | 311 | |
310 | 312 | if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){ |
311 | - | |
313 | + | |
312 | 314 | throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。'); |
313 | 315 | } |
314 | - | |
316 | + | |
315 | 317 | socket_set_timeout($fp, 3); |
316 | 318 | fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n"); |
317 | 319 | |
318 | - $replacement = mb_convert_encoding(@file_get_contents($target),"UTF-8","auto"); | |
319 | - $function_name = $val['function']; | |
320 | - $replacement = $function_name($replacement); | |
320 | + $replacement = mb_convert_encoding(@file_get_contents($target),"UTF-8","auto"); | |
321 | + $function_name = $val['function']; | |
322 | + $replacement = $function_name($replacement); | |
321 | 323 | |
322 | 324 | $stat = socket_get_status($fp); |
325 | + | |
326 | + if ($stat["timed_out"]) { | |
327 | + | |
328 | + throw new Exception('タイムアウトしました。'); | |
329 | + } | |
323 | 330 | |
324 | - if ($stat["timed_out"]) { | |
325 | - | |
326 | - throw new Exception('タイムアウトしました。'); | |
327 | - } | |
328 | - | |
329 | 331 | fclose($fp); |
330 | 332 | |
331 | 333 | |
332 | 334 | }catch (Exception $e) { |
333 | - | |
334 | - $errstr = mb_convert_encoding($errstr,"UTF-8","auto"); | |
335 | + | |
336 | + $errstr = mb_convert_encoding($errstr,"UTF-8","auto"); | |
335 | 337 | echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n"; |
336 | 338 | } |
337 | 339 | break; |
338 | 340 | |
339 | 341 | } |
340 | - | |
342 | + | |
341 | 343 | save_cache($matches[$key][0],$replacement); |
342 | 344 | |
343 | 345 | $text = str_replace($matches[$key][0],$replacement,$text)."\n"; |
@@ -360,16 +362,16 @@ | ||
360 | 362 | } |
361 | 363 | |
362 | 364 | function text2html(){ |
363 | - | |
365 | + | |
364 | 366 | global $benchmark; |
365 | 367 | global $source; |
366 | - global $content_name; | |
367 | - | |
368 | + global $content_name; | |
369 | + | |
368 | 370 | $pear_file = ""; |
369 | 371 | $timer = false; |
370 | - $buffer = $this->document; | |
372 | + $buffer = $this->document; | |
371 | 373 | $output_enc = "UTF-8"; |
372 | - | |
374 | + | |
373 | 375 | if(isset($benchmark) and $benchmark == true){ |
374 | 376 | include_once ("Benchmark/Timer.php"); |
375 | 377 | $timer = true; |
@@ -388,7 +390,7 @@ | ||
388 | 390 | if($timer){ $oTimer->setMarker( 'text2html_table' );} |
389 | 391 | //blockquote |
390 | 392 | $buffer = $this->text2html_code($buffer,"\n","pre",'code:','code','','class="source"','souce'); |
391 | - | |
393 | + | |
392 | 394 | if($timer){ $oTimer->setMarker( 'text2html_code' );} |
393 | 395 | //heading |
394 | 396 | $buffer = $this->text2html_element($buffer,"\n","h6",'\*\*\*\*\*','a','', 'href="#TOP"','h6'); |
@@ -423,7 +425,7 @@ | ||
423 | 425 | asort($this->header_info); |
424 | 426 | $this->midasilist = "<a name=\"TOP\" id=\"TOP\" >head line</a>\n"; |
425 | 427 | $kihou = ""; |
426 | - | |
428 | + | |
427 | 429 | foreach($this->header_info as $key=>$link){ |
428 | 430 | |
429 | 431 | $kihou = str_repeat ('+', $link[1]-1); |
@@ -443,17 +445,17 @@ | ||
443 | 445 | break; |
444 | 446 | |
445 | 447 | case(count($end) > count($start)): |
446 | - //閉じタグが多い | |
447 | - $rep = $rep; | |
448 | - $rep = str_repeat("<\/ol><\/li>",$rep + 1); | |
449 | - $this->midasilist = preg_replace("/$rep<\/ol>$/m","</ol>",$this->midasilist); | |
448 | + //閉じタグが多い | |
449 | + $rep = $rep; | |
450 | + $rep = str_repeat("<\/ol><\/li>",$rep + 1); | |
451 | + $this->midasilist = preg_replace("/$rep<\/ol>$/m","</ol>",$this->midasilist); | |
450 | 452 | |
451 | 453 | break; |
452 | 454 | |
453 | 455 | case(count($end) < count($start)): |
454 | - //閉じタグが少ない | |
455 | - $rep = str_repeat('</ol></li>',abs($rep)-1); | |
456 | - $this->midasilist = preg_replace("/<\/ol>$/m","",$this->midasilist).$rep."</ol>"; | |
456 | + //閉じタグが少ない | |
457 | + $rep = str_repeat('</ol></li>',abs($rep)-1); | |
458 | + $this->midasilist = preg_replace("/<\/ol>$/m","",$this->midasilist).$rep."</ol>"; | |
457 | 459 | |
458 | 460 | break; |
459 | 461 | } |
@@ -475,7 +477,7 @@ | ||
475 | 477 | |
476 | 478 | $buffer = $this->keyword_change($buffer,"\n"); |
477 | 479 | if($timer){$oTimer->setMarker( 'keyword_change' );} |
478 | - | |
480 | + | |
479 | 481 | $buffer = $this->read_php($buffer,"\n"); |
480 | 482 | if($timer){$oTimer->setMarker( 'read_php' );} |
481 | 483 |
@@ -520,7 +522,7 @@ | ||
520 | 522 | |
521 | 523 | $buffer = $this->clear_both($buffer,"\n"); |
522 | 524 | if($timer){$oTimer->setMarker( 'clear_both' );} |
523 | - | |
525 | + | |
524 | 526 | $buffer = $this->get_querys($buffer,"\n"); |
525 | 527 | if($timer){$oTimer->setMarker( 'get_querys' );} |
526 | 528 |
@@ -529,7 +531,7 @@ | ||
529 | 531 | $buffer = $this->text2html_list($buffer,"\n","ul",'※','li','style="font:size:70%;color:#66f;"',"style=\"list-style-type:none;\"","caution"); |
530 | 532 | if($timer){$oTimer->setMarker( 'list' );} |
531 | 533 | |
532 | - //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote'); | |
534 | + //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote'); | |
533 | 535 | //入れ子可 |
534 | 536 | $buffer = $this->text2html_list($buffer,"\n","blockquote",'>','p','','','quote'); |
535 | 537 | if($timer){$oTimer->setMarker( 'list_blockquote' );} |
@@ -544,7 +546,7 @@ | ||
544 | 546 | if($timer){$oTimer->setMarker( 'result_encoding' );} |
545 | 547 | |
546 | 548 | if(isset($source) and $source == true){ |
547 | - | |
549 | + | |
548 | 550 | $source = $this->my_wordwrap($text); |
549 | 551 | $source = str_replace("/",'/',$source); |
550 | 552 |
@@ -551,7 +553,7 @@ | ||
551 | 553 | $this->source = '<div class="source_view">'. |
552 | 554 | $this->style_set($source)."\n</div>"; |
553 | 555 | }else{ |
554 | - | |
556 | + | |
555 | 557 | $this->source = ""; |
556 | 558 | } |
557 | 559 | if($timer){$oTimer->setMarker( 'create_source' );} |
@@ -571,17 +573,17 @@ | ||
571 | 573 | |
572 | 574 | function change_word($text){ |
573 | 575 | |
574 | - if(!defined('TEXTTOHTML_CHANGE_TXT')){return $text;} | |
575 | - $file = TEXTTOHTML_CHANGE_TXT; | |
576 | + if(!defined('TEXTTOHTML_CHANGE_TXT')){return $text;} | |
577 | + $file = TEXTTOHTML_CHANGE_TXT; | |
576 | 578 | |
577 | 579 | if(file_exists($file)){ |
578 | - | |
580 | + | |
579 | 581 | $chenge_words = file($file); |
580 | 582 | |
581 | 583 | foreach($chenge_words as $chenge_word){ |
584 | + | |
585 | + $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto"); | |
582 | 586 | |
583 | - $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto"); | |
584 | - | |
585 | 587 | if(strstr($chenge_word,"#")){ |
586 | 588 | list($before, $after) = explode("#", $chenge_word); |
587 | 589 | $text = str_replace($before , trim($after), $text); |
@@ -590,7 +592,7 @@ | ||
590 | 592 | |
591 | 593 | return $text; |
592 | 594 | }else{ |
593 | - | |
595 | + | |
594 | 596 | return $text; |
595 | 597 | } |
596 | 598 |
@@ -637,7 +639,7 @@ | ||
637 | 639 | $line = $line."\n"; |
638 | 640 | if($current_flag = preg_match("/^([$wm]+)(.+)/u",$line,$current)){ |
639 | 641 | |
640 | - $marker_length = @strlen($current[1]); | |
642 | + $marker_length = @strlen($current[1]); | |
641 | 643 | |
642 | 644 | |
643 | 645 | //リスト変換のオンオフ判定 |
@@ -907,12 +909,12 @@ | ||
907 | 909 | $description = $description.$content_name; |
908 | 910 | } |
909 | 911 | |
910 | - $lines = explode($separator,$document); | |
911 | - $start = true; | |
912 | - $this->content_no = 1; | |
913 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
914 | - $end_tag = ''; | |
915 | - $result = ""; | |
912 | + $lines = explode($separator,$document); | |
913 | + $start = true; | |
914 | + $this->content_no = 1; | |
915 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
916 | + $end_tag = ''; | |
917 | + $result = ""; | |
916 | 918 | |
917 | 919 | foreach($lines as $list){ |
918 | 920 |
@@ -922,30 +924,30 @@ | ||
922 | 924 | |
923 | 925 | if(!empty($content)){ |
924 | 926 | |
925 | - $start_content = "<$content>"; | |
926 | - $end_content = "</$content>\n"; | |
927 | + $start_content = "<$content>"; | |
928 | + $end_content = "</$content>\n"; | |
927 | 929 | }else{ |
928 | - | |
929 | - $start_content = ""; | |
930 | - $end_content = ""; | |
930 | + | |
931 | + $start_content = ""; | |
932 | + $end_content = ""; | |
931 | 933 | } |
932 | 934 | |
933 | 935 | $res = $this->text2html_list($regs[2],$this->separator,$this->element,$this->wm,$this->content,$this->attr,$this->content_attr,$this->description); |
934 | 936 | |
935 | - $list = str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($res)).$end_content,$list); | |
936 | - $start_tag = ""; | |
937 | - $end_tag = "</{$element}>"; | |
937 | + $list = str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($res)).$end_content,$list); | |
938 | + $start_tag = ""; | |
939 | + $end_tag = "</{$element}>"; | |
938 | 940 | |
939 | 941 | }elseif(!empty($end_tag)){ |
940 | 942 | |
941 | - $list = $end_tag."\n".$list; | |
943 | + $list = $end_tag."\n".$list; | |
942 | 944 | $this->content_no++; |
943 | - $end_tag = ''; | |
944 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
945 | + $end_tag = ''; | |
946 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
945 | 947 | }else{ |
948 | + | |
949 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
946 | 950 | |
947 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
948 | - | |
949 | 951 | } |
950 | 952 | |
951 | 953 | $result .= $list; |
@@ -960,36 +962,36 @@ | ||
960 | 962 | $element = $this->element; |
961 | 963 | $wm = $this->wm; |
962 | 964 | $content = $this->content; |
963 | - $start = true; | |
964 | - $lines = explode($separator,$document); | |
965 | - $end_tag = ""; | |
966 | - $result = ""; | |
967 | - $class = ""; | |
965 | + $start = true; | |
966 | + $lines = explode($separator,$document); | |
967 | + $end_tag = ""; | |
968 | + $result = ""; | |
969 | + $class = ""; | |
968 | 970 | |
969 | - foreach($lines as $key=>$list){ | |
971 | + foreach($lines as $key=>$list){ | |
970 | 972 | |
971 | - $list = $list. "\n"; | |
973 | + $list = $list. "\n"; | |
972 | 974 | |
973 | 975 | if(ereg("(^$wm{1})(.+)",$list,$regs)){ |
974 | 976 | |
975 | - if($start == false){$start_tag = "";}else{$start_tag = "<$element>";} | |
977 | + if($start == false){$start_tag = "";}else{$start_tag = "<$element>";} | |
978 | + | |
979 | + if(!ereg("(^$wm{1})(.+)",$lines[$key+1])){$end_tag= "</$element>";}else{$end_tag= "";} | |
980 | + | |
981 | + if(!empty($content)){ | |
982 | + | |
983 | + $start_content = "<$content>"; | |
984 | + $end_content = "</$content>"; | |
985 | + }else{ | |
986 | + | |
987 | + $start_content = ""; | |
988 | + $end_content = ""; | |
989 | + } | |
976 | 990 | |
977 | - if(!ereg("(^$wm{1})(.+)",$lines[$key+1])){$end_tag= "</$element>";}else{$end_tag= "";} | |
978 | - | |
979 | - if(!empty($content)){ | |
980 | - | |
981 | - $start_content = "<$content>"; | |
982 | - $end_content = "</$content>"; | |
983 | - }else{ | |
984 | - | |
985 | - $start_content = ""; | |
986 | - $end_content = ""; | |
987 | - } | |
988 | - | |
989 | 991 | $list= str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($regs[2]))."\n".$end_content,$list); |
990 | 992 | |
991 | 993 | $start = false; |
992 | - | |
994 | + | |
993 | 995 | }elseif(!empty($end_tag)){ |
994 | 996 | |
995 | 997 | $list = $end_tag. "\n".$list; |
@@ -996,9 +998,9 @@ | ||
996 | 998 | } |
997 | 999 | $result .= $list; |
998 | 1000 | |
999 | - } | |
1001 | + } | |
1000 | 1002 | |
1001 | - return $this->tag_clear($result); | |
1003 | + return $this->tag_clear($result); | |
1002 | 1004 | } |
1003 | 1005 | |
1004 | 1006 | function text2html_code($document = "", $separator = "\n",$element = "pre",$wm = 'code:',$content = 'code',$attr = '',$content_attr = '',$description = ''){ |
@@ -1010,21 +1012,21 @@ | ||
1010 | 1012 | global $content_name; |
1011 | 1013 | |
1012 | 1014 | if(!empty($content_name) and !empty($description)){ |
1013 | - $description = $description.'-'.$content_name; | |
1015 | + $description = $description.'-'.$content_name; | |
1014 | 1016 | }else{ |
1015 | - $description = $description.$content_name; | |
1017 | + $description = $description.$content_name; | |
1016 | 1018 | } |
1017 | 1019 | |
1018 | - $i = 0; | |
1019 | - $lines = explode($separator,$document); | |
1020 | - $start = true; | |
1020 | + $i = 0; | |
1021 | + $lines = explode($separator,$document); | |
1022 | + $start = true; | |
1021 | 1023 | $this->content_no = 1; |
1022 | - $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1023 | - $end_tag = ''; | |
1024 | - $result = ""; | |
1024 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1025 | + $end_tag = ''; | |
1026 | + $result = ""; | |
1025 | 1027 | |
1026 | 1028 | foreach($lines as $list){ |
1027 | - | |
1029 | + | |
1028 | 1030 | $list = $list. "\n"; |
1029 | 1031 | |
1030 | 1032 | if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){ |
@@ -1038,26 +1040,26 @@ | ||
1038 | 1040 | $end_content = "\n"; |
1039 | 1041 | } |
1040 | 1042 | |
1041 | - $doc = $regs[2]; | |
1042 | - $doc = $this->my_wordwrap($doc); | |
1043 | - $doc = htmlspecialchars($doc); | |
1044 | - $doc = str_replace(array('/',"\t",'$','<'),array("/"," ",'$','&#lt'),$doc); | |
1045 | - $doc = str_replace("\n","</code><code>",$doc);//ワードラップは、改行だけ埋め込むので、タグを補充 | |
1046 | - $list = str_replace($regs[0],$start_tag.$start_content.trim($doc).$end_content,$list); | |
1047 | - $start_tag = ""; | |
1048 | - $end_tag = "</{$element}>"; | |
1043 | + $doc = $regs[2]; | |
1044 | + $doc = $this->my_wordwrap($doc); | |
1045 | + $doc = htmlspecialchars($doc); | |
1046 | + $doc = str_replace(array('/',"\t",'$','<'),array("/"," ",'$','&#lt'),$doc); | |
1047 | + $doc = str_replace("\n","</code><code>",$doc);//ワードラップは、改行だけ埋め込むので、タグを補充 | |
1048 | + $list = str_replace($regs[0],$start_tag.$start_content.trim($doc).$end_content,$list); | |
1049 | + $start_tag = ""; | |
1050 | + $end_tag = "</{$element}>"; | |
1049 | 1051 | |
1050 | 1052 | }elseif(!empty($end_tag)){ |
1051 | - | |
1052 | - $list = $end_tag."\n".$list; | |
1053 | + | |
1054 | + $list = $end_tag."\n".$list; | |
1053 | 1055 | $this->content_no++; |
1054 | - $end_tag = ''; | |
1055 | - $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1056 | - $i = 0; | |
1056 | + $end_tag = ''; | |
1057 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1058 | + $i = 0; | |
1057 | 1059 | }else{ |
1058 | - | |
1059 | - $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1060 | - $i =0; | |
1060 | + | |
1061 | + $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">"; | |
1062 | + $i =0; | |
1061 | 1063 | } |
1062 | 1064 | |
1063 | 1065 | $result .= $list; |
@@ -1086,19 +1088,19 @@ | ||
1086 | 1088 | $description = $description.$content_name; |
1087 | 1089 | } |
1088 | 1090 | |
1089 | - $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1090 | - $lines = explode($separator,$document); | |
1091 | - $group = "<colgroup><col /></colgroup>"; | |
1091 | + $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1092 | + $lines = explode($separator,$document); | |
1093 | + $group = "<colgroup><col /></colgroup>"; | |
1092 | 1094 | |
1093 | 1095 | foreach($lines as $key=>$list){ |
1094 | 1096 | |
1095 | - $list = $list. $separator; | |
1096 | - $write_group = false; | |
1097 | + $list = $list. $separator; | |
1098 | + $write_group = false; | |
1097 | 1099 | |
1098 | 1100 | if(ereg("(^$wm{1})(.+)",$list,$regs)){ |
1099 | 1101 | |
1100 | 1102 | if(preg_match("/({$wm}summary:)(.+)/um",$list,$match)){ |
1101 | - | |
1103 | + | |
1102 | 1104 | if($end_tag){ |
1103 | 1105 | |
1104 | 1106 | $start_tag = "</table>\n<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">"; |
@@ -1108,9 +1110,9 @@ | ||
1108 | 1110 | $start_tag = "<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">"; |
1109 | 1111 | } |
1110 | 1112 | |
1111 | - $write_group = true; | |
1112 | - unset($regs[2]); | |
1113 | - $list = ""; | |
1113 | + $write_group = true; | |
1114 | + unset($regs[2]); | |
1115 | + $list = ""; | |
1114 | 1116 | |
1115 | 1117 | }else{ |
1116 | 1118 |
@@ -1119,20 +1121,20 @@ | ||
1119 | 1121 | if(isset($regs[2])){ |
1120 | 1122 | |
1121 | 1123 | $fields = explode('|',$regs[2]); |
1122 | - $col_no =1; | |
1124 | + $col_no =1; | |
1123 | 1125 | foreach($fields as $colkey=>$field){ |
1124 | - | |
1126 | + | |
1125 | 1127 | $ht_field .= "<td class=\"col{$col_no} row{$row_no}\" id=\"tbl".$this->content_no."{$col_no}{$row_no}\">$field</td>"; |
1126 | 1128 | $col_no++; |
1127 | 1129 | |
1128 | 1130 | } |
1129 | - | |
1131 | + | |
1130 | 1132 | $row_no++; |
1131 | 1133 | } |
1132 | 1134 | |
1133 | - $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>\n",$list); | |
1134 | - $start_tag = ""; | |
1135 | - $end_tag = "</{$element}>\n"; | |
1135 | + $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>\n",$list); | |
1136 | + $start_tag = ""; | |
1137 | + $end_tag = "</{$element}>\n"; | |
1136 | 1138 | |
1137 | 1139 | if(!isset($lines[$key + 1]) or !ereg("(^$wm{1})(.+)",$lines[$key + 1])){ |
1138 | 1140 |
@@ -1141,22 +1143,22 @@ | ||
1141 | 1143 | } |
1142 | 1144 | } |
1143 | 1145 | }elseif($end_tag){ |
1146 | + | |
1147 | + $list = $end_tag."\n".$list; | |
1148 | + $row_no = 1; | |
1144 | 1149 | |
1145 | - $list = $end_tag."\n".$list; | |
1146 | - $row_no = 1; | |
1147 | - | |
1148 | 1150 | $this->content_no++; |
1149 | 1151 | |
1150 | - $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1151 | - $end_tag = false; | |
1152 | + $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; | |
1153 | + $end_tag = false; | |
1152 | 1154 | }else{ |
1153 | - | |
1155 | + | |
1154 | 1156 | $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">"; |
1155 | 1157 | } |
1156 | 1158 | |
1157 | 1159 | $result .= $list; |
1158 | 1160 | } |
1159 | - return $this->tag_clear($result); | |
1161 | + return $this->tag_clear($result); | |
1160 | 1162 | } |
1161 | 1163 | |
1162 | 1164 | function text2html_element($document, $separator = "\n",$element = "h2",$wm = '*',$content = 'span',$attr = '',$content_attr = '',$description = ''){ |
@@ -1164,16 +1166,16 @@ | ||
1164 | 1166 | global $content_name; |
1165 | 1167 | |
1166 | 1168 | if(!empty($content_name) and !empty($description)){ |
1167 | - $description = $description.'-'.$content_name; | |
1169 | + $description = $description.'-'.$content_name; | |
1168 | 1170 | }else{ |
1169 | - $description = $description.$content_name; | |
1171 | + $description = $description.$content_name; | |
1170 | 1172 | } |
1171 | 1173 | |
1172 | 1174 | $lines = explode($separator,$document); |
1173 | - $start = true; | |
1174 | - $end_tag = ''; | |
1175 | - $result = ""; | |
1176 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1175 | + $start = true; | |
1176 | + $end_tag = ''; | |
1177 | + $result = ""; | |
1178 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1177 | 1179 | $this->content_no = 1; |
1178 | 1180 | |
1179 | 1181 | foreach($lines as $key => $list){ |
@@ -1181,43 +1183,43 @@ | ||
1181 | 1183 | $list = $list. "\n"; |
1182 | 1184 | |
1183 | 1185 | if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){ |
1184 | - | |
1186 | + | |
1185 | 1187 | if(!empty($content)){ |
1186 | - | |
1188 | + | |
1187 | 1189 | $content_start = "<$content $content_attr >"; |
1188 | 1190 | $content_end = "</$content>"; |
1189 | 1191 | }else{ |
1190 | - | |
1192 | + | |
1191 | 1193 | $content_start = ""; |
1192 | 1194 | $content_end = ""; |
1193 | 1195 | } |
1196 | + | |
1197 | + $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list); | |
1198 | + $start_tag = ""; | |
1199 | + $end_tag = "</{$element}>\n"; | |
1194 | 1200 | |
1195 | - $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list); | |
1196 | - $start_tag = ""; | |
1197 | - $end_tag = "</{$element}>\n"; | |
1198 | - | |
1199 | 1201 | //見出しリスト |
1200 | 1202 | |
1201 | - if(ereg("h([1-6])",$element,$match)){ | |
1202 | - | |
1203 | - $list = str_replace("\n","",$list); | |
1203 | + if(ereg("h([1-6])",$element,$match)){ | |
1204 | + | |
1205 | + $list = str_replace("\n","",$list); | |
1204 | 1206 | array_push($this->header_info,array($key,trim($match[1]),"$element-$description-".$this->content_no,$regs[2])); |
1205 | 1207 | } |
1206 | 1208 | |
1207 | 1209 | }elseif(!empty($end_tag)){ |
1208 | - | |
1209 | - $list = $end_tag."\n".$list; | |
1210 | + | |
1211 | + $list = $end_tag."\n".$list; | |
1210 | 1212 | $this->content_no++; |
1211 | - $end_tag = ''; | |
1212 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1213 | + $end_tag = ''; | |
1214 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1213 | 1215 | }else{ |
1214 | - | |
1215 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1216 | + | |
1217 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >"; | |
1216 | 1218 | } |
1217 | - $result .= $list; | |
1219 | + $result .= $list; | |
1218 | 1220 | } |
1219 | 1221 | |
1220 | - return $this->tag_clear($result); | |
1222 | + return $this->tag_clear($result); | |
1221 | 1223 | } |
1222 | 1224 | |
1223 | 1225 | function paragraf($document, $separator = "\n\n",$element = "p",$wm = '',$content = '',$attr = '',$content_attr = '',$description = 'paragraph'){ |
@@ -1234,43 +1236,43 @@ | ||
1234 | 1236 | |
1235 | 1237 | foreach($checks as $val){ |
1236 | 1238 | |
1237 | - $check[] = "<$val"; | |
1238 | - $check[] = "$val>"; | |
1239 | - $check[] = "</$val"; | |
1239 | + $check[] = "<$val"; | |
1240 | + $check[] = "$val>"; | |
1241 | + $check[] = "</$val"; | |
1240 | 1242 | |
1241 | - $replace[] = "\n\n<$val"; | |
1242 | - $replace[] = "$val>$separator"; | |
1243 | - $replace[] = "$separator</$val"; | |
1243 | + $replace[] = "\n\n<$val"; | |
1244 | + $replace[] = "$val>$separator"; | |
1245 | + $replace[] = "$separator</$val"; | |
1244 | 1246 | } |
1245 | 1247 | |
1246 | 1248 | |
1247 | - $document = str_replace($check,$replace,$document); | |
1248 | - $document = $this->tag_clear($document); | |
1249 | - $document = ereg_replace("(\n{1})","\n\n",$document); | |
1250 | - $lines = explode($separator,$document); | |
1251 | - $start = true; | |
1252 | - $end_tag = ''; | |
1253 | - $result = ""; | |
1254 | - $this->content_no = 1; | |
1255 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1256 | - //$wm = "[^(\*|+|<|\=|\n$|\s|code:| )]"; | |
1257 | - $blocks = true;//pをコンテンツに出来ないタグ内での変換を禁止 | |
1258 | - $wm = "[^(\*|\+|\=|\n$|\s| |\-|<)]"; | |
1259 | - $tags_block = "(dl|ol|ul|address|blockquote|form|fieldset|table|style|tr|p|code)"; | |
1260 | - $cdata_zone = false; | |
1249 | + $document = str_replace($check,$replace,$document); | |
1250 | + $document = $this->tag_clear($document); | |
1251 | + $document = ereg_replace("(\n{1})","\n\n",$document); | |
1252 | + $lines = explode($separator,$document); | |
1253 | + $start = true; | |
1254 | + $end_tag = ''; | |
1255 | + $result = ""; | |
1256 | + $this->content_no = 1; | |
1257 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1258 | + //$wm = "[^(\*|+|<|\=|\n$|\s|code:| )]"; | |
1259 | + $blocks = true;//pをコンテンツに出来ないタグ内での変換を禁止 | |
1260 | + $wm = "[^(\*|\+|\=|\n$|\s| |\-|<)]"; | |
1261 | + $tags_block = "(dl|ol|ul|address|blockquote|form|fieldset|table|style|tr|p|code)"; | |
1262 | + $cdata_zone = false; | |
1261 | 1263 | |
1262 | 1264 | foreach($lines as $key => $list){ |
1263 | - | |
1265 | + | |
1264 | 1266 | $list = $list."\n\n"; |
1265 | 1267 | |
1266 | - if(preg_match("/(<!--|<!\[CDATA\[|<script|<style|<$tags_block)/iu",$list) and !preg_match("/(!--|\]\]>|\/script|\/style|<\/$tags_block)\s?\/?>/iu",$list)){ | |
1267 | - $cdata_zone = true; | |
1268 | - //テーブル間にタグを適用できなくなる | |
1269 | - } | |
1268 | + if(preg_match("/(<!--|<!\[CDATA\[|<script|<style|<$tags_block)/iu",$list) and !preg_match("/(!--|\]\]>|\/script|\/style|<\/$tags_block)\s?\/?>/iu",$list)){ | |
1269 | + $cdata_zone = true; | |
1270 | + //テーブル間にタグを適用できなくなる | |
1271 | + } | |
1270 | 1272 | |
1271 | - if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){ | |
1273 | + if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){ | |
1272 | 1274 | |
1273 | - $content_start = ""; | |
1275 | + $content_start = ""; | |
1274 | 1276 | |
1275 | 1277 | if(isset($lines[$key + 1]) and $lines[$key + 1] == true){ |
1276 | 1278 |
@@ -1280,19 +1282,19 @@ | ||
1280 | 1282 | $content_end = ""; |
1281 | 1283 | } |
1282 | 1284 | |
1283 | - $list = str_replace($regs[0],$start_tag.$content_start.trim($regs[1]).$content_end,$list); | |
1284 | - $start_tag = ""; | |
1285 | - $end_tag = "\n</{$element}>\n\n"; | |
1286 | - $paragraph_div = '¶'; | |
1285 | + $list = str_replace($regs[0],$start_tag.$content_start.trim($regs[1]).$content_end,$list); | |
1286 | + $start_tag = ""; | |
1287 | + $end_tag = "\n</{$element}>\n\n"; | |
1288 | + $paragraph_div = '¶'; | |
1289 | + | |
1290 | + if(eregi($paragraph_div,$list)){ | |
1291 | + | |
1292 | + $list = str_replace(array($paragraph_div.$content_end,$paragraph_div),$end_tag, $list); | |
1293 | + $end_tag = ''; | |
1294 | + $this->content_no++; | |
1295 | + $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1296 | + } | |
1287 | 1297 | |
1288 | - if(eregi($paragraph_div,$list)){ | |
1289 | - | |
1290 | - $list = str_replace(array($paragraph_div.$content_end,$paragraph_div),$end_tag, $list); | |
1291 | - $end_tag = ''; | |
1292 | - $this->content_no++; | |
1293 | - $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">"; | |
1294 | - } | |
1295 | - | |
1296 | 1298 | }elseif(!empty($end_tag) ){ |
1297 | 1299 | |
1298 | 1300 | $list = $end_tag."\n".$list; |
@@ -1318,9 +1320,9 @@ | ||
1318 | 1320 | } |
1319 | 1321 | |
1320 | 1322 | function img_copy($buffer){ |
1321 | - | |
1322 | - if(!defined('TEXTTOHTML_IMAGE_DIR_PATH')){return $buffer;} | |
1323 | - | |
1323 | + if(ini_get('allow_url_fopen') !== "1"){return $buffer;} | |
1324 | + if(!defined('TEXTTOHTML_IMAGE_DIR_PATH')){return $buffer;} | |
1325 | + | |
1324 | 1326 | $copy_width = TEXTTOHTML_COPY_IMG_WIDTH; |
1325 | 1327 | |
1326 | 1328 | if(preg_match_all("/(copy>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){ |
@@ -1327,20 +1329,20 @@ | ||
1327 | 1329 | |
1328 | 1330 | foreach($matches as $key=>$match){ |
1329 | 1331 | |
1330 | - $cache = use_cache($matches[$key][0],$buffer); | |
1332 | + $cache = use_cache($matches[$key][0],$buffer); | |
1331 | 1333 | |
1332 | 1334 | if($cache[0]){ |
1333 | 1335 | |
1334 | - $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n"; | |
1336 | + $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n"; | |
1335 | 1337 | }else{ |
1336 | 1338 | clearstatcache(); |
1339 | + | |
1340 | + $copy_target = TEXTTOHTML_IMAGE_DIR_PATH.basename($match[2]); | |
1341 | + $copy_target_url = TEXTTOHTML_IMAGE_DIR_URL.basename($match[2]); | |
1342 | + $quote_comment = "<!--from:".$match[2]."--><a href=\"".$match[2]."\" class=\"quoted\">"; | |
1343 | + $size = getimagesize($match[2]); | |
1344 | + $uri = htmlspecialchars(trim($match[2])); | |
1337 | 1345 | |
1338 | - $copy_target = TEXTTOHTML_IMAGE_DIR_PATH.basename($match[2]); | |
1339 | - $copy_target_url = TEXTTOHTML_IMAGE_DIR_URL.basename($match[2]); | |
1340 | - $quote_comment = "<!--from:".$match[2]."--><a href=\"".$match[2]."\" class=\"quoted\">"; | |
1341 | - $size = getimagesize($match[2]); | |
1342 | - $uri = htmlspecialchars(trim($match[2])); | |
1343 | - | |
1344 | 1346 | if($size[0] > $copy_width){ |
1345 | 1347 | $aspect = @round($size[1]/$size[0],2); |
1346 | 1348 | $height = @round($copy_width * $aspect,0); |
@@ -1348,42 +1350,42 @@ | ||
1348 | 1350 | $copy_width = $size[0]; |
1349 | 1351 | $height = $size[1]; |
1350 | 1352 | } |
1351 | - | |
1353 | + | |
1352 | 1354 | $gdimg = imagecreatetruecolor($copy_width,$height); |
1353 | 1355 | |
1354 | 1356 | if($size[2] == 1) { |
1355 | - | |
1356 | - if( $im = imagecreatefromgif($uri)){ | |
1357 | - imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1358 | - @imagegif($gdimg,$copy_target); | |
1359 | - } | |
1357 | + | |
1358 | + if( $im = imagecreatefromgif($uri)){ | |
1359 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1360 | + @imagegif($gdimg,$copy_target); | |
1361 | + } | |
1360 | 1362 | } |
1361 | - | |
1363 | + | |
1362 | 1364 | if($size[2] == 2 and $size) { |
1363 | - | |
1364 | - if( $im = imagecreatefromjpeg($uri)){ | |
1365 | - imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1366 | - @imagejpeg($gdimg,$copy_target); | |
1367 | - } | |
1365 | + | |
1366 | + if( $im = imagecreatefromjpeg($uri)){ | |
1367 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1368 | + @imagejpeg($gdimg,$copy_target); | |
1369 | + } | |
1368 | 1370 | } |
1369 | 1371 | if($size[2] == 3) { |
1370 | - | |
1371 | - if($im = imagecreatefrompng($uri)){ | |
1372 | - imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1373 | - @imagepng($gdimg,$copy_target); | |
1374 | - } | |
1372 | + | |
1373 | + if($im = imagecreatefrompng($uri)){ | |
1374 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1375 | + @imagepng($gdimg,$copy_target); | |
1376 | + } | |
1375 | 1377 | } |
1376 | 1378 | if($size[2] == 15) { |
1377 | - | |
1378 | - if($im = imagecreatefromwbmp($uri)){ | |
1379 | - imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1380 | - @imagebmp($gdimg,$copy_target); | |
1381 | - } | |
1379 | + | |
1380 | + if($im = imagecreatefromwbmp($uri)){ | |
1381 | + imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]); | |
1382 | + @imagebmp($gdimg,$copy_target); | |
1383 | + } | |
1382 | 1384 | } |
1385 | + | |
1386 | + $buffer= str_replace($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>",$buffer)."\n"; | |
1387 | + | |
1383 | 1388 | |
1384 | - $buffer= str_replace($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>",$buffer)."\n"; | |
1385 | - | |
1386 | - | |
1387 | 1389 | save_cache($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>"); |
1388 | 1390 | } |
1389 | 1391 |
@@ -1395,17 +1397,17 @@ | ||
1395 | 1397 | |
1396 | 1398 | function keyword_change($document){ |
1397 | 1399 | |
1398 | - $keyword_res = array(); | |
1399 | - $change_val_res = array(); | |
1400 | + $keyword_res = array(); | |
1401 | + $change_val_res = array(); | |
1400 | 1402 | |
1401 | 1403 | if(phpversion('domDocument')){ |
1402 | 1404 | |
1403 | - $dom = new domDocument; | |
1404 | - $dom->load(CHANGE_PATTERN_PATH); | |
1405 | - $root = $dom->documentElement; | |
1406 | - $books = $root->childNodes; | |
1407 | - $keyword_res = array(); | |
1408 | - $change_val = array(); | |
1405 | + $dom = new domDocument; | |
1406 | + $dom->load(CHANGE_PATTERN_PATH); | |
1407 | + $root = $dom->documentElement; | |
1408 | + $books = $root->childNodes; | |
1409 | + $keyword_res = array(); | |
1410 | + $change_val = array(); | |
1409 | 1411 | |
1410 | 1412 | foreach ($books as $book) { |
1411 | 1413 |
@@ -1428,8 +1430,8 @@ | ||
1428 | 1430 | |
1429 | 1431 | }else{ |
1430 | 1432 | |
1431 | - $data = file_get_contents(CHANGE_PATTERN_PATH); | |
1432 | - $dls = explode("<dl>",$data); | |
1433 | + $data = file_get_contents(CHANGE_PATTERN_PATH); | |
1434 | + $dls = explode("<dl>",$data); | |
1433 | 1435 | |
1434 | 1436 | foreach($dls as $dl){ |
1435 | 1437 |
@@ -1439,15 +1441,15 @@ | ||
1439 | 1441 | array_push($change_val_res,$change_val[2]); |
1440 | 1442 | } |
1441 | 1443 | |
1442 | - $keyword_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$keyword_res); | |
1443 | - $change_val_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$change_val_res); | |
1444 | - $res = str_replace($keyword_res,$change_val_res,$document); | |
1444 | + $keyword_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$keyword_res); | |
1445 | + $change_val_res = str_replace(array(">","<","&","""),array(">","<",'&','"'),$change_val_res); | |
1446 | + $res = str_replace($keyword_res,$change_val_res,$document); | |
1445 | 1447 | return $res; |
1446 | 1448 | } |
1447 | 1449 | } |
1448 | 1450 | |
1449 | 1451 | |
1450 | - function keyword_change_inline($document, $separator = "\n"){ | |
1452 | + function keyword_change_inline($document, $separator = "\n"){ | |
1451 | 1453 | |
1452 | 1454 | $before_start = "<!--%"; |
1453 | 1455 | $before_end = "%-->"; |
@@ -1467,9 +1469,9 @@ | ||
1467 | 1469 | |
1468 | 1470 | if($record == 0 and ereg("(^$start_tag)([^/]+)($end_tag)",$words,$keyword)){ |
1469 | 1471 | |
1470 | - $change = ""; | |
1471 | - $keyword = $before_start.$keyword[2].$before_end; | |
1472 | - $record = 1; | |
1472 | + $change = ""; | |
1473 | + $keyword = $before_start.$keyword[2].$before_end; | |
1474 | + $record = 1; | |
1473 | 1475 | }elseif($record == 1 and !ereg("(^$start_tag\/)(.+)($end_tag)",$words)){ |
1474 | 1476 | |
1475 | 1477 | $change .= $words . "\n"; |
@@ -1492,7 +1494,7 @@ | ||
1492 | 1494 | $document_result = str_replace($keyword_res,$change_val_res,$document_result); |
1493 | 1495 | $result = str_replace(array("<><>","><"),array("\n",">\n<"),$document_result); |
1494 | 1496 | |
1495 | - return $this->tag_clear($result); | |
1497 | + return $this->tag_clear($result); | |
1496 | 1498 | } |
1497 | 1499 | |
1498 | 1500 |
@@ -1503,17 +1505,17 @@ | ||
1503 | 1505 | if(preg_match_all("/(\[)($tags_inline)(\|)([^\|]+)(\|)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){ |
1504 | 1506 | foreach($matches as $key=>$match){ |
1505 | 1507 | |
1506 | - $element = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1507 | - $attr = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1508 | - $value = mb_convert_encoding($match[7],"UTF-8","auto"); | |
1509 | - $replacement = "<$element $attr>$value</$element>"; | |
1510 | - $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1508 | + $element = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1509 | + $attr = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1510 | + $value = mb_convert_encoding($match[7],"UTF-8","auto"); | |
1511 | + $replacement = "<$element $attr>$value</$element>"; | |
1512 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1511 | 1513 | } |
1512 | - | |
1513 | - $code_hit = true; | |
1514 | + | |
1515 | + $code_hit = true; | |
1514 | 1516 | } |
1515 | - | |
1516 | - return $text; | |
1517 | + | |
1518 | + return $text; | |
1517 | 1519 | } |
1518 | 1520 | |
1519 | 1521 |
@@ -1520,69 +1522,69 @@ | ||
1520 | 1522 | function ruby($text){ |
1521 | 1523 | |
1522 | 1524 | if(preg_match_all("/(ruby>\()([^:]+)(:)([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ |
1523 | - | |
1525 | + | |
1524 | 1526 | foreach($matches as $key=>$match){ |
1525 | 1527 | |
1526 | - $word = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1527 | - $kana = mb_convert_encoding($match[4],"UTF-8","auto"); | |
1528 | - $word = str_replace("\n","",$word); | |
1529 | - $kana = str_replace("\n","",$kana); | |
1530 | - $replacement = "<ruby><rb>$word</rb><rp>(</rp><rt>$kana</rt><rp>)</rp></ruby>"; | |
1531 | - $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1528 | + $word = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1529 | + $kana = mb_convert_encoding($match[4],"UTF-8","auto"); | |
1530 | + $word = str_replace("\n","",$word); | |
1531 | + $kana = str_replace("\n","",$kana); | |
1532 | + $replacement = "<ruby><rb>$word</rb><rp>(</rp><rt>$kana</rt><rp>)</rp></ruby>"; | |
1533 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1532 | 1534 | } |
1533 | 1535 | |
1534 | - $code_hit = true; | |
1536 | + $code_hit = true; | |
1535 | 1537 | } |
1536 | - | |
1537 | - return $text; | |
1538 | + | |
1539 | + return $text; | |
1538 | 1540 | } |
1539 | 1541 | |
1540 | 1542 | |
1541 | 1543 | function trackback($text){ |
1542 | 1544 | |
1543 | - if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;} | |
1545 | + if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;} | |
1544 | 1546 | |
1545 | 1547 | if(preg_match_all("/(trackback>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ |
1546 | - | |
1548 | + | |
1547 | 1549 | foreach($matches as $key=>$match){ |
1550 | + | |
1551 | + $tabindex = $key + 1; | |
1548 | 1552 | |
1549 | - $tabindex = $key + 1; | |
1553 | + switch ($key) { | |
1554 | + case 0: | |
1555 | + $accesskey = "a"; | |
1556 | + break; | |
1557 | + case 1: | |
1558 | + $accesskey = "b"; | |
1559 | + break; | |
1560 | + case 2: | |
1561 | + $accesskey = "c"; | |
1562 | + break; | |
1563 | + case 3: | |
1564 | + $accesskey = "d"; | |
1565 | + break; | |
1566 | + case 4: | |
1567 | + $accesskey = "e"; | |
1568 | + break; | |
1569 | + case 5: | |
1570 | + $accesskey = "f"; | |
1571 | + break; | |
1572 | + default: | |
1573 | + $accesskey = "g"; | |
1574 | + | |
1575 | + } | |
1550 | 1576 | |
1551 | - switch ($key) { | |
1552 | - case 0: | |
1553 | - $accesskey = "a"; | |
1554 | - break; | |
1555 | - case 1: | |
1556 | - $accesskey = "b"; | |
1557 | - break; | |
1558 | - case 2: | |
1559 | - $accesskey = "c"; | |
1560 | - break; | |
1561 | - case 3: | |
1562 | - $accesskey = "d"; | |
1563 | - break; | |
1564 | - case 4: | |
1565 | - $accesskey = "e"; | |
1566 | - break; | |
1567 | - case 5: | |
1568 | - $accesskey = "f"; | |
1569 | - break; | |
1570 | - default: | |
1571 | - $accesskey = "g"; | |
1572 | - | |
1573 | - } | |
1574 | - | |
1575 | - $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1576 | - $enc = urlencode($enc); | |
1577 | - | |
1577 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1578 | + $enc = urlencode($enc); | |
1579 | + | |
1578 | 1580 | $replacement = "<div class=\"trackback\"><span>トラックバック:".$match[2]."</span><br />Track back URL:<input type=\"text\" value=\"".TEXTTOHTML_TRACKBACK_URL. $enc. "\" accesskey=\"$accesskey\" tabindex=\"".$tabindex."\" /><br /><script type=\"text/javascript\" src=\"".TEXTTOHTML_TRACKBACK_URL. $enc. "\"></script>\n</div>\n"; |
1579 | 1581 | |
1580 | - $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1582 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1581 | 1583 | } |
1582 | 1584 | |
1583 | 1585 | $code_hit = true; |
1584 | 1586 | } |
1585 | - return $text; | |
1587 | + return $text; | |
1586 | 1588 | |
1587 | 1589 | } |
1588 | 1590 | /*------------------------------------------------------------------------------+ |
@@ -1603,8 +1605,8 @@ | ||
1603 | 1605 | } |
1604 | 1606 | |
1605 | 1607 | } |
1606 | - | |
1607 | - return $text; | |
1608 | + | |
1609 | + return $text; | |
1608 | 1610 | } |
1609 | 1611 | |
1610 | 1612 |
@@ -1635,8 +1637,8 @@ | ||
1635 | 1637 | $text= str_replace($matches[$key][0],$quote_comment."{$copy_target}?w={$copy_width}h={$height}alt=YouTube </a>",$text)."\n"; |
1636 | 1638 | } |
1637 | 1639 | } |
1638 | - | |
1639 | - return $text; | |
1640 | + | |
1641 | + return $text; | |
1640 | 1642 | } |
1641 | 1643 | /*------------------------------------------------------------------------------+ |
1642 | 1644 | * 文字列から、イメージの作成とコーディング処理 |
@@ -1643,41 +1645,41 @@ | ||
1643 | 1645 | *------------------------------------------------------------------------------*/ |
1644 | 1646 | function txt2img($buffer,$separator = "\n"){ |
1645 | 1647 | |
1646 | - global $default; | |
1648 | + global $default; | |
1649 | + | |
1650 | + if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{ | |
1647 | 1651 | |
1648 | - if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{ | |
1652 | + include(TEXTTOHTML_FONTS_PATH); | |
1653 | + $buffers = explode($separator,$buffer); | |
1654 | + $string = ""; | |
1655 | + | |
1656 | + foreach($buffers as $buffer){ | |
1657 | + | |
1658 | + if(preg_match_all("/(txt2img>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){ | |
1659 | + | |
1660 | + foreach($matches as $key=>$match){ | |
1661 | + | |
1662 | + if(ereg("(:)",$match[2])){ | |
1663 | + list($element,$val_name,$val) =explode(":",$match[2]); | |
1664 | + | |
1665 | + $replacement = $this->convert_image($val,$$val_name,$element); | |
1666 | + }else{ | |
1667 | + $replacement = $this->convert_image($match[2],$default,"p"); | |
1668 | + } | |
1669 | + | |
1670 | + $string .= str_replace($matches[$key][0],$replacement,$buffer); | |
1671 | + } | |
1672 | + | |
1673 | + | |
1674 | + }else{ | |
1675 | + | |
1676 | + $string .= $buffer."\n"; | |
1677 | + } | |
1678 | + } | |
1649 | 1679 | |
1650 | - include(TEXTTOHTML_FONTS_PATH); | |
1651 | - $buffers = explode($separator,$buffer); | |
1652 | - $string = ""; | |
1653 | - | |
1654 | - foreach($buffers as $buffer){ | |
1655 | - | |
1656 | - if(preg_match_all("/(txt2img>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){ | |
1657 | - | |
1658 | - foreach($matches as $key=>$match){ | |
1659 | - | |
1660 | - if(ereg("(:)",$match[2])){ | |
1661 | - list($element,$val_name,$val) =explode(":",$match[2]); | |
1662 | - | |
1663 | - $replacement = $this->convert_image($val,$$val_name,$element); | |
1664 | - }else{ | |
1665 | - $replacement = $this->convert_image($match[2],$default,"p"); | |
1666 | - } | |
1667 | - | |
1668 | - $string .= str_replace($matches[$key][0],$replacement,$buffer); | |
1669 | - } | |
1670 | - | |
1671 | - | |
1672 | - }else{ | |
1673 | - | |
1674 | - $string .= $buffer."\n"; | |
1675 | - } | |
1676 | - } | |
1677 | - | |
1678 | 1680 | return $string; |
1679 | 1681 | |
1680 | - } | |
1682 | + } | |
1681 | 1683 | } |
1682 | 1684 | |
1683 | 1685 | ///////////////////////////////////////////////////////////// |
@@ -1684,16 +1686,16 @@ | ||
1684 | 1686 | |
1685 | 1687 | function convert_image( $string , $gd_set = array("gt200001","13","class=\"text2image\"","0"),$element = "p"){ |
1686 | 1688 | |
1687 | - if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;} | |
1689 | + if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;} | |
1688 | 1690 | |
1689 | - $file_name = md5($string.$gd_set[0].$gd_set[1]); | |
1690 | - $image_file_name = str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1691 | - $image_file_name = TEXTTOHTML_IMAGE_DIR_URL.$image_file_name; | |
1692 | - $image_file_path = TEXTTOHTML_IMAGE_DIR_PATH.str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1693 | - $cache = use_cache($file_name); | |
1691 | + $file_name = md5($string.$gd_set[0].$gd_set[1]); | |
1692 | + $image_file_name = str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1693 | + $image_file_name = TEXTTOHTML_IMAGE_DIR_URL.$image_file_name; | |
1694 | + $image_file_path = TEXTTOHTML_IMAGE_DIR_PATH.str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png'; | |
1695 | + $cache = use_cache($file_name); | |
1694 | 1696 | |
1695 | 1697 | if($cache[0]){ |
1696 | - | |
1698 | + | |
1697 | 1699 | $result= $cache[1]."\n"; |
1698 | 1700 | return $result; |
1699 | 1701 | }else{ |
@@ -1710,41 +1712,41 @@ | ||
1710 | 1712 | |
1711 | 1713 | switch(true){ |
1712 | 1714 | |
1713 | - case($background_img == "0"): //背景画像を使用しない | |
1714 | - | |
1715 | - $timg = imagecreate($fontsize * 2 * $len, $fontsize * 2); | |
1716 | - $background = ImageColorAllocate($timg, 255, 255, 255); | |
1717 | - ImageFill($timg, 0, 0, $background); | |
1718 | - $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1719 | - break; | |
1720 | - | |
1721 | - default://背景画像を使用する。 | |
1722 | - | |
1723 | - $timg = imagecreatefrompng(TEXTTOHTML_FONT_DIR_PATH.$background_img); | |
1724 | - | |
1725 | - $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1726 | - break; | |
1715 | + case($background_img == "0"): //背景画像を使用しない | |
1716 | + | |
1717 | + $timg = imagecreate($fontsize * 2 * $len, $fontsize * 2); | |
1718 | + $background = ImageColorAllocate($timg, 255, 255, 255); | |
1719 | + ImageFill($timg, 0, 0, $background); | |
1720 | + $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1721 | + break; | |
1722 | + | |
1723 | + default://背景画像を使用する。 | |
1724 | + | |
1725 | + $timg = imagecreatefrompng(TEXTTOHTML_FONT_DIR_PATH.$background_img); | |
1726 | + | |
1727 | + $Color = ImageColorAllocate($timg, 0, 0, 0); | |
1728 | + break; | |
1727 | 1729 | } |
1728 | 1730 | |
1729 | 1731 | $vertical_align = $fontsize * 1.5; |
1730 | - $chr = mb_convert_encoding($string,"UTF-8","auto"); | |
1731 | - $box = ImageTTFText($timg, $fontsize, 0, $indent, $vertical_align, $Color, $font, $chr); | |
1732 | - $width = $box[2] + $marginRight; | |
1733 | - $timg_resized = ImageCreate($width, $fontsize * 2); | |
1734 | - | |
1732 | + $chr = mb_convert_encoding($string,"UTF-8","auto"); | |
1733 | + $box = ImageTTFText($timg, $fontsize, 0, $indent, $vertical_align, $Color, $font, $chr); | |
1734 | + $width = $box[2] + $marginRight; | |
1735 | + $timg_resized = ImageCreate($width, $fontsize * 2); | |
1736 | + | |
1735 | 1737 | imagecopy($timg_resized, $timg, 0, 0, 0, 0, $width, $fontsize * 2); |
1736 | 1738 | imagepng($timg_resized,$image_file_path); |
1737 | 1739 | |
1738 | 1740 | if($timg_resized){ |
1739 | 1741 | |
1740 | - $result = "<{$element} $attribute style=\"height:{$height}px;width:{$width}px;background:url($image_file_name);background-repeat:no-repeat;\">\n\t<span style=\"display:none;font-size:{$fontsize}px;\">$string</span></{$element}>\n"; | |
1742 | + $result = "<{$element} $attribute style=\"height:{$height}px;width:{$width}px;background:url($image_file_name);background-repeat:no-repeat;\">\n\t<span style=\"display:none;font-size:{$fontsize}px;\">$string</span></{$element}>\n"; | |
1741 | 1743 | |
1742 | - save_cache($file_name,$result); | |
1744 | + save_cache($file_name,$result); | |
1743 | 1745 | |
1744 | - return $result; | |
1746 | + return $result; | |
1745 | 1747 | }else{ |
1746 | - | |
1747 | - return $string; | |
1748 | + | |
1749 | + return $string; | |
1748 | 1750 | } |
1749 | 1751 | |
1750 | 1752 | } |
@@ -1798,16 +1800,16 @@ | ||
1798 | 1800 | function encode_query($text){ |
1799 | 1801 | |
1800 | 1802 | if(preg_match_all("/(query>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ |
1801 | - | |
1803 | + | |
1802 | 1804 | foreach($matches as $key=>$match){ |
1803 | 1805 | |
1804 | - $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1805 | - $enc = urlencode($enc); | |
1806 | - $text= str_replace($matches[$key][0],$enc,$text)."\n"; | |
1806 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1807 | + $enc = urlencode($enc); | |
1808 | + $text= str_replace($matches[$key][0],$enc,$text)."\n"; | |
1807 | 1809 | } |
1808 | 1810 | |
1809 | 1811 | } |
1810 | - return $text; | |
1812 | + return $text; | |
1811 | 1813 | } |
1812 | 1814 | |
1813 | 1815 | /*------------------------------------------------------------------------------+ |
@@ -1816,7 +1818,7 @@ | ||
1816 | 1818 | |
1817 | 1819 | function image($text){ |
1818 | 1820 | |
1819 | - $allow_img_filetype = "(\.gif|\.png|\.jpe?g)"; | |
1821 | + $allow_img_filetype = "(\.gif|\.png|\.jpe?g)"; | |
1820 | 1822 | |
1821 | 1823 | $text = eregi_replace("(https?://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)($allow_img_filetype)(\?w=)([0-9]{1,3})(h=)([0-9]{1,3})(alt=)?([^([:space:]|<)]+)?", "<img src=\"\\1\\2\" width=\"\\5\" height=\"\\7\" class=\"picture\" alt=\"\\9\" />",$text); |
1822 | 1824 |
@@ -1830,65 +1832,70 @@ | ||
1830 | 1832 | if(preg_match_all("/(https?)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)(\()(b:|t:|s:)?([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){ |
1831 | 1833 | |
1832 | 1834 | foreach($matches as $key=>$match){ |
1833 | - | |
1835 | + | |
1834 | 1836 | $cache = use_cache($matches[$key][0],$text); |
1837 | + | |
1838 | + if($cache[0]){ | |
1839 | + | |
1840 | + $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
1841 | + }else{ | |
1835 | 1842 | |
1836 | - if($cache[0]){ | |
1843 | + switch($match[4]){ | |
1844 | + case('b:'): | |
1845 | + $attr = '_blank'; | |
1846 | + break; | |
1847 | + case('t:'): | |
1848 | + $attr = '_top'; | |
1849 | + break; | |
1850 | + case('s:'): | |
1851 | + $attr = '_self'; | |
1852 | + break; | |
1853 | + | |
1854 | + default: | |
1855 | + $attr = '_self'; | |
1856 | + | |
1857 | + break; | |
1858 | + } | |
1859 | + | |
1860 | + $attr = "onclick=\"this.target='$attr';\" onkeypress=\"this.target='$attr';\""; | |
1861 | + $link_name = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1862 | + $url = $match[1].$match[2]; | |
1863 | + | |
1864 | + if(trim($link_name) == 'title'){ | |
1865 | + | |
1866 | + $cache = use_cache($matches[$key][0],$link_name); | |
1867 | + | |
1868 | + if(ini_get('allow_url_fopen') == "1"){ | |
1837 | 1869 | |
1838 | - $text = str_replace($matches[$key][0],$cache[1],$text)."\n"; | |
1839 | - }else{ | |
1870 | + try{ | |
1871 | + if(!$data = mb_convert_encoding(file_get_contents($url),"UTF-8","auto")){ | |
1840 | 1872 | |
1841 | - switch($match[4]){ | |
1842 | - case('b:'): | |
1843 | - $attr = '_blank'; | |
1844 | - break; | |
1845 | - case('t:'): | |
1846 | - $attr = '_top'; | |
1847 | - break; | |
1848 | - case('s:'): | |
1849 | - $attr = '_self'; | |
1850 | - break; | |
1873 | + throw new Exception('リンクタイトルを取得できません'); | |
1874 | + } | |
1851 | 1875 | |
1852 | - default: | |
1853 | - $attr = '_self'; | |
1876 | + preg_match( "/<title.*?>(.*?)<\/title>/si", $data, $regs ); | |
1877 | + $linkname = trim(strip_tags($regs[1])); | |
1878 | + $link_name = htmlspecialchars($linkname); | |
1879 | + | |
1880 | + }catch (Exception $e) { | |
1881 | + $link_name = $url; | |
1882 | + echo '例外: ',$url, $e->getMessage(), "\n"; | |
1883 | + } | |
1884 | + }else{ | |
1885 | + $link_name = ""; | |
1886 | + } | |
1887 | + | |
1888 | + if(empty($link_name)){ $link_name = $url;} | |
1889 | + } | |
1890 | + | |
1891 | + $link = "<a href=\"".$url."\" $attr >".$link_name."</a>"; | |
1892 | + $text = str_replace($matches[$key][0],$link,$text)."\n"; | |
1893 | + } | |
1894 | + | |
1895 | + } | |
1896 | + | |
1897 | + } | |
1854 | 1898 | |
1855 | - break; | |
1856 | - } | |
1857 | - | |
1858 | - $attr = "onclick=\"this.target='$attr';\" onkeypress=\"this.target='$attr';\""; | |
1859 | - $link_name = mb_convert_encoding($match[5],"UTF-8","auto"); | |
1860 | - $url = $match[1].$match[2]; | |
1861 | - | |
1862 | - if(trim($link_name) == 'title'){ | |
1863 | - | |
1864 | - $cache = use_cache($matches[$key][0],$link_name); | |
1865 | - | |
1866 | - try{ | |
1867 | - if(!$data = mb_convert_encoding(file_get_contents($url),"UTF-8","auto")){ | |
1868 | - | |
1869 | - throw new Exception('リンクタイトルを取得できません'); | |
1870 | - } | |
1871 | - | |
1872 | - preg_match( "/<title.*?>(.*?)<\/title>/si", $data, $regs ); | |
1873 | - $linkname = trim(strip_tags($regs[1])); | |
1874 | - $link_name = htmlspecialchars($linkname); | |
1875 | - | |
1876 | - }catch (Exception $e) { | |
1877 | - $link_name = $url; | |
1878 | - echo '例外: ',$url, $e->getMessage(), "\n"; | |
1879 | - } | |
1880 | - | |
1881 | - if(empty($link_name)){ $link_name = $url;} | |
1882 | - } | |
1883 | - | |
1884 | - $link = "<a href=\"".$url."\" $attr >".$link_name."</a>"; | |
1885 | - $text = str_replace($matches[$key][0],$link,$text)."\n"; | |
1886 | - } | |
1887 | - | |
1888 | - } | |
1889 | - | |
1890 | - } | |
1891 | - | |
1892 | 1899 | return $text; |
1893 | 1900 | } |
1894 | 1901 |
@@ -1895,8 +1902,8 @@ | ||
1895 | 1902 | |
1896 | 1903 | function name_link($text){ |
1897 | 1904 | |
1898 | - $text = eregi_replace("(link>)(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)", "<a href=\"\\2\\3\" title=\"\\2\\3\">\\2\\3</a>\n", $text); | |
1899 | - $text = mb_ereg_replace("(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)(()([^)]+)())", "<a href=\"\\1\\2\" title=\"\\1\\2\">\\4</a>\n",$text); | |
1905 | + $text = eregi_replace("(link>)(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)", "<a href=\"\\2\\3\" title=\"\\2\\3\">\\2\\3</a>\n", $text); | |
1906 | + $text = mb_ereg_replace("(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)(()([^)]+)())", "<a href=\"\\1\\2\" title=\"\\1\\2\">\\4</a>\n",$text); | |
1900 | 1907 | |
1901 | 1908 | return $text; |
1902 | 1909 | } |
@@ -1916,9 +1923,9 @@ | ||
1916 | 1923 | if(preg_match_all("/(eval>\[)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){ |
1917 | 1924 | foreach($matches as $key=>$match){ |
1918 | 1925 | |
1919 | - $str = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1920 | - eval("\$str = $str;"); | |
1921 | - $text= str_replace($matches[$key][0],$str,$text)."\n"; | |
1926 | + $str = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1927 | + eval("\$str = $str;"); | |
1928 | + $text= str_replace($matches[$key][0],$str,$text)."\n"; | |
1922 | 1929 | } |
1923 | 1930 | |
1924 | 1931 | } |
@@ -1932,6 +1939,8 @@ | ||
1932 | 1939 | |
1933 | 1940 | $str = mb_convert_encoding($match[2],"UTF-8","auto"); |
1934 | 1941 | if(isset($str) and !empty($str)){ |
1942 | + | |
1943 | + if(ini_get('allow_url_fopen') == "1"){ | |
1935 | 1944 | |
1936 | 1945 | try { |
1937 | 1946 |
@@ -1942,6 +1951,10 @@ | ||
1942 | 1951 | } catch (Exception $e) { |
1943 | 1952 | echo '例外発生: ', $e->getMessage(), "\n"; |
1944 | 1953 | } |
1954 | + }else{ | |
1955 | + | |
1956 | + $text= str_replace($matches[$key][0],"<strong style=\"color:red\">変換できません</strong>",$text)."\n"; | |
1957 | + } | |
1945 | 1958 | |
1946 | 1959 | |
1947 | 1960 | } |
@@ -1978,18 +1991,18 @@ | ||
1978 | 1991 | if(preg_match_all("/(《)([^》]+)(》)/su", $text, $matches, PREG_SET_ORDER)){ |
1979 | 1992 | |
1980 | 1993 | foreach($matches as $key=>$match){ |
1994 | + | |
1995 | + $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1996 | + $replacement = "<a class=\"foot-note\" href=\"#foot-note-$key\" name=\"anchor-foot-note-$key\" id=\"anchor-foot-note-$key\" title=\"脚注へ移動\">[$key]</a>"; | |
1997 | + $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1981 | 1998 | |
1982 | - $enc = mb_convert_encoding($match[2],"UTF-8","auto"); | |
1983 | - $replacement = "<a class=\"foot-note\" href=\"#foot-note-$key\" name=\"anchor-foot-note-$key\" id=\"anchor-foot-note-$key\" title=\"脚注へ移動\">[$key]</a>"; | |
1984 | - $text = str_replace($matches[$key][0],$replacement,$text)."\n"; | |
1985 | - | |
1986 | - array_push($this->footNote, array($key,"anchor-foot-note-$key","foot-note-$key",$enc)); | |
1999 | + array_push($this->footNote, array($key,"anchor-foot-note-$key","foot-note-$key",$enc)); | |
1987 | 2000 | } |
1988 | 2001 | |
1989 | - $code_hit = true; | |
2002 | + $code_hit = true; | |
1990 | 2003 | } |
1991 | 2004 | |
1992 | - return $text; | |
2005 | + return $text; | |
1993 | 2006 | } |
1994 | 2007 | |
1995 | 2008 | /*------------------------------------------------------------------------------+ |
@@ -2034,13 +2047,13 @@ | ||
2034 | 2047 | -------------------------------------------------------------*/ |
2035 | 2048 | |
2036 | 2049 | function basic_cleaner($buffer,$separator = "\n"){ |
2037 | - | |
2038 | - global $parm; | |
2039 | - | |
2050 | + | |
2051 | + global $parm; | |
2052 | + | |
2040 | 2053 | $buffer = mb_convert_encoding($buffer,"UTF-8","auto"); |
2041 | - $file = explode($separator,$buffer); | |
2042 | - $text = ""; | |
2043 | - | |
2054 | + $file = explode($separator,$buffer); | |
2055 | + $text = ""; | |
2056 | + | |
2044 | 2057 | foreach($file as $key => $chk){ |
2045 | 2058 | |
2046 | 2059 | $chk = str_replace("\0", "", $chk); |
@@ -2052,8 +2065,8 @@ | ||
2052 | 2065 | $text .= "\n$chk"; |
2053 | 2066 | |
2054 | 2067 | } |
2055 | - | |
2056 | - return $text; | |
2068 | + | |
2069 | + return $text; | |
2057 | 2070 | } |
2058 | 2071 | /*------------------------------------------------------------------------------+ |
2059 | 2072 | * イメージサイズの検出 |
@@ -2062,9 +2075,9 @@ | ||
2062 | 2075 | |
2063 | 2076 | if(eregi("\.(gif|jpg|png|swc|psd|tiff|bmp|iff|jp2|jpx|jb2|jpc|xbm|wbmp)",$file)){ |
2064 | 2077 | list($width, $height, $type, $attr) = getimagesize($file); |
2065 | - return $attr; | |
2078 | + return $attr; | |
2066 | 2079 | }else{ |
2067 | - return $wide; | |
2080 | + return $wide; | |
2068 | 2081 | } |
2069 | 2082 | } |
2070 | 2083 |
@@ -2107,59 +2120,59 @@ | ||
2107 | 2120 | *------------------------------------------------------------------------------*/ |
2108 | 2121 | function style_set($str){ |
2109 | 2122 | |
2110 | - $tab = " "; | |
2111 | - $i = 0; | |
2112 | - $break = ""; | |
2113 | - $str = str_replace("<","@@@@@<",$str); | |
2123 | + $tab = " "; | |
2124 | + $i = 0; | |
2125 | + $break = ""; | |
2126 | + $str = str_replace("<","@@@@@<",$str); | |
2114 | 2127 | $result =""; |
2115 | - $lines = explode("@@@@@",$str); | |
2128 | + $lines = explode("@@@@@",$str); | |
2116 | 2129 | |
2117 | - foreach($lines as $key=>$line){ | |
2130 | + foreach($lines as $key=>$line){ | |
2118 | 2131 | |
2119 | 2132 | if(preg_match("/(<\/?(xml|html|body))/mi",$line) ){ |
2120 | 2133 | |
2121 | - $i = 0; | |
2122 | - $space = str_repeat($tab,$i); | |
2123 | - $break = "<br />\n"; | |
2134 | + $i = 0; | |
2135 | + $space = str_repeat($tab,$i); | |
2136 | + $break = "<br />\n"; | |
2124 | 2137 | |
2125 | 2138 | }elseif(preg_match("/(<\/?(xml|html|head|body|script|!doctype))/mi",$line) ){ |
2126 | 2139 | |
2127 | - $i = 2; | |
2128 | - $space = str_repeat($tab,$i); | |
2129 | - $break = "<br />\n"; | |
2140 | + $i = 2; | |
2141 | + $space = str_repeat($tab,$i); | |
2142 | + $break = "<br />\n"; | |
2130 | 2143 | }elseif(preg_match("/(<\/)/",$line) ){ |
2131 | 2144 | |
2132 | 2145 | if($i<0){ |
2133 | - $i = 0; | |
2134 | - } | |
2135 | - | |
2136 | - $space = str_repeat($tab,$i); | |
2137 | - $break = "<br />\n"; | |
2138 | - $i--; | |
2146 | + $i = 0; | |
2147 | + } | |
2148 | + | |
2149 | + $space = str_repeat($tab,$i); | |
2150 | + $break = "<br />\n"; | |
2151 | + $i--; | |
2139 | 2152 | }elseif(preg_match("/(\/>?)/",$line) ){ |
2140 | 2153 | |
2141 | 2154 | if($i<0){ |
2142 | - $i = 0; | |
2143 | - } | |
2144 | - | |
2145 | - $space = str_repeat($tab,$i); | |
2146 | - $break = "<br />\n"; | |
2155 | + $i = 0; | |
2156 | + } | |
2157 | + | |
2158 | + $space = str_repeat($tab,$i); | |
2159 | + $break = "<br />\n"; | |
2147 | 2160 | }else{ |
2148 | - $break = "<br />\n"; | |
2161 | + $break = "<br />\n"; | |
2149 | 2162 | |
2150 | 2163 | if($i<0){ |
2151 | - $i = 0; | |
2152 | - } | |
2153 | - | |
2154 | - $space = str_repeat($tab,$i); | |
2164 | + $i = 0; | |
2165 | + } | |
2166 | + | |
2167 | + $space = str_repeat($tab,$i); | |
2155 | 2168 | $i++; |
2156 | 2169 | |
2157 | 2170 | } |
2158 | 2171 | |
2159 | - $result .= $space.htmlspecialchars($line).$break; | |
2172 | + $result .= $space.htmlspecialchars($line).$break; | |
2160 | 2173 | } |
2161 | 2174 | |
2162 | - return $this->tag_clear($result); | |
2175 | + return $this->tag_clear($result); | |
2163 | 2176 | } |
2164 | 2177 | |
2165 | 2178 | /* ------------------------------------------------------------ |
@@ -2176,7 +2189,7 @@ | ||
2176 | 2189 | $text = str_replace("\r","\n",$text); |
2177 | 2190 | $text = preg_replace("/(\n){2,}/","\n\n",$text); |
2178 | 2191 | |
2179 | - return $text; | |
2192 | + return $text; | |
2180 | 2193 | } |
2181 | 2194 | |
2182 | 2195 | //end class |
@@ -2249,56 +2262,48 @@ | ||
2249 | 2262 | //wikipedia |
2250 | 2263 | function simpleapi_wikipedia($replacement, $count = 1){ |
2251 | 2264 | |
2252 | - $result = unserialize($replacement); | |
2253 | - $results = "<div style=\"margin:1em;\">"; | |
2265 | + $result = unserialize($replacement); | |
2266 | + $results = "<div style=\"margin:1em;\">"; | |
2254 | 2267 | |
2255 | 2268 | for($i=0;$i<$count;$i++){ |
2256 | - | |
2257 | - $title = $result[$i]['title']; | |
2258 | - $body = $result[$i]['body']; | |
2259 | - $results .= "<strong>Wikipedia:{$title}</strong><blockquote>".nl2br($body)."</blockquote>"; | |
2269 | + | |
2270 | + $title = $result[$i]['title']; | |
2271 | + $body = $result[$i]['body']; | |
2272 | + $results .= "<strong>Wikipedia:{$title}</strong><blockquote>".nl2br($body)."</blockquote>"; | |
2260 | 2273 | } |
2261 | 2274 | |
2262 | 2275 | return str_replace(array("<br>","<br/>"),"<br />",$results)."\n</div>"; |
2263 | 2276 | } |
2264 | 2277 | |
2265 | -/* | |
2266 | -function test1(){ | |
2267 | - | |
2268 | -return date("ymd"); | |
2269 | - | |
2270 | -} | |
2271 | -*/ | |
2272 | - | |
2273 | 2278 | //////////////////////////////////////////////////////////////////////////////////// |
2274 | 2279 | function use_cache($name){ |
2275 | 2280 | |
2276 | - if(!defined('CACHE_LITE_PATH')){return array(false,"");} | |
2277 | - | |
2281 | + if(!defined('CACHE_LITE_PATH')){return array(false,"");} | |
2282 | + | |
2278 | 2283 | require_once(CACHE_LITE_PATH); |
2279 | 2284 | |
2280 | - $options = array( | |
2281 | - 'cacheDir' => CACHE_DIR_PATH, | |
2282 | - 'lifeTime' => CACHE_LIFE_TIME, | |
2283 | - ); | |
2285 | + $options = array( | |
2286 | + 'cacheDir' => CACHE_DIR_PATH, | |
2287 | + 'lifeTime' => CACHE_LIFE_TIME, | |
2288 | + ); | |
2284 | 2289 | |
2285 | - $Cache_Lite = new Cache_Lite($options); | |
2290 | + $Cache_Lite = new Cache_Lite($options); | |
2286 | 2291 | |
2287 | - if(!CACHE_SWITCH){ | |
2292 | + if(!CACHE_SWITCH){ | |
2293 | + | |
2294 | + $Cache_Lite->clean(); | |
2295 | + return array(false,""); | |
2296 | + } | |
2288 | 2297 | |
2289 | - $Cache_Lite->clean(); | |
2290 | - return array(false,""); | |
2291 | - } | |
2292 | - | |
2293 | 2298 | $name = md5($name); |
2294 | 2299 | |
2295 | - if ($data = $Cache_Lite->get($name)){ | |
2296 | - $result = $data; | |
2297 | - $flag = true; | |
2298 | - }else { | |
2300 | + if ($data = $Cache_Lite->get($name)){ | |
2301 | + $result = $data; | |
2302 | + $flag = true; | |
2303 | + }else { | |
2299 | 2304 | |
2300 | - $flag = false; | |
2301 | - } | |
2305 | + $flag = false; | |
2306 | + } | |
2302 | 2307 | |
2303 | 2308 | return array($flag,$data); |
2304 | 2309 | } |
@@ -2305,59 +2310,59 @@ | ||
2305 | 2310 | |
2306 | 2311 | function save_cache($name,$value){ |
2307 | 2312 | |
2308 | - if(!defined('CACHE_LITE_PATH')){return array(false,$value);} | |
2313 | + if(!defined('CACHE_LITE_PATH')){return array(false,$value);} | |
2309 | 2314 | |
2310 | 2315 | $name = md5($name); |
2311 | 2316 | |
2312 | 2317 | require_once(CACHE_LITE_PATH); |
2313 | 2318 | |
2314 | - $options = array( | |
2315 | - 'cacheDir' => CACHE_DIR_PATH, | |
2316 | - 'lifeTime' => CACHE_LIFE_TIME, | |
2317 | - ); | |
2319 | + $options = array( | |
2320 | + 'cacheDir' => CACHE_DIR_PATH, | |
2321 | + 'lifeTime' => CACHE_LIFE_TIME, | |
2322 | + ); | |
2318 | 2323 | |
2319 | 2324 | $Cache_Lite = new Cache_Lite($options); |
2325 | + | |
2326 | + if(!CACHE_SWITCH){ | |
2327 | + | |
2328 | + $Cache_Lite->clean(); | |
2329 | + return array(false,$value); | |
2330 | + } | |
2320 | 2331 | |
2321 | - if(!CACHE_SWITCH){ | |
2332 | + if ($data = $Cache_Lite->get($name)){ | |
2333 | + $result = $data; | |
2334 | + $flag = true; | |
2335 | + }else { | |
2322 | 2336 | |
2323 | - $Cache_Lite->clean(); | |
2324 | - return array(false,$value); | |
2325 | - } | |
2337 | + $Cache_Lite->save($value,$name); | |
2338 | + //print_r($Cache_Lite); | |
2339 | + $result = $value; | |
2340 | + $flag = false; | |
2341 | + } | |
2326 | 2342 | |
2327 | - if ($data = $Cache_Lite->get($name)){ | |
2328 | - $result = $data; | |
2329 | - $flag = true; | |
2330 | - }else { | |
2331 | - | |
2332 | - $Cache_Lite->save($value,$name); | |
2333 | - //print_r($Cache_Lite); | |
2334 | - $result = $value; | |
2335 | - $flag = false; | |
2336 | - } | |
2337 | - | |
2338 | 2343 | return array($flag,$value); |
2339 | 2344 | } |
2340 | 2345 | |
2341 | 2346 | function html_document1($ini_array,$documents,$navi="",$source = ""){ |
2342 | 2347 | |
2343 | - global $content_name; | |
2344 | - global $source; | |
2345 | - global $campany_data; | |
2348 | + global $content_name; | |
2349 | + global $source; | |
2350 | + global $campany_data; | |
2351 | + | |
2352 | + $charset = $ini_array['html_header']['charset']; | |
2353 | + $author = $ini_array['html_header']['author']; | |
2354 | + $keyword = $ini_array['html_header']['keyword']; | |
2355 | + $description = $ini_array['html_header']['description']; | |
2356 | + $mail = $ini_array['html_header']['mail']; | |
2357 | + $stylesheet = $ini_array['html_header']['stylesheet']; | |
2358 | + $style_media = $ini_array['html_header']['style_media']; | |
2359 | + $navi_start = $ini_array['html_header']['start']; | |
2360 | + $navi_prev = $ini_array['html_header']['prev']; | |
2361 | + $navi_next = $ini_array['html_header']['next']; | |
2362 | + $navi_help = $ini_array['html_header']['help']; | |
2363 | + $title = $ini_array['html_header']['title']; | |
2364 | + $embed = $ini_array['html_header']['embed']; | |
2346 | 2365 | |
2347 | - $charset = $ini_array['html_header']['charset']; | |
2348 | - $author = $ini_array['html_header']['author']; | |
2349 | - $keyword = $ini_array['html_header']['keyword']; | |
2350 | - $description = $ini_array['html_header']['description']; | |
2351 | - $mail = $ini_array['html_header']['mail']; | |
2352 | - $stylesheet = $ini_array['html_header']['stylesheet']; | |
2353 | - $style_media = $ini_array['html_header']['style_media']; | |
2354 | - $navi_start = $ini_array['html_header']['start']; | |
2355 | - $navi_prev = $ini_array['html_header']['prev']; | |
2356 | - $navi_next = $ini_array['html_header']['next']; | |
2357 | - $navi_help = $ini_array['html_header']['help']; | |
2358 | - $title = $ini_array['html_header']['title']; | |
2359 | - $embed = $ini_array['html_header']['embed']; | |
2360 | - | |
2361 | 2366 | $html=<<<DOC |
2362 | 2367 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
2363 | 2368 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |