[ Index ] |
PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 *************************************************************************************/ 22 23 24 session_start(); 25 $phpwcms = array(); 26 require_once ('../../config/phpwcms/conf.inc.php'); 27 require_once ('../inc_lib/default.inc.php'); 28 require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php'); 29 30 require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php'); 31 checkLogin(); 32 require_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php'); 33 34 35 $action = isset($_GET['action']) ? $_GET['action'] : ''; 36 37 // export form results 38 if($action == 'exportformresult' && isset($_GET['fid']) && ($fid = intval($_GET['fid']))) { 39 40 $data = _dbQuery("SELECT *, DATE_FORMAT(formresult_createdate, '%Y-%m-%d %H:%i:%s') AS formresult_date FROM ".DB_PREPEND.'phpwcms_formresult WHERE formresult_pid='.$fid); 41 42 if(!$data) die('Just a problem!'); 43 44 $export = array(); 45 $row = 1; 46 $export[0] = array('#'=>'','#ID'=>'','#Date'=>'','#IP'=>''); 47 48 // run all data first and combine array elements 49 foreach($data as $key => $value) { 50 51 // numbering starting at 1 52 $export[$row]['#'] = $row; 53 $export[$row]['#ID'] = $value['formresult_id']; 54 $export[$row]['#Date'] = $value['formresult_createdate']; 55 $export[$row]['#IP'] = $value['formresult_ip']; 56 57 $val_array = @unserialize($value['formresult_content']); 58 if(is_array($val_array) && count($val_array)) { 59 foreach($val_array as $a_key => $a_value) { 60 $export[$row][$a_key] = $a_value; 61 $export[0][$a_key] = ''; 62 } 63 } 64 65 $row++; 66 } 67 68 $elements = array(); 69 70 $elements[0] = ' <tr>'.LF; 71 foreach($export[0] as $key => $value) { 72 $elements[0] .= ' <th>'; 73 $elements[0] .= $key; 74 $elements[0] .= '</th>'.LF; 75 } 76 $elements[0] .= ' </tr>'; 77 78 79 for($x = 1; $x < $row; $x++) { 80 81 $elements[$x] = ' <tr>'.LF; 82 foreach($export[0] as $key => $value) { 83 84 $elements[$x] .= ' <td>'; 85 $elements[$x] .= isset($export[$x][$key]) ? html_specialchars($export[$x][$key]) : ''; 86 $elements[$x] .= '</td>'.LF; 87 88 } 89 $elements[$x] .= ' </tr>'; 90 91 92 } 93 94 $filename = date('Y-m-d_H-i-s').'_formresultID-'.$fid.'.xls'; 95 96 if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { 97 // workaround for IE filename bug with multiple periods / multiple dots in filename 98 // that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe 99 $filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1); 100 } 101 102 //header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 103 //header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 104 //header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 105 106 107 //header('Content-type: application/force-download'); 108 //header('Content-Disposition: attachment; filename="'.$filename.'"'); 109 //header('Content-Transfer-Encoding: binary'.LF); 110 111 echo '<table border="1" cellspacing="1" cellpadding="2">'.LF; 112 echo implode(LF, $elements); 113 echo LF.'</table>'; 114 flush(); 115 exit(); 116 117 } elseif($action == 'exportformresultdetail' && isset($_GET['fid']) && ($fid = intval($_GET['fid']))) { 118 119 $data = _getDatabaseQueryResult("SELECT *, DATE_FORMAT(formresult_createdate, '%Y-%m-%d %H:%i:%S') AS formresult_date FROM ".DB_PREPEND.'phpwcms_formresult WHERE formresult_pid='.$fid); 120 121 if(!$data) die('Just a problem!'); 122 123 $export = array(); 124 $row = 1; 125 $export[0] = array('#ID'=>'','#Date'=>'','#IP'=>''); 126 127 // run all data first and combine array elements 128 foreach($data as $key => $value) { 129 130 // numbering starting at 1 131 $export[$row]['#ID'] = $value['formresult_id']; 132 $export[$row]['#Date'] = $value['formresult_createdate']; 133 $export[$row]['#IP'] = $value['formresult_ip']; 134 135 $val_array = @unserialize($value['formresult_content']); 136 if(is_array($val_array) && count($val_array)) { 137 foreach($val_array as $a_key => $a_value) { 138 $export[$row][$a_key] = $a_value; 139 $export[0][$a_key] = ''; 140 } 141 } 142 143 $row++; 144 } 145 146 147 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 148 header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 149 header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 150 151 $filename = date('Y-m-d_H-i-s').'_formresultdetailID-'.$fid.'.html'; 152 header('Content-type: text/html'); 153 header('Content-Disposition: attachment; filename="'.$filename.'"'); 154 155 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'.LF; 156 echo '<html>'.LF; 157 echo '<head>'.LF; 158 echo ' <title>Formresult Detail Export ID'.$fid.'</title>'.LF; 159 echo ' <style type="text/css"> 160 <!-- 161 body {font-family:Arial,Helvetica,sans-serif;font-size:10pt;} 162 hr {margin:0;padding:0;height:1px;border:0;border-bottom:1px solid #666666;page-break-after:always;} 163 td {font-size: 10pt;} 164 //--> 165 </style>'.LF; 166 echo '</head>'.LF; 167 echo '<body>'.LF; 168 169 $elements = array(); 170 171 172 for($x = 1; $x < $row; $x++) { 173 174 echo '<p style="font-weight:bold">page '.$x.' of '.($row-1).'</p>'.LF; 175 echo '<table border="0" cellspacing="0" cellpadding="0" summary="ID:'.$fid.'">'.LF; 176 177 foreach($export[0] as $key => $value) { 178 179 echo '<tr>'.LF; 180 echo ' <td valign="top" style="padding:0 5px 0 0;"><strong>'.ucfirst($key).'</strong></td>'.LF; 181 echo ' <td valign="top" style="padding:0 0 3px 0;">'; 182 if(isset($export[$x][$key])) { 183 184 if(strpos($export[$x][$key], '/'.$phpwcms["content_path"].'form/')) { 185 186 $ext = which_ext($export[$x][$key]); 187 $export[$x][$key] = html_specialchars($export[$x][$key]); 188 if($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { 189 echo '<img src="'.$export[$x][$key].'" border="0" alt="" />'; 190 } else { 191 echo '<a href="'.$export[$x][$key].'">'.$export[$x][$key].'</a>'; 192 } 193 194 } else { 195 echo html_specialchars($export[$x][$key]); 196 } 197 198 } else { 199 200 echo ' '; 201 202 } 203 204 echo '</td>'.LF.'</tr>'.LF; 205 206 } 207 echo '</table>'.LF.'<hr />'.LF; 208 209 } 210 211 echo '</body>'.LF.'</html>'; 212 exit(); 213 214 215 } elseif($action == 'exportsubscriber') { 216 217 // export list of newsletter subscribers 218 $_userInfo = array(); 219 220 // default settings for listing selected users 221 $_userInfo['list_active'] = isset($_SESSION['list_active']) ? $_SESSION['list_active'] : 1; 222 $_userInfo['list_inactive'] = isset($_SESSION['list_inactive']) ? $_SESSION['list_inactive'] : 1; 223 224 $_userInfo['where_query'] = ''; 225 226 if($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_active']) { 227 $_userInfo['where_query'] = ' WHERE address_verified=1'; 228 } elseif($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_inactive']) { 229 $_userInfo['where_query'] = ' WHERE address_verified=0'; 230 } 231 232 if(isset($_SESSION['filter_subscriber']) && count($_SESSION['filter_subscriber'])) { 233 234 $_userInfo['filter_array'] = array(); 235 236 foreach($_SESSION['filter_subscriber'] as $_userInfo['filter']) { 237 //usr_name, usr_login, usr_email 238 $_userInfo['filter_array'][] = "CONCAT(address_email, address_name) LIKE '%".aporeplace($_userInfo['filter'])."%'"; 239 } 240 if(count($_userInfo['filter_array'])) { 241 242 $_userInfo['where_query'] .= $_userInfo['where_query'] ? ' AND ' : ' WHERE '; 243 $_userInfo['where_query'] .= '('.implode('OR', $_userInfo['filter_array']).')'; 244 245 } 246 247 } 248 249 // get all subscribers from db 250 $data = _dbQuery("SELECT *, DATE_FORMAT(address_tstamp, '%Y-%m-%d %H:%i:%s') AS addate FROM ".DB_PREPEND."phpwcms_address".$_userInfo['where_query'].' ORDER BY address_tstamp'); 251 if($data) { 252 253 // send header data 254 $filename = date('Y-m-d_H-i-s').'_newsletterRecipients.xls'; 255 256 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 257 header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 258 header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 259 260 header('Content-type: application/vnd-ms-excel'); 261 header('Content-Disposition: attachment; filename="'.$filename.'"'); 262 263 echo '<table border="1" cellspacing="1" cellpadding="2">'.LF; 264 265 // 1st row - column names 266 echo '<tr>'.LF; 267 268 echo '<th>verified</th>'.LF; 269 echo '<th>email</th>'.LF; 270 echo '<th>name</th>'.LF; 271 echo '<th>last change</th>'.LF; 272 echo '<th>all</th>'.LF; 273 274 // now check subscriptions 275 $_userInfo['subscriptions'] = _dbQuery("SELECT * FROM ".DB_PREPEND."phpwcms_subscription ORDER BY subscription_name"); 276 277 $_userInfo['channel'] = array(); 278 279 if($_userInfo['subscriptions']) { 280 281 $x = 0; 282 foreach($_userInfo['subscriptions'] as $value) { 283 284 // echo channel column name 285 echo '<th>'.html_specialchars($value['subscription_name']).'</th>'.LF; 286 $_userInfo['channel'][$x] = $value['subscription_id']; 287 $x++; 288 289 } 290 291 } 292 293 echo '</tr>'.LF; 294 295 $_userInfo['count'] = count($_userInfo['channel']); 296 297 foreach($data as $value) { 298 299 // make check if all szubscriptions or special 300 if($value['address_subscription']) { 301 302 $value['all'] = ''; 303 304 $value['address_subscription'] = unserialize($value['address_subscription']); 305 if(in_array(0, $value['address_subscription'])) $value['all'] = 'X'; 306 307 } else { 308 309 $value['all'] = 'X'; 310 311 } 312 313 314 echo '<tr>'.LF; 315 echo '<td align="center">'.($value['address_verified'] ? 'X' : '').'</td>'.LF; 316 echo '<td>'.html_specialchars($value['address_email']).'</td>'.LF; 317 echo '<td>'.html_specialchars($value['address_name']).'</td>'.LF; 318 echo '<td>'.html_specialchars($value['addate']).'</td>'.LF; 319 echo '<td align="center">'.$value['all'].'</td>'.LF; 320 321 // custom subscriptions 322 if($_userInfo['count']) { 323 324 if($value['all'] === '') { 325 326 for($x=0; $x < $_userInfo['count']; $x++) { 327 328 echo '<td align="center">'; 329 echo in_array($_userInfo['channel'][$x], $value['address_subscription']) ? 'X' : ''; 330 echo '</td>'.LF; 331 332 } 333 334 335 } else { 336 337 echo str_repeat('<td></td>'.LF, $_userInfo['count']); 338 339 } 340 341 } 342 343 echo '</tr>'.LF; 344 345 } 346 347 echo '</table>'; 348 349 } 350 exit(); 351 352 353 } else { 354 355 die('Just a problem!'); 356 357 } 358 359 360 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 30 05:55:15 2009 | Cross-referenced by PHPXref 0.7 |