Example #1
0
                if ($ab_del) {
                    echo '<button class="btn" name="delete" data-delete-msg="' . $LANG['delete_msg'] . '">' . $LANG['delete_all'] . '</button> ';
                }
                if ($ab_edt) {
                    echo $LANG['action'] . ':
    <select name="action">';
                    foreach (array('verify' => $LANG['verify'], 'unverify' => $LANG['unverify']) as $k => $v) {
                        echo '<option value="' . $k . '">' . $v . '</option>';
                    }
                    echo '</select>

    <button class="btn" name="set_action">' . $LANG['set_all'] . '</button>';
                }
                echo '</div>';
            }
            foreach (admin_query::while_subscribers(array_merge(array('orderby' => isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'date desc'), $options)) as $item) {
                echo '<li>
  <input type="checkbox" name="id[' . $item->ID . ']"' . ($item->is_user ? ' disabled' : '') . ' />';
                if ($item->is_user) {
                    echo '<div style="display: table;">

  <img src="' . \query\main::user_avatar($item->user_avatar) . '" alt="" />

  <div class="info-div"><h2>' . ($item->verified ? '<span class="msg-success">' . $LANG['verified'] . '</span> ' : '<span class="msg-error">' . $LANG['notverified'] . '</span> ') . htmlspecialchars($item->user_name) . '
  <span class="fright date">' . date('Y.m.d, ' . (\query\main::get_option('hour_format') == 12 ? 'g:i A' : 'G:i'), strtotime($item->date)) . '</span></h2>
  ' . htmlspecialchars($item->email) . '</div>

  </div>

  <div style="clear:both;"></div>
    die;
}
$from = isset($_POST['date']['from']) ? strtotime($_POST['date']['from']) : strtotime('2000-01-01');
$to = isset($_POST['date']['to']) ? strtotime($_POST['date']['to']) : strtotime('tomorrow');
// disable caching
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// force download
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
// disposition / encoding on response body
header("Content-Disposition: attachment; filename=subscribers_" . date('dMy', $from) . "-" . date('dMy', $to) . ".csv");
header("Content-Transfer-Encoding: binary");
$file = fopen('php://output', 'w');
$head = array();
if ($name = isset($_POST['fields']['name'])) {
    $head[] = 'Name';
}
$head[] = 'Email';
fputcsv($file, array_values($head));
foreach (admin_query::while_subscribers(array('max' => 0, 'show' => isset($_POST['view']) ? urldecode($_POST['view']) : '', 'date' => "" . $from . ',' . $to . "")) as $subscriber) {
    $line = array();
    if ($name) {
        $line[] = $subscriber->user_name;
    }
    $line[] = $subscriber->email;
    fputcsv($file, $line);
}
fclose($file);