Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
1 + 6 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     

Re: How to allow a cron job to access a xoops module?
by sceilig on 2006/6/27 10:43:00

I did manage to answer my own question. In case anyone else might be looking to perform the same task, this can be done using cURL.

First you use curl to post login credentials to XOOPS and then you can access the module function that requires administrator access.

e.g.
le="color: #000000"><?php $url = "http://www.domainname.com/user.php"; $login_data = "op=login" ."&uname=admin" ."&pass=password"; $user_agent = "php" . phpversion(); $ch = curl_init($url); // initialize curl handle curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_COOKIEJAR, "curl_cookies"); curl_setopt($ch, CURLOPT_COOKIEFILE, "curl_cookies"); // file where the cookies will be stored curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); $result = curl_exec($ch); // run the whole process // you should now be logged in // now access the admin only page $url2 = "http://www.domainname.com/modules/modulename/admin/index.php?op=process_admin_function"; curl_setopt($ch, CURLOPT_URL, $url2); $result = curl_exec($ch); echo $result; // $result contains the page contents which you can parse for the success or error message you are looking for //close cURL connection curl_close($ch);
Re: How to allow a cron job to access a xoops module?
by ghettonet on 2006/6/22 3:18:47

hm, but running the php script just as an absolute path with the php bin (****crontab stuff php /home/user/public_html/script.php) shouldn't require authentication should it? If it does I don't know what i'm talking about so ignore me.
Re: How to allow a cron job to access a xoops module?
by sceilig on 2006/6/22 2:05:47

Accessing the php script in a cron job is fine - its just authentication I think i would have the problem with.
e.g.
a cron job to access
http://www.domainname.com/modules/modname/admin/index.php?op=runcron

would just redirect to the XOOPS login page - just as what would happen to a guest user visiting that page since it is only allowed access by XOOPS administrators.
Re: How to allow a cron job to access a xoops module?
by brash on 2006/6/22 1:21:56

Possibly via WGET, or even the PHP cli.
How to allow a cron job to access a xoops module?
by sceilig on 2006/6/22 0:41:37

I want to setup a cron job to execute a script within a XOOPS module on a daily basis - and that module is set up to only have administration access. Is this possible? How do I go about authenticating the cron job so that XOOPS allows it to execute the script?

Who's Online

152 user(s) are online (96 user(s) are browsing Support Forums)


Members: 0


Guests: 152


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits