Changeset 933680
- Timestamp:
- 06/17/2014 01:09:29 PM (12 years ago)
- Location:
- wpnewsman-newsletters/trunk
- Files:
-
- 11 edited
-
api.php (modified) (7 diffs)
-
class.analytics.php (modified) (1 diff)
-
class.emails.php (modified) (3 diffs)
-
class.list.php (modified) (6 diffs)
-
class.utils.php (modified) (1 diff)
-
core.php (modified) (6 diffs)
-
js/jquery.placeholder.js (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
views/welcome.php (modified) (1 diff)
-
workers/class.mailer.php (modified) (2 diffs)
-
wpnewsman.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpnewsman-newsletters/trunk/api.php
r929655 r933680 13 13 $loc = "UTF-8"; 14 14 putenv("LANG=$loc"); 15 15 16 $loc = setlocale(LC_ALL, $loc); 16 17 17 if ( function_exists('ob_gzhandler') ) { 18 function ob_gz_handler_no_errors($buffer) 19 { 20 @ob_gzhandler($buffer); 21 } 22 ob_start('ob_gzhandler'); 23 } 18 // UNCOMMENT IN PRODUCTION 19 20 // if ( function_exists('ob_gzhandler') ) { 21 // function ob_gz_handler_no_errors($buffer) 22 // { 23 // ob_gzhandler($buffer); 24 // } 25 // ob_start('ob_gzhandler'); 26 // } 24 27 25 28 $o = newsmanOptions::getInstance(); … … 43 46 } 44 47 45 call_user_ method($method, $this);48 call_user_func(array($this, $method)); 46 49 } 47 50 … … 65 68 66 69 header("Content-type: application/json"); 70 71 //ob_end_clean(); 67 72 68 73 echo json_encode( $u->utf8_encode_all($msg) ); 74 75 //ob_flush(); 69 76 70 77 if ($db) $db->close(); … … 149 156 150 157 public function ajGetLists() { 158 global $newsman_current_subscriber; 159 global $newsman_current_list; 160 161 $newsman_current_subscriber = array( 'ucode' => '' ); 162 151 163 $r = array(); 152 164 153 $lists = newsmanList::findALL(); 165 $n = newsman::getInstance(); 166 167 $lists = newsmanList::findALL(); 154 168 155 169 foreach ($lists as $list) { 170 $newsman_current_list = $list; 156 171 $r[] = array( 157 172 'id' => $list->id, 158 173 'uid' => $list->uid, 159 'name' => $list->name 174 'name' => $list->name, 175 'confirmed' => $list->countSubs(NEWSMAN_SS_CONFIRMED), 176 'unsubscribeURL' => $n->getActionLink('unsubscribe', false, false, 'DROP_EMAIL_IDENTIFIER') 160 177 ); 161 178 } 162 179 163 180 $this->respond(true, $r); 181 } 182 183 private function buildExtraQuery() { 184 global $wpdb; 185 186 $validTimeUnits = array('MICROSECOND', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR'); 187 188 $extraQuery = array(); 189 190 $timeInList = $this->param('timeInList', false); 191 if ( $timeInList ) { 192 $til = explode(',', $timeInList); 193 $tilNum = intval($til[0]); 194 $tilUnit = isset($til[1]) ? strtoupper($til[1]) : 'DAY'; 195 if ( in_array($tilUnit, $validTimeUnits) ) { 196 // no need to use wpdb->prepare here becuase all vars are checked 197 $extraQuery[] = "TIMESTAMPDIFF($tilUnit, NOW(), ts) >= $tilNum"; 198 } 199 } 200 201 //view-source:blog.dev/wp-content/plugins/wpnewsman/api.php?method=downloadList&key=575d037167f77f3b1c01c7fff7b9d31282009867&listId=18 202 203 $emailIn = $this->param('emailIn', false); 204 205 if ( $emailIn ) { 206 $args = explode(',', $emailIn); 207 $placeholders = array(); 208 foreach ($args as $email) { 209 $placeholders[] = '%s'; 210 } 211 212 $set = 'email in ('.implode(',', $placeholders).')'; // (%s, %s, ...) 213 214 array_unshift($args, $set); // placeing set SQL part before the emails 215 216 $set = call_user_func_array(array($wpdb, 'prepare'), $args); 217 $extraQuery[] = $set; 218 } 219 220 if ( !empty($extraQuery) ) { 221 define('newsman_csv_export_query', implode(' AND ', $extraQuery)); 222 } 223 $u = newsmanUtils::getInstance(); 224 $u->log('[buildExtraQuery] %s', newsman_csv_export_query); 164 225 } 165 226 … … 169 230 $limit = $this->param('limit', false); 170 231 $offset = $this->param('offset', false); 232 $map = $this->param('map', ''); 233 234 $nofile = $this->param('nofile', false); 235 236 if ( is_string($nofile) ) { 237 $nofile = ( $nofile === '1' || strtolower($nofile) == 'true' ); 238 } 239 240 global $newsman_export_fields_map; 241 242 if ( $map ) { 243 $map = explode(',', $map); 244 $newsman_export_fields_map = array(); 245 foreach ($map as $pair) { 246 $p = explode(':', $pair); 247 $newsman_export_fields_map[ $p[0] ] = $p[1]; 248 } 249 } 171 250 172 251 if ( $limit ) { … … 177 256 define('newsman_csv_export_offset', $offset); 178 257 } 258 259 $this->buildExtraQuery(); 179 260 180 261 $list = newsmanList::findOne('id = %d', array($listId)); … … 204 285 // 'confirmation-link', 'resend-confirmation-link', 'unsubscribe-link' 205 286 206 $list->exportToCSV($fileName, 'all', $linkTypes); 287 $list->exportToCSV($fileName, 'all', $linkTypes, !$nofile); 288 } 289 290 public function ajGetListFields() { 291 $listId = $this->param('listId'); 292 293 $list = newsmanList::findOne('id = %d', array($listId)); 294 295 if ( !$list ) { 296 $this->respond(false, sprintf( __( 'List with id "%s" is not found.', NEWSMAN), $listId), array(), '404 Not found'); 297 } 298 299 $fields = $list->getAllFields(); 300 301 $this->respond(true, array( 302 'fields' => $fields 303 )); 207 304 } 208 305 } -
wpnewsman-newsletters/trunk/class.analytics.php
r929655 r933680 48 48 // /c/{emailId}/{listId}/{subId}/{linkId} 49 49 // http://blog.dev/c/3d-a-oo-go 50 if ( preg_match('# ^\/(o|c)\/((?:[a-z0-9]+\-){2,3}(?:[a-z0-9]+))#', strtolower($_SERVER['REQUEST_URI']), $matches ) ) {50 if ( preg_match('#\/(o|c)\/((?:[a-z0-9]+\-){2,3}(?:[a-z0-9]+))#', strtolower($_SERVER['REQUEST_URI']), $matches ) ) { 51 51 $op = $matches[1]; 52 52 $args = $this->decodeIdsArray(explode('-', $matches[2])); -
wpnewsman-newsletters/trunk/class.emails.php
r930191 r933680 63 63 $this->embedStyles(); 64 64 $this->addAnalytics(); 65 65 66 66 67 return parent::save(); … … 169 170 $url = $matches[3]; 170 171 172 $u = newsmanUtils::getInstance(); 173 $u->log('wrapping URL: %s', $url); 174 171 175 // if not unsubscribe or "view online" link 172 176 if ( strpos($url, 'newsman=unsubscribe') === false && … … 193 197 base_convert($link->id, 10, 36) 194 198 ); 199 $u->log('wrapped: %s', $url); 195 200 } 196 201 -
wpnewsman-newsletters/trunk/class.list.php
r929655 r933680 168 168 } 169 169 170 171 public function countSubs($stat) { 172 global $wpdb; 173 174 $u = newsmanUtils::getInstance(); 175 $sql = "SELECT COUNT(id) as cnt FROM $this->tblSubscribers WHERE status = %d"; 176 return intval($wpdb->get_var($wpdb->prepare($sql, $stat)));; 177 } 178 170 179 public function setStatus($ids, $status) { 171 180 global $wpdb; … … 343 352 } 344 353 345 public function getSubscribers($offset = 0, $limit = 100, $type = 'all', $q = false ) {354 public function getSubscribers($offset = 0, $limit = 100, $type = 'all', $q = false, $rawQuery = false) { 346 355 global $wpdb; 347 356 … … 371 380 372 381 if ( $q ) { 373 $word = empty($sel) ? ' WHERE' : ' AND'; 374 $sel .= $word.' email regexp %s'; 375 $sel = $wpdb->prepare($sel, $u->preg_quote($q)); 376 } 382 if ( $rawQuery ) { 383 $word = empty($sel) ? ' WHERE' : ' AND'; 384 $sel .= $word.' '.$q; 385 } else { 386 $word = empty($sel) ? ' WHERE' : ' AND'; 387 $sel .= $word.' email regexp %s'; 388 $sel = $wpdb->prepare($sel, $u->preg_quote($q)); 389 } 390 } 377 391 378 392 $sql = "SELECT * FROM $this->tblSubscribers ".$sel." ORDER BY `ts` DESC LIMIT %d, %d"; 393 379 394 $sql = $wpdb->prepare($sql, $offset, $limit); 380 395 … … 601 616 private function subsToCSV($file, $fields, $type = 'all') { 602 617 603 if ( defined('newsman_csv_export_limit') || defined('newsman_csv_export_offset') ) { 618 if ( 619 defined('newsman_csv_export_limit') || 620 defined('newsman_csv_export_offset') || 621 defined('newsman_csv_export_query') 622 ) { 604 623 $offset = defined('newsman_csv_export_offset') ? newsman_csv_export_offset : 0; 605 624 $limit = defined('newsman_csv_export_limit') ? newsman_csv_export_limit : 100; 606 607 $res = $this->getSubscribers($offset, $limit, $type); 625 $query = defined('newsman_csv_export_query') ? newsman_csv_export_query : false; 626 627 $res = $this->getSubscribers($offset, $limit, $type, $query, 'RAW_SQL_QUERY'); 608 628 if ( is_array($res) && !empty($res) ) { 609 629 foreach ($res as $sub) { … … 631 651 } 632 652 633 public function exportToCSV($filename, $type = 'all', $linksFields = array()) { 634 header( 'Content-Type: text/csv' ); 635 header( 'Content-Disposition: attachment;filename='.$filename); 653 public function exportToCSV($filename, $type = 'all', $linksFields = array(), $forceFileOutput = true) { 654 global $newsman_export_fields_map; 655 if ( $forceFileOutput ) { 656 header( 'Content-Type: text/csv' ); 657 header( 'Content-Disposition: attachment;filename='.$filename); 658 } 659 660 //var_dump($newsman_export_fields_map); 661 662 if ( isset($_REQUEST['debug']) ) { 663 echo '<pre>'; // FOR DEBUG ONLY 664 } 636 665 637 666 $out = fopen('php://output', 'w'); … … 640 669 641 670 $fields = array_merge($fields, $linksFields); 642 643 fputcsv($out, $fields, ',', '"'); 671 $mappedFields = array(); 672 673 if ( isset($newsman_export_fields_map) ) { 674 foreach ($fields as &$field) { 675 $mappedFields[] = isset($newsman_export_fields_map[$field]) ? $newsman_export_fields_map[$field] : $field; 676 } 677 } else { 678 $mappedFields = $fields; 679 } 680 681 fputcsv($out, $mappedFields, ',', '"'); 644 682 $this->subsToCSV($out, $fields, $type); 645 683 @fclose($out); 684 } 685 686 if ( isset($_REQUEST['debug']) ) { 687 echo '</pre>'; // FOR DEBUG ONLY 646 688 } 647 689 } -
wpnewsman-newsletters/trunk/class.utils.php
r929655 r933680 750 750 751 751 public function linkNormalizationCallback($matches) { 752 return $matches[1].urldecode(html_entity_decode($matches[4])).$matches[5]; 752 $url = $matches[4]; 753 if ( preg_match('/^(\[|%5B)/i', $url) ) { 754 $url = urldecode(html_entity_decode($url)); 755 } 756 return $matches[1].$url.$matches[5]; 753 757 } 754 758 -
wpnewsman-newsletters/trunk/core.php
r930191 r933680 406 406 return $newsman_loop_post_nr; 407 407 } else if ( $post == "permalink" ) { 408 $this->utils->log('[newsmanShortCode] post = permalink'); 409 $this->utils->log('[newsmanShortCode] newsman_current_email->emailAnalytics: %d', $newsman_current_email->emailAnalytics); 410 411 if ( $newsman_current_email->emailAnalytics ) { 412 return home_url('?p=' . $newsman_loop_post->ID); 413 } else { 414 return get_permalink( $newsman_loop_post->ID ); 415 } 408 return get_permalink( $newsman_loop_post->ID ); 416 409 } else if ( $post == "fancy_excerpt" ) { 417 410 if ( !isset($words) ) { … … 557 550 // links 558 551 559 public function getActionLink($type, $only_code = false, $externalForm = false ) {552 public function getActionLink($type, $only_code = false, $externalForm = false, $dropEmailPart = false) { 560 553 global $newsman_current_subscriber; 561 554 global $newsman_current_email; … … 574 567 $link = "$blogurl/?newsman=$type&code=".$newsman_current_list->uid.':'.$ucode; 575 568 576 if ( in_array($type, array('email', 'unsubscribe' ))) {569 if ( in_array($type, array('email', 'unsubscribe', 'unsubscribe-confirmation')) && !$dropEmailPart ) { 577 570 $link.='&email='.$newsman_current_email->ucode; 578 571 } … … 599 592 global $newsman_current_email; 600 593 global $newsman_current_list; 594 595 if ( !isset($newsman_current_email) ) { return; } 601 596 602 597 $sd = new newsmanAnSubDetails(); … … 2036 2031 'query_var' => "subscription", // This goes to the WP_Query schema 2037 2032 'supports' => array('title', 'excerpt', 'editor' /*,'custom-fields'*/), // Let's use custom fields for debugging purposes only 2038 'register_meta_box_cb' => array($this, 'add_shortcode_metabox') 2033 'register_meta_box_cb' => array($this, 'add_shortcode_metabox'), 2034 'exclude_from_search' => true 2039 2035 )); 2040 2036 … … 2265 2261 $sub = $list->findSubscriber("id = %s", 1); 2266 2262 $c = $eml->renderMessage($sub->toJSON()); 2267 $c = $c['html']; 2268 2263 echo $c['html']; 2264 2265 } elseif ( isset($_REQUEST['processed2']) ) { 2266 echo $eml->p_html; 2269 2267 } else { 2270 $c =$eml->html;2271 } 2272 echo $eml->html; //echo $this->utils->processAssetsURLs($c, $eml->assetsURL);2268 echo $eml->html; 2269 } 2270 //echo $eml->html; //echo $this->utils->processAssetsURLs($c, $eml->assetsURL); 2273 2271 } 2274 2272 die(); -
wpnewsman-newsletters/trunk/js/jquery.placeholder.js
r703446 r933680 1 1 /*! http://mths.be/placeholder v2.0.7 by @mathias */ 2 2 ;(function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){var l=this;l.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder');return l};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return m.value=n}if(n==''){m.value=n;if(m!=h.activeElement){e.call(m)}}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder');l==h.activeElement&&l.select()}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('<input>').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery)); 3 jQuery(function($){ $('input, textarea').placeholder(); }); 3 jQuery(function($){ 4 $('.newsman-form input:visible, .newsman-form textarea:visible').not('[type="hidden"]').placeholder(); 5 }); 6 7 8 //TODO: unfinished. check the code above 9 // var oldJQuery = jQuery; 10 // jQuery = function(fn){ 11 // if ( fn.toString().indexOf("$('input, textarea').placeholder()") >= 0 ) { 12 // return oldJQuery.apply(oldJQuery, arguments); 13 // } 14 // }; -
wpnewsman-newsletters/trunk/readme.txt
r930191 r933680 5 5 Requires at least: 3.5 6 6 Tested up to: 4.0 7 Stable tag: 1.7. 17 Stable tag: 1.7.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 58 58 * French (completed) 59 59 * Russian (completed) 60 * German (Germany) ( 99%)60 * German (Germany) (completed) 61 61 * Polish (99%) 62 62 * Italian (Italy) (50%) … … 124 124 125 125 == Changelog == 126 127 = 1.7.2 = 128 129 * Fixed unsubscribes analytics with double opt-out option enabled. 130 * Fixed processing of analytics enabled links on sites installed in sub-directories. 131 * Fixed false-positive SPAM detection during form submission in Internet Explorer. 126 132 127 133 = 1.7.1 = -
wpnewsman-newsletters/trunk/views/welcome.php
r930191 r933680 8 8 <?php else: ?> 9 9 <div class="about-text">You updated and have better newsletter gadget!</div> 10 11 10 12 <?php endif; ?> 11 13 -
wpnewsman-newsletters/trunk/workers/class.mailer.php
r930191 r933680 66 66 $sl = newsmanSentlog::getInstance(); 67 67 68 $u->log("[launchSender] p_html 1 \n%s", $email->p_html); 69 68 70 $tStreamer = new newsmanTransmissionStreamer($email); 69 71 … … 112 114 113 115 $email->p_html = $u->processAssetsURLs($email->p_html, $email->assetsURL); 114 $email->p_html = $u->compileThumbnails($email->p_html); 116 $email->p_html = $u->compileThumbnails($email->p_html); 115 117 116 118 $this->processMessages(); -
wpnewsman-newsletters/trunk/wpnewsman.php
r930191 r933680 4 4 Plugin URI: http://wpnewsman.com 5 5 Description: You get simple yet powerful newsletter solution for WordPress. Now you can easily add double optin subscription forms in widgets, articles and pages, import and manage your lists, create and send beautiful newsletters directly from your WordPress site. You get complete freedom and a lower cost compared to Email Service Providers. Free yourself from paying for expensive email campaigns. WPNewsman plugin updated regularly with new features. 6 Version: 1.7. 16 Version: 1.7.2 7 7 Author: Alex Ladyga - G-Lock Software 8 8 Author URI: http://www.glocksoft.com … … 32 32 33 33 define('NEWSMAN', 'wpnewsman'); 34 define('NEWSMAN_VERSION', '1.7. 1');34 define('NEWSMAN_VERSION', '1.7.2'); 35 35 36 36 if ( preg_match('/.*?\.dev$/i', $_SERVER['HTTP_HOST']) ) {
Note: See TracChangeset
for help on using the changeset viewer.