d("a")) && (ord($login)<=ord("z"))) || ((ord($login)>=ord("A")) && (ord($login)<=ord("Z"))))) $error = ERROR_LOGIN_SHOULD_START_WITH_LATIN_SYMBOL; else if ( $cust_password1 == "" || $cust_password2 == "" || $cust_password1 != $cust_password2 ) $error = ERROR_WRONG_PASSWORD_CONFIRMATION; else if ( trim($first_name) == "" ) $error = ERROR_INPUT_NAME; else if ( trim($last_name) == "" ) $error = ERROR_INPUT_NAME; else if ( trim($Email) == "" ) $error = ERROR_INPUT_EMAIL; else if (!preg_match("/^[_\.a-z0-9-]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|edu|gov|arpa|info|biz|inc|name|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/is",$Email)) { //e-mail validation $error = ERROR_INPUT_EMAIL; } if (isset($_POST['affiliationLogin'])) if ( !regIsRegister($_POST['affiliationLogin']) && $_POST['affiliationLogin']) $error = ERROR_WRONG_AFFILIATION; foreach( $additional_field_values as $key => $val ) { if ( !_testStrInvalidSymbol($val["additional_field"]) ) return ERROR_INVALID_SYMBOL; if ( trim($val["additional_field"]) == "" && GetIsRequiredRegField($key) == 1 ) { $error = ERROR_INPUT_ADDITION_FIELD; break; } } return $error; } function regUpdateContactInfo( $old_login, $login, $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values ) { db_query("update ".CUSTOMERS_TABLE." set ". " Login = '".xToText(trim($login))."', ". " cust_password = '".cryptPasswordCrypt( $cust_password, null )."', ". " Email = '".xToText($Email)."', ". " first_name = '".xToText(trim($first_name))."', ". " last_name = '".xToText(trim($last_name))."', ". " subscribed4news = ".(int)$subscribed4news." ". " where Login='".xToText(trim($old_login))."'"); foreach( $additional_field_values as $key => $val ) SetRegField($key, $login, $val["additional_field"]); if (!strcmp($old_login, $login)) //update administrator login (core/config/connect.inc.php) { db_query("update ".CUSTOMERS_TABLE." set Login='".xToText(trim($login))."' where Login='".xToText(trim($old_login))."'"); } $customerID = regGetIdByLogin( $login ); if ( $subscribed4news ) subscrAddRegisteredCustomerEmail( $customerID ); else subscrUnsubscribeSubscriberByEmail( base64_encode($Email) ); } // ***************************************************************************** // Purpose get address string by address ID // Inputs // Remarks // Returns function regGetAddressStr( $addressID, $NoTransform = false ) { $address = regGetAddress( $addressID ); // countryID, zoneID, state $country = cnGetCountryById( $address["countryID"] ); $country = $country["country_name"]; if ( trim($address["state"]) == "" ) { $zone = znGetSingleZoneById( $address["zoneID"] ); $zone = $zone["zone_name"]; } else $zone = trim($address["state"]); if ( $country != "" ) { $strAddress = $address["first_name"]." ".$address["last_name"]; if (strlen($address["address"])>0) $strAddress .= "
".$address["address"]; if (strlen($address["city"])>0) $strAddress .= "
".$address["city"]; if (strlen($zone)>0) $strAddress .= " ".$zone; if (strlen($country)>0) $strAddress .= "
".$country; } else { $strAddress = $address["first_name"]." ".$address["last_name"]; if (strlen($address["address"])>0) $strAddress .= "
".$address["address"]; if (strlen($address["city"])>0) $strAddress .= "
".$address["city"]; if (strlen($zone)>0) $strAddress .= " ".$zone; } return $strAddress; } // ***************************************************************************** // Purpose gets all customers // Inputs // Remarks // Returns function regGetCustomers( $callBackParam, &$count_row, $navigatorParams = null ) { if ( $navigatorParams != null ) { $offset = $navigatorParams["offset"]; $CountRowOnPage = $navigatorParams["CountRowOnPage"]; } else { $offset = 0; $CountRowOnPage = 0; } $where_clause = ""; if ( isset($callBackParam["Login"]) ) { $callBackParam["Login"] = xEscSQL( $callBackParam["Login"] ); $where_clause .= " Login LIKE '%".$callBackParam["Login"]."%' "; } if ( isset($callBackParam["first_name"]) ) { $callBackParam["first_name"] = xEscSQL( $callBackParam["first_name"] ); if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " first_name LIKE '%".$callBackParam["first_name"]."%' "; } if ( isset($callBackParam["last_name"]) ) { $callBackParam["last_name"] = xEscSQL( $callBackParam["last_name"] ); if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " last_name LIKE '%".$callBackParam["last_name"]."%' "; } if ( isset($callBackParam["email"]) ) { $callBackParam["email"] = xEscSQL( $callBackParam["email"] ); if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " Email LIKE '%".$callBackParam["email"]."%' "; } if ( isset($callBackParam["groupID"]) ) { if ( $callBackParam["groupID"] != 0 ) { if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " custgroupID = ".(int)$callBackParam["groupID"]." "; } } if ( isset($callBackParam["ActState"]) ) { switch ($callBackParam["ActState"]){ #activated case 1: if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " (ActivationCode='' OR ActivationCode IS NULL)"; break; #not activated case 0: if ( $where_clause != "" ) $where_clause .= " AND "; $where_clause .= " ActivationCode!=''"; break; } } if ( $where_clause != "" ) $where_clause = " where ".$where_clause; $order_clause = ""; if ( isset($callBackParam["sort"]) ) { $order_clause .= " order by ".xEscSQL($callBackParam["sort"])." "; if ( isset($callBackParam["direction"]) ) { if ( $callBackParam["direction"] == "ASC" ) $order_clause .= " ASC "; else $order_clause .= " DESC "; } } $q=db_query("select customerID, Login, cust_password, Email, first_name, last_name, subscribed4news, ". " custgroupID, addressID, reg_datetime, ActivationCode ". " from ".CUSTOMERS_TABLE." ".$where_clause." ".$order_clause ); $data = array(); $i=0;//var_dump ($navigatorParams); while( $row=db_fetch_row($q) ) { if ( ($i >= $offset && $i < $offset + $CountRowOnPage) || $navigatorParams == null ) { $group = GetCustomerGroupByCustomerId( $row["customerID"] ); $row["custgroup_name"] = $group["custgroup_name"]; $row["allowToDelete"] = regVerifyToDelete( $row["customerID"] ); $row["reg_datetime"] = format_datetime( $row["reg_datetime"] ); $data[] = $row; } $i++; } $count_row = $i; return $data; } function regSetSubscribed4news( $customerID, $value ) { db_query( "update ".CUSTOMERS_TABLE." set subscribed4news = ".(int)$value. " where customerID=".(int)$customerID ); if ($value > 0) { subscrAddRegisteredCustomerEmail($customerID); } else { subscrUnsubscribeSubscriberByCustomerId($customerID); } } function regSetCustgroupID( $customerID, $custgroupID ) { db_query( "update ".CUSTOMERS_TABLE." set custgroupID=".(int)$custgroupID. " where customerID=".(int)$customerID ); } function regAddressBelongToCustomer( $customerID, $addressID ) { if (!$customerID) return false; if (!$addressID) return false; $q_count = db_query( "select count(*) from ".CUSTOMER_ADDRESSES_TABLE. " where customerID=".(int)$customerID." AND addressID=".(int)$addressID ); $count = db_fetch_row( $q_count ); $count = $count[0]; return ( $count != 0 ); } function regVerifyToDelete( $customerID ) { if (!$customerID) return 0; $q = db_query( "select count(*) from ".CUSTOMERS_TABLE." where customerID=".(int)$customerID ); $row = db_fetch_row($q); if ( regIsAdminiatrator(regGetLoginById($customerID)) ) return false; return ($row[0] == 1); } function regDeleteCustomer( $customerID ) { if ( $customerID == null || trim($customerID) == "" ) return false; if (!$customerID) return 0; if ( regVerifyToDelete( $customerID ) ) { db_query( "delete from ".SHOPPING_CARTS_TABLE." where customerID=".(int)$customerID ); db_query( "delete from ".MAILING_LIST_TABLE." where customerID=".(int)$customerID ); db_query( "delete from ".CUSTOMER_ADDRESSES_TABLE." where customerID=".(int)$customerID ); db_query( "delete from ".CUSTOMER_REG_FIELDS_VALUES_TABLE." where customerID=".(int)$customerID ); db_query( "delete from ".CUSTOMERS_TABLE." where customerID=".(int)$customerID ); db_query( "update ".ORDERS_TABLE." set customerID=NULL where customerID=".(int)$customerID ); return true; } else return false; } function regActivateCustomer($_CustomerID){ $sql = 'UPDATE '.CUSTOMERS_TABLE.' SET ActivationCode = "" WHERE customerID='.(int)$_CustomerID; db_query($sql); } ?>