Previous Thread
Next Thread
Print Thread
Hop To
#128845 05/12/2006 1:54 AM
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
I can not get the subscriptions.php to run.

I have had my admin setup the cron jobs but the scripts will not run I get this error.

Fatal error: Maximum execution time of 30 seconds exceeded in /usr/wwwroot/ddehek/newzealandnz/discussions/cron/php/subscriptions.php on line 95

// Require the library
require ("../../includes/main.inc.php");
require ("$thispath/languages/{$myprefs['language']}/subscriptions.php");
$html = new html;
$mailer = new mailer;

I have does this

Using the PHP Scripts


1. Customize Paths
Using NotePad, or a suitable text editor, open doexpire.php and subscriptions.php and place the path to PHP in the top of the script. For example, it might look like this:

#!/usr/bin/php

Also in subscriptions.php, you have to change line 22 of the script to reflect the location of your specific install. (i.e., the following line is hard-coded in the script, and needs to be edited:



<pre class="ip-ubbcode-code-pre"> require ("/home/www/html/ubbthreads/main.inc.php");</pre>


2. Upload Files
Open your FTP program and upload the two files in the PHP subfolder (within the cron folder of your zip) in ASCII mode. Be sure to maintain the same file structure on your server as is contained in the zip.

3. Change Permissions
Change the file permissions on doexpire.php and subscriptions.php files so that they can be read and executed by everyone (755). No other permissions need to be set.

Either use telnet to issue the command chmod 755 *.php, or use your FTP program to set the permissions. For assistance with permissions, see the detailed explanation in the UBB.threads Installation Guide.

4. Set up Cron Task – Subscriptions
If you wish to use the digest subscriptions feature (users can subscribe to daily digests of forum activity), then the file subscriptions.php should be run nightly. Tell your webhost the location where you have uploaded the file, and request that they set up a cron task for you to run the script.

If you’re doing it yourself, you need to edit your crontab so the script will run nightly. Use the command “crontab –e” or “man crontab”. DO NOT RUN THIS SCRIPT AS ROOT.

Something like the following will work on most systems.

0 1 * * * root /home/httpd/html/ubbthreads.com/php/cron/subscriptions.php

You might also need to change the path to the script or the user it runs as, but this example would run the script at 1 AM every morning.

Once the cron task is set up, you will need to go into your UBB.threads Admin control panel, click “config settings”, click “special functions/miscellaneous”, and select “allow subscriptions to forum”. Click “update config.inc.php” and the email digest feature will be enabled.

#128846 05/12/2006 3:30 AM
Joined: Jun 2006
Posts: 956
Old Hand
Old Hand
Joined: Jun 2006
Posts: 956
again: take the file from the archive, open it in any editor you like,
then change this:
require ("/home/www/html/ubbthreads/main.inc.php");
require ("$thispath/languages/{$myprefs['language']}/subscriptions.php");

to this:
require ("../../includes/main.inc.php");
require ("$thispath/languages/{$_SESSION['myprefs']['language']}/subscriptions.php");

then upload the file to its propper place and try to run it from your browser. It schould work without error messages.
If you finish this you can put it to your crontab.

/edit: this is for threads v6.5.x only

Last edited by Zarzal; 05/12/2006 3:33 AM.

my board: http://www.dragonclan-forum.de
my hobby: http://www.biker-reise.de
Ich kann bei Fragen zu UBBthreads in Deutsch weiterhelfen oder es zumindest versuchen
#128847 05/14/2006 5:49 AM
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
Hey thanks for your help

I had tried that I still get

Fatal error: Maximum execution time of 30 seconds exceeded in /usr/wwwroot/ddehek/newzealandnz/discussions/cron/php/subscriptions.php on line 97


I am running v6.5.4

At the top of the .php do I add

#!/usr/bin/php

Like this??

#!/usr/bin/php
<?
/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: NO DATE YET

# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Groupee, Inc., 2005.
# For more info on UBB.threads and other Groupee Services
# visit http://www.groupee.com/ & https://www.ubbcentral.com/

# Program Author: Rick Baker.
# File Version 6.5.4

# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Groupee, Inc..

# Note: if you modify ANY code within UBB.threads, we at Groupee, Inc.
# cannot offer you support-- thus modify at your own peril <img src="https://www.ubbcentral.com/boards/images/graemlins/smile.gif" alt="" />
# ---------------------------------------------------------------------------
*/

// Require the library
require ("../../includes/main.inc.php");
require ("$thispath/languages/{$_SESSION['myprefs']['language']}/subscriptions.php");
$html = new html;
$mailer = new mailer;

#128848 05/14/2006 8:35 AM
Joined: Jun 2006
Posts: 956
Old Hand
Old Hand
Joined: Jun 2006
Posts: 956
Why do you add something? It's not needet. Just REPLACE these 2 lines as I wrote above. Thats all.

Last edited by Zarzal; 05/14/2006 8:35 AM.

my board: http://www.dragonclan-forum.de
my hobby: http://www.biker-reise.de
Ich kann bei Fragen zu UBBthreads in Deutsch weiterhelfen oder es zumindest versuchen
#128849 05/14/2006 8:13 PM
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
I did it after the 2 lines did not work, the script is standard with the 2 lines and it still times out?

I have php installed on my server or do I need something more?

Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13

OK I have tried it all with no joy ;-(

I even added

set_time_limit(300);

And it still returns the same timeout error

I have dumbed the subscribers in the MYSQL database and setup a new one with no joy so this mean there is no large data sending trying to send to hundreds of people but still times out!

Any one got any other ways of test the subscriptions.php?

I have also ask my admin for the php location

Going by the Cron Setup at https://www.ubbcentral.com/support/docs/ubbthreads/UBBthreads_cron.html

I should...

1. Customize Paths
Using NotePad, or a suitable text editor, open doexpire.php and subscriptions.php and place the path to PHP in the top of the script. For example, it might look like this:

#!/usr/bin/php

I have update this to my path

#!/usr/local/bin/php

But I get a can not update header error and then it times out.

Anyone?

Maybe I have a premission set wrong somewhere?

My script subscriptions.php

[]
<?
/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: NO DATE YET

# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Groupee, Inc., 2005.
# For more info on UBB.threads and other Groupee Services
# visit http://www.groupee.com/ & https://www.ubbcentral.com/

# Program Author: Rick Baker.
# File Version 6.5.4

# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Groupee, Inc..

# Note: if you modify ANY code within UBB.threads, we at Groupee, Inc.
# cannot offer you support-- thus modify at your own peril <img src="https://www.ubbcentral.com/boards/images/graemlins/smile.gif" alt="" />
# ---------------------------------------------------------------------------
*/
// Require the library
require ("../../includes/main.inc.php");
require ("$thispath/languages/{$_SESSION['myprefs']['language']}/subscriptions.php");
$html = new html;
$mailer = new mailer;

// ----------------------------------------------
// First we grab all boards that have subscribers
$query = "
SELECT DISTINCT S_Board,MAX(S_Last)
FROM {$config['tbprefix']}Subscribe
GROUP BY S_Board
";
$sth = $dbh -> do_query($query);
$rows = $dbh -> total_rows($sth);

$ostype = find_environmental("OSTYPE");
$newline = "\n";
if (stristr($ostype,"win")) {
$newline = "\r\n";
}


// ----------------------------------------------------------------
// Now we have the boards we need to cycle through the subscribers
for ($j = 0;$j < $rows; $j++ ) {
list($Board,$Last) = $dbh -> fetch_array($sth);
$Board_q = addslashes($Board);

$query = "
SELECT Bo_Title,Bo_Read_Perm
FROM {$config['tbprefix']}Boards
WHERE Bo_Keyword = '$Board_q'
";
$sta = $dbh -> do_query($query);
list($Title,$ReadPerm) = $dbh -> fetch_array($sta);

// ------------------------------
// Now we grab all the posts info
$query = "
SELECT t1.B_Number,t1.B_Posted,t2.U_Username,t1.B_IP,t1.B_Subject,t1.B_Body,t1.B_AnonName,t2.U_Number
FROM {$config['tbprefix']}Posts AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.B_Number > '$Last'
AND t1.B_Approved = 'yes'
AND t1.B_Board = '$Board_q'
AND t1.B_Posterid = t2.U_Number
AND t1.B_Status <> 'M'
ORDER BY t1.B_Number ASC
";
$stk = $dbh -> do_query($query);
$postrows = $dbh -> total_rows($stk);
$seperator = "----------------------------------------------------------------------\n";
$message = "{$ubbt_lang['SUB_DESC2']}\n";
$message = $message . "{$ubbt_lang['SUB_DESC']} '$Title' Forum.\n$seperator\n\n";

// ------------------------------------------------------
// Only send out an email if there are posts for the day
if($postrows > 0){

// --------------------------------------------------------
// Now we cycle through the posts and append to the message
for ($l =0; $l < $postrows; $l++) {
list($Number,$PPosted,$PUsername,$PIP,$PSubject,$PBody,$PAnon,$Pnumber) = $dbh -> fetch_array($stk);
if ($Pnumber == 1) {
if ($PAnon) {
$PUsername = $PAnon;
}
else {
$PUsername = $ubbt_lang['ANON_TEXT'];
}
}
$message = $message . "{$ubbt_lang['SUBJECT_TEXT']}: $PSubject\n";
$message = $message . "{$ubbt_lang['POSTER_TEXT']}: $PUsername\n";
$date = $html -> convert_time($PPosted);
$message = $message . "{$ubbt_lang['POSTON_TEXT']}: $date\n";
$PBody = str_replace("<br>","\n",$PBody);
$PBody = str_replace("<br />","\n",$PBody);
$PBody = str_replace("&lt;br&gt;","\n",$PBody);
$message = $message . "\n$PBody\n\n";
$message = $message . "$seperator\n\n";

}

// ------------------------------------
// Now we need to update the last entry
$query = "
UPDATE {$config['tbprefix']}Subscribe
SET S_Last = $Number
WHERE S_Board = '$Board_q'
";
$dbh -> do_query($query);

// -----------------------------------------
// Now grab everyone that we need to mail to
$query = "
SELECT S_Uid
FROM {$config['tbprefix']}Subscribe
WHERE S_Board = '$Board_q'
";
$sti = $dbh -> do_query($query);
$userrows = $dbh -> total_rows($sti);

// ---------------------------------------------------------
// Now that we have all the users we need to cycle through
for ($k = 0; $k < $userrows; $k++) {

// ---------------------------------------
// Now we need to grab their email address
list($Uid) = $dbh -> fetch_array($sti);
$Uid_q = addslashes($Uid);
$query = "
SELECT U_Email,U_TimeOffset,U_Groups,U_EmailFormat
FROM {$config['tbprefix']}Users
WHERE U_Number = '$Uid_q'
";
$stj = $dbh -> do_query($query);
list($Email,$TimeOffset,$Groups,$emailformat) = $dbh -> fetch_array($stj);
if (!$Email) { continue; }
$query = "
SELECT U_Banned
FROM {$config['tbprefix']}Users
WHERE U_Number='$Uid_q'
";
$stx = $dbh -> do_query($query);
list ($Checkuser) = $dbh -> fetch_array($stx);
$dbh -> finish_sth($stx);
if ($Checkuser) {
continue;
}

$Grouparray = split("-",$Groups);
$canread = 0;
$gsize = sizeof($Grouparray);
for ($i=0; $i<$gsize; $i++) {
if (ereg("-$Grouparray[$i]-",$ReadPerm) ) {
$canread = 1;
}
}
if (!$canread) { continue; }

$mailmessage = $message;
if ($emailformat == "HTML") {
$mailmessage = str_replace("\"{$config['images']}","\"{$config['phpurl']}{$config['images']}",$mailmessage);
$mailmessage = str_replace("\n","<br />\n",$mailmessage);
$mailmessage = "<html>\n<head>\n<title>{$ubbt_lang['SUB_INTRO']} $Title</title>\n</head>\n<body>\n$mailmessage</body>\n</html>\n";
}
$to = $Email;
$from = $config['emailaddy'];
$subject = "{$ubbt_lang['SUB_INTRO']} $Title";
$mailer -> send_mail("$emailformat","","$to","$subject","$mailmessage");

}
}
}

?>
[/]

Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
Update

I now have it setup like this...

Code

#!/usr/local/bin/php
&lt;?
set_time_limit(300);
/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: NO DATE YET

# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Groupee, Inc., 2005.
# For more info on UBB.threads and other Groupee Services
# visit http://www.groupee.com/ &amp; https://www.ubbcentral.com/

# Program Author: Rick Baker.
# File Version 6.5.4

# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Groupee, Inc..

# Note: if you modify ANY code within UBB.threads, we at Groupee, Inc.
# cannot offer you support-- thus modify at your own peril :)
# ---------------------------------------------------------------------------
*/
// Require the library
   require ("../../includes/main.inc.php");
   require ("$thispath/languages/{$_SESSION['myprefs']['language']}/subscriptions.php");
   $html = new html;
   $mailer = new mailer;


I now get this error

#!/usr/local/bin/php
Warning: Cannot modify header information - headers already sent by (output started at /usr/wwwroot/ddehek/newzealandnz/discussions/cron/php/subscriptions.php:2) in /usr/wwwroot/ddehek/newzealandnz/discussions/ubbt.inc.php on line 122

Fatal error: Maximum execution time of 300 seconds exceeded in /usr/wwwroot/ddehek/newzealandnz/discussions/cron/php/subscriptions.php on line 102

Just incase it helps some clever person!

Joined: Jun 2006
Posts: 9,242
Likes: 1
R
Former Developer
Former Developer
R Offline
Joined: Jun 2006
Posts: 9,242
Likes: 1
It's actually printing out your #!/usr/local/bin/php line. How are you running this? If your running it like '/usr/local/bin/php subscriptions.php' then you can remove the first line altogether.

Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
to test it I am just entering the url www. and running testing this way

Joined: Dec 2003
Posts: 1,796
Pooh-Bah
Pooh-Bah
Joined: Dec 2003
Posts: 1,796
I don't think it runs from the www url. It should run with the server cron setup for it tho.

I can't get it to run on a site I have been tasked with setting up - I don't see any errors tho :/


- Allen
- ThreadsDev | PraiseCafe
Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
I agree with allen, I think the subscribers php file is supposed to be executed via the command line on a unix machine via the cron utility...


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
It was not working at 1am as it should have when I was using cron utility.

Thank for your feedback

#128857 05/17/2006 2:39 AM
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
I need to ask my admin each time I setup a Cron job however I have Telnet Access so would this be the right commands for setting this cron job myself?

My PHP is at /usr/local/bin/php

Would I login to telnet and type crontab -e at the command line Enter

0 1 * * * /usr/local/bin/php –q /usr/wwwroot/ddehek/newzealandnz/discussions/cron/php/subscriptions.pl

Cheers Beers

#128858 05/17/2006 2:49 AM
Joined: Jun 2006
Posts: 956
Old Hand
Old Hand
Joined: Jun 2006
Posts: 956
subscriptions.pl is the perl version, not a php script


my board: http://www.dragonclan-forum.de
my hobby: http://www.biker-reise.de
Ich kann bei Fragen zu UBBthreads in Deutsch weiterhelfen oder es zumindest versuchen
Joined: Jun 2006
Posts: 956
Old Hand
Old Hand
Joined: Jun 2006
Posts: 956
[]I don't think it runs from the www url. It should run with the server cron setup for it tho.[/]

You can call the subscriptions.php in your browser every time and it works well. When I remember correct my provider setup a cron job with wget to execute the php script once a day.


my board: http://www.dragonclan-forum.de
my hobby: http://www.biker-reise.de
Ich kann bei Fragen zu UBBthreads in Deutsch weiterhelfen oder es zumindest versuchen
#128860 05/17/2006 5:39 AM
Joined: Jun 2006
Posts: 13
D
stranger
stranger
D Offline
Joined: Jun 2006
Posts: 13
O My God! good spotting!! I think this has been my error!! Silly Kiwi!!


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Bots
by Outdoorking - 04/13/2024 5:08 PM
Can you add html to language files?
by Baldeagle - 04/07/2024 2:41 PM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
This is not a bug, but a suggestion
by Baldeagle - 04/05/2024 11:25 PM
Is UBB.threads still going?
by Aaron101 - 04/01/2022 8:18 AM
Who's Online Now
1 members (Nightcrawler), 715 guests, and 175 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240501)