public function exportExcel($headArr, $data, $fileName = 'info') { import('@.ORG.XmlExcel'); $xls = new XmlExcel(); $xls->setDefaultWidth(180); $xls->setDefaultAlign("left"); $xls->setDefaultHeight(18); $xls->addHead($headArr); foreach ($data as $k => $v) { $xls->addRow($v); } $xls->export($fileName); }
public function download_excel() { $this->verify_content_prms(array('_action' => 'show_result')); $feedback_id = $this->input['fid']; if (!$feedback_id) { $this->errorOutput(NO_FEEDBACK_ID); } $person = array(); $condition = $this->get_condition(); $sql = "SELECT * FROM " . DB_PREFIX . "record_person rp WHERE rp.feedback_id IN(" . $feedback_id . ")" . $condition; $person = $this->db->fetch_all($sql); if ($person && count($person) > 0) { foreach ($person as $k => $v) { $fid[] = $v['id']; } $fids = implode(',', $fid); } if ($fids) { $forms = $this->mode->get_forms($feedback_id); if ($forms && is_array($forms)) { foreach ($forms as $k => $v) { $form_name[$v['type']][$v['id']] = $v['name']; } } $form_ids = array(); $sql = 'SELECT * FROM ' . DB_PREFIX . 'materials WHERE content_id = ' . $feedback_id; $q = $this->db->query($sql); while ($rs = $this->db->fetch_array($q)) { if ($rs['vodid']) { if ($this->settings['App_mediaserver']) { $rs['url'] = $this->settings['App_mediaserver']['protocol'] . $this->settings['App_mediaserver']['host'] . '/' . $this->settings['App_mediaserver']['dir'] . '/admin/download.php?id=' . $rs['vodid']; } else { $rs['url'] = $rs['host'] . '/' . $rs['dir'] . $rs['filename'] . '.mp4'; } } if ($rs['original_id']) { $rs['url'] = hg_material_link($rs['host'], $rs['dir'], $rs['material_path'], $rs['pic_name']); } $mat[$rs['id']] = $rs['url']; } $sql = "SELECT r.*,f.title,f.brief FROM " . DB_PREFIX . "record r LEFT JOIN " . DB_PREFIX . "feedback f ON r.feedback_id = f.id WHERE r.person_id in( " . $fids . ") ORDER BY r.order_id desc"; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { $rec['title'] = $r['title']; $rec['brief'] = $r['brief']; if ($r['type'] == 'file') { $r['type'] = 'standard'; $fvalue = trim($r['value'], ','); if ($fvalue) { $file_value = array(); $mat_ids = explode(',', $fvalue); foreach ($mat_ids as $k => $vm) { if ($vm) { $mat_id = @explode('_', $vm); $file_value[] = $mat[$mat_id[0]]; } } $r['value'] = implode(", ", $file_value); } } $formname = $r['form_name'] ? $r['form_name'] : ($form_name[$r['type']][$r['form_id']] ? $form_name[$r['type']][$r['form_id']] : '组件' . $r['form_id']); $rec['names'][$r['type'] . '_' . $r['form_id']] = $formname; $rec['data'][$r['person_id']][$r['type'] . '_' . $r['form_id']] = $r['value']; } $rec['names']['user_name'] = '用户昵称'; $rec['names']['create_time'] = '填写时间'; $rec['names']['process'] = '是否处理'; $rec['names']['device_token'] = '设备号'; if (is_array($person) && count($person) > 0) { foreach ($person as $k => $v) { $rec['data'][$v['id']]['user_name'] = $v['user_name'] ? $v['user_name'] : '未登录'; $rec['data'][$v['id']]['create_time'] = $v['create_time'] ? date('Y-m-d H:i:s', $v['create_time']) : ''; $rec['data'][$v['id']]['process'] = $v['process'] ? '已处理' : '未处理'; $rec['data'][$v['id']]['device_token'] = $v['device_token'] ? $v['device_token'] : ''; } } } if (!$rec) { $this->errorOutput(NO_CONTENT); } include_once CUR_CONF_PATH . 'lib/XmlExcel.php'; $xls = new XmlExcel(); $xls->setDefaultWidth(80); $xls->setDefaultAlign("center"); $xls->setDefaultHeight(18); $xls->addTitle($rec['title'], $rec['title']); $xls->addHead($rec['names'], $rec['title']); if (is_array($rec['data']) && count($rec['data']) > 0) { foreach ($rec['data'] as $k => $value) { foreach ($rec['names'] as $key => $rs) { $mac[$k][] = $value[$key]; } $xls->addRow($mac[$k], $rec['title']); } } $xls->export($rec['title']); exit; }
function export() { global $db; require LDINC . '/XmlExcel.php'; $title1 = array('URL', 'User', 'Status', '节点IP', 'High', 'Middle', 'Low', 'Banner', 'OS', 'Finishtime'); $title2 = array('Id', 'Type', 'Level', 'Webpath', 'Param', 'details', 'Request'); if (!empty($_GET['hash'])) { $hash = $_GET['hash']; $xls = new XmlExcel(); $xls->setDefaultWidth(80); $xls->setDefaultAlign("center"); $xls->setDefaultHeight(30); $xls->addHead($title1, 'info'); $sql = "SELECT a.url,a.user,a.pointserver,b.finishtime,b.banner,b.os,b.responsive FROM scan_list as a,target_info as b where a.hash = b.hash and a.hash = '{$hash}'"; $results = $db->fetch_assoc($sql); $url = $results['url']; $user = $results['user']; $pointserver = $results['pointserver']; $finishtime = $results['finishtime']; $banner = $results['banner']; $os = $results['os']; $status = $results['responsive']; $high = get_severity($hash, 'high'); $middle = get_severity($hash, 'middle'); $low = get_severity($hash, 'low'); $data_arr = array($url, $user, $status, $pointserver, $high, $middle, $low, $banner, $os, $finishtime); $xls->addRow($data_arr, 'info'); $xls->addHead($title2, 'vulnerability'); $sql = "SELECT * FROM target_vul where hash='{$hash}' order by Severity"; $results = $db->query($sql); if (mysql_num_rows($results) > 0) { $i = 1; while ($fs = $db->fetch_array($results)) { $id = $i; $Name = $fs["name"]; $Affects = $fs["affects"]; $Parameter = $fs["parameter"]; $Severity = $fs["severity"]; $details = $fs["details"]; $Request = str_replace("\r\n", ' ', urldecode($fs["request"])); //$Response = str_replace("\r\n",' ',urldecode($fs["response"])); if (strtolower($Severity) == 'high') { $class = 'error'; } else { if (strtolower($Severity) == 'middle') { $class = 'warning'; } else { if (strtolower($Severity) == 'low' or strtolower($Severity) == 'info') { $class = 'info'; } } } if ($Parameter == 'Array') { $Parameter = ''; } if ($Request == 'Array') { $Request = ''; } /* if ($Response == 'Array'){ $Response = ''; } */ $vul_arr = array($id, $Name, $Severity, $Affects, $Parameter, $details, $Request); $xls->addRow($vul_arr, 'vulnerability'); } } $xls->export($hash); } }