Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues
Author Message
Lucifix
Regular
Regular



Joined: Mar 11, 2005
Posts: 67

PostPosted: Tue Jan 29, 2013 9:39 am Reply with quote

I've got 3.000 subscribers for my HTML Newsletter. When I try to send all of them newsletter, after awhile I receive this error:

Quote:
ERROR: 500 - Internal Server Error

Internal Server Error
Namig: Check the .htaccess file for syntax/configuration errors


And in apache error log:
Quote:
Script timed out before returning headers:admin.php, referer: ***?op=msnl_admin


I understand this error and I could change max_execution_time in php.ini file. But this maybe it's not the best options.

Does anyone know what could I do to avoid this problem?
 
View user's profile Send private message
hicuxunicorniobestbuildpc
The Mouse Is Extension Of Arm



Joined: Aug 13, 2009
Posts: 1122

PostPosted: Tue Jan 29, 2013 4:20 pm Reply with quote

Safe .htaccess on your computer from your root where the mainfile is. Delete or remove it from your server. Send the newsletter again. If you don't get the 500 error means your problems come from .htacess file so u should post it completly here in order to check it.
 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Wed Jan 30, 2013 3:44 am Reply with quote

Also check with your hosting provider regarding mass mail sending. The majority of hosting providers put a limit on the number of emails they will send per hour, per account as a Spam prevention measure. and also to stop EXIM from falling over.
 
View user's profile Send private message Send e-mail
Lucifix







PostPosted: Thu Apr 04, 2013 11:55 pm Reply with quote

