웹마스터 팁

kjoe42.gif
kjoe4.gif
http://pje444.w3ip.co.kr/sc.php<!---------------------------------------------------------------------
*프로그램이름: Space Checker
*제작자: 조경진
*제작일:2003년6월3일
*용도: 자신의 계정을 어느 정도 사용했는지 확인할 수 있게 만든 프로그램
*연락처: Email: jstyle@empal.com
         Website: http://jstyle.byus.net
         MSN massenger: jstyle@empal.com

*수정: HyoSub
*수정일: 2004년5월26일
*최종수정일: 2004년5월29일
*용도: pje444.com 사용자전용 계정 사용 용량 확인 프로그램
*연락처: Email: yhs6374@hotmail.com
         Website: http://hyosub.uu.st
         MSN Messenger: yhs6374@hotmail.com
----------------------------------------------------------------------->
<?
//아래에 설정을 변경해 주세요.
//수정하실 부분... 여기부터 시작...

//계정ID 설정
//$user_id = "계정 아이디로 "; //자신의 계정 아이디로 수정
//sc.php?user_id=ID&user_pass=PASSWORD 형식으로 호출되도록

if($check == "space") {

//ID와 PASSWORD가 제대로 입력되었는지 확인하고 제대로 입력이 안되면 오류메시지 출력
if(!$user_id || !$user_pass) {
        echo"<script> alert('아이디와 비밀번호를 제대로 입력해주세요.'); history.back(-1); </script>";
        exit;
}

//DB 설정
$db_host = "localhost"; //호스트네임을 입력하세요.
$db_database = $user_id; //디비네임을 입력하세요.
$db_user = $user_id; //아이디을 입력하세요.
$db_pwd = $user_pass; //패스워드를 입력하세요.
$db_total = 20; //디비 용량을 입력해주세요. MB단위로 적어주세요.

//수정하실 부분... 여기까지 끝...

function dir_size($dirname)
{
        $dir_space = 0;
        if(!is_dir($dirname)) return;
        $handle = @opendir($dirname);
        while($filename = @readdir($handle))
        {
                if ($filename == "." || $filename == "..") continue;
                $file_name = $dirname."/".$filename;
                if(is_dir($file_name)) $dir_space += dir_size($file_name);
                else $dir_space += filesize($file_name);
        }
        closedir($handle);
        return $dir_space;
}

$dir_name = "/apm_setup/users/".$user_id;
//존재하는 사용자인지 확인, 존재하지 않으면 오류메시지 출력
if(!is_dir($dir_name)) {
        echo"<script> alert('존재하지 않는 사용자입니다.'); history.back(-1); </script>";
        exit;
}

$dir_space = 0;
$handle = opendir($dir_name);
while($filename = readdir($handle))
{
        if ($filename == "." || $filename == "..") continue;
        $file_name = $dir_name."/".$filename;
        if(is_dir($file_name)) $dir_space += dir_size($file_name);
        else $dir_space += filesize($file_name);
}
closedir($handle);
$disk_using = $dir_space;
$disk_total = 100;
$disk_total = $disk_total * 1024 * 1024;
$disk_free = $disk_total-$disk_using;
$r_disk_using = sprintf("%0.1f",$disk_using/$disk_total*100);
$r_disk_free = 100-$r_disk_using;

//이 아래부터는 설정할 부분이 없습니다.
$db_total = $db_total*1024*1024; //MB -> Byte

//db접속
$db_con = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_database, $db_con);

//전체테이블현황을 불러오는 쿼리문
$result = mysql_query("SHOW TABLE STATUS", $db_con);
$db_using = 0;
while($dbData=mysql_fetch_array($result))
{
        $db_using += $dbData[Data_length]+$dbData[Index_length];
}
$db_free = $db_total-$db_using;
$r_db_using = sprintf("%0.1f",$db_using/$db_total*100);
$r_db_free = 100-$r_db_using;

