[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2010 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 unset($export[$x]); // free memory 92 } 93 94 unset($export); // free memory 95 96 $filename = date('Y-m-d_H-i-s').'_formresultID-'.$fid.'.xls'; 97 98 if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { 99 // workaround for IE filename bug with multiple periods / multiple dots in filename 100 // that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe 101 $filename = preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1); 102 } 103 104 //header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 105 //header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 106 //header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 107 108 109 //header('Content-type: application/force-download'); 110 //header('Content-Disposition: attachment; filename="'.$filename.'"'); 111 //header('Content-Transfer-Encoding: binary'.LF); 112 113 echo '<table border="1" cellspacing="1" cellpadding="2">'.LF; 114 echo implode(LF, $elements); 115 echo LF.'</table>'; 116 flush(); 117 exit(); 118 119 } elseif($action == 'exportformresultdetail' && isset($_GET['fid']) && ($fid = intval($_GET['fid']))) { 120 121 $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); 122 123 if(!$data) die('Just a problem!'); 124 125 $export = array(); 126 $row = 1; 127 $export[0] = array('#ID'=>'','#Date'=>'','#IP'=>''); 128 129 // run all data first and combine array elements 130 foreach($data as $key => $value) { 131 132 // numbering starting at 1 133 $export[$row]['#ID'] = $value['formresult_id']; 134 $export[$row]['#Date'] = $value['formresult_createdate']; 135 $export[$row]['#IP'] = $value['formresult_ip']; 136 137 $val_array = @unserialize($value['formresult_content']); 138 if(is_array($val_array) && count($val_array)) { 139 foreach($val_array as $a_key => $a_value) { 140 $export[$row][$a_key] = $a_value; 141 $export[0][$a_key] = ''; 142 } 143 } 144 145 $row++; 146 } 147 148 149 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 150 header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 151 header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 152 153 $filename = date('Y-m-d_H-i-s').'_formresultdetailID-'.$fid.'.html'; 154 header('Content-type: text/html'); 155 header('Content-Disposition: attachment; filename="'.$filename.'"'); 156 157 echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'.LF; 158 echo '<html>'.LF; 159 echo '<head>'.LF; 160 echo ' <title>Formresult Detail Export ID'.$fid.'</title>'.LF; 161 echo ' <style type="text/css"> 162 <!-- 163 body {font-family:Arial,Helvetica,sans-serif;font-size:10pt;} 164 hr {margin:0;padding:0;height:1px;border:0;border-bottom:1px solid #666666;page-break-after:always;} 165 td {font-size: 10pt;} 166 // --> 167 </style>'.LF; 168 echo '</head>'.LF; 169 echo '<body>'.LF; 170 171 $elements = array(); 172 173 174 for($x = 1; $x < $row; $x++) { 175 176 echo '<p style="font-weight:bold">page '.$x.' of '.($row-1).'</p>'.LF; 177 echo '<table border="0" cellspacing="0" cellpadding="0" summary="ID:'.$fid.'">'.LF; 178 179 foreach($export[0] as $key => $value) { 180 181 echo '<tr>'.LF; 182 echo ' <td valign="top" style="padding:0 5px 0 0;"><strong>'.ucfirst($key).'</strong></td>'.LF; 183 echo ' <td valign="top" style="padding:0 0 3px 0;">'; 184 if(isset($export[$x][$key])) { 185 186 if(strpos($export[$x][$key], '/'.$phpwcms["content_path"].'form/')) { 187 188 $ext = which_ext($export[$x][$key]); 189 $export[$x][$key] = html_specialchars($export[$x][$key]); 190 if($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { 191 echo '<img src="'.$export[$x][$key].'" border="0" alt="" />'; 192 } else { 193 echo '<a href="'.$export[$x][$key].'">'.$export[$x][$key].'</a>'; 194 } 195 196 } else { 197 echo html_specialchars($export[$x][$key]); 198 } 199 200 } else { 201 202 echo ' '; 203 204 } 205 206 echo '</td>'.LF.'</tr>'.LF; 207 208 } 209 echo '</table>'.LF.'<hr />'.LF; 210 211 } 212 213 echo '</body>'.LF.'</html>'; 214 exit(); 215 216 217 } elseif($action == 'exportsubscriber') { 218 219 // export list of newsletter subscribers 220 $_userInfo = array(); 221 222 // default settings for listing selected users 223 $_userInfo['list_active'] = isset($_SESSION['list_active']) ? $_SESSION['list_active'] : 1; 224 $_userInfo['list_inactive'] = isset($_SESSION['list_inactive']) ? $_SESSION['list_inactive'] : 1; 225 226 $_userInfo['where_query'] = ''; 227 228 if($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_active']) { 229 $_userInfo['where_query'] = ' WHERE address_verified=1'; 230 } elseif($_userInfo['list_active'] != $_userInfo['list_inactive'] && $_userInfo['list_inactive']) { 231 $_userInfo['where_query'] = ' WHERE address_verified=0'; 232 } 233 234 if(isset($_SESSION['filter_subscriber']) && count($_SESSION['filter_subscriber'])) { 235 236 $_userInfo['filter_array'] = array(); 237 238 foreach($_SESSION['filter_subscriber'] as $_userInfo['filter']) { 239 //usr_name, usr_login, usr_email 240 $_userInfo['filter_array'][] = "CONCAT(address_email, address_name) LIKE '%".aporeplace($_userInfo['filter'])."%'"; 241 } 242 if(count($_userInfo['filter_array'])) { 243 244 $_userInfo['where_query'] .= $_userInfo['where_query'] ? ' AND ' : ' WHERE '; 245 $_userInfo['where_query'] .= '('.implode('OR', $_userInfo['filter_array']).')'; 246 247 } 248 249 } 250 251 // get all subscribers from db 252 $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'); 253 if($data) { 254 255 // send header data 256 $filename = date('Y-m-d_H-i-s').'_newsletterRecipients.xls'; 257 258 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 259 header('Last-Modified: '.gmdate('D, d M Y H:i:s GMT', time()) ); 260 header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0'); 261 262 header('Content-type: application/vnd-ms-excel'); 263 header('Content-Disposition: attachment; filename="'.$filename.'"'); 264 265 echo '<table border="1" cellspacing="1" cellpadding="2">'.LF; 266 267 // 1st row - column names 268 echo '<tr>'.LF; 269 270 echo '<th>verified</th>'.LF; 271 echo '<th>email</th>'.LF; 272 echo '<th>name</th>'.LF; 273 echo '<th>last change</th>'.LF; 274 echo '<th>all</th>'.LF; 275 276 // now check subscriptions 277 $_userInfo['subscriptions'] = _dbQuery("SELECT * FROM ".DB_PREPEND."phpwcms_subscription ORDER BY subscription_name"); 278 279 $_userInfo['channel'] = array(); 280 281 if($_userInfo['subscriptions']) { 282 283 $x = 0; 284 foreach($_userInfo['subscriptions'] as $value) { 285 286 // echo channel column name 287 echo '<th>'.html_specialchars($value['subscription_name']).'</th>'.LF; 288 $_userInfo['channel'][$x] = $value['subscription_id']; 289 $x++; 290 291 } 292 293 } 294 295 echo '</tr>'.LF; 296 297 $_userInfo['count'] = count($_userInfo['channel']); 298 299 foreach($data as $value) { 300 301 // make check if all szubscriptions or special 302 if($value['address_subscription']) { 303 304 $value['all'] = ''; 305 306 $value['address_subscription'] = unserialize($value['address_subscription']); 307 if(in_array(0, $value['address_subscription'])) $value['all'] = 'X'; 308 309 } else { 310 311 $value['all'] = 'X'; 312 313 } 314 315 316 echo '<tr>'.LF; 317 echo '<td align="center">'.($value['address_verified'] ? 'X' : '').'</td>'.LF; 318 echo '<td>'.html_specialchars($value['address_email']).'</td>'.LF; 319 echo '<td>'.html_specialchars($value['address_name']).'</td>'.LF; 320 echo '<td>'.html_specialchars($value['addate']).'</td>'.LF; 321 echo '<td align="center">'.$value['all'].'</td>'.LF; 322 323 // custom subscriptions 324 if($_userInfo['count']) { 325 326 if($value['all'] === '') { 327 328 for($x=0; $x < $_userInfo['count']; $x++) { 329 330 echo '<td align="center">'; 331 echo in_array($_userInfo['channel'][$x], $value['address_subscription']) ? 'X' : ''; 332 echo '</td>'.LF; 333 334 } 335 336 337 } else { 338 339 echo str_repeat('<td></td>'.LF, $_userInfo['count']); 340 341 } 342 343 } 344 345 echo '</tr>'.LF; 346 347 } 348 349 echo '</table>'; 350 351 } 352 exit(); 353 354 355 } else { 356 357 die('Just a problem!'); 358 359 } 360 361 362 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |