[solution] Getting cron to work with $require_login = 1;

Solutions for other advanced phplisters

[solution] Getting cron to work with $require_login = 1;

Postby Phil » 11:17pm, Fri 15 Oct, 2004

This is a very useful little trick for users who need to setup a cron job for process queue and/or process bounces where they also need to create various admins for the mailing lists (i.e. they need login to work). In no way can I take any of the credit for this - that belongs to Jeff (yookoso), who devised this ingenious bit of hacking.

Many users who have attempted cron jobs with $require_login = 1; (in config.php), have no doubt been frustrated by the cron returning a lengthy HTML code that informs you of the need to login.

So Jeff's come up with the following solution:

In admin/index.php, find the following:

error_reporting($er);

Immediately after that, insert the following:

// -------------------------------------------------
if ($var) {
$temp = explode("-", $var);
$page = $temp[0];
$_GET["page"] = $temp[0];
$cli = $temp[1];
if ($cli) $GLOBALS["require_login"] = 0;
}
// -------------------------------------------------


Then write your cron to resemble the following:

10 * * * * GET http://yourdomain.com/phpList/admin/?va ... squeue-cli > /dev/null
or
10 * * * * GET http://yourdomain.com/phpList/admin/?va ... ounces-cli > /dev/null

10 * * * *, of course, being the timing of the cron job however you want it, and http://yourdomain.com/phpList/ should be customised to your own site.

