Uid."/filesystem";$Encode=array('UTF-8','EUC-JP','SJIS','JIS');if($_REQUEST['ajax']){if($_REQUEST['action']=="checkfile"){if(is_file($_SERVER['DOCUMENT_ROOT'].$_REQUEST['path'])){ $text="指定のファイル(".$_REQUEST['path'].")は既に存在します。\n上書きしてもよろしいですか?";}else{ $text="新しいファイル(".$_REQUEST['path'].")を保存します。";}}header("Content-type:text/plain;charset=UTF-8");echo $text;exit;}if($_REQUEST['action']=="regist"){ !preg_match("/^\//",$_REQUEST['file'])&&$_REQUEST['file']="/".$_REQUEST['file'];$text=tag_decode($_REQUEST['text'],1);$text=preg_replace("/(\r\n|\r)/","\n",$text);$text=tag_decode($text,1);$_REQUEST['encode']!="UTF-8"&&$text=mb_convert_encoding($text,$_REQUEST['encode'],"UTF-8");file_put_contents($_SERVER['DOCUMENT_ROOT'].$_REQUEST['file'],$text);}else{ $width="100%";$height='';$caption='テキストファイルの編集';if($_REQUEST['path']){preg_match("/\/([^\/]+)$/",$_REQUEST['path'],$m);$file=$m[1];$dir=preg_replace("/\/$/","",str_replace($file,"",$_REQUEST['path']));$text=preg_replace("/(\r\n|\n)/","\r",file_get_contents($_SERVER['DOCUMENT_ROOT'].$_REQUEST['path']));$text=tag_encode($text);$encode=getEncoding($text,$Admin->Encode);$encode !="UTF-8"&&$text=tag_encode(mb_convert_encoding($text,"UTF-8",$encode));}if(preg_match("/\.php$/i",$file)){ $lang="php";}elseif(preg_match("/\.js$/i",$file)){ $lang="javascript";}elseif(preg_match("/\.pl$/i",$file)||preg_match("/\.cgi$/i",$file)){ $lang="perl";}elseif(preg_match("/\.sql$/i",$file)){ $lang="sql";}elseif(preg_match("/\.html$/i",$file)||preg_match("/\.htm$/i",$file)){ $lang="html";}elseif(preg_match("/\.css$/i",$file)){ $lang="css";}else{ $lang="text";}$codepress=0;if(is_dir($_SERVER['DOCUMENT_ROOT']."/jquery/codepress")&&is_file($_SERVER['DOCUMENT_ROOT']."/jquery/codepress/codepress.js")){ $doc="";$codepress=1;}$doc.="
  • File :

";if(preg_match("/firefox/i",$_SERVER['HTTP_USER_AGENT'])&&$codepress){ $doc.="";}else{ $doc.="";}$doc.="


";if($_REQUEST['path']){ $doc.="
";}$doc.="


";$client=new window;$client->name='client';$client->width=$width;$client->height=$height;$client->display='block';$client->caption=$caption;$client->drag=true;$client->resize=false;$client->closebutton=true;$client->smallbutton=true;$client->border=false;$client->bgcolor=$winbg;$client->foldericon='';$client->statusbar=$statusbar;$client->status=$status;$client->body=$doc;$html.=$client->show();$javascript.=" var fileDialog;var fox=".preg_match("/firefox/i",$_SERVER['HTTP_USER_AGENT']).";var codepress=$codepress;if(!fox||!codepress){ $(function(){ $('#text').tabby();});}function regist(){if($('#file').val()==''){saveas();return;}$.get('ctrl.php?ajax=editor&action=checkfile&path='+$('#file').val(),function(data){ if(confirm(data)){ if(fox&&codepress){ $('#text').val(codePress.getCode());}$('#clientform').submit();}});}function saveas(){fileDialog=window.open('filedialog.php?func=setfilename&typeID=1&md=a&start='+$('#file').val(),'fileDialog','toolbar=no,location=no,status=no,menubar=no,width=920,height=600,scrollbars=yes');fileDialog.focus();}function setfilename(path){ $('#file').val(path);regist();}function goregist(){if(confirm($('#systemDialog').text())){ $('#text').val(codePress.getCode());$('#clientform').submit();}}function windowGoResize(){var size=GetWindowSize();if(fox&&codepress){var v=90;var w=120;document.getElementById('codePress').style.width=size[0]-w+'px';document.getElementById('codePress').style.height=size[1]-v+'px';}else{var v=100;document.getElementById('text').style.height=size[1]-v+'px';}}windowGoResize();window.onresize=windowGoResize;parent.$('#alertdialog').dialog('close');";}?>