Zen Cart Logo
Forums / General Questions / Email Address Export add-on... limited to Newsletter customer

Email Address Export add-on... limited to Newsletter customer

Locked

Views: 4,673

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
14 May 2008, 2:37 AM
#1
mauiexcellent avatar

mauiexcellent

New Zenner

Join Date:
Nov 2006
Posts:
13
Plugin Contributions:
0

Email Address Export add-on... limited to Newsletter customer

Hello!

Dr. Byte provided a Customer Email Export Add-On for the Admin area, in the Downloads section. Unfortunately, it is entirely limited to Newsletter customers, and not the entier customer base.

So, I have 2 questions:

  1. How do I modify that specific program to export the ENTIRE customer database to a "*.CSV" file.

  2. How do I access my databases, in general? I hear people talk about using MyPhP Admin or MySQL...but how do I activate an application like that to access my own database...and where the heck is the actual *.dbs (or whatever it is called) Database file!

Thanks!!!!!!
Matt
Maui Excellent

14 May 2008, 2:42 AM
#2
fatguyinaz avatar

fatguyinaz

Zen Follower

Join Date:
Oct 2007
Location:
Safford, AZ
Posts:
313
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

You should be able to access your SQL Database area from within your cPanel. There should be a link within the SQL Database area to access PHPMyAdmin.

15 May 2008, 2:20 AM
#3
mauiexcellent avatar

mauiexcellent

New Zenner

Join Date:
Nov 2006
Posts:
13
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

Hmmmm....I am fully upgraded to 1.3.7 (not yet the new .8), and I see no tab or button for "cPanel" anywhere. How can I activate that? It sounds like that is what I have wanted all along...true, direct SQL query access to my own database.

Also, still...where is the ACTUAL file path for the *dbs or whatever the SQL file is? I want that backed up separately.

Hep me!

But thanks in advance!!!!

Matt

FatGuyinAZ:

You should be able to access your SQL Database area from within your cPanel. There should be a link within the SQL Database area to access PHPMyAdmin.

15 May 2008, 2:28 AM
#4
fatguyinaz avatar

fatguyinaz

Zen Follower

Join Date:
Oct 2007
Location:
Safford, AZ
Posts:
313
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

cPanel isn't part of Zen Cart. It's a feature through your hosting company. Who do you have your website hosted by?

The database is stored on the server, with the people that is hosting your site.

16 May 2008, 1:36 AM
#5
mauiexcellent avatar

mauiexcellent

New Zenner

Join Date:
Nov 2006
Posts:
13
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

I am hosted through Camelot-Hosting, a Zen-Cart forum recommended host. WHat should I be asking them?

FatGuyinAZ:

cPanel isn't part of Zen Cart. It's a feature through your hosting company. Who do you have your website hosted by?

The database is stored on the server, with the people that is hosting your site.

16 May 2008, 1:48 AM
#6
mauiexcellent avatar

mauiexcellent

New Zenner

Join Date:
Nov 2006
Posts:
13
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

But still, I wonder...isn't the SQL query to change the PHP file pretty simple? I tried just removing the word "newsletters", it didn't work.

Here is the PHP file that makes the query that returns ONLY newsletter subscribers:

--------
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | [URL]http://www.zen-cart.com/index.php[/URL]                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | [URL]http://www.zen-cart.com/license/2_0.txt[/URL].                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [EMAIL="[email protected]"][email protected][/EMAIL] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//  $Id: email_export.php   2005-04-15  drbyte $
 require('includes/application_top.php');

// change destination here for path when using "save to file on server"
if (!defined('DIR_FS_EMAIL_EXPORT')) define('DIR_FS_EMAIL_EXPORT',DIR_FS_CATALOG.'images/uploads/');

 $action = (isset($_GET['action']) ? $_GET['action'] : '');
 $NL="
