/i", $Setup['Name'], $html); $html = preg_replace("//i", $title, $html); $html = preg_replace("//i", $_REQUEST['Subject'], $html); $html = preg_replace("//i", $_REQUEST['Summary'], $html); $html = preg_replace("//i", $_REQUEST['date'], $html); $html = preg_replace("/(.*)/i", $_REQUEST['Body'], $html); $html = tag_encode($html); /* * htmlの所有権は、最終的に静的htmlを生成した方 */ $html = setHeader_uid($html); $html = tag_decode($html, true); $html = mb_convert_encoding($html, $Init['Encode'], "UTF-8"); $html = str_replace(" ", "\n", $html); if ($_REQUEST['action'] == "preview_news") { !is_dir($System['datadir']. "/contents/preview") && mkdir($System['datadir']. "/contents/preview"); file_put_contents($System['datadir']. "/contents/preview/". $_COOKIE['admin']. ".html", $html); header("Location:". $System['datadir']. "/contents/preview/". $_COOKIE['admin']. ".html"); } else { file_put_contents($_SERVER['DOCUMENT_ROOT']. $_REQUEST['htmlpath'], $html); $News = file($_SERVER['DOCUMENT_ROOT']. "/trycms/". $System['datadir']. "/news/". $_REQUEST['file']. ".dat"); if (array_values(preg_grep("/\tID=". $_REQUEST['ID']. "\t/", $News))) { $i = 0; foreach ($News as $line) { if (preg_match("/\tID=". $_REQUEST['ID']. "\t/", $line)) { array_splice($News, $i, 1); break; } $i++; } data_save($System['datadir']. "/news/". $_REQUEST['file']. ".dat", $News); logregist("$title の静的html生成(". $_REQUEST['htmlpath']. ")"); } header("Location: ctrl.php?cmd=news&file=". $_REQUEST['file']); } } } exit; } elseif ($_REQUEST['action'] == 'delete') { if (is_file($_SERVER['DOCUMENT_ROOT']. "/trycms/". $System['datadir']. "/contents/". $_REQUEST['ID']. ".html")) { unlink($_SERVER['DOCUMENT_ROOT']. "/trycms/". $System['datadir']. "/contents/". $_REQUEST['ID']. ".html"); $i = 0; foreach ($Contents as $line) { if (preg_match("/^ID=". $_REQUEST['ID']. "\t/", $line)) { $dummy = array_splice($Contents, $i, 1); $content = dbfields($dummy[0]); break; } $i++; } data_save($System['datadir']. "/contents/contents.cgi", $Contents); logregist("コンテンツ削除(". $content['Title']. ")"); } $_REQUEST['action'] = 'auth'; } if ($_REQUEST['action'] == 'initregist') { $_REQUEST['Hidden'] = str_replace(" ", "\n", $_REQUEST['Hidden']); $_REQUEST['Openpath'] = str_replace(" ", "\n", $_REQUEST['Openpath']); $value = " [Setup] edit=". $_REQUEST['edit']. " listtitle=". $_REQUEST['listtitle']. " [Hidden] ". $_REQUEST['Hidden']. " [Openpath] ". $_REQUEST['Openpath']; $value = str_replace("\r", "\n", $value); $value = str_replace("\t", "", $value); file_put_contents($System['datadir']. "/contents/initialize.cgi", $value); readini($System['datadir']. "/contents/initialize.cgi"); logregist("コンテンツ環境設定の編集"); } elseif ($_REQUEST['action'] == 'preview') { !is_dir($System['datadir']. "/contents/preview") && mkdir($System['datadir']. "/contents/preview"); $_REQUEST['header'] = setHeader_uid($_REQUEST['header']); $_REQUEST['header'] = preg_replace("/(<title>)(.*)(<\/title>)/i", "$1". $_REQUEST['title']. "$3", $_REQUEST['header']); $html = tag_decode($_REQUEST['header']. $_REQUEST['body']. $_REQUEST['footer'], 1); $_REQUEST['Encode'] != "UTF-8" && $html = mb_convert_encoding($html, $_REQUEST['Encode'], "UTF-8"); file_put_contents($System['datadir']. "/contents/preview/". $_COOKIE['admin']. ".html", $html); header("Location:". $System['datadir']. "/contents/preview/". $_COOKIE['admin']. ".html"); exit; } elseif ($_REQUEST['action'] == 'createhtml') { !preg_match("/^\//", $_REQUEST['path']) && $_REQUEST['path'] = "/". $_REQUEST['path']; $paths = split("/", $_REQUEST['path']); $dummy = array_shift($paths); $cnt = count($paths); $dir = $_SERVER['DOCUMENT_ROOT']; for($i = 0; $i < $cnt - 1; $i++) { if (!is_dir("$dir/$paths[$i]")) { mkdir("$dir/$paths[$i]"); $dir = "$dir/$paths[$i]"; } } !preg_match("/\.(.+)$/", $_REQUEST['path']) && $_REQUEST['path'] .= ".html"; if (!is_file($System['datadir']. "/contents/". $_REQUEST['ID']. ".html")) { $_REQUEST['header'] = setHeader_uid($_REQUEST['header']); $_REQUEST['header'] = preg_replace("/(<title>)(.*)(<\/title>)/i", "$1". $_REQUEST['title']. "$3", $_REQUEST['header']); $xml = tag_decode($_REQUEST['header']. $_REQUEST['body']. $_REQUEST['footer'], 1); $_REQUEST['Encode'] != "UTF-8" && $xml = mb_convert_encoding($xml, $_REQUEST['Encode'], "UTF-8"); file_put_contents($System['datadir']. "/contents/". $_REQUEST['ID']. ".html", $xml); } if (is_file($System['datadir']. "/contents/". $_REQUEST['ID']. ".html") && copy($System['datadir']. "/contents/". $_REQUEST['ID']. ".html", $_SERVER['DOCUMENT_ROOT']. $_REQUEST['path'])) { unlink($System['datadir']. "/contents/". $_REQUEST['ID']. ".html"); $i = 0; foreach ($Contents as $line) { if (preg_match("/^ID=". $_REQUEST['ID']. "\t/", $line)) { array_splice($Contents, $i, 1); break; } $i++; } data_save($System['datadir']. "/contents/contents.cgi", $Contents); logregist("コンテンツ一般公開(". $_REQUEST['path']. ")"); } $_REQUEST['action'] = ''; } elseif ($_REQUEST['action'] == 'regist') { $approval = ""; is_array($_REQUEST['Approval']) && $approval = join(",", $_REQUEST['Approval']); $value = join("\t", array( "ID=". $_REQUEST['ID'], "Date=". jst_time(time(), 7), "Uid=". $_COOKIE['admin'], "Gid=". $Admin['Depart'], "Creator=". $Admin['Name'], "Approval=$approval", "Path=". $_REQUEST['path'], "Encode=". $_REQUEST['Encode'], "Title=". $_REQUEST['title'], "\n" )); if (count(array_values(preg_grep("/^ID=". $_REQUEST['ID']. "\t/", $Contents)))) { $i = 0; foreach ($Contents as $line) { if (preg_match("/^ID=". $_REQUEST['ID']. "\t/", $line)) { $Contents[$i] = $value; break; } $i++; } } else { array_unshift($Contents, $value); } data_save($System['datadir']. "/contents/contents.cgi", $Contents); $_REQUEST['header'] = setHeader_uid($_REQUEST['header']); $_REQUEST['header'] = preg_replace("/(<title>)(.*)(<\/title>)/i", "$1". $_REQUEST['title']. "$3", $_REQUEST['header']); $xml = tag_decode($_REQUEST['header']. $_REQUEST['body']. $_REQUEST['footer'], 1); $xml = str_replace("\r\n", "\n", $xml); $xml = str_replace("\r", "\n", $xml); $_REQUEST['Encode'] != "UTF-8" && $xml = mb_convert_encoding($xml, $_REQUEST['Encode'], "UTF-8"); file_put_contents($System['datadir']. "/contents/". $_REQUEST['ID']. ".html", $xml); logregist("コンテンツ編集(". $_REQUEST['title']. ")"); $_REQUEST['action'] = 'auth'; } elseif ($_REQUEST['action'] == 'form' && $_REQUEST['path']) { if (is_array($Contents)) { $path = str_replace("/", "\/", $_REQUEST['path']); if (preg_grep("/\tPath=$path\t/", $Contents)) { $_REQUEST['action'] = 'error'; $errmsg = "ご指定のファイル「". $_REQUEST['path']. "」は、現在編集中です。この編集が完了するまで新たに編集を開始することはできません。

