Ejemplo n.º 1
0
 public function connect($ip, $port)
 {
     $this->remoteip = $ip;
     $this->remoteport = $port;
     $errno = 0;
     $errstr = '';
     logger::debug("Connecting to %s:%d", $ip, $port);
     $this->state = SOCKSTATE_CONNECTING;
     $this->fsh = fsockopen($ip, $port, $errno, $errstr);
     if ($errno) {
         logger::warning("Socket error: %d %s (%s:%d)", $errno, $errstr, $ip, $port);
         $this->state = SOCKSTATE_ERROR;
         return false;
     } else {
         if (!$this->fsh) {
             $this->state = SOCKSTATE_ERROR;
             logger::warning("No socket handle returned but no error indicated");
             return false;
         }
         logger::debug("Socket connected to %s:%d", $ip, $port);
         stream_set_timeout($this->fsh, 0, 200);
         $this->state = SOCKSTATE_CONNECTED;
         return true;
     }
 }
Ejemplo n.º 2
0
 public static function getupdatesql($table_name, &$data, $whereClause)
 {
     $db = vmc::database();
     if (!$table_name) {
         trigger_error('getupdatesql UNKNOW TABLE_NAME', E_USER_WARNING);
         return false;
     }
     foreach ($data as $key => $value) {
         $data[strtolower($key)] = $value;
     }
     $table_fields = $db->fetch_colum('DESCRIBE ' . $table_name, 0);
     $table_fields_type = $db->fetch_colum('DESCRIBE ' . $table_name, 1);
     $table_fields = array_combine($table_fields, $table_fields_type);
     $ready_update_str_arr = array();
     foreach ($table_fields as $key => $type) {
         if (isset($data[$key])) {
             $ready_update_str_arr[] = '`' . $key . '`=' . self::quotevalue($db, $data[$key], $type);
         }
     }
     if (count($ready_update_str_arr) > 0) {
         $update_str = implode(',', $ready_update_str_arr);
         $sql = 'UPDATE ' . $table_name . ' SET ' . $update_str;
         if (strlen($whereClause) > 0) {
             $sql .= ' WHERE ' . $whereClause;
         } else {
             logger::warning('全表更新被拦截' . $sql);
             return '';
         }
         return $sql;
     } else {
         return '';
     }
 }
Ejemplo n.º 3
0
 public function addAnimator($property, ILpfAnimator $animator, $frstart, $frend)
 {
     if (arr::hasKey($this->_properties, $property)) {
         $this->_animators[$property][] = array('animator' => $animator, 'framestart' => $frstart, 'frameend' => $frend);
         console::writeLn("Attached animator: %s => %s", typeOf($animator), $property);
     } else {
         logger::warning("Animator attached to nonexisting property %s of object %s", $property, (string) $this->_object);
     }
 }
Ejemplo n.º 4
0
 public function __get($property)
 {
     if (arr::hasKey($this->properties, $property)) {
         $propmeta = $this->properties[$property];
         if ($propmeta['propget']) {
             return $propmeta['propget']($property);
         } else {
             return $this->properties['value'];
         }
     } else {
         logger::warning("Ambient property %s requested object %s", $property, $this);
     }
 }
Ejemplo n.º 5
0
 public function exec($params = null)
 {
     $order_autocancel_day = app::get('b2c')->getConf('order_autofinish_day', 9);
     //天
     $mdl_orders = app::get('b2c')->model('orders');
     $limit = 200;
     //每次最多处理200条
     $filter = array('status' => 'active', 'pay_status' => '1', 'ship_status' => '1', 'createtime|lthan' => time() - $order_autocancel_day * 24 * 3600);
     foreach ($mdl_orders->getList('order_id', $filter, 0, $limit) as $key => $order) {
         $order['op_id'] = '-1';
         $order['op_name'] = '定时任务队列';
         if (!vmc::singleton('b2c_order_end')->generate($order, $msg)) {
             logger::warning('订单自动完成队列异常。ORDER_ID:' . $order['order_id'] . '。' . $msg);
         }
     }
     return false;
 }
