Re: php-nuke?

From: Date: Sun, 04 Feb 2001 05:24:52 +0000
Subject: Re: php-nuke?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38075@lists.php.net to get a copy of this message
> What is php-nuke? It's a "Template" system written in PHP where you kinda click-and-drag to build a PHP page. > How could I make a php-page execute something (itself?) without entering the > site... it starts evry hour?! The most resource-friendly way is to compile PHP as a CGI, and then use "cron" to have that PHP binary run your page every hour. Second choice (distant second) is to use "wget" to surf to a page every hour. Third choice (distant third) is to use "lynx -d" to surf to a page every hour. If you are on Windows NT, you're mostly on your own, but you've got that Scheduler thingie to play with, and php.exe, and you can make a shortcut to php.exe and alter the path it uses to be more like "php.exe -q yourpage.php" instead of just plain ol' "php.exe" Now, back to a real OS :-) To compile PHP as a CGI, you need to go back to the PHP source directory and copy that config.nice file (config.status?) and name it, like, "config.ascgi" or something. Or, if you didn't compile from source in the first place, try viewing a page with <?php phpinfo();?> on it and copy&paste that stuff about "configure --with-mysql --with-apxs --with-kitchen-sink" into a file somewhere. Download the PHP source code, and mostly follow the instructions in there, *except* ignore all that stuff about configuring Apache and using --with-apxs or --with-apache. Instead, you'll use the configure stuff you just copied as your guide. Anyway, whichever way you end up doing it, you'll want to end up with a file you can execute or a command you can paste that starts off with "configure", has all the same "--with-xxx" in it, *except* not --with-apxs and not --with-apache. So, you finally get that to go, then do "make" like the directions say. You'll end up with this file named "php" in your directory there, and you can copy that to /usr/bin or /usr/sbin or whatever location you feel is convenient and makes sense. Just be sure you know where the heck you put it, cuz you'll need it in a bit. Assuming "cron" is as much as mystery to you as it once was to me, you'll want to read "man 5 crontab" Okay, now you'll have to read it a few more times, cuz it ain't the most light reading. But the examples are pretty instructive. Focus on them. You'll also want to be sure to set your environment variable DISPLAY to an editor you know how to use instead of the default, which, Murphy's Law, will be one you won't... Now that opens up a whole new can of worms, since you may not know how to set an environment variable. Easiest thing to do is to do "cd" to get back to your home directory. Then to "ls -als". There's gonna be a whole mess of files that you maybe never even saw before that start off with a "." character. Peek into each one of them, and see if you can find anything like: setenv xxx=yyy or xxx=yyy export xxx If you do, edit that file that has that stuff, and do kinda the same thing, only you want to set DISPLAY (or maybe editor, depending on which Un*x/shell) you are using to your favorite editor, like "vi" or "joe" or "pico" or "emacs" or... If you have no idea which editor you like, use "pico" because it's the one most like Notepad, only the menus are things you type, not things you click, and they're at the bottom... Anyway, once you got your DISPLAY set up, you can do: crontab -e The -e means to "edit" your crontab file. You want to add a line that looks something like those examples from "man 5 crontab" but that point to your "php" binary you copied into /usr/bin and makes it fire up your script, every hour. Something not unlike this: email=ftakle@online.no 5 * * * * /usr/bin/php -q /full/path/to/your/script.php Now if you couldn't get PHP to compile, just use "wget" there instead of /usr/bin/php. And if you couldn't get PHP to compile, and you can't get "wget" installed, just use "lynx -d" But someday, you want to get PHP as a CGI compiled, cuz "wget" and "lynx" tie up an HTTP connection when you do this, so that's one less person that can surf to your web-site when it gets busy. Save and quit your editor. Because there is a "5" in that first column, this is going to fire off the php program in /usr/bin at 5 minutes after the hour, every hour (the first *) every day (the second *) every month (the third *), no matter whether it's a Monday, Sunday, Weekday, Weekend, or whatever (the last *), and it's going to feed yourscript.php to PHP to run it. The -q just tells PHP not to bother printing out that Content-type: text/html stuff, since it ain't going to a browser anyway. The email line means it will email you whatever output PHP makes, or an error message if you screwed up. (Only maybe I got the email= part wrong... That's why you read "man 5 crontab") PS You can find pretty much this same answer in the mailing list archives... -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#38075) next »