"; $errmsg .= "編集が制限されていない場合は、未承認コンテンツの一覧で編集を行うことが可能です。"; } } } $border = false; if ($_REQUEST['action'] == 'error') { $body = " "; $javascript .= " function errormessage() { $('#confirmdialog').html('$errmsg'); $(function() { $('#confirmdialog').dialog({ title: 'エラー', resizable: false,width: 400,height:240,modal:true,show:'blind',hide:'blind', buttons: { キャンセル: function() { $('#client').fadeOut('slow'); history.back(); } } }); }); } errormessage();"; } elseif ($_REQUEST['action'] == 'new') { $body = " "; $javascript .= " function newhtml() { getAjaxText('fileman.php?ajax=templist&','confirmdialog'); $(function() { $('#confirmdialog').dialog({ title: 'ページの作成', resizable: false,width: 400,height:480,modal:true,show:'blind',hide:'blind', buttons: { キャンセル: function() { $('#client').fadeOut('slow'); $(this).dialog('close'); } } }); }); } function tinymce(file, temp) { location.href='ctrl.php?cmd=contents&action=form&temp='+temp; } newhtml();"; } elseif ($_REQUEST['action'] == 'form') { $styles = array(); $scripts = array(); if ($_REQUEST['path']) { $title = "コンテンツ編集 (".$_REQUEST['path'].")"; $readfile = $_SERVER['DOCUMENT_ROOT']."/".$_REQUEST['path']; $contents['Path'] = $_REQUEST['path']; $editmode = 2; } elseif ($_REQUEST['temp']) { $title = "コンテンツ作成 (".$_REQUEST['temp'].")"; $readfile = $_SERVER['DOCUMENT_ROOT']."/".$_REQUEST['temp']; $editmode = 1; } else { $title = "コンテンツ再編集 (".$_REQUEST['ID'].")"; $readfile = $System['datadir']. "/contents/". $_REQUEST['ID']. ".html"; $dummy = array_values(preg_grep("/^ID=".$_REQUEST['ID']."\t/", $Contents)); $contents = dbfields($dummy[0]); $editmode = 0; } !$_REQUEST['ID'] && $_REQUEST['ID'] = createid(); if (is_file($readfile)) { $contentsBody = file_get_contents($readfile); $contentsBody = str_replace("\n", "\r", $contentsBody); $contentsBody = str_replace("\r\r", "\r", $contentsBody); if (preg_match("/)(.*)(<\/body>.*)$/i", $contentsBody, $m)) { preg_match("/(.+)<\/title>/i", $m[1], $n); $contentTitle = $n[1]; $header = tag_encode($m[1]); $contentsBody = $m[2]; $footer = tag_encode($m[3]); $heads = split("\r", $m[1]); if (count($heads)) { foreach ($heads as $l) { if (preg_match("/href=(\"|\')(.+)(\.css)(\"|\')/i", $l, $m)) { $css = "$m[2]$m[3]"; if (!preg_match("/^http/", $css) && !in_array($css, $styles)) { $styles[] = $css; $styles_str && $styles_str .= ","; $styles_str .= $css; $select_styles .= " <li><a href=\"javascript:void(0)\" onclick=\"subeditor('$css');\">$css</a></li>"; } } elseif (preg_match("/src=(\"|\')(.+)(\.js)(\"|\')/i", $l, $m)) { $js = "$m[2]$m[3]"; if (!preg_match("/^http/", $js) && !in_array($js, $scripts)) { $scripts[] = $js; $select_scripts .= " <li><a href=\"javascript:void(0)\" onclick=\"subeditor('$js');\">$js</a></li>"; } } if (preg_match("/meta name=\"permission\" content=\"uid=(.*); gid=(.*);.*\"/i", $l, $m)) { $contents_uid = $m[1]; $contents_gid = $m[2]; } } } } $contentsBody = str_replace("<", "<", $contentsBody); $contentsBody = str_replace(">", ">", $contentsBody); } if ($contents_uid) { $title .= " 所有権 : ". $contents_uid. "($contents_gid)"; } if ($_COOKIE['admin'] != "root" && $_COOKIE['admin'] != "superadmin") { if (!$contents_uid) { $contents_uid = $Admin['Uid']; $contents_gid = $Admin['Depart']; } } if (is_array($Approval)) { $contentsApproval = split(",", $contents['Approval']); $approvals = " <table cellspacing=\"0\" cellpadding=\"0\" style=\"text-align:left;\"><tr><td valign=\"top\">"; $i = 1; $j = 0;$disp = 'block'; foreach ($Approval as $line) { if ($i > 2) { $approvals .= "</td><td valign=\"top\">"; $i = 1; } if ($dummy = array_values(preg_grep("/\tUid=$line\t/", $Adminuser))) { $member = dbfields($dummy[0]); } $check = ""; if (in_array($line, $contentsApproval)) { $check = "checked"; } else { $disp = 'none'; } $dsbl = ""; $hide = ""; if ($_COOKIE['admin'] != $line && $_COOKIE['admin'] != 'root') { $dsbl = "disabled=\"true\""; $check && $hide = " <input type=\"hidden\" name=\"Approval[]\" value=\"$line\" />"; } $approvals .= "$hide <input type=\"checkbox\" name=\"Approval[]\" class=\"Approval\" id=\"Approval_$j\" $check value=\"$line\" $dsbl onclick=\"writeButton()\" /><label for=\"Approval_$j\">". $member['Name']. "</label><br />"; $i++; $j++; } $approvals .= " </td></tr></table>"; } if ($Setup['edit'] && ($_COOKIE['admin'] == "root" || $_COOKIE['admin'] == "superadmin")) { $prmbutton = "<a href=\"javascript:void(0);\" onclick=\"selectmember();\">所有権</a>"; } else { $prmbutton = " "; } $body .= " <div id=\"selectStyles\" style=\"display:none;\"> <div style=\"margin:0 40px 10px 40px;color:#008;\"> 外部スタイルシートの編集は、保存と同時に反映されます。 ページ個々のスタイル設定は外部ファイルではなく、ページごとのヘッダー部に記述します。 </div> <ul> $select_styles </ul> </div> <div id=\"selectScript\" style=\"display:none;\"> <div style=\"margin:0 40px 10px 40px;color:#008;\"> 外部javascriptの編集は、保存と同時に反映されます。 ページ個々のjavascriptの設定は外部ファイルではなく、ページごとのヘッダー部または、フッターに記述します。 </div> <ul> $select_scripts </ul> </div> <form action=\"ctrl.php\" method=\"post\" name=\"editform\"> <input type=\"hidden\" name=\"cmd\" value=\"". $_REQUEST['cmd']. "\" /> <input type=\"hidden\" name=\"action\" value=\"regist\" /> <input type=\"hidden\" name=\"path\" value=\"". $contents['path']. "\" /> <input type=\"hidden\" name=\"ID\" value=\"". $_REQUEST['ID']. "\" /> <input type=\"hidden\" name=\"Encode\" value=\"$encode\" /> <input type=\"hidden\" name=\"contents_uid\" value=\"$contents_uid\" /> <input type=\"hidden\" name=\"contents_gid\" value=\"$contents_gid\" /> <input type=\"hidden\" name=\"saveflag\" value=\"\" /> <textarea name=\"header\" id=\"header\" style=\"display:none;\">$header</textarea> <textarea name=\"footer\" id=\"footer\" style=\"display:none;\">$footer</textarea> <div align=\"left\" id=\"\" class=\"listtitle_gray\" style=\"height:58px;\"> <table cellspacing=\"2\" cellpadding=\"0\"> <tr><td><div class=\"circleButton40\"><a href=\"javascript:void(0)\" onclick=\"history.back()\"><img src=\"images/arrow_left40.gif\" /></a></div></td> <td><table cellspacing=\"1\" cellpadding=\"0\"> <tr><td style=\"width:60px;\" class=\"imageButton60B\"><a href=\"javascript:void(0)\" onclick=\"selectFile('start='+$('#path').val()+'&typeID=1&func=setfilename');\">ファイル</a></td> <td><input type=\"text\" name=\"path\" id=\"path\" value=\"". $contents['Path']. "\" style=\"width:240px;ime-mode:disabled;\" title=\"ファイル名指定\" /></td></tr> <tr><td style=\"background:url(images/imageButton/60_52B.png);height:26px;\">タイトル</td> <td><input type=\"text\" name=\"title\" value=\"$contentTitle\" style=\"width:240px;\" /></td></tr> </table></td> <td><table cellspacing=\"0\" cellpadding=\"0\" class=\"imageButton80C\"> <tr><td><a href=\"javascript:void(0);\" onclick=\"subeditor('header');\">ヘッダー</a></td> <td><a href=\"javascript:void(0);\" onclick=\"selectsubeditor('selectStyles');\">スタイル</a></td> <td>$prmbutton</td></tr> <tr><td><a href=\"javascript:void(0);\" onclick=\"subeditor('footer');\">フッター</a></td> <td><a href=\"javascript:void(0);\" onclick=\"selectsubeditor('selectScript');\">スクリプト</a></td> <td> </td></tr> </table></td> <td><img src=\"images/v_separator.jpg\" style=\"margin-left:5px;margin-right:5px;\" /></td> <td><table cellspacing=\"0\" cellpadding=\"0\" class=\"imageButton100C\"> <tr><td><a href=\"javascript:void(0);\" onclick=\"preview();\">プレビュー</a></td></tr> <tr><td><a href=\"javascript:void(0);\" onclick=\"gosubmit()\">保存して終了</a></td><tr> </table></td> <td><img src=\"images/v_separator.jpg\" style=\"margin-left:5px;margin-right:5px;\" /></td> <td><table cellspacing=\"0\" cellpadding=\"0\" class=\"imageButton100x100C\"> <tr><td> $approvals </td> <td id=\"htmlwritebutton\" style=\"display:$disp;\"><a href=\"javascript:void(0);\" onclick=\"create_html()\">html公開</a></td></tr> </table></td> </tr> </table> </div> <textarea name=\"body\" id=\"editor\">$contentsBody</textarea> </form> <iframe name=\"blind\" id=\"blind\" frameborder=\"0\" style=\"display:none;\"></iframe>"; $javascript .= " var previewwin; var editmode=$editmode; tinymce_initialize('#editor', '100%', '', '$styles_str'); function selectmember() { getAjaxText('ctrl.php?ajax=member&action=selectlist', 'confirmdialog'); $(function() { $('#confirmdialog').dialog({ title: 'ファイルの所有権', resizable: false, width: 400, height:480, modal: true, show: 'blind', hide: 'blind', buttons: { 閉じる: function() { $(this).dialog('close'); } } }); }); } function setuid(uid,gid) { document.editform.contents_uid.value=uid; document.editform.contents_gid.value=gid; $('#confirmdialog').dialog('close'); } function create_html() { if ($('#path').val() == '') { selectFile('start='+$('#path').val()+'&typeID=1&func=setfilename'); } else { $('#confirmdialog').html('\ <table cellspacing=\"5\" cellspacing=\"0\">\ <tr><td valign=\"top\"><img src=\"/trycms/images/crysigns/Question.png\" /></td>\ <td valign=\"top\">編集中のページをhtmlドキュメントとして一般公開しても宜しいですか?<br />\ <br />\ このページのアドレスは、<br />\ http://". $_SERVER['SERVER_NAME']. "'+$('#path').val()+'<br />\ になります。<br />\ サイト内からのリンクは、'+$('#path').val()+'でも結構です。<br />\ <br />\ htmlドキュメントに変換されたコンテンツは、この一覧から削除されますが、\ コンテンツツリーからファイルを選択して再度編集することは可能です。<br />\ ただ、この場合編集後は、再度担当者による承認が必要になります。<br />\ <br />\ 同名のファイルが既に存在する場合は、更新として上書きされます。<br />\ <br />\ <b>最終確認です。</b><br />\ コンテンツを公開しても宜しいですか?\ </td></tr>\ </table>'); $(function() { $('#confirmdialog').dialog({ title: '最終確認', resizable: true,width: 600,height:380,modal:true,show:'blind',hide:'blind', buttons: { 保存する: function() { $(this).dialog('close'); document.editform.target=''; document.editform.action.value='createhtml'; document.editform.submit(); }, キャンセル: function() { $(this).dialog('close'); } } }); }); } } function setfilename(file) { $('#path').val(file); } function gosubmit() { if (document.editform.title.value=='') { alertdialog('エラー', 'ページのタイトルを省略できません。'); return; } document.editform.target=''; document.editform.action.value='regist'; document.editform.submit(); } function preview() { previewwin = window.open('', 'previewwin'); document.editform.target='previewwin'; document.editform.action.value='preview'; document.editform.submit(); } function selectsubeditor(id) { $(function() { $('#'+id).dialog({ title: '編集するスタイル / スクリプトの選択', resizable: true,width:600,height:400,modal:true,show:'blind',hide:'blind', buttons: { キャンセル: function() { $(this).dialog('close'); } } }); }); } function subeditor(mode) { if (mode=='footer' || mode=='header') { if (mode=='footer') { subj = 'フッター編集'; } else if (mode=='header') { subj = 'ヘッダー編集'; } document.getElementById('confirmdialog').innerHTML = '\ <textarea name=\"subeditor\" id=\"subeditor\"\ style=\"width:100%;height:410px;\" wrap=\"off\">'+document.getElementById(mode).value+'</textarea>'; } else { subj = 'スタイル「' + mode + '」編集'; getAjaxText('fileman.php?ajax=styleform&css='+mode,'confirmdialog'); } /*jQuery(document).ready(function () { $(\"textarea#subeditor\").tabby(); });*/ $('textarea#texteditor').editor(); $(function() { $('#confirmdialog').dialog({ title: subj, resizable: true,width: '95%',height:520,modal:true,show:'blind',hide:'blind', buttons: { 保存する: function() { $(this).dialog('close'); if (mode=='footer' || mode=='header') { document.getElementById(mode).value=document.getElementById('subeditor').value; } else { document.getElementById('optionform').submit(); } }, キャンセル: function() { $(this).dialog('close'); } } }); }); } function writeButton() { var max = $('.Approval').size(); var disp = 'block'; for(j=0;j<max;j++) { if (!document.getElementById('Approval_'+j).checked) { disp = 'none'; break; } } $('#htmlwritebutton').css('display', disp); } if ('$disp' != 'block') writeButton(); function windowGoResize() { var size = GetWindowSize(); var v = 125; document.getElementById('editor').style.height=size[1]-v+'px'; } windowGoResize(); window.onresize=windowGoResize;"; } elseif ($_REQUEST['action'] == 'auth') { $title = '未承認(承認待ち)コンテンツ一覧'; !is_array($Approval) && $Approval = array(); $body .= " <div id=\"scroolBody\"> <table cellspacing=\"0\" cellpadding=\"2\" width=\"100%\" class=\"linetable\"> <tr><td class=\"listtitle_gray\" width=\"30\">No.</td> <td class=\"listtitle_gray\" width=\"200\">ファイル</td> <td class=\"listtitle_gray\">タイトル</td> <td class=\"listtitle_gray\" width=\"280\">承認待ち</td> <td class=\"listtitle_gray\" width=\"120\">更新日</td> <td class=\"listtitle_gray\" width=\"100\">作成者</td> </tr>"; $i = 1; foreach ($Contents as $line) { $contents = dbfields($line); !$contents['Path'] && $contents['Path'] = "新規作成"; $contentsApproval = split(",", $contents['Approval']); $auth = ""; $authEmail = array(); foreach ($Approval as $line) { if (!in_array($line, $contentsApproval)) { if ($dummy = array_values(preg_grep("/\tUid=$line\t/", $Adminuser))) { $member = dbfields($dummy[0]); $auth && $auth .= ", "; $auth .= $member['Name']; $member['Email'] && $authEmail[] = $member['Email']; } } } if (count($authEmail)) { $to = array_shift($authEmail); count($authEmail) && $cc = join(",", $authEmail); $auth = "<a href=\"javascript:void(0)\" onclick=\"parent.mailform('$to', '$cc', '', '', '');\">$auth</a>"; } $edit = true; if ($contents['Uid'] != 'root' && $contents['Uid'] != 'superadmin' && $_COOKIE['admin'] != 'root' && $_COOKIE['admin'] != 'superadmin' && !in_array($_COOKIE['admin'], $Approval)) { if ($Setup['edit'] == 1) { $_COOKIE['admin'] != $contents['Uid'] && $edit = false; } elseif ($Setup['edit'] == 2) { $dummy = array_values(preg_grep("/\tUid=". $contents['Uid']. "\t/", $Adminuser)); $user = dbfields($dummy[0]); $Admin['Depart'] != $user['Depart'] && $edit = false; } } if ($edit) { $contentsTitle = "<a href=\"ctrl.php?cmd=contents&action=form&ID=". $contents['ID']. "\">". $contents['Title']. "</a>"; } else { $contentsTitle = $contents['Title']; } $creator = $contents['Creator']; if ($_COOKIE['admin'] == 'root' || $_COOKIE['admin'] == 'superadmin' || $_COOKIE['admin'] == $contents['Uid']) { $creator = "<input type=\"button\" value=\"$creator...\" onclick=\"contents_delete('". $contents['ID']. "');\" />"; } $body .= " <tr><td align=\"right\">$i</td> <td>". $contents['Path']. "</td> <td>$contentsTitle</td> <td>$auth</td> <td>". $contents['Date']. "</td> <td>$creator</td> </tr>"; $i++; } $body .= " </table> </div>"; $javascript = " function contents_delete(id) { document.getElementById('systemDialog').innerHTML = '\ 指定の編集中コンテンツを削除します。<br />\ 編集中のコンテンツが既存のページの場合でも、既存のファイルには影響しません。<br />\ <br />\ 削除しても宜しいですか?'; $(function() { $('#systemDialog').dialog({ title: 'コンテンツの削除確認', resizable: false,width: 400,height:200,modal:true,show:'blind',hide:'blind', buttons: { 削除する: function() { $(this).dialog('close'); location.replace('ctrl.php?cmd=". $_REQUEST['cmd']. "&action=delete&ID='+id); }, キャンセル: function() { $(this).dialog('close'); } } }); }); } function windowGoResize() { var h = $(window).height(); document.getElementById('scroolBody').style.height=h-54+'px'; } windowGoResize(); window.onresize=windowGoResize;"; } elseif ($_REQUEST['action'] == 'init') { $width = '800px'; $title = 'コンテンツマネージャ環境設定'; is_array($Hidden) && $hidden = join("\r", $Hidden); is_array($Openpath) && $openpath = join("\r", $Openpath); !$Setup['edit'] && $Setup['edit'] = 0; $Edit[$Setup['edit']] = "checked"; $body .= " <form action=\"ctrl.php\" method=\"post\" name=\"clientform\" id=\"clientform\"> <input type=\"hidden\" name=\"cmd\" value=\"". $_REQUEST['cmd']. "\" /> <input type=\"hidden\" name=\"action\" value=\"initregist\" /> <table cellspacing=\"0\" cellpadding=\"2\" width=\"100%\" summary=\"\"> <tr><td valign=\"top\"> <div id=\"scroolBody\" style=\"overflow:auto;\"> <table cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" class=\"linetable\" summary=\"\"> <tr><th class=\"fieldtitle120\" style=\"width:120px;\">編集</td> <td colspan=\"2\"> <input type=\"radio\" name=\"edit\" $Edit[0] value=\"0\" />すべてのユーザに編集を許可<br /> <input type=\"radio\" name=\"edit\" $Edit[1] value=\"1\" />作成者のみ編集可能<br /> <input type=\"radio\" name=\"edit\" $Edit[2] value=\"2\" />作成者のグループ(所属部署)のみ編集可能 <div class=\"indent\"> ※コンテンツ(htmlドキュメント)の編集許可を設定します。<br /> 所有者が設定されていないコンテンツは、最初に編集された方が所有者になります。<br /> <span style=\"color:#f00;\">また、管理者が開始した編集はすべてのユーザが編集可能です。</span> </div></td></tr> <tr><th class=\"fieldtitle120\">タイトル</td> <td colspan=\"2\"><input type=\"checkbox\" name=\"listtitle\" ". $Setup['listtitle']. " value=\"checked\" />コンテンツツリーにhtmlドキュメントのタイトル等、詳細情報を表示</td></tr> <tr><th class=\"fieldtitle120\">除外</td> <td width=\"40%\"><textarea name=\"Hidden\" style=\"width:98%;height:200px;\">$hidden</textarea></td> <td valign=\"top\">コンテンツ管理対象から除外するディレクトリを/からの絶対パスで指定します。 指定したディレクトリの下層ディレクトリも除外されます。<br /> 1件ごとに改行してください。<br /> 本システムのディレクトリ /trycms は、無条件に除外されます。 </td></tr> <tr><th class=\"fieldtitle120\">オープンパス</td> <td width=\"40%\"><textarea name=\"Openpath\" style=\"width:98%;height:100px;\">$openpath</textarea></td> <td valign=\"top\">デフォルトでオープンした状態にするディレクトリの絶対パス<br /> 1件ごとに改行して複数設定可能</td></tr> </table> </div></td> <td style=\"width:100px;vertical-align:top\" class=\"imageButton80B\" align=\"center\"> <a href=\"javascript:void(0)\" onclick=\"document.clientform.submit()\">保存する</a> <a href=\"javascript:void(0)\" onclick=\"document.clientform.reset()\">リセット</a> <a href=\"javascript:void(0)\" onclick=\"$('#client').fadeOut('slow');\">キャンセル</a> <a href=\"javascript:void(0)\" onclick=\"history.back()\">≪ 戻る</a> $helpbutton </td></tr> </table> </form>"; $javascript = " function windowGoResize() { var h = $(window).height(); document.getElementById('scroolBody').style.height=h-54+'px'; } windowGoResize(); window.onresize=windowGoResize;"; } else { $title = 'コンテンツツリー'; $bgcolor = '#fff'; $border = true; $body .= " <div id=\"scroolBody\" style=\"font-size:14px;overflow:auto;\"> <ul id=\"contentstree\" class=\"filetree\"> <li><span class=\"folder\">Document Root</span>"; tree_view(''); $body .= " </ul> </div>"; $javascript = " $(document).ready(function(){ $('#contentstree').treeview({ persist: 'cookie', cookieId: 'contentstreeview' }); }); function windowGoResize() { var h = $(window).height(); document.getElementById('scroolBody').style.height=h-54+'px'; } parent.$('#alertdialog').dialog('close'); windowGoResize(); window.onresize=windowGoResize;"; } $client = new window; $client->name = 'client'; $client->width = $width; $client->display = 'block'; $client->caption = $title; $client->drag = false; $client->resize = false; $client->closebutton = true; $client->closeFunc = ''; $client->smallbutton = true; $client->height = ''; $client->border = $border; $client->bgcolor = $bgcolor; $client->statusbar = false; $client->date = false; $client->time = false; $client->copy = false; $client->help = $help->contents; $client->body = $body; $html .= $client->show(); function tree_view($dir = "") { global $Hidden, $body, $Openpath, $Init, $Setup; $nonDir = array('/trycms', '/jquery'); if (is_array($Hidden)) { foreach ($Hidden as $line) { $nonDir[] = $line; } } $Dir = array(); $File = array(); $Files = array(); $abs = $_SERVER['DOCUMENT_ROOT']. "/$dir"; $abs = str_replace('//', '/', $abs); $abs = preg_replace("/\/$/", "", $abs); $child = false; if ($dh = opendir($abs)) { while (($file = readdir($dh)) !== false) { if ($file && !preg_match("/^\./", $file)) { if (preg_match("/\.(htm|html)$/i", $file) && is_file("$abs/$file")) { array_push($File, "$file,file"); } elseif (is_dir("$abs/$file")) { !in_array("$dir/$file", $nonDir) && array_push($Dir, "$file,dir"); } } } closedir($dh); } sort($Dir); sort($File); $Files = array_merge($Dir, $File); if (count($Files)) { $child = true; $body .= " <ul>"; foreach ($Files as $line) { list($file, $type) = split(",", $line); $absfile = "$abs/$file"; $absfile = str_replace('//', '/', $absfile); $url = "$dir/$file"; if ($type == 'dir') { $closed = "closed"; if (is_array($Openpath)) { in_array($url, $Openpath) && $closed = ""; } $body .= " <li class=\"$closed\" nowrap><span class=\"folder\">$file</span>"; tree_view("$dir/$file") && $body .= "</ul>"; $body .= "</li>"; } else { $abs = $_SERVER['DOCUMENT_ROOT']. "/$dir"; $abs = preg_replace("/\/$/", "", $abs); $abs .= "/$file"; $title = ""; $uid = ""; $gid = ""; $date = ""; if (is_file($abs)) { $html = file_get_contents($abs); $html = preg_replace("/[\r\n\t]/", "", $html); preg_match("/http-equiv=\"content-type\" .* ?content=\".+; charset=([\w\-]*)?\".*?<\/head/i", $html, $m); $encode = $m[1]; !$encode && $encode = $Init['Encode']; $date = date ("Y/m/d", filemtime($abs)); preg_match("/<title>(.*)<\/title>/", $html, $m); $title = mb_convert_encoding($m[1], "UTF-8", $encode); preg_match("/meta name=\"permission\" content=\"uid=(\w+); gid=(\w+);\"/", $html, $m); $uid = $m[1]; $gid = $m[2]; } $view = $title; if ($Setup['listtitle']) { $view && $view .= " : "; $view .= $file; $uid && $view .= " : $uid($gid)"; } $view .= " : $date"; if (!$Setup['edit'] || !$uid || ($Setup['edit'] == 2 && $gid == $Admin['Depart']) || $_COOKIE['admin'] == 'root' || $_COOKIE['admin'] == 'superadmin' || $_COOKIE['admin'] == $uid) { $view = "<a href=\"ctrl.php?cmd=contents&action=form&path=$dir/$file\">$view</a>"; } $body .= " <li nowrap><span class=\"file\">$view</span></li>"; } } } return($child); } function setHeader_uid($header) { $meta = "<meta name="permission" content="uid=". $_REQUEST['contents_uid']. "; gid=". $_REQUEST['contents_gid']. ";" />"; $baundary = "<meta name="permission" content="uid=\w*; gid=\w*;" ?\/>"; if (preg_match("/$baundary/", $header)) { $header = preg_replace("/$baundary/", $meta, $header); } else { $header = preg_replace("/^(.+\/title> )(.+)/i", "$1$meta $2", $header); } return($header); } ?>