Example #1
0
function main()
{
    // Login Form
    if (isset($_POST['login'])) {
        // handle login
        $email = $_POST['email'];
        $password = sha1($_POST['password']);
        $sql = "SELECT * FROM `customers` WHERE `customer_email`='{$email}' AND `customer_password`='{$password}';";
        $result = dbQuery($sql);
        if (mysql_num_rows($result) != 1) {
            $url = BASE_URL . '/signup';
            //@todo create error message
            addMessage('نام کاربری یا رمز عبور اشتباه وارد شده است.', FAILURE);
        } else {
            $user = mysql_fetch_assoc($result);
            //@todo save user id in session
            //@todo create welcome message
            $url = BASE_URL . '/customer';
            $spKey = getSpKey();
            $_SESSION[$spKey]['customer'] = $user['id'];
            $userName = $user['customer_name'];
            addMessage($userName . ' عزیز خوش آمدید.', SUCSESS);
        }
        mysql_free_result($result);
        return array('redirect' => $url);
    }
    // SignUp Form
    if (isset($_POST['signup'])) {
        $firstName = safeQuery($_POST['firstName']);
        $lastName = safeQuery($_POST['lastName']);
        $mobile = safeQuery($_POST['mobile']);
        $email = safeQuery($_POST['email']);
        $password = sha1($_POST['password']);
        $gender = $_POST['gender'];
        if (isPhone($mobile) && isEmail($email) && !empty(trim($firstName)) && !empty(trim($lastName)) && !empty(trim($mobile)) && !empty(trim($email)) && !empty(trim($password))) {
            $sql = "SELECT * FROM `customers` WHERE  `customer_email`='{$email}'";
            $result = dbQuery($sql);
            if (mysql_num_rows($result) == 0) {
                $sql = "INSERT INTO `customers`(`customer_name`,`customer_family`,`customer_email`,`customer_password`,`customer_gender`,`customer_mobile`)\n                                        VALUES('{$firstName}','{$lastName}','{$email}','{$password}','{$gender}','{$mobile}')";
                $result = dbQuery($sql);
                addMessage('ثبت نام شما با موفقیت انجام شد. با آدرس ایمیل و رمز عور انتخابی وارد شوید', SUCSESS);
                $url = BASE_URL . '/customer';
            } else {
                $url = BASE_URL . '/signup';
                //@todo create error message
                addMessage('آدرس ایمیل واد شده تکراری میباشد، برای بازیابی رمز عبور کلیک کنید.', FAILURE);
            }
            mysql_free_result($result);
        } else {
            $url = BASE_URL . '/signup';
            //@todo create error message
            addMessage('اطلاعات فرم ثبت نام به درستی وارد نشده است.', FAILURE);
        }
        return array('redirect' => $url);
    }
}
Example #2
0
 function _isValidPhone($phone)
 {
     if (!isPhone($phone)) {
         $this->form_validation->set_message('_isValidPhone', 'Please enter valid phone number!');
         return FALSE;
     } else {
         return TRUE;
     }
 }
Example #3
0
			</div>
		</div>
	</section>
	<section id="siteMap" class="fullbg row4">
		<div class="bg"></div>
		<div class="wrapper">
			<header class="txtImg_title-title-map <?php 
isPhone('mobile_title-group');
?>
">
				<h1 class="hidden <?php 
isPhone('mobile_title');
?>
 title-1" data-lang="en">Site Map</h1>
				<h2 class="hidden <?php 
isPhone('mobile_title');
?>
 title-2" data-lang="tw">網站地圖</h2>
			</header>
			<div class="sitemap-sec cnt cf">
				<div class="col-2">
					<ul>
						<li>
							<a href="<?php 
webPageUrlAu('index');
?>
" class="txt-1">首頁 Home Page</a>
						</li>
						<li>
							<a href="<?php 
webPageUrlAu('about');
Example #4
0
                 {
                    
 	$log .= "<li>Не дійсний email!</li>";
 	$error = "yes";
                 }
 */
 //Проверка Phone
 function isPhone($posPhone)
 {
     return preg_match("/^[0-9]{10,10}+\$/", $posPhone);
 }
 if ($posPhone == '') {
     $log .= "<li>Введіть телефон!</li>";
     $error = "yes";
 } else {
     if (!isPhone($posPhone)) {
         $log .= "<li>Не дійсний телефон!</li>";
         $error = "yes";
     }
 }
 //Проверка наличия введенного текста комментария
 if (empty($posText)) {
     $log .= "<li>Введіть повідомлення!</li>";
     $error = "yes";
 }
 //Проверка длины текста комментария
 if (strlen($posText) > 1010) {
     $log .= "<li>Текст максимально 1000 символів!</li>";
     $error = "yes";
 }
 //Проверка на наличие длинных слов
