Database Error in account-signup.php on line 160: Column 'gender' cannot be null. Query was: INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, ip) VALUES <?php
require_once("backend/functions.php");
dbconn();
$site_config["LEFTNAV"] = $site_config["MIDDLENAV"] = $site_config["RIGHTNAV"] = false;############ hide site #########
session_start();
$username_length = 15; // Max username length. You shouldn't set this higher without editing the database first
$password_minlength = 6;
$password_maxlength = 40;
// Disable checks if we're signing up with an invite
if (!is_valid_id($_REQUEST["invite"]) || strlen($_REQUEST["secret"]) != 32) {
//invite only check
if ($site_config["INVITEONLY"]) {
show_error_msg(T_("INVITE_ONLY"), "<br /><br /><center>".T_("INVITE_ONLY_MSG")."<br /><br /></center>",1);
}
//get max members, and check how many users there is
$numsitemembers = get_row_count("users");
if ($numsitemembers >= $site_config["maxusers"])
show_error_msg(T_("SORRY")."...", T_("SITE_FULL_LIMIT_MSG") . number_format($site_config["maxusers"])." ".T_("SITE_FULL_LIMIT_REACHED_MSG")." ".number_format($numsitemembers)." members",1);
} else {
$res = SQL_Query_exec("SELECT id FROM users WHERE id = $_REQUEST[invite] AND MD5(secret) = ".sqlesc($_REQUEST["secret"]));
$invite_row = mysqli_fetch_assoc($res);
if (!$invite_row) {
show_error_msg(T_("ERROR"), T_("INVITE_ONLY_NOT_FOUND")." ".($site_config['signup_timeout']/86400)." days.", 1);
}
}
if ($_GET["takesignup"] == "1") {
$message == "";
// function validusername($username) {
// $allowedchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// for ($i = 0; $i < strlen($username); ++$i)
// if (strpos($allowedchars, $username[$i]) === false)
// return false;
// return true;
// }
function validusername($username)
{
return ctype_alnum($username);
}
$wantusername = $_POST["wantusername"];
$email = $_POST["email"];
$wantpassword = $_POST["wantpassword"];
$passagain = $_POST["passagain"];
$country = $_POST["country"];
$gender = $_POST["gender"];
$client = $_POST["client"];
$age = (int) $_POST["age"];
if (empty($wantpassword) || (empty($email) && !$invite_row) || empty($wantusername))
$message = T_("DONT_LEAVE_ANY_FIELD_BLANK");
elseif (strlen($wantusername) > $username_length)
$message = sprintf(T_("USERNAME_TOO_LONG"), $username_length);
elseif ($wantpassword != $passagain)
$message = T_("PASSWORDS_NOT_MATCH");
elseif (strlen($wantpassword) < $password_minlength)
$message = sprintf(T_("PASS_TOO_SHORT_2"), $password_minlength);
elseif (strlen($wantpassword) > $password_maxlength)
$message = sprintf(T_("PASS_TOO_LONG_2"), $password_maxlength);
elseif ($wantpassword == $wantusername)
$message = T_("PASS_CANT_MATCH_USERNAME");
elseif (!validusername($wantusername))
$message = "Invalid username.";
elseif (!$invite_row && !validemail($email))
$message = "That doesn't look like a valid email address.";
if ($message == "") {
// Certain checks must be skipped for invites
if (!$invite_row) {
//check email isnt banned
$maildomain = (substr($email, strpos($email, "@") + 1));
$a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain='$email'")));
if ($a[0] != 0)
$message = sprintf(T_("EMAIL_ADDRESS_BANNED_S"), $email);
$a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from email_bans where mail_domain LIKE '%$maildomain%'")));
if ($a[0] != 0)
$message = sprintf(T_("EMAIL_ADDRESS_BANNED_S"), $email);
// check if email addy is already in use
$a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from users where email='$email'")));
if ($a[0] != 0)
$message = sprintf(T_("EMAIL_ADDRESS_INUSE_S"), $email);
}
//check username isnt in use
$a = (@mysqli_fetch_row(@SQL_Query_exec("select count(*) from users where username='$wantusername'")));
if ($a[0] != 0)
$message = sprintf(T_("USERNAME_INUSE_S"), $wantusername);
$secret = mksecret(); //generate secret field
$wantpassword = passhash($wantpassword);// hash the password
}
if ($message != "")
show_error_msg(T_("SIGNUP_FAILED"), $message, 1);
if ($message == "") {
if ($invite_row) {
SQL_Query_exec("UPDATE users SET username=".sqlesc($wantusername).", password=".sqlesc($wantpassword).", secret=".sqlesc($secret).", status='confirmed', added='".get_date_time()."' WHERE id=$invite_row[id]");
//send pm to new user
if ($site_config["WELCOMEPMON"]){
$dt = sqlesc(get_date_time());
$msg = sqlesc($site_config["WELCOMEPMMSG"]);
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $invite_row[id], $dt, $msg, 0)");
}
//
if ($site_config["WELCOMEEMAIL"]) {
require_once "Mail.php";
$from = $site_config['SITENAME'] . " <" . $site_config['SITEEMAIL'] . ">";
$subject = "Welcome to " . $site_config['SITENAME'];
$headers = array(
'To' => $email,
'From' => $from,
'Subject' => $subject,
'MIME-Version' => 1,
'Content-type' => 'text/html;charset=iso-8859-1'
);
$smtp = Mail::factory('smtp', array(
'host' => $site_config["mail_smtp_host"],
'auth' => $site_config["mail_smtp_auth"],
'username' => $site_config["mail_smtp_user"],
'password' => $site_config["mail_smtp_pass"]
));
$mail = $smtp->send($email, $headers, $site_config["WELCOMEEMAILBODY"]);
// Log send error
if (PEAR::isError($mail)) {
write_log($mail->getMessage());
return false;
} else {
write_log("Welcome Email successfully sent to " . $email);
}
}
header("Refresh: 0; url=account-confirm-ok.php?type=confirm");
die;
}
if ($site_config["CONFIRMEMAIL"]) { //req confirm email true/false
$status = "pending";
}else{
$status = "confirmed";
}
//make first member admin
if ($numsitemembers == '0') {
$signupclass = '7';
} else {
$signupclass = '1';
}
SQL_Query_exec("INSERT INTO users (username, password, secret, email, status, added, last_access, age, country, gender, client, stylesheet, language, class, ip) VALUES (" .
implode(",", array_map("sqlesc", array($wantusername, $wantpassword, $secret, $email, $status, get_date_time(), get_date_time(), $age, $country, $gender, $client, $site_config["default_theme"], $site_config["default_language"], $signupclass, getip()))).")");
$id = mysqli_insert_id($GLOBALS["DBconnector"]);
$psecret = md5($secret);
$thishost = $_SERVER["HTTP_HOST"];
$thisdomain = preg_replace('/^www\./is', "", $thishost);
//ADMIN CONFIRM
if ($site_config["ACONFIRM"]) {
$body = T_("YOUR_ACCOUNT_AT")." ".$site_config['SITENAME']." ".T_("HAS_BEEN_CREATED_YOU_WILL_HAVE_TO_WAIT")."\n\n".$site_config['SITENAME']." ".T_("ADMIN");
}else{//NO ADMIN CONFIRM, BUT EMAIL CONFIRM
$body = T_("YOUR_ACCOUNT_AT")." ".$site_config['SITENAME']." ".T_("HAS_BEEN_APPROVED_EMAIL")."\n\n ".$site_config['SITEURL']."/account-confirm.php?id=$id&secret=$psecret\n\n".T_("HAS_BEEN_APPROVED_EMAIL_AFTER")."\n\n ".T_("HAS_BEEN_APPROVED_EMAIL_DELETED")."\n\n".$site_config['SITENAME']." ".T_("ADMIN");
}
if ($site_config["CONFIRMEMAIL"]){ //email confirmation is on
sendmail($email, "Your $site_config[SITENAME] User Account", $body, "", "-f$site_config[SITEEMAIL]");
header("Refresh: 0; url=account-confirm-ok.php?type=signup&email=" . urlencode($email));
}else{ //email confirmation is off
header("Refresh: 0; url=account-confirm-ok.php?type=noconf");
}
//send pm to new user
if ($site_config["WELCOMEPMON"]){
$dt = sqlesc(get_date_time());
$msg = sqlesc($site_config["WELCOMEPMMSG"]);
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $id, $dt, $msg, 0)");
}
die;
}
}//end takesignup
stdhead(T_("SIGNUP"));
begin_frame(T_("SIGNUP"));
?>
<?php echo T_("COOKIES"); ?>
<form method="post" action="account-signup.php?takesignup=1">
<?php if ($invite_row) { ?>
<input type="hidden" name="invite" value="<?php echo $_GET["invite"]; ?>" />
<input type="hidden" name="secret" value="<?php echo htmlspecialchars($_GET["secret"]); ?>" />
<?php } ?>
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td><?php echo T_("USERNAME"); ?>: <font class="required">*</font></td>
<td><input type="text" size="40" name="wantusername" /></td>
</tr>
<tr>
<td><?php echo T_("PASSWORD"); ?>: <font class="required">*</font></td>
<td><input type="password" size="40" name="wantpassword" /></td>
</tr>
<tr>
<td><?php echo T_("CONFIRM"); ?>: <font class="required">*</font></td>
<td><input type="password" size="40" name="passagain" /></td>
</tr>
<?php if (!$invite_row) {?>
<tr>
<td><?php echo T_("EMAIL"); ?>: <font class="required">*</font></td>
<td><input type="text" size="40" name="email" /></td>
</tr>
<?php } ?>
<tr>
<td><?php echo T_("AGE"); ?>:</td>
<td><input type="text" size="40" name="age" maxlength="3" /></td>
</tr>
<tr>
<td><?php echo T_("COUNTRY"); ?>:</td>
<td>
<select name="country" size="1">
<?php
$countries = "<option value=\"0\">---- ".T_("NONE_SELECTED")." ----</option>\n";
$ct_r = SQL_Query_exec("SELECT id,name,domain from countries ORDER BY name");
while ($ct_a = mysqli_fetch_assoc($ct_r)) {
$countries .= "<option value=\"$ct_a[id]\">$ct_a[name]</option>\n";
}
?>
<?php echo $countries; ?>
</select>
</td>
</tr>
<tr>
<td><?php echo T_("GENDER"); ?>:</td>
<td>
<input type="radio" name="gender" value="Male" /><?php echo T_("MALE"); ?>
<input type="radio" name="gender" value="Female" /><?php echo T_("FEMALE"); ?>
</td>
</tr>
<tr>
<td><?php echo T_("PREF_BITTORRENT_CLIENT"); ?>:</td>
<td><input type="text" size="40" name="client" maxlength="20" /></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="<?php echo T_("SIGNUP"); ?>" />
</td>
</tr>
</table>
</form>
<?php
end_frame();
stdfoot();
?>
<?php
/**
* PHP Class for handling Google Authenticator 2-factor authentication.
*
* @author Michael Kliewe
* @copyright 2012 Michael Kliewe
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*
* @link http://www.phpgangsta.de/
*/
class PHPGangsta_GoogleAuthenticator
{
protected $_codeLength = 6;
/**
* Create new secret.
* 16 characters, randomly chosen from the allowed base32 characters.
*
* @param int $secretLength
*
* @return string
*/
public function createSecret($secretLength = 16)
{
$validChars = $this->_getBase32LookupTable();
// Valid secret lengths are 80 to 640 bits
if ($secretLength < 16 || $secretLength > 128) {
throw new Exception('Bad secret length');
}
$secret = '';
$rnd = false;
if (function_exists('random_bytes')) {
$rnd = random_bytes($secretLength);
} elseif (function_exists('mcrypt_create_iv')) {
$rnd = mcrypt_create_iv($secretLength, MCRYPT_DEV_URANDOM);
} elseif (function_exists('openssl_random_pseudo_bytes')) {
$rnd = openssl_random_pseudo_bytes($secretLength, $cryptoStrong);
if (!$cryptoStrong) {
$rnd = false;
}
}
if ($rnd !== false) {
for ($i = 0; $i < $secretLength; ++$i) {
$secret .= $validChars[ord($rnd[$i]) & 31];
}
} else {
throw new Exception('No source of secure random');
}
return $secret;
}
/**
* Calculate the code, with given secret and point in time.
*
* @param string $secret
* @param int|null $timeSlice
*
* @return string
*/
public function getCode($secret, $timeSlice = null)
{
if ($timeSlice === null) {
$timeSlice = floor(time() / 30);
}
$secretkey = $this->_base32Decode($secret);
// Pack time into binary string
$time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice);
// Hash it with users secret key
$hm = hash_hmac('SHA1', $time, $secretkey, true);
// Use last nipple of result as index/offset
$offset = ord(substr($hm, -1)) & 0x0F;
// grab 4 bytes of the result
$hashpart = substr($hm, $offset, 4);
// Unpak binary value
$value = unpack('N', $hashpart);
$value = $value[1];
// Only 32 bits
$value = $value & 0x7FFFFFFF;
$modulo = pow(10, $this->_codeLength);
return str_pad($value % $modulo, $this->_codeLength, '0', STR_PAD_LEFT);
}
/**
* Get QR-Code URL for image, from google charts.
*
* @param string $name
* @param string $secret
* @param string $title
* @param array $params
*
* @return string
*/
public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = array())
{
$width = !empty($params['width']) && (int) $params['width'] > 0 ? (int) $params['width'] : 200;
$height = !empty($params['height']) && (int) $params['height'] > 0 ? (int) $params['height'] : 200;
$level = !empty($params['level']) && array_search($params['level'], array('L', 'M', 'Q', 'H')) !== false ? $params['level'] : 'M';
$urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.'');
if (isset($title)) {
$urlencoded .= urlencode('&issuer='.urlencode($title));
}
return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level";
}
/**
* Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now.
*
* @param string $secret
* @param string $code
* @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after)
* @param int|null $currentTimeSlice time slice if we want use other that time()
*
* @return bool
*/
public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null)
{
if ($currentTimeSlice === null) {
$currentTimeSlice = floor(time() / 30);
}
if (strlen($code) != 6) {
return false;
}
for ($i = -$discrepancy; $i <= $discrepancy; ++$i) {
$calculatedCode = $this->getCode($secret, $currentTimeSlice + $i);
if ($this->timingSafeEquals($calculatedCode, $code)) {
return true;
}
}
return false;
}
/**
* Set the code length, should be >=6.
*
* @param int $length
*
* @return PHPGangsta_GoogleAuthenticator
*/
public function setCodeLength($length)
{
$this->_codeLength = $length;
return $this;
}
/**
* Helper class to decode base32.
*
* @param $secret
*
* @return bool|string
*/
protected function _base32Decode($secret)
{
if (empty($secret)) {
return '';
}
$base32chars = $this->_getBase32LookupTable();
$base32charsFlipped = array_flip($base32chars);
$paddingCharCount = substr_count($secret, $base32chars[32]);
$allowedValues = array(6, 4, 3, 1, 0);
if (!in_array($paddingCharCount, $allowedValues)) {
return false;
}
for ($i = 0; $i < 4; ++$i) {
if ($paddingCharCount == $allowedValues[$i] &&
substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) {
return false;
}
}
$secret = str_replace('=', '', $secret);
$secret = str_split($secret);
$binaryString = '';
for ($i = 0; $i < count($secret); $i = $i + 8) {
$x = '';
if (!in_array($secret[$i], $base32chars)) {
return false;
}
for ($j = 0; $j < 8; ++$j) {
$x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
}
$eightBits = str_split($x, 8);
for ($z = 0; $z < count($eightBits); ++$z) {
$binaryString .= (($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48) ? $y : '';
}
}
return $binaryString;
}
/**
* Get array with all 32 characters for decoding from/encoding to base32.
*
* @return array
*/
protected function _getBase32LookupTable()
{
return array(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 7
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 15
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 23
'Y', 'Z', '2', '3', '4', '5', '6', '7', // 31
'=', // padding char
);
}
/**
* A timing safe equals comparison
* more info here: http://blog.ircmaxell.com/2014/11/its-all-about-time.html.
*
* @param string $safeString The internal (safe) value to be checked
* @param string $userString The user submitted (unsafe) value
*
* @return bool True if the two strings are identical
*/
private function timingSafeEquals($safeString, $userString)
{
if (function_exists('hash_equals')) {
return hash_equals($safeString, $userString);
}
$safeLen = strlen($safeString);
$userLen = strlen($userString);
if ($userLen != $safeLen) {
return false;
}
$result = 0;
for ($i = 0; $i < $userLen; ++$i) {
$result |= (ord($safeString[$i]) ^ ord($userString[$i]));
}
// They are only identical strings if $result is exactly 0...
return $result === 0;
}
}
<?php
//SERVER LOAD BLOCK
if (!$site_config["MEMBERSONLY"] || $CURUSER) {
begin_block(T_("SERVER_LOAD"));
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<?php
if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
if (!class_exists("COM"))
echo "COM support not available.";
} else {
// Load information
$reguptime = exec("uptime");
if ($reguptime) {
if (preg_match("/up\s+(?:(\d+)\s+days?,\s+)?(?:(\d+):(\d+))?,/", $reguptime, $uptimeMatches)) {
$days = isset($uptimeMatches[1]) ? $uptimeMatches[1] : 0;
$hours = isset($uptimeMatches[2]) ? $uptimeMatches[2] : 0;
$minutes = isset($uptimeMatches[3]) ? $uptimeMatches[3] : 0;
// Build a user-friendly uptime string
$up = [];
if ($days > 0) $up[] = "$days day" . ($days > 1 ? "s" : "");
if ($hours > 0) $up[] = "$hours hour" . ($hours > 1 ? "s" : "");
if ($minutes > 0) $up[] = "$minutes minute" . ($minutes > 1 ? "s" : "");
$up = implode(", ", $up);
} else {
$up = "--";
}
// Extract load averages and user count
if (preg_match("/(\d+) (users?), .*: (.*), (.*), (.*)/", $reguptime, $loadMatches)) {
$users[0] = $loadMatches[1];
$users[1] = $loadMatches[2];
$loadnow = $loadMatches[3];
$load5 = $loadMatches[4];
$load15 = $loadMatches[5];
} else {
$users[0] = "NA";
$users[1] = "--";
$loadnow = "NA";
$load5 = "--";
$load15 = "--";
}
} else {
$up = "--";
$users[0] = "NA";
$users[1] = "--";
$loadnow = "NA";
$load5 = "--";
$load15 = "--";
}
// Operating system
$operatingsystem = defined('PHP_OS_FAMILY') ? PHP_OS_FAMILY : php_uname('s') . " " . php_uname('r');
// RAM usage
$meminfo = file_get_contents("/proc/meminfo");
preg_match("/^MemTotal:\s*(?P<total>\d+) kB.*^MemFree:\s*(?P<free>\d+) kB.*^Buffers:\s*(?P<buffers>\d+) kB.*^Cached:\s*(?P<cached>\d+) kB/ms", $meminfo, $matches);
$memtotal = $matches['total'] * 1024;
$memfree = $matches['free'] * 1024;
$buffers = $matches['buffers'] * 1024;
$cached = $matches['cached'] * 1024;
$memused = mksize($memtotal - $memfree - $buffers - $cached);
$memtotal = mksize($memtotal);
$phpload = round(memory_get_usage() / 1000000, 2);
// Disk space
$fs = "/";
$disk_total_space = disk_total_space($fs);
$disk_free_space = disk_free_space($fs);
$disk_used_space = $disk_total_space - $disk_free_space;
echo ("<b>Total HDD: </b>" . round($disk_total_space / (1024 * 1024 * 1024)) . " GB<br />");
echo ("<b>HDD Used: </b>" . round($disk_used_space / (1024 * 1024 * 1024)) . " GB<br />");
echo ("<b>Percent Used: </b>" . round(($disk_used_space / $disk_total_space) * 100) . " %<br /><hr />");
// CPU Information
$cpuinfo = file_get_contents('/proc/cpuinfo');
preg_match_all('/^model name\s+\:\s+(.*)$/m', $cpuinfo, $modelMatches);
$totalCores = count($modelMatches[1]);
$cpuModel = $modelMatches[1][0] ?? "Unknown";
echo "<b>CPU:</b> $cpuModel<br />";
echo "<b>Total Cores:</b> $totalCores<br /><hr />";
// Display server stats
echo("<b>" . T_("CURRENT_LOAD") . ":</b> $loadnow<br />");
echo("<b>" . T_("LOAD_5_MINS") . ":</b> $load5<br />");
echo("<b>" . T_("LOAD_15_MINS") . ":</b> $load15<br /><hr />");
echo("<b>PHP Load:</b> $phpload MB<br />");
echo("<b>OS:</b> $operatingsystem<br />");
echo("<b>" . T_("RAM_USED") . ":</b> $memused of $memtotal<br />");
echo("<b>" . T_("UPTIME") . ":</b> $up<br />");
}
?>
</td>
</tr>
</table>
<?php
end_block();
}
?>
disable_functions = exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname