참고는 이쪽 : http://www.xpressengine.com/19585441

 

한글 / 확장변수 수정된 버전임..

관리자가 아닐경우 아무 반응 없도록 함..

 

<?
define('__ZBXE__',true);
require_once("../../config/config.inc.php");
$oContext = &Context::getInstance();
$oContext->init();
 
$logged_info = Context::get('logged_info');
$isadmin = $logged_info->is_admin;
 
if($isadmin)
{
    $connect_host        = "localhost";
    $connect_id        = "디비아이디";
    $connect_pass        = "패스워드";
    $connect_db        = "디비이르ㅁ";
    $connect_table        = "xe_member";
    $xls_filename        = "memberlist.xls";
 
    $connect=@mysql_connect($connect_host,$connect_id,$connect_pass);
    @mysql_query("set character set utf8");
    $mysql=@mysql_select_db($connect_db,$connect);
}
else
{
    @mysql_close($connect);
    die();
}
header("Content-Type: application/vnd.ms-excel"); 
header("Content-Disposition: attachment; filename=$xls_filename"); 
?> 
 
<html> 
  <head> 
    <meta http-equiv=Content-Type content="text/html; charset=UTF-8" />
  </head> 
  <body> 
    <table border=1>
    <tr align=center>
<?
  $fields = mysql_list_fields("$connect_db", "$connect_table");
  $columns = mysql_num_fields($fields);
 
  for ($i = 0; $i < $columns; $i++) {
    $field[$i]=mysql_field_name($fields, $i);
    if($field[$i]=='extra_vars')
    {
    echo "<th>확장변수1</th>";
    echo "<th>확장변수2</th>";
    echo "<th>확장변수3</th>";
    echo "<th>확장변수4</th>";
    echo "<th>확장변수5</th>";
    echo "<th>확장변수6</th>";
    echo "<th>확장변수7</th>";
    }
    else echo "<th>".$field[$i]. "</th>";
  }
?>
    </tr>
 
<?
  $result=mysql_query("select * from $connect_table");
  while($data=mysql_fetch_assoc($result)){
    echo"<tr>";
 
    for ($i = 0; $i < sizeof($field); $i++) {
    if($i==3) echo "<td></td>";
    elseif($i==15) {
        $dstr=date("Y-m-d", ztime($data["$field[$i]"]));
        echo "<td>".$dstr."</td>";
    } elseif($i==16) {
        $dstr=date("Y-m-d", ztime($data["$field[$i]"]));
        echo "<td>".$dstr."</td>";
    } elseif($i==19) {
        $ser = unserialize($data["$field[$i]"]);
        echo "<td>".$ser->확장변수1."</td>";
        echo "<td>".$ser->확장변수2."</td>";
        echo "<td>".$ser->확장변수3."</td>";
        echo "<td>".$ser->확장변수4."</td>";
        echo "<td>".$ser->확장변수5."</td>";
        echo "<td>".$ser->확장변수6."</td>";
        echo "<td>".$ser->확장변수7."</td>";
 
    } elseif($i==20) {
        $dstr=date("Y-m-d", ztime($data["$field[$i]"]));
        echo "<td>".$dstr."</td>";
    } else echo "<td>".$data["$field[$i]"]."</td>";
    }
 
  echo"</tr>";
}
?>
    </table>
  </body> 
</html> 
신고

+ Recent posts