Example #1
0
<?php

require_once '../inc/autoload.php';
if (isset($_POST['qty']) && isset($_POST['id'])) {
    $out = array();
    $id = $_POST['id'];
    $val = $_POST['qty'];
    $objCatalogue = new Catalogue();
    $product = $objCatalogue->getProduct($id);
    if (!empty($product)) {
        switch ($val) {
            case 0:
                Session::removeItem($id);
                break;
            default:
                Session::setItem($id, $val);
        }
    }
}
Example #2
0
function register($username, $email, $password, $antispam = '')
{
    global $hndb, $lang, $loc, $responseMsg, $hnauth;
    $session = new Session();
    $db = DB::getInstance();
    $username = $db->filter($username);
    $email = $db->filter($email);
    $password = $db->filter($password);
    if ($antispam !== '') {
        return false;
    } else {
        if (_checkExist($username, 'username')) {
            $responseMsg['hnauth'] = $lang['hnauth'][$loc]['username_already_exist'];
            return false;
        } else {
            if (strlen($username) == 0 || strlen($password) == 0 || strlen($email) == 0) {
                $responseMsg['hnauth'] = $lang['hnauth'][$loc]['all_fields_required'];
                return false;
            } else {
                if (strlen($username) > 30) {
                    $responseMsg['hnauth'] = $lang['hnauth'][$loc]['username_too_long'];
                    return false;
                } else {
                    if (strlen($username) < 3) {
                        $responseMsg['hnauth'] = $lang['hnauth'][$loc]['username_too_short'];
                        return false;
                    } else {
                        if (strlen($password) > 100) {
                            $responseMsg['hnauth'] = $lang['hnauth'][$loc]['password_too_long'];
                            return false;
                        } else {
                            if (strlen($password) < 8) {
                                $responseMsg['hnauth'] = $lang['hnauth'][$loc]['password_too_short'];
                                return false;
                            } else {
                                if (!_validateUsername($username)) {
                                    $responseMsg['hnauth'] = $lang['hnauth'][$loc]['username_invalid'];
                                    return false;
                                } else {
                                    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                                        $responseMsg['hnauth'] = $lang['hnauth'][$loc]['email_invalid'];
                                        return false;
                                    } else {
                                        $hash_password = _hashPassword($password);
                                        $data = array('username' => $username, 'password' => $hash_password, 'email' => $email);
                                        $add_query = $db->insert($hndb['table'], $data);
                                        if ($add_query) {
                                            $session->setItem('username', $username);
                                            $session->setItem('userlevel', $hnauth['default_userlevel']);
                                            $session->save();
                                            return true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Example #3
0
<?php

require_once '../inc/autoload.php';
if (isset($_POST['job']) && isset($_POST['id'])) {
    $out = array();
    $job = $_POST['job'];
    $id = $_POST['id'];
    $objCatalogue = new Catalogue();
    $product = $objCatalogue->getProduct($id);
    if (!empty($product)) {
        switch ($job) {
            case 0:
                Session::removeItem($id);
                $out['job'] = 1;
                break;
            case 1:
                Session::setItem($id);
                $out['job'] = 0;
                break;
        }
        echo json_encode($out);
    }
}