"; // NOTE: The line break above is INTENTIONAL!
 $available_export_formats[0]=array('id' => '0', 'text' => 'CSV');
 $available_export_formats[1]=array('id' => '1', 'text' => 'TXT');
 $available_export_formats[2]=array('id' => '2', 'text' => 'HTML');
 $available_export_formats[3]=array('id' => '3', 'text' => 'XML');
 $save_to_file_checked=(isset($_POST['savetofile']) && zen_not_null($_POST['savetofile']) ? $_POST['savetofile'] : 0 );
 $post_format = (isset($_POST['format']) && zen_not_null($_POST['format']) ? $_POST['format'] : 1 );
 $format = $available_export_formats[$post_format]['text'];
 $file = (isset($_POST['filename']) ? $_POST['filename'] : 'email_addresses.txt');
 if ($action != '') {
   switch ($action) {
     case 'save':
     global $db;
 if ($format =='CSV') {
   $FIELDSTART = '"';
   $FIELDEND = '"';
   $FIELDSEPARATOR = ',';
   $LINESTART = '';
   $LINEBREAK = "\n";
 }
 if ($format =='TXT') {
   $FIELDSTART = '';
   $FIELDEND = '';
   $FIELDSEPARATOR = "\t";
   $LINESTART = '';
   $LINEBREAK = "\n";
 }
 if ($format =='HTML') {
   $FIELDSTART = '<td>';
   $FIELDEND = '</td>';
   $FIELDSEPARATOR = "";
   $LINESTART = "<tr>";
   $LINEBREAK = "</tr>".$NL;
 }
     if (isset($_POST['audience_selected'])) {
         $query_name=$_POST['audience_selected'];
       if (is_array($_POST['audience_selected']))  $query_name=$_POST['audience_selected']['text'];
     }
     $audience_select = get_audience_sql_query($query_name, 'newsletters');
     $query_string = (get_magic_quotes_runtime() > 0) ? stripslashes($audience_select['query_string']) : $audience_select['query_string'];
     $audience = $db->Execute($query_string);
     $records = $audience->RecordCount();
     if ($records==0) {
       $messageStack->add("No Records Found.", 'error');
     } else { //process records
       $i=0;
       // make a <table> tag if HTML output
       if ($format == "HTML") {
         $exporter_output .= '<table border="1">'.$NL;
       }
       // add column headers if CSV or HTML format
         if ($format == "CSV" || $format == "HTML") {
           $exporter_output .=  $LINESTART;
           $exporter_output .=  $FIELDSTART . "customers_email_address".$FIELDEND;
           $exporter_output .=  $FIELDSEPARATOR;
           $exporter_output .=  $FIELDSTART . "customers_firstname".$FIELDEND;
           $exporter_output .=  $FIELDSEPARATOR;
           $exporter_output .=  $FIELDSTART . "customers_lastname".$FIELDEND;
           $exporter_output .=  $LINEBREAK;
         }
         // headers - XML
         if ($format == "XML") {
           $exporter_output .=  '<?xml version="1.0" encoding="' . CHARSET . '"?>'."\n";
         }
       // output real data
       while (!$audience->EOF) {
         $i++;
         if ($format=="XML") {
           $exporter_output .=  "<address_book>\n";
           $exporter_output .=  "  <contact>\n";
           $exporter_output .=  "    <firstname>" . $audience->fields['customers_firstname'] . "</firstname>\n";
           $exporter_output .=  "    <lastname>" .$audience->fields['customers_lastname'] . "</lastname>\n";
           $exporter_output .=  "    <email_address>" . $audience->fields['customers_email_address'] . "</email_address>\n";
           $exporter_output .=  "  </contact>\n";
         } else {  // output non-XML data-format
           $exporter_output .=  $LINESTART;
           $exporter_output .=  $FIELDSTART . $audience->fields['customers_email_address'].$FIELDEND;
           $exporter_output .=  $FIELDSEPARATOR;
           $exporter_output .=  $FIELDSTART . $audience->fields['customers_firstname'].$FIELDEND;
           $exporter_output .=  $FIELDSEPARATOR;
           $exporter_output .=  $FIELDSTART . $audience->fields['customers_lastname'].$FIELDEND;
           $exporter_output .=  $LINEBREAK;
         }
       $audience->MoveNext();
       }
       if ($format == "HTML") {
         $exporter_output .=  $NL."</table>";
       }
       if ($format == "XML") {
         $exporter_output .=  "</address_book>\n";
       }

   // theoretically, $i should == $records at this point.
     // status message
     $messageStack->add($records . " Processed.", 'success');
     // begin streaming file contents
     if ($save_to_file_checked != 1) { // not saving to a file, so do regular output
       if ($format == "CSV" || $format =="TXT" || $format=="XML") {
         if ($format == "CSV" || $format =="TXT") {
           $content_type = 'text/x-csv';
         } elseif ($format == "XML") {
           $content_type = 'text/xml; charset='.CHARSET;
         }
         if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
           header('Content-Type: application/octetstream');
//            header('Content-Type: '.$content_type);
//              header('Content-Disposition: inline; filename="' . $file . '"');
           header('Content-Disposition: attachment; filename=' . $file);
           header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");
           header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
           header("Cache-Control: must_revalidate, post-check=0, pre-check=0");
           header("Pragma: public");
           header("Cache-control: private");
         } else {
           header('Content-Type: application/x-octet-stream');
//            header('Content-Type: '.$content_type);
           header('Content-Disposition: attachment; filename=' . $file);
           header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");
           header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
           header("Pragma: no-cache");
         }
         echo $exporter_output;
         exit;
       } else {
         echo $exporter_output;
         exit;
       }
     } else { //write to file
       //open output file for writing
       $f=fopen(DIR_FS_EMAIL_EXPORT.$file,'w');
       fwrite($f,$exporter_output);
       fclose($f);
       unset($f);
     } // endif $save_to_file
   } //end if $records for processing not 0
   zen_redirect(zen_href_link(FILENAME_EMAIL_EXPORT));
   break;
   }  //end switch / case
 }  //endif $action
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
 <!--
 function init()
 {
   cssjsmenu('navbar');
   if (document.getElementById)
   {
     var kill = document.getElementById('hoverJS');
     kill.disabled = true;
   }
 }
 // -->