//파일크기를 KB, MB, etc 변환해서 리턴
function size($size)
{
        if(!$size) return "0 Byte";
        if($size<1024)
                {
                        return ($size." Byte");
                }
        elseif($size >1024 && $size< 1024 *1024)
                {
                        return sprintf("%0.1f KB",$size / 1024);
                }
        else return sprintf("%0.1f MB",$size / (1024*1024));
}
?>
<html>
<head>
<title>Space Checker (only pje444.com) // Disk <?=size($disk_using)?>, DB <?=size($db_using)?></title>
<style>
<!--
TD {font-size:9pt;font-family:tahoma;color:FFFFFF}
A:link    {color:FFFFFF;text-decoration:none;}
A:visited {color:FFFFFF;text-decoration:none;}
A:active  {color:FFFFFF;text-decoration:none;}
A:hover  {color:999999;text-decoration:none;}
-->
</style>
</head>
<body bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" height="100%">
  <tr>
    <td>
      <div align="center">
        <table width="500" bgcolor="#000000" cellspacing="0" cellpadding="20" style='table-layout:fixed;border:1 solid; border-color:#333333'>
          <tr>
            <td>
              <div align="center">
                <p><h3><i>Space Checker</i> <a href="http://pje444.com" target="_blank"><font face="tahoma" color="#333333" style="font-size:9px;">(only pje444.com)</font></a></h3></p>
                <p>
                                <b><font size="2" color="#FFFFFF">*</font>Disk space - <?=$user_id?></b><br>
                                Total <?=size($disk_total)?> | Using <font color="#CCCCCC"><?=size($disk_using)?>(<?=$r_disk_using?>%)</font> | Free <font color="#CCCCCC"><?=size($disk_free)?></font><br>
                                </p>
                <table width="400" border="1" height="16" cellspacing="0" cellpadding="0" bordercolor="#333333" style=table-layout:fixed>
                  <tr>
                    <td width="<?=$r_disk_using?>%" style="filter=progid:DXImageTransform.Microsoft.Gradient(GradientType=<SPAN class=font-color2>0</SPAN>, StartColorStr=#000000, EndColorStr=#FFFFFF)">
                      </td>
                                        <td width="<?=$r_disk_free?>%" bgcolor="#000000">
                      </td>
                  </tr>
                </table>
                <br>
                <p>
                                <b><font size="2" color="#FFFFFF">*</font>DB space - <?=$user_id?></b><br>
                                Total <?=size($db_total)?> | Using <font color="#CCCCCC"><?=size($db_using)?>(<?=$r_db_using?>%)</font> | Free <font color="#CCCCCC"><?=size($db_free)?></font>
                                </p>
                <table width="400" border="1" height="16" cellspacing="0" cellpadding="0" bordercolor="#333333" style=table-layout:fixed>
                  <tr>
                    <td width="<?=$r_db_using?>%" style="filter=progid:DXImageTransform.Microsoft.Gradient(GradientType=<SPAN class=font-color2>0</SPAN>, StartColorStr=#000000, EndColorStr=#FFFFFF)">
                      </td>
                                        <td width="<?=$r_db_free?>%" bgcolor="#000000">
                      </td>
                  </tr>
                </table>
                                <p style='font-size:9px;'><A HREF="http://jstyle.byus.net" target="_blank">Created by JSTYLE</A> / <A HREF="http://hyosub.uu.st" target="_blank">Modified by HyoSub</A></p>
                        </div>
            </td>
          </tr>
        </table>
          </div>
    </td>
  </tr>
</table>
</body>
</html>
<?
}
else {
?>
<html>
<head>
<title>Space Checker (only pje444.com)</title>
<style>
<!--
TD {font-size:9pt;font-family:tahoma;color:FFFFFF}
A:link    {color:FFFFFF;text-decoration:none;}
A:visited {color:FFFFFF;text-decoration:none;}
A:active  {color:FFFFFF;text-decoration:none;}
A:hover  {color:999999;text-decoration:none;}
-->
</style>
</head>
<body bgcolor="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding=0 cellspacing=0 width=100% height=100%>
<tr>
<td align=center>
<table cellpadding=20 cellspacing=0 width=220 height=170 style='table-layout:fixed;border:1 solid; border-color:#333333'>
<tr>
<td align=right>
<h3><i>Space Checker</i> <span style="font-size:9px;font-family:tahoma;">- Login</span></h3>
<form name='spacecheck'+ ' method='post'>
<input type='hidden' name='check' value='space'>
ID     <input style='background-color:black;color:white;border-width:1px;font-size:9px;font-family:tahoma;' type='text' name='user_id' size=10  maxlength=20><br>
PASS <input style='background-color:black;color:white;border-width:1px;font-size:9px;font-family:tahoma;' type='password' name='user_pass' size=10  maxlength=20><br>
<input style='background-color:black;color:white;border-width:1px;font-size:9px;font-family:tahoma;' type='submit' value='Check!'>
</form>
<span style='font-size:9px;'><A HREF="http://jstyle.byus.net" target="_blank">Created by JSTYLE</A> / <A HREF="http://hyosub.uu.st" target="_blank">Modified by HyoSub</A></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<? } ?>