function assignLocalC($row, $civiOps, $updated, $civiContactId, $civiMemberId)
{
    global $dbConn;
    // Base
    global $civicrm_contact;
    // Membership#
    global $civicrm_membership;
    global $civicrm_membership_status;
    // Membership changes
    global $civicrm_membership_log;
    // email
    global $civicrm_email;
    // addres
    global $civicrm_address;
    // phone
    global $civicrm_phone;
    // Membership card#
    global $civicrm_value_identification_and_cred;
    // Datestamp
    global $civicrm_log;
    global $adminId;
    /* SQL DML statements
     */
    global $insertContact;
    global $insertMembership;
    global $insertMembershipLog;
    global $insertEmail;
    global $insertAddress;
    global $insertPhone;
    global $insertMemberCard;
    global $insertLog;
    global $updateContact;
    global $updateMembership;
    global $updateEmail;
    global $updateAddress;
    global $updatePhone;
    global $updateMemberCard;
    global $updateLog;
    global $memberCardTable;
    global $memberCardField;
    // #'u
    /* In general:
     * - Use the civicrm_* array elements for prepared versions of the data for that table.
     * - Assign prepared versions of the data for that table to the civicrm_* array elements.
     * - Test civiOps[table_name] for whether to prepare an insert or update.
     * - Compose the statement and assign/append it to the statement list for that table.
     * - Create a civicrm_log record (datestamp) to match the IS4C datestamp.
     */
    // 1/0. 1 prevents any communication.
    $civicrm_contact[is_opt_out] = $row[ads_OK] == 0 ? 1 : 0;
    if ($row[pref] == 0) {
        $civicrm_contact[do_not_email] = 1;
        //$civicrm_contact[do_not_phone] = 1;
        $civicrm_contact[do_not_mail] = 1;
    } elseif ($row[pref] == 1) {
        $civicrm_contact[do_not_email] = 1;
        $civicrm_contact[do_not_mail] = 0;
        // 2 is usual and at WEFC probably means nothing either way about postalmail
    } elseif ($row[pref] == 2) {
        $civicrm_contact[do_not_email] = 0;
        $civicrm_contact[do_not_mail] = 0;
    } elseif ($row[pref] == 3) {
        $civicrm_contact[do_not_email] = 0;
        $civicrm_contact[do_not_mail] = 0;
    } else {
        1;
    }
    // Community Partner or Producer: organizations.
    // IS4C convention s/b: LastName = Organization, FirsName = "" or "Joe Bloggs"
    if ($row[memType] == 3 || $row[memType] == 5) {
        $civicrm_contact[contact_type] = "Organization";
        $civicrm_contact[organization_name] = $row[LastName];
        // Better to split FirstName on " " and assign to both first_name and last_name?
        $civicrm_contact[first_name] = $row[FirstName];
        if ($row[LastName] != "") {
            $civicrm_contact[sort_name] = $row[LastName];
            $civicrm_contact[display_name] = $row[LastName];
        } elseif ($row[email_1] != "") {
            $civicrm_contact[sort_name] = $row[email_1];
            $civicrm_contact[display_name] = $row[email_1];
        } else {
            1;
        }
    } elseif ($row[memType] == 4 || $row[memType] == 6 || $row[FirstName] != "") {
        $civicrm_contact[contact_type] = "Individual";
        list($first, $middle) = explode("|", $row[FirstName]);
        $civicrm_contact[first_name] = $first;
        $civicrm_contact[middle_name] = $middle;
        $civicrm_contact[last_name] = $row[LastName];
        $row[FirstName] = str_replace("|", " ", $row[FirstName]);
        if ($row[LastName] != "") {
            $civicrm_contact[sort_name] = "{$row[LastName]}, {$row[FirstName]}";
            $civicrm_contact[display_name] = "{$row[FirstName]} {$row[LastName]}";
        } elseif ($row[email_1] != "") {
            $civicrm_contact[sort_name] = $row[email_1];
            $civicrm_contact[display_name] = $row[email_1];
        } else {
            1;
        }
    } else {
        // Unknown memType, or 1.  Does 1 ever happen? Is not offered in Civi but is in IS4C.
        // c.memType :: _membership.membership_type_id
        1;
    }
    // id is auto_increment.
    if ($civiOps[civicrm_contact] == "insert") {
        $insertContact = "INSERT INTO civicrm_contact\n        (id\n        , source\n        , first_name, middle_name, last_name\n        , organization_name, sort_name, display_name\n        , is_opt_out\n        , do_not_email , do_not_mail\n        )\n        VALUES\n        (''\n        , {$dbConn->escape($civicrm_contact[contact_type])}\n        , {$dbConn->escape($civicrm_contact[source])}\n        , {$dbConn->escape($civicrm_contact[first_name])}\n        , {$dbConn->escape($civicrm_contact[middle_name])}\n        , {$dbConn->escape($civicrm_contact[last_name])}\n        , {$dbConn->escape($civicrm_contact[organization_name])}\n        , {$dbConn->escape($civicrm_contact[sort_name])}\n        , {$dbConn->escape($civicrm_contact[display_name])}\n        , {$civicrm_contact['is_opt_out']}\n        , {$civicrm_contact['do_not_email']}\n        , {$civicrm_contact['do_not_mail']}\n        )";
    } else {
        $updateContact = "UPDATE civicrm_contact\n        SET\n            contact_type = {$dbConn->escape($civicrm_contact[contact_type])}\n            , first_name = {$dbConn->escape($civicrm_contact[first_name])}\n            , middle_name = {$dbConn->escape($civicrm_contact[middle_name])}\n            , last_name = {$dbConn->escape($civicrm_contact[last_name])}\n            , organization_name = {$dbConn->escape($civicrm_contact[organization_name])}\n            , sort_name = {$dbConn->escape($civicrm_contact[sort_name])}\n            , display_name = {$dbConn->escape($civicrm_contact[display_name])}\n            , is_opt_out = {$civicrm_contact['is_opt_out']}\n            , do_not_email = {$civicrm_contact['do_not_email']}\n            , do_not_mail = {$civicrm_contact['do_not_mail']}\n        WHERE id = {$civiContactId}";
    }
    /* Membership
     */
    $civicrm_membership[membership_type_id] = $row[memType];
    // These civi dates are date only, no time.
    $civicrm_membership[join_date] = substr($row[start_date], 0, 10);
    $civicrm_membership[start_date] = substr($row[start_date], 0, 10);
    $civicrm_membership[end_date] = substr($row[end_date], 0, 10);
    if ($civicrm_membership[end_date] == '0000-00-00') {
        $civicrm_membership[end_date] = 'NULL';
    } else {
        $civicrm_membership[end_date] = "'" . $civicrm_membership[end_date] . "'";
    }
    // Skeletal new records were created earlier, inserts never done here.
    if ($civiOps[civicrm_membership] == "insert") {
        $insertMembership = "INSERT INTO civicrm_membership\n        (id, contact_id\n        , membership_type_id\n        , status_id\n        , join_date\n        , start_date\n        , end_date\n        )\n        VALUES\n        ('', {$civiContactId}\n        , {$civicrm_membership['membership_type_id']})\n        , {$civicrm_membership_status['New']}\n        , '{$civicrm_membership['join_date']}'\n        , '{$civicrm_membership['start_date']}'\n        , {$civicrm_membership['end_date']}\n        )";
    } elseif ($civiOps[civicrm_membership] == "update") {
        // Cannot assign status_id because it isn't edited in IS4C
        //  For records created here status_id was intialized on creation.
        $updateMembership = "UPDATE civicrm_membership\n        SET\n        membership_type_id = {$civicrm_membership['membership_type_id']}\n        , join_date = '{$civicrm_membership['join_date']}'\n        , start_date = '{$civicrm_membership['start_date']}'\n        , end_date = {$civicrm_membership['end_date']}\n        WHERE\n        id = {$civiMemberId}";
        // o> 25Nov13. Used to be on contact_id.
        // contact_id = $civiContactId";
    } else {
        $noop = 1;
    }
    /* Membership log
     *  Always insert if done at all.
     *  modified_* agree with civicrm_log
     */
    if ($civiOps[civicrm_membership_log] == "insert") {
        $civicrm_membership_log['modified_id'] = "{$adminId}";
        $civicrm_membership_log['modified_date'] = "{$updated}";
        $insertMembership = "INSERT INTO civicrm_membership_log\n        (id\n        , membership_id\n        , status_id\n        , start_date\n        , end_date\n        , modified_id\n        , modified_date\n        )\n        VALUES\n        (''\n        , {$civiMemberId}\n        , {$civicrm_membership_status['Current']}\n        , '{$civicrm_membership['start_date']}'\n        , {$civicrm_membership['end_date']}\n        , {$civicrm_membership_log['modified_id']}\n        , '{$civicrm_membership_log['modified_date']}'\n        )";
    }
    /* Email(s)
     * For insert is_primary=1
     * For update:
     *  There is always one where is_primary=1
     * + First change the one where is_primary=1
     * + If there is another
     *   + See if there is one with is_primary=0
     *     + If yes, update that one.
     *     + If not, insert one with is_primary=0
     */
    $civicrm_email[email] = $row[email_1];
    if ($civiOps[civicrm_email] == "insert") {
        $civicrm_email[location_type_id] = 1;
        $civicrm_email[is_primary] = 1;
        $civicrm_email[is_bulkmail] = 1;
        $insertEmail[] = "INSERT INTO civicrm_email\n        (id, contact_id\n        , email\n        , location_type_id\n        , is_primary\n        , is_bulkmail\n        )\n        VALUES\n        ('', {$civiContactId}\n        , {$dbConn->escape($civicrm_email[email])}\n        , {$civicrm_email['location_type_id']}\n        , {$civicrm_email['is_primary']}\n        , {$civicrm_email['is_bulkmail']}\n        )";
        // If there is another one insert it, is_primary=0.
        if (isEmail($row[email_2])) {
            $civicrm_email[email] = $row[email_2];
            $civicrm_email[location_type_id] = 2;
            // We don't actually know.
            // In fact 0 is default.
            $civicrm_email[is_primary] = 0;
            $insertEmail[] = "INSERT INTO civicrm_email\n            (id, contact_id\n            , email\n            , location_type_id\n            , is_primary\n            )\n            VALUES\n            ('', {$civiContactId}\n            , {$dbConn->escape($civicrm_email[email])}\n            , {$civicrm_email['location_type_id']}\n            , {$civicrm_email['is_primary']}\n            )";
        }
    } else {
        $updateEmail[] = "UPDATE civicrm_email\n        SET\n        email = {$dbConn->escape($civicrm_email[email])}\n        WHERE contact_id = {$civiContactId} AND is_primary = 1";
        /* If there is another one
         *  Look for the id of one non-primary at Civi
         *   If there is one
         *    update it on id#
         *   If not,
         *    insert it, is_primary=0.
         */
        if (isEmail($row[email_2])) {
            $civicrm_email[email] = $row[email_2];
            $civicrm_email[is_primary] = 0;
            $email_id = getCiviSecondEmail($civiContactId);
            if ($email_id != 0) {
                $updateEmail[] = "UPDATE civicrm_email\n                SET\n                email = {$dbConn->escape($civicrm_email[email])}\n                , is_primary = {$civicrm_email['is_primary']}\n                WHERE id = {$email_id}";
            } else {
                $insertEmail[] = "INSERT INTO civicrm_email\n                (id, contact_id\n                , email\n                , is_primary\n                )\n                VALUES\n                ('', {$civiContactId}\n                , {$dbConn->escape($civicrm_email[email])}\n                , {$civicrm_email['is_primary']}\n                )";
            }
        }
        // update Email
    }
    /* Address - IS4C only supports one.
     */
    $row[street] = str_replace("\n", " ", $row[street]);
    $civicrm_address[street_address] = fixAddress($row[street]);
    $civicrm_address[city] = fixCity($row[city]);
    $civicrm_address[postal_code] = fixPostalCode($row[zip]);
    $civicrm_address[state_province_id] = getProvinceId($row[state]);
    if ($civiOps[civicrm_address] == "insert") {
        if ($civicrm_address[street_address] != "") {
            $civicrm_address[location_type_id] = 1;
            $civicrm_address[is_primary] = 1;
            $insertAddress[] = "INSERT INTO civicrm_address\n            (id, contact_id\n            , street_address\n            , city\n            , postal_code\n            , state_province_id\n            , location_type_id\n            , is_primary\n            )\n            VALUES\n            ('', {$civiContactId}\n            , {$dbConn->escape($civicrm_address[street_address])}\n            , {$dbConn->escape($civicrm_address[city])}\n            , {$dbConn->escape($civicrm_address[postal_code])}\n            , {$civicrm_address['state_province_id']}\n            , {$civicrm_address['location_type_id']}\n            , {$civicrm_address['is_primary']}\n            )";
        }
    } else {
        // This will set-empty but not delete if foo=="".
        $updateAddress[] = "UPDATE civicrm_address\n        SET\n        street_address = {$dbConn->escape($civicrm_address[street_address])}\n        , city = {$dbConn->escape($civicrm_address[city])}\n        , postal_code = {$dbConn->escape($civicrm_address[postal_code])}\n        , state_province_id = {$civicrm_address['state_province_id']}\n        WHERE contact_id = {$civiContactId} AND is_primary = 1";
        // update Address
    }
    /* Phone(s)
     * For insert, first: is_primary=1, 2nd: is_primary=0
     * For update:
     *  There is always one where is_primary=1
     * + First change the one where is_primary=1
     * + If there is another
     *   + See if there is one with is_primary=0
     *     + If yes, update that one.
     *     + If not, insert one with is_primary=0
     */
    // Does it need some validation?
    $civicrm_phone[phone] = $row[phone];
    if ($civiOps[civicrm_phone] == "insert") {
        if ($civicrm_phone[phone] != "") {
            $civicrm_phone[location_type_id] = 1;
            $civicrm_phone[is_primary] = 1;
            $insertPhone[] = "INSERT INTO civicrm_phone\n            (id, contact_id\n            , phone\n            , location_type_id\n            , is_primary\n            )\n            VALUES\n            ('', {$civiContactId}\n            , {$dbConn->escape($civicrm_phone[phone])}\n            , {$civicrm_phone['location_type_id']}\n            , {$civicrm_phone['is_primary']}\n            )";
            // If there is another one insert it, is_primary=0.
            if (isPhone($row[email_2])) {
                $civicrm_phone[phone] = $row[email_2];
                $civicrm_phone[location_type_id] = 2;
                // We don't actually know.
                // In fact 0 is default.
                $civicrm_phone[is_primary] = 0;
                $insertPhone[] = "INSERT INTO civicrm_phone\n                (id, contact_id\n                , phone\n                , location_type_id\n                , is_primary\n                )\n                VALUES\n                ('', {$civiContactId}\n                , {$dbConn->escape($civicrm_phone[phone])}\n                , {$civicrm_email['location_type_id']}\n                , {$civicrm_phone['is_primary']}\n                )";
            }
        }
    } else {
        // This will set-empty but not delete if phone=="".
        $updatePhone[] = "UPDATE civicrm_phone\n        SET\n        phone = {$dbConn->escape($civicrm_phone[phone])}\n        WHERE contact_id = {$civiContactId} AND is_primary = 1";
        /* If there is another one
         *  Look for the id of one non-primary at Civi
         *   If there is one
         *    update it on id#
         *   If not,
         *    insert it, is_primary=0.
         */
        if (isPhone($row[email_2])) {
            $civicrm_phone[phone] = $row[email_2];
            $civicrm_phone[is_primary] = 0;
            $phone_id = getCiviSecondPhone($civiContactId);
            if ($phone_id != 0) {
                $updatePhone[] = "UPDATE civicrm_phone\n                SET\n                phone = {$dbConn->escape($civicrm_phone[phone])}\n                , is_primary = {$civicrm_phone['is_primary']}\n                WHERE id = {$phone_id}";
            } else {
                $insertPhone[] = "INSERT INTO civicrm_phone\n                (id, contact_id\n                , phone\n                , is_primary\n                )\n                VALUES\n                ('', {$civiContactId}\n                , {$dbConn->escape($civicrm_phone[phone])}\n                , {$civicrm_phone['is_primary']}\n                )";
            }
        }
        // update Phone
    }
    // Membership card#.
    if ($row[member_card_upc] != "") {
        $civicrm_value_identification_and_cred["{$memberCardField}"] = ltrim(substr($row[member_card_upc], 8, 5), "0");
    } else {
        $civicrm_value_identification_and_cred["{$memberCardField}"] = 'NULL';
    }
    if ($civiOps["{$memberCardTable}"] == "insert") {
        $insertMemberCard = "INSERT INTO {$memberCardTable}\n        (id\n        , entity_id\n        , {$memberCardField})\n        VALUES\n        (''\n        , {$civiContactId}\n        , {$civicrm_value_identification_and_cred[$memberCardField]})";
    } else {
        $updateMemberCard = "UPDATE {$memberCardTable}\n        SET {$memberCardField} = {$civicrm_value_identification_and_cred[$memberCardField]}\n        WHERE entity_id = {$civiContactId}";
    }
    // Datestamp
    // Create a civicrm_log record (datestamp) to match the IS4C datestamp.
    $civicrm_log['entity_table'] = "civicrm_contact";
    $civicrm_log['entity_id'] = $civiContactId;
    $civicrm_log['data'] = "{$civicrm_log['entity_table']},{$civicrm_log['entity_id']}";
    // This is civicrm_contact.id of an "IS4C" record in Civi.
    $civicrm_log['modified_id'] = "{$adminId}";
    $civicrm_log['modified_date'] = "{$updated}";
    $insertLog = "INSERT INTO civicrm_log\n    (id\n    , entity_table\n    , entity_id\n    , data\n    , modified_id\n    , modified_date)\n    VALUES\n    ('',\n    '{$civicrm_log['entity_table']}',\n    {$civicrm_log['entity_id']},\n    '{$civicrm_log['data']}',\n    {$civicrm_log['modified_id']},\n    '{$civicrm_log['modified_date']}'\n    )";
    // assignLocalC
}
Example #6
0
<?php