Ejemplo n.º 6
0
 public function query($query = null, $debug = false)
 {
     if ($this->_dbo == null) {
         logger::error("dbo::query: A connection needs to be made with the db server first!");
         exit("Error: A connection needs to be made with the db server first!");
     }
     if ($query === null && $this->_query != "") {
         $query = $this->_query;
     } elseif ($query === null) {
         if ($this->_debug || $debug) {
             logger::warning("dbo::query: No SQL query was provided to execute.");
         }
         return false;
     }
     $this->_query = $query;
     $query = str_replace("##_", $this->_prefix, $query);
     logger::debug("dbo::query: query: {$query}");
     $this->_record_set = $this->_dbo->query($query);
     if ($this->_dbo->errno != 0) {
         logger::error("dbo::query: An error occured executing the query.");
         logger::error("The error is: '" . $this->_dbo->error . "'");
         exit("Error: The query failed. {$query}");
     }
     $this->result_count = $this->_dbo->affected_rows;
     if ($this->_dbo->errno != 0) {
         logger::error("dbo::query: An error occured calculating the number of results.");
         logger::error("The error is: '" . $this->_dbo->error . "'");
         exit("Error: Couldn't count the number of records.");
     }
     $this->fields = array();
     if (strtoupper(substr($query, 0, 6)) == "SELECT") {
         $temp = $this->_record_set->fetch_fields();
         foreach ($temp as $t) {
             $this->fields[] = $t->name;
         }
         if ($this->_dbo->errno != 0) {
             logger::error("dbo::query: An error occured fetching the fields of the result.");
             logger::error("The error is: '" . $this->_dbo->error . "'");
             exit("Error: Couldn't fetch the fields.");
         }
     }
     return $this->_record_set;
 }
Ejemplo n.º 7
0
 /**
  * 用于订单退货确认,并影响售后服务单.
  *
  * @params array - 退货单据数据SDF
  *
  * @return bool - 执行成功与否
  */
 public function exec($delivery_sdf, &$msg = '')
 {
     $mdl_as_request = $this->app->model('request');
     $req_order = $mdl_as_request->getRow('*', array('delivery_id' => $delivery_sdf['delivery_id']));
     if (!$req_order) {
         return true;
     }
     if ($req_order['status'] != '3' || $delivery_sdf['status'] != 'succ') {
         $msg = '不在退货处理流程中或错误的退货确认指令!';
         return false;
     }
     $req_order['status'] = '4';
     //退货成功,进入退款流程
     if ($mdl_as_request->save($req_order)) {
         return true;
     } else {
         $msg = '存在售后服务单据,售后服务单据状态更新异常!';
         logger::warning($msg . 'request_id:' . $req_order['request_id']);
         return false;
     }
 }
Ejemplo n.º 8
0
 /**
  * 用于订单退货确认,并影响售后服务单.
  *
  * @params array - 退货单据数据SDF
  *
  * @return bool - 执行成功与否
  */
 public function exec($bill_sdf, &$msg = '')
 {
     $mdl_as_request = $this->app->model('request');
     $req_order = $mdl_as_request->getRow('*', array('bill_id' => $bill_sdf['bill_id']));
     if (!$req_order) {
         return true;
     }
     if ($req_order['status'] != '4' || $bill_sdf['status'] != 'succ') {
         $msg = '不在售后退款流程内,或错误的退款单据状态!';
         return false;
     }
     $req_order['status'] = '5';
     //退款成功,完成售后流程
     if ($mdl_as_request->save($req_order)) {
         return true;
     } else {
         $msg = '存在售后服务单据,售后服务单据状态更新异常!';
         logger::warning($msg . 'request_id:' . $req_order['request_id']);
         return false;
     }
 }