If the bit of PHP above seems a little strange, Jeff originally wrote that to get his cron job to work using lynx (he doesn't have GET installed on his system), while at the same time getting around the login issue. All I did was to realise that the same method could work with GET.

In Jeff's case, the cron command would be as follows:

10 * * * * lynx -dump http://yourdomain.com/phpList/admin/?va ... squeue-cli > /dev/null
or
10 * * * * lynx -dump http://yourdomain.com/phpList/admin/?va ... ounces-cli > /dev/null

That's it, in a nutshell. For more explanation on Jeff's method, you can view his original posting at http://www.phplist.com/forums/viewtopic.php?t=1074

Phil
Last edited by Phil on 8:23am, Sat 16 Oct, 2004, edited 2 times in total.
Phil
PL Nut
 
Posts: 27
Joined: 6:36pm, Mon 04 Oct, 2004
Location: RSA

Postby MattF » 2:56am, Sat 16 Oct, 2004

alrite! I knew there was a method around it, but just couldn't for the life of me, figure it out.

This just made me feel a LOT better...of course now I'm going to go test it out fully (turning off process queue, composing a message and letting it go send overnight)...see tomorrow what happens.
MattF
phpLister
 
Posts: 12
Joined: 6:27pm, Sun 10 Oct, 2004

Postby Phil » 8:17am, Sat 16 Oct, 2004

MattF wrote:alrite! I knew there was a method around it, but just couldn't for the life of me, figure it out.

This just made me feel a LOT better...of course now I'm going to go test it out fully (turning off process queue, composing a message and letting it go send overnight)...see tomorrow what happens.


Hope it works for you! Please let us know.

Phil
Phil
PL Nut
 
Posts: 27
Joined: 6:36pm, Mon 04 Oct, 2004
Location: RSA

Postby MattF » 4:17pm, Sat 16 Oct, 2004

it looks like it will; I think I need to now tweak the batch processing and cron job times accordingly so they process and send out right (any reload of processqueue early will start it from the beginning, thus having to scan through the users agin until it finds some it hasn't sent to yet)
MattF
phpLister
 
Posts: 12
Joined: 6:27pm, Sun 10 Oct, 2004

Postby MattF » 8:53pm, Sat 16 Oct, 2004

marginal success.

It looks like however that when processqueue is called up, it won't "reload" like it does in the browser until the full batch is sent out...I think my timing is still off, because it'll either reset itself if called too early, or take an immense amount of time to scan through a batch.
MattF
phpLister
 
Posts: 12
Joined: 6:27pm, Sun 10 Oct, 2004

Postby bensauer » 1:54pm, Mon 18 Oct, 2004

does this not strike anyone as a potentially nasty security hole?

I'm going to use a variation of this, but I'm going to put some basic authentication in there too.
bensauer
phpList newbie
 
Posts: 1
Joined: 11:07am, Mon 07 Jun, 2004

Postby Phil » 4:30pm, Mon 18 Oct, 2004

bensauer wrote:I'm going to use a variation of this, but I'm going to put some basic authentication in there too.

True, there's some security risk there - would you share your mod with the rest of us?
Phil
PL Nut
 
Posts: 27
Joined: 6:36pm, Mon 04 Oct, 2004
Location: RSA

Postby MattF » 8:01pm, Tue 19 Oct, 2004

I'm curious if this was written with 2.8.11 in mind...I'm running 2.9 (I know, not 100% stable yet), but in that the eventlog is showing a reset everytime the cron job is called (i.e. the browser would reload and continue until the batch is sent, but a cron job call resets the whole process).

Is it me or am I missing something...I feel like I'm so close to the solution either way
MattF
phpLister
 
Posts: 12
Joined: 6:27pm, Sun 10 Oct, 2004

Curious too

Postby troutstalker » 6:07pm, Mon 01 Nov, 2004

I am running 2.8.11 and noted update to 2.8.12 is available. I just got this working but was wondering how it would be effected with batch processing on a list of 1,800 with batches set to 199 per batch. Will the previous question about batch on 2.9 also be true with mine on 2.8.11 -- will the process of que restart every time the page is called... do I need to set the cron to only run after the queue would have emptied?

Help... gotta figure this out.

(NOTE: Will I just have to temporarily disable Cron when sending to big list, but can use for smaller lists in meantime?)
troutstalker
PL Nut
 
Posts: 29
Joined: 3:17am, Thu 08 Apr, 2004

Postby cweather » 4:14pm, Tue 16 Nov, 2004

It seems the authentications done by checking the environmental varible USER, which isn't set when a job is run by cron. (LOGNAME is set instead.) .
There's an easy hack that can be made to make things work (if ( $_SERVER["USER"]=="") $_SERVER["USER"]=$_SERVER["LOGNAME"]);, somewhere in config.php. but this still leaves things wide open, if a user wants to set LOGNAME.
Seems to me the whole cmd line authentication system is a bit shakey.
cweather
phpList newbie
 
Posts: 1
Joined: 11:28am, Fri 12 Nov, 2004

Postby ryanc » 5:27am, Wed 24 Nov, 2004

FWIW, I have this line setup in my cron to run every hour.. Seems to work fine, and I didn't modify any php files. Maybe it will help someone.

Code: Select all
wget -q  -O - 'http://mywebsite.com/phpList/admin/index.php?page=processqueue&login=myusername&password=mypassword' > /dev/null


Ryan
ryanc
phpLister
 
Posts: 5
Joined: 6:03am, Fri 05 Nov, 2004

Postby drubarth » 6:04am, Sat 18 Dec, 2004

I tried the wget and receive the following error:

This page can only be called from the commandline

Running PHPlist - version 2.8.12


darryl
drubarth
PL Master
 
Posts: 188
Joined: 10:14pm, Fri 17 Dec, 2004

Postby drubarth » 7:25am, Sat 18 Dec, 2004

Ah, found my problem with using WGET. I had the MANUALLY_PROCESS_QUEUE turned off. It's working now! :)

Would have rather used the CLI so that I could keep my users from processing the queue during the day, but no big deal.


darryl
drubarth
PL Master
 
Posts: 188
Joined: 10:14pm, Fri 17 Dec, 2004

On DreamHost, PHP 5 is built for CLI

Postby ajdavis » 2:47am, Tue 04 Sep, 2007

I've had this problem, too: when I do phplist -pprocessqueue or -pprocessbounce on the command line, it responds with a login page (spat out on the command line).

I have a basic DreamHost plan, which provides php 4.4.7 (cgi) in the default path at /usr/local/bin/php. By doing a 'locate' I found php 5.2.3 (cli) at /usr/local/php5/bin/php, which executes phplist on the command line w/out errors. So I changed the text of the 'phplist' bash script to call php 5.

The other funny thing is, I had to manually set the USER environment variable in the shell script. I added

export USER='jiryu'

above the last line in bin/phplist. (Obviously, substitute your user name for 'jiryu'.) Apparently cron doesn't set USER, and PHPList's "security" is lame.
ajdavis
phpList newbie
 
Posts: 1
Joined: 12:59am, Tue 04 Sep, 2007

Re: [solution] Getting cron to work with $require_login = 1;

Postby SweterdJ » 9:29am, Sat 10 Oct, 2009

I've had this problem, too: when I do phplist -pprocessqueue or -pprocessbounce on the command line, it responds with a login page (spat out on the command line).

I have this problem too. Anibody help me please.
SweterdJ
phpList newbie
 
Posts: 1
Joined: 9:26am, Sat 10 Oct, 2009

Next

Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 0 guests