메뉴 건너뛰기

프로그램언어

2014.02.27 10:38

유용한 함수 모음

조회 수 21422 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<?
///////////////////////////////////////////////////////////////////////
// 프로그램 ID : web-lib.php3
// 프로그램 설명 : WebSite Library 모음
// 작 성 자 : iHelpers
// 작 성 일 : 2001.06.22
// 


///////////////////////////////////////////////////////////////////////
// 함  수  명 : PrintMsg
// 입력 필드
// $strMessage : 출력될 메시지
// 리  턴  값 : 없음
// 설      명 : 화면에 메시지를 출력
function PrintMsg($strMessage)
{
?>
<script language="javascript">
<!--
alert("<?echo $strMessage;?>");
//-->
</script>
<?
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : PrintMsgBack
// 입력 필드
// $strMessage : 출력될 메시지
// 리  턴  값 : 없음
// 설      명 : 화면에 메시를 출력하고 이전 페이지로 이동
function PrintMsgBack($strMessage)
{
?>
<script language="javascript">
<!--
alert("<?echo $strMessage;?>");
history.back();
//-->
</script>
<?
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : cuttingStr
// 입력 필드
// $str : 자를 문자열
// $divpnt : 문자열 크기
// 리  턴  값 : $substring
// 설      명 : 문자열 길이가 길때 "..."으로 대치
function cuttingStr($str, $divpnt) {
$retArray = array();
if ( strlen($str) <= $divpnt ) {
return $str;
}
for ( $i=0, $substring="", $hanStart=false; $i < $divpnt; $i++ ) {
$char=substr($str,$i,1);

if ( ord($char) > 127 ) { // toggle
if ( $hanStart ) $hanStart = false;
else $hanStart = true;
}

if ( $i >= ($divpnt -1) ) {
if ( ord($char) <= 127 || !$hanStart ) $substring .= $char;
else $substring = substr($substring,0,$i--);
break;
}
$substring .= $char;
}
return $substring . "...";
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : TimeComp
// 입력 필드
// $temptime : 날짜
// 리  턴  값 : $new
// 설      명 :
Function TimeComp($temptime)
{
/* 인자 형식
YYYY-MM-DD
YYYY-MM-DD HH:mm:ss
*/

$save = GetTimeStamp($temptime);
$now = GetTimeStamp(date("Y-m-d H:j:s"));
$diff = (int)(($now - $save)/60/60);

if ($diff < 35){
$new = "TRUE";
}
else{
$new = "FALSE";
}
return $new;
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : GetTimeStamp
// 입력 필드
// $date : 날짜
// 리  턴  값 : $time
// 설      명 :
function GetTimeStamp($date)
{
/* 인자 형식
YYYY-MM-DD
YYYY-MM-DD HH:mm:ss
*/
if (strlen($DATE) == 10) {
$time = mktime(0,0,0,(int)substr($date,5,2),
(int)substr($date,8,2),(int)substr($date,0,4));
} else {
$time = mktime((int)substr($date,11,2),(int)substr($date,14,2),
(int)substr($date,17,2),(int)substr($date,5,2),(int)substr($date,8,2),
(int)substr($date,0,4));
}
return $time;
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : DayDiff
// 입력 필드
// $day : 계산할 날짜
// 리  턴  값 : 날짜의 차이
// 설      명 : 입력한 날짜를 오늘과 비교하여 날짜의 차이를 계산
function DayDiff($day)
{
$save = GetTimeStamp($day);
$now = GetTimeStamp(date("Y-m-d H:j:s"));
return ($now-$save)/60/60/24;
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : CheckBrowser
// 입력 필드
// $num : Explore value
// $num2 : Netscape value
// 리  턴  값 : 브라우저 value
// 설      명 : 브라우저 종류 체크
function CheckBroswer($num, $num2)
{
global $HTTP_USER_AGENT;

if (strpos($HTTP_USER_AGENT, "MSIE")) {
return $num;
} else {
return $num2;
}
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : GoUrl
// 입력 필드
// $strUrl : 이동할 Url
// 리  턴  값 : 없음
// 설      명 : 지정한 url로 이동
function GoUrl($strUrl)
{
?>
<script language="javascript">
<!--
varUrl = '<?echo $strUrl;?>';
if (varUrl !="") {
document.location.replace(varUrl);
}
//-->
</script>
<?
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : RedirectTarget
// 입력 필드
// $url : 이동할 Url
// $target : 바뀔 target명
// 리  턴  값 : 없음
// 설      명 : 지정한 url & Target 으로 이동
function RedirectTarget($url,$target,$param="")
{
?>
<html>
<body onLoad="document.form1.submit()";>
<form action="<?echo $url;?>" target="<?echo $target;?>" name=form1 method=post>
<input type=hidden name=name value=""><?echo $param;?>
</form>
</body>
</html>
<?
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : RedirectTarget2
// 입력 필드
// $url : 이동할 Url
// $target : 바뀔 target명
// $param : 전달할 parameter
// 리  턴  값 : 없음
// 설      명 : 지정한 url & Target 으로 Parameter를 전달
function RedirectTarget2($url,$target,$param)
{
?>
<html>
<body onLoad="document.form1.submit()";>
<form action="<?echo $url;?>" target="<?echo $target;?>" name=form1 method=post>
<?echo $param;?>
</form>
</body>
</html>
<?
}


///////////////////////////////////////////////////////////////////////
// 함  수  명 : CloseWindow
// 입력 필드
// $opener : 부모창
// 리  턴  값 : 없음
// 설      명 : 창이 닫힐때 부모창을 reLoad
function CloseWindow($opener)
{ ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>저장중</title>
<SCRIPT LANGUAGE="javascript">
<!--
function close_win() {
<? if ($opener == "opener") echo "opener.document.location.reload();";?>
self.close();
}
//-->
</SCRIPT>

</head>
<body bgcolor=white onload="close_win()">
</body>
</html>
<?
}

///////////////////////////////////////////////////////////////////////
// 함  수  명 : GoBack
// 입력 필드
// $strUrl : 지정된 url
// 리  턴  값 : 없음
// 설      명 : 지정된 Url로 돌아감
function GoBack($strUrl)
{
?>
<html>
<head></head>
<body onLoad="document.form1.submit();">
<form name=form1 method=post action="<?echo $strUrl;?>">
<input type=hidden name=name value=>
</form>
</html>
<?
}

///////////////////////////////////////////////////////////////////////
// 함  수  명 : CompStr
// 입력 필드
// $buffer : 비교할 값
// $value : 입력된 값
// 리  턴  값 : 없음
// 설      명 :
function CompStr($buffer, $value) {
if (strlen($buffer) <= strlen($value)) return false;

if (substr($buffer, 0, strlen($value)) == $value) {
return true;
} else {
return false;
}
}

///////////////////////////////////////////////////////////////////////
// 함  수  명 : PrintDate
// 입력 필드
// $date : 날짜
// 리  턴  값 : 없음
// 설      명 :
function PrintDate($date){
$date = substr($date,0,10);
return $date;
}


////////////////////////////////////////////////
// HTML 메일 보내기
function SendMail($from_name, $from_email, $to_name, $to_email, $subject, $content) {
//$bodytext = base64_encode("<html><body><font size=2>$content</font></body></html>");
$bodytext = "<html><body><font size=2>$content</font></body></html>";
$mailheaders = "Return-Path: ".$from_email."
From: $from_name <$from_email>
MIME-Version: 1.0
X-Mailer: PHP/".phpversion()."
Importance: normal
Content-Type: text/html;  charset="ks_c_5601-1987"
";
return mail($to_email, $subject, $bodytext, $mailheaders);
}

///////////////////////////////////////////////////////////////////////
// 함  수  명 : NumberPrint
// 입력 필드
// $num : 숫자
// 리  턴  값 : 콤마 처리 숫자
// 설      명 : 콤마 처리 함수
function NumberPrint($num)
{
if( $num == ""){
return "";
} else {
return number_format($num);
}
}


?>

List of Articles
번호 제목 날짜 조회 수
160 PHP의 유동변수!? - $a1 ~ $a2 같은 형식의 변수를 반복문 돌릴때... 2017.03.06 16610
159 PHP웹 보안 취약점 TOP5(웹해킹) 2023.01.12 292
158 PHP와 HTML과 자바스크립트의 관계 2021.03.26 311
157 PHP에서의 대칭 암호화/복호화 ― 간단한 예제에서 DB 입/출력까지 2018.09.14 3548
156 php에서 체크박스 선택한 것 보여주기 file 2019.01.08 1805
155 PHP에서 조건문 처리 2015.04.14 22038
154 PHP에서 자바스크립트 값 가져오기 2014.02.27 31635
153 PHP에서 자료, 데이터의 타입을 확인하는 방법, gettype() 2018.08.29 2447
152 PHP에서 암호화 encrypt 복호화 decrypt 해서 값을 넘기기 2018.02.09 10626
151 PHP에서 모든 세션 정보를 화면에 출력하는 방법 2018.08.29 2693
150 PHP에서 데이터를 엑셀(Excel)로 저장 2017.02.19 18428
149 PHP에서 UTF와 EUC-KR 변환 2019.02.19 1553
148 PHP에서 PDF파일 생성하기 2014.02.27 32777
147 PHP에서 Excel 파일을 만들 수 있는 PHPExcel file 2017.03.06 17112
146 PHP에서 CSV 파일 export file 2016.04.22 22333
145 PHP로 엑셀 자료 MySQL에 넣기 2017.03.06 17875
144 PHP로 Excel 파일 만들기... 2014.02.27 30257
143 php로 db 컨트롤 1 2017.03.06 15769
142 phpMyAdmin WebMysql 에 CSV 엑셀 파일 업로드 입력하기 ( Excel / Upload / data / 데이터 / 데이타 ) file 2021.03.25 754
141 phpexcel을 이용한 PHP로 엑셀파일 읽기와 생성 file 2017.03.06 22787
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved