Author Topic: Export users e-mails  (Read 2945 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Export users e-mails
« on: October 20, 2007, 05:21:12 PM »
Hi,

Is there a mod to export users e-mails to a text file?
I want to import the e-mails into a mailinglist program.

I saw a similar mod for phpBB:

Quote
<?php
/***************************************************************************
 *                                admin_export_emails.php
 *                            -------------------
 *   begin                : Saturday, July 31, 2006
 *   copyright            : (C) Funender.com
 *
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['Users']['Export_Emails'] = $file;
   return;
}

//
// Let's set the root dir for phpBB
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);

//
// Begin Email Export
//

export_email($HTTP_POST_VARS['search_username']);

function export_email($emails_found)
{
   global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
   
   if ( !empty($emails_found) )
   {
      $export_email = preg_replace('/\*/', '%', trim(strip_tags($emails_found)));

      $sql = "SELECT *
         FROM " . USERS_TABLE . "
         WHERE user_email != '';";
      if ( !($result = $db->sql_query($sql)) )
      {
         message_die(GENERAL_ERROR, 'Could not obtain emails', '', __LINE__, __FILE__, $sql);
      }

      if ( $row = $db->sql_fetchrow($result) )
      {
         do
         {
            $export_list .= $row['user_email'] . '<br />';
         }
         while ( $row = $db->sql_fetchrow($result) );
      }
      else
      {
         message_die(GENERAL_ERROR, 'Could not obtain emails');
      }
      $db->sql_freeresult($result);
   }

   $page_title = $lang['Export_Emails_Title'];

   $template->set_filenames(array(
      "body" => "admin/export_emails.tpl")
   );

   $template->assign_vars(array(
       'L_EXPORT_EMAILS_PAGE' => $lang['Export_emails_page'],
      'L_EXPORT_EMAILS_EXPLAIN' => $lang['Export_emails_explain'],
       'L_EXPORT_EMAILS_HEADER' => $lang['Export_emails_header'],
      'L_EXPORT' => $lang['Export'], 

      'S_EXPORT_LIST' => $export_list,
      'S_EXPORT_ACTION' => append_sid("admin_export_emails.$phpEx"))
   );

   if ( $export_list != '' )
   {
      $template->assign_block_vars('export_email_list', array());
   }

   $template->pparse("body");

include('./page_footer_admin.'.$phpEx);
   
   }

?>

Can someone do this very important MOD?

Cheers,
cruxy

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Export users e-mails
« Reply #1 on: October 21, 2007, 12:48:34 AM »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Export users e-mails
« Reply #2 on: October 21, 2007, 01:07:28 AM »
Thank you thunderstrike, it get what I want!