일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- dock
- PLSQL
- iBATIS
- phonegap
- Eclipse
- JDOM
- Spring
- oracle
- appspresso
- jsr 296
- GPS
- WebLogic
- 선택적조인
- swingx
- 전자정부프레임워크
- PHP
- tomcat
- ibsheet
- MFC
- 가우스
- rowspan
- Google Map
- Struts
- MySQL
- node.js
- JSON
- Android
- sencha touch
- jQuery
- Ajax
Archives
- Today
- Total
Where The Streets Have No Name
php에서 비동기 처리 본문
참고 : http://robert.accettura.com/blog/2006/09/14/asynchronous-processing-with-php/
브라우저에서 호출되는 페이지
<?php
/* Note that the call itself isn’t sanitized in any way, so it’s
important to make sure that this can’t be exploited, see
docs for escapeshellcmd() for details
*/
// Demonstration
if(launchBackgroundProcess('php d:/temp2/convert.php')){
print 'Successfully launched background process';
}
/**
* Launch Background Process
*
* Launches a background process (note, provides no security itself, $call must be sanitized prior to use)
* @param string $call the system call to make
* @author raccettura
*/
function launchBackgroundProcess($call) {
// Windows
if(is_windows()){
pclose(popen('start /b '.$call, 'r'));
}
// Some sort of UNIX
else {
pclose(popen($call.' /dev/null &', 'r'));
}
return true;
}
/**
* Is Windows
*
* Tells if we are running on Windows Platform
* @author raccettura
*/
function is_windows(){
if(PHP_OS == 'WINNT' || PHP_OS == 'WIN32'){
return true;
}
return false;
}
?>
백그라운드로 실행되는 페이지
<?
$cnt = shell_exec('identify -density 10 -format %n d:/temp2/0806daemun_vol2_08.pdf');
for ($i = 0; $i < $cnt; $i++) {
$output = shell_exec('convert -density 200 d:/temp2/0806daemun_vol2_08.pdf['.$i.'] -resize 1275x1816 -colorspace RGB d:/temp2/image/aaa_'.$i.'.jpg');
}
?>