Antwort #15 am: 21. Februar 2017, 22:36:08
Nabend.
Ich habe den Code oben in eine separate Datei gepackt und über eine Datei für das Hilfsprogramme Menü gebastelt. Das klappt soweit (Shop V.2.0.2.1). Da der Shop auf UTF-8 läuft, ist auch die Exportdatei in UTF-8. Kann man den Export auch in ANSI erstellen?
Als zweites habe ich versucht den Output in eine Datei zu speichern und als Link im Admin Bereich zum Download zu ermöglichen. Die Datei wird zwar angelegt, ist dann aber leer. Vermutlich ist es da mit dem ersetzen des echo mit $content .= nicht getan?
Kann da evtl. mir jemand einen Tipp geben, wo der Haken ist?
Danke!
<?php error_reporting(E_ALL);require ('includes/application_top.php'); $content = "";// show List of all Recipients, where status is OK $csv = xtc_db_query
("SELECT customers_firstname, customers_lastname, customers_email_address FROM ".TABLE_NEWSLETTER_RECIPIENTS
." WHERE mail_status = 1"); // write heading $kopfzeile = 'Vorname;Nachname;E-Mail' . "\r\n"; // write data while ($row = xtc_db_fetch_array
($csv)){ $content .= ''. str_replace(array("\r","\n",",",'"'),array(''),$row['customers_firstname']) . ';' . str_replace(array("\r","\n",",",'"'),array(''),$row['customers_lastname']) . ';' . str_replace(array("\r","\n",",",'"'),array(''),$row['customers_email_address']) . '' . "\r\n"; } die(); $content = $kopfzeile.$content; print chr(0xEF).chr(0xBB).chr(0xBF); // print $content; $handle = fopen("./export/dataexport.csv","w"); fwrite($handle,$content); fclose($handle); require (DIR_WS_INCLUDES
.'head.php');?><style type="text/css">
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?phprequire (DIR_WS_INCLUDES
.'header.php');?><!-- header_eof //-->
<table style="border:none; width:100%;" cellspacing="2" cellpadding="2">
<tr>
<td class="columnLeft2" width="
<?php echo BOX_WIDTH
; ?>" valign="top">
<?php //left_navigation if (USE_ADMIN_TOP_MENU
== 'false') { echo '<td class="columnLeft2">'.PHP_EOL
; echo '<!-- left_navigation //-->'.PHP_EOL
; require_once(DIR_WS_INCLUDES
. 'column_left.php'); echo '<!-- left_navigation eof //-->'.PHP_EOL
; echo '</td>'.PHP_EOL
; } ?> </td>
<!-- body_text //-->
<td class="boxCenter" width="100%" valign="top">
<?php # column_left.php: $admin_access
define('EDIT_MODE', ($admin_access['stocklist_edit'] == '1')); define('CONFIG_MODE', ($admin_access['stocklist_config'] == '1')); if(isset($_REQUEST['access']) && EDIT_MODE
) { $_SESSION['access'] = $_REQUEST['access']; } elseif(!isset($_SESSION['access'])) { $_SESSION['access'] = 0; } echo xtc_draw_form
('stocklist', FILENAME_STOCKLIST
); echo xtc_draw_hidden_field
('search', $_SESSION['search']); echo xtc_draw_hidden_field
('page', $_SESSION['page']); echo xtc_draw_hidden_field
('sorting', $_SESSION['sorting']); echo xtc_draw_hidden_field
('action', ''); ?> <div class="pageHeadingImage">
<?php echo xtc_image
(DIR_WS_ICONS
.'heading/das richtige icon.png'); ?></div>
<div class="pageHeading">
<?php echo 'HIER FEHLT NOCH DIE VARIABLE'; ?></div>
<div class="main pdg2 flt-l">
<?php echo 'UND HIER AUCH'; ?><br /> </div>
<table border="0" cellspacing="0" cellpadding="0">
<td class="boxCenter" width="100%" valign="top" align="center">
<a href="./export/dataexport.csv">Download Newsletterempfaenger</a>
</td>
<!-- 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'); ?>