목록php (106)
세이박스
switch($HTTP_ACCEPT_LANGUAGE) { case "ko" : header("Location: /kor/index.php");break; case "en" : header("Location: /enu/index.php");break; case "ja" : header("Location: /jpn/index.php");break; case "zh" : header("Location: /chs/index.php");break; case "zh-cn" : header("Location: /chs/index.php");break; Default : header("Location: /kor/index.php");break; }
$d_time = microtime (); $code = 'x'.substr('0000000'.dechex($d_time*100000000),-7);
preg_match("/^(http:\/\/)/i",$url, $matches); $host = $matches[0]; if($host!="http://") $url="http://".$url; else $url=$url;
결과 값 PHP 코드 설명 20051011 date("Ymd"); 1129015289 time(); unixtime 1128956400 mktime(0, 0, 0, date("m"), date("d"), date("Y")); 오늘 0시 유닉스 타임 1128870000 mktime(0, 0, 0, date("m"), date("d")-1, date("Y")); 어제 0시 유닉스 타임 1126364400 mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); 한달전 0시 유닉스 타임 1097420400 mktime(0, 0, 0, date("m"), date("d"), date("Y")-1); 작년 0시 유닉스 타임 1104505200 mktime(0, 0, 0, 1, ..
제목: register_globals=Off 상태에서의 POST,GET 변수제어 분류: php 글쓴이: 김정균 호스팅 서버 같은 곳에서 보안상의 이유로 register_globals 를 OFF 로 변경 하거나 또는 보안상 register_globals 를 OFF 로 변경하고 싶은데 기존의 소스들 때문에 망설이시는 분들께 유용한 함수가 될것 같네요. JSBoard 를 개발하다가 보안때문에 register_globals 를 OFF 로 두었을때 작동을 하지 않는다는 문의가 많이 들어와 만든 함수입니다.. * PHP 4.1 이상 버젼용 function parse_query_str() { foreach($_GET as $key => $value) { global ${$key}; ${$key} = $value; }..
$_GET['a'] --> GET으로 넘어온 $a라는 변수.. $_POST['a'] --> POST로 넘어온 $a라는 변수.. $_SERVER['a'] --> ?? $_COOKIE['a'] --> 쿠기 변수 $a ?? $_ENV['a'] --> ?? $_REQUEST['a'] --> ?? $_FILE['a']['name']; --> $a라는 폼으로 올라온 첨부파일의 파일명 $_FILE['a']['size']; --> $a라는 폼으로 올라온 첨부파일의 크기 $_SESSION['a']; --> 세션변수 $a $HTTP_GET_VARS['a']; --> $_GET['a']과 동일? 전혀 차이 없음? $HTTP_POST_VARS['a']; --> $_POST['a']과 동일? 전혀 차이 없음? @extract(..
function sendmail_ctrl($from_mail, $from_name, $to_mail, $to_name, $subject, $body, $headers) { $fp = popen( '/usr/sbin/sendmail -f'.$from_mail.' '.$to_mail,"w"); if(!$fp) return false; if($to_name){ fputs($fp, "To: $to_name \n"); }else{ fputs($fp, "To: $to_mail\n"); } fputs($fp, "From: $from_name \n"); fputs($fp, "Subject: $subject\n"); fputs($fp, $headers."\n\n"); fputs($fp, $body); fputs($fp,..
function emailCheck($email){ if(!eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??0-9]+(-[a-z??0-9]+)*(\.[a-z??0-9-]+)*(\.[a-z]{2,4})$", $email)) return FALSE; return $email; }
$fp = @fopen("$DOCUMENT_ROOT/../log_txt/etc/216_".date("Ymd").".txt", "a"); @fwrite($fp, date("Y/m/d(H:i:s)")."\t".$aa."\t".$HTTP_REFERER."\t".$HTTP_SERVER_VARS["HTTP_USER_AGENT"]."\t".$REMOTE_ADDR."\n"); @fclose($fp);
$speed = 8.5; // 8,5 kb/s 비율로 다운로드를 받는다. $file=$DOCUMENT_ROOT.$file; if(file_exists($file) && is_file($file)) { header("Cache-control: private"); header("Content-Type: audio/mp3"); header("Content-Length: ".filesize($file)); header("Content-Disposition: filename={$filename}"); flush(); $fp = fopen($file, "r"); while(!feof($fp)) { echo fread($fp, round($speed*1024)); flush(); sleep(1); } fclose (..
$s_ext=substr($s_name,strrpos($s_name,".")+1);
// W3C P3P 규약설정 @header ("P3P : CP=\"ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC\""); IE6 부터... 바뀐 쿠키 설정에 따른 설정법
$ftp_server='kkk.net';//serverip $conn_id = @ftp_connect($ftp_server); // login with username and password $user="kkk"; $passwd="aaa"; $login_result = @ftp_login($conn_id, $user, $passwd); //directorylike /www.velibaba.com/images @ftp_chdir($conn_id, "public_html/report_files"); // upload the file $upload = @ftp_put($conn_id, $filename, $file, FTP_BINARY); // close the FTP stream @ftp_close($con..
PHP 와 플래시가 값을 주고 받기 테그 on (release) { getURL("javascript-x:void(open('http://sss.co.kr/sss.php?concern="+concern+"','popup','width=280,height=150'))"); } on (release) { getURL("javascript-x:void(alert('오른쪽 소스보기를 클릭해주세요'))"); }
@extract($HTTP_SESSION_VARS); @extract($HTTP_COOKIE_VARS); @extract($HTTP_SERVER_VARS); @extract($HTTP_GET_VARS); @extract($HTTP_POST_VARS); @extract($HTTP_ENV_VARS); if($_FILES['file']['name']){ $AllowExt='/\.alz|\.txt|\.psd|\.xls|\.gz|\.zip|\.bmp|\.doc|\.exe|\.dat|\.gif|\.htm?|\.hwp|\.pdf|\.ppt|\.rar|\.jp?g|\.tif|\.png/i'; $rename=date("YmdHis"); $saveDir="$DOCUMENT_ROOT/report_files/".date("Y..
php 4.3.4에서 session_start()를 써도 저런 메세지가 나지 않던데요. 물론 에러리포팅은 다 켜 놓았구요. session_register 대신에 $_SESSION['이름'] ="값"; 을 써 보세요. 아마 이것 때문엔거 같은데, 자세한건 저도 잘 모르겠습니다. Warning: Unknown(): Your script-x possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. ..
$xMailer="PHP/".phpversion(); $headers="MIME-Version: 1.0\r\n"; $headers.="Content-Type:text/html;charset=EUC-KR \n"; $headers.="Content-type: text/html; charset=iso-8859-1\r\n"; $headers.="Content-type: text/html; charset=ks_c_5601-1987\r\n"; $headers.="From: $from_name \r\n"; $headers.="Reply-To: \r\n"; $headers.="X-Mailer : $xMailer \n";
PHP 소스 상단에 다음과 같이 선언해주면 php.ini에 register_global = OFF 상태여도 POST전송시 변수값이 전송 됩니다. 웹소스를 코딩시 서버 설정을 손대지 못할 경우 유용하게 사용하실 수 있을겁니다. @error_reporting(E_ALL ^ E_NOTICE); @extract($HTTP_GET_VARS); @extract($HTTP_POST_VARS); @extract($HTTP_SERVER_VARS); @extract($HTTP_ENV_VARS); @extract($HTTP_SESSION_VARS); @extract($_FILES);
if(!is_dir($saveDir)) { $oldumask = umask(0); mkdir($saveDir, 0777); // or even 01777 so you get the sticky bit set umask($oldumask); } 이때... umask란 file이 생성될 때 사용할 file의 권한에 대해 mask를 인코딩하는 system 변수이다. 보통 3자리로 표현이 되며 각각의 자리는 user, group, other의 권한을 나타낸다. umake의 값은 3자리의 8진수의 값이며 각각의 값은 1,2,4의 값은 AND 연산한 결과이다. 0 : 사용자에게 모든 권한을 혀용. 4 : 사용자에게 읽기 권한은 주지 않음. 2 : 사용자에게 쓰기 권한을 주지 않음. 1 : 사용자에게 실행 권한을 주..
현재달의 1일이 몇번재 요일인지 숫자로 뽑기 blank = date("w",mktime(0,0,0,$month,1,$year)); 해당달의 마지막날 allday = date("t",mktime(0,0,0,$month,1,$year));
$today=time(); echo $today.'->unixtime '; $today_=date("Y-m-d H:i:s",$today); echo $today_.'->오늘 날짜 '; $yesterday=mktime(23, 59, 0, 05, 28, 2004); echo $yesterday.' ->어제 날짜와 시간 유닉스 타임, '; echo floor(($today-$yesterday)/(24*60*60)).' ';
보통 데이타를 DB에 집어 넣을 때 load data infile 을 이용해서 화일로 부터 집어 넣습니다. 이런 방법도 무쟈게 빠름니다. 하지만 insert를 써서 데이타를 집어넣는 방법도 빠르게 할 수 있습니다. 예 1) for($i=0;$i
CGI 변수 Variable Value DOCUMENT_ROOT /home/vidr/public_html (스크립트가 저장된 로컬 파일 시스템 경로) REMOTE_ADDR 211.110.223.225 (페이지를 요청한 컴퓨터의 IP주소) REMOTE_PORT 3854 (페이지를 요청한 컴퓨터가 응답을 기다리는 포트 번호) SCRIPT-x_FILENAME /home/vidr/public_html/phpinfo.php (PHP 실행 파일의 경로) SERVER_ADDR 218.38.56.185 (실행 중인 웹 서버의 IP 주소) SERVER_NAME family2.vidr.net (실행 중인 웹 서버의 호스트 이름) SERVER_PORT 80 (웹 서비스가 제공되는 포트 번호) SERVER_PROTOCOL H..
string substr(string 문자열, int 시작 [, int 끝]) -> 문자열의 일부를 반환 $string = substr("The cat sat on the mat", 4, 3); // 결과 : 'cat' int strpos(string 대상 문자열, string 찾을 문자열 [, int 오프셋]) -> 찾는 문자열의 위치 $string = strpost("The cat sat on the mat", "cat"); // 결과 : '4' chr()은 아스키 코드를 받아서 해당 문자를 출력 ord()은 반대기능 -> echo(char(64)); //결과 '@' -> echo(ord('@')); //결과 '64' * 참고. & -> & amp; " -> & quot; < -> & lt; > ->..
$file="../../upLoad/expose/".$row[filename]; $img=@getimagesize($file); $img_type=$img[mime]; Header("Content-Type: $img_type"); $fp=fopen($file,"r"); //스트리밍 JPG,GIF일 경우 $count = fread($fp, filesize($file)); echo $count;
php.ini 파일에서 보안 문제로 잠겨있는 register_globals = On 이거 on으로 해주세요~~ DOCUMENT_ROOT값 프린팅 안될때두~~~
$ftp_server_1="test.net"; $ftp_user_name="test"; $ftp_user_pass="testpwd"; $file = "/home/public_html/test/".$pre_file; // set up basic connection $conn_id_1 = ftp_connect($ftp_server_1); // login with username and password $login_result_1 = ftp_login($conn_id_1, $ftp_user_name, $ftp_user_pass); // try to delete $file @ftp_delete($conn_id_1, $file); // close the connection ftp_quit($conn_id_1);