name. "-win\" class=\"virtualwin box-shadow\" style=\"width:". $this->width. ";\">
name. "-caption\" class=\"win-caption default-bar\" style=\"\">". $this->caption. "
name. "-body\" class=\"win-body\" style=\"height:". $this->height. ";\">
". $this->body. "
";
return($text);
}
}
function precedent() {
global $Selects;
$text = "
";
foreach ($Selects as $line) {
$text .= "
- $line
";
}
$text .= "
";
return($text);
}
function startmenu() {
global $admin, $client, $Init,$accesslimit;
$text = "
ホームメニュー
";
if ($admin) {
if ($accesslimit && $Init['enDate'] && $_SESSION['uid'] == "admin") {
$text .= "
システム使用期限は、". date("Y年 m月 d日", strtotime($Init['enDate'])). " までです。
";
}
$text .= "
";
} else {
$rs = mysql_query("SELECT * FROM `$client-ans` WHERE `TargetID`='". $_SESSION['uid']. "'");
mysql_num_rows($rs) && $no_edit = true;
$text .= "
";
}
$text .= "
";
return($text);
}
function openDB() {
global $System, $dbh;
$dbh = mysql_connect($System['servername'], $System['username'], $System['password'], $System['dbname']);
if (!$dbh) {
die('接続できませんでした: ' . mysql_error());
exit;
}
mysql_select_db($System['dbname']);
mysql_query("SET NAMES 'utf8'");
}
function closeDB() { global $dbh;mysql_close($dbh); }
function session_clear() {
$_SESSION = array();
if( ini_get( 'session.use_cookies' ) ) {
$params = session_get_cookie_params();
setcookie( session_name(), '', time() - 3600, $params[ 'path' ] );
}
session_destroy();
}
function AuthorizationError() {
$html = join("\n", array(
'',
'',
'401 Authorization Required',
'',
'Authorization Required
',
'This server could not verify that you are authorized to access the document',
' requested. Either you supplied the wrong credentials (e.g., bad password), or your',
' browser doesn\'t understand how to supply the credentials required.
',
''
));
header("Content-type:text/html; charset=utf-8");
echo $html;
exit;
}
function getCryptfile($path, $key) {
$buffer = array();
$filepath = $_SERVER['DOCUMENT_ROOT']. $path;
if (is_file($filepath)) {
if ($buf = file_get_contents($filepath)) {
$base64 = strcrypt($buf, 0, $key);
$buffer = split("\n", $base64);
array_pop($buffer);
}
}
return($buffer);
}
function setCryptfile($path, $buffer = array(), $key) {
$filepath = $_SERVER['DOCUMENT_ROOT']. $path;
data_save($filepath, $buffer);
if ($key) {
if ($buf = file_get_contents($filepath)) {
$base64 = strcrypt($buf, 1, $key);
file_put_contents($filepath, $base64);
}
}
}
function pager($page, $max, $pageview = 50) {
!$page && $page = 1;
$maxpage = ceil($max / $pageview);
$pager = "
";
return($pager);
}
function get_middle_section($que) {
$middle = array();
foreach ($que as $line) {
$Field = dbfields($line);
if ($Field['Field']) {
$key = $Field['Field'];
}
if ($Field['Type'] == 0) $middle[$key]++;
}
return($middle);
}
function createTable($file, $table) {
/*
テンポラリテーブルを作成してデータをセット
大分類に属する中分類の名称は、グローバル変数 $category に
中分類に属する設問コードは、変数 $subcategory に格納されている
*/
$QueCount = array();
global $Init, $Report, $QueCount;
$commfields = split(",", $Report['commfields']);
$category = array();
if (is_file($file)) {
if ($fh = fopen($file, "r")) {
$cat = fgetcsv_reg($fh); /* 1行目は大分類 */
mb_convert_variables('UTF-8', 'SJIS-win', $cat);
$subcat = fgetcsv_reg($fh); /* 2行目は中分類 */
mb_convert_variables('UTF-8', 'SJIS-win', $subcat);
$data = fgetcsv_reg($fh); /* 3行目で設問フィールドを取得 */
$cnt = count($data);
/* 大分類と中分類の設問を解析 */
for ($i = 8; $i < $cnt; $i++) {
if ($cat[$i]) {
$key = $cat[$i];
$category[$key];
}
if ($subcat[$i]) {
$subkey = $subcat[$i];
$category[$key][$subkey];
}
$category[$key][$subkey][] = $data[$i];
$QueCount[$key][] = $data[$i];
}
if ($Report['exclusion']) {
$exclusion = split(",", $Report['exclusion']);
foreach ($exclusion as $line) {
unset($category[$line]);
unset($QueCount[$line]);
}
}
/* テンポラリテーブルを生成 */
mb_convert_variables('UTF-8', 'SJIS-win', $data);
$sql = "CREATE TEMPORARY TABLE IF NOT EXISTS `$table` (
`ID` int(11) NOT NULL auto_increment,
`Date` datetime NOT NULL COMMENT '日付',
`F1` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT 'ユーザID',
`F2` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '被評価者',
`F3` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '関係',
`F4` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '所属(大)',
`F5` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '所属(中)',
`F6` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '所属(小)',
`F7` varchar(20) collate utf8_unicode_ci NOT NULL COMMENT '役職',";
for ($i = 8; $i < $cnt; $i++) {
if (in_array($data[$i], $commfields)) {
$sql .= "
`". $data[$i]. "` varchar(200) collate utf8_unicode_ci NOT NULL,";
} else {
$sql .= "
`". $data[$i]. "` int(11) NOT NULL,";
}
}
$sql .= "
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;";
$sql = str_replace("\t", "", $sql);
mysql_query($sql);
$data = fgetcsv_reg($fh); /* 4行目も削除 */
while (($data = fgetcsv_reg($fh))) {
mb_convert_variables('UTF-8', 'SJIS-win', $data);
$sql = "
INSERT INTO `$table` VALUES (
''";
foreach ($data as $line) {
$sql .= ",
'$line'";
}
$sql .= "
);";
mysql_query($sql);
}
}
}
return($category);
}
?>