42 public function execute(&$controller, &$xoopsUser)
44 $filename = sprintf(
'%s_User_data_List.csv', $GLOBALS[
'xoopsConfig'][
'sitename']);
48 $user_handler =& $this->_getHandler();
50 $criteria->setSort(
'uid');
51 $users = $user_handler->getObjects($criteria);
52 if (!$users || 0 == (is_countable($users) ? count($users) : 0)) {
53 return USER_FRAME_VIEW_INDEX;
55 foreach ($users[0]->gets() as $key=>$var) {
56 $_f =
'_MD_USER_LANG_'.strtoupper($key);
57 $field_line .= (defined($_f) ? constant($_f) : $key) .
',';
61 foreach ($users as $u) {
63 foreach ($u->gets() as $key=>$value) {
67 $value = $value ? formatTimestamp($value,
'Y/n/j H:i') :
'';
71 if (preg_match(
'/[,"\r\n]/', $value)) {
72 $value = preg_replace(
'/"/',
'""', $value);
73 $value =
"\"$value\"";
75 $user_data .= $value .
',';
77 $text .= trim($user_data,
',').
"\n";
79 $text = $field_line.$text;
82 if (0 === strncasecmp($GLOBALS[
'xoopsConfig'][
'language'],
'ja', 2)) {
83 if (_CHARSET !==
'UTF-8') {
84 mb_convert_variables(
'UTF-8', _CHARSET, $text);
86 $text = pack(
'C*', 0xEF, 0xBB, 0xBF) . $text;
89 if (preg_match(
'/firefox/i', xoops_getenv(
'HTTP_USER_AGENT'))) {
90 header(
'Content-Type: application/x-csv');
92 header(
'Content-Type: application/vnd.ms-excel');
96 header(
"Content-Disposition: attachment ; filename=\"{$filename}\"") ;