<script language="javascript">
window.resizeTo(가로, 세로);
</script>

현재 윈도우의 사이즈를 조절한다.
물론 팝업창 마지막 스크립트로 실행되게 순차적용을 해야하며,

parent 창에서 팝업창의 이름을 지정해주고 현재 윈도우에서 opener 속성을 가진 모든 윈도우를 컨트롤 가능
Posted by 철냄비짱
,

function PersonalNo_Check(PersonalNo)
{
 // 주민번호의 형태와 7번째 자리(성별) 유효성 검사
 fmt = /^\d{6}-[1234]\d{6}$/;
 if (!fmt.test(PersonalNo)) {
  return false;
 }

 // 날짜 유효성 검사
 birthYear = (PersonalNo.charAt(7) <= "2") ? "19" : "20";
 birthYear += PersonalNo.substr(0, 2);
 birthMonth = PersonalNo.substr(2, 2) - 1;
 birthDate = PersonalNo.substr(4, 2);
 birth = new Date(birthYear, birthMonth, birthDate);

 if ( birth.getYear() % 100 != PersonalNo.substr(0, 2) ||
  birth.getMonth() != birthMonth ||
  birth.getDate() != birthDate) {
  return false;
 }

 // Check Sum 코드의 유효성 검사
 buf = new Array(13);
 for (i = 0; i < 6; i++) buf[i] = parseInt(PersonalNo.charAt(i));
 for (i = 6; i < 13; i++) buf[i] = parseInt(PersonalNo.charAt(i + 1));

 multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];
 for (i = 0, sum = 0; i < 12; i++) sum += (buf[i] *= multipliers[i]);

 if ((11 - (sum % 11)) % 10 != buf[12]) {
  return false;
 }
 return true;
}//PersonalNo_Check(PersonalNo)



호출은 "-" 하이픈 까지 모두 전송

Posted by 철냄비짱
,
var x,y;
if (self.innerHeight) { // IE 외 모든 브라우저
  x = (screen.availWidth - self.innerWidth) / 2;
  y = (screen.availHeight - self.innerHeight) / 2;
}else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드
  x = (screen.availWidth - document.documentElement.clientWidth) / 2;
  y = (screen.availHeight - document.documentElement.clientHeight) / 2;
}else if (document.body) { // 다른 IE 브라우저( IE < 6)
  x = (screen.availWidth - document.body.clientWidth) / 2;
  y = (screen.availHeight - document.body.clientHeight) / 2;
}
window.moveTo(x,y);
Posted by 철냄비짱
,
<?php
 
if(!empty($_FILES["magfile"]))
  {
   
$uploaddir = $_SERVER['DOCUMENT_ROOT']."/dainsider/magazines/";
   
$uploaddir.="magazine.pdf";
   
   
//Copy the file to some permanent location
   
if(move_uploaded_file($_FILES["magfile"]["tmp_name"], $uploaddir))
    {
      echo
"Magazine Updated!";
    }
    else
    {
      echo
"There was a problem when uploding the new file, please contact ".$admin_email." about this.";
     
print_r($_FILES);
    }
  }
?>

위에서 처럼 DOCUMENT_ROOT 를 사용하여 절대경로로 사용.
뭣보다 TRUE, FALSE 를 반환해주고 파일 카피가 아닌 move 기능

업로드 함수를 사용할때 유용
Posted by 철냄비짱
,

implode 와 explode

PHP 2008. 3. 2. 20:27
implode 특정구분자로 배열을 문자열로 변환

<?php

$array
= array('lastname', 'email', 'phone'
);
$comma_separated = implode(",", $array
);

echo
$comma_separated;
// lastname,email,phone

?>



explode 특정구분자로 구분된 문자열을 배열로 변황
<?php
// 예제 1
$pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode (" ", $pizza);
echo
$pieces[0]; // piece1
echo $pieces[1]; // piece2

// 예제 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list(
$user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo
$user; // foo
echo $pass; // *

?>

상당히 유용하게 사용되며,
예전에 문자열을 하나씩 추가 시키면서 for문으로 돌려서 사용을 해서
끝에 필요없는 문자열이 하나씩 추가되는 현상에 대해 고민할 필요가 없어졌다.

분명 explode로 사용을 할때도 implode가 있었을텐데..
왜 난 내장함수를 그리도 사용을 못했던가....

어쨌거나 알아두면 유용함...사용법도 쉽고 ㅋ
Posted by 철냄비짱
,
처음으로 이런 일상 얘기를 적어본다.

몇몇 남은 텅빈 사무실에 앉아 시간을 기다리며...센티한 기분을 즐긴다...

종이컵에 따라진 한잔의 커피처럼 나날이 식어지는 내 열정의 한심함을 느끼며

키보드를 두드린다...

흘러나오는 최신 음악이 왠지 무색해져 소리가 작아진다...

...

이뤄질 수 없는 꿈을 쫓고 있는 듯한 느낌이 든다. 꿈을 놓칠새라 처음 시작했던 그 장소와 사람들을

떠올리며 놓친 기회를 안타까워진다. 또다시 돌아갈수 없는 과거를...

시스템에서 웹으로 전향한건 순전히 내 생각에서 이뤄나온 행동이었지만 자주 후회가 된다.

지금 이 순간에도...

꿈이라 지정해 놓고 애초에 내 자신이 먼저 포기해버린 것일까...

바라보기만 할뿐, 오를 생각을 안하니...여건이 안된다는 상황으로 합리화 시키고 포기해버리고

