|
- <?php
- error_reporting(0);
- define('P_W',1);
- define('PW_UPLOAD',1);
- define('R_P',getdirname(__FILE__));
- define('D_P',R_P);
- require_once(R_P.'require/common.php');
- include_once(D_P.'data/bbscache/config.php');
- $basename = 'http://'.$_SERVER['HTTP_HOST'].(isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
- @header("Content-Type:text/html; charset=$db_charset");
- include_once(D_P.'data/sql_config.php');
- //if ($database=='mysqli' && Pwloaddl('mysqli')===false) {
- $database = 'mysql';
- require_once Pcv(R_P."require/db_$database.php");
- $db = new DB($dbhost,$dbuser,$dbpw,$dbname,$PW,$charset,$pconnect);
- $action = $_GET['action'];
- if (empty($action)) {
- echo '<a href="'.$basename.'?action=step1">开始导出会员</a>';exit;
- } elseif ($action == 'step1') {
- $words = '';
- $sql = "SELECT username,email FROM pw_members";
- $query = $db->query($sql);
- while($rt = $db->fetch_array($query)){
- //$rt['username'] = iconv("UTF-8","GB2312//IGNORE",$rt['username']);
- $words .= $rt['username']." ".$rt['email']."\r\n";
- }
- //echo $words;exit;
- header('Last-Modified: '.gmdate('D, d M Y H:i:s',$timestamp+86400).' GMT');
- header('Cache-control: no-cache');
- header('Content-Encoding: none');
- header('Content-Disposition: attachment; filename="会员邮件.doc"');
- header('Content-type: txt');
- header('Content-Length: '.strlen($words));
- echo $words;exit;
- }
- echo '添加完毕,一共添加了'.$num.'个会员';exit;
- function getdirname($path=null){
- if (!empty($path)) {
- if (strpos($path,'\\')!==false) {
- return substr($path,0,strrpos($path,'\\')).'/';
- } elseif (strpos($path,'/')!==false) {
- return substr($path,0,strrpos($path,'/')).'/';
- }
- }
- return './';
- }
- function createtable($array){
- global $db,$charset;
- foreach ($array as $key => $value) {
- !$value[1] && $value[1] = 'MyISAM';
- $value[0] = "CREATE TABLE IF NOT EXISTS $key ($value[0]) ";
- if ($db->server_info() > '4.1') {
- $value[0] .= "ENGINE=$value[1]".($charset ? " DEFAULT CHARSET=$charset" : '');
- } else {
- $value[0] .= "TYPE=$value[1]";
- }
- $db->query($value[0]);
- }
- }
- ?>
|