</script>
</head>
<body onload="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
     </tr>
     <tr><?php echo zen_draw_form('export', FILENAME_EMAIL_EXPORT, 'action=save','post');//, 'onsubmit="return check_form(export);"'); ?>
       <td align="center">
         <table border="0" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><?php echo TEXT_EMAIL_EXPORT_FORMAT; ?><br />
<?php echo zen_draw_pull_down_menu('format', $available_export_formats, $format); ?></td>
         </tr>
         <tr>
           <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_PLEASE_SELECT_AUDIENCE; ?><br />
<?php echo zen_draw_pull_down_menu('audience_selected', get_audiences_list('newsletters'), $query_name)?></td>
         </tr>
         <tr>
           <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_EMAIL_EXPORT_FILENAME; ?><br />
<?php echo zen_draw_input_field('filename', $file); ?></td>
         </tr>
         <tr>
           <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_EMAIL_EXPORT_SAVETOFILE; ?><br />
<?php echo zen_draw_checkbox_field('savetofile', '1', $save_to_file_checked); 
     echo TEXT_EMAIL_EXPORT_DEST . ' ' .DIR_FS_EMAIL_EXPORT; ?></td>
         </tr>
         <tr>
           <td class="main" align="right"><?php echo zen_image_submit('button_save.gif', IMAGE_SAVE) . '  <a href="' . zen_href_link(FILENAME_DEFAULT) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
         </tr>
         <tr>
           <td class="main" colspan="2"><?php echo TEXT_INSTRUCTIONS; ?></td>
         </tr>
     </table></td>
   </form>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br />
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


--------

mauiexcellent:

I am hosted through Camelot-Hosting, a Zen-Cart forum recommended host. WHat should I be asking them?

16 May 2008, 2:27 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Email Address Export add-on... limited to Newsletter customer

You can access your phpMyAdmin tool via your cPanel control panel area ... which has nothing to do with Zen Cart at all. Your hosting company provides that.
Ask your host "how do I access my cPanel?" ... or better yet, check their online FAQs for that information ... or even better, look at the confirmation emails you got from them when you signed up for your hosting account. All that information is provided there.

There is no such thing as a *.dbs file when you're working with a MySQL database. It's a fair bit more sophisticated than MS Access.

As for doing database backups, there is an FAQ on doing Zen Cart database backups via phpMyAdmin in the Zen Cart FAQs area.

16 May 2008, 2:29 AM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Email Address Export add-on... limited to Newsletter customer

mauiexcellent:

  1. How do I modify that specific program to export the ENTIRE customer database to a "*.CSV" file.

That mod was written for exporting email address and customer names.

If you want your "entire" customer database exported, and not just information pertinent to using it for emailing purposes, you'll need to do a fair bit of custom coding to restructure the output for all the fields in multiple tables.

It's not designed to be a customer address manager.

16 May 2008, 2:35 AM
#9
fatguyinaz avatar

fatguyinaz

Zen Follower

Join Date:
Oct 2007
Location:
Safford, AZ
Posts:
313
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

Matt,

Sorry I can't help you with the file/code you posted. However, you should be able to login to your hosting account via the main Camelot Hosting page. Click this link and enter your username/password you got from them when you signed up. According to their hosting specs they have a Control Panel (cPanel). When you are in the cPanel you should be able to access your SQL Databases. Just look for an icon or button.

https://www.camelot-hosting.com/hosting/aLogIn.php

This is about all I can help with, which isn't much.

Now that you have mentioned your hosting provider I am sure others will be able to assist.

Good luck

22 May 2008, 6:01 PM
#10
mauiexcellent avatar

mauiexcellent

New Zenner

Join Date:
Nov 2006
Posts:
13
Plugin Contributions:
0

Re: Email Address Export add-on... limited to Newsletter customer

Thanks very much everyone for your help. Yes, through the original domain email I did access PhPMyAdmin, and I exported the customer list. Thanks again!!!!!