Sorry for my late reply. Actually the problem is within PHP script, because it tries to send over 3000 emails in one step which takes some time. Htaccess or my host provider (I'm on VPS) isn't the problem. The script just shouldn't load over few minutes to finish its job.

The problem for this solution would be sending email with steps and using javascript for redirecting to next page:
1. step: send 500 emails
- redirect -
2. step: next 500 emails
etc.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Apr 06, 2013 4:42 pm Reply with quote

Lucifix, completely agree, although, for some hosts, even this wouldn't work as they can impose additional constraints. But, the approach you mention was my plan from the beginning for what I like to call a "poor man's approach" to the issue. Sorry that I never got around to implementing.

Years later, when I incorporated the Swift Mailer script into *nuke, my intent at that time was to using its Anti-Flood and Throttler plugins to "do the job"... Again, Sad , my hobby/programming time just went out the window with life and RN.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Sun Apr 07, 2013 1:36 pm Reply with quote

This may or not apply to your case, but I suspect that a lot of sites have many users who once created an ID and haven't logged on since. You could take a quick look using PHPmyadmin and sorting on the lastsitevisit field.

I recently reduced my users table from over 1800 records to around 700 using this approach.

Here is a modified version of a script I used to list users by lastsitevisit. It also tell how many stories and forum posts they authored. I haven't tested the modifications I made (to include the database config variables right in the script rather than in a separate file) so you might need to tweak. I imported the output of this into a spreadsheet to help manage it.

Code:


$dbhost = 'localhost';
$dbname     = 'your name';
$dbuname = 'your username';
$dbpass = 'your password';
$prefix = 'nuke';
$user_prefix = 'nuke';
    require_once("../db/db.php");
   $sql = "SELECT * FROM ".$user_prefix."_users ORDER BY `lastsitevisit` ASC";
   $result = $db->sql_query($sql);
      while ($row = $db->sql_fetchrow($result)) {
         $numst = 0;
         $numbb = 0;
         $sql2 = 'SELECT `poster_id` FROM '. $user_prefix.'_bbposts WHERE `poster_id` = \''. $row['user_id'].'\'';
         $result2 = $db->sql_query($sql2);
//         echo $sql2 . '<br />';
         $numbb = $db->sql_numrows($result2);
         $sql3 = 'SELECT `informant` FROM nuke_stories WHERE `informant` = \''.$row['username'].'\'';
         $result3 = $db->sql_query($sql3);
         $numst = $db->sql_numrows($result3);
         echo  '"' . $row['user_id'] . '" "'. $row['username'] . '" "' . $row['user_email'] . '" "' . date('Y-m-d', $row['lastsitevisit']) . '" "'. $numbb . '" "'. $numst. '" . <br/>';
      }


I also wrote a batch delete so I didn't need to go in and delete 1000 users by hand.

The other thing you could do is export your email addresses to something like MailChimp.
 
View user's profile Send private message Visit poster's website
hicuxunicorniobestbuildpc







PostPosted: Mon Apr 08, 2013 5:22 am Reply with quote

Hi fkelly. Can u share the bath delete script.? I think it will be a good idea to have that option in the new RaveNuke 3.0.
 
fkelly







PostPosted: Mon Apr 08, 2013 7:30 am Reply with quote

With no warranty ... you need to backup your users table before running this and read the comments at the top of the program. What is listed here is for test_mode ... it won't delete anything until you go in and change it from test mode. I ran through the last visit list many times before and ran this on a test system a number of times before going live, so be cautious.

Once you run this live you basically will have no way to restore your users without restoring the whole database because a number of different tables are affected

That said:

Code:


<?php
// USAGE
// Put these files in an adhocs directory under your nuke root
// delete them when done -- saving copies on your local machine but not leaving them on your web server
// create a simple_config.php with database and prefix items from your config.php
// these include:  $dbhost = 'xxxx'; $dbuname = 'xxxx';  $dbpass = 'xxxx';  $dbname = 'xxxx';  $prefix = 'xxxx';
//  $user_prefix = 'xxxx'; $dbtype = 'MySQL';
// where xxxx is your values
// prepare a text file of userids that you want to delete  this goes in the adhocs directory too
// each line in the text file must start with the userid (an integer) followed by a blank
// by default the text file is named deleteusers.txt and is in the adhocs directory
// there is a testmode for this program; to start with we recommend you run it with testmode set to true
// realizing that the effects are irreversible, run this with testmode set to false when you are ready
// you might want to back up your users table first, in fact we'd highly recommend this but realize that this program changes other tables as well and is really irreversible.
 require_once("../simple_config.php");
    require_once("../db/db.php");
$file = 'deleteusers.txt';
$testmode = true;
$res = fopen("$file","r");
if ($res) {
   while (!feof($res)) {
      $contents = rtrim(fgets($res));
      if (empty($contents)) continue;   // Allows empty line at end of file
//      echo $contents . '<br />';
      $del_uid = substr($contents, 0, 4);
      if ($testmode) {
         echo $del_uid . ' ' . $contents . '<br />';
         continue;
      }
      else {
   // Delete phpbb groups associated with the user
      $result1 = $db->sql_query('SELECT group_id FROM ' . $prefix . '_bbuser_group WHERE user_id = \''.$del_uid.'\'');
      if ($db->sql_numrows($result1) > 0) {
         while ( $row_grouplist = $db->sql_fetchrow($result1) ) {
            $group_list[] = $row_grouplist['group_id'];
            }
         $db->sql_query('DELETE FROM ' . $prefix . '_bbuser_group WHERE user_id=\''.$del_uid.'\'');
         $delete_sql_id = implode(', ', $group_list);
         $result2 = $db->sql_query('SELECT group_id FROM ' . $prefix . '_bbgroups WHERE group_moderator = \'0\' AND group_single_user = \'1\' AND group_id IN ('.$delete_sql_id.')');
      if ($db->sql_numrows($result2) >= 1) {
         list($group_id) = $db->sql_fetchrow($result2);
         $db->sql_query('DELETE FROM ' . $prefix . '_bbauth_access WHERE group_id = '.$group_id.'');
      }
      $db->sql_query('DELETE FROM ' . $prefix . '_bbgroups WHERE group_moderator = \'0\' AND group_single_user = \'1\' AND group_id IN ('.$delete_sql_id.')');
      }
         // Delete NSN Group Info
      $db->sql_query('DELETE FROM ' . $prefix . '_nsngr_users WHERE uid = \'' . $del_uid . '\'');
      $db->sql_query('DELETE FROM ' . $user_prefix . '_users_field_values WHERE uid=\'' .  $del_uid . '\'');
      $db->sql_query('DELETE FROM ' . $user_prefix . '_users WHERE user_id=\'' .  $del_uid . '\'');

      list($rem_uname) = $db->sql_fetchrow($db->sql_query('SELECT username FROM ' . $user_prefix . '_users WHERE user_id=\'' . $del_uid . '\''));
      $db->sql_query('UPDATE ' . $prefix . '_bbposts SET poster_id = 1, post_username = \'' . $rem_uname . '\' WHERE poster_id = \''. $del_uid.'\'');
      $db->sql_query('UPDATE ' . $prefix . '_bbtopics SET topic_poster = 1 WHERE topic_poster = \''. $del_uid.'\'');
      $db->sql_query('UPDATE ' . $prefix . '_bbvote_voters SET vote_user_id = 1 WHERE vote_user_id = \''. $del_uid.'\'');
   // Remove other phpbb related info
      $db->sql_query('DELETE FROM ' . $prefix . '_bbtopics_watch WHERE user_id=\''. $del_uid.'\'');
      $db->sql_query('DELETE FROM ' . $prefix . '_bbbanlist WHERE ban_userid=\''. $del_uid.'\'');
      $result3 = $db->sql_query('SELECT privmsgs_id FROM ' . $prefix . '_bbprivmsgs WHERE privmsgs_from_userid = \''. $del_uid.'\' OR privmsgs_to_userid = \''. $del_uid.'\'');
   if ($db->sql_numrows($result3) > 0) {
      while ( $row_privmsgs = $db->sql_fetchrow($result3) ) {
         $mark_list[] = $row_privmsgs['privmsgs_id'];
      }
      $delete_sql_id = implode(', ', $mark_list);
      $db->sql_query('DELETE FROM ' . $prefix . '_bbprivmsgs_text WHERE privmsgs_text_id IN ('.   $delete_sql_id.')');
      $db->sql_query('DELETE FROM ' . $prefix . '_bbprivmsgs WHERE privmsgs_id IN ('.$delete_sql_id.')');
      }

      } // end of else testmode
   } //end of the while reading delete input file      // all optimizes
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbprivmsgs_text');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbprivmsgs');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbuser_group');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbauth_access');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbgroups');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_nsngr_users');
   $db->sql_query('OPTIMIZE TABLE ' . $user_prefix . '_users_field_values');
   $db->sql_query('OPTIMIZE TABLE ' . $user_prefix . '_users');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbtopics_watch');
   $db->sql_query('OPTIMIZE TABLE ' . $prefix . '_bbbanlist');
} // we can open the input file
?>


