|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /home/queenjbs/www/schedule/ |
Upload File : |
<?
$Host = "localhost";
$User = "queenjbs";
$Password = "jbs5642";
$Database = "jyjsite";
class mySQL
{
// Error Define
var $Errno = 0;
var $Error = FALSE;
var $Auto_Free = 0; // Set to 1 for automatic mysql_free_result()
var $Debug = 0; // Set to 1 for debugging messages.
var $Halt_On_Error = "no"; // "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Record = array();
var $Row;
var $Link_ID = 0;
var $error_no = 0;
// Database Connect
function connect()
{
global $Host, $User, $Password, $Database;
if(!$Database || !$Host || !$User || !$Password)
{
$this->halt("cannot use database");
exit;
}
if( 0 == $this->Link_ID )
{
$this->Link_ID=mysql_connect($Host, $User, $Password);
mysql_select_db("$Database")or die("cannot select DB : $Database");
if(!$this->Link_ID)
{
$this->halt("pconnect($Host, $User, $Password) failed.");
return 0;
}
if(!@mysql_select_db($Database,$this->Link_ID))
{
$this->halt("cannot use database ".$Database);
return 0;
}
}
/*
$qry = "
delete..update..insert
";
$this->query($qry);
if(!$this->error_no()) { $this->rollback(); $this->message1("입력 오류입니다."); }
*/
mysql_query("set autocommit=0"); // 0 -> commit 사용 해야함, innoDB 의 경우만! 예) $oci->commit();
return $this->Link_ID;
}
# Query
function query($Query_String)
{
if(!$Query_String)
{
return 0;
}
if(!$this->connect())
{
return 0;
}
// New query, discard previous result.
if($this->error_no)
{
$this->free();
}
if($this->Debug)
{
printf("Debug: query = %s<br>\n", $Query_String);
}
$this->error_no = @mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if(!$this->error_no)
{
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->error_no;
}
# Fetch Array
function fetch_result()
{
if(!$this->error_no)
{
$this->halt("next_record called with no query pending.");
return 0;
}
$this->Record = @mysql_fetch_result($this->error_no);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if(!$stat && $this->Auto_Free)
{
$this->free();
}
return $stat;
}
// Fetch Array
function fetch_array()
{
if(!$this->error_no)
{
$this->halt("next_record called with no query pending.");
return 0;
}
$this->Record = @mysql_fetch_array($this->error_no);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if(!$stat && $this->Auto_Free)
{
$this->free();
}
return $stat;
}
// Data Seek
function data_seek($pos = 0)
{
$status = @mysql_data_seek($this->error_no, $pos);
if($status)
$this->Row = $pos;
else {
$this->halt("seek($pos) failed: result has ".$this->num_rows()." rows");
@mysql_data_seek($this->error_no, $this->num_rows());
$this->Row = $this->num_rows;
return 0;
}
return 1;
}
# table count rows
public function rowCount($table,$where=null)
{
if($where) $where = "WHERE $where";
$query = "
SELECT COUNT(*) FROM $table $where
";
$this->query($query);
$this->fetch_array();
//echo "$query";
return $this->field(0);
}
# 칼럼 값에 대한 복호화 유무
public function field($Name,$s=null)
{
if(preg_match("/p/i",$s)) return $this->MySQL->ekpb_crypt("d",$this->Record[$Name]);
if(preg_match("/e/i",$s)) return $this->MySQL->ekpb_crypt("e",$this->Record[$Name]);
if(preg_match("/d/i",$s)) return $this->MySQL->ekpb_crypt("d",$this->Record[$Name]);
else return $this->Record[$Name];
}
# InnoDB 사용의 경우 : commit
function commit()
{
mysql_query("commit");
}
# InnoDB 사용의 경우 : rollback
function rollback()
{
mysql_query("rollback");
}
# select value name
# 무조건 CMB_MEMBER 에서 search
function selectName($num)
{
if(!$num) return '';
$query = "
SELECT CMB_NAME FROM CMB_MEMBER WHERE CMB_NUM = ".$num."
";
$this->query($query);
$this->fetch_array();
return $this->field(CMB_NAME);
}
// viewName($table,$field,$where,$num)
function viewName($table,$field,$where,$num)
{
if(!$num) return '';
$query = "
SELECT $field FROM $table WHERE $where = ".$num."
";
$this->query($query);
$this->fetch_array();
return $this->field(0);
}
// Affected Rows
function affected_rows() { return @mysql_affected_rows($this->Link_ID); }
function num_rows() { return @mysql_num_rows($this->error_no); }
function num_fields() { return @mysql_num_fields($this->error_no); }
function nf() { return $this->num_rows(); }
function np() { print $this->num_rows(); }
function p($Name) { print $this->Record[$Name]; }
function free() { @mysql_free_result($this->error_no); $this->error_no = 0; }
function DB_sql($query = "") { $this->query($query); }
function link_id() { return $this->Link_ID; }
function error_no() { return $this->error_no; }
function halt($msg)
{
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
if($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
if($this->Halt_On_Error != "report") die("Session halted.");
}
function haltmsg($msg)
{
printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br>\n",$this->Errno,$this->Error);
}
////////////////////////////////
// 에러 메시지 처리 함수
////////////////////////////////
function error2($msg)
{
echo "<script>window.alert('$msg'); history.back();</script>";
exit;
}
////////////////////////////////
// DB에 테이블이 있는지 체크
////////////////////////////////
function isTable($dbName, $TableName)
{
$result = mysql_list_tables($dbName);
while ($row=mysql_fetch_row($result))
{
if($row[0]==$TableName) return 1;
}
return 0;
}
//////////////////////////
// Message 1. (Back)
//////////////////////////
function message31($msg,$url,$nArray,$vArray)
{
if($msg)
{
$msgVal = "window.alert(\"$msg\");";
}
if(is_array($nArray)==true && is_array($vArray)==true)
{
for($i=0;$i<count($nArray);$i++)
{
$inputForm .= "<input type=hidden name='".$nArray[$i]."' value='".$vArray[$i]."'>";
}
}
else
if($nArray && $vArray)
{
$inputForm .= "<input type=hidden name='".$nArray."' value='".$vArray."'>";
}
echo "
<form name=SecurePostForm method='post'>
$inputForm
</form>
<script>
$msgVal
document.SecurePostForm.target = '';
document.SecurePostForm.action = '$url';
document.SecurePostForm.submit();
</script>
";
exit;
}
// Message 0. (분기)
function message0($msg,$name,$value,$url)
{
echo "
<form method=GeT name=LoginCheck>
<input type=hidden name=$name value='$value'>
<script>
window.alert(\"$msg\");
document.LoginCheck.action = '$url';
document.LoginCheck.submit();
</script>
";
exit;
}
// Message 1. (Back)
function message1($msg)
{
echo "
<script>
window.alert(\"$msg\");
history.back();
</script>
";
exit;
}
// Message 2. (Go Home)
function message2($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
location.href='$url';
</script>
";
exit;
}
// Message 3. (Go Home)
function message3($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
top.location.href='$url';
</script>
";
exit;
}
// Message 4. (Go Home)
function message4($url)
{
echo "
<script>
location.href='$url';
</script>
";
//exit;
}
// Message 5. (Go Home)
function message5($msg)
{
echo "
<script>
window.alert(\"$msg\");
window.close();
</script>
";
}
// message6
function message6($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
top.location.href='$url';
window.close();
</script>
";
exit;
}
// message7
function message7($msg)
{
echo "
<script>
window.alert(\"$msg\");
</script>
";
}
// Message 8. ()
function message8($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
location.href='$url';
</script>
";
exit;
}
// message9
function message9($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
parent.location.href='$url';
window.close();
</script>
";
exit;
}
// message10
function message10($msg,$url)
{
echo "
<script>
window.alert(\"$msg\");
self.location.href='$url';
window.close();
</script>
";
exit;
}
function message01() { echo "<script>window.close();</script>"; }
function message02() { echo "<script>window.opener.location.reload(); parent.window.close();</script>"; }
function message03() { echo "<script>history.back;</script>"; }
function message04($url) { echo "<script>location.href='$url';</script>"; }
function message05($url) { echo "<script>window.opener.location.href='$url'; parent.window.close();</script>"; }
function message11($msg) { echo "<script>window.alert(\"$msg\");</script>"; }
function message12($msg) { echo "<script>window.alert('$msg'); history.back();</script>"; }
function message13($msg) { echo "<script>window.alert('$msg'); top.window.close();</script>"; }
function message14($msg) { echo "<script>window.alert('$msg'); window.opener.location.reload(); parent.window.close();</script>"; }
function message15($msg) { echo "<script>window.alert('$msg'); top.window.opener.location.reload(); top.window.close();</script>"; }
function message16($msg,$url) { echo "<script>window.alert('$msg'); location.href='$url';</script>"; }
function message17($msg,$url) { echo "<script>window.alert('$msg'); top.location.href='$url';</script>"; }
function message18($msg,$url) { echo "<script>window.alert('$msg'); top.location.href='$url'; window.close();</script>"; }
function message19($msg,$url) { echo "<script>window.alert('$msg'); parent.location.href='$url'; window.close();</script>"; }
function message20($msg,$url) { echo "<script>window.alert('$msg'); self.location.href='$url'; window.close();</script>"; }
function message21($msg,$url) { echo "<script>window.alert('$msg'); top.window.opener.location.href='$url'; top.window.close();</script>"; }
function message50($msg,$url) { echo "<script>window.confirm('$msg'); location.href='$url';</script>"; }
function message51($msg,$url) { echo "<script>window.confirm('$msg'); location.href='$url target=_top';</script>"; }
// ModalPopups
function message60($msg,$popmid,$reload='R')
{
if($msg ) echo "<script language='javascript'>window.alert('$msg');</script>";
if($reload) echo "<script language='javascript'>parent.location.reload();</script>";
if($popmid) echo "<script language='javascript'>parent.ModalPopups.Close('".$popmid."');</script>";
}
///////////////////////////////////////
// text 체크(메모장) TEXT or HTML
///////////////////////////////////////
//소수점이하 자리 올림(ceil)
function ceilChk($val, $int)
{
$exp_val = explode(".",$val); //분할
$sub_val = substr($exp_val[1], 0, $int);
$chk_val = substr($exp_val[1], $int, 1);
if($chk_val > 0)
$sub_val = $sub_val + 1;
if($sub_val == 0)
{
$tun_val = $exp_val[0];
} else {
$tun_val = $exp_val[0].'.'.$sub_val;
}
return $tun_val;
}
//소수점이하 자리 버림(floor)
function floorChk($val, $int)
{
$exp_val = explode(".",$val); //분할
$sub_val = substr($exp_val[1], 0, $int);
if($sub_val == 0)
{
$tun_val = $exp_val[0];
} else {
$tun_val = $exp_val[0].'.'.$sub_val;
}
return $tun_val;
}
function htmlCheckView($chkName)
{
$chkName = stripslashes($chkName);
$chkName = stripslashes($chkName);
//if((strpos($chkBody, "<table" ) > 0) or
if((stristr(strtolower($chkName), "<table" )==true) or
(stristr(strtolower($chkName), "<object" )==true) or
(stristr(strtolower($chkName), "<a" )==true) or
(stristr(strtolower($chkName), "<tr" )==true) or
(stristr(strtolower($chkName), "<div" )==true) or
(stristr(strtolower($chkName), "<img" )==true) )
{
//$chkName = htmlspecialchars($chkName);
} else {
// $chkName = str_replace("<br />","<br>",$chkName);
$chkName = str_replace(" "," ",$chkName);
}
return $chkName;
}
function htmlCheckEdit($chkName)
{
$chkName = stripslashes($chkName);
$chkName = stripslashes($chkName);
$chkName = str_replace("<br />","",$chkName);
//$chkName = htmlspecialchars($chkName);
return $chkName;
}
function usetagCheckEdit($chkName)
{
if((stristr(strtolower($chkName), "<table" )==true) or
(stristr(strtolower($chkName), "<object" )==true) or
(stristr(strtolower($chkName), "<a" )==true) or
(stristr(strtolower($chkName), "<tr" )==true) or
(stristr(strtolower($chkName), "<div" )==true) or
(stristr(strtolower($chkName), "<img" )==true) )
{
$htmlValue = 'Y';
} else {
$htmlValue = 'N';
}
return $htmlValue;
}
///////////////////////////////////////
// 날짜 관리
///////////////////////////////////////
// 날짜 계산하기(2003-11-13 16:01:44)
function ToDayReset($ToDay,$Y="",$m="",$d="",$H="",$i="",$s="",$ReType="")
{
$ToDay = preg_replace("/\/|\-|\_|\.|\:| /",'',$ToDay);
$ToDay_Y = substr($ToDay, 0, 4);
$ToDay_m = substr($ToDay, 4, 2);
$ToDay_d = substr($ToDay, 6, 2);
$ToDay_H = substr($ToDay, 8, 2);
$ToDay_i = substr($ToDay, 10, 2);
$ToDay_s = substr($ToDay, 12, 2);
// 기본타입
if(!$ReType)
{
$ReType = "Y-m-d H:i:s";
}
$Return_Val = date($ReType, mktime($ToDay_H + $H, $ToDay_i + $i, $ToDay_s + $s, $ToDay_m + $m, $ToDay_d + $d, $ToDay_Y + $Y));
return $Return_Val;
}
// 두 날자 사이의 일수 구하기
function DayGapSearch($date1, $date2)
{
$date1 = preg_replace("/\/|\-|\_|\.|\:| /",'',$date1);
$date2 = preg_replace("/\/|\-|\_|\.|\:| /",'',$date2);
$Return_Val =
abs(
mktime(0, 0, 0,
intval(substr($date2,4,2)),
intval(substr($date2,6,2)),
intval(substr($date2,0,4))
) -
mktime(0, 0, 0,
intval(substr($date1,4,2)),
intval(substr($date1,6,2)),
intval(substr($date1,0,4))
)
) / 86400 + 1; // 하루 = 86400초
return $Return_Val;
}
// 날짜함수 보기 형식 변경
function DateReset($date1,$ReType)
{
if(!$date1) return "";
$date = preg_replace("/\/|\-|\_|\.|\:| /","",$date1);
if($ReType)
{
$year01 = substr($date, 0, 4);
$month01 = substr($date, 4, 2);
$day01 = substr($date, 6, 2);
}
if(!$ReType)
{
$Return_Val = $date;
}
else
if($ReType=='H')
{
$Return_Val = ($year01*1)."년 ".($month01*1)."월 ".($day01*1)."일";
}
else
{
unset($Return_Val);
if($year01 ) $Return_Val .= $year01;
if($month01) $Return_Val .= $ReType.$month01;
if($day01 ) $Return_Val .= $ReType.$day01;
}
return $Return_Val;
}
////////////////////////////
// 암호화
////////////////////////////
function PassWordStart($s1, $s2)
{
$s1 = $s1; //id
$s2 = $s2; //password
$length1 = strLen($s1);
$length2 = strLen($s2);
//$s1 및 $s2는 4자리 이상이고 20자리 미만 이여야 한다.
if ($length1 < 4 || $length2 < 4)
{
return -1;
}
else
if ($length1 > 20 || $length2 > 20)
{
return -1;
}
//입력받은 값을 모두 대문자로 바꾼다.
$s1 = strToUpper($s1);
$s2 = strToUpper($s2);
//A-Z 이외의 캐릭터 수정 시작
for ($i = 0 ; $i < $length1 ; $i++) {
$shift = ord(subStr($s1, $i, 1));
if ($shift < 65 || $shift > 90) {
$shift = 65 + $shift%24;
$s1 = str_replace(subStr($s1, $i, 1), chr($shift), $s1);
}
}
for ($i = 0 ; $i < $length2 ; $i++) {
$shift = ord(subStr($s2, $i, 1));
if ($shift < 65 || $shift > 90) {
$shift = 65 + $shift%24;
$s2 = str_replace(subStr($s2, $i, 1), chr($shift), $s2);
}
}
//A-Z 이외의 캐릭터 수정 끝
$offset = ord(subStr($s1, 1, 1)); //$s1의 두번쨰 문자
$root = ord(subStr($s2, $length2-1, 1)); //$s2의 마지막 문자
$shift = ord(subStr($s1, $length1-1, 1)); //$s1의 마지막 문자
$shift %= 13; //$s1의 마지막 문자를 13으로 나눈 나머지
$answer = $s1.$s2; //$s1와 $s2를 합친다.
$position = 1;
for ($i = 1 ; $i < 20 ; $i++) {
if (strLen($answer) >= 20) {
break;
}
$shift = $shift + $offset + $i;
if ($shift > 90) {
$shift %= 24;
$shift += 65;
}
if ($position == 1) {
$answer = $answer.chr($shift);
$position = 0;
} else {
$answer = chr($shift).$answer;
$position = 1;
}
}
for ($i = 0 ; $i < 20 ; $i++) {
$shift = ord(subStr($answer, $i, 1));
$shift += $root + ($i + 1);
if ($shift > 90) {
$shift %= 24;
$shift += 65;
}
$answer = subStr($answer, 0, $i).chr($shift).subStr($answer, $i+1);
}
return subStr($answer, 0, 20);
}
////////////////////////////
// String Length Limited
////////////////////////////
// 한글 자르기
function han_substr($string,$limit_length,$type='')
{
$string_length = strlen($string);
if($limit_length > $string_length)
{
return $string;
} else {
$string = substr( $string, 0, $limit_length );
$han_char = 0;
for($i=$limit_length-1;$i>=0;$i--) {
$lastword = ord(substr($string,$i,1));
if(127 > $lastword) {
break;
} else {
$han_char++;
}
}
if( $han_char%2 == 1 ) {
$string = substr( $string, 0, $limit_length-1 );
}
return($string.$type);
}
}
// 일반 배열값 라디오버튼 폼 만들기(라벨등록)(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayFormRL($items,$value,$inVal,$name,$disabled='',$onclick='',$trEa=0,$ARR_USE='')
{
$returnVal = "<table border='0' cellspacing='0' cellpadding='0'><tr>";
for($i=0; $i < count($items) ; $i++)
{
if($ARR_USE=='' || (is_array($ARR_USE) && $ARR_USE[$i]=='Y'))
{
if(strpos($items[$i],'==')===true && (strpos($items[$i],"<")===false || strpos($items[$i],"'")===false))
{
$exp_val = explode("=",$items[$i]);
$items_val = $exp_val[0];
$value_val = $exp_val[1];
}
else
{
$items_val = $items[$i];
$value_val = $value[$i];
}
// 자바스크립트
if($onclick)
{
$onclickV = "onclick=".$onclick."(this);";
}
// 행구분(라인이 긴 경우)
if($trEa && $i!=0 && ($i % $trEa)==0)
{
$returnVal .= "</tr><tr>";
}
if($inVal == $value_val)
{
$ms_raVal = "checked";
}
else
{
$ms_raVal = '';
}
$returnVal .= "<td><input type='radio' name='$name' value='$value_val' id='".$name."_$value_val' $ms_raVal $onclickV></td>";
$returnVal .= "<td valign='bottom'><LABEL STYLE='cursor:pointer;' OnMouseOver=style.textdecoration='underline' OnMouseOut=style.textdecoration='none' FOR='".$name."_$value_val'>$items_val</LABEL></td><td> </td>";
}
}
$returnVal .= "</tr></table>";
return($returnVal);
}
// 년도 배열값 셀렉트바 option 만들기(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayYYYY($YYYY,$NUM,$inVal)
{
for($i=0; $i <= $NUM; $i++)
{
$vi = $YYYY - $i;
if($inVal == $vi) $ms_raVal = "SELECTED"; else $ms_raVal = '';
$returnVal .= "<option value='$vi' $ms_raVal>$vi";
}
return($returnVal);
}
// 년도 배열값 셀렉트바 option 만들기(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayYYYYurl($YYYY,$NUM,$inVal,$url)
{
for($i=0; $i <= $NUM; $i++)
{
$vi = $YYYY - $i;
if($inVal == $vi) $ms_raVal = "SELECTED"; else $ms_raVal = '';
$returnVal .= "<option value='$url?inVal=$vi' $ms_raVal>$vi";
}
return($returnVal);
}
// 일반 배열값 셀렉트바 option 만들기(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayFormS($items,$value,$inVal,$ARR_USE='')
{
for($i=0; $i < count($items); $i++)
{
if($ARR_USE=='' || (is_array($ARR_USE) && $ARR_USE[$i]=='Y'))
{
if(strpos($items[$i],'==')===true && (strpos($items[$i],"<")===false || strpos($items[$i],"'")===false))
{
$exp_val = explode("=",$items[$i]);
$items_val = $exp_val[0];
$value_val = $exp_val[1];
}
else
{
$items_val = $items[$i];
$value_val = $value[$i];
}
if($inVal == $value_val) $ms_raVal = "SELECTED"; else $ms_raVal = '';
$returnVal .= "<option value='$value_val' $ms_raVal>$items_val";
}
}
return($returnVal);
}
// select form array overriding ...
function ArrayFormS1($ARR_NUM,$inVal,$name,$MESS="")
{
global ${ARR_NAME_.$ARR_NUM},${ARR_FCODE_.$ARR_NUM},${ARR_USE_.$ARR_NUM};
$items = ${ARR_NAME_.$ARR_NUM};
$value = ${ARR_FCODE_.$ARR_NUM};
$arr_use = ${ARR_USE_.$ARR_NUM};
$name = preg_replace("/ /","",chop(trim($name)));
$returnVal = $this->ArrayFormS($items,$value,$inVal,$arr_use);
$returnVal = "<select name='$name' id='$name'".$MESS."><option value=''>선택</option>".$returnVal."</select>";
return($returnVal);
}
// select form array overriding ...
function ArrayFormS2($items,$value,$inVal,$name,$ARR_USE="",$MESS="")
{
$name = preg_replace("/ /","",chop(trim($name)));
$returnVal = $this->ArrayFormS($items,$value,$inVal,$ARR_USE);
$returnVal = "<select name='$name' id='$name'".$MESS."><option value=''>선택</option>".$returnVal."</select>";
return($returnVal);
}
// 일반 배열값 찾기
// usage : name, value, $value
function ArrayVal($items,$value,$inVal)
{
if(strpos($items[0],'==')===true && (strpos($items[0],"<")===false || strpos($items[0],"'")===false))
{
for($i=0; $i < count($items); $i++)
{
$exp_val = explode("=",$items[$i]);
if($exp_val[1] == $inVal)
{
$returnVal = $exp_val[0];
break;
}
}
}
else
{
if($value && in_array($inVal,$value))
{
$returnVal = $items[(array_search($inVal,$value))];
}
}
return($returnVal);
}
// 체크박스 값 있으면 체크
function CheckboxVal($value,$inVal)
{
if($value == $inVal)
{
$returnVal = " checked";
}
return($returnVal);
}
// 일반 배열값 셀렉트바 option 만들기(검색전용 -> 업.직종 합침)(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayFormWJ($items,$value,$inVal,$type)
{
$Count = count($items);
for($i=0; $i < $Count; $i++)
{
if($inVal == $value[$i]) $ms_raVal = "SELECTED"; else $ms_raVal = '';
$returnVal .= "<option value='$value[$i]|$type' $ms_raVal>$items[$i]";
}
return($returnVal);
}
// 일반 배열 값 리스트 만들기
function ArrayListForm($items,$value,$inVal,$codeVal)
{
$onMouse = "onmouseover=\"this.style.background='F0F0E1'; this.style.cursor='hand';\" onmouseout=\"this.style.background='FFFFFF';\"";
$Count = count($items);
for($i=1; $i < $Count; $i++)
{
if($inVal==$value[$i]) $ms_bold = '<font color=8A5509><b>'; else $ms_bold = '';
$returnVal .= "
<a href=\"javascript:ScriptStart('$codeVal','$value[$i]','$items[$i]')\"><tr bgcolor='FFFFFF' $onMouse><td style='padding:3 0 0 10'>$ms_bold$items[$i]</td></tr></a>";
}
return($returnVal);
}
function ArrayListForm2($items,$value,$inVal,$codeVal,$type,$flag,$colEa)
{
if(!$items || !$value || !$type || !$flag)
{
$this->message12("기본값이 없습니다. \\n\\n확인 후 다시 시도해 주십시요!");
exit;
}
if(!$colEa) $colEa = 6;
if($colEa)
{
$returnVal .= "
<tr height='20'>";
if($codeVal=='GB')
{
$ii = 1;
$returnVal .= "
<td width='2%'>· <b>전국</td>";
}
for($i=0; $i < count($items); $i++)
{
if($value[$i] && $inVal==$value[$i])
{
$ms_bold = '<b>';
$ms_bVal = 'yes';
}
else
{
if((stristr($items[$i],"전체")==true) && !$ms_bVal)
$ms_bold = '<b>';
else
$ms_bold = '';
}
if($value[$i])
{
$ii++;
if(stristr($items[$i],"전체")==true) $value[$i] = '';
if($codeVal=='GB')
$returnVal .= "
<td width='2%'>· <a href=\"javascript:goListScript('','$items[$i]','$value[$i]','".substr($type,3)."','$flag')\">$ms_bold$items[$i]</a></td>";
else
$returnVal .= "
<td width='2%'>· <a href=\"javascript:goListScript('$value[$i]','$items[$i]','$codeVal','".substr($type,3)."','$flag')\">$ms_bold$items[$i]</a></td>";
}
if((($ii) % $colEa)==0)
$returnVal .= "
</tr>
<tr height='20'>";
}
$returnVal .= "
</tr>";
}
return($returnVal);
}
// 체크박스 폼 만들기(자바스크립트와 같이 사용하므로 함부로 폼에 엔터키를 넣지 마시요!)
function ArrayFormCB($items,$value,$inVal,$name,$onclick)
{
$returnVal .= "<input type='checkbox' name='".$name."' value='".$value."' ".$this->CheckboxVal($inVal,$value)." ".$onclick." id='".$name."'> ";
$returnVal .= "<LABEL STYLE='cursor:hand;' OnMouseOver=style.textdecoration='underline' OnMouseOut=style.textdecoration='none' FOR='".$name."'>".$items."</LABEL>";
return($returnVal);
}
// 배열 체크박스 폼 만들기
function ArrayFormCBa($items,$value,$inVal,$name,$disabled,$onclick,$trEa,$v_type)
{
$returnVal = "<table border='0' cellspacing='0' cellpadding='0'><tr>";
for($i=0; $i < count($items) ; $i++)
{
if(strpos($items[$i],'=')===false)
{
$items_val = $items[$i];
$value_val = $value[$i];
}
else
{
$exp_val = explode("=",$items[$i]);
$items_val = $exp_val[0];
$value_val = $exp_val[1];
}
// 행구분(라인이 긴 경우)
if($trEa && $i!=0 && ($i % $trEa)==0)
{
$returnVal .= "</tr><tr>";
}
if($v_type=='input' || !$v_type)
{
$returnVal .= "<td style='padding-right:6px;'>".$this->ArrayFormCB($items_val,$value_val,$inVal[$i],$name[$i],$onclick[$i])."</td>";
}
else
if($v_type=='view')
{
if($value_val == $inVal)
{
$view_Val .= ", ".$items_val;
}
}
}
if($v_type=='view' && $view_Val)
{
$returnVal .= "<td>".substr($view_Val,2)."</td>";
}
$returnVal .= "</tr></table>";
return($returnVal);
}
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 파일 관련 함수
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 지정된 파일이 Locking중인지 검사
function check_fileislocked($filename)
{
$f = @fopen($filename,w);
$count = 0;
$break = true;
while(!@flock($f,2))
{
$count++;
if($count>10)
{
$break = false;
break;
}
}
if($break!=false) @flock($f,3);
@fclose($f);
}
// 파일 읽기
function iReadFile($filename)
{
if(!file_exists($filename))
{
return '';
}
$f = fopen($filename,"r");
$str = fread($f, filesize($filename));
fclose($f);
return $str;
}
// 파일 데이타 쓰기
function iWriteFile($filename, $str)
{
$f = fopen($filename,"w");
$lock = flock($f,2);
if($lock)
{
fwrite($f,$str);
}
flock($f,3);
fclose($f);
}
// 디렉토리내 파일 및 디렉토리 삭제하기
function DirDelete($DirName)
{
if(substr($DirName,-1)=="/")
{
$DirName = substr($DirName,0,-1);
}
if(is_dir($DirName))
{
$OpenDir = opendir($DirName);
while(($filename = readdir($OpenDir)) !== false)
{
if($filename!="." && $filename!="..")
{
$path = $DirName."/".$filename;
if(is_dir($path))
{
$this->DirDelete($path);
}
else
if(is_file($path))
{
unlink($path);
}
}
}
rmdir($DirName);
}
}
// 디렉토리내 파일 및 디렉토리 삭제하기
function PHP_WriteFile($DirName,$SaveFileName,$Save_PHP_Val)
{
$DOC_DIR = explode($_SERVER["DOCUMENT_ROOT"],$DirName);
if(count($DOC_DIR) > 1)
{
$STR_DIR = str_replace($_SERVER["DOCUMENT_ROOT"],"",$DirName);
$EXP_DIR = explode("/",$STR_DIR);
for($i=0;$i < count($EXP_DIR);$i++)
{
if($EXP_DIR[$i])
{
$MK_DIR .= "/".$EXP_DIR[$i];
if(!is_dir($_SERVER["DOCUMENT_ROOT"].$MK_DIR."/"))
{
mkdir($_SERVER["DOCUMENT_ROOT"].$MK_DIR."/", 0777);
if(!is_dir($_SERVER["DOCUMENT_ROOT"].$MK_DIR."/"))
{
$this->message12("디렉토리 생성 권한이 없습니다. \\n\\n관리자에게 문의해 주십시오.(".$AdminTelNo.")");
exit;
}
}
}
}
}
if(file_exists($SaveFileName))
{
unlink($SaveFileName);
}
if(!file_exists($SaveFileName))
{
$this->iWriteFile($SaveFileName, '<?'."\n".($Save_PHP_Val)."\n".'?>');
}
if(!file_exists($SaveFileName))
{
$this->message12("파일이 저장되지 않습니다. \\n\\n관리자에게 문의해 주십시오.(".$AdminTelNo.")");
exit;
}
}
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 메일발송
##++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// $receiver_email // 받는 메일주소
// $sender // 보내는 사람
// $sender_email // 보내는 메일주소
// $subject // 메일 제목
// $messages // 본문 메시지
// $userfile // 첨부파일
// $filePath // 서버내 파일을 읽을 경우
function mailer($receiver_email, $sender, $sender_email, $subject, $messages, $userfile, $userfile_name, $userfile_size, $userfile_type, $filePath)
{
if($filePath && substr($filePath,-1)!="/")
{
$filePath = $filePath."/";
}
if($receiver_email && $subject)
{
$subject = stripslashes($subject);
$messages = stripslashes($messages);
// 입력내용이 HTML인지 확인한다.
if($this->usetagCheckEdit($messages)=='N')
{
$messages = nl2br("$messages");
}
// 서버내 파일을 읽을 경우
if($userfile && $filePath && file_exists($filePath.''.$userfile))
{
$userfile_size = filesize($filePath.''.$userfile);
$userfile_type = filetype($filePath.''.$userfile);
$userfile_name = $userfile;
$userfile = $filePath.''.$userfile;
}
$current_time = time();
$signdate = date("Y년 m월 d일 H시 i분 s초", $current_time);
//메일 header
$add_header .= "Return-Path: $sender\r\n";
$add_header .= "From: ".$sender." <".$sender_email.">\r\n";
$add_header .= "X-Mailer: webmail\r\n";
$boundary = "----".uniqid("part");
// Body의 경계에 사용할 데이터 구하기
$boundary = '=_'.md5(uniqid(time()));
// 첨부파일이 있는 경우
if($userfile && $userfile_size)
{
$filename = $userfile_name;
$fp = fopen($userfile, "r");
$file = fread($fp, $userfile_size);
fclose($fp);
if($userfile_type == "")
$userfile_type = "application/octet-stream";
// header part
// Multipart/mixed 일경우 첨부파일이 있다는 것을 의미한다.
$add_header .= "MIME-Version: 1.0\r\n";
$add_header .= "Content-Type: Multipart/mixed; boundary = \"$boundary\"";
// 본문파트
$mailbody = "This is a multi-part message in MIME format.\r\n\r\n";
$mailbody .= "--$boundary\r\n";
$mailbody .= "Content-Type: text/html; charset=\"ks_c_5601-1987\"\r\n";
$mailbody .= "Content-Transfer-Encoding: base64\r\n\r\n";
$mailbody .= base64_encode($messages)."\r\n\r\n";
$mailbody .= "--$boundary\r\n";
$mailbody .= "Content-Type: $userfile_type; name=\"$filename\"\r\n";
$mailbody .= "Content-Transfer-Encoding: base64\r\n";
$mailbody .= "Content-Disposition: attachment; filename=\"$filename\"\r\n\r\n";
$mailbody .= base64_encode($file)."\r\n\r\n";
$mailbody .= "--$boundary--";
$add_header.= "MIME-Version: 1.0\r\n";
$add_header.= "Content-Type: multipart/mixed;".
chr(13).chr(10).chr(9)."boundary=\"$boundary\"\r\n\r\n";
}
else
{
$mailbody = $messages;
$add_header .= "Reply-To: $sender_email\n";
$add_header .= "Content-Type: text/html;charset=EUC-KR";
}
mail($receiver_email, $subject, $mailbody, $add_header, '-f'.$sender_email);
}
}
##--------------------------------------------------------------------------------------------------------
// 테이블 리스트 헤더 고정하기
// 테이블 너비, 높이, 헤드 타이틀 높이, 헤드 배경 색상, 테두리 색상
##--------------------------------------------------------------------------------------------------------
function TableHeaderFix($W_VAL='920px',$H_VAL='400px',$TR_H=25,$BAC_COLOR='cfdef3',$BORDER_COLOR='cccccc')
{
$ReturnVal[0] = "
<style type='text/css'>
.fix-th { font-family: 돋움;font-size: 12px;color:#000000;font-weight:normal;padding:0px 0px 0px 10px; }
.fix-table { background-color: white; width: 100%; overflow-x: hidden; overflow-y: auto; }
.fixed-table-container { width: ".$W_VAL."; height: ".$H_VAL."; border: 1px solid #".$BORDER_COLOR."; margin: 0px 0px 0px 0px; background-color: white; position: relative; padding-top: ".$TR_H."px; }
.fixed-table-container-inner { overflow-x: hidden; overflow-y: auto; height: 100%; }
.header-background { background-color: #".$BAC_COLOR."; height: ".$TR_H."px; position: absolute; top: 0; right: 0; left: 0; }
.th-inner { position: absolute; top: 0; line-height: ".$TR_H."px; text-align: center; }
</style>
<div class='fixed-table-container".$DOUBLE_ROW_DIV."'>
<div class='header-background'></div>
<div class='fixed-table-container-inner'>";
$ReturnVal[1] = "
</div></div>";
return $ReturnVal;
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: 페이지 만들기
# date : 2012.07.25.
# usage : $PARSER 는 페이지별로 위에서 정의해줘야 함.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function PageMaking($URL, $PARSER, $total, $clickPage, $PostNum, $start, $end, $widthpage, $totalpage)
{
static $s = "style='padding: 0px 4px 0px 4px; text-size: 12px; color: #0D89E6;'";
static $f = "style='padding: 0px 4px 0px 4px; text-size: 12px; color: #0D89E6; font-family: consolas;'";
$PAGE_LINK .= "
<center>
<div style='height: 20px;' class='pi'>
";
if($widthpage > 1)
{
$prev = $clickPage - $PostNum;
$PAGE_LINK .= "<a href='$URL?$PARSER&page=1&field=$field&word=$word&array=$array&desc=$desc' $s> |◀ </a>";
$PAGE_LINK .= "<a href='$URL?$PARSER&page=$prev&field=$field&word=$word&array=$array&desc=$desc' $s> ◀ </a>";
}
for($start;$start<= $end;$start++)
{
if($clickPage == $start)
{
$PAGE_LINK .= "<span style='font-family: consolas; padding: 0px 3px 0px 3px; color: #09558E; text-weight: bold;'><b>$start</b></span>";
}
else
{
$PAGE_LINK .= "<a href='$URL?$PARSER&page=$start&field=$field&word=$word&array=$array&desc=$desc' $f>$start</a>";
}
}
if($totalpage > $end)
{
$end = ceil($total / $PostNum);
$next = $clickPage + $PostNum;
if($next > $end) $next = $end;
$PAGE_LINK .= "<a href='$URL?$PARSER&page=$next&field=$field&word=$word&array=$array&desc=$desc' $s> ▶ </a>";
$PAGE_LINK .= "<a href='$URL?$PARSER&page=$end&field=$field&word=$word&array=$array&desc=$desc' $s> ▶| </a>";
}
$PAGE_LINK .= "
</div>
</center>
";
return $PAGE_LINK;
}
# Ajax 데이타 주고 받기 스크립트
function AjaxSuccess($URL)
{
$ReturnVal = "
$.ajax({
type: 'post',
url: '$URL',
data: dataString,
cache: false,
success: function(data)
{
var sp_data = data.split('|+|');
for(var i=0; i < sp_data.length ;i++ )
{
var sp_arr = sp_data[i].split('::');
AjaxSuccessSend(frm, sp_arr[0], sp_arr[1], sp_arr[2]);
}
}
});
";
return $ReturnVal;
}
# 데이타베이스 필드 '$field' 를 감쌈.
function F($name,$value,$com)
{
echo "str: $value<br>";
echo "str: ".str_replace(" ","",$name)."<br>";
echo "str: ".${str_replace(" ","",$name)}."<br>";
echo "str: $name<br>";
echo "str: $name<br>";
if($com == 1) $result = "'".${str_replace(" ","",$name)}."',"; // 콤마 있음
else if($com == 2) $result = "'".${str_replace(" ","",$name)}."' "; // 콤마 없음
return $result;
}
//////////////////////////
// Buffer & Memory Clear
//////////////////////////
function BufferClear()
{
//leak();
flush();
}
# memory reset
function flush_buffers()
{
//ob_end_flush();
//ob_flush();
flush();
ob_start();
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: html form pattern
# date : 2012.11.22.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function MakePattern($method=1, $type, $name, $value=null, $class="box2", $size=null, $style=null, $readonly=null,$script=null,$file=null,$id=null)
{
if($size)
{
if($type=="checkbox") $size = $this->CheckboxVal($value,$size);
else $size = "size='$size'";
}
if($class) $class = "class='$class'";
if($id ) $id = "id='$id'";
else $id = "id='$name'";
switch($method)
{
case "1": $d = "<input type='$type' name='$name' $id value='$value' ".$size." $class $style $readonly $script>$file"; break;
case "2": $d = "<select name='$name' $id ".$size." $readonly $script $style>$value</select>"; break;
case "3": $d = "<textarea name='$name' $id $style $readonly $script>$value</textarea>"; break;
}
return $d;
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject : doGet(x) & doPost(o)
# date : 2012.11.22.
# history : [일반조건] 값이 넘어오는 모든 값을 입력함!
# [전제조건] 입력 값만 할 경우 if( preg_match("/\_/",$name) && $value )
# [전제조건] ?? 암호화 !! _p 면 자돈 암호화
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public function doGet($_GET,$update,$retUrl)
{
$this->doPost2($_GET,$update,$retUrl);
}
# 값, 입력/수정선택, 리턴URL, 검색파라메타 값
public function doPost2($_POST,$update,$retUrl,$aceWord=null)
{
global $member_id;
$TODATE = date("YmdHis");
# POST METHOD OUTPUT
if($_POST)
{
static $ii = 0; // 루프 개수 카운트
# 루프
foreach ($_POST as $name => $value)
{
$name = chop(trim($name ));
$value = chop(trim($value));
# 전제조건: 유효한 값인 경우만 -> 변수가 _ 가 포함되하며 값이 있는 경우만
if(preg_match("/^SER\_/i",$name))
{
// 통과 ( skip ..... )
}
else
if( preg_match("/\_/",$name) )
{
# 업로드 파일 존재 유무 체크는 1회만
if($ii == 0 && $_FILES)
{
$FILE_INFO = $this->doFile($_FILES); // doFile 메쏘드 호출
$F_NAME = $FILE_INFO[0]; //
$F_VALUE = $FILE_INFO[1][name]; // 실제 파일명
$F_TEMP_NAME = $FILE_INFO[1][tmp_name]; // 임시저장파일명
$RealValue = $this->FileUpload($F_VALUE,$F_TEMP_NAME); // 파일 업로드 ( 실제 파일명, 임시저장파일명 )
}
# 비교 시 소문자로 전환
$str_name = strtolower($name);
# 수정(yes)인지 입력(no)인지
# 수정 시 예외인 경우는 한번 더 고심 할것. (분석하기가 용이하지 않으면 보류)
# where 과 frontQry 을 분리 안한 이유??????
# 수정!!!
if($update == "yes")
{
# FILE UPLOAD
if($ii == 0 && $F_TEMP_NAME ) { $frontQry .= " ,$F_NAME = '$RealValue' \n"; } // 업로드 파일이 있는 경우 한번만!
# SET
if(substr($str_name,-2)=="_p" ) { $frontQry .= ",$name = '".$this->MySQL->ekpb_crypt("e",$value,'')."'\n"; } // 암호저장
else if(preg_match("/_update_u/i",$str_name)) { $frontQry .= ",$name = '$member_id' \n"; } // 수정자
else if(preg_match("/_update_d/i",$str_name)) { $frontQry .= ",$name = $TODATE \n"; } // 수정일
else { $frontQry .= ",$name = '$value' \n"; } // 기본
# WHERE
if(preg_match("/_create_u/i",$str_name)) { $where .= ""; } // 입력자
else if(preg_match("/_create_d/i",$str_name)) { $where .= " AND $name= $value "; } // 입력일
else if(substr($str_name,3)=="_num" ) { $where .= " AND $name= $value "; } // 키값
}
# 입력!!!
else
{
# FILE UPLOAD
if($ii == 0 && $F_TEMP_NAME ) { $frontQry .= " ,$F_NAME \n"; $lastQry .= ",'$RealValue' \n"; } // 업로드 파일이 있는 경우
# SET
if(substr($str_name,-2)=="_p" ) { $frontQry .= " ,$name \n"; $lastQry .= ",'".$this->MySQL->ekpb_crypt("e",$value,'')."'\n"; } // 암호저장
else if(preg_match("/_create_u/i",$str_name)) { $frontQry .= " ,$name \n"; $lastQry .= ",'$member_id' \n"; } // 입력자
else if(preg_match("/_create_d/i",$str_name)) { $frontQry .= " ,$name \n"; $lastQry .= ", $TODATE \n"; } // 입력일
else { $frontQry .= " ,$name \n"; $lastQry .= ",'$value' \n"; } // 기본
}
$ii++; // 루프 카운트
}
}
}
if($update == "yes")
{
$resultQuery[0] = substr(trim($frontQry),1);
$resultQuery[1] = "\n\nWHERE \n".substr(trim($where),3);
}
else
{
$resultQuery[0] = substr(trim($frontQry),1);
$resultQuery[1] = substr(trim($lastQry ),1);
}
//echo "필드의 개수: $ii<br>";
# 예외처리
if($ii == 0) { $resultQuery = null; $this->message2("입력된 값이 존재 하지 않습니다.",$retUrl); }
UNSET($where,$frontQry,$lastQry);
return $resultQuery;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# 업로드 file 제어
public function doFile($_FILES)
{
$debug = null;
foreach($_FILES as $name => $file)
{
if($debug != null)
{
echo "
<pre>
====================
$name
====================
$file[name]
$file[type]
$file[tmp_name]
$file[error]
$file[size]
--------------------
</pre>
";
}
}
return array($name,$file);
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: 파일업로드메쏘드
# date : 2012.11.22.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public function FileUpload($UPLOAD_FILE,$TEMP_NAME,$SAVE_DIR="")
{
if($UPLOAD_FILE)
{
global $CMB_UPLOAD_FILE;
static $MAX_WIDE = 150;
if(!$SAVE_DIR) $SAVE_DIR = $CMB_UPLOAD_FILE;
# 파일명/확장자/베이스명 추출
$path_parts = pathinfo(urlencode($UPLOAD_FILE)); // Fuction
$up_file_name_t = $path_parts['extension']; // Exec
# 파일 속성 체크 부분 (입력된확장자,확장자 배열,허락유무
//$this->FileCheckFormat($up_file_name_t,"php,inc","not");
//echo "
//<pre>
// -------------------------
// $UPLOAD_FILE
// $TEMP_NAME
// $path_parts
// $up_file_name_t
// $SAVE_DIR
// -------------------------
//";
if(!is_dir($SAVE_DIR)) mkdir($SAVE_DIR, 0777);
# 파일존재여부체크
for($RE=0;$RE<10000;$RE++)
{
$re_file_name = 'FILE_'.date("YmdHis").'_'.$RE.'.'.$up_file_name_t; // 파일명을 다시 만든다.(File + Num + Exec)
$real_path_file = $SAVE_DIR."/".$re_file_name; // 실제 파일이 저장될 값
if(!file_exists($real_path_file)) break;
}
if(preg_match("~\b(jpg|jpeg|gif|png)\b~i",$up_file_name_t) && $FileImageWidth > $MAX_WIDE)
{
# 이미지 사이즈 정보
$FileImageSize = GetImageSize($TEMP_NAME);
$FileImageWidth = $FileImageSize[0];
$FileImageHeight = $FileImageSize[1];
system("convert -strip -channel RGB -resize $MAX_WIDE '$TEMP_NAME' '$real_path_file'");
}
else
{
# 업로드된 파일 /tmp/?????? 를 $real_path_file 로 복사
if(@exec("cp $TEMP_NAME $real_path_file ")!=0) $oci->message1("tmp --> 복사 에러");
}
//echo "[$re_file_name] [$SAVE_DIR] cp $TEMP_NAME $real_path_file"; exit;
return $re_file_name;
}
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# FileCheckFormat(입력된확장자,확장자 배열,허락유무
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public function FileCheckFormat($File_Tail,$Extension,$Allow="yes")
{
echo "==> $File_Tail / $Extension / $Allow<br>";
$Extension = explode(",",$Extension);
$LOOP = COUNT($Extension);
for($i=0;$i<$LOOP;$i++)
{
if($Allow == "yes") if($File_Tail == $Extension[$i]) { echo "OK"; } else { echo "no"; }
if($Allow == "not") if($File_Tail == $Extension[$i]) { echo "NO"; } else { echo "ok"; }
}
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: doSelect
# date : 2012.11.22.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
// SELECT COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_NAME = 'BKC_BUSINESS_CODE'
function doSelect($qry,$qtype="")
{
global $Temp_Dir; // 1회용 임시 파일 저장소
if(!$qtype) $qtype = "oci"; // DB 쿼리를 변경 할 수 있도록 추가 KimPB 2012.12.31
$TempFile = $Temp_Dir."/_select_".str_replace(" ","",microtime());
$TempFile = str_replace(".","",$TempFile);
//echo "$qry<br>";
if($qry)
{
$result = mysql_query($qry);
$i = 0;
while ($i < mysql_num_fields($result))
{
$meta = mysql_fetch_field($result, $i);
// 비교 시 소문자로 전환
$str_name = strtolower($meta->name);
// PRIMARY
if( $i == 0 || preg_match("/_create_d/i",$str_name))
{
$_PRIMARY .= "&".$meta->name."=".'$'."".$meta->name."";
$_WHERE .= " AND ".$meta->name."='".'$'."".$meta->name."'";
}
# output value
if(substr($str_name,-2)=="_p") $LIST .= "\n ".'$'."".$meta->name." = ".'$'."".$qtype."->MySQL->ekpb_crypt('d', ".'$'."".$qtype."->field(".$meta->name."),'');";
else $LIST .= "\n ".'$'."".$meta->name." = ".'$'."".$qtype."->field(".$meta->name.");";
//echo "**>".$meta->name."<br>";
$i++;
}
$LIST .= "\n ".'$'."PRIMARY_VAl=\"".substr($_PRIMARY,1)."\";";
$LIST .= "\n ".'$'."WHERE_VAl=\"".substr($_WHERE,5)."\";";
}
//echo "<pre>$LIST</pre>";
//exit;
$this->PHP_WriteFile($Temp_Dir,$TempFile,$LIST);
return $TempFile;
}
# _P 칼럼의 암호화
public function passValue($str_name, $str_value)
{
if(substr($str_name,-2)=="_P") $ret = $this->MySQL->ekpb_crypt("e", $str_value);
return $ret;
}
# _P 칼럼의 암호화 ??????
public function secureValue($str_value, $type)
{
$ret = $this->MySQL->ekpb_crypt($type, $str_value);
return $ret;
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: 파일 다운로드
# date : 2012.11.22.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function downloadFile( $fullPath )
{
# Must be fresh start
if( headers_sent() ) die('Headers Sent');
# Required for some browsers
if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');
# File Exists?
if( file_exists($fullPath) )
{
# Parse Info / Get Extension
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
# Determine Content Type
switch ($ext)
{
case "pdf" : $ctype="application/pdf" ; break;
case "exe" : $ctype="application/octet-stream" ; break;
case "zip" : $ctype="application/zip" ; eak;
case "doc" : $ctype="application/msword" ; break;
case "xls" : $ctype="application/vnd.ms-excel" ; break;
case "ppt" : $ctype="application/vnd.ms-powerpoint" ; break;
case "gif" : $ctype="image/gif" ; break;
case "png" : $ctype="image/png" ; break;
case "ai" : $ctype="application/postscript" ; break;
case "jpeg":
case "jpg" : $ctype="image/jpg" ; break;
default : $ctype="application/force-download"; ; break;
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$fsize);
ob_clean();
flush();
readfile( $fullPath );
}
else
{
die('file not found');
}
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: 예외사항 처리
# date : 2012.11.22.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
public function _ExceptionErrorMessage($str,$code=null)
{
try
{
$mag = "
<div style='text-align: center; height:100%; color: #999999; width: 100%'>
<div style='height: 100px;'></div>
<img src='/Images/alert256.png' border=0>
<div style='height: 30px;'></div>
<div style='font-size: 12px; text-align: center; border: 0px solid red; color: #999999; width: 100%;'>
<br> Exception Code = $code
<br> $str
<!--
해당 페이지는 잘못 입력되었거나 존재하지 않는 페이지입니다.
웹 페이지의 주소가 변경 또는 삭제되었거나 요청하신 페이지를 찾을 수 없습니다.
다시한번 확인해 보시기 바랍니다.
-->
<div style='height: 30px;'></div>
<input type='button' onClick=history.back(); value='이전화면' class='button gray normal bs'>
</div>
</div>
";
}
catch(Exception $e)
{
$mag =$e;
}
return $mag;
}
# 교인 번호를 이름으로!
public function OutputName($cmb_num)
{
$qry = "
SELECT CMB_NAME FROM CMB_MEMBER WHERE CMB_NUM='$cmb_num'
";
//echo $qry;
$this->query($qry);
$this->fetch_array();
$cmb_name = $this->field(CMB_NAME);
return $cmb_name;
}
# 교인 검색 공통 폼
function FromSearchPerson($id="CMB_NAME", $name="CMB_NAME", $value="", $size=10)
{
$form = "<input type='text' id='$id' name='$name' size='$size' value='$value' class='box2'>".
"<img src='../Images/Edit-Male-User16.png' onclick=OpenSend('search','CPV_RESERVATION','','$id') style='cursor: pointer;' align='absmiddle'>";
return $form;
}
// 배열 입력시 입력내용이 없는 배열 값을 제외하고 앞으로 재정렬
// $ValArray : 넘어오는 배열 값 전체 배열처리
// $StanVal : 꼭 입력하여야 할 값의 배열($ValArray) 순위 한개만 숫자로..
function NoValueDefined($ValArray,$StanVal)
{
$ii = 0;
for($i=0;$i<count($ValArray[0]);$i++)
{
if($ValArray[$StanVal][$i]!='')
{
for($j=0;$j<count($ValArray);$j++)
{
$ValArray_NVD[$j][$ii] = $ValArray[$j][$i];
}
$ii++;
}
}
return $ValArray_NVD;
}
// 인쇄 엑티브 엑스
function PrintScriptX($P_SEND='true',$PORTRAIT='true',$T_MARGIN=20,$B_MARGIN=15,$R_MARGIN=1.0,$L_MARGIN=1.0,$HEADER="",$FOOTER="")
{
if($FOOTER)
$FOOTER = strip_tags($FOOTER)." - Page &p of &P";
// 인쇄 대화창 열기 여부
if($P_SEND=='true')
$PRINTING_OPEN = "factory.printing.Print(true);";
$ReturnVal = "
<object id='factory' viewastext style='display:none' classid='clsid:1663ed61-23eb-11d2-b92f-008048fdd814' codebase='http://ekpb.co.kr/FileSave/ScriptX/smsx.cab#Version=7,1,0,60'></object>
<script>
function printWindow()
{
factory.printing.header = \"$HEADER\";
factory.printing.footer = \"$FOOTER\";
factory.printing.portrait = $PORTRAIT; // false 면 가로인쇄, true 면 세로 인쇄
factory.printing.topMargin = $T_MARGIN;
factory.printing.bottomMargin = $B_MARGIN;
factory.printing.rightMargin = $R_MARGIN;
factory.printing.leftMargin = $L_MARGIN;
$PRINTING_OPEN
// navigate or close browser here //
}
printWindow();
</script>
";
// factory.printing.SetMarginMeasure(1); // set inches(2)
// factory.printing.copies = 1; // 인쇄 매수
// factory.printing.printBackground = true; // 백그라운드까지 출력
// factory.printing.WaitForSpoolingComplete(); // 스풀링
return $ReturnVal;
}
// 복식부기 기본 결재 양식
function ApprovalForm()
{
$ReturnVal = "
<table border='0' cellpadding='0' cellspacing='0' class='table_p_border' style='width: 265px;'>
<tr>
<td style='width: 25px;height: 90px;text-align:center;' rowspan='2'>결<br><br><br>재</td>
<td style='width: 80px;height: 20px;text-align:center;'>담당</td>
<td style='width: 80px;height: 20px;text-align:center;'>총무</td>
<td style='width: 80px;height: 20px;text-align:center;'>부장</td>
</tr>
<tr><td style='height: 70px;'> </td><td> </td><td> </td></tr>
</table>
";
return $ReturnVal;
}
// 복식부기 기본 보고서 헤드부분 인쇄 양식
function HeaderPrintForm($Width, $Title, $DepName, $PrintLink="", $ApprovalForm="y", $SER_DATE_01, $SER_DATE_02)
{
global $member_year;
if($SER_DATE_01 || $SER_DATE_02)
{
if(!$SER_DATE_01) $SER_DATE_01 = $member_year.".01.01";
if(!$SER_DATE_02) $SER_DATE_02 = $member_year.".12.31";
if($SER_DATE_02 > date("Y.m.d")) $SER_DATE_02 = date("Y.m.d");
$SER_DATE_FORM = "<tr><td style='width: 70px;font-weight:bold;text-align:left;padding:3px 0px 1px 0px;'><span style='letter-spacing:23.5px;'>기</span>간 :</td><td style='font-weight:bold;padding:3px 0px 1px 0px;text-align:left;'>".$SER_DATE_01." ~ ".$SER_DATE_02."</td></tr>";
}
if($PrintLink)
{
$PrintLinkCss = "cursor:pointer;";
$PrintLinkSrc = " onclick='factory.printing.Print(true);'";
}
$ReturnVal = "
<table border='0' cellpadding='0' cellspacing='0' style='width: ".$Width."px;'>
<tr>
<td align='left' style='padding:0px 0px 0px 3px;vertical-align: bottom;".$PrintLinkCss."'".$PrintLinkSrc.">
<table border='0' cellpadding='0' cellspacing='0' style='width: 100%;'>
<tr><td colspan='2' style='color: #000000;font-size: 24px;line-height: 32px;font-weight:bold;text-align:left;padding: 0px 0px 5px 0px;'>$Title</td></tr>
$SER_DATE_FORM
<tr><td style='width: 70px;font-weight:bold;text-align:left;padding:3px 0px 1px 0px;'>출력일시 : </td><td style='font-weight:bold;padding:3px 0px 1px 0px;text-align:left;'>".date("Y.m.d H:i:s")."</td></tr>
<tr><td style='width: 70px;font-weight:bold;text-align:left;padding:3px 0px 1px 0px;'><span class='fls-07'>부서</span>명 :</td><td style='font-weight:bold;padding:3px 0px 1px 0px;text-align:left;'>$DepName</td></tr>
</table>
</td>
<td align='right' style='width: 265px;padding:0px 0px 0px 0px;vertical-align: bottom;".$PrintLinkCss."'".$PrintLinkSrc.">
".($ApprovalForm=="y" ? $this->ApprovalForm() : "")."
</td>
</tr>
</table>
<div style='height: 5px;'></div>
";
return $ReturnVal;
}
# 메뉴 체크 (1 row : 코드별 .. 상세 버튼 체크)
function MenuCheck($code,$use,$memNo,$Mode,$url)
{
# file path exception
if($use != "Y")
{
if(!preg_match("/Login.html/" , $url) &&
!preg_match("/Logout.html/", $url) &&
!preg_match("/Schedule/" , $url) &&
!preg_match("/Include/" , $url)
)
$this->message1("해당 메뉴[$code]는 사용 불가 메뉴입니다.");
//echo "===> $url";
}
else
{
// // Mode/
// 목록 CCA_01
// list 목록 CCA_01
// view 보기 CCA_02
// ins 입력 CCA_03
// mod 수정 CCA_04
// del 삭제 CCA_05
// 검색 CCA_06 (일단, 목록을 보면 검색 가능한 상태 .... Mode 값이 없음!)
// excel 엑셀 CCA_07
// message 문자발송 CCA_08
// email 메일 CCA_09
$qry = "
SELECT
*
FROM
CMB_CODE_AUTHORITY
WHERE
BME_NO = '$code' AND -- 목록코드
BUI_idx = '$memNo' -- 사용자번호
";
$this->query($qry);
$this->fetch_array();
$CCA_01 = $this->field(CCA_01); // 목록',
$CCA_02 = $this->field(CCA_02); // 보기',
$CCA_03 = $this->field(CCA_03); // 입력',
$CCA_04 = $this->field(CCA_04); // 수정',
$CCA_05 = $this->field(CCA_05); // 삭제',
//$CCA_06 = $this->field(CCA_06); // 검색',
$CCA_07 = $this->field(CCA_07); // 엑셀다운
$CCA_08 = $this->field(CCA_08); // 문자전송
$CCA_09 = $this->field(CCA_09); // 메일발송
$CCA_10 = $this->field(CCA_10); // 초기화',
$CCA_11 = $this->field(CCA_11); // 여분2',
$CCA_12 = $this->field(CCA_12); // 여분3',
$CCA_13 = $this->field(CCA_13); // 여분4',
$CCA_14 = $this->field(CCA_14); // 여분5',
$CCA_15 = $this->field(CCA_15); // 여분6',
//echo "MyClass.inc <font color=red style='font-size:12px;'><b>[$Mode/$CCA_01] $qry</b></font><br>";
if($Mode == "" ) { if(!$CCA_01 || $CCA_01 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '목록',
if($Mode == "view" ) { if(!$CCA_02 || $CCA_02 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '보기',
if($Mode == "ins" ) { if(!$CCA_03 || $CCA_03 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '입력',
if($Mode == "mod" ) { if(!$CCA_04 || $CCA_04 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '수정',
if($Mode == "del" ) { if(!$CCA_05 || $CCA_05 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '삭제',
//if($Mode == "search" ) { if(!$CCA_06 || $CCA_06 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '검색',
if($Mode == "excel" ) { if(!$CCA_07 || $CCA_07 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '엑셀다운',
if($Mode == "message") { if(!$CCA_08 || $CCA_08 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '문자전송',
if($Mode == "email" ) { if(!$CCA_09 || $CCA_09 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '메일발송',
//if($Mode == "" ) { if(!$CCA_10 || $CCA_10 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '초기화',
//if($Mode == "" ) { if(!$CCA_11 || $CCA_11 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '여분2',
//if($Mode == "" ) { if(!$CCA_12 || $CCA_12 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '여분3',
//if($Mode == "" ) { if(!$CCA_13 || $CCA_13 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '여분4',
//if($Mode == "" ) { if(!$CCA_14 || $CCA_14 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '여분5',
//if($Mode == "" ) { if(!$CCA_15 || $CCA_15 == "N") { echo $this->_ExceptionErrorMessage("권한이 없습니다.",$code); exit; } } // '여분6',
}
}
function substr_utf8($str,$from,$len)
{
//if($len > 200) $tail = " ...";
return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'. $from .'}'.'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'. $len .'}).*#s','$1', $str).$tail;
}
}
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#
# subject: extention secure class
# date : 2012.07.23.
#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
class Secure extends MySQL
{
public function ekpb_crypt($method,$str,$key="")
{
if($str!='' && $str!=NULL)
{
if(!$key)
{
global $__KEY__;
$key = $__KEY__;
}
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$type = md5(md5(mcrypt_create_iv($size, MCRYPT_RAND))); // md5(md5($key))
if($method == "e") $result = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $str, MCRYPT_MODE_CBC, md5(md5($key))));
elseif($method == "d") $result = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($str), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
}
return $result;
}
# 문자 전송 (SMS / LMS ) ---> MMS 는 없음!
function SendMessage($TYPE, $MSG_SEND, $CMB_HP_P, $MSG_SUBJECT="", $MSG_CONTENTS, $sendDate)
{
if($TYPE == "SMS")
{
$qry = "
INSERT INTO Mobile.SC_TRAN
(TR_SENDDATE , TR_SENDSTAT ,TR_MSGTYPE ,TR_PHONE ,TR_CALLBACK , TR_MSG)
VALUES
('$sendDate', '0', '0', '$CMB_HP_P', '$MSG_SEND', '$MSG_SEND')
";
$this->query($qry);
}
else if($TYPE == "LMS")
{
$qry = "
INSERT INTO MMS_MSG
(SUBJECT, PHONE, CALLBACK, STATUS, REQDATE, MSG, TYPE)
VALUES
('$MSG_SUBJECT', '$CMB_HP_P', '$MSG_SEND', '0','$sendDate', '$MSG_CONTENTS', '0' )
";
$this->query($qry);
}
}
}
# 객체생성
$oci = new mySQL(); $oci->connect(); $oci->flush_buffers();
$sec = new mySQL(); $sec->connect(); $sec->flush_buffers();
$new = new mySQL(); $new->connect(); $new->flush_buffers();
$oci->MySQL = new Secure;
$sec->MySQL = new Secure;
// 데이터베이스 한글 정의...
mysql_query("set Names utf8");
//
?>