Ejemplo n.º 9
0
 public function filter(&$filter, &$cart_result, $config = array())
 {
     // 取出符合当前购物车条件的规则(已经使用了conditions过滤)
     $this->_filter_rules($cart_result, $config);
     $this->used_rules = array('normal' => array(), 'coupon' => array());
     $rules_groups = array('normal' => $this->ready_normal_rules, 'coupon' => $this->ready_coupon_rules);
     foreach ($rules_groups as $key => $ready_type_items) {
         foreach ($ready_type_items as $rule) {
             if ($this->used_rules[$key][$rule['rule_id']]) {
                 continue;
             }
             /**
              * $cart_result 是引用传递,会在内部进行修改
              */
             if (!$this->_apply_order($cart_result, $rule, $save)) {
                 continue;
             }
             $solution = $rule['action_solution'];
             if (!$solution) {
                 continue;
             }
             reset($solution);
             $solution_class = key($solution);
             if (!$solution_class) {
                 logger::warning('优惠方案异常!' . var_export($rule, 1));
                 continue;
             }
             $this->_add_promotion_to_cart($solution_class, $rule, $cart_result, $key);
             $this->used_rules[$key][$rule['rule_id']] = true;
         }
     }
     foreach ($cart_result['objects']['coupon'] as &$coupon) {
         /**
          * @see line 200~210
          */
         if ($coupon['params']['in_use'] != 'true') {
             $coupon['params']['warning'] = '优惠券未被成功使用!';
         }
     }
 }
Ejemplo n.º 10
0
 /**
  *_error 记录错误和警告log
  *
  * @param string $query_sql 执行的sphinxql语句
  * @access public
  */
 public function _error($query_sql)
 {
     $br = "\r\n\t\t\t\t";
     $msg = 'sphinxql执行错误:' . $query_sql;
     if (mysql_error()) {
         $error = mysql_error();
         $msg .= $br . 'ERROR :' . $error;
         throw new Exception($msg);
     }
     $warnings = $this->query('SHOW WARNINGS');
     if ($warnings) {
         foreach ($warnings as $row) {
             $msg .= $br . 'WARNING (' . $row['Code'] . '):' . $row['Message'];
         }
         logger::warning($msg);
     }
 }
