General Community > Off-Topic
PHP Cronjob --> Automatically submit newsitem via e-mail
pcwacht:
Been digging
get a copy of wordpress -> http://wordpress.org/latest.zip
read:
/include/class.pop3.php for popping, squirrelmail class
and
/wp_mail.php wich does the actual reading of the mail
to get what you need
Basicly :
include the class
create an instance with pop server,port,usernam,password
fetch the mail and import it into the database
something like :
subject = title
content = content
Have fun,
John
PS Need help?
John too :)
Woudloper:
interesting material. Will read some stuff this weekend. A small/fast question. Is wordpress using the pseudo cron where you are referring to!?
PS: I am hosting at pcextreme.nl and they have ssh access and there I can run bash or php...
PPS: Your idea/solution to keep it within WB also seems very nice
rsmith:
:-D Looks like I have another project to start for the weekend
@pcwacht
need help?.. no.....not usualy.. :-)
like help? sure... every little bit helps... i'm still learning whats in WB, and always finding new WB functions to make things easier, i'll look at the wordpress stuff tonight as well as what ive written the past... should be able to have a basic test module in a few days...
any more "features"/"wishes" to be included? can design for some in the inital rc versions
@woudloper
If i understand pcwacht correctly... "pseudo cron" would be running the "cronjob.php" when someone views the page and the time since the last update is more than xx minutes (admin sets xx, last update time is set in the database when its updated) (in his sample any page that uses the template index.php)
I would take this one step further(as i posted) and run the job when the specfic page is loaded and the time is more than xx mins...
this way its not part of the template, all controlled by the WB admin
designed right could also be scheduled to run as a cron job, I know in the past ive had speed issues when checking mail via php, so a cron job works better for this than actively checking on page load, then again ;) my work mail has 10,000+ messages... so may not be an issue for this WB module,
(could be a full time job programming WB modules, I have a few more in the works too :-D but.. too much fun to be a "job" , i know, i know..strange idea of fun :-P )
Rob
pcwacht:
ok, in that case offering some ideas....
Make db for backend popnews module settings for admin to administer through backend
in it you need:
news section -> int -> default section to insert mailed content
news categorie -> int -> default categorie to use for mailed content
popserver -> text -> obvious
popport -> int -> obvious
popaccount -> text -> obvious
poppassword -> text -> obvious
timeinterval -> int -> hours I reckon, easier then minutes ;)
lasttime -> date -> last time executed
then the code for determing the execution of the popreader woudl be executed by the view.php of this wbmodule
something like:
fetch popnews module settings from settings table
currenttime = time();
if currenttime > lasttime + interval*60*60 (making seconds of hours) {
update db, lasttime = currenttime;
call popreader
}
The popreader should :
include the popclass
read the pop
while there is mail {
read the mail
insert subject and content into database
(maybe check if there is allready a content with same title and update the record with new submission??)
(maybe use tags for categorie, short and long text entries in news? ifso divide content into categorie, short, long then submit to db)
delete the mail
}
That's basicly it.
John
frank:
Hi,
I think I'm using such a script for a while.
http://www.fraikin.net/sms2email-liveticker/ in german or
http://www.fraikin.net/sms2email-liveticker/index.php?l=en in english
It is a PHP script which reads an POP3 or IMAP mailaccount.
I placed it as a wrapper modul on my page http://www.beyernetz.de
For news I only have to send a text mail to the defined mail account and one minute later it's online.
Frank
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version