• R/O
  • SSH
  • HTTPS

text2html: Commit


Commit MetaInfo

Revisión80 (tree)
Tiempo2008-08-26 11:35:12
Autortenman

Log Message

ライセンス署名追加

Cambiar Resumen

Diferencia incremental

--- trunk/text2html/scripts/trans.php (revision 79)
+++ trunk/text2html/scripts/trans.php (revision 80)
@@ -1,7 +1,10 @@
11 <?php
22 /*------------------------------------------------------------------------------+
3- *<meta http-equiv="Content-Type" content="text/php; charset=utf-8">
3+ <meta http-equiv="Content-Type" content="text/php; charset=utf-8">
44
5+ text2html てきでこ Akio Tenman. <http://text2html.sourceforge.jp/>
6+ Copyright (C) 2008 Akio Tenman <tenman@users.sourceforge.jp>
7+
58 This program is free software: you can redistribute it and/or modify
69 it under the terms of the GNU General Public License as published by
710 the Free Software Foundation, either version 3 of the License, or
@@ -14,23 +17,23 @@
1417
1518 You should have received a copy of the GNU General Public License
1619 along with this program. If not, see <http://www.gnu.org/licenses/>.
17- *------------------------------------------------------------------------------*/
20+ +------------------------------------------------------------------------------*/
1821 //このアプリで、外部API等を参照する場合、allow_url_fopenはtrueである必要があります。
1922
2023 mb_language( 'Japanese' );
21-
24+
2225 if(preg_match("/^[A-z]:.+/",__FILE__)){
23- $separater = '\\';
26+ $separater = '\\';
2427 }else{
25- $separater = '/';
28+ $separater = '/';
2629 }
27-
28- if(!isset($text2html_url)){
29- $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']).$separater;
3033 }
3134
32- if(!isset($text2html_dir_path)){
33- $text2html_dir_path = dirname(dirname(__FILE__)).$separater;
35+ if(!isset($text2html_dir_path)){
36+ $text2html_dir_path = dirname(dirname(__FILE__)).$separater;
3437 }
3538
3639 if(!isset($cache)){
@@ -120,47 +123,47 @@
120123 var $attr;
121124 var $content_attr;
122125 var $description;
123- var $copy_target;
124- var $copy_uri;
126+ var $copy_target;
127+ var $copy_uri;
125128
126129
127- function trans($document){
130+ function trans($document){
128131
129- $document = str_replace(array("\r"),"\n",$document);
130- $document = $this->tag_br($document);
131- $this->document = $this->tag_clear($document);
132+ $document = str_replace(array("\r"),"\n",$document);
133+ $document = $this->tag_br($document);
134+ $this->document = $this->tag_clear($document);
132135 }
133136
134137 function delete_break($matches){
135138 $result = "";
136-
137- foreach($matches as $key=>$match){
138- if($key==0){
139- $result .= str_replace("\n","",$match);
140- }
141- }
142-
143- $result = preg_replace("/\s{2,}/"," ",$result);
144-
145- return $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;
146149 }
147150
148151 function tag_br($text){
149- $text = str_replace("\r","",$text);
150- $text = preg_replace("/\s=/","=",$text);
151- $text = preg_replace_callback("/[^(code:)](<[^>]+\s{2,}[^>]+>)/usi",array($this, 'delete_break'),$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);
152155
153- return $text;
156+ return $text;
154157
155158 }
156159
157160 function get_querys($text){
158161
159- if(ini_get("allow_url_fopen") == false){
160-
161- return $text;
162- }
162+ if(ini_get("allow_url_fopen") == false){
163163
164+ return $text;
165+ }
166+
164167 //重複名の誤変換を避けるために、文字数の長い順にソート
165168 $get_querys = array(
166169 /*キー名は10文字未満*/
@@ -207,22 +210,22 @@
207210 'url'=>'http://www.odekake.biz/branch/?date=+++E_KEYWORD+++',
208211 "response"=>"+++CONTENTS+++\n"),
209212 );
210-
213+
211214 uksort($get_querys,"text2html_cmp");
212215
213216 if(isset($get_querys)){
214217 foreach($get_querys as $key=>$val){
215218 if(preg_match_all("/($key>\()([^\)]+)(\))/u", $text, $matches, PREG_SET_ORDER)){
216-
219+
217220 foreach($matches as $key=>$match){
218-
221+
219222 $cache = use_cache($matches[$key][0]);
220223 if($cache[0]){
221-
222- $text = str_replace($matches[$key][0],$cache[1],$text)."\n";
224+
225+ $text = str_replace($matches[$key][0],$cache[1],$text)."\n";
223226 }else{
224-
225- $enc = mb_convert_encoding($match[2],$val['charset'],"auto");
227+
228+ $enc = mb_convert_encoding($match[2],$val['charset'],"auto");
226229 $no_enc = mb_convert_encoding($match[2],"UTF-8","auto");
227230 $no_enc = str_replace("\n","",$no_enc);
228231
@@ -230,7 +233,7 @@
230233
231234 case('link'):
232235
233- $enc = urlencode($enc);
236+ $enc = urlencode($enc);
234237 $replacement = mb_convert_encoding($val['response'],"UTF-8","auto");
235238 $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']);
236239 $replacement = trim($replacement);
@@ -238,24 +241,24 @@
238241
239242 case('contents'):
240243
241- $enc = urlencode($enc);
242- $target = mb_convert_encoding($val['url'],"UTF-8","auto");
243- $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$target);
244- $host = parse_url($target);
245- $host = $host['host'];
246-
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+
247250 try{
248251
249252 if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){
250-
253+
251254 throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。');
252255 }
253-
256+
254257 socket_set_timeout($fp, 3);
255258 fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n");
256- $replacement = mb_convert_encoding(file_get_contents($target),"UTF-8","auto");
257- $stat = socket_get_status($fp);
258-
259+ $replacement = mb_convert_encoding(file_get_contents($target),"UTF-8","auto");
260+ $stat = socket_get_status($fp);
261+
259262 if ($stat["timed_out"]) {
260263
261264 throw new Exception('タイムアウトしました。');
@@ -264,77 +267,77 @@
264267 fclose($fp);
265268
266269 }catch (Exception $e) {
267-
270+
268271 $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
269272 echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n";
270273 }
271274
272275 break;
273-
276+
274277 case('query'):
275278
276- $replacement = mb_convert_encoding($val['response'],"UTF-8","auto");
277- $querys = explode("&",$enc);
278- $enc = "";
279-
280- foreach($querys as $query){
281-
282- preg_match("/([^=]+)(=)(.+)/", $query, $hit);
283-
284- if($hit){
285- $enc .= '&amp;'.urlencode($hit[1]).$hit[2].urlencode($hit[3]);
286- }
287-
288- }
279+ $replacement = mb_convert_encoding($val['response'],"UTF-8","auto");
280+ $querys = explode("&",$enc);
281+ $enc = "";
289282
290- $enc = str_replace("\n","",$enc);
291- $no_enc = "";
292- $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']);
283+ foreach($querys as $query){
293284
285+ preg_match("/([^=]+)(=)(.+)/", $query, $hit);
286+
287+ if($hit){
288+ $enc .= '&amp;'.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+
294297 break;
295298
296299 case('contents_rebuild'):
297300
298- $enc = urlencode($enc);
301+ $enc = urlencode($enc);
299302 $replacement = mb_convert_encoding($val['response'],"UTF-8","auto");
300- $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['url']);
303+ $target = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['url']);
301304
302- $host = parse_url($target);
303- $host = $host['host'];
304-
305+ $host = parse_url($target);
306+ $host = $host['host'];
307+
305308 try{
306309
307310 if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){
308-
311+
309312 throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。');
310313 }
311-
314+
312315 socket_set_timeout($fp, 3);
313316 fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n");
314317
315- $replacement = mb_convert_encoding(@file_get_contents($target),"UTF-8","auto");
316- $function_name = $val['function'];
317- $replacement = $function_name($replacement);
318+ $replacement = mb_convert_encoding(@file_get_contents($target),"UTF-8","auto");
319+ $function_name = $val['function'];
320+ $replacement = $function_name($replacement);
318321
319322 $stat = socket_get_status($fp);
320-
321- if ($stat["timed_out"]) {
322-
323- throw new Exception('タイムアウトしました。');
324- }
325323
324+ if ($stat["timed_out"]) {
325+
326+ throw new Exception('タイムアウトしました。');
327+ }
328+
326329 fclose($fp);
327330
328331
329332 }catch (Exception $e) {
330-
331- $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
333+
334+ $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
332335 echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n";
333336 }
334337 break;
335338
336339 }
337-
340+
338341 save_cache($matches[$key][0],$replacement);
339342
340343 $text = str_replace($matches[$key][0],$replacement,$text)."\n";
@@ -357,16 +360,16 @@
357360 }
358361
359362 function text2html(){
360-
363+
361364 global $benchmark;
362365 global $source;
363- global $content_name;
364-
366+ global $content_name;
367+
365368 $pear_file = "";
366369 $timer = false;
367- $buffer = $this->document;
370+ $buffer = $this->document;
368371 $output_enc = "UTF-8";
369-
372+
370373 if(isset($benchmark) and $benchmark == true){
371374 include_once ("Benchmark/Timer.php");
372375 $timer = true;
@@ -385,7 +388,7 @@
385388 if($timer){ $oTimer->setMarker( 'text2html_table' );}
386389 //blockquote
387390 $buffer = $this->text2html_code($buffer,"\n","pre",'code:','code','','class="source"','souce');
388-
391+
389392 if($timer){ $oTimer->setMarker( 'text2html_code' );}
390393 //heading
391394 $buffer = $this->text2html_element($buffer,"\n","h6",'\*\*\*\*\*','a','', 'href="#TOP"','h6');
@@ -420,7 +423,7 @@
420423 asort($this->header_info);
421424 $this->midasilist = "<a name=\"TOP\" id=\"TOP\" >head line</a>\n";
422425 $kihou = "";
423-
426+
424427 foreach($this->header_info as $key=>$link){
425428
426429 $kihou = str_repeat ('+', $link[1]-1);
@@ -440,17 +443,17 @@
440443 break;
441444
442445 case(count($end) > count($start)):
443- //閉じタグが多い
444- $rep = $rep;
445- $rep = str_repeat("<\/ol><\/li>",$rep + 1);
446- $this->midasilist = preg_replace("/$rep<\/ol>$/m","</ol>",$this->midasilist);
446+ //閉じタグが多い
447+ $rep = $rep;
448+ $rep = str_repeat("<\/ol><\/li>",$rep + 1);
449+ $this->midasilist = preg_replace("/$rep<\/ol>$/m","</ol>",$this->midasilist);
447450
448451 break;
449452
450453 case(count($end) < count($start)):
451- //閉じタグが少ない
452- $rep = str_repeat('</ol></li>',abs($rep)-1);
453- $this->midasilist = preg_replace("/<\/ol>$/m","",$this->midasilist).$rep."</ol>";
454+ //閉じタグが少ない
455+ $rep = str_repeat('</ol></li>',abs($rep)-1);
456+ $this->midasilist = preg_replace("/<\/ol>$/m","",$this->midasilist).$rep."</ol>";
454457
455458 break;
456459 }
@@ -472,7 +475,7 @@
472475
473476 $buffer = $this->keyword_change($buffer,"\n");
474477 if($timer){$oTimer->setMarker( 'keyword_change' );}
475-
478+
476479 $buffer = $this->read_php($buffer,"\n");
477480 if($timer){$oTimer->setMarker( 'read_php' );}
478481
@@ -517,7 +520,7 @@
517520
518521 $buffer = $this->clear_both($buffer,"\n");
519522 if($timer){$oTimer->setMarker( 'clear_both' );}
520-
523+
521524 $buffer = $this->get_querys($buffer,"\n");
522525 if($timer){$oTimer->setMarker( 'get_querys' );}
523526
@@ -526,7 +529,7 @@
526529 $buffer = $this->text2html_list($buffer,"\n","ul",'※','li','style="font:size:70%;color:#66f;"',"style=\"list-style-type:none;\"","caution");
527530 if($timer){$oTimer->setMarker( 'list' );}
528531
529- //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote');
532+ //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote');
530533 //入れ子可
531534 $buffer = $this->text2html_list($buffer,"\n","blockquote",'>','p','','','quote');
532535 if($timer){$oTimer->setMarker( 'list_blockquote' );}
@@ -541,7 +544,7 @@
541544 if($timer){$oTimer->setMarker( 'result_encoding' );}
542545
543546 if(isset($source) and $source == true){
544-
547+
545548 $source = $this->my_wordwrap($text);
546549 $source = str_replace("&#47;",'/',$source);
547550
@@ -548,7 +551,7 @@
548551 $this->source = '<div class="source_view">'.
549552 $this->style_set($source)."\n</div>";
550553 }else{
551-
554+
552555 $this->source = "";
553556 }
554557 if($timer){$oTimer->setMarker( 'create_source' );}
@@ -568,17 +571,17 @@
568571
569572 function change_word($text){
570573
571- if(!defined('TEXTTOHTML_CHANGE_TXT')){return $text;}
572- $file = TEXTTOHTML_CHANGE_TXT;
574+ if(!defined('TEXTTOHTML_CHANGE_TXT')){return $text;}
575+ $file = TEXTTOHTML_CHANGE_TXT;
573576
574577 if(file_exists($file)){
575-
578+
576579 $chenge_words = file($file);
577580
578581 foreach($chenge_words as $chenge_word){
579-
580- $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto");
581582
583+ $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto");
584+
582585 if(strstr($chenge_word,"#")){
583586 list($before, $after) = explode("#", $chenge_word);
584587 $text = str_replace($before , trim($after), $text);
@@ -587,7 +590,7 @@
587590
588591 return $text;
589592 }else{
590-
593+
591594 return $text;
592595 }
593596
@@ -634,7 +637,7 @@
634637 $line = $line."\n";
635638 if($current_flag = preg_match("/^([$wm]+)(.+)/u",$line,$current)){
636639
637- $marker_length = @strlen($current[1]);
640+ $marker_length = @strlen($current[1]);
638641
639642
640643 //リスト変換のオンオフ判定
@@ -904,12 +907,12 @@
904907 $description = $description.$content_name;
905908 }
906909
907- $lines = explode($separator,$document);
908- $start = true;
909- $this->content_no = 1;
910- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
911- $end_tag = '';
912- $result = "";
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 = "";
913916
914917 foreach($lines as $list){
915918
@@ -919,30 +922,30 @@
919922
920923 if(!empty($content)){
921924
922- $start_content = "<$content>";
923- $end_content = "</$content>\n";
925+ $start_content = "<$content>";
926+ $end_content = "</$content>\n";
924927 }else{
925-
926- $start_content = "";
927- $end_content = "";
928+
929+ $start_content = "";
930+ $end_content = "";
928931 }
929932
930933 $res = $this->text2html_list($regs[2],$this->separator,$this->element,$this->wm,$this->content,$this->attr,$this->content_attr,$this->description);
931934
932- $list = str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($res)).$end_content,$list);
933- $start_tag = "";
934- $end_tag = "</{$element}>";
935+ $list = str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($res)).$end_content,$list);
936+ $start_tag = "";
937+ $end_tag = "</{$element}>";
935938
936939 }elseif(!empty($end_tag)){
937940
938- $list = $end_tag."\n".$list;
941+ $list = $end_tag."\n".$list;
939942 $this->content_no++;
940- $end_tag = '';
941- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
943+ $end_tag = '';
944+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
942945 }else{
943-
944- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
945946
947+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
948+
946949 }
947950
948951 $result .= $list;
@@ -957,36 +960,36 @@
957960 $element = $this->element;
958961 $wm = $this->wm;
959962 $content = $this->content;
960- $start = true;
961- $lines = explode($separator,$document);
962- $end_tag = "";
963- $result = "";
964- $class = "";
963+ $start = true;
964+ $lines = explode($separator,$document);
965+ $end_tag = "";
966+ $result = "";
967+ $class = "";
965968
966- foreach($lines as $key=>$list){
969+ foreach($lines as $key=>$list){
967970
968- $list = $list. "\n";
971+ $list = $list. "\n";
969972
970973 if(ereg("(^$wm{1})(.+)",$list,$regs)){
971974
972- if($start == false){$start_tag = "";}else{$start_tag = "<$element>";}
973-
974- if(!ereg("(^$wm{1})(.+)",$lines[$key+1])){$end_tag= "</$element>";}else{$end_tag= "";}
975-
976- if(!empty($content)){
977-
978- $start_content = "<$content>";
979- $end_content = "</$content>";
980- }else{
981-
982- $start_content = "";
983- $end_content = "";
984- }
975+ if($start == false){$start_tag = "";}else{$start_tag = "<$element>";}
985976
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+
986989 $list= str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($regs[2]))."\n".$end_content,$list);
987990
988991 $start = false;
989-
992+
990993 }elseif(!empty($end_tag)){
991994
992995 $list = $end_tag. "\n".$list;
@@ -993,9 +996,9 @@
993996 }
994997 $result .= $list;
995998
996- }
999+ }
9971000
998- return $this->tag_clear($result);
1001+ return $this->tag_clear($result);
9991002 }
10001003
10011004 function text2html_code($document = "", $separator = "\n",$element = "pre",$wm = 'code:',$content = 'code',$attr = '',$content_attr = '',$description = ''){
@@ -1007,21 +1010,21 @@
10071010 global $content_name;
10081011
10091012 if(!empty($content_name) and !empty($description)){
1010- $description = $description.'-'.$content_name;
1013+ $description = $description.'-'.$content_name;
10111014 }else{
1012- $description = $description.$content_name;
1015+ $description = $description.$content_name;
10131016 }
10141017
1015- $i = 0;
1016- $lines = explode($separator,$document);
1017- $start = true;
1018+ $i = 0;
1019+ $lines = explode($separator,$document);
1020+ $start = true;
10181021 $this->content_no = 1;
1019- $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1020- $end_tag = '';
1021- $result = "";
1022+ $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1023+ $end_tag = '';
1024+ $result = "";
10221025
10231026 foreach($lines as $list){
1024-
1027+
10251028 $list = $list. "\n";
10261029
10271030 if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){
@@ -1035,26 +1038,26 @@
10351038 $end_content = "\n";
10361039 }
10371040
1038- $doc = $regs[2];
1039- $doc = $this->my_wordwrap($doc);
1040- $doc = htmlspecialchars($doc);
1041- $doc = str_replace(array('/',"\t",'$','<'),array("&#47;"," ",'&#36;','&#lt'),$doc);
1042- $doc = str_replace("\n","</code><code>",$doc);//ワードラップは、改行だけ埋め込むので、タグを補充
1043- $list = str_replace($regs[0],$start_tag.$start_content.trim($doc).$end_content,$list);
1044- $start_tag = "";
1045- $end_tag = "</{$element}>";
1041+ $doc = $regs[2];
1042+ $doc = $this->my_wordwrap($doc);
1043+ $doc = htmlspecialchars($doc);
1044+ $doc = str_replace(array('/',"\t",'$','<'),array("&#47;"," ",'&#36;','&#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}>";
10461049
10471050 }elseif(!empty($end_tag)){
1048-
1049- $list = $end_tag."\n".$list;
1051+
1052+ $list = $end_tag."\n".$list;
10501053 $this->content_no++;
1051- $end_tag = '';
1052- $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1053- $i = 0;
1054+ $end_tag = '';
1055+ $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1056+ $i = 0;
10541057 }else{
1055-
1056- $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1057- $i =0;
1058+
1059+ $start_tag = "<{$element} $attr id=\"$element-$description-".trim($this->content_no)."\">";
1060+ $i =0;
10581061 }
10591062
10601063 $result .= $list;
@@ -1083,19 +1086,19 @@
10831086 $description = $description.$content_name;
10841087 }
10851088
1086- $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
1087- $lines = explode($separator,$document);
1088- $group = "<colgroup><col /></colgroup>";
1089+ $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
1090+ $lines = explode($separator,$document);
1091+ $group = "<colgroup><col /></colgroup>";
10891092
10901093 foreach($lines as $key=>$list){
10911094
1092- $list = $list. $separator;
1093- $write_group = false;
1095+ $list = $list. $separator;
1096+ $write_group = false;
10941097
10951098 if(ereg("(^$wm{1})(.+)",$list,$regs)){
10961099
10971100 if(preg_match("/({$wm}summary:)(.+)/um",$list,$match)){
1098-
1101+
10991102 if($end_tag){
11001103
11011104 $start_tag = "</table>\n<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">";
@@ -1105,9 +1108,9 @@
11051108 $start_tag = "<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">";
11061109 }
11071110
1108- $write_group = true;
1109- unset($regs[2]);
1110- $list = "";
1111+ $write_group = true;
1112+ unset($regs[2]);
1113+ $list = "";
11111114
11121115 }else{
11131116
@@ -1116,20 +1119,20 @@
11161119 if(isset($regs[2])){
11171120
11181121 $fields = explode('|',$regs[2]);
1119- $col_no =1;
1122+ $col_no =1;
11201123 foreach($fields as $colkey=>$field){
1121-
1124+
11221125 $ht_field .= "<td class=\"col{$col_no} row{$row_no}\" id=\"tbl".$this->content_no."{$col_no}{$row_no}\">$field</td>";
11231126 $col_no++;
11241127
11251128 }
1126-
1129+
11271130 $row_no++;
11281131 }
11291132
1130- $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>\n",$list);
1131- $start_tag = "";
1132- $end_tag = "</{$element}>\n";
1133+ $list = str_replace($regs[0],$start_tag."<$content>".$ht_field."</$content>\n",$list);
1134+ $start_tag = "";
1135+ $end_tag = "</{$element}>\n";
11331136
11341137 if(!isset($lines[$key + 1]) or !ereg("(^$wm{1})(.+)",$lines[$key + 1])){
11351138
@@ -1138,22 +1141,22 @@
11381141 }
11391142 }
11401143 }elseif($end_tag){
1141-
1142- $list = $end_tag."\n".$list;
1143- $row_no = 1;
11441144
1145+ $list = $end_tag."\n".$list;
1146+ $row_no = 1;
1147+
11451148 $this->content_no++;
11461149
1147- $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
1148- $end_tag = false;
1150+ $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
1151+ $end_tag = false;
11491152 }else{
1150-
1153+
11511154 $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
11521155 }
11531156
11541157 $result .= $list;
11551158 }
1156- return $this->tag_clear($result);
1159+ return $this->tag_clear($result);
11571160 }
11581161
11591162 function text2html_element($document, $separator = "\n",$element = "h2",$wm = '*',$content = 'span',$attr = '',$content_attr = '',$description = ''){
@@ -1161,16 +1164,16 @@
11611164 global $content_name;
11621165
11631166 if(!empty($content_name) and !empty($description)){
1164- $description = $description.'-'.$content_name;
1167+ $description = $description.'-'.$content_name;
11651168 }else{
1166- $description = $description.$content_name;
1169+ $description = $description.$content_name;
11671170 }
11681171
11691172 $lines = explode($separator,$document);
1170- $start = true;
1171- $end_tag = '';
1172- $result = "";
1173- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
1173+ $start = true;
1174+ $end_tag = '';
1175+ $result = "";
1176+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
11741177 $this->content_no = 1;
11751178
11761179 foreach($lines as $key => $list){
@@ -1178,43 +1181,43 @@
11781181 $list = $list. "\n";
11791182
11801183 if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){
1181-
1184+
11821185 if(!empty($content)){
1183-
1186+
11841187 $content_start = "<$content $content_attr >";
11851188 $content_end = "</$content>";
11861189 }else{
1187-
1190+
11881191 $content_start = "";
11891192 $content_end = "";
11901193 }
1191-
1192- $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list);
1193- $start_tag = "";
1194- $end_tag = "</{$element}>\n";
11951194
1195+ $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list);
1196+ $start_tag = "";
1197+ $end_tag = "</{$element}>\n";
1198+
11961199 //見出しリスト
11971200
1198- if(ereg("h([1-6])",$element,$match)){
1199-
1200- $list = str_replace("\n","",$list);
1201+ if(ereg("h([1-6])",$element,$match)){
1202+
1203+ $list = str_replace("\n","",$list);
12011204 array_push($this->header_info,array($key,trim($match[1]),"$element-$description-".$this->content_no,$regs[2]));
12021205 }
12031206
12041207 }elseif(!empty($end_tag)){
1205-
1206- $list = $end_tag."\n".$list;
1208+
1209+ $list = $end_tag."\n".$list;
12071210 $this->content_no++;
1208- $end_tag = '';
1209- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
1211+ $end_tag = '';
1212+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
12101213 }else{
1211-
1212- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
1214+
1215+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\" >";
12131216 }
1214- $result .= $list;
1217+ $result .= $list;
12151218 }
12161219
1217- return $this->tag_clear($result);
1220+ return $this->tag_clear($result);
12181221 }
12191222
12201223 function paragraf($document, $separator = "\n\n",$element = "p",$wm = '',$content = '',$attr = '',$content_attr = '',$description = 'paragraph'){
@@ -1231,43 +1234,43 @@
12311234
12321235 foreach($checks as $val){
12331236
1234- $check[] = "<$val";
1235- $check[] = "$val>";
1236- $check[] = "</$val";
1237+ $check[] = "<$val";
1238+ $check[] = "$val>";
1239+ $check[] = "</$val";
12371240
1238- $replace[] = "\n\n<$val";
1239- $replace[] = "$val>$separator";
1240- $replace[] = "$separator</$val";
1241+ $replace[] = "\n\n<$val";
1242+ $replace[] = "$val>$separator";
1243+ $replace[] = "$separator</$val";
12411244 }
12421245
12431246
1244- $document = str_replace($check,$replace,$document);
1245- $document = $this->tag_clear($document);
1246- $document = ereg_replace("(\n{1})","\n\n",$document);
1247- $lines = explode($separator,$document);
1248- $start = true;
1249- $end_tag = '';
1250- $result = "";
1251- $this->content_no = 1;
1252- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
1253- //$wm = "[^(\*|+|<|\=|\n$|\s|code:|   )]";
1254- $blocks = true;//pをコンテンツに出来ないタグ内での変換を禁止
1255- $wm = "[^(\*|\+|\=|\n$|\s| |\-|<)]";
1256- $tags_block = "(dl|ol|ul|address|blockquote|form|fieldset|table|style|tr|p|code)";
1257- $cdata_zone = false;
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;
12581261
12591262 foreach($lines as $key => $list){
1260-
1263+
12611264 $list = $list."\n\n";
12621265
1263- if(preg_match("/(<!--|<!\[CDATA\[|<script|<style|<$tags_block)/iu",$list) and !preg_match("/(!--|\]\]>|\/script|\/style|<\/$tags_block)\s?\/?>/iu",$list)){
1264- $cdata_zone = true;
1265- //テーブル間にタグを適用できなくなる
1266- }
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+ }
12671270
1268- if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){
1271+ if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){
12691272
1270- $content_start = "";
1273+ $content_start = "";
12711274
12721275 if(isset($lines[$key + 1]) and $lines[$key + 1] == true){
12731276
@@ -1277,19 +1280,19 @@
12771280 $content_end = "";
12781281 }
12791282
1280- $list = str_replace($regs[0],$start_tag.$content_start.trim($regs[1]).$content_end,$list);
1281- $start_tag = "";
1282- $end_tag = "\n</{$element}>\n\n";
1283- $paragraph_div = '¶';
1284-
1285- if(eregi($paragraph_div,$list)){
1286-
1287- $list = str_replace(array($paragraph_div.$content_end,$paragraph_div),$end_tag, $list);
1288- $end_tag = '';
1289- $this->content_no++;
1290- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
1291- }
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 = '¶';
12921287
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+
12931296 }elseif(!empty($end_tag) ){
12941297
12951298 $list = $end_tag."\n".$list;
@@ -1316,8 +1319,8 @@
13161319
13171320 function img_copy($buffer){
13181321
1319- if(!defined('TEXTTOHTML_IMAGE_DIR_PATH')){return $buffer;}
1320-
1322+ if(!defined('TEXTTOHTML_IMAGE_DIR_PATH')){return $buffer;}
1323+
13211324 $copy_width = TEXTTOHTML_COPY_IMG_WIDTH;
13221325
13231326 if(preg_match_all("/(copy>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){
@@ -1324,20 +1327,20 @@
13241327
13251328 foreach($matches as $key=>$match){
13261329
1327- $cache = use_cache($matches[$key][0],$buffer);
1330+ $cache = use_cache($matches[$key][0],$buffer);
13281331
13291332 if($cache[0]){
13301333
1331- $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n";
1334+ $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n";
13321335 }else{
13331336 clearstatcache();
1334-
1335- $copy_target = TEXTTOHTML_IMAGE_DIR_PATH.basename($match[2]);
1336- $copy_target_url = TEXTTOHTML_IMAGE_DIR_URL.basename($match[2]);
1337- $quote_comment = "<!--from:".$match[2]."--><a href=\"".$match[2]."\" class=\"quoted\">";
1338- $size = getimagesize($match[2]);
1339- $uri = htmlspecialchars(trim($match[2]));
13401337
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+
13411344 if($size[0] > $copy_width){
13421345 $aspect = @round($size[1]/$size[0],2);
13431346 $height = @round($copy_width * $aspect,0);
@@ -1345,42 +1348,42 @@
13451348 $copy_width = $size[0];
13461349 $height = $size[1];
13471350 }
1348-
1351+
13491352 $gdimg = imagecreatetruecolor($copy_width,$height);
13501353
13511354 if($size[2] == 1) {
1352-
1353- if( $im = imagecreatefromgif($uri)){
1354- imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]);
1355- @imagegif($gdimg,$copy_target);
1356- }
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+ }
13571360 }
1358-
1361+
13591362 if($size[2] == 2 and $size) {
1360-
1361- if( $im = imagecreatefromjpeg($uri)){
1362- imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]);
1363- @imagejpeg($gdimg,$copy_target);
1364- }
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+ }
13651368 }
13661369 if($size[2] == 3) {
1367-
1368- if($im = imagecreatefrompng($uri)){
1369- imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]);
1370- @imagepng($gdimg,$copy_target);
1371- }
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+ }
13721375 }
13731376 if($size[2] == 15) {
1374-
1375- if($im = imagecreatefromwbmp($uri)){
1376- imagecopyresized($gdimg,$im,0,0,0,0,$copy_width,$height,$size[0],$size[1]);
1377- @imagebmp($gdimg,$copy_target);
1378- }
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+ }
13791382 }
1380-
1381- $buffer= str_replace($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>",$buffer)."\n";
1382-
13831383
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+
13841387 save_cache($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>");
13851388 }
13861389
@@ -1392,17 +1395,17 @@
13921395
13931396 function keyword_change($document){
13941397
1395- $keyword_res = array();
1396- $change_val_res = array();
1398+ $keyword_res = array();
1399+ $change_val_res = array();
13971400
13981401 if(phpversion('domDocument')){
13991402
1400- $dom = new domDocument;
1401- $dom->load(CHANGE_PATTERN_PATH);
1402- $root = $dom->documentElement;
1403- $books = $root->childNodes;
1404- $keyword_res = array();
1405- $change_val = array();
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();
14061409
14071410 foreach ($books as $book) {
14081411
@@ -1425,8 +1428,8 @@
14251428
14261429 }else{
14271430
1428- $data = file_get_contents(CHANGE_PATTERN_PATH);
1429- $dls = explode("<dl>",$data);
1431+ $data = file_get_contents(CHANGE_PATTERN_PATH);
1432+ $dls = explode("<dl>",$data);
14301433
14311434 foreach($dls as $dl){
14321435
@@ -1436,15 +1439,15 @@
14361439 array_push($change_val_res,$change_val[2]);
14371440 }
14381441
1439- $keyword_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$keyword_res);
1440- $change_val_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$change_val_res);
1441- $res = str_replace($keyword_res,$change_val_res,$document);
1442+ $keyword_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$keyword_res);
1443+ $change_val_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$change_val_res);
1444+ $res = str_replace($keyword_res,$change_val_res,$document);
14421445 return $res;
14431446 }
14441447 }
14451448
14461449
1447- function keyword_change_inline($document, $separator = "\n"){
1450+ function keyword_change_inline($document, $separator = "\n"){
14481451
14491452 $before_start = "<!--%";
14501453 $before_end = "%-->";
@@ -1464,9 +1467,9 @@
14641467
14651468 if($record == 0 and ereg("(^$start_tag)([^/]+)($end_tag)",$words,$keyword)){
14661469
1467- $change = "";
1468- $keyword = $before_start.$keyword[2].$before_end;
1469- $record = 1;
1470+ $change = "";
1471+ $keyword = $before_start.$keyword[2].$before_end;
1472+ $record = 1;
14701473 }elseif($record == 1 and !ereg("(^$start_tag\/)(.+)($end_tag)",$words)){
14711474
14721475 $change .= $words . "\n";
@@ -1489,7 +1492,7 @@
14891492 $document_result = str_replace($keyword_res,$change_val_res,$document_result);
14901493 $result = str_replace(array("<><>","><"),array("\n",">\n<"),$document_result);
14911494
1492- return $this->tag_clear($result);
1495+ return $this->tag_clear($result);
14931496 }
14941497
14951498
@@ -1500,17 +1503,17 @@
15001503 if(preg_match_all("/(\[)($tags_inline)(\|)([^\|]+)(\|)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){
15011504 foreach($matches as $key=>$match){
15021505
1503- $element = mb_convert_encoding($match[2],"UTF-8","auto");
1504- $attr = mb_convert_encoding($match[5],"UTF-8","auto");
1505- $value = mb_convert_encoding($match[7],"UTF-8","auto");
1506- $replacement = "<$element $attr>$value</$element>";
1507- $text = str_replace($matches[$key][0],$replacement,$text)."\n";
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";
15081511 }
1509-
1510- $code_hit = true;
1512+
1513+ $code_hit = true;
15111514 }
1512-
1513- return $text;
1515+
1516+ return $text;
15141517 }
15151518
15161519
@@ -1517,69 +1520,69 @@
15171520 function ruby($text){
15181521
15191522 if(preg_match_all("/(ruby>\()([^:]+)(:)([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1520-
1523+
15211524 foreach($matches as $key=>$match){
15221525
1523- $word = mb_convert_encoding($match[2],"UTF-8","auto");
1524- $kana = mb_convert_encoding($match[4],"UTF-8","auto");
1525- $word = str_replace("\n","",$word);
1526- $kana = str_replace("\n","",$kana);
1527- $replacement = "<ruby><rb>$word</rb><rp>(</rp><rt>$kana</rt><rp>)</rp></ruby>";
1528- $text = str_replace($matches[$key][0],$replacement,$text)."\n";
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";
15291532 }
15301533
1531- $code_hit = true;
1534+ $code_hit = true;
15321535 }
1533-
1534- return $text;
1536+
1537+ return $text;
15351538 }
15361539
15371540
15381541 function trackback($text){
15391542
1540- if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;}
1543+ if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;}
15411544
15421545 if(preg_match_all("/(trackback>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1543-
1546+
15441547 foreach($matches as $key=>$match){
1545-
1546- $tabindex = $key + 1;
15471548
1548- switch ($key) {
1549- case 0:
1550- $accesskey = "a";
1551- break;
1552- case 1:
1553- $accesskey = "b";
1554- break;
1555- case 2:
1556- $accesskey = "c";
1557- break;
1558- case 3:
1559- $accesskey = "d";
1560- break;
1561- case 4:
1562- $accesskey = "e";
1563- break;
1564- case 5:
1565- $accesskey = "f";
1566- break;
1567- default:
1568- $accesskey = "g";
1569-
1570- }
1549+ $tabindex = $key + 1;
15711550
1572- $enc = mb_convert_encoding($match[2],"UTF-8","auto");
1573- $enc = urlencode($enc);
1574-
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+
15751578 $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";
15761579
1577- $text = str_replace($matches[$key][0],$replacement,$text)."\n";
1580+ $text = str_replace($matches[$key][0],$replacement,$text)."\n";
15781581 }
15791582
15801583 $code_hit = true;
15811584 }
1582- return $text;
1585+ return $text;
15831586
15841587 }
15851588 /*------------------------------------------------------------------------------+
@@ -1600,8 +1603,8 @@
16001603 }
16011604
16021605 }
1603-
1604- return $text;
1606+
1607+ return $text;
16051608 }
16061609
16071610
@@ -1632,8 +1635,8 @@
16321635 $text= str_replace($matches[$key][0],$quote_comment."{$copy_target}?w={$copy_width}h={$height}alt=YouTube </a>",$text)."\n";
16331636 }
16341637 }
1635-
1636- return $text;
1638+
1639+ return $text;
16371640 }
16381641 /*------------------------------------------------------------------------------+
16391642 * 文字列から、イメージの作成とコーディング処理
@@ -1640,41 +1643,41 @@
16401643 *------------------------------------------------------------------------------*/
16411644 function txt2img($buffer,$separator = "\n"){
16421645
1643- global $default;
1644-
1645- if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{
1646+ global $default;
16461647
1647- include(TEXTTOHTML_FONTS_PATH);
1648- $buffers = explode($separator,$buffer);
1649- $string = "";
1650-
1651- foreach($buffers as $buffer){
1652-
1653- if(preg_match_all("/(txt2img>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){
1654-
1655- foreach($matches as $key=>$match){
1656-
1657- if(ereg("(:)",$match[2])){
1658- list($element,$val_name,$val) =explode(":",$match[2]);
1659-
1660- $replacement = $this->convert_image($val,$$val_name,$element);
1661- }else{
1662- $replacement = $this->convert_image($match[2],$default,"p");
1663- }
1664-
1665- $string .= str_replace($matches[$key][0],$replacement,$buffer);
1666- }
1667-
1668-
1669- }else{
1670-
1671- $string .= $buffer."\n";
1672- }
1673- }
1648+ if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{
16741649
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+
16751678 return $string;
16761679
1677- }
1680+ }
16781681 }
16791682
16801683 /////////////////////////////////////////////////////////////
@@ -1681,16 +1684,16 @@
16811684
16821685 function convert_image( $string , $gd_set = array("gt200001","13","class=\"text2image\"","0"),$element = "p"){
16831686
1684- if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;}
1687+ if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;}
16851688
1686- $file_name = md5($string.$gd_set[0].$gd_set[1]);
1687- $image_file_name = str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png';
1688- $image_file_name = TEXTTOHTML_IMAGE_DIR_URL.$image_file_name;
1689- $image_file_path = TEXTTOHTML_IMAGE_DIR_PATH.str_replace(array('=','"','\\'),array(""),$gd_set[1])."-".$file_name.'.png';
1690- $cache = use_cache($file_name);
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);
16911694
16921695 if($cache[0]){
1693-
1696+
16941697 $result= $cache[1]."\n";
16951698 return $result;
16961699 }else{
@@ -1707,41 +1710,41 @@
17071710
17081711 switch(true){
17091712
1710- case($background_img == "0"): //背景画像を使用しない
1711-
1712- $timg = imagecreate($fontsize * 2 * $len, $fontsize * 2);
1713- $background = ImageColorAllocate($timg, 255, 255, 255);
1714- ImageFill($timg, 0, 0, $background);
1715- $Color = ImageColorAllocate($timg, 0, 0, 0);
1716- break;
1717-
1718- default://背景画像を使用する。
1719-
1720- $timg = imagecreatefrompng(TEXTTOHTML_FONT_DIR_PATH.$background_img);
1721-
1722- $Color = ImageColorAllocate($timg, 0, 0, 0);
1723- break;
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;
17241727 }
17251728
17261729 $vertical_align = $fontsize * 1.5;
1727- $chr = mb_convert_encoding($string,"UTF-8","auto");
1728- $box = ImageTTFText($timg, $fontsize, 0, $indent, $vertical_align, $Color, $font, $chr);
1729- $width = $box[2] + $marginRight;
1730- $timg_resized = ImageCreate($width, $fontsize * 2);
1731-
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+
17321735 imagecopy($timg_resized, $timg, 0, 0, 0, 0, $width, $fontsize * 2);
17331736 imagepng($timg_resized,$image_file_path);
17341737
17351738 if($timg_resized){
17361739
1737- $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";
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";
17381741
1739- save_cache($file_name,$result);
1742+ save_cache($file_name,$result);
17401743
1741- return $result;
1744+ return $result;
17421745 }else{
1743-
1744- return $string;
1746+
1747+ return $string;
17451748 }
17461749
17471750 }
@@ -1795,16 +1798,16 @@
17951798 function encode_query($text){
17961799
17971800 if(preg_match_all("/(query>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1798-
1801+
17991802 foreach($matches as $key=>$match){
18001803
1801- $enc = mb_convert_encoding($match[2],"UTF-8","auto");
1802- $enc = urlencode($enc);
1803- $text= str_replace($matches[$key][0],$enc,$text)."\n";
1804+ $enc = mb_convert_encoding($match[2],"UTF-8","auto");
1805+ $enc = urlencode($enc);
1806+ $text= str_replace($matches[$key][0],$enc,$text)."\n";
18041807 }
18051808
18061809 }
1807- return $text;
1810+ return $text;
18081811 }
18091812
18101813 /*------------------------------------------------------------------------------+
@@ -1813,7 +1816,7 @@
18131816
18141817 function image($text){
18151818
1816- $allow_img_filetype = "(\.gif|\.png|\.jpe?g)";
1819+ $allow_img_filetype = "(\.gif|\.png|\.jpe?g)";
18171820
18181821 $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);
18191822
@@ -1827,65 +1830,65 @@
18271830 if(preg_match_all("/(https?)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)(\()(b:|t:|s:)?([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
18281831
18291832 foreach($matches as $key=>$match){
1830-
1833+
18311834 $cache = use_cache($matches[$key][0],$text);
1832-
1833- if($cache[0]){
1834-
1835- $text = str_replace($matches[$key][0],$cache[1],$text)."\n";
1836- }else{
18371835
1838- switch($match[4]){
1839- case('b:'):
1840- $attr = '_blank';
1841- break;
1842- case('t:'):
1843- $attr = '_top';
1844- break;
1845- case('s:'):
1846- $attr = '_self';
1847- break;
1848-
1849- default:
1850- $attr = '_self';
1851-
1852- break;
1853- }
1854-
1855- $attr = "onclick=\"this.target='$attr';\" onkeypress=\"this.target='$attr';\"";
1856- $link_name = mb_convert_encoding($match[5],"UTF-8","auto");
1857- $url = $match[1].$match[2];
1858-
1859- if(trim($link_name) == 'title'){
1860-
1861- $cache = use_cache($matches[$key][0],$link_name);
1836+ if($cache[0]){
18621837
1863- try{
1864- if(!$data = mb_convert_encoding(file_get_contents($url),"UTF-8","auto")){
1838+ $text = str_replace($matches[$key][0],$cache[1],$text)."\n";
1839+ }else{
18651840
1866- throw new Exception('リンクタイトルを取得できません');
1867- }
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;
18681851
1869- preg_match( "/<title.*?>(.*?)<\/title>/si", $data, $regs );
1870- $linkname = trim(strip_tags($regs[1]));
1871- $link_name = htmlspecialchars($linkname);
1872-
1873- }catch (Exception $e) {
1874- $link_name = $url;
1875- echo '例外: ',$url, $e->getMessage(), "\n";
1876- }
1877-
1878- if(empty($link_name)){ $link_name = $url;}
1879- }
1880-
1881- $link = "<a href=\"".$url."\" $attr >".$link_name."</a>";
1882- $text = str_replace($matches[$key][0],$link,$text)."\n";
1883- }
1884-
1885- }
1886-
1887- }
1852+ default:
1853+ $attr = '_self';
18881854
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+
18891892 return $text;
18901893 }
18911894
@@ -1892,8 +1895,8 @@
18921895
18931896 function name_link($text){
18941897
1895- $text = eregi_replace("(link>)(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)", "<a href=\"\\2\\3\" title=\"\\2\\3\">\\2\\3</a>\n", $text);
1896- $text = mb_ereg_replace("(https?)(://[[:alnum:]\+\$\;\?\.%,!#~*/:@&=_-]+)(()([^)]+)())", "<a href=\"\\1\\2\" title=\"\\1\\2\">\\4</a>\n",$text);
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);
18971900
18981901 return $text;
18991902 }
@@ -1913,9 +1916,9 @@
19131916 if(preg_match_all("/(eval>\[)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){
19141917 foreach($matches as $key=>$match){
19151918
1916- $str = mb_convert_encoding($match[2],"UTF-8","auto");
1917- eval("\$str = $str;");
1918- $text= str_replace($matches[$key][0],$str,$text)."\n";
1919+ $str = mb_convert_encoding($match[2],"UTF-8","auto");
1920+ eval("\$str = $str;");
1921+ $text= str_replace($matches[$key][0],$str,$text)."\n";
19191922 }
19201923
19211924 }
@@ -1975,18 +1978,18 @@
19751978 if(preg_match_all("/(《)([^》]+)(》)/su", $text, $matches, PREG_SET_ORDER)){
19761979
19771980 foreach($matches as $key=>$match){
1978-
1979- $enc = mb_convert_encoding($match[2],"UTF-8","auto");
1980- $replacement = "<a class=\"foot-note\" href=\"#foot-note-$key\" name=\"anchor-foot-note-$key\" id=\"anchor-foot-note-$key\" title=\"脚注へ移動\">[$key]</a>";
1981- $text = str_replace($matches[$key][0],$replacement,$text)."\n";
19821981
1983- array_push($this->footNote, array($key,"anchor-foot-note-$key","foot-note-$key",$enc));
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));
19841987 }
19851988
1986- $code_hit = true;
1989+ $code_hit = true;
19871990 }
19881991
1989- return $text;
1992+ return $text;
19901993 }
19911994
19921995 /*------------------------------------------------------------------------------+
@@ -2031,13 +2034,13 @@
20312034 -------------------------------------------------------------*/
20322035
20332036 function basic_cleaner($buffer,$separator = "\n"){
2034-
2035- global $parm;
2036-
2037+
2038+ global $parm;
2039+
20372040 $buffer = mb_convert_encoding($buffer,"UTF-8","auto");
2038- $file = explode($separator,$buffer);
2039- $text = "";
2040-
2041+ $file = explode($separator,$buffer);
2042+ $text = "";
2043+
20412044 foreach($file as $key => $chk){
20422045
20432046 $chk = str_replace("\0", "", $chk);
@@ -2049,8 +2052,8 @@
20492052 $text .= "\n$chk";
20502053
20512054 }
2052-
2053- return $text;
2055+
2056+ return $text;
20542057 }
20552058 /*------------------------------------------------------------------------------+
20562059 * イメージサイズの検出
@@ -2059,9 +2062,9 @@
20592062
20602063 if(eregi("\.(gif|jpg|png|swc|psd|tiff|bmp|iff|jp2|jpx|jb2|jpc|xbm|wbmp)",$file)){
20612064 list($width, $height, $type, $attr) = getimagesize($file);
2062- return $attr;
2065+ return $attr;
20632066 }else{
2064- return $wide;
2067+ return $wide;
20652068 }
20662069 }
20672070
@@ -2104,59 +2107,59 @@
21042107 *------------------------------------------------------------------------------*/
21052108 function style_set($str){
21062109
2107- $tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
2108- $i = 0;
2109- $break = "";
2110- $str = str_replace("<","@@@@@<",$str);
2110+ $tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
2111+ $i = 0;
2112+ $break = "";
2113+ $str = str_replace("<","@@@@@<",$str);
21112114 $result ="";
2112- $lines = explode("@@@@@",$str);
2115+ $lines = explode("@@@@@",$str);
21132116
2114- foreach($lines as $key=>$line){
2117+ foreach($lines as $key=>$line){
21152118
21162119 if(preg_match("/(<\/?(xml|html|body))/mi",$line) ){
21172120
2118- $i = 0;
2119- $space = str_repeat($tab,$i);
2120- $break = "<br />\n";
2121+ $i = 0;
2122+ $space = str_repeat($tab,$i);
2123+ $break = "<br />\n";
21212124
21222125 }elseif(preg_match("/(<\/?(xml|html|head|body|script|!doctype))/mi",$line) ){
21232126
2124- $i = 2;
2125- $space = str_repeat($tab,$i);
2126- $break = "<br />\n";
2127+ $i = 2;
2128+ $space = str_repeat($tab,$i);
2129+ $break = "<br />\n";
21272130 }elseif(preg_match("/(<\/)/",$line) ){
21282131
21292132 if($i<0){
2130- $i = 0;
2131- }
2132-
2133- $space = str_repeat($tab,$i);
2134- $break = "<br />\n";
2135- $i--;
2133+ $i = 0;
2134+ }
2135+
2136+ $space = str_repeat($tab,$i);
2137+ $break = "<br />\n";
2138+ $i--;
21362139 }elseif(preg_match("/(\/>?)/",$line) ){
21372140
21382141 if($i<0){
2139- $i = 0;
2140- }
2141-
2142- $space = str_repeat($tab,$i);
2143- $break = "<br />\n";
2142+ $i = 0;
2143+ }
2144+
2145+ $space = str_repeat($tab,$i);
2146+ $break = "<br />\n";
21442147 }else{
2145- $break = "<br />\n";
2148+ $break = "<br />\n";
21462149
21472150 if($i<0){
2148- $i = 0;
2149- }
2150-
2151- $space = str_repeat($tab,$i);
2151+ $i = 0;
2152+ }
2153+
2154+ $space = str_repeat($tab,$i);
21522155 $i++;
21532156
21542157 }
21552158
2156- $result .= $space.htmlspecialchars($line).$break;
2159+ $result .= $space.htmlspecialchars($line).$break;
21572160 }
21582161
2159- return $this->tag_clear($result);
2162+ return $this->tag_clear($result);
21602163 }
21612164
21622165 /* ------------------------------------------------------------
@@ -2173,7 +2176,7 @@
21732176 $text = str_replace("\r","\n",$text);
21742177 $text = preg_replace("/(\n){2,}/","\n\n",$text);
21752178
2176- return $text;
2179+ return $text;
21772180 }
21782181
21792182 //end class
@@ -2246,14 +2249,14 @@
22462249 //wikipedia
22472250 function simpleapi_wikipedia($replacement, $count = 1){
22482251
2249- $result = unserialize($replacement);
2250- $results = "<div style=\"margin:1em;\">";
2252+ $result = unserialize($replacement);
2253+ $results = "<div style=\"margin:1em;\">";
22512254
22522255 for($i=0;$i<$count;$i++){
2253-
2254- $title = $result[$i]['title'];
2255- $body = $result[$i]['body'];
2256- $results .= "<strong>Wikipedia:{$title}</strong><blockquote>".nl2br($body)."</blockquote>";
2256+
2257+ $title = $result[$i]['title'];
2258+ $body = $result[$i]['body'];
2259+ $results .= "<strong>Wikipedia:{$title}</strong><blockquote>".nl2br($body)."</blockquote>";
22572260 }
22582261
22592262 return str_replace(array("<br>","<br/>"),"<br />",$results)."\n</div>";
@@ -2270,32 +2273,32 @@
22702273 ////////////////////////////////////////////////////////////////////////////////////
22712274 function use_cache($name){
22722275
2273- if(!defined('CACHE_LITE_PATH')){return array(false,"");}
2274-
2276+ if(!defined('CACHE_LITE_PATH')){return array(false,"");}
2277+
22752278 require_once(CACHE_LITE_PATH);
22762279
2277- $options = array(
2278- 'cacheDir' => CACHE_DIR_PATH,
2279- 'lifeTime' => CACHE_LIFE_TIME,
2280- );
2280+ $options = array(
2281+ 'cacheDir' => CACHE_DIR_PATH,
2282+ 'lifeTime' => CACHE_LIFE_TIME,
2283+ );
22812284
2282- $Cache_Lite = new Cache_Lite($options);
2285+ $Cache_Lite = new Cache_Lite($options);
22832286
2284- if(!CACHE_SWITCH){
2285-
2286- $Cache_Lite->clean();
2287- return array(false,"");
2288- }
2287+ if(!CACHE_SWITCH){
22892288
2289+ $Cache_Lite->clean();
2290+ return array(false,"");
2291+ }
2292+
22902293 $name = md5($name);
22912294
2292- if ($data = $Cache_Lite->get($name)){
2293- $result = $data;
2294- $flag = true;
2295- }else {
2295+ if ($data = $Cache_Lite->get($name)){
2296+ $result = $data;
2297+ $flag = true;
2298+ }else {
22962299
2297- $flag = false;
2298- }
2300+ $flag = false;
2301+ }
22992302
23002303 return array($flag,$data);
23012304 }
@@ -2302,59 +2305,59 @@
23022305
23032306 function save_cache($name,$value){
23042307
2305- if(!defined('CACHE_LITE_PATH')){return array(false,$value);}
2308+ if(!defined('CACHE_LITE_PATH')){return array(false,$value);}
23062309
23072310 $name = md5($name);
23082311
23092312 require_once(CACHE_LITE_PATH);
23102313
2311- $options = array(
2312- 'cacheDir' => CACHE_DIR_PATH,
2313- 'lifeTime' => CACHE_LIFE_TIME,
2314- );
2314+ $options = array(
2315+ 'cacheDir' => CACHE_DIR_PATH,
2316+ 'lifeTime' => CACHE_LIFE_TIME,
2317+ );
23152318
23162319 $Cache_Lite = new Cache_Lite($options);
2317-
2318- if(!CACHE_SWITCH){
2319-
2320- $Cache_Lite->clean();
2321- return array(false,$value);
2322- }
23232320
2324- if ($data = $Cache_Lite->get($name)){
2325- $result = $data;
2326- $flag = true;
2327- }else {
2321+ if(!CACHE_SWITCH){
23282322
2329- $Cache_Lite->save($value,$name);
2330- //print_r($Cache_Lite);
2331- $result = $value;
2332- $flag = false;
2333- }
2323+ $Cache_Lite->clean();
2324+ return array(false,$value);
2325+ }
23342326
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+
23352338 return array($flag,$value);
23362339 }
23372340
23382341 function html_document1($ini_array,$documents,$navi="",$source = ""){
23392342
2340- global $content_name;
2341- global $source;
2342- global $campany_data;
2343-
2344- $charset = $ini_array['html_header']['charset'];
2345- $author = $ini_array['html_header']['author'];
2346- $keyword = $ini_array['html_header']['keyword'];
2347- $description = $ini_array['html_header']['description'];
2348- $mail = $ini_array['html_header']['mail'];
2349- $stylesheet = $ini_array['html_header']['stylesheet'];
2350- $style_media = $ini_array['html_header']['style_media'];
2351- $navi_start = $ini_array['html_header']['start'];
2352- $navi_prev = $ini_array['html_header']['prev'];
2353- $navi_next = $ini_array['html_header']['next'];
2354- $navi_help = $ini_array['html_header']['help'];
2355- $title = $ini_array['html_header']['title'];
2356- $embed = $ini_array['html_header']['embed'];
2343+ global $content_name;
2344+ global $source;
2345+ global $campany_data;
23572346
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+
23582361 $html=<<<DOC
23592362 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
23602363 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Show on old repository browser