Ejemplo n.º 11
0
 /**
  * delete.
  *
  * 根据条件删除条目
  * 不可以由pipe控制
  * 可以广播事件
  *
  * @param mixed $filter
  * @param mixed $named_action
  */
 public function delete($filter)
 {
     $where_sql = $this->filter($filter);
     $sql = 'DELETE FROM `' . $this->table_name(1) . '` where ' . $where_sql;
     if (!stripos($where_sql, 'AND')) {
         logger::warning('全表删除操作被拦截!SQL:' . $sql);
         return false;
     }
     if ($this->db->exec($sql, $this->skipModifiedMark)) {
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 12
0
 /*
 	Wait for a valid event occurs that we can process, OR
 	up to the timeout limit, in which case we then go and
 	check if there's anything in the message queue that
 	needs processing
 */
 $payloads = $conn->processUntil(array('message', 'presence', 'end_stream', 'session_start'), MESSAGE_TIMEOUT_SECONDS);
 foreach ($payloads as $event) {
     $pl = $event[1];
     switch ($event[0]) {
         case 'message':
             // check sender - we only allow messages from the configured recipient
             if (preg_match("/^{$config[$section]["xmpp_reciever"]}\\/\\w\$/", $pl["from"])) {
                 // denied
                 $conn->message($pl["from"], $body = "Sorry you are not a user whom is permitted to talk with me. :-(");
                 $log->warning("[{$section}] Denied connection attempt from {$pl["from"]}, only connections from {$config[$section]["xmpp_reciever"]} are permitted");
                 break;
             }
             // trim whitespace from message
             $pl["body"] = trim($pl["body"]);
             // process message
             switch ($pl["body"]) {
                 case "_help":
                 case "_about":
                 case "_license":
                 case "_version":
                     /*
                     	User help & application status
                     */
                     $help = array();
                     $help[] = "" . APP_NAME . " (" . APP_VERSION . ")";
Ejemplo n.º 13
0
 public static function registerFactory(LoggerFactory $factory)
 {
     foreach (self::$_loggers as $logger) {
         if (typeOf($logger) == typeOf($factory)) {
             logger::warning('Attempting to register logger %s twice', typeOf($factory));
             return;
         }
     }
     self::$_loggers[] = $factory;
 }
Ejemplo n.º 14
0
 public function error_handle($code, $msg, $file, $line)
 {
     if ($code == ($code & (E_ERROR ^ E_USER_ERROR ^ E_USER_WARNING))) {
         if ($code == ($code & (E_ERROR ^ E_USER_ERROR))) {
             logger::error(sprintf('ERROR:%d @ %s @ file:%s @ line:%d', $code, $msg, $file, $line));
             exit;
         }
         logger::warning(sprintf('WARNING:%d @ %s @ file:%s @ line:%d', $code, $msg, $file, $line));
     }
     return true;
 }
Ejemplo n.º 15
0
 /**
  * 优惠券使用日志记录.
  */
 public function couponlog($params, &$msg)
 {
     if (!$params || !is_array($params) || empty($params['member_id']) || empty($params['order_id']) || empty($params['order_total']) || empty($params['coupon_save']) || empty($params['memc_code']) || empty($params['cpns_name']) || empty($params['cpns_id'])) {
         $msg = '优惠券日志记录缺少参数!';
         logger::warning($msg . $member_id . '|' . $memc_code . '|' . $order_id);
         return false;
     }
     $new_member_couponlog = array_merge($params, array('usetime' => time()));
     logger::debug('优惠券日志记录成功' . var_export($new_member_couponlog, 1));
     $this->app->model('member_couponlog')->save($new_member_couponlog);
     return true;
 }
Ejemplo n.º 16
0
 /**
  * 准备跳转到支付平台.
  *
  * @param mixed $order_id 订单编号
  * @param $recursive 递归调用标记
  */
 public function dopayment($order_id, $recursive = false)
 {
     $redirect = $this->gen_url(array('app' => 'b2c', 'ctl' => 'mobile_member', 'act' => 'orders'));
     $obj_bill = vmc::singleton('ectools_bill');
     $mdl_bills = app::get('ectools')->model('bills');
     $order = $this->app->model('orders')->dump($order_id);
     if ($order['pay_status'] == '1' || $order['pay_status'] == '2') {
         $this->splash('success', $redirect, '已支付');
     }
     if (in_array($order['pay_app'], array('cod', 'offline'))) {
         $this->splash('error', $redirect, '不是在线支付方式');
     }
     if ($this->app->member_id != $order['member_id']) {
         $this->splash('error', $redirect, '非法操作');
     }
     //未交互过的账单复用
     $bill_sdf = array('order_id' => $order['order_id'], 'bill_type' => 'payment', 'pay_mode' => 'online', 'pay_object' => 'order', 'money' => $order['order_total'] - $order['payed'], 'member_id' => $order['member_id'], 'status' => 'ready', 'pay_app_id' => $order['pay_app'], 'pay_fee' => $order['cost_payment'], 'memo' => $order['memo']);
     $exist_bill = $mdl_bills->getRow('*', $bill_sdf);
     //一天内重复利用原支付单据
     if ($exist_bill && !empty($exist_bill['bill_id']) && $exist_bill['createtime'] + 86400 > time()) {
         $bill_sdf = array_merge($exist_bill, $bill_sdf);
     } else {
         $bill_sdf['bill_id'] = $mdl_bills->apply_id($bill_sdf);
     }
     $bill_sdf['return_url'] = $this->gen_url(array('app' => 'b2c', 'ctl' => 'mobile_checkout', 'act' => 'payresult', 'args' => array($bill_sdf['bill_id'])));
     //微信内支付时,需要静默授权,以获得用户openid
     if (base_mobiledetect::is_wechat() && $order['pay_app'] == 'wxpay' && empty($bill_sdf['payer_account'])) {
         $wxpay_setting = unserialize(app::get('ectools')->getConf('wechat_payment_applications_wxpay'));
         $wxpay_appid = $wxpay_setting['appid'];
         $wxpay_appsecret = $wxpay_setting['appsecret'];
         $auth_code = $_GET['code'];
         $auth_state = $_GET['state'];
         if (!$recursive) {
             $oauth_redirect = $this->gen_url(array('app' => 'b2c', 'ctl' => 'mobile_checkout', 'act' => 'dopayment', 'args' => array($order_id, 'recursive'), 'full' => 1));
             $oauth_redirect = urlencode($oauth_redirect);
             $oauth_action = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$wxpay_appid}&redirect_uri={$oauth_redirect}&response_type=code&scope=snsapi_base&state={$order_id}#wechat_redirect";
             logger::debug('微信snsapi_base URL:' . $oauth_action);
             $this->redirect($oauth_action);
             //静默授权
         } elseif ($recursive && $auth_code && $auth_state == $order_id) {
             //把微信用户openid 记录到支付单据中
             $auth_token = vmc::singleton('base_httpclient')->get("https://api.weixin.qq.com/sns/oauth2/access_token?appid={$wxpay_appid}&secret={$wxpay_appsecret}&code={$auth_code}&grant_type=authorization_code");
             $auth_token = json_decode($auth_token, 1);
             if (!$auth_token['openid']) {
                 logger::warning('微信静默授权失败!' . var_export($auth_token, 1));
                 $this->splash('error', $redirect, '暂无法进行微信内支付。');
             }
             $bill_sdf['payer_account'] = $auth_token['openid'];
         } else {
             logger::warning('微信静默授权失败!order_id:' . $order_id . '|' . var_export($_GET, 1));
         }
     }
     try {
         if (!$obj_bill->generate($bill_sdf, $msg)) {
             $this->splash('error', $redirect, $msg);
         }
     } catch (Exception $e) {
         $this->splash('error', $redirect, $e->getMessage());
     }
     $get_way_params = $bill_sdf;
     if (!vmc::singleton('ectools_payment_api')->redirect_getway($get_way_params, $msg)) {
         $this->splash('error', $redirect, $msg);
     }
     //here we go to the platform
 }
Ejemplo n.º 17
0
function __deprecated($oldfunc, $newfunc = null)
{
    $stack = debug_backtrace(false);
    $method = $stack[1];
    if (!isset($method['file'])) {
        $caller = sprintf("%s%s%s (%s:%d)", $method['class'], $method['type'], $method['function'], '???', 0);
    } else {
        if (isset($method['type'])) {
            $caller = sprintf("%s%s%s (%s:%d)", $method['class'], $method['type'], $method['function'], str_replace(SYS_PATH, '', $method['file']), $method['line']);
        } else {
            $caller = sprintf("%s (%s:%d)", $method['function'], str_replace(SYS_PATH, '', $method['file']), $method['line']);
        }
    }
    // todo: add strict option to make deprecation warnings fatal
    if ($newfunc) {
        logger::warning('%s: Function %s is deprecated in favor of %s', $caller, $oldfunc, $newfunc);
        $msg = sprintf('%s: Function %s is deprecated in favor of %s', $caller, $oldfunc, $newfunc);
    } else {
        logger::warning('%s. Function %s is deprecated', $caller, $oldfunc);
        $msg = sprintf('%s. Function %s is deprecated', $caller, $oldfunc);
    }
    @trigger_error($msg, E_USER_DEPRECATED);
    if (config::get('lepton.base.strict', false) == true) {
        throw new BaseException($msg);
    }
}
Ejemplo n.º 18
0
 /**
  * 通过json 进行演示数据安装.
  *
  * @param $app_id
  * @param $model
  * @param $data_arr php 表数组
  */
 public function init_json($app_id, $model, $data_arr)
 {
     $table_name = 'vmc_' . $app_id . '_' . $model;
     $ct_arr = app::get('base')->getConf('init_demo_complete');
     if (!$ct_arr || !is_array($ct_arr)) {
         $ct_arr = array();
     }
     if (in_array($table_name, $ct_arr)) {
         logger::info($table_name . ' Has insert Demodata.');
         return true;
     }
     logger::info('Inserting Datatable ' . $table_name . ' Start...');
     $db = vmc::database();
     $ts = $db->beginTransaction();
     foreach ($data_arr as $sdf) {
         if (!app::get($app_id)->model($model)->db_save($sdf)) {
             $db->rollback();
             logger::warning('出现异常!' . $table_name . 'DEMO数据导入失败!');
             return fasle;
         }
     }
     $ct_arr[] = $table_name;
     app::get('base')->setConf('init_demo_complete', $ct_arr);
     $db->commit($ts);
     logger::info('Inserting Datatable ' . $table_name . ' Complete!');
 }
Ejemplo n.º 19
0
 static function handleError($errno, $errstr, $errfile, $errline, $errcontext = null)
 {
     $args = func_get_args();
     if (self::$__errorhandler) {
         return call_user_func_array(self::$__errorhandler, $args) == true;
     } else {
         // Chain PHPs error handling
         switch ($errno) {
             case E_STRICT:
                 logger::debug('Warning: %s:%d %s', str_replace(base::basePath(), '', $errfile), $errline, $errstr);
                 break;
             case E_DEPRECATED:
                 // Disable showing deprecation warnings for now
                 break;
                 logger::warning('Deprecated: %s:%d %s', str_replace(base::basePath(), '', $errfile), $errline, $errstr);
                 break;
             default:
                 logger::warning('%s:%d %s', str_replace(base::basePath(), '', $errfile), $errline, $errstr);
                 break;
         }
         return true;
     }
 }
Ejemplo n.º 20
0
 private function getColType($type, $flags)
 {
     list($type, $constrain) = explode(':', $type . ':');
     switch (strtolower($type)) {
         case 'int':
             if ($constrain) {
                 $otype = sprintf('INT(%d)', $constrain);
             } else {
                 $otype = 'int';
             }
             if ($flags & SqlTableSchema::COL_AUTO) {
                 $otype .= ' AUTO_INCREMENT';
             }
             break;
         case 'char':
         case 'varchar':
         case 'text':
             if ($constrain) {
                 if ($flags & SqlTableSchema::COL_FIXED) {
                     $otype = sprintf('CHAR(%d)', $constrain);
                 } else {
                     $otype = sprintf('VARCHAR(%d)', $constrain);
                 }
             } else {
                 if ($flags & SqlTableSchema::COL_BINARY) {
                     $otype = sprintf('BLOB');
                 } else {
                     $otype = sprintf('TEXT');
                 }
             }
             break;
         case 'enum':
             $cl = explode(',', $constrain);
             $cls = '';
             foreach ($cl as $c) {
                 if (strlen($cls) > 0) {
                     $cls .= ',';
                 }
                 $cls .= "'" . $c . "'";
             }
             $otype = 'ENUM(' . $cls . ')';
             break;
         default:
             logger::warning("Unhandled field type: %s", $type);
             $otype = '';
     }
     // Check nullable state
     if ($flags & SqlTableSchema::COL_NULLABLE) {
         $otype .= ' NULL';
     } else {
         $otype .= ' NOT NULL';
     }
     // Keys
     if ($flags & SqlTableSchema::KEY_PRIMARY) {
         $otype .= ' PRIMARY KEY';
     }
     if ($flags & SqlTableSchema::KEY_UNIQUE) {
         $otype .= ' UNIQUE KEY';
     }
     return $otype;
 }
Ejemplo n.º 21
0
 public function command_kvrecovery($instance = null)
 {
     if (app::get('base')->status() == 'uninstalled') {
         logger::info('系统未安装!请先运行install');
         return;
     }
     base_kvstore::config_persistent(false);
     //临时禁用KV持久化 TODO 比较危险
     $testObj = base_kvstore::instance('test');
     if (get_class($testObj->get_controller()) === 'base_kvstore_mysql') {
         logger::info('The \'base_kvstore_mysql\' is default persistent, Not necessary recovery');
         exit;
     }
     logger::info('KVrecovery BEGIN...');
     $db = vmc::database();
     $count = $db->count('SELECT count(*) AS count FROM vmc_base_kvstore', true);
     if (empty($count)) {
         logger::info('No data recovery');
         exit;
     }
     $pagesize = 100;
     $page = ceil($count / 100);
     for ($i = 0; $i < $page; $i++) {
         $rows = $db->selectlimit('SELECT * FROM vmc_base_kvstore', $pagesize, $i * $pagesize);
         foreach ($rows as $row) {
             $arr_value = unserialize($row['value']);
             if (!$arr_value || !is_array($arr_value)) {
                 logger::error($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery ERROR');
             }
             $row['value'] = $arr_value;
             if (base_kvstore::instance($row['prefix'])->recovery($row)) {
                 logger::info($row['prefix'] . '=>' . $row['key'] . ' ... KVrecovery Success');
             } else {
                 logger::warning($row['prefix'] . '=>' . $row['key'] . ' ... KVrcovery Failure');
             }
         }
     }
     logger::info('KVrecovery END...');
 }
Ejemplo n.º 22
0
 public function index()
 {
     $this->load->model('account/customer');
     // Login override for admin users
     if (!empty($this->request->get['token'])) {
         //$this->customer->logout();
         $this->cart->clear();
         unset($this->session->data['wishlist']);
         unset($this->session->data['shipping_address_id']);
         unset($this->session->data['shipping_country_id']);
         unset($this->session->data['shipping_zone_id']);
         unset($this->session->data['shipping_postcode']);
         unset($this->session->data['shipping_method']);
         unset($this->session->data['shipping_methods']);
         unset($this->session->data['payment_address_id']);
         unset($this->session->data['payment_country_id']);
         unset($this->session->data['payment_zone_id']);
         unset($this->session->data['payment_method']);
         unset($this->session->data['payment_methods']);
         unset($this->session->data['comment']);
         unset($this->session->data['order_id']);
         unset($this->session->data['coupon']);
         unset($this->session->data['reward']);
         unset($this->session->data['voucher']);
         unset($this->session->data['vouchers']);
         $customer_info = $this->model_account_customer->getCustomerByToken($this->request->get['token']);
         if ($customer_info && $this->customer->login($customer_info['email'], '', true)) {
             // Default Addresses
             $this->load->model('account/address');
             $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
             if ($address_info) {
                 if ($this->config->get('config_tax_customer') == 'shipping') {
                     $this->session->data['shipping_country_id'] = $address_info['country_id'];
                     $this->session->data['shipping_zone_id'] = $address_info['zone_id'];
                     $this->session->data['shipping_postcode'] = $address_info['postcode'];
                 }
                 if ($this->config->get('config_tax_customer') == 'payment') {
                     $this->session->data['payment_country_id'] = $address_info['country_id'];
                     $this->session->data['payment_zone_id'] = $address_info['zone_id'];
                 }
             } else {
                 unset($this->session->data['shipping_country_id']);
                 unset($this->session->data['shipping_zone_id']);
                 unset($this->session->data['shipping_postcode']);
                 unset($this->session->data['payment_country_id']);
                 unset($this->session->data['payment_zone_id']);
             }
             //$this->redirect($this->url->link('account/account', '', 'SSL'));
             logger::warning('customer validated, should be logged in now');
         } else {
             logger::warning('customer_info empty or not validated by this-customer-login');
         }
     }
     if ($this->customer->isLogged()) {
         $this->redirect($this->url->link('account/account', '', 'SSL'));
     }
     $this->document->setTitle(Language::getVar('SUMO_ACCOUNT_LOGIN_TITLE'));
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         unset($this->session->data['guest']);
         // Default Shipping Address
         $this->load->model('account/address');
         $address_info = $this->model_account_address->getAddress($this->customer->getAddressId());
         if ($address_info) {
             if ($this->config->get('config_tax_customer') == 'shipping') {
                 $this->session->data['shipping_country_id'] = $address_info['country_id'];
                 $this->session->data['shipping_zone_id'] = $address_info['zone_id'];
                 $this->session->data['shipping_postcode'] = $address_info['postcode'];
             }
             if ($this->config->get('config_tax_customer') == 'payment') {
                 $this->session->data['payment_country_id'] = $address_info['country_id'];
                 $this->session->data['payment_zone_id'] = $address_info['zone_id'];
             }
         } else {
             unset($this->session->data['shipping_country_id']);
             unset($this->session->data['shipping_zone_id']);
             unset($this->session->data['shipping_postcode']);
             unset($this->session->data['payment_country_id']);
             unset($this->session->data['payment_zone_id']);
         }
         if (isset($this->request->post['ajax'])) {
             exit('OK');
         } else {
             if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('base_http')) !== false || strpos($this->request->post['redirect'], $this->config->get('base_https')) !== false)) {
                 $this->redirect(str_replace('&amp;', '&', $this->request->post['redirect']));
             } else {
                 $this->redirect($this->url->link('account/account', '', 'SSL'));
             }
         }
     }
     if (isset($this->request->post['ajax'])) {
         exit(Language::getVar('SUMO_ACCOUNT_ERROR_LOGIN_INVALID'));
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => Language::getVar('SUMO_NOUN_HOME'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => Language::getVar('SUMO_ACCOUNT_TITLE'), 'href' => $this->url->link('account/account', '', 'SSL'));
     $this->data['breadcrumbs'][] = array('text' => Language::getVar('SUMO_ACCOUNT_LOGIN_TITLE'), 'href' => $this->url->link('account/login', '', 'SSL'));
     $this->data['warning'] = '';
     if (isset($this->error['warning'])) {
         $this->data['warning'] = $this->error['warning'];
     }
     $this->data['action'] = $this->url->link('account/login', '', 'SSL');
     $this->data['register'] = $this->url->link('account/register', '', 'SSL');
     $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
     $this->data['redirect'] = '';
     if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], $this->config->get('base_http')) !== false || strpos($this->request->post['redirect'], $this->config->get('base_https')) !== false)) {
         $this->data['redirect'] = $this->request->post['redirect'];
     } elseif (isset($this->session->data['redirect'])) {
         $this->data['redirect'] = $this->session->data['redirect'];
         unset($this->session->data['redirect']);
     }
     $this->data['success'] = '';
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     }
     $this->data['email'] = '';
     if (isset($this->request->post['email'])) {
         $this->data['email'] = $this->request->post['email'];
     }
     $this->data['settings'] = $this->config->get('details_account_' . $this->config->get('template'));
     if (!is_array($this->data['settings']) || !count($this->data['settings'])) {
         $this->data['settings']['left'][] = $this->getChild('app/widgetsimplesidebar/', array('type' => 'accountTree', 'data' => array()));
     }
     $this->template = 'account/login.tpl';
     $this->children = array('common/footer', 'common/header');
     $this->response->setOutput($this->render());
 }