Version Notes
Support multi-currency
Download this release
Release Info
Developer | Eric Benayoun |
Extension | payitsimplepayment |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- app/code/community/Cm/RedisSession/Model/Session.php +0 -695
- app/code/community/Cm/RedisSession/etc/config.xml +0 -48
- app/code/community/Phoenix/Moneybookers/Block/Form.php +0 -93
- app/code/community/Phoenix/Moneybookers/Block/Info.php +0 -51
- app/code/community/Phoenix/Moneybookers/Block/Jsinit.php +0 -49
- app/code/community/Phoenix/Moneybookers/Block/Payment.php +0 -39
- app/code/community/Phoenix/Moneybookers/Block/Placeform.php +0 -67
- app/code/community/Phoenix/Moneybookers/Block/Redirect.php +0 -30
- app/code/community/Phoenix/Moneybookers/Helper/Data.php +0 -130
- app/code/community/Phoenix/Moneybookers/Model/Abstract.php +0 -208
- app/code/community/Phoenix/Moneybookers/Model/Acc.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Csi.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Did.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Dnk.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Ebt.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Ent.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Event.php +0 -274
- app/code/community/Phoenix/Moneybookers/Model/Gcb.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Gir.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Idl.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Lsr.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Mae.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Npy.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Obt.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Pli.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Psp.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Pwy.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Sft.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/So2.php +0 -27
- app/code/community/Phoenix/Moneybookers/Model/Wlt.php +0 -28
- app/code/community/Phoenix/Moneybookers/controllers/MoneybookersController.php +0 -97
- app/code/community/Phoenix/Moneybookers/controllers/ProcessingController.php +0 -146
- app/code/community/Phoenix/Moneybookers/etc/config.xml +0 -306
- app/code/community/Phoenix/Moneybookers/etc/system.xml +0 -1201
- app/code/community/Phoenix/Moneybookers/sql/moneybookers_setup/install-1.6.0.0.php +0 -22
- app/code/community/Phoenix/Moneybookers/sql/moneybookers_setup/mysql4-upgrade-1.2-1.2.0.1.php +0 -41
- app/design/adminhtml/default/default/layout/payitsimple_notification.xml +9 -0
- app/design/adminhtml/default/default/template/payitsimple/system/config/button.phtml +14 -0
- app/design/adminhtml/default/default/template/payitsimple/system/config/notification.phtml +5 -0
- app/design/frontend/base/default/layout/pis_payment.xml +29 -0
- app/design/frontend/base/default/template/payitsimple/form/method_faq.phtml +4 -0
- app/design/frontend/base/default/template/payitsimple/form/pis.phtml +84 -0
- app/design/frontend/base/default/template/payitsimple/help.phtml +8 -0
- app/design/frontend/base/default/template/payitsimple/terms.phtml +102 -0
- app/etc/modules/PayItSimple_Payment.xml +9 -0
- package.xml +5 -7
app/code/community/Cm/RedisSession/Model/Session.php
DELETED
@@ -1,695 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
==New BSD License==
|
4 |
-
|
5 |
-
Copyright (c) 2013, Colin Mollenhour
|
6 |
-
All rights reserved.
|
7 |
-
|
8 |
-
Redistribution and use in source and binary forms, with or without
|
9 |
-
modification, are permitted provided that the following conditions are met:
|
10 |
-
|
11 |
-
* Redistributions of source code must retain the above copyright
|
12 |
-
notice, this list of conditions and the following disclaimer.
|
13 |
-
* Redistributions in binary form must reproduce the above copyright
|
14 |
-
notice, this list of conditions and the following disclaimer in the
|
15 |
-
documentation and/or other materials provided with the distribution.
|
16 |
-
* The name of Colin Mollenhour may not be used to endorse or promote products
|
17 |
-
derived from this software without specific prior written permission.
|
18 |
-
* Redistributions in any form must not change the Cm_RedisSession namespace.
|
19 |
-
|
20 |
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
21 |
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
22 |
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23 |
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
24 |
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
25 |
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26 |
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
27 |
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28 |
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29 |
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30 |
-
*/
|
31 |
-
/**
|
32 |
-
* Redis session handler with optimistic locking.
|
33 |
-
*
|
34 |
-
* Features:
|
35 |
-
* - Falls back to mysql handler if it can't connect to redis. Mysql handler falls back to file handler.
|
36 |
-
* - When a session's data exceeds the compression threshold the session data will be compressed.
|
37 |
-
* - Compression libraries supported are 'gzip', 'lzf', 'lz4' and 'snappy'.
|
38 |
-
* - Compression can be enabled, disabled, or reconfigured on the fly with no loss of session data.
|
39 |
-
* - Expiration is handled by Redis. No garbage collection needed.
|
40 |
-
* - Logs when sessions are not written due to not having or losing their lock.
|
41 |
-
* - Limits the number of concurrent lock requests before a 503 error is returned.
|
42 |
-
*
|
43 |
-
* Locking Algorithm Properties:
|
44 |
-
* - Only one process may get a write lock on a session.
|
45 |
-
* - A process may lose it's lock if another process breaks it, in which case the session will not be written.
|
46 |
-
* - The lock may be broken after BREAK_AFTER seconds and the process that gets the lock is indeterminate.
|
47 |
-
* - Only MAX_CONCURRENCY processes may be waiting for a lock for the same session or else a 503 error is returned.
|
48 |
-
* - Detects crashed processes to prevent session deadlocks (Linux only).
|
49 |
-
* - Detects inactive waiting processes to prevent false-positives in concurrency throttling.
|
50 |
-
*
|
51 |
-
*/
|
52 |
-
class Cm_RedisSession_Model_Session extends Mage_Core_Model_Mysql4_Session
|
53 |
-
{
|
54 |
-
const SLEEP_TIME = 500000; /* Sleep 0.5 seconds between lock attempts (1,000,000 == 1 second) */
|
55 |
-
const FAIL_AFTER = 15; /* Try to break lock for at most this many seconds */
|
56 |
-
const DETECT_ZOMBIES = 20; /* Try to detect zombies every this many tries */
|
57 |
-
const SESSION_PREFIX = 'sess_';
|
58 |
-
const LOG_FILE = 'redis_session.log';
|
59 |
-
|
60 |
-
/* Bots get shorter session lifetimes */
|
61 |
-
const BOT_REGEX = '/^alexa|^blitz\.io|bot|^browsermob|crawl|^curl|^facebookexternalhit|feed|google web preview|^ia_archiver|indexer|^java|jakarta|^libwww-perl|^load impact|^magespeedtest|monitor|^Mozilla$|nagios|^\.net|^pinterest|postrank|slurp|spider|uptime|^wget|yandex/i';
|
62 |
-
|
63 |
-
const DEFAULT_TIMEOUT = 2.5;
|
64 |
-
const DEFAULT_COMPRESSION_THRESHOLD = 2048;
|
65 |
-
const DEFAULT_COMPRESSION_LIB = 'gzip';
|
66 |
-
const DEFAULT_LOG_LEVEL = 1;
|
67 |
-
const DEFAULT_MAX_CONCURRENCY = 6; /* The maximum number of concurrent lock waiters per session */
|
68 |
-
const DEFAULT_BREAK_AFTER = 30; /* Try to break the lock after this many seconds */
|
69 |
-
const DEFAULT_FIRST_LIFETIME = 600; /* The session lifetime for non-bots on the first write */
|
70 |
-
const DEFAULT_BOT_FIRST_LIFETIME = 60; /* The session lifetime for bots on the first write */
|
71 |
-
const DEFAULT_BOT_LIFETIME = 7200; /* The session lifetime for bots - shorter to prevent bots from wasting backend storage */
|
72 |
-
const DEFAULT_DISABLE_LOCKING = FALSE; /* Session locking is enabled by default */
|
73 |
-
const DEFAULT_MAX_LIFETIME = 2592000; /* Redis backend limit */
|
74 |
-
const DEFAULT_MIN_LIFETIME = 60;
|
75 |
-
|
76 |
-
/** @var bool */
|
77 |
-
protected $_useRedis;
|
78 |
-
|
79 |
-
/** @var Credis_Client */
|
80 |
-
protected $_redis;
|
81 |
-
|
82 |
-
/** @var int */
|
83 |
-
protected $_dbNum;
|
84 |
-
|
85 |
-
protected $_config;
|
86 |
-
protected $_compressionThreshold;
|
87 |
-
protected $_compressionLib;
|
88 |
-
protected $_logLevel;
|
89 |
-
protected $_maxConcurrency;
|
90 |
-
protected $_breakAfter;
|
91 |
-
protected $_useLocking;
|
92 |
-
protected $_hasLock;
|
93 |
-
protected $_sessionWritten; // avoid infinite loops
|
94 |
-
protected $_sessionWrites; // set expire time based on activity
|
95 |
-
protected $_maxLifetime;
|
96 |
-
protected $_minLifetime;
|
97 |
-
|
98 |
-
static public $failedLockAttempts = 0; // for debug or informational purposes
|
99 |
-
|
100 |
-
public function __construct()
|
101 |
-
{
|
102 |
-
$this->_config = $config = Mage::getConfig()->getNode('global/redis_session');
|
103 |
-
if (!$config) {
|
104 |
-
$this->_useRedis = FALSE;
|
105 |
-
Mage::log('Redis configuration does not exist, falling back to MySQL handler.', Zend_Log::EMERG);
|
106 |
-
parent::__construct();
|
107 |
-
return;
|
108 |
-
}
|
109 |
-
|
110 |
-
$this->_logLevel = ((int) $config->descend('log_level') ?: self::DEFAULT_LOG_LEVEL);
|
111 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
112 |
-
$timeStart = microtime(true);
|
113 |
-
}
|
114 |
-
|
115 |
-
// Database config
|
116 |
-
$host = ((string) $config->descend('host') ?: '127.0.0.1');
|
117 |
-
$port = ((int) $config->descend('port') ?: '6379');
|
118 |
-
$pass = ((string) $config->descend('password') ?: '');
|
119 |
-
$timeout = ((float) $config->descend('timeout') ?: self::DEFAULT_TIMEOUT);
|
120 |
-
$persistent = ((string) $config->descend('persistent') ?: '');
|
121 |
-
$this->_dbNum = ((int) $config->descend('db') ?: 0);
|
122 |
-
|
123 |
-
// General config
|
124 |
-
$this->_compressionThreshold = ((int) $config->descend('compression_threshold') ?: self::DEFAULT_COMPRESSION_THRESHOLD);
|
125 |
-
$this->_compressionLib = ((string) $config->descend('compression_lib') ?: self::DEFAULT_COMPRESSION_LIB);
|
126 |
-
$this->_maxConcurrency = ((int) $config->descend('max_concurrency') ?: self::DEFAULT_MAX_CONCURRENCY);
|
127 |
-
$this->_breakAfter = ((float) $config->descend('break_after_'.session_name()) ?: self::DEFAULT_BREAK_AFTER);
|
128 |
-
$this->_maxLifetime = ((int) $config->descend('max_lifetime') ?: self::DEFAULT_MAX_LIFETIME);
|
129 |
-
$this->_minLifetime = ((int) $config->descend('min_lifetime') ?: self::DEFAULT_MIN_LIFETIME);
|
130 |
-
$this->_useLocking = defined('CM_REDISSESSION_LOCKING_ENABLED')
|
131 |
-
? CM_REDISSESSION_LOCKING_ENABLED
|
132 |
-
: ! ((int) $config->descend('disable_locking') ?: self::DEFAULT_DISABLE_LOCKING);
|
133 |
-
|
134 |
-
// Use sleep time multiplier so break time is in seconds
|
135 |
-
$this->_breakAfter = (int) round((1000000 / self::SLEEP_TIME) * $this->_breakAfter);
|
136 |
-
$this->_failAfter = (int) round((1000000 / self::SLEEP_TIME) * self::FAIL_AFTER);
|
137 |
-
|
138 |
-
// Connect and authenticate
|
139 |
-
$this->_redis = new Credis_Client($host, $port, $timeout, $persistent);
|
140 |
-
if (!empty($pass)) {
|
141 |
-
$this->_redis->auth($pass) or Zend_Cache::throwException('Unable to authenticate with the redis server.');
|
142 |
-
}
|
143 |
-
$this->_redis->setCloseOnDestruct(FALSE); // Destructor order cannot be predicted
|
144 |
-
$this->_useRedis = TRUE;
|
145 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
146 |
-
$this->_log(sprintf("%s initialized for connection to %s:%s after %.5f seconds",
|
147 |
-
get_class($this), $host, $port, (microtime(true) - $timeStart)
|
148 |
-
));
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @param $msg
|
154 |
-
* @param $level
|
155 |
-
*/
|
156 |
-
protected function _log($msg, $level = Zend_Log::DEBUG)
|
157 |
-
{
|
158 |
-
Mage::log("{$this->_getPid()}: $msg", $level, self::LOG_FILE);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Check DB connection
|
163 |
-
*
|
164 |
-
* @return bool
|
165 |
-
*/
|
166 |
-
public function hasConnection()
|
167 |
-
{
|
168 |
-
if( ! $this->_useRedis) return parent::hasConnection();
|
169 |
-
|
170 |
-
try {
|
171 |
-
$this->_redis->connect();
|
172 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
173 |
-
$this->_log("Connected to Redis");
|
174 |
-
}
|
175 |
-
return TRUE;
|
176 |
-
}
|
177 |
-
catch (Exception $e) {
|
178 |
-
Mage::logException($e);
|
179 |
-
$this->_redis = NULL;
|
180 |
-
Mage::log('Unable to connect to Redis; falling back to MySQL handler', Zend_Log::EMERG);
|
181 |
-
|
182 |
-
// Fall-back to MySQL handler. If this fails, the file handler will be used.
|
183 |
-
$this->_useRedis = FALSE;
|
184 |
-
parent::__construct();
|
185 |
-
return parent::hasConnection();
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Fetch session data
|
191 |
-
*
|
192 |
-
* @param string $sessionId
|
193 |
-
* @return string
|
194 |
-
*/
|
195 |
-
public function read($sessionId)
|
196 |
-
{
|
197 |
-
if ( ! $this->_useRedis) return parent::read($sessionId);
|
198 |
-
Varien_Profiler::start(__METHOD__);
|
199 |
-
|
200 |
-
// Get lock on session. Increment the "lock" field and if the new value is 1, we have the lock.
|
201 |
-
$sessionId = self::SESSION_PREFIX.$sessionId;
|
202 |
-
$tries = $waiting = $lock = 0;
|
203 |
-
$lockPid = $oldLockPid = NULL; // Restart waiting for lock when current lock holder changes
|
204 |
-
$detectZombies = FALSE;
|
205 |
-
if ($this->_logLevel >= Zend_Log::WARN) {
|
206 |
-
$timeStart = microtime(true);
|
207 |
-
}
|
208 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
209 |
-
$this->_log(sprintf("Attempting to take lock on ID %s", $sessionId));
|
210 |
-
}
|
211 |
-
$this->_redis->select($this->_dbNum);
|
212 |
-
while ($this->_useLocking)
|
213 |
-
{
|
214 |
-
// Increment lock value for this session and retrieve the new value
|
215 |
-
$oldLock = $lock;
|
216 |
-
$lock = $this->_redis->hIncrBy($sessionId, 'lock', 1);
|
217 |
-
|
218 |
-
// Get the pid of the process that has the lock
|
219 |
-
if ($lock != 1 && $tries + 1 >= $this->_breakAfter) {
|
220 |
-
$lockPid = $this->_redis->hGet($sessionId, 'pid');
|
221 |
-
}
|
222 |
-
|
223 |
-
// If we got the lock, update with our pid and reset lock and expiration
|
224 |
-
if ( $lock == 1 // We actually do have the lock
|
225 |
-
|| (
|
226 |
-
$tries >= $this->_breakAfter // We are done waiting and want to start trying to break it
|
227 |
-
&& $oldLockPid == $lockPid // Nobody else got the lock while we were waiting
|
228 |
-
)
|
229 |
-
) {
|
230 |
-
$this->_hasLock = TRUE;
|
231 |
-
break;
|
232 |
-
}
|
233 |
-
|
234 |
-
// Otherwise, add to "wait" counter and continue
|
235 |
-
else if ( ! $waiting) {
|
236 |
-
$i = 0;
|
237 |
-
do {
|
238 |
-
$waiting = $this->_redis->hIncrBy($sessionId, 'wait', 1);
|
239 |
-
} while (++$i < $this->_maxConcurrency && $waiting < 1);
|
240 |
-
}
|
241 |
-
|
242 |
-
// Handle overloaded sessions
|
243 |
-
else {
|
244 |
-
// Detect broken sessions (e.g. caused by fatal errors)
|
245 |
-
if ($detectZombies) {
|
246 |
-
$detectZombies = FALSE;
|
247 |
-
if ( $lock > $oldLock // lock shouldn't be less than old lock (another process broke the lock)
|
248 |
-
&& $lock + 1 < $oldLock + $waiting // lock should be old+waiting, otherwise there must be a dead process
|
249 |
-
) {
|
250 |
-
// Reset session to fresh state
|
251 |
-
if ($this->_logLevel >= Zend_Log::INFO) {
|
252 |
-
$this->_log(sprintf(
|
253 |
-
"Detected zombie waiter after %.5f seconds for ID %s (%d waiting)\n %s (%s - %s)",
|
254 |
-
(microtime(true) - $timeStart),
|
255 |
-
$sessionId, $waiting,
|
256 |
-
Mage::app()->getRequest()->getRequestUri(), Mage::app()->getRequest()->getClientIp(), Mage::app()->getRequest()->getHeader('User-Agent')
|
257 |
-
), Zend_Log::INFO);
|
258 |
-
}
|
259 |
-
$waiting = $this->_redis->hIncrBy($sessionId, 'wait', -1);
|
260 |
-
continue;
|
261 |
-
}
|
262 |
-
}
|
263 |
-
|
264 |
-
// Limit concurrent lock waiters to prevent server resource hogging
|
265 |
-
if ($waiting >= $this->_maxConcurrency) {
|
266 |
-
// Overloaded sessions get 503 errors
|
267 |
-
$this->_redis->hIncrBy($sessionId, 'wait', -1);
|
268 |
-
$this->_sessionWritten = TRUE; // Prevent session from getting written
|
269 |
-
$writes = $this->_redis->hGet($sessionId, 'writes');
|
270 |
-
if ($this->_logLevel >= Zend_Log::WARN) {
|
271 |
-
$this->_log(sprintf(
|
272 |
-
"Session concurrency exceeded for ID %s; displaying HTTP 503 (%s waiting, %s total requests)\n %s (%s - %s)",
|
273 |
-
$sessionId, $waiting, $writes,
|
274 |
-
Mage::app()->getRequest()->getRequestUri(), Mage::app()->getRequest()->getClientIp(), Mage::app()->getRequest()->getHeader('User-Agent')
|
275 |
-
), Zend_Log::WARN);
|
276 |
-
}
|
277 |
-
$this->_logLevel = -1; // Disable further logging
|
278 |
-
require_once(Mage::getBaseDir() . DS . 'errors' . DS . '503.php');
|
279 |
-
exit;
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
$tries++;
|
284 |
-
$oldLockPid = $lockPid;
|
285 |
-
$sleepTime = self::SLEEP_TIME;
|
286 |
-
|
287 |
-
// Detect dead lock waiters
|
288 |
-
if ($tries % self::DETECT_ZOMBIES == 1) {
|
289 |
-
$detectZombies = TRUE;
|
290 |
-
$sleepTime += 10000; // sleep + 0.01 seconds
|
291 |
-
}
|
292 |
-
// Detect dead lock holder every 10 seconds (only works on same node as lock holder)
|
293 |
-
if ($tries % self::DETECT_ZOMBIES == 0) {
|
294 |
-
Varien_Profiler::start(__METHOD__.'-detect-zombies');
|
295 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
296 |
-
$this->_log(sprintf(
|
297 |
-
"Checking for zombies after %.5f seconds of waiting...", (microtime(true) - $timeStart)
|
298 |
-
));
|
299 |
-
}
|
300 |
-
$pid = $this->_redis->hGet($sessionId, 'pid');
|
301 |
-
if ($pid && ! $this->_pidExists($pid)) {
|
302 |
-
// Allow a live process to get the lock
|
303 |
-
$this->_redis->hSet($sessionId, 'lock', 0);
|
304 |
-
if ($this->_logLevel >= Zend_Log::INFO) {
|
305 |
-
$this->_log(sprintf(
|
306 |
-
"Detected zombie process (%s) for %s (%s waiting)\n %s (%s - %s)",
|
307 |
-
$pid, $sessionId, $waiting,
|
308 |
-
Mage::app()->getRequest()->getRequestUri(), Mage::app()->getRequest()->getClientIp(), Mage::app()->getRequest()->getHeader('User-Agent')
|
309 |
-
), Zend_Log::INFO);
|
310 |
-
}
|
311 |
-
Varien_Profiler::stop(__METHOD__.'-detect-zombies');
|
312 |
-
continue;
|
313 |
-
}
|
314 |
-
Varien_Profiler::stop(__METHOD__.'-detect-zombies');
|
315 |
-
}
|
316 |
-
// Timeout
|
317 |
-
if ($tries >= $this->_breakAfter + $this->_failAfter) {
|
318 |
-
$this->_hasLock = FALSE;
|
319 |
-
if ($this->_logLevel >= Zend_Log::NOTICE) {
|
320 |
-
$this->_log(sprintf("Giving up on read lock for ID %s after %.5f seconds (%d attempts)", $sessionId, (microtime(true) - $timeStart), $tries), Zend_Log::NOTICE);
|
321 |
-
}
|
322 |
-
break;
|
323 |
-
}
|
324 |
-
else {
|
325 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
326 |
-
$this->_log(sprintf(
|
327 |
-
"Waiting %.2f seconds for lock on ID %s (%d tries, lock pid is %s, %.5f seconds elapsed)",
|
328 |
-
$sleepTime / 1000000, $sessionId, $tries, $lockPid, (microtime(true) - $timeStart)
|
329 |
-
));
|
330 |
-
}
|
331 |
-
Varien_Profiler::start(__METHOD__.'-wait');
|
332 |
-
usleep($sleepTime);
|
333 |
-
Varien_Profiler::stop(__METHOD__.'-wait');
|
334 |
-
}
|
335 |
-
}
|
336 |
-
self::$failedLockAttempts = $tries;
|
337 |
-
|
338 |
-
// Session can be read even if it was not locked by this pid!
|
339 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
340 |
-
$timeStart = microtime(true);
|
341 |
-
}
|
342 |
-
list($sessionData, $sessionWrites) = $this->_redis->hMGet($sessionId, array('data','writes'));
|
343 |
-
Varien_Profiler::stop(__METHOD__);
|
344 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
345 |
-
$this->_log(sprintf("Data read for ID %s in %.5f seconds", $sessionId, (microtime(true) - $timeStart)));
|
346 |
-
}
|
347 |
-
$this->_sessionWrites = (int) $sessionWrites;
|
348 |
-
|
349 |
-
$this->_redis->pipeline();
|
350 |
-
|
351 |
-
// This process is no longer waiting for a lock
|
352 |
-
if ($tries > 0) {
|
353 |
-
$this->_redis->hIncrBy($sessionId, 'wait', -1);
|
354 |
-
}
|
355 |
-
|
356 |
-
// This process has the lock, save the pid
|
357 |
-
if ($this->_hasLock) {
|
358 |
-
$setData = array(
|
359 |
-
'pid' => $this->_getPid(),
|
360 |
-
'lock' => 1,
|
361 |
-
);
|
362 |
-
|
363 |
-
// Save request data in session so if a lock is broken we can know which page it was for debugging
|
364 |
-
if ($this->_logLevel >= Zend_Log::INFO) {
|
365 |
-
if (empty($_SERVER['REQUEST_METHOD'])) {
|
366 |
-
$setData['req'] = $_SERVER['SCRIPT_NAME'];
|
367 |
-
} else {
|
368 |
-
$setData['req'] = "{$_SERVER['REQUEST_METHOD']} {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
|
369 |
-
}
|
370 |
-
if ($lock != 1) {
|
371 |
-
$this->_log(sprintf(
|
372 |
-
"Successfully broke lock for ID %s after %.5f seconds (%d attempts). Lock: %d\nLast request of broken lock: %s",
|
373 |
-
$sessionId, (microtime(true) - $timeStart), $tries, $lock, $this->_redis->hGet($sessionId, 'req')
|
374 |
-
), Zend_Log::INFO);
|
375 |
-
}
|
376 |
-
}
|
377 |
-
$this->_redis->hMSet($sessionId, $setData);
|
378 |
-
}
|
379 |
-
|
380 |
-
// Set session expiration
|
381 |
-
$this->_redis->expire($sessionId, min($this->getLifeTime(), $this->_maxLifetime));
|
382 |
-
$this->_redis->exec();
|
383 |
-
|
384 |
-
// Reset flag in case of multiple session read/write operations
|
385 |
-
$this->_sessionWritten = FALSE;
|
386 |
-
|
387 |
-
return $sessionData ? $this->_decodeData($sessionData) : '';
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
* Update session
|
392 |
-
*
|
393 |
-
* @param string $sessionId
|
394 |
-
* @param string $sessionData
|
395 |
-
* @return boolean
|
396 |
-
*/
|
397 |
-
public function write($sessionId, $sessionData)
|
398 |
-
{
|
399 |
-
Varien_Profiler::start(__METHOD__);
|
400 |
-
if ( ! $this->_useRedis) return parent::write($sessionId, $sessionData);
|
401 |
-
if ($this->_sessionWritten) {
|
402 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
403 |
-
$this->_log(sprintf("Repeated session write detected; skipping for ID %s", $sessionId));
|
404 |
-
}
|
405 |
-
Varien_Profiler::stop(__METHOD__);
|
406 |
-
return TRUE;
|
407 |
-
}
|
408 |
-
$this->_sessionWritten = TRUE;
|
409 |
-
if ($this->_logLevel >= Zend_Log::WARN) {
|
410 |
-
$timeStart = microtime(true);
|
411 |
-
}
|
412 |
-
|
413 |
-
// Do not overwrite the session if it is locked by another pid
|
414 |
-
try {
|
415 |
-
if($this->_dbNum) $this->_redis->select($this->_dbNum); // Prevent conflicts with other connections?
|
416 |
-
|
417 |
-
if ( ! $this->_useLocking
|
418 |
-
|| ( ! ($pid = $this->_redis->hGet('sess_'.$sessionId, 'pid')) || $pid == $this->_getPid())
|
419 |
-
) {
|
420 |
-
$this->_writeRawSession($sessionId, $sessionData, $this->getLifeTime());
|
421 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
422 |
-
$this->_log(sprintf("Data written to ID %s in %.5f seconds", $sessionId, (microtime(true) - $timeStart)));
|
423 |
-
}
|
424 |
-
}
|
425 |
-
else {
|
426 |
-
if ($this->_logLevel >= Zend_Log::WARN) {
|
427 |
-
if ($this->_hasLock) {
|
428 |
-
$this->_log(sprintf("Did not write session for ID %s: another process took the lock.",
|
429 |
-
$sessionId
|
430 |
-
), Zend_Log::WARN);
|
431 |
-
} else {
|
432 |
-
$this->_log(sprintf("Did not write session for ID %s: unable to acquire lock.",
|
433 |
-
$sessionId
|
434 |
-
), Zend_Log::WARN);
|
435 |
-
}
|
436 |
-
}
|
437 |
-
}
|
438 |
-
}
|
439 |
-
catch(Exception $e) {
|
440 |
-
if (class_exists('Mage', false)) {
|
441 |
-
Mage::logException($e);
|
442 |
-
} else {
|
443 |
-
error_log("$e");
|
444 |
-
}
|
445 |
-
Varien_Profiler::stop(__METHOD__);
|
446 |
-
return FALSE;
|
447 |
-
}
|
448 |
-
Varien_Profiler::stop(__METHOD__);
|
449 |
-
return TRUE;
|
450 |
-
}
|
451 |
-
|
452 |
-
/**
|
453 |
-
* Destroy session
|
454 |
-
*
|
455 |
-
* @param string $sessionId
|
456 |
-
* @return boolean
|
457 |
-
*/
|
458 |
-
public function destroy($sessionId)
|
459 |
-
{
|
460 |
-
if ( ! $this->_useRedis) return parent::destroy($sessionId);
|
461 |
-
Varien_Profiler::start(__METHOD__);
|
462 |
-
|
463 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
464 |
-
$this->_log(sprintf("Destroying ID %s", $sessionId));
|
465 |
-
}
|
466 |
-
$this->_redis->pipeline();
|
467 |
-
if($this->_dbNum) $this->_redis->select($this->_dbNum);
|
468 |
-
$this->_redis->del(self::SESSION_PREFIX.$sessionId);
|
469 |
-
$this->_redis->exec();
|
470 |
-
Varien_Profiler::stop(__METHOD__);
|
471 |
-
return TRUE;
|
472 |
-
}
|
473 |
-
|
474 |
-
/**
|
475 |
-
* Overridden to prevent calling getLifeTime at shutdown
|
476 |
-
*
|
477 |
-
* @return bool
|
478 |
-
*/
|
479 |
-
public function close()
|
480 |
-
{
|
481 |
-
if ( ! $this->_useRedis) return parent::close();
|
482 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
483 |
-
$this->_log("Closing connection");
|
484 |
-
}
|
485 |
-
if ($this->_redis) $this->_redis->close();
|
486 |
-
return TRUE;
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
* Garbage collection
|
491 |
-
*
|
492 |
-
* @param int $maxLifeTime ignored
|
493 |
-
* @return boolean
|
494 |
-
*/
|
495 |
-
public function gc($maxLifeTime)
|
496 |
-
{
|
497 |
-
if ( ! $this->_useRedis) return parent::gc($maxLifeTime);
|
498 |
-
return TRUE;
|
499 |
-
}
|
500 |
-
|
501 |
-
/**
|
502 |
-
* @return int|mixed
|
503 |
-
*/
|
504 |
-
public function getLifeTime()
|
505 |
-
{
|
506 |
-
if ( ! $this->_config) return parent::getLifeTime();
|
507 |
-
|
508 |
-
if ($this->_lifeTime === NULL) {
|
509 |
-
$lifeTime = NULL;
|
510 |
-
|
511 |
-
// Detect bots by user agent
|
512 |
-
$botLifetime = ((int) $this->_config->descend('bot_lifetime') ?: self::DEFAULT_BOT_LIFETIME);
|
513 |
-
if ($botLifetime) {
|
514 |
-
$userAgent = empty($_SERVER['HTTP_USER_AGENT']) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
|
515 |
-
$isBot = ! $userAgent || preg_match(self::BOT_REGEX, $userAgent);
|
516 |
-
if ($isBot) {
|
517 |
-
if ($this->_logLevel > Zend_Log::DEBUG) {
|
518 |
-
$this->_log(sprintf("Bot detected for user agent: %s", $userAgent));
|
519 |
-
}
|
520 |
-
if ( $this->_sessionWrites <= 1
|
521 |
-
&& ($botFirstLifetime = ((int) $this->_config->descend('bot_first_lifetime') ?: self::DEFAULT_BOT_FIRST_LIFETIME))
|
522 |
-
) {
|
523 |
-
$lifeTime = $botFirstLifetime * (1+$this->_sessionWrites);
|
524 |
-
} else {
|
525 |
-
$lifeTime = min(parent::getLifeTime(), $botLifetime);
|
526 |
-
}
|
527 |
-
}
|
528 |
-
}
|
529 |
-
|
530 |
-
// Use different lifetime for first write
|
531 |
-
if ($lifeTime === NULL && $this->_sessionWrites <= 1) {
|
532 |
-
$firstLifetime = ((int) $this->_config->descend('first_lifetime') ?: self::DEFAULT_FIRST_LIFETIME);
|
533 |
-
if ($firstLifetime) {
|
534 |
-
$lifeTime = $firstLifetime * (1+$this->_sessionWrites);
|
535 |
-
}
|
536 |
-
}
|
537 |
-
|
538 |
-
// Neither bot nor first write
|
539 |
-
if ($lifeTime === NULL) {
|
540 |
-
$lifeTime = parent::getLifeTime();
|
541 |
-
}
|
542 |
-
|
543 |
-
$this->_lifeTime = $lifeTime;
|
544 |
-
if ($this->_lifeTime < $this->_minLifetime) {
|
545 |
-
$this->_lifeTime = $this->_minLifetime;
|
546 |
-
}
|
547 |
-
if ($this->_lifeTime > $this->_maxLifetime) {
|
548 |
-
$this->_lifeTime = $this->_maxLifetime;
|
549 |
-
}
|
550 |
-
}
|
551 |
-
return $this->_lifeTime;
|
552 |
-
}
|
553 |
-
|
554 |
-
/**
|
555 |
-
* Public for testing purposes only.
|
556 |
-
*
|
557 |
-
* @param string $data
|
558 |
-
* @return string
|
559 |
-
*/
|
560 |
-
public function _encodeData($data)
|
561 |
-
{
|
562 |
-
Varien_Profiler::start(__METHOD__);
|
563 |
-
$originalDataSize = strlen($data);
|
564 |
-
if ($this->_compressionThreshold > 0 && $this->_compressionLib != 'none' && $originalDataSize >= $this->_compressionThreshold) {
|
565 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
566 |
-
$this->_log(sprintf("Compressing %s bytes with %s", $originalDataSize,$this->_compressionLib));
|
567 |
-
$timeStart = microtime(true);
|
568 |
-
}
|
569 |
-
$prefix = ':'.substr($this->_compressionLib,0,2).':';
|
570 |
-
switch($this->_compressionLib) {
|
571 |
-
case 'snappy': $data = snappy_compress($data); break;
|
572 |
-
case 'lzf': $data = lzf_compress($data); break;
|
573 |
-
case 'lz4': $data = lz4_compress($data); $prefix = ':l4:'; break;
|
574 |
-
case 'gzip': $data = gzcompress($data, 1); break;
|
575 |
-
}
|
576 |
-
if($data) {
|
577 |
-
$data = $prefix.$data;
|
578 |
-
if ($this->_logLevel >= Zend_Log::DEBUG) {
|
579 |
-
$this->_log(sprintf("Data compressed by %.1f percent in %.5f seconds",
|
580 |
-
($originalDataSize == 0 ? 0 : (100 - (strlen($data) / $originalDataSize * 100))), (microtime(true) - $timeStart)
|
581 |
-
));
|
582 |
-
}
|
583 |
-
} else if ($this->_logLevel >= Zend_Log::WARN) {
|
584 |
-
$this->_log(sprintf("Could not compress session data using %s", $this->_compressionLib), Zend_Log::WARN);
|
585 |
-
}
|
586 |
-
}
|
587 |
-
Varien_Profiler::stop(__METHOD__);
|
588 |
-
return $data;
|
589 |
-
}
|
590 |
-
|
591 |
-
/**
|
592 |
-
* Public for testing purposes only.
|
593 |
-
*
|
594 |
-
* @param string $data
|
595 |
-
* @return string
|
596 |
-
*/
|
597 |
-
public function _decodeData($data)
|
598 |
-
{
|
599 |
-
Varien_Profiler::start(__METHOD__);
|
600 |
-
switch (substr($data,0,4)) {
|
601 |
-
// asking the data which library it uses allows for transparent changes of libraries
|
602 |
-
case ':sn:': $data = snappy_uncompress(substr($data,4)); break;
|
603 |
-
case ':lz:': $data = lzf_decompress(substr($data,4)); break;
|
604 |
-
case ':l4:': $data = lz4_uncompress(substr($data,4)); break;
|
605 |
-
case ':gz:': $data = gzuncompress(substr($data,4)); break;
|
606 |
-
}
|
607 |
-
Varien_Profiler::stop(__METHOD__);
|
608 |
-
return $data;
|
609 |
-
}
|
610 |
-
|
611 |
-
/**
|
612 |
-
* Public for testing/import purposes only.
|
613 |
-
*
|
614 |
-
* @param $id
|
615 |
-
* @param $data
|
616 |
-
* @param $lifetime
|
617 |
-
* @throws Exception
|
618 |
-
*/
|
619 |
-
public function _writeRawSession($id, $data, $lifetime)
|
620 |
-
{
|
621 |
-
if ( ! $this->_useRedis) {
|
622 |
-
throw new Exception('Not connected to redis!');
|
623 |
-
}
|
624 |
-
|
625 |
-
$sessionId = 'sess_' . $id;
|
626 |
-
$this->_redis->pipeline()
|
627 |
-
->select($this->_dbNum)
|
628 |
-
->hMSet($sessionId, array(
|
629 |
-
'data' => $this->_encodeData($data),
|
630 |
-
'lock' => 0, // 0 so that next lock attempt will get 1
|
631 |
-
))
|
632 |
-
->hIncrBy($sessionId, 'writes', 1)
|
633 |
-
->expire($sessionId, min($lifetime, $this->_maxLifetime))
|
634 |
-
->exec();
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* @param string $id
|
639 |
-
* @return array
|
640 |
-
* @throws Exception
|
641 |
-
*/
|
642 |
-
public function _inspectSession($id)
|
643 |
-
{
|
644 |
-
if ( ! $this->_useRedis) {
|
645 |
-
throw new Exception('Not connected to redis!');
|
646 |
-
}
|
647 |
-
|
648 |
-
$sessionId = strpos($id, 'sess_') === 0 ? $id : 'sess_' . $id;
|
649 |
-
$this->_redis->select($this->_dbNum);
|
650 |
-
$data = $this->_redis->hGetAll($sessionId);
|
651 |
-
if ($data && isset($data['data'])) {
|
652 |
-
$data['data'] = $this->_decodeData($data['data']);
|
653 |
-
}
|
654 |
-
return $data;
|
655 |
-
}
|
656 |
-
|
657 |
-
/**
|
658 |
-
* Public for testing/inspection purposes only.
|
659 |
-
*
|
660 |
-
* @param $forceStandalone
|
661 |
-
* @return Credis_Client
|
662 |
-
*/
|
663 |
-
public function _redisClient($forceStandalone)
|
664 |
-
{
|
665 |
-
if ($forceStandalone) {
|
666 |
-
$this->_redis->forceStandalone();
|
667 |
-
}
|
668 |
-
if ($this->_dbNum) {
|
669 |
-
$this->_redis->select($this->_dbNum);
|
670 |
-
}
|
671 |
-
return $this->_redis;
|
672 |
-
}
|
673 |
-
|
674 |
-
/**
|
675 |
-
* @return string
|
676 |
-
*/
|
677 |
-
public function _getPid()
|
678 |
-
{
|
679 |
-
return gethostname().'|'.getmypid();
|
680 |
-
}
|
681 |
-
|
682 |
-
/**
|
683 |
-
* @param $pid
|
684 |
-
* @return bool
|
685 |
-
*/
|
686 |
-
public function _pidExists($pid)
|
687 |
-
{
|
688 |
-
list($host,$pid) = explode('|', $pid);
|
689 |
-
if (PHP_OS != 'Linux' || $host != gethostname()) {
|
690 |
-
return TRUE;
|
691 |
-
}
|
692 |
-
return @file_exists('/proc/'.$pid);
|
693 |
-
}
|
694 |
-
|
695 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Cm/RedisSession/etc/config.xml
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/*
|
4 |
-
==New BSD License==
|
5 |
-
|
6 |
-
Copyright (c) 2013, Colin Mollenhour
|
7 |
-
All rights reserved.
|
8 |
-
|
9 |
-
Redistribution and use in source and binary forms, with or without
|
10 |
-
modification, are permitted provided that the following conditions are met:
|
11 |
-
|
12 |
-
* Redistributions of source code must retain the above copyright
|
13 |
-
notice, this list of conditions and the following disclaimer.
|
14 |
-
* Redistributions in binary form must reproduce the above copyright
|
15 |
-
notice, this list of conditions and the following disclaimer in the
|
16 |
-
documentation and/or other materials provided with the distribution.
|
17 |
-
* The name of Colin Mollenhour may not be used to endorse or promote products
|
18 |
-
derived from this software without specific prior written permission.
|
19 |
-
* The module name must remain Cm_RedisSession.
|
20 |
-
|
21 |
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
22 |
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
23 |
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
24 |
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
25 |
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
26 |
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
27 |
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
28 |
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29 |
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
30 |
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31 |
-
*/
|
32 |
-
-->
|
33 |
-
<config>
|
34 |
-
<modules>
|
35 |
-
<Cm_RedisSession>
|
36 |
-
<version>0.2</version>
|
37 |
-
</Cm_RedisSession>
|
38 |
-
</modules>
|
39 |
-
<global>
|
40 |
-
<models>
|
41 |
-
<core_mysql4>
|
42 |
-
<rewrite>
|
43 |
-
<session>Cm_RedisSession_Model_Session</session>
|
44 |
-
</rewrite>
|
45 |
-
</core_mysql4>
|
46 |
-
</models>
|
47 |
-
</global>
|
48 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Form.php
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Form extends Mage_Payment_Block_Form
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Available locales for content URL generation
|
24 |
-
*
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
protected $_supportedInfoLocales = array('de');
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Default locale for content URL generation
|
31 |
-
*
|
32 |
-
* @var string
|
33 |
-
*/
|
34 |
-
protected $_defaultInfoLocale = 'en';
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Constructor. Set template.
|
38 |
-
*/
|
39 |
-
protected function _construct()
|
40 |
-
{
|
41 |
-
parent::_construct();
|
42 |
-
$this->setTemplate('moneybookers/form.phtml');
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Return payment logo image src
|
47 |
-
*
|
48 |
-
* @param string $payment Payment Code
|
49 |
-
* @return string|bool
|
50 |
-
*/
|
51 |
-
public function getPaymentImageSrc($payment)
|
52 |
-
{
|
53 |
-
if ($payment == 'moneybookers_obt') {
|
54 |
-
$payment .= '_'.$this->getInfoLocale();
|
55 |
-
}
|
56 |
-
|
57 |
-
$imageFilename = Mage::getDesign()
|
58 |
-
->getFilename('images' . DS . 'moneybookers' . DS . $payment, array('_type' => 'skin'));
|
59 |
-
|
60 |
-
if (file_exists($imageFilename . '.png')) {
|
61 |
-
return $this->getSkinUrl('images/moneybookers/' . $payment . '.png');
|
62 |
-
} else if (file_exists($imageFilename . '.gif')) {
|
63 |
-
return $this->getSkinUrl('images/moneybookers/' . $payment . '.gif');
|
64 |
-
}
|
65 |
-
|
66 |
-
return false;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Return supported locale for information text
|
71 |
-
*
|
72 |
-
* @return string
|
73 |
-
*/
|
74 |
-
public function getInfoLocale()
|
75 |
-
{
|
76 |
-
$locale = substr(Mage::app()->getLocale()->getLocaleCode(), 0 ,2);
|
77 |
-
if (!in_array($locale, $this->_supportedInfoLocales)) {
|
78 |
-
$locale = $this->_defaultInfoLocale;
|
79 |
-
}
|
80 |
-
return $locale;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Return info URL for eWallet payment
|
85 |
-
*
|
86 |
-
* @return string
|
87 |
-
*/
|
88 |
-
public function getWltInfoUrl()
|
89 |
-
{
|
90 |
-
$locale = substr(Mage::app()->getLocale()->getLocaleCode(), 0 ,2);
|
91 |
-
return 'http://www.moneybookers.com/app/?l=' . strtoupper($locale);
|
92 |
-
}
|
93 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Info.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Info extends Mage_Payment_Block_Info
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Constructor. Set template.
|
24 |
-
*/
|
25 |
-
protected function _construct()
|
26 |
-
{
|
27 |
-
parent::_construct();
|
28 |
-
$this->setTemplate('moneybookers/info.phtml');
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Returns code of payment method
|
33 |
-
*
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
public function getMethodCode()
|
37 |
-
{
|
38 |
-
return $this->getInfo()->getMethodInstance()->getCode();
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Build PDF content of info block
|
43 |
-
*
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function toPdf()
|
47 |
-
{
|
48 |
-
$this->setTemplate('moneybookers/pdf/info.phtml');
|
49 |
-
return $this->toHtml();
|
50 |
-
}
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Jsinit.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Jsinit extends Mage_Adminhtml_Block_Template
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Include JS in head if section is moneybookers
|
24 |
-
*/
|
25 |
-
protected function _prepareLayout()
|
26 |
-
{
|
27 |
-
$section = $this->getAction()->getRequest()->getParam('section', false);
|
28 |
-
if ($section == 'moneybookers') {
|
29 |
-
$this->getLayout()
|
30 |
-
->getBlock('head')
|
31 |
-
->addJs('mage/adminhtml/moneybookers.js');
|
32 |
-
}
|
33 |
-
parent::_prepareLayout();
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Print init JS script into body
|
38 |
-
* @return string
|
39 |
-
*/
|
40 |
-
protected function _toHtml()
|
41 |
-
{
|
42 |
-
$section = $this->getAction()->getRequest()->getParam('section', false);
|
43 |
-
if ($section == 'moneybookers') {
|
44 |
-
return parent::_toHtml();
|
45 |
-
} else {
|
46 |
-
return '';
|
47 |
-
}
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Payment.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Payment extends Mage_Core_Block_Template
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Return Payment logo src
|
24 |
-
*
|
25 |
-
* @return string
|
26 |
-
*/
|
27 |
-
public function getMoneybookersLogoSrc()
|
28 |
-
{
|
29 |
-
$locale = Mage::getModel('moneybookers/acc')->getLocale();
|
30 |
-
$logoFilename = Mage::getDesign()
|
31 |
-
->getFilename('images' . DS . 'moneybookers' . DS . 'banner_120_' . $locale . '.gif', array('_type' => 'skin'));
|
32 |
-
|
33 |
-
if (file_exists($logoFilename)) {
|
34 |
-
return $this->getSkinUrl('images/moneybookers/banner_120_'.$locale.'.gif');
|
35 |
-
}
|
36 |
-
|
37 |
-
return $this->getSkinUrl('images/moneybookers/banner_120_int.gif');
|
38 |
-
}
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Placeform.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Placeform extends Mage_Core_Block_Template
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Return checkout session instance
|
24 |
-
*
|
25 |
-
* @return Mage_Checkout_Model_Session
|
26 |
-
*/
|
27 |
-
protected function _getCheckout()
|
28 |
-
{
|
29 |
-
return Mage::getSingleton('checkout/session');
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Return order instance
|
34 |
-
*
|
35 |
-
* @return Mage_Sales_Model_Order|null
|
36 |
-
*/
|
37 |
-
protected function _getOrder()
|
38 |
-
{
|
39 |
-
if ($this->getOrder()) {
|
40 |
-
return $this->getOrder();
|
41 |
-
} elseif ($orderIncrementId = $this->_getCheckout()->getLastRealOrderId()) {
|
42 |
-
return Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
43 |
-
} else {
|
44 |
-
return null;
|
45 |
-
}
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get Form data by using ogone payment api
|
50 |
-
*
|
51 |
-
* @return array
|
52 |
-
*/
|
53 |
-
public function getFormData()
|
54 |
-
{
|
55 |
-
return $this->_getOrder()->getPayment()->getMethodInstance()->getFormFields();
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Getting gateway url
|
60 |
-
*
|
61 |
-
* @return string
|
62 |
-
*/
|
63 |
-
public function getFormAction()
|
64 |
-
{
|
65 |
-
return $this->_getOrder()->getPayment()->getMethodInstance()->getUrl();
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Block/Redirect.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Block_Redirect extends Mage_Core_Block_Template
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* Constructor. Set template.
|
24 |
-
*/
|
25 |
-
protected function _construct()
|
26 |
-
{
|
27 |
-
parent::_construct();
|
28 |
-
$this->setTemplate('moneybookers/redirect.phtml');
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Helper/Data.php
DELETED
@@ -1,130 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
class Phoenix_Moneybookers_Helper_Data extends Mage_Payment_Helper_Data
|
21 |
-
{
|
22 |
-
const XML_PATH_EMAIL = 'moneybookers/settings/moneybookers_email';
|
23 |
-
const XML_PATH_CUSTOMER_ID = 'moneybookers/settings/customer_id';
|
24 |
-
const XML_PATH_SECRET_KEY = 'moneybookers/settings/secret_key';
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Internal parameters for validation
|
28 |
-
*/
|
29 |
-
protected $_moneybookersServer = 'https://www.moneybookers.com';
|
30 |
-
protected $_checkEmailUrl = '/app/email_check.pl';
|
31 |
-
protected $_checkEmailCustId = '6999315';
|
32 |
-
protected $_checkEmailPassword = 'a4ce5a98a8950c04a3d34a2e2cb8c89f';
|
33 |
-
protected $_checkSecretUrl = '/app/secret_word_check.pl';
|
34 |
-
protected $_activationEmailTo = 'ecommerce@moneybookers.com';
|
35 |
-
protected $_activationEmailSubject = 'Magento Moneybookers Activation';
|
36 |
-
protected $_moneybookersMasterCustId = '7283403';
|
37 |
-
protected $_moneybookersMasterSecretHash = 'c18524b6b1082653039078a4700367f0';
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Send activation Email to Moneybookers
|
41 |
-
*/
|
42 |
-
public function activateEmail()
|
43 |
-
{
|
44 |
-
$storeId = Mage::app()->getStore()->getId();
|
45 |
-
|
46 |
-
$translate = Mage::getSingleton('core/translate');
|
47 |
-
/* @var $translate Mage_Core_Model_Translate */
|
48 |
-
$translate->setTranslateInline(false);
|
49 |
-
|
50 |
-
Mage::getModel('core/email_template')
|
51 |
-
->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))
|
52 |
-
->sendTransactional(
|
53 |
-
'moneybookers_activateemail',
|
54 |
-
Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId),
|
55 |
-
$this->_activationEmailTo,
|
56 |
-
null,
|
57 |
-
array(
|
58 |
-
'subject' => $this->_activationEmailSubject,
|
59 |
-
'email_addr' => Mage::getStoreConfig(self::XML_PATH_EMAIL),
|
60 |
-
'url' => Mage::getBaseUrl(),
|
61 |
-
'customer_id' => Mage::getStoreConfig(self::XML_PATH_CUSTOMER_ID),
|
62 |
-
'language' => Mage::getModel('core/locale')->getDefaultLocale()
|
63 |
-
)
|
64 |
-
);
|
65 |
-
|
66 |
-
$translate->setTranslateInline(true);
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Check if email is registered at Moneybookers
|
71 |
-
*
|
72 |
-
* @param array $params
|
73 |
-
* @return array
|
74 |
-
*/
|
75 |
-
public function checkEmailRequest(Array $params) {
|
76 |
-
$response = null;
|
77 |
-
try {
|
78 |
-
$response = $this->_getHttpsPage($this->_moneybookersServer . $this->_checkEmailUrl, array(
|
79 |
-
'email' => $params['email'],
|
80 |
-
'cust_id' => $this->_checkEmailCustId,
|
81 |
-
'password' => $this->_checkEmailPassword)
|
82 |
-
);
|
83 |
-
} catch (Exception $e) {
|
84 |
-
Mage::log($e->getMessage());
|
85 |
-
return null;
|
86 |
-
}
|
87 |
-
return $response;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Check if entered secret is valid
|
92 |
-
* @param array $params
|
93 |
-
* @return array
|
94 |
-
*/
|
95 |
-
public function checkSecretRequest(Array $params)
|
96 |
-
{
|
97 |
-
$response = null;
|
98 |
-
try {
|
99 |
-
$response = $this->_getHttpsPage($this->_moneybookersServer . $this->_checkSecretUrl, array(
|
100 |
-
'email' => $params['email'],
|
101 |
-
'secret' => md5(md5($params['secret']) . $this->_moneybookersMasterSecretHash),
|
102 |
-
'cust_id' => $this->_moneybookersMasterCustId)
|
103 |
-
);
|
104 |
-
} catch (Exception $e) {
|
105 |
-
Mage::log($e->getMessage());
|
106 |
-
return null;
|
107 |
-
}
|
108 |
-
return $response;
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* Reading a page via HTTPS and returning its content.
|
113 |
-
*/
|
114 |
-
protected function _getHttpsPage($host, $parameter)
|
115 |
-
{
|
116 |
-
$client = new Varien_Http_Client();
|
117 |
-
$client->setUri($host)
|
118 |
-
->setConfig(array('timeout' => 30))
|
119 |
-
->setHeaders('accept-encoding', '')
|
120 |
-
->setParameterGet($parameter)
|
121 |
-
->setMethod(Zend_Http_Client::GET);
|
122 |
-
$request = $client->request();
|
123 |
-
// Workaround for pseudo chunked messages which are yet too short, so
|
124 |
-
// only an exception is is thrown instead of returning raw body
|
125 |
-
if (!preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $request->getRawBody(), $m))
|
126 |
-
return $request->getRawBody();
|
127 |
-
|
128 |
-
return $request->getBody();
|
129 |
-
}
|
130 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Phoenix/Moneybookers/Model/Abstract.php
DELETED
@@ -1,208 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Phoenix
|
16 |
-
* @package Phoenix_Moneybookers
|
17 |
-
* @copyright Copyright (c) 2015 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
abstract class Phoenix_Moneybookers_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
21 |
-
{
|
22 |
-
/**
|
23 |
-
* unique internal payment method identifier
|
24 |
-
*/
|
25 |
-
protected $_code = 'moneybookers_abstract';
|
26 |
-
|
27 |
-
protected $_formBlockType = 'moneybookers/form';
|
28 |
-
protected $_infoBlockType = 'moneybookers/info';
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Availability options
|
32 |
-
*/
|
33 |
-
protected $_isGateway = true;
|
34 |
-
protected $_canAuthorize = true;
|
35 |
-
protected $_canCapture = true;
|
36 |
-
protected $_canCapturePartial = false;
|
37 |
-
protected $_canRefund = false;
|
38 |
-
protected $_canVoid = false;
|
39 |
-
protected $_canUseInternal = false;
|
40 |
-
protected $_canUseCheckout = true;
|
41 |
-
protected $_canUseForMultishipping = false;
|
42 |
-
|
43 |
-
protected $_paymentMethod = 'abstract';
|
44 |
-
protected $_defaultLocale = 'en';
|
45 |
-
protected $_supportedLocales = array('cn', 'cz', 'da', 'en', 'es', 'fi', 'de', 'fr', 'gr', 'it', 'nl', 'ro', 'ru', 'pl', 'sv', 'tr');
|
46 |
-
protected $_hidelogin = '1';
|
47 |
-
|
48 |
-
protected $_order;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Get order model
|
52 |
-
*
|
53 |
-
* @return Mage_Sales_Model_Order
|
54 |
-
*/
|
55 |
-
public function getOrder()
|
56 |
-
{
|
57 |
-
if (!$this->_order) {
|
58 |
-
$this->_order = $this->getInfoInstance()->getOrder();
|
59 |
-
}
|
60 |
-
return $this->_order;
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Return url for redirection after order placed
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function getOrderPlaceRedirectUrl()
|
68 |
-
{
|
69 |
-
return Mage::getUrl('moneybookers/processing/payment');
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Capture payment through Moneybookers api
|
74 |
-
*
|
75 |
-
* @param Varien_Object $payment
|
76 |
-
* @param decimal $amount
|
77 |
-
* @return Phoenix_Moneybookers_Model_Abstract
|
78 |
-
*/
|
79 |
-
public function capture(Varien_Object $payment, $amount)
|
80 |
-
{
|
81 |
-
$payment->setStatus(self::STATUS_APPROVED)
|
82 |
-
->setTransactionId($this->getTransactionId())
|
83 |
-
->setIsTransactionClosed(0);
|
84 |
-
|
85 |
-
return $this;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Camcel payment
|
90 |
-
*
|
91 |
-
* @param Varien_Object $payment
|
92 |
-
* @return Phoenix_Moneybookers_Model_Abstract
|
93 |
-
*/
|
94 |
-
public function cancel(Varien_Object $payment)
|
95 |
-
{
|
96 |
-
$payment->setStatus(self::STATUS_DECLINED)
|
97 |
-
->setTransactionId($this->getTransactionId())
|
98 |
-
->setIsTransactionClosed(1);
|
99 |
-
|
100 |
-
return $this;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Return url of payment method
|
105 |
-
*
|
106 |
-
* @return string
|
107 |
-
*/
|
108 |
-
public function getUrl()
|
109 |
-
{
|
110 |
-
return 'https://www.moneybookers.com/app/payment.pl';
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Return url of payment method
|
115 |
-
*
|
116 |
-
* @return string
|
117 |
-
*/
|
118 |
-
public function getLocale()
|
119 |
-
{
|
120 |
-
$locale = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
121 |
-
if (is_array($locale) && !empty($locale) && in_array($locale[0], $this->_supportedLocales)) {
|
122 |
-
return $locale[0];
|
123 |
-
}
|
124 |
-
return $this->getDefaultLocale();
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* prepare params array to send it to gateway page via POST
|
129 |
-
*
|
130 |
-
* @return array
|
131 |
-
*/
|
132 |
-
public function getFormFields()
|
133 |
-
{
|
134 |
-
$order_id = $this->getOrder()->getRealOrderId();
|
135 |
-
$billing = $this->getOrder()->getBillingAddress();
|
136 |
-
if ($this->getOrder()->getBillingAddress()->getEmail()) {
|
137 |
-
$email = $this->getOrder()->getBillingAddress()->getEmail();
|
138 |
-
} else {
|
139 |
-
$email = $this->getOrder()->getCustomerEmail();
|
140 |
-
}
|
141 |
-
|
142 |
-
$params = array(
|
143 |
-
'merchant_fields' => 'partner',
|
144 |
-
'partner' => 'magento',
|
145 |
-
'pay_to_email' => Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_EMAIL),
|
146 |
-
'transaction_id' => $order_id,
|
147 |
-
'return_url' => Mage::getUrl('moneybookers/processing/success', array('transaction_id' => $order_id)),
|
148 |
-
'cancel_url' => Mage::getUrl('moneybookers/processing/cancel', array('transaction_id' => $order_id)),
|
149 |
-
'status_url' => Mage::getUrl('moneybookers/processing/status'),
|
150 |
-
'language' => $this->getLocale(),
|
151 |
-
'amount' => round($this->getOrder()->getGrandTotal(), 2),
|
152 |
-
'currency' => $this->getOrder()->getOrderCurrencyCode(),
|
153 |
-
'recipient_description' => $this->getOrder()->getStore()->getWebsite()->getName(),
|
154 |
-
'firstname' => $billing->getFirstname(),
|
155 |
-
'lastname' => $billing->getLastname(),
|
156 |
-
'address' => $billing->getStreet(-1),
|
157 |
-
'postal_code' => $billing->getPostcode(),
|
158 |
-
'city' => $billing->getCity(),
|
159 |
-
'country' => $billing->getCountryModel()->getIso3Code(),
|
160 |
-
'pay_from_email' => $email,
|
161 |
-
'phone_number' => $billing->getTelephone(),
|
162 |
-
'detail1_description' => Mage::helper('moneybookers')->__('Order ID'),
|
163 |
-
'detail1_text' => $order_id,
|
164 |
-
'payment_methods' => $this->_paymentMethod,
|
165 |
-
'hide_login' => $this->_hidelogin,
|
166 |
-
'new_window_redirect' => '1'
|
167 |
-
);
|
168 |
-
|
169 |
-
// add optional day of birth
|
170 |
-
if ($billing->getDob()) {
|
171 |
-
$params['date_of_birth'] = Mage::app()->getLocale()->date($billing->getDob(), null, null, false)->toString('dmY');
|
172 |
-
}
|
173 |
-
|
174 |
-
return $params;
|
175 |
-
}
|
176 |
-
/**
|
177 |
-
* Get initialized flag status
|
178 |
-
* @return true
|
179 |
-
*/
|
180 |
-
public function isInitializeNeeded()
|
181 |
-
{
|
182 |
-
return true;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Instantiate state and set it to state onject
|
187 |
-
* //@param
|
188 |
-
* //@param
|
189 |
-
*/
|
190 |
-
public function initialize($paymentAction, $stateObject)
|
191 |
-
{
|
192 |
-
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
|
193 |
-
$stateObject->setState($state);
|
194 |
-
$stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
195 |
-
$stateObject->setIsNotified(false);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Get config action to process initialization
|
200 |
-
*
|
201 |
-
* @return string
|
202 |
-
*/
|
203 |
-
public function getConfigPaymentAction()
|
204 |
-
{
|
205 |
-
$paymentAction = $this->getConfigData('payment_action');
|
206 |
-
return empty($paymentAction) ? true : $paymentAction;
|
207 |
-
}
|
208 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|