// fb-root
// include_once INC_PATH.'fbscript.php';
?>

<div id="top"></div>
<header id="<?php 
notPhone('globalHeader');
?>
" class="global_hd <?php 
isPhone('mobile_header');
?>
">
	<!-- <div class="wrapper"> -->
		<header id="logo" class="ib"><a href="<?php 
webPageUrlAu('index');
?>
" title="康和期貨網站首頁"><img src="<?php 
path_au('img');
?>
LOGO.png" alt=""></a></header>
		<nav class="main_nav ib ">
			<ul class="cf">
			<?php 
headerNavAu();
?>
				<li class="quick_bar">
					<div class="login">
						<a href="https://fm.concordfutures.com.tw/fundM/Login.aspx" class="hide_txt" target="_blank">會員登入</a>
					</div>
Example #7
0
if (!isset($_GET['callto'])) {
    $ERR = "Pas de destinataire";
} else {
    $callto = $_GET['callto'];
    if (!isPhone($callto)) {
        $ERR = "Le numéro du destinataire est invalide";
    }
    if (!hasInternationalExt($callto)) {
        $callto = substr($callto, 1, strlen($callto) - 1);
        $callto = $cn + "0033";
    }
}
if (isset($_POST['callbacknum'])) {
    $cn = $_POST['callbacknum'];
    //vérification du numéro de téléphone, et ajout du préfix international si nécéssaire.
    if (!isPhone($cn)) {
        $ERR = "Le numéro entré est invalide";
    }
    if (!hasInternationalExt($cn)) {
        $cn = substr($cn, 1, strlen($cn) - 1);
        $cn = $cn + "0033";
    }
    $MSG = "Nous allons vous appeler dans quelques instants..";
    if (!isset($ERR)) {
        //## Code plivo pour le controle de Freeswitch
        require "lib/plivo/plivohelper.php";
        //instanciation du client plivo
        $client = new PlivoRestClient($REST_API_URL, $AccountSid, $AuthToken, $ApiVersion);
        //$bridge_id = genBridgeUUID(1);
        //$bridge_id = '1234';
        //cree un nouvel uuid dans freeswitch
Example #8
0
$user = new UserManager();
$cookies = new Cookies();
foreach (array('name', 'email', 'password', 'phone') as $field) {
    if (!isset($_POST[$field]) || empty($_POST[$field])) {
        //        echo "Failed to create account because not enough information was passed";
        header("Location: /index.php?m=3");
        exit;
    }
}
// validate data
$errors = array();
$inputs = app('request')->input();
if (!filter_var($inputs['email'], FILTER_VALIDATE_EMAIL)) {
    array_push($errors, 'Invalid email');
}
if (!isPhone($inputs['phone'])) {
    array_push($errors, 'Invalid phone');
}
if (!empty($errors)) {
    header("Location: /index.php?m=13");
    exit;
}
if ($user->is_account_available($_POST["email"])) {
    $id = $user->add_user($_POST["name"], $_POST["email"], $_POST["password"], $_POST["phone"]);
    if ($id != 0) {
        $user_obj = $user->get_user_from_insertid($id);
        $cookies->set_cookie($user_obj->data["uid"]);
        // log the user in
        //        header("Location: /index.php?m=1");
        header("Location: /profile.php?p=2&m=6");
        exit;