/** * validating input based on conditions passed as an array */ function validateinput($inputname, $valuename, $conditions) { if (isset($_POST[$inputname])) { $value = $_POST[$inputname]; $conditionschecks = array(); $index = 0; foreach ($conditions as $condition) { if ($skipnext) { $index++; $skipnext = false; } else { //echo $condition; switch ($condition) { case "required": if (checkrequired($value, $conditions[$index + 1])) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " required to have a min. length of {$conditions[$index + 1]} chararcters"); } $index++; $skipnext = true; break; case "email": if (checkemail($value)) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " invalid"); } $index++; break; case "emailused": if (isemailused($value)) { $conditionschecks[$condition] = array(false, " used"); } else { $conditionschecks[$condition] = true; } $index++; break; case "username": if (checkusername($value)) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " used"); } $index++; break; case "password": if (checkpassword($value)) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " required to have a min. length of 8 chararcters"); } $index++; break; case "match|repassword": if (checkmatch($value, substr($condition, strpos($condition, "|") + 1))) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " does not match"); } $index++; break; case "validpassword": if (validpassword($_POST['userid'], $value)) { $conditionschecks[$condition] = true; } else { $conditionschecks[$condition] = array(false, " current password is invalid."); } $index++; break; } } } //construct a message $isvalid = true; $errormessage = $valuename . " fails on ("; foreach ($conditionschecks as $check) { if (is_array($check)) { $errormessage .= $check[1] . " ,"; $isvalid = false; } } if ($isvalid) { return true; } else { return substr_replace($errormessage, "", -1) . " )"; } } else { return "There is not input with {$inputname} name"; } }
showsetting('insenz_register_msn', 'msn', $msn, 'text'); echo '<tr><td class="altbg1" width="45%"><b>' . $lang['insenz_register_tel'] . '</b><br />' . $lang['insenz_register_tel_comment'] . '</td><td class="altbg2"><input type="text" name="tel1" size="3" value="' . $tel1 . '" onmousedown="clearinput(this, \'' . $lang['insenz_register_zone'] . '\')"> - <input type="text" name="tel2" size="8" value="' . $tel2 . '" onmousedown="clearinput(this,\'' . $lang['insenz_register_exchange'] . '\')"> - <input type="text" name="tel3" size="5" value="' . $tel3 . '" onmousedown="clearinput(this, \'' . $lang['insenz_register_extension'] . '\')"></td></tr>'; showsetting('insenz_register_mobile', 'mobile', $mobile, 'text'); echo '<tr><td class="altbg1" width="45%"><b>' . $lang['insenz_register_fax'] . '</b><br />' . $lang['insenz_register_fax_comment'] . '</td><td class="altbg2"><input type="text" name="fax1" size="3" value="' . $fax1 . '"> - <input type="text" name="fax2" size="8" value="' . $fax2 . '"> - <input type="text" name="fax3"size="5" value="' . $fax3 . '"></td></tr>'; echo '<tr><td class="altbg1" width="45%"><b>' . $lang['insenz_register_country'] . '</b></td><td class="altbg2"><select name="country" onChange="changeseleccountry(this.value)"><option value="0">' . $lang['select'] . '</option></select></td></tr>'; echo '<tr><td class="altbg1" width="45%"><b>' . $lang['insenz_register_province'] . '</b></td><td class="altbg2"><select name="province" onChange="changeseleccity(this.value)"><option value="0">' . $lang['select'] . '</option></select> </td></tr>'; echo '<tr><td class="altbg1" width="45%"><b>' . $lang['insenz_register_city'] . '</b></td><td class="altbg2"><select name="city"><option value="0">' . $lang['select'] . '</option></select> </td></tr>'; showsetting('insenz_register_address', 'address', $address, 'text'); showsetting('insenz_register_postcode', 'postcode', $postcode, 'text'); echo '<tr class="category"><td colspan="2">' . $lang['insenz_register_account'] . '</td></tr>'; showsetting('insenz_register_alipay', 'alipay', $alipay, 'text'); showtype('', 'bottom'); echo '<br /><center><input type="submit" class="button" name="regsubmit" value="' . $lang['submit'] . '" onclick="this.form.target=\'register\';"><iframe name="register" style="display: none"></iframe> <input type="button" class="button" value="' . $lang['cancel'] . '" onclick="window.location=\'admincp.php?action=insenz\'"></center></form> <script type="text/javascript" src="./include/javascript/insenz_reg.js"></script>'; } else { $username = checkusername($username); $password = checkpassword($password, $password2); $name = checkname($name); $idcard = checkidcard($idcard); $email1 = checkemail($email1, 'email1'); $email2 = $email2 ? checkemail($email2, 'email2') : ''; $qq = checkqq($qq); $msn = $msn ? checkemail($msn, 'msn') : ''; $tel3 = $tel3 != $lang['insenz_register_extension'] ? intval($tel3) : ''; $tel = checktel($tel1, $tel2, $tel3, 'tel'); $fax = $fax2 ? checktel($fax1, $fax2, $fax3, 'fax') : ''; $mobile = checkmobile($mobile); $cpc = checkcpc($country, $province, $city); $country = $cpc[0]; $province = $cpc[1]; $city = $cpc[2];
$subject = "Re: {$msg['title']}"; $tcellbg = "{$tccell1l} valign=top"; $postlist = "\n\t\t\t\t{$tccellh} width=150>User</td>\n\t\t\t\t{$tccellh}>Message<tr>\n\t\t\t\t{$tcellbg}><a href=profile.php?id={$user['id']}>{$user['name']}</a>{$smallfont}<br>\n\t\t\t\tPosts: {$postnum}{$user['posts']}</td>\n\t\t\t\t{$tcellbg}>" . doreplace2($msg[text]) . "<tr>\n\t\t\t"; } else { $postlist = ''; } if ($userid) { $user = loaduser($userid, 1); } $user['name'] = htmlspecialchars($user['name']); $subject = htmlspecialchars($subject); print "\n\t\t\t{$tccellh} width=150> </td>\n\t\t\t{$tccellh}> <tr>\n\t\t\t{$tccell1}><b>Send to:</td>\t {$tccell2l}>{$inpt}=username value=\"{$user['name']}\" size=25 maxlength=25><tr>\n\t\t\t{$tccell1}><b>Subject:</td>\t {$tccell2l}>{$inpt}=subject value=\"{$subject}\" size=60 maxlength=100><tr>\n\t\t\t{$tccell1}><b>Message:</td>\t {$tccell2l}>{$txta}='message' rows=20 cols={$numcols}>{$quotemsg}</textarea><tr>\n\t\t\t{$tccell1}> </td>\t\t {$tccell2l}>\n\t\t\t{$inph}=action VALUE=sendmsg>\n\t\t\t{$inps}=submit VALUE='Send message'>\n\t\t\t{$inps}=preview VALUE='Preview message'></td>\n\n\t\t\t{$tblend}\n\t\t\t</FORM>\n\t\t\t<br>{$tblstart}{$postlist}{$tblend}\n\t\t\t{$fonttag}<a href=index.php>{$boardname}</a> - <a href=private.php>Private messages</a>\n\t\t"; } if ($action == 'sendmsg') { $username = stripslashes($_POST['username']); $userid = checkusername($username); if ($userid == -1) { print "{$tccell1}>Couldn't send the message. You didn't enter an existing username to send the message to.\n\t\t\t\t<br>" . redirect('private.php', 'your private message box', 2); } elseif (!$subject) { print "{$tccell1}>Couldn't send the message. You didn't enter a subject.\n\t\t\t\t<br>" . redirect('private.php', 'your private message box', 2); } else { $subject = str_replace('<', '<', $subject); $sign = $loguser['signature']; $head = $loguser['postheader']; if ($user['postbg']) { $head = "<div style=background:url({$user['postbg']});height=100%>{$head}"; } $numdays = (ctime() - $loguser['regdate']) / 86400; $message = doreplace($message, $loguser['posts'], $numdays, $loguser['name']); $rsign = doreplace($sign, $loguser['posts'], $numdays, $loguser['name']); $rhead = doreplace($head, $loguser['posts'], $numdays, $loguser['name']);