<?php
	require("../__common__/__define_common.php");
	require("../__common__/include-common-all.php");
	require("__include-common-code-file.php");
	my_session_start();
	require("../account/__logincheck.php");
	if ($_SESSION['システム管理者'] <> "YES") {
		exit;
	}
	if ($_GET['ret'].'' == '') {
		$ret_php = 'code-file-view.php';
	} else {
		$ret_php = $_GET['ret'];
	}
	if ($_GET['path'].'' == '' or $_GET['new'].'' == '') {
		header("Location: ".$ret_php."?path=".urlencode(up_folder_path($src_file)));
	}
	$src_file = $_GET['path'];
	$src_file_SJIS = mb_convert_encoding($src_file, 'SJIS-win', 'UTF-8');
	if (file_exists($src_file_SJIS)) {
		$new_file = substr($src_file, 0, strrpos($src_file, '/')).'/'.$_GET['new'];
		$new_file_SJIS = mb_convert_encoding($new_file, 'SJIS-win', 'UTF-8');
		if (@rename($src_file_SJIS, $new_file_SJIS) == False) {
			error_simple_html('ファイルリネームエラー', 'リネーム先のファイル名['.$new_file.']が存在します。');
		}
	}
	header("Location: ".$ret_php."?path=".urlencode(up_folder_path($src_file)));
?>
