• R/O
  • SSH
  • HTTPS

text2html: Commit


Commit MetaInfo

Revisión81 (tree)
Tiempo2008-08-27 12:06:13
Autortenman

Log Message

allow_url_fopenがOffの場合にエスケープ

Cambiar Resumen

Diferencia incremental

--- trunk/text2html/scripts/trans.php (revision 80)
+++ trunk/text2html/scripts/trans.php (revision 81)
@@ -1,7 +1,7 @@
11 <?php
22 /*------------------------------------------------------------------------------+
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+
55 text2html てきでこ Akio Tenman. <http://text2html.sourceforge.jp/>
66 Copyright (C) 2008 Akio Tenman <tenman@users.sourceforge.jp>
77
@@ -21,19 +21,19 @@
2121 //このアプリで、外部API等を参照する場合、allow_url_fopenはtrueである必要があります。
2222
2323 mb_language( 'Japanese' );
24-
24+
2525 if(preg_match("/^[A-z]:.+/",__FILE__)){
26- $separater = '\\';
26+ $separater = '\\';
2727 }else{
28- $separater = '/';
28+ $separater = '/';
2929 }
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']).'/';
3333 }
3434
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;
3737 }
3838
3939 if(!isset($cache)){
@@ -51,7 +51,7 @@
5151
5252 //画像保管用ディレクトリ
5353 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/');
5555 //イメージコピー用スクリプト
5656 define("TEXTTOHTML_COPY_IMG_WIDTH","100");
5757 define("IMAGE_IMPORT_PATH", $text2html_dir_path."import{$separater}");
@@ -75,7 +75,9 @@
7575 define("HTML_RULE_CONFIG_FILE_PATH",TEXTTOHTML_SCRIPTS_DIR_PATH."html.ini");
7676 define("TEXTTOHTML_FONT_DIR_PATH",$text2html_dir_path."font{$separater}");
7777 define("TEXTTOHTML_FONTS_PATH",TEXTTOHTML_FONT_DIR_PATH."fonts.inc");
78+
7879
80+
7981 //MEMO
8082 /*----------------------------------------------------------------------+
8183 * get_querys()で使用する配列の説明。
@@ -123,47 +125,47 @@
123125 var $attr;
124126 var $content_attr;
125127 var $description;
126- var $copy_target;
127- var $copy_uri;
128+ var $copy_target;
129+ var $copy_uri;
128130
129131
130- function trans($document){
132+ function trans($document){
131133
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);
135137 }
136138
137139 function delete_break($matches){
138140 $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;
149151 }
150152
151153 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);
155157
156- return $text;
158+ return $text;
157159
158160 }
159161
160162 function get_querys($text){
161163
162- if(ini_get("allow_url_fopen") == false){
164+ if(ini_get("allow_url_fopen") == false){
165+
166+ return $text;
167+ }
163168
164- return $text;
165- }
166-
167169 //重複名の誤変換を避けるために、文字数の長い順にソート
168170 $get_querys = array(
169171 /*キー名は10文字未満*/
@@ -210,22 +212,22 @@
210212 'url'=>'http://www.odekake.biz/branch/?date=+++E_KEYWORD+++',
211213 "response"=>"+++CONTENTS+++\n"),
212214 );
213-
215+
214216 uksort($get_querys,"text2html_cmp");
215217
216218 if(isset($get_querys)){
217219 foreach($get_querys as $key=>$val){
218220 if(preg_match_all("/($key>\()([^\)]+)(\))/u", $text, $matches, PREG_SET_ORDER)){
219-
221+
220222 foreach($matches as $key=>$match){
221-
223+
222224 $cache = use_cache($matches[$key][0]);
223225 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";
226228 }else{
227-
228- $enc = mb_convert_encoding($match[2],$val['charset'],"auto");
229+
230+ $enc = mb_convert_encoding($match[2],$val['charset'],"auto");
229231 $no_enc = mb_convert_encoding($match[2],"UTF-8","auto");
230232 $no_enc = str_replace("\n","",$no_enc);
231233
@@ -233,7 +235,7 @@
233235
234236 case('link'):
235237
236- $enc = urlencode($enc);
238+ $enc = urlencode($enc);
237239 $replacement = mb_convert_encoding($val['response'],"UTF-8","auto");
238240 $replacement = str_replace(array("+++E_KEYWORD+++","+++KEYWORD+++"),array($enc,$no_enc),$val['response']);
239241 $replacement = trim($replacement);
@@ -241,24 +243,24 @@
241243
242244 case('contents'):
243245
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+
250252 try{
251253
252254 if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){
253-
255+
254256 throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。');
255257 }
256-
258+
257259 socket_set_timeout($fp, 3);
258260 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+
262264 if ($stat["timed_out"]) {
263265
264266 throw new Exception('タイムアウトしました。');
@@ -267,77 +269,77 @@
267269 fclose($fp);
268270
269271 }catch (Exception $e) {
270-
272+
271273 $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
272274 echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n";
273275 }
274276
275277 break;
276-
278+
277279 case('query'):
278280
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 .= '&amp;'.urlencode($hit[1]).$hit[2].urlencode($hit[3]);
291+ }
292+
293+ }
282294
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']);
284298
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-
297299 break;
298300
299301 case('contents_rebuild'):
300302
301- $enc = urlencode($enc);
303+ $enc = urlencode($enc);
302304 $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']);
304306
305- $host = parse_url($target);
306- $host = $host['host'];
307-
307+ $host = parse_url($target);
308+ $host = $host['host'];
309+
308310 try{
309311
310312 if(!$fp = fsockopen ($host, 80, $errno, $errstr, 5)){
311-
313+
312314 throw new Exception('を、取得できません。サービスを停止してるかどうか確認してください。');
313315 }
314-
316+
315317 socket_set_timeout($fp, 3);
316318 fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$_SERVER['HTTP_HOST']."\r\n\r\n");
317319
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);
321323
322324 $stat = socket_get_status($fp);
325+
326+ if ($stat["timed_out"]) {
327+
328+ throw new Exception('タイムアウトしました。');
329+ }
323330
324- if ($stat["timed_out"]) {
325-
326- throw new Exception('タイムアウトしました。');
327- }
328-
329331 fclose($fp);
330332
331333
332334 }catch (Exception $e) {
333-
334- $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
335+
336+ $errstr = mb_convert_encoding($errstr,"UTF-8","auto");
335337 echo '<div style="text-align:left;padding:2em;background:#FF99FF;">例外: ',$target,$e->getMessage(), "\n</div>\n";
336338 }
337339 break;
338340
339341 }
340-
342+
341343 save_cache($matches[$key][0],$replacement);
342344
343345 $text = str_replace($matches[$key][0],$replacement,$text)."\n";
@@ -360,16 +362,16 @@
360362 }
361363
362364 function text2html(){
363-
365+
364366 global $benchmark;
365367 global $source;
366- global $content_name;
367-
368+ global $content_name;
369+
368370 $pear_file = "";
369371 $timer = false;
370- $buffer = $this->document;
372+ $buffer = $this->document;
371373 $output_enc = "UTF-8";
372-
374+
373375 if(isset($benchmark) and $benchmark == true){
374376 include_once ("Benchmark/Timer.php");
375377 $timer = true;
@@ -388,7 +390,7 @@
388390 if($timer){ $oTimer->setMarker( 'text2html_table' );}
389391 //blockquote
390392 $buffer = $this->text2html_code($buffer,"\n","pre",'code:','code','','class="source"','souce');
391-
393+
392394 if($timer){ $oTimer->setMarker( 'text2html_code' );}
393395 //heading
394396 $buffer = $this->text2html_element($buffer,"\n","h6",'\*\*\*\*\*','a','', 'href="#TOP"','h6');
@@ -423,7 +425,7 @@
423425 asort($this->header_info);
424426 $this->midasilist = "<a name=\"TOP\" id=\"TOP\" >head line</a>\n";
425427 $kihou = "";
426-
428+
427429 foreach($this->header_info as $key=>$link){
428430
429431 $kihou = str_repeat ('+', $link[1]-1);
@@ -443,17 +445,17 @@
443445 break;
444446
445447 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);
450452
451453 break;
452454
453455 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>";
457459
458460 break;
459461 }
@@ -475,7 +477,7 @@
475477
476478 $buffer = $this->keyword_change($buffer,"\n");
477479 if($timer){$oTimer->setMarker( 'keyword_change' );}
478-
480+
479481 $buffer = $this->read_php($buffer,"\n");
480482 if($timer){$oTimer->setMarker( 'read_php' );}
481483
@@ -520,7 +522,7 @@
520522
521523 $buffer = $this->clear_both($buffer,"\n");
522524 if($timer){$oTimer->setMarker( 'clear_both' );}
523-
525+
524526 $buffer = $this->get_querys($buffer,"\n");
525527 if($timer){$oTimer->setMarker( 'get_querys' );}
526528
@@ -529,7 +531,7 @@
529531 $buffer = $this->text2html_list($buffer,"\n","ul",'※','li','style="font:size:70%;color:#66f;"',"style=\"list-style-type:none;\"","caution");
530532 if($timer){$oTimer->setMarker( 'list' );}
531533
532- //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote');
534+ //$buffer = $this->text2html_list2($buffer,"\n","blockquote",'引用:','p','','','quote');
533535 //入れ子可
534536 $buffer = $this->text2html_list($buffer,"\n","blockquote",'>','p','','','quote');
535537 if($timer){$oTimer->setMarker( 'list_blockquote' );}
@@ -544,7 +546,7 @@
544546 if($timer){$oTimer->setMarker( 'result_encoding' );}
545547
546548 if(isset($source) and $source == true){
547-
549+
548550 $source = $this->my_wordwrap($text);
549551 $source = str_replace("&#47;",'/',$source);
550552
@@ -551,7 +553,7 @@
551553 $this->source = '<div class="source_view">'.
552554 $this->style_set($source)."\n</div>";
553555 }else{
554-
556+
555557 $this->source = "";
556558 }
557559 if($timer){$oTimer->setMarker( 'create_source' );}
@@ -571,17 +573,17 @@
571573
572574 function change_word($text){
573575
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;
576578
577579 if(file_exists($file)){
578-
580+
579581 $chenge_words = file($file);
580582
581583 foreach($chenge_words as $chenge_word){
584+
585+ $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto");
582586
583- $chenge_word = mb_convert_encoding($chenge_word, "UTF-8","auto");
584-
585587 if(strstr($chenge_word,"#")){
586588 list($before, $after) = explode("#", $chenge_word);
587589 $text = str_replace($before , trim($after), $text);
@@ -590,7 +592,7 @@
590592
591593 return $text;
592594 }else{
593-
595+
594596 return $text;
595597 }
596598
@@ -637,7 +639,7 @@
637639 $line = $line."\n";
638640 if($current_flag = preg_match("/^([$wm]+)(.+)/u",$line,$current)){
639641
640- $marker_length = @strlen($current[1]);
642+ $marker_length = @strlen($current[1]);
641643
642644
643645 //リスト変換のオンオフ判定
@@ -907,12 +909,12 @@
907909 $description = $description.$content_name;
908910 }
909911
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 = "";
916918
917919 foreach($lines as $list){
918920
@@ -922,30 +924,30 @@
922924
923925 if(!empty($content)){
924926
925- $start_content = "<$content>";
926- $end_content = "</$content>\n";
927+ $start_content = "<$content>";
928+ $end_content = "</$content>\n";
927929 }else{
928-
929- $start_content = "";
930- $end_content = "";
930+
931+ $start_content = "";
932+ $end_content = "";
931933 }
932934
933935 $res = $this->text2html_list($regs[2],$this->separator,$this->element,$this->wm,$this->content,$this->attr,$this->content_attr,$this->description);
934936
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}>";
938940
939941 }elseif(!empty($end_tag)){
940942
941- $list = $end_tag."\n".$list;
943+ $list = $end_tag."\n".$list;
942944 $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."\">";
945947 }else{
948+
949+ $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
946950
947- $start_tag = "<{$element} $attr id=\"$element-$description-".$this->content_no."\">";
948-
949951 }
950952
951953 $result .= $list;
@@ -960,36 +962,36 @@
960962 $element = $this->element;
961963 $wm = $this->wm;
962964 $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 = "";
968970
969- foreach($lines as $key=>$list){
971+ foreach($lines as $key=>$list){
970972
971- $list = $list. "\n";
973+ $list = $list. "\n";
972974
973975 if(ereg("(^$wm{1})(.+)",$list,$regs)){
974976
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+ }
976990
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-
989991 $list= str_replace($regs[0],$start_tag.$start_content.trim($this->sublist($regs[2]))."\n".$end_content,$list);
990992
991993 $start = false;
992-
994+
993995 }elseif(!empty($end_tag)){
994996
995997 $list = $end_tag. "\n".$list;
@@ -996,9 +998,9 @@
996998 }
997999 $result .= $list;
9981000
999- }
1001+ }
10001002
1001- return $this->tag_clear($result);
1003+ return $this->tag_clear($result);
10021004 }
10031005
10041006 function text2html_code($document = "", $separator = "\n",$element = "pre",$wm = 'code:',$content = 'code',$attr = '',$content_attr = '',$description = ''){
@@ -1010,21 +1012,21 @@
10101012 global $content_name;
10111013
10121014 if(!empty($content_name) and !empty($description)){
1013- $description = $description.'-'.$content_name;
1015+ $description = $description.'-'.$content_name;
10141016 }else{
1015- $description = $description.$content_name;
1017+ $description = $description.$content_name;
10161018 }
10171019
1018- $i = 0;
1019- $lines = explode($separator,$document);
1020- $start = true;
1020+ $i = 0;
1021+ $lines = explode($separator,$document);
1022+ $start = true;
10211023 $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 = "";
10251027
10261028 foreach($lines as $list){
1027-
1029+
10281030 $list = $list. "\n";
10291031
10301032 if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){
@@ -1038,26 +1040,26 @@
10381040 $end_content = "\n";
10391041 }
10401042
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}>";
1043+ $doc = $regs[2];
1044+ $doc = $this->my_wordwrap($doc);
1045+ $doc = htmlspecialchars($doc);
1046+ $doc = str_replace(array('/',"\t",'$','<'),array("&#47;"," ",'&#36;','&#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}>";
10491051
10501052 }elseif(!empty($end_tag)){
1051-
1052- $list = $end_tag."\n".$list;
1053+
1054+ $list = $end_tag."\n".$list;
10531055 $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;
10571059 }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;
10611063 }
10621064
10631065 $result .= $list;
@@ -1086,19 +1088,19 @@
10861088 $description = $description.$content_name;
10871089 }
10881090
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>";
10921094
10931095 foreach($lines as $key=>$list){
10941096
1095- $list = $list. $separator;
1096- $write_group = false;
1097+ $list = $list. $separator;
1098+ $write_group = false;
10971099
10981100 if(ereg("(^$wm{1})(.+)",$list,$regs)){
10991101
11001102 if(preg_match("/({$wm}summary:)(.+)/um",$list,$match)){
1101-
1103+
11021104 if($end_tag){
11031105
11041106 $start_tag = "</table>\n<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">";
@@ -1108,9 +1110,9 @@
11081110 $start_tag = "<{$element} $attr summary=\"$match[2]\" id=\"table-$description-".$this->content_no."\">";
11091111 }
11101112
1111- $write_group = true;
1112- unset($regs[2]);
1113- $list = "";
1113+ $write_group = true;
1114+ unset($regs[2]);
1115+ $list = "";
11141116
11151117 }else{
11161118
@@ -1119,20 +1121,20 @@
11191121 if(isset($regs[2])){
11201122
11211123 $fields = explode('|',$regs[2]);
1122- $col_no =1;
1124+ $col_no =1;
11231125 foreach($fields as $colkey=>$field){
1124-
1126+
11251127 $ht_field .= "<td class=\"col{$col_no} row{$row_no}\" id=\"tbl".$this->content_no."{$col_no}{$row_no}\">$field</td>";
11261128 $col_no++;
11271129
11281130 }
1129-
1131+
11301132 $row_no++;
11311133 }
11321134
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";
11361138
11371139 if(!isset($lines[$key + 1]) or !ereg("(^$wm{1})(.+)",$lines[$key + 1])){
11381140
@@ -1141,22 +1143,22 @@
11411143 }
11421144 }
11431145 }elseif($end_tag){
1146+
1147+ $list = $end_tag."\n".$list;
1148+ $row_no = 1;
11441149
1145- $list = $end_tag."\n".$list;
1146- $row_no = 1;
1147-
11481150 $this->content_no++;
11491151
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;
11521154 }else{
1153-
1155+
11541156 $start_tag = "<{$element} $attr id=\"table-$description-".$this->content_no."\">";
11551157 }
11561158
11571159 $result .= $list;
11581160 }
1159- return $this->tag_clear($result);
1161+ return $this->tag_clear($result);
11601162 }
11611163
11621164 function text2html_element($document, $separator = "\n",$element = "h2",$wm = '*',$content = 'span',$attr = '',$content_attr = '',$description = ''){
@@ -1164,16 +1166,16 @@
11641166 global $content_name;
11651167
11661168 if(!empty($content_name) and !empty($description)){
1167- $description = $description.'-'.$content_name;
1169+ $description = $description.'-'.$content_name;
11681170 }else{
1169- $description = $description.$content_name;
1171+ $description = $description.$content_name;
11701172 }
11711173
11721174 $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."\" >";
11771179 $this->content_no = 1;
11781180
11791181 foreach($lines as $key => $list){
@@ -1181,43 +1183,43 @@
11811183 $list = $list. "\n";
11821184
11831185 if(preg_match("/(^$wm{1})(.+)/um",$list,$regs)){
1184-
1186+
11851187 if(!empty($content)){
1186-
1188+
11871189 $content_start = "<$content $content_attr >";
11881190 $content_end = "</$content>";
11891191 }else{
1190-
1192+
11911193 $content_start = "";
11921194 $content_end = "";
11931195 }
1196+
1197+ $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list);
1198+ $start_tag = "";
1199+ $end_tag = "</{$element}>\n";
11941200
1195- $list = str_replace($regs[0],$start_tag.$content_start.$regs[2].$content_end,$list);
1196- $start_tag = "";
1197- $end_tag = "</{$element}>\n";
1198-
11991201 //見出しリスト
12001202
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);
12041206 array_push($this->header_info,array($key,trim($match[1]),"$element-$description-".$this->content_no,$regs[2]));
12051207 }
12061208
12071209 }elseif(!empty($end_tag)){
1208-
1209- $list = $end_tag."\n".$list;
1210+
1211+ $list = $end_tag."\n".$list;
12101212 $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."\" >";
12131215 }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."\" >";
12161218 }
1217- $result .= $list;
1219+ $result .= $list;
12181220 }
12191221
1220- return $this->tag_clear($result);
1222+ return $this->tag_clear($result);
12211223 }
12221224
12231225 function paragraf($document, $separator = "\n\n",$element = "p",$wm = '',$content = '',$attr = '',$content_attr = '',$description = 'paragraph'){
@@ -1234,43 +1236,43 @@
12341236
12351237 foreach($checks as $val){
12361238
1237- $check[] = "<$val";
1238- $check[] = "$val>";
1239- $check[] = "</$val";
1239+ $check[] = "<$val";
1240+ $check[] = "$val>";
1241+ $check[] = "</$val";
12401242
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";
12441246 }
12451247
12461248
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;
12611263
12621264 foreach($lines as $key => $list){
1263-
1265+
12641266 $list = $list."\n\n";
12651267
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+ }
12701272
1271- if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){
1273+ if(preg_match("/(^($wm).*)/um",$list,$regs) and $cdata_zone == false ){
12721274
1273- $content_start = "";
1275+ $content_start = "";
12741276
12751277 if(isset($lines[$key + 1]) and $lines[$key + 1] == true){
12761278
@@ -1280,19 +1282,19 @@
12801282 $content_end = "";
12811283 }
12821284
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+ }
12871297
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-
12961298 }elseif(!empty($end_tag) ){
12971299
12981300 $list = $end_tag."\n".$list;
@@ -1318,9 +1320,9 @@
13181320 }
13191321
13201322 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+
13241326 $copy_width = TEXTTOHTML_COPY_IMG_WIDTH;
13251327
13261328 if(preg_match_all("/(copy>\()([^\)]+)(\))/", $buffer, $matches, PREG_SET_ORDER)){
@@ -1327,20 +1329,20 @@
13271329
13281330 foreach($matches as $key=>$match){
13291331
1330- $cache = use_cache($matches[$key][0],$buffer);
1332+ $cache = use_cache($matches[$key][0],$buffer);
13311333
13321334 if($cache[0]){
13331335
1334- $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n";
1336+ $buffer= str_replace($matches[$key][0],$cache[1],$buffer)."\n";
13351337 }else{
13361338 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]));
13371345
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-
13441346 if($size[0] > $copy_width){
13451347 $aspect = @round($size[1]/$size[0],2);
13461348 $height = @round($copy_width * $aspect,0);
@@ -1348,42 +1350,42 @@
13481350 $copy_width = $size[0];
13491351 $height = $size[1];
13501352 }
1351-
1353+
13521354 $gdimg = imagecreatetruecolor($copy_width,$height);
13531355
13541356 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+ }
13601362 }
1361-
1363+
13621364 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+ }
13681370 }
13691371 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+ }
13751377 }
13761378 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+ }
13821384 }
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+
13831388
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-
13871389 save_cache($matches[$key][0],$quote_comment."<img src=\"".$copy_target_url."\" width=\"$copy_width\" height=\"$height\" alt=\"copyed image\" /></a>");
13881390 }
13891391
@@ -1395,17 +1397,17 @@
13951397
13961398 function keyword_change($document){
13971399
1398- $keyword_res = array();
1399- $change_val_res = array();
1400+ $keyword_res = array();
1401+ $change_val_res = array();
14001402
14011403 if(phpversion('domDocument')){
14021404
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();
14091411
14101412 foreach ($books as $book) {
14111413
@@ -1428,8 +1430,8 @@
14281430
14291431 }else{
14301432
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);
14331435
14341436 foreach($dls as $dl){
14351437
@@ -1439,15 +1441,15 @@
14391441 array_push($change_val_res,$change_val[2]);
14401442 }
14411443
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);
1444+ $keyword_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$keyword_res);
1445+ $change_val_res = str_replace(array("&gt;","&lt;","&amp;","&quot;"),array(">","<",'&','"'),$change_val_res);
1446+ $res = str_replace($keyword_res,$change_val_res,$document);
14451447 return $res;
14461448 }
14471449 }
14481450
14491451
1450- function keyword_change_inline($document, $separator = "\n"){
1452+ function keyword_change_inline($document, $separator = "\n"){
14511453
14521454 $before_start = "<!--%";
14531455 $before_end = "%-->";
@@ -1467,9 +1469,9 @@
14671469
14681470 if($record == 0 and ereg("(^$start_tag)([^/]+)($end_tag)",$words,$keyword)){
14691471
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;
14731475 }elseif($record == 1 and !ereg("(^$start_tag\/)(.+)($end_tag)",$words)){
14741476
14751477 $change .= $words . "\n";
@@ -1492,7 +1494,7 @@
14921494 $document_result = str_replace($keyword_res,$change_val_res,$document_result);
14931495 $result = str_replace(array("<><>","><"),array("\n",">\n<"),$document_result);
14941496
1495- return $this->tag_clear($result);
1497+ return $this->tag_clear($result);
14961498 }
14971499
14981500
@@ -1503,17 +1505,17 @@
15031505 if(preg_match_all("/(\[)($tags_inline)(\|)([^\|]+)(\|)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){
15041506 foreach($matches as $key=>$match){
15051507
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";
15111513 }
1512-
1513- $code_hit = true;
1514+
1515+ $code_hit = true;
15141516 }
1515-
1516- return $text;
1517+
1518+ return $text;
15171519 }
15181520
15191521
@@ -1520,69 +1522,69 @@
15201522 function ruby($text){
15211523
15221524 if(preg_match_all("/(ruby>\()([^:]+)(:)([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1523-
1525+
15241526 foreach($matches as $key=>$match){
15251527
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";
15321534 }
15331535
1534- $code_hit = true;
1536+ $code_hit = true;
15351537 }
1536-
1537- return $text;
1538+
1539+ return $text;
15381540 }
15391541
15401542
15411543 function trackback($text){
15421544
1543- if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;}
1545+ if(!defined('TEXTTOHTML_TRACKBACK_URL')){return $text;}
15441546
15451547 if(preg_match_all("/(trackback>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1546-
1548+
15471549 foreach($matches as $key=>$match){
1550+
1551+ $tabindex = $key + 1;
15481552
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+ }
15501576
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+
15781580 $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";
15791581
1580- $text = str_replace($matches[$key][0],$replacement,$text)."\n";
1582+ $text = str_replace($matches[$key][0],$replacement,$text)."\n";
15811583 }
15821584
15831585 $code_hit = true;
15841586 }
1585- return $text;
1587+ return $text;
15861588
15871589 }
15881590 /*------------------------------------------------------------------------------+
@@ -1603,8 +1605,8 @@
16031605 }
16041606
16051607 }
1606-
1607- return $text;
1608+
1609+ return $text;
16081610 }
16091611
16101612
@@ -1635,8 +1637,8 @@
16351637 $text= str_replace($matches[$key][0],$quote_comment."{$copy_target}?w={$copy_width}h={$height}alt=YouTube </a>",$text)."\n";
16361638 }
16371639 }
1638-
1639- return $text;
1640+
1641+ return $text;
16401642 }
16411643 /*------------------------------------------------------------------------------+
16421644 * 文字列から、イメージの作成とコーディング処理
@@ -1643,41 +1645,41 @@
16431645 *------------------------------------------------------------------------------*/
16441646 function txt2img($buffer,$separator = "\n"){
16451647
1646- global $default;
1648+ global $default;
1649+
1650+ if(!defined('TEXTTOHTML_FONTS_PATH') ){return $buffer;}else{
16471651
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+ }
16491679
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-
16781680 return $string;
16791681
1680- }
1682+ }
16811683 }
16821684
16831685 /////////////////////////////////////////////////////////////
@@ -1684,16 +1686,16 @@
16841686
16851687 function convert_image( $string , $gd_set = array("gt200001","13","class=\"text2image\"","0"),$element = "p"){
16861688
1687- if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;}
1689+ if(!defined('TEXTTOHTML_IMAGE_DIR_URL')){return $string;}
16881690
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);
16941696
16951697 if($cache[0]){
1696-
1698+
16971699 $result= $cache[1]."\n";
16981700 return $result;
16991701 }else{
@@ -1710,41 +1712,41 @@
17101712
17111713 switch(true){
17121714
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;
17271729 }
17281730
17291731 $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+
17351737 imagecopy($timg_resized, $timg, 0, 0, 0, 0, $width, $fontsize * 2);
17361738 imagepng($timg_resized,$image_file_path);
17371739
17381740 if($timg_resized){
17391741
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";
17411743
1742- save_cache($file_name,$result);
1744+ save_cache($file_name,$result);
17431745
1744- return $result;
1746+ return $result;
17451747 }else{
1746-
1747- return $string;
1748+
1749+ return $string;
17481750 }
17491751
17501752 }
@@ -1798,16 +1800,16 @@
17981800 function encode_query($text){
17991801
18001802 if(preg_match_all("/(query>\()([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
1801-
1803+
18021804 foreach($matches as $key=>$match){
18031805
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";
18071809 }
18081810
18091811 }
1810- return $text;
1812+ return $text;
18111813 }
18121814
18131815 /*------------------------------------------------------------------------------+
@@ -1816,7 +1818,7 @@
18161818
18171819 function image($text){
18181820
1819- $allow_img_filetype = "(\.gif|\.png|\.jpe?g)";
1821+ $allow_img_filetype = "(\.gif|\.png|\.jpe?g)";
18201822
18211823 $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);
18221824
@@ -1830,65 +1832,70 @@
18301832 if(preg_match_all("/(https?)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)(\()(b:|t:|s:)?([^\)]+)(\))/", $text, $matches, PREG_SET_ORDER)){
18311833
18321834 foreach($matches as $key=>$match){
1833-
1835+
18341836 $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{
18351842
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"){
18371869
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")){
18401872
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+ }
18511875
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+ }
18541898
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-
18921899 return $text;
18931900 }
18941901
@@ -1895,8 +1902,8 @@
18951902
18961903 function name_link($text){
18971904
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);
19001907
19011908 return $text;
19021909 }
@@ -1916,9 +1923,9 @@
19161923 if(preg_match_all("/(eval>\[)([^\]]+)(\])/", $text, $matches, PREG_SET_ORDER)){
19171924 foreach($matches as $key=>$match){
19181925
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";
19221929 }
19231930
19241931 }
@@ -1932,6 +1939,8 @@
19321939
19331940 $str = mb_convert_encoding($match[2],"UTF-8","auto");
19341941 if(isset($str) and !empty($str)){
1942+
1943+ if(ini_get('allow_url_fopen') == "1"){
19351944
19361945 try {
19371946
@@ -1942,6 +1951,10 @@
19421951 } catch (Exception $e) {
19431952 echo '例外発生: ', $e->getMessage(), "\n";
19441953 }
1954+ }else{
1955+
1956+ $text= str_replace($matches[$key][0],"<strong style=\"color:red\">変換できません</strong>",$text)."\n";
1957+ }
19451958
19461959
19471960 }
@@ -1978,18 +1991,18 @@
19781991 if(preg_match_all("/(《)([^》]+)(》)/su", $text, $matches, PREG_SET_ORDER)){
19791992
19801993 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";
19811998
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));
19872000 }
19882001
1989- $code_hit = true;
2002+ $code_hit = true;
19902003 }
19912004
1992- return $text;
2005+ return $text;
19932006 }
19942007
19952008 /*------------------------------------------------------------------------------+
@@ -2034,13 +2047,13 @@
20342047 -------------------------------------------------------------*/
20352048
20362049 function basic_cleaner($buffer,$separator = "\n"){
2037-
2038- global $parm;
2039-
2050+
2051+ global $parm;
2052+
20402053 $buffer = mb_convert_encoding($buffer,"UTF-8","auto");
2041- $file = explode($separator,$buffer);
2042- $text = "";
2043-
2054+ $file = explode($separator,$buffer);
2055+ $text = "";
2056+
20442057 foreach($file as $key => $chk){
20452058
20462059 $chk = str_replace("\0", "", $chk);
@@ -2052,8 +2065,8 @@
20522065 $text .= "\n$chk";
20532066
20542067 }
2055-
2056- return $text;
2068+
2069+ return $text;
20572070 }
20582071 /*------------------------------------------------------------------------------+
20592072 * イメージサイズの検出
@@ -2062,9 +2075,9 @@
20622075
20632076 if(eregi("\.(gif|jpg|png|swc|psd|tiff|bmp|iff|jp2|jpx|jb2|jpc|xbm|wbmp)",$file)){
20642077 list($width, $height, $type, $attr) = getimagesize($file);
2065- return $attr;
2078+ return $attr;
20662079 }else{
2067- return $wide;
2080+ return $wide;
20682081 }
20692082 }
20702083
@@ -2107,59 +2120,59 @@
21072120 *------------------------------------------------------------------------------*/
21082121 function style_set($str){
21092122
2110- $tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
2111- $i = 0;
2112- $break = "";
2113- $str = str_replace("<","@@@@@<",$str);
2123+ $tab = "&nbsp;&nbsp;&nbsp;&nbsp;";
2124+ $i = 0;
2125+ $break = "";
2126+ $str = str_replace("<","@@@@@<",$str);
21142127 $result ="";
2115- $lines = explode("@@@@@",$str);
2128+ $lines = explode("@@@@@",$str);
21162129
2117- foreach($lines as $key=>$line){
2130+ foreach($lines as $key=>$line){
21182131
21192132 if(preg_match("/(<\/?(xml|html|body))/mi",$line) ){
21202133
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";
21242137
21252138 }elseif(preg_match("/(<\/?(xml|html|head|body|script|!doctype))/mi",$line) ){
21262139
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";
21302143 }elseif(preg_match("/(<\/)/",$line) ){
21312144
21322145 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--;
21392152 }elseif(preg_match("/(\/>?)/",$line) ){
21402153
21412154 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";
21472160 }else{
2148- $break = "<br />\n";
2161+ $break = "<br />\n";
21492162
21502163 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);
21552168 $i++;
21562169
21572170 }
21582171
2159- $result .= $space.htmlspecialchars($line).$break;
2172+ $result .= $space.htmlspecialchars($line).$break;
21602173 }
21612174
2162- return $this->tag_clear($result);
2175+ return $this->tag_clear($result);
21632176 }
21642177
21652178 /* ------------------------------------------------------------
@@ -2176,7 +2189,7 @@
21762189 $text = str_replace("\r","\n",$text);
21772190 $text = preg_replace("/(\n){2,}/","\n\n",$text);
21782191
2179- return $text;
2192+ return $text;
21802193 }
21812194
21822195 //end class
@@ -2249,56 +2262,48 @@
22492262 //wikipedia
22502263 function simpleapi_wikipedia($replacement, $count = 1){
22512264
2252- $result = unserialize($replacement);
2253- $results = "<div style=\"margin:1em;\">";
2265+ $result = unserialize($replacement);
2266+ $results = "<div style=\"margin:1em;\">";
22542267
22552268 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>";
22602273 }
22612274
22622275 return str_replace(array("<br>","<br/>"),"<br />",$results)."\n</div>";
22632276 }
22642277
2265-/*
2266-function test1(){
2267-
2268-return date("ymd");
2269-
2270-}
2271-*/
2272-
22732278 ////////////////////////////////////////////////////////////////////////////////////
22742279 function use_cache($name){
22752280
2276- if(!defined('CACHE_LITE_PATH')){return array(false,"");}
2277-
2281+ if(!defined('CACHE_LITE_PATH')){return array(false,"");}
2282+
22782283 require_once(CACHE_LITE_PATH);
22792284
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+ );
22842289
2285- $Cache_Lite = new Cache_Lite($options);
2290+ $Cache_Lite = new Cache_Lite($options);
22862291
2287- if(!CACHE_SWITCH){
2292+ if(!CACHE_SWITCH){
2293+
2294+ $Cache_Lite->clean();
2295+ return array(false,"");
2296+ }
22882297
2289- $Cache_Lite->clean();
2290- return array(false,"");
2291- }
2292-
22932298 $name = md5($name);
22942299
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 {
22992304
2300- $flag = false;
2301- }
2305+ $flag = false;
2306+ }
23022307
23032308 return array($flag,$data);
23042309 }
@@ -2305,59 +2310,59 @@
23052310
23062311 function save_cache($name,$value){
23072312
2308- if(!defined('CACHE_LITE_PATH')){return array(false,$value);}
2313+ if(!defined('CACHE_LITE_PATH')){return array(false,$value);}
23092314
23102315 $name = md5($name);
23112316
23122317 require_once(CACHE_LITE_PATH);
23132318
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+ );
23182323
23192324 $Cache_Lite = new Cache_Lite($options);
2325+
2326+ if(!CACHE_SWITCH){
2327+
2328+ $Cache_Lite->clean();
2329+ return array(false,$value);
2330+ }
23202331
2321- if(!CACHE_SWITCH){
2332+ if ($data = $Cache_Lite->get($name)){
2333+ $result = $data;
2334+ $flag = true;
2335+ }else {
23222336
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+ }
23262342
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-
23382343 return array($flag,$value);
23392344 }
23402345
23412346 function html_document1($ini_array,$documents,$navi="",$source = ""){
23422347
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'];
23462365
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-
23612366 $html=<<<DOC
23622367 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
23632368 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Show on old repository browser