분위기만 잡는 한심한 인간이 되고싶지 않지만, 지금 이 순간은 한심해 보이는 건 어쩔수 없네.

하....그래도 힘내야지 ^^ 위로해주는 여자친구와 동료, 선배.

감사합니다. ^^

Write In 사무실
2008-02-28
Posted by 철냄비짱
,

출처 : phpschool.com // 어느 분 자료



굉장히 유용하다.
사용하기도 쉽고 적용도 쉬움.
이미지 올라가는 부분과 첨부 된 이미지 중에서 마사용 이미지 걸러내고 저장 하는 부분은
살짝 튜닝해서 쓰는 중.

<!-- Content 입력 내용 부분에 삽입 -->
<link rel="StyleSheet" HREF="/KEditor/css/KEditor.css" type="text/css" title="style">
<script type="text/javascript" src="/KEditor/prototype.js"></script>
<script type="text/javascript" src="/KEditor/builder.js"></script>
<script type="text/javascript" src="/KEditor/KUtil.js"></script>
<script type="text/javascript" src="/KEditor/KEditor.js"></script>
<textarea name="content" id="contentEditor" class="textarea" style="width:520px;height:280px;"></textarea>
<script type="text/javascript">
var topMenu = [
 ["fontface","fontsize","|","bold","italic","underline","strikethrough","|","justifyleft","justifycenter","justifyright","justifyfull","|","fontcolor","bgcolor","|","code"],
 ["outdent","indent","|","undo","redo","|","table","insertdate","inserttime","charmap","fullscreen","|","link","unlink","image"]
];

var editor = new KEditor(
 "contentEditor",
 {
  lang: "php",
  updateDir: "/KEditor/data/editor", //절대경로 표기 할것
  topMenus: topMenu
 });
</script>
<!-- //Content 입력 내용 부분에 삽입 -->

Posted by 철냄비짱
,
<?
/*
 데이터 엑셀로 출력
*/
header( "Content-type: application/vnd.ms-excel; charset=euc-kr" );
header( "Content-Disposition: attachment; filename=파일명.xls" );
Header("Content-Transfer-Encoding: binary");
Header("Content-Type charset=ks_c_5601-1987");
Header("Pragma: no-cache");
Header("Expires: 0");
header( "Content-Description: PHP4 Generated Data" );



/*
   리스트 조회 코딩
*/
?>


이 방식으로 최대한 간편하게 프로그래밍이 가능하다.

header만 추가시켜주면 끝 ^^
Posted by 철냄비짱
,

<?
/* 썸네일 파일 생성 시작*/
function create_thumnail($url, $width=0, $height=0)
{
 global $HTTP_SERVER_VARS;
 
 if ($url[0] == "/") $fname = $url;
 else $fname = $url;
 
 $imsize = @getimagesize($fname);
 if (empty($imsize)) return;
 
 if ($imsize[0] >= 10 && $imsize[1] >= 10)  {

  if ($width > 0) {
   if ($imsize[0] > $width) {
    $imsize[1] = intval($imsize[1] * $width / $imsize[0]);
    $imsize[0] = $width;
   }
  }
 
  if ($height > 0) {
   if ($imsize[1] > $height) {
    $imsize[0] = intval($imsize[0] * $height / $imsize[1]);
    $imsize[1] = $height;
   }
  }
 }
 
 //$src = gd_imagecreate($url);

 $pos = strrpos($url, ".");
 $ext = strtolower(substr($url, $pos + 1));
 
 if ($ext == "jpeg" || $ext == "jpg") $src = imagecreatefromjpeg($url);
 else if ($ext == "gif") $src = imagecreatefromgif($url);
 else if ($ext == "bmp") $src = imagecreatefromwbmp($url);
 else if ($ext == "png") $src = imagecreatefrompng($url);

  $dest = imagecreatetruecolor($imsize[0], $imsize[1]);

  // 이미지 정보
  list($image_width, $image_height) = getimagesize($fname);
 @imagecopyresampled($dest, $src, 0, 0, 0, 0, $imsize[0], $imsize[1], $image_width, $image_height);


 imagejpeg($dest, $fname);
 
// echo "<img src='$fname' width='${imsize[0]}' height='${imsize[1]}' border='0'>";

}
/* 썸네일 파일 생성 끝*/
?>


사용시...
  //create_thumnail(BBS_DATA_PATH."/".$folder_path."/".$realfile, 540, 0);
  create_thumnail(BBS_THUMNAIL_PATH."/".$folder_path."/".$realfile, 138, 0);

Posted by 철냄비짱
,

foreah 구문

PHP 2008. 2. 3. 18:11
<?php
$arr
= array("하나", "둘", "셋"
);
reset($arr
);
while (list(,
$value) = each($arr
)) {
    echo
"값: $value<br />\n"
;
}

foreach (
$arr as $value
) {
    echo
"값: $value<br />\n"
;
}
?>

작업하면서 배열구문을 많이 사용할때가 있다.

게시판만 하더라도 수도 없이 사용됨. 그 와중에 같은 목적의 변수들을

$value = Array("1", "2", "3");
$text  = Array("하나", "줄", "셋");

이렇게 같이 땡겨 사용할시 메모리 낭비...

foreach문으로 value 값과 key 값을 동시에 대입, 사용할 수 있다.

상당히 유용항 구문... 나도 아직 습관기르는 중...
Posted by 철냄비짱
,