Changeset 3264323
- Timestamp:
- 03/31/2025 08:52:31 AM (12 months ago)
- Location:
- woorewards/trunk
- Files:
-
- 6 edited
-
assets/lws-adminpanel/include/tools/session.php (modified) (6 diffs)
-
assets/lws-adminpanel/js/tools/tools.js (modified) (1 diff)
-
assets/lws-adminpanel/lws-adminpanel.php (modified) (2 diffs)
-
include/abstracts/unlockable.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
woorewards.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woorewards/trunk/assets/lws-adminpanel/include/tools/session.php
r3227529 r3264323 13 13 private $dirty = false; 14 14 private $user = false; 15 private $sent = false; 16 private $created = true; 17 18 const OBF = true; 15 19 16 20 static public function set($key, $value) 17 21 { 18 $GLOBALS['lwssession_user']->maybeLoad(); 19 $GLOBALS['lwssession_user']->dirty = true; 20 $GLOBALS['lwssession_user']->data[$key] = \maybe_serialize($value); 22 $me = $GLOBALS['lwssession_user']; 23 $me->maybeLoad(); 24 $me->dirty = true; 25 $me->data[$key] = \maybe_serialize($value); 26 $me->maybeSend(); 21 27 } 22 28 … … 45 51 unset($me->data[$key]); 46 52 } 53 $me->maybeSend(); 47 54 } 48 55 … … 53 60 \add_action('shutdown', [$me, 'save'], 200); 54 61 \add_action('wp_logout', [$me, 'clean']); 55 \LWS\Adminpanel\Tools\Conveniences::addGreadyHook('wp', [$me, 'send']); 62 $me->maybeRepeat(); 63 } 64 65 /** Force start a session. 66 * Call this if you are sure you will use it later, 67 * but too late to place the session cookie. */ 68 static public function start() 69 { 70 $GLOBALS['lwssession_user']->maybeSend(); 71 } 72 73 /** repeat the session cookie if any */ 74 public function maybeRepeat() 75 { 76 if ($this->hasUser()) { 77 $this->maybeSend(); 78 } 79 } 80 81 private function maybeSend() 82 { 83 if (!$this->sent) { 84 $this->send(); 85 } 56 86 } 57 87 58 88 public function send() 59 89 { 90 $this->sent = true; 60 91 if (!\headers_sent()) { 61 92 \setcookie( 62 93 $this->getCookieName(), 63 \base64_encode($this->getUser()),94 self::OBF ? \base64_encode($this->getUser()) : $this->getUser(), 64 95 $this->getExpiry(), 65 96 COOKIEPATH ? COOKIEPATH : '/', … … 76 107 $this->user = false; 77 108 $this->dirty = false; 78 \setcookie( 79 $this->getCookieName(), 80 '', 81 0, 82 COOKIEPATH ? COOKIEPATH : '/', 83 COOKIE_DOMAIN 84 ); 109 $this->sent = false; 110 $this->created = false; 111 if (!\headers_sent()) { 112 \setcookie( 113 $this->getCookieName(), 114 '', 115 0, 116 COOKIEPATH ? COOKIEPATH : '/', 117 COOKIE_DOMAIN 118 ); 119 } 85 120 } 86 121 … … 170 205 } 171 206 207 private function readUser() 208 { 209 $user = false; 210 $name = $this->getCookieName(); 211 if (isset($_COOKIE[$name]) && $_COOKIE[$name]) { 212 // read from cookie if any 213 if (self::OBF) $user = \sanitize_key((string)\base64_decode((string)$_COOKIE[$name])); 214 else $user = \sanitize_key((string)$_COOKIE[$name]); 215 // valid format 216 if (!\in_array(\substr($user, 0, 2), ['l_', 'g_'], true)) { 217 $user = false; 218 } 219 } 220 return $user; 221 } 222 223 private function hasUser(): bool 224 { 225 $this->getUser(); 226 return !$this->created; 227 } 228 172 229 private function getUser(): string 173 230 { 174 231 if (false === $this->user) { 175 $name = $this->getCookieName(); 176 if (isset($_COOKIE[$name]) && $_COOKIE[$name]) { 177 // read from cookie if any 178 $this->user = (string)\base64_decode((string)$_COOKIE[$name]); 179 if (!\in_array(\substr($this->user, 0, 2), ['l_', 'g_'], true)) { 180 $this->user = false; 181 } 182 } 183 return $this->user ?: $this->createUser(); 232 $this->created = false; 233 $this->user = $this->readUser(); 234 $read = $this->user; 235 if (!$this->user) $this->user = $this->createUser(); 184 236 } 185 237 return $this->user; … … 189 241 { 190 242 if (false === $this->user) { 243 $this->created = true; 191 244 $u = \get_current_user_id(); 192 245 if ($u) { -
woorewards/trunk/assets/lws-adminpanel/js/tools/tools.js
r3188612 r3264323 26 26 value=elt.val();else value=elt.text();value=value.toString().normalize('NFD').replace(/[\u0300-\u036f]/g,'').toLowerCase().trim().replace(/\s+/g,'-').replace(/[^\w\-]+/g,'').replace(/\-\-+/g,'-');if('input'==tag||'textarea'==tag||'select'==tag) 27 27 elt.val(value);else elt.text(value)}})(jQuery) 28 jQuery(function($){window.lwsDate= {isLeapYear:function(year){return(((year%4===0)&&(year%100!==0))||(year%400===0))},getMonthLength:function(monthIndex,year){if(1==monthIndex&&this.isLeapYear(year))return 29;return[31,28,31,30,31,30,31,31,30,31,30,31][monthIndex]},isLastDayOfMonth:function(date){return date.getDate()==this.getMonthLength(date.getMonth(),date.getFullYear())},addMonth:function(date,add,stayAtLast){let d=date.getDate(),m=date.getMonth(),y=date.getFullYear();let n=m+add;if(add>=0)y+=Math.floor(n/12);else y-=Math.ceil(-n/12);m=(n%12);if(m<0)m+=12;if(undefined!==stayAtLast&&stayAtLast&&this.isLastDayOfMonth(date)){d=this.getMonthLength(m,y)}else{d=Math.min(d,this.getMonthLength(m,y))}29 let r=new Date();r.setFullYear(y);r.setMonth(m);r.setDate(d);return r},toString:function(date){return date?date.toISOString().split('T')[0]:''},fromString:function(str){if(!str.length)return!1;let d=Date.parse(str);return isNaN(d)?!1:new Date(d)}} })28 jQuery(function($){window.lwsDate=(function(){let self={isLeapYear:function(year){return(((year%4===0)&&(year%100!==0))||(year%400===0))},getMonthLength:function(monthIndex,year){if(1===monthIndex&&this.isLeapYear(year))return 29;return[31,28,31,30,31,30,31,31,30,31,30,31][monthIndex]},isLastDayOfMonth:function(date){return date.getDate()===this.getMonthLength(date.getMonth(),date.getFullYear())},addMonth:function(date,add,stayAtLast){let d=date.getDate(),m=date.getMonth(),y=date.getFullYear();let n=m+add;if(add>=0)y+=Math.floor(n/12);else y-=Math.ceil(-n/12);m=(n%12);if(m<0)m+=12;if(undefined!==stayAtLast&&stayAtLast&&this.isLastDayOfMonth(date)){d=this.getMonthLength(m,y)}else{d=Math.min(d,this.getMonthLength(m,y))} 29 let r=new Date();r.setFullYear(y);r.setMonth(m);r.setDate(d);return r},toString:function(date){return date?date.toISOString().split('T')[0]:''},fromString:function(str){if(!str.length)return!1;let d=Date.parse(str);return isNaN(d)?!1:new Date(d)}};return self})();(function(nav){window.lwsIsMobileDevice=(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(nav)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(nav.substr(0,4))?"yes":"no")})(navigator.userAgent||navigator.vendor||window.opera)}) -
woorewards/trunk/assets/lws-adminpanel/lws-adminpanel.php
r3253331 r3264323 6 6 * Author: Long Watch Studio 7 7 * Author URI: https://longwatchstudio.com 8 * Version: 5. 5.198 * Version: 5.6.1.1 9 9 * Text Domain: lws-adminpanel 10 10 * … … 58 58 59 59 add_filter('lws_adminpanel_versions', function($versions){ 60 $versions['5. 5.19'] = __FILE__;60 $versions['5.6.1.1'] = __FILE__; 61 61 return $versions; 62 62 }); -
woorewards/trunk/include/abstracts/unlockable.php
r3188612 r3264323 50 50 if ($reward !== false) { 51 51 $this->incrRedeemCount($user->ID); 52 \do_action('lws_woorewards_reward_created', $reward, $this, $user); 52 53 if ($this->isEmailEnabled()) 53 54 $this->sendMail($user, $reward, $mailTemplate); -
woorewards/trunk/readme.txt
r3253331 r3264323 5 5 Tested up to: 6.7 6 6 Requires PHP: 7.0.0 7 Stable tag: 5.4.1 07 Stable tag: 5.4.11 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 110 110 == Changelog == 111 111 112 = 5.4.11 = 113 * Dev - new hook 114 * MyRewards Pro : 115 * Fix - Free product duplicated without discount on order again 116 * Update - Facebook share URL for mobile 117 * Feature - Show generated coupon code in reward popup 118 112 119 = 5.4.10 = 113 120 * Fix - language loading path -
woorewards/trunk/woorewards.php
r3253331 r3264323 7 7 * Author: Long Watch Studio 8 8 * Author URI: https://longwatchstudio.com 9 * Version: 5.4.1 09 * Version: 5.4.11 10 10 * License: Copyright LongWatchStudio 2022 11 11 * Text Domain: woorewards-lite … … 111 111 private function defineConstants() 112 112 { 113 define('LWS_WOOREWARDS_VERSION', '5.4.1 0');113 define('LWS_WOOREWARDS_VERSION', '5.4.11'); 114 114 define('LWS_WOOREWARDS_FILE', __FILE__); 115 115 define('LWS_WOOREWARDS_DOMAIN', 'woorewards-lite'); … … 149 149 public function addPluginVersion($url) 150 150 { 151 return '5.4.1 0';151 return '5.4.11'; 152 152 } 153 153
Note: See TracChangeset
for help on using the changeset viewer.