Re: PHP Win32 Standalone scripting?

From: Date: Thu, 20 Jul 2000 11:21:19 +0000
Subject: Re: PHP Win32 Standalone scripting?
Groups: php.general 
Request: Send a blank email to php-general+get-7399@lists.php.net to get a copy of this message
Hurraaaaah, I got it! <jump, jump> Sune, here a brief description of how to proceed and what to set and write and put. My example concerns the following environment: I'm maintaining a php-based site (www.posh.ch). I have an ISP that doesn't support php (apache). So I get my php contents from a friend of mine's web server (apache, mysql, php). Although the domain is with the ISP. That's easy: On the ISP's account I just have an index.htm with a frameset that gets any further content from the php enabled web server. But as it is, I have to be aware that my friend's webserver isn't supported 24h a day - although I haven't had problems until now. So I periodically generate a static, pure html version (www.posh.ch/fallback/index.html) of the core contents of my site and store it at the ISP. I case of "emergency" I just have to switch the frameset, and it will get the static contents from the ISP's web server. This is also usefull while maintaining the php contents. Locally I work on a Win95 PC /w apache, php ,mysql and the identical db to the live db. So I can reproduce almost everything locally that's going on "in production". So I'm able to produce the static version locally on my PC and then upload the whole bump. Every page of mine is programmed the way that it evaluates the variable $pure_HTML passed. According to this, the pages adapt hrefs between each other and hide any "active" php content such as guestbooks a.s.o (all these references and info are stored in my central navigation table in a MySQL db). What I have done 'till now: I had a page that listed all the scripts that will be in the static version, together with the filename of the future static html file. So I just had to click on every link (which pass pure_HTML=TRUE in the URL) on this "static generator" page and safe the appearing pages under the given name. But that sucked...clicking 20 times on a link...Ctrl+S...click.....Back-Button.... Now I get to the point: The latest version of my static generator just outputs a batch file, which in turn I can start from the DOS command line. This batch file - and this is the key point - looks like this: (one line for every page to be generated) c:\php3\php.exe -q c:\apache\htdocs\sourcescript.php3 there=comes&the=string&that=contains&all=the&variables=tobe&passed=to&the=script > c:\static\htmlfile.htm When writing the batch file with a php script, the output lines to the batch file must terminated with "\r\n". So the string that the script puts to the batch file (e.g. static.bat) looks like this: <?php $line="c:\php3\php.exe -q ".$source_path.$source_file." "there=comes&the=string >".$out_path.$out_file."\r\n"; fputs($fp,$line); ?> The whole argument stuff looks very similar to a URL, but there's a whitespace instead of the question mark. With the > sign you can define the output destination. To get the arguments in the scripts called I just inserted <?php parse_str($argv[1]); ?> at the very beginning of the code. That's what sets the variables "packed" in the argv string into the script context. Confused? Anyway: HTH ;-) -Steff webmaster@posh.ch www.posh.ch - Newcomer 2000

« previous php.general (#7399) next »