I also fixed up a simple config that does this:

Code:
<?php

$dbhost = 'localhost';
$dbname     = '';
$dbuname = '';
$dbpass = '';
$prefix = 'nuke';
$user_prefix = 'nuke';
$dbtype = 'MySQL';
$display_errors = true;
?>


You'll need to put this in your nuke root.

Here's a few sample lines from the deleteusers.txt file:

Quote:

2600 D David_Mika mika@crd.ge.com
2352 D namcaosan@hotmail.com namcaosan@hotmail.com
2636 D peteg gilbertsonp@minervasd.org
2637 D TonyE aeldering1@verizon.net
2646 D Darren e25094@aol.com
2668 D Dan dsamson@nycap.rr.com


Only the first four characters on each line are used for the actual deletion.
 
hicuxunicorniobestbuildpc







PostPosted: Mon Apr 08, 2013 12:20 pm Reply with quote

Can u explain what means the letter D. What I know 2600 is the ID, David_Mika is the username but what is D then?

2600 D David_Mika [ Only registered users can see links on this board! Get registered or login! ]
 
fkelly







PostPosted: Mon Apr 08, 2013 1:30 pm Reply with quote

I think the letter D simply denotes that we intended to delete this user. This data was processed extensively in a spreadsheet file to sort out those who we wanted to delete versus those who we didn't want to delete. Then we just sorted on the D field (column in a spreadsheet) and copied and pasted that data into a text file. You'll note in the PHP code, the line:

$del_uid = substr($contents, 0, 4);

If your userids have any values greater then 9999 you'll need to modify this line of code. The rest of the input (column 5 and further) is ignored. When you run the script in test mode it does get output to the screen so you can see who will be deleted.

I hope I've put enough caveats in this that no one shoots themselves in the foot. You really need to have a backup of your data and I'd very highly recommend that you run this on a local server against a copy of your "real" site a few times before going live.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©