<?
function iif($tst,$cmp,$bad) {
return(($tst == $cmp)?$cmp:$bad);
}
function ReadTextFile($filename) {
$fp = fopen($filename, "r");
if($fp) {
$buffer = fread($fp, filesize($filename));
//return mb_convert_encoding(htmlspecialchars($buffer), "UTF-8", "EUC-KR");
return $buffer;
} else return "";
fclose($fp);
}
function InStr($searchIn,$stringToSearch){
if($stringToSearch=="") return 0;
else {
$x=-1;
$x=strpos(strtoupper($searchIn),strtoupper($stringToSearch));
if ($x>-1) return $x+1; else return 0;
}
}
function requestVB($arg)
{
if($_POST[$arg]!="") {
return $_POST[$arg];
} else if($_GET[$arg]!="") {
return $_GET[$arg];
} else {
return $_SESSION[$arg];
}
}
function request_querystring($arg)
{
return $_GET[$arg];
}
function request_form($arg)
{
return $_POST[$arg];
}
function request_cookies($arg)
{
return $_COOKIE[$arg];
}
function POST_GET($arg)
{
if($_POST[$arg]!="") {
return $_POST[$arg];
} else {
//echo "OK POST\n";
return $_GET[$arg];
}
}
function left($arg1,$arg2)
{
return mb_substr($arg1,0,$arg2,"UTF-8");
}
function right($arg1,$arg2)
{
return mb_substr($arg1,-$arg2,$arg2,"UTF-8");
}
function mid($arg1,$arg2,$arg3)
{
return mb_substr($arg1,$arg2-1,$arg3,"UTF-8");
}
function replace($arg1,$arg2,$arg3) {
return str_replace($arg2,$arg3,$arg1);
}
function splitVB($arg1,$arg2) {
return explode($arg2,$arg1);
}
function serverExecute($PagePath) {
if(is_file($PagePath)==1) include($PagePath);
else echo "<!--" . $PagePath . ": 존재안함-->";
}
function WriteTextFile($filename, $StrOutText) {
$file = fopen($filename, "w");
fwrite($file , $StrOutText);
fclose($file);
}
function len($str) {
return strlen($str);
}
function uni_len($str) {
$len = strlen($str);
for ($i = $length = 0; $i < $len; $length++) {
$high = ord($str{$i});
if ($high < 0x80)//0<= code <128 범위의 문자(ASCII 문자)는 인덱스 1칸이동
$i += 1;
else if ($high < 0xE0)//128 <= code < 224 범위의 문자(확장 ASCII 문자)는 인덱스 2칸이동
$i += 1;
else if ($high < 0xF0)//224 <= code < 240 범위의 문자(유니코드 확장문자)는 인덱스 3칸이동
$i += 2;
else//그외 4칸이동 (미래에 나올문자)
$i += 2;
}
return $length;
}
function uni_left($str, $chars) {
if (uni_len($str) <= $chars)//전체 길이를 불러올 수 있으면 tail을 제거한다.
$tail = '';
else
$chars -= uni_len($tail);//글자가 잘리게 생겼다면 tail 문자열의 길이만큼 본문을 빼준다.
$len = strlen($str);
for ($i = $adapted = 0; $i < $len; $adapted = $i) {
$high = ord($str{$i});
if ($high < 0x80)
$i += 1;
else if ($high < 0xE0)
$i += 2;
else if ($high < 0xF0)
$i += 3;
else
$i += 4;
if (--$chars < 0)
break;
}
return trim(substr($str, 0, $adapted)) . $tail;
}
function console_log($str) {
?>
<img onerror="console.log(this.title);" src="" title="<?=$str?>" style="display:none;"/>
<script></script>
<?
}
function createFolder($strDir) {
global $base_root;
if(InStr(strtolower($strDir), strtolower($base_root)) > 0 ) {
if(!is_dir($strDir)) mkdir($strDir,0,true); //멀티레벨도 거뜬히 생성함.
} else console_log($strDir . " 는 지정경로를 이탈함");
}
//createFolder("C:\\APM_Setup\\htdocs\\qqq2");
function getTextStringEnter($str) {
$str = replace($str,"<style>","<!--style");
$str = replace($str,"<style","<!--style");
$str = replace($str,"</style>","/style-->");
$str = replace($str,"<script","<!--script");
$str = replace($str,"</script>","/script-->");
$str = replace($str,"<STYLE>","<!--STYLE");
$str = replace($str,"<STYLE","<!--STYLE");
$str = replace($str,"</STYLE>","/STYLE-->");
$str = replace($str,"<SCRIPT","<!--SCRIPT");
$str = replace($str,"</SCRIPT>","/SCRIPT-->");
$str = replace($str,"/css\">","/css");
$str = replace($str,"<br>","@enter");
$str = replace($str,"<BR>","@enter");
$str = replace($str,"<br/>","@enter");
$str = replace($str,"<br />","@enter");
$str = replace($str,"</p>","@enter");
$str = replace($str,"</P>","@enter");
$str = replace($str,"</div>","@enter");
$str = replace($str,"</DIV>","@enter");
$$nLen = len($str);
$sf = $str;
for($qq = 1; $qq <= $$nLen; $qq++) {
$st = InStr($qq,$str,"<");
$ed = InStr($st+1,$str,">");
if($st > 0 && $ed > 0) {
$ds = mid($str,$st,($ed+1)-$st);
$sf = replace($sf,$ds,"");
$qq = $ed;
}
}
$sf = replace($sf,"@enter","<br/>") ;
return $sf;
}
function FormatNum($pVal, $pFmt) {
$rValue = "";
$f = "0";
if(InStr($pFmt,",") > 0) {
if(InStr($pFmt,".") == 0) {
$rValue = number_format($pVal,0);
} else {
if(InStr($pFmt,".00000000") > 0) $rValue = number_format($pVal,8);
else if(InStr($pFmt,".0000000") > 0) $rValue = number_format($pVal,7);
else if(InStr($pFmt,".000000") > 0) $rValue = number_format($pVal,6);
else if(InStr($pFmt,".00000") > 0) $rValue = number_format($pVal,5);
else if(InStr($pFmt,".0000") > 0) $rValue = number_format($pVal,4);
else if(InStr($pFmt,".000") > 0) $rValue = number_format($pVal,3);
else if(InStr($pFmt,".00") > 0) $rValue = number_format($pVal,2);
else if(InStr($pFmt,".0") > 0) $rValue = number_format($pVal,1);
else $rValue = number_format($pVal,0);
}
} else {
if(InStr($pFmt,".") == 0) {
$pVal = round($pVal);
if(isSameString(left($pFmt,8),"00000000")) $rValue = sprintf("%08d", $pVal);
else if(isSameString(left($pFmt,7),"0000000")) $rValue = sprintf("%07d", $pVal);
else if(isSameString(left($pFmt,6),"000000")) $rValue = sprintf("%06d", $pVal);
else if(isSameString(left($pFmt,5),"00000")) $rValue = sprintf("%05d", $pVal);
else if(isSameString(left($pFmt,4),"0000")) $rValue = sprintf("%04d", $pVal);
else if(isSameString(left($pFmt,3),"000")) $rValue = sprintf("%03d", $pVal);
else if(isSameString(left($pFmt,2),"00")) $rValue = sprintf("%02d", $pVal);
else if(isSameString(left($pFmt,1),"0")) $rValue = sprintf("%01d", $pVal);
else $rValue = sprintf("%." . $f . "f", $pVal);
} else {
if(InStr($pFmt,".00000000") > 0) $f = "8";
else if(InStr($pFmt,".0000000") > 0) $f = "7";
else if(InStr($pFmt,".000000") > 0) $f = "6";
else if(InStr($pFmt,".00000") > 0) $f = "5";
else if(InStr($pFmt,".0000") > 0) $f = "4";
else if(InStr($pFmt,".000") > 0) $f = "3";
else if(InStr($pFmt,".00") > 0) $f = "2";
else if(InStr($pFmt,".0") > 0) $f = "1";
else $f = "0";
if(isSameString(left($pFmt,8),"00000000")) $rValue = sprintf("%0" . (9+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,7),"0000000")) $rValue = sprintf("%0" . (8+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,6),"000000")) $rValue = sprintf("%0" . (7+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,5),"00000")) $rValue = sprintf("%0" . (6+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,4),"0000")) $rValue = sprintf("%0" . (5+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,3),"000")) $rValue = sprintf("%0" . (4+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,2),"00")) $rValue = sprintf("%0" . (3+$f) . "." . $f . "f", $pVal);
else if(isSameString(left($pFmt,1),"0")) $rValue = sprintf("%0" . (2+$f) . "." . $f . "f", $pVal);
else $rValue = sprintf("%." . $f . "f", $pVal);
}
}
return $rValue;
}
//echo FormatNum("11123.885", "###,###,###.00") . "<br>";
//문자열이 같으면 true. 내용상 숫자일 경우 비교가 안되면 만듦
function isSameString($arg1,$arg2) {
return !strcmp($arg1,$arg2);
}
function MakeCookiesUrlEncode($tid) {
$rValue = "";
for($temp1 = 1; $temp1 <= len($tid); $temp1++) {
$temp2 = mid($tid,$temp1,1);
$temp3 = urlencode(ord($temp2)+29);
$rValue = $rValue . $temp3;
}
return $rValue;
}
//echo MakeCookiesUrlEncode("abc");
function UrlDecode_GBToUtf8($str) {
return urldecode($str);
}
//echo UrlDecode_GBToUtf8("%EC%A0%95%EC%8A%A4%ED%94%BC%EB%93%9C");
function isnull($str) {
return is_null($str);
}
function lcase($str) {
return strtolower($str);
}
function ucase($str) {
return strtoupper($str);
}
function getTextString($str) {
if(isnull($str)) {
$str = "";
} else {
$str = replace($str,"<style>","<!--style");
$str = replace($str,"<style","<!--style");
$str = replace($str,"</style>","/style-->");
$str = replace($str,"<script","<!--script");
$str = replace($str,"</script>","/script-->");
$str = replace($str,"<STYLE>","<!--STYLE");
$str = replace($str,"<STYLE","<!--STYLE");
$str = replace($str,"</STYLE>","/STYLE-->");
$str = replace($str,"<SCRIPT","<!--SCRIPT");
$str = replace($str,"</SCRIPT>","/SCRIPT-->");
$str = replace($str,"/css\">","/css");
$str = replace($str," "," ");
}
$nLen = len($str);
$sf = $str;
for($qq = 1; $qq <= $nLen; $qq++) {
$st = InStr($qq,$str,"<");
$ed = InStr($st+1,$str,">");
if($st > 0 && $ed > 0) {
$ds = mid($str,$st,($ed+1)-$st);
$sf = replace($sf,$ds,"");
$qq = $ed;
}
}
return $sf;
}
function HtmlTOText_MultiLine($str) {
$str = HtmlTOText($str);
$str = replace($str," "," ");
$str = replace($str,chr(13).chr(10),"<br/>");
return $str;
}
function HtmlTOText($str) {
$str = replace($str,"<STYLE>","<STYLE><!--");
$str = replace($str,"</STYLE>","--></STYLE>");
$str = replace($str,"<SCRIPT>","<SCRIPT><!--");
$str = replace($str,"</SCRIPT>","--></SCRIPT>");
$str = replace($str," "," ");
$str = replace($str,"</p>",chr(13).chr(10));
$str = replace($str,"<br>",chr(13).chr(10));
$str = replace($str,"<br/>",chr(13).chr(10));
$nLen = len($str);
$sf = $str;
for($qq = 1; $qq <= $nLen; $qq++) {
$st = InStr($qq,$str,"<");
$ed = InStr($st+1,$str,">");
if($st > 0 && $ed > 0) {
$ds = mid($str,$st,($ed+1)-$st);
$sf = replace($sf,$ds,"");
$qq = $ed;
}
}
return $sf;
}
//echo HtmlTOText("aa<br/>나나나<br/><br>zzz");
function TextToHtml($temp) {
if(isnull($temp)) $temp = "";
$temp = replace($temp," ","&nbsp;");
$temp = replace(replace(replace(replace(replace(replace($temp,"<","<"),">",">"),chr(13).chr(10),"<br>"),chr(10),"<br>")," "," "),chr(9)," ");
return $temp;
}
//echo TextToHtml("zzz sss");
function only_filename($temp) {
if($temp=="") {
return "";
} else {
$temp1 = splitVB($temp,"\\");
return $temp1($temp1.length);
}
}
function only_urlFilename($temp) {
if($temp=="") {
return "";
} else {
$temp1 = splitVB($temp,"/");
return $temp1($temp1.length);
}
}
?>
'Developer > PHP' 카테고리의 다른 글
apache 기본 관리 (0) | 2018.02.19 |
---|---|
strpos / 문장내 단어 내포 확인 (0) | 2017.07.19 |
WP 유용한 플러그인 (0) | 2016.05.31 |
WP - 관리자 로그인 로고 변경 (0) | 2016.05.11 |
WP - 리비젼 파일의 제한 주기 (0) | 2016.05.11 |