$customeradd['zipwarning'] = 1; } if ($customeradd['post_zip'] != '' && !check_zip($customeradd['post_zip']) && !isset($customeradd['post_zipwarning'])) { $error['post_zip'] = trans('Incorrect ZIP code! If you are sure you want to accept it, then click "Submit" again.'); $customeradd['post_zipwarning'] = 1; } if ($customeradd['pin'] == '') { $error['pin'] = trans('PIN code is required!'); } elseif (!preg_match('/^[0-9]{4,6}$/', $customeradd['pin'])) { $error['pin'] = trans('Incorrect PIN code!'); } foreach ($customeradd['uid'] as $idx => $val) { $val = trim($val); switch ($idx) { case IM_GG: if ($val != '' && !check_gg($val)) { $error['gg'] = trans('Incorrect IM uin!'); } break; case IM_YAHOO: if ($val != '' && !check_yahoo($val)) { $error['yahoo'] = trans('Incorrect IM uin!'); } break; case IM_SKYPE: if ($val != '' && !check_skype($val)) { $error['skype'] = trans('Incorrect IM uin!'); } break; } if ($val) {
function validate_customer_ims(&$customerdata, &$contacts, &$error) { foreach ($customerdata['ims'] as $idx => &$val) { $im = trim($val['contact']); $name = trim($val['name']); $type = !empty($val['type']) ? array_sum($val['type']) : 0; $type |= $val['typeselector']; $val['type'] = $type; $imtype = $type & CONTACT_IM; if ($im != '' && ($imtype == CONTACT_IM_GG && !check_gg($im) || $imtype == CONTACT_IM_YAHOO && !check_yahoo($im) || $imtype == CONTACT_IM_SKYPE && !check_skype($im) || $imtype == CONTACT_IM_FACEBOOK && !check_facebook($im))) { $error['im' . $idx] = trans('Incorrect IM uin!'); } elseif ($name && !$im) { $error['im' . $idx] = trans('IM uid is required!'); } elseif ($im) { $contacts[] = array('name' => $name, 'contact' => $im, 'type' => $type); } } }