Beispiel #1
0
 $numrows = query_numrows("SELECT `clientid` FROM `" . DBPREFIX . "client` WHERE `username` = '" . $username . "' AND `password` = '" . $password . "' AND `status` = 'Active'");
 if ($numrows == 1) {
     $rows = query_fetch_assoc("SELECT `clientid`, `username`, `firstname`, `lastname`, `lang` FROM `" . DBPREFIX . "client` WHERE `username` = '" . $username . "' AND `password` = '" . $password . "' AND `status` = 'Active'");
     //Retrieve information from database
     ###
     query_basic("UPDATE `" . DBPREFIX . "client` SET `lastlogin` = '" . date('Y-m-d H:i:s') . "', `lastip` = '" . $_SERVER['REMOTE_ADDR'] . "', `lasthost` = '" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "' WHERE `clientid` = '" . $rows['clientid'] . "'");
     //Update last connection and so on
     ###
     //Creation of the session's information
     $_SESSION['clientid'] = $rows['clientid'];
     $_SESSION['clientusername'] = $rows['username'];
     $_SESSION['clientfirstname'] = $rows['firstname'];
     $_SESSION['clientlastname'] = $rows['lastname'];
     $_SESSION['clientlang'] = $rows['lang'];
     ###
     validateClient();
     ###
     //Cookie
     if (isset($_POST['rememberMe'])) {
         setcookie('clientUsername', htmlentities($username, ENT_QUOTES), time() + 86400 * 7 * 2);
         // 86400 = 1 day
     } else {
         if (isset($_COOKIE['clientUsername'])) {
             setcookie('clientUsername', htmlentities($username, ENT_QUOTES), time() - 3600);
             // Remove the cookie
         }
     }
     setcookie('clientLanguage', htmlentities($rows['lang'], ENT_QUOTES), time() + 86400 * 7 * 2);
     // 86400 = 1 day
     ###
     if (!empty($_SESSION['loginattempt'])) {
        break;
    }
}
if (Configuration::get('PIGMBH_PAYMILL_FASTCHECKOUT')) {
    if (Tools::getValue('payment') == 'creditcard') {
        $sql = 'SELECT `clientId`,`paymentId` FROM `pigmbh_paymill_creditcard_userdata` WHERE `userId`=' . $cart->id_customer;
    } elseif (Tools::getValue('payment') == 'debit') {
        $sql = 'SELECT `clientId`,`paymentId` FROM `pigmbh_paymill_directdebit_userdata` WHERE `userId`=' . $cart->id_customer;
    }
    try {
        $dbData = $db->getRow($sql);
    } catch (Exception $exception) {
        $dbData = false;
    }
}
if ($dbData && validateClient($dbData['clientId'])) {
    $clientObject = new Services_Paymill_Clients(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), "https://api.paymill.com/v2/");
    $oldClient = $clientObject->getOne($dbData['clientId']);
    if ($customer["email"] !== $oldClient['email']) {
        $clientObject->update(array('id' => $dbData['clientId'], 'email' => $customer["email"]));
    }
}
$payment = false;
if ($dbData && validatePayment($dbData['paymentId'])) {
    $paymentObject = new Services_Paymill_Payments(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), "https://api.paymill.com/v2/");
    $paymentResponse = $paymentObject->getOne($dbData['paymentId']);
    if ($paymentResponse['id'] === $dbData['paymentId']) {
        $payment = $dbData['paymentId'] !== '' ? $paymentResponse : false;
    }
    $payment['expire_date'] = null;
    if (isset($payment['expire_month'])) {