'3'"; $result = @mysqli_query($authlink, $sql); if (@mysqli_num_rows($result) == 1) { $form = @mysqli_fetch_array($result); $_SESSION['usernamein'] = $form['username']; $_SESSION['passwd'] = $form['password']; $_SESSION['pgm_id'] = $config['pgm_id']; $_SESSION['sess_userid'] = $form['userid']; // Check to see if they have a local user record, read in & set values dbConnectMyAccount(); $sql = "SELECT sec_level, status FROM tbl_users WHERE username='" . addslashes($form['username']) . "'"; $result = @mysqli_query($myaccountdblink, $sql); if (@mysqli_num_rows($result) == 1 ) { $myrow = @mysqli_fetch_array($result); // Deny access to anybody Suspended if ($myrow['status'] != 'a') { error( "Sorry, the system is currently unavailable at the moment.", "MyAccount: suspended user: $client_username"); } $_SESSION['sec_level'] = $myrow['sec_level']; $todays_date = date("Y-m-d") . " " . date("H:i:s"); $sql = "UPDATE tbl_users SET logins=logins+1, last_login='$todays_date' WHERE username = '" . addslashes($form['username']) . "'"; $result = @mysqli_query($myaccountdblink, $sql); } return true; } else { return false; } } } else { return false; } } // --------------------------------------------- function displayHeader($title) { global $config; // Capture the header template if ($file = @fopen($config['header_file'],"r")) { ob_start(); @fpassthru($file); $page = ob_get_contents(); ob_end_clean(); @fclose($file); } // Capture the banner if ($file = @fopen("http://banner.kingsnake.com/ssi/get_banner.php?region=$banner_rotation","r")) { ob_start(); @fpassthru($file); $banner = ob_get_contents(); ob_end_clean(); @fclose($file); } $css = << HTML; $page = str_replace("{title}", strip_tags($title), $page); $page = str_replace("{css}", $css, $page); $page = str_replace("{banner}", $banner, $page); //$page = str_replace("{splash}", $splash, $page); echo $page; } // --------------------------------------------- function displayFooter() { global $config; echo "

\n"; if($myfile = @fopen($config['footer_file'],'r')) { @fpassthru($myfile); } exit; } // --------------------------------------------- function toolbar() { global $config; if ( isset($_SESSION['usernamein']) && isset($_SESSION['passwd']) ) { $TITLE = $_SESSION['usernamein'] . "'s Personal Account Manager"; } else { $TITLE = $config['title']; } print << $TITLE HTML; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "
"; if ( verifyUser() >= 1) { echo "[ Manage Banned IPs | "; echo "Users | "; echo "IP Monitor | "; echo "Recent Accounts ]
"; } if ( verifyUser() >= 2) { echo "[ Manage Local Users | "; echo "Manage Categories ]
"; echo "[ View Module List | "; echo "Add New Module | "; echo "Change a Username ]
"; } echo "[ "; echo "Home | "; echo "View your User Profile | "; if ( isset($_SESSION['usernamein']) && isset($_SESSION['passwd']) ) { echo "Logout {$_SESSION['usernamein']} ]"; } else { echo "Login ]"; } echo "
\n"; } // --------------------------------------------- function error( $error, $details="" ) { global $config; displayHeader("Error Page"); toolbar(); echo "

Error Page

Error: $error

Back  |  {$config['title']}

"; $mydate = date("Y-m-d H:i:s") . ": "; error_log($mydate . " " . $error . "(" . $config['title'] . ")\n", 3, $config['logfile']); if ($details) { error_log ("\t\t\t$details\n", 3, $config['logfile']); } displayFooter(); exit; } //------------------------------------------------------------------ function logit($logtext) { global $config; $logdate = date("Y-m-d H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; $logscript = $_SERVER['SCRIPT_FILENAME']; $logheader = "Entry made from $ip on $logdate\n\t[script: $logscript]\n"; error_log ($logheader, 3, $config['logfile']); $f_logtext = "\t$logtext\n"; error_log ($f_logtext, 3, $config['logfile']); } // --------------------------------------------- function print_message($text) { global $config; print << 

$text
HTML; } // end print_message // --------------------------------------------- function banIPcheck () { global $config, $myaccountdblink; if (!$myaccountdblink) { dbConnectMyAccount(); } if ($config['banIP'] == 1 ) { $result = @mysqli_query($myaccountdblink, "SELECT ip FROM bannedip WHERE ip='" . $_SERVER['REMOTE_ADDR'] . "' LIMIT 1"); if ( @mysqli_num_rows($result)==1 ) { return true; } } return false; } // --------------------------------------------- function monitor_ip_check($ip="") { global $myaccountdblink; if (!$ip) { return false; } if (!$myaccountdblink) { dbConnectMyAccount(); } $result = @mysqli_query($myaccountdblink, "SELECT ip FROM ipmonitor WHERE ip='$ip' LIMIT 1"); if ( @mysqli_num_rows( $result ) == 1 ) { return true; } return false; } // --------------------------------------------- function substrcount($needle, $haystack) { $strcount = explode($needle, $haystack); return count($strcount); } // --------------------------------------------- function is_hostname($hostname) { $tokens = explode(".", $hostname); for ($error = $j = 0; $j < sizeof($tokens); $j++) { if ((!preg_match("/^[a-zA-Z]/", $tokens[$j])) || preg_match("/[^a-zA-Z0-9\-]/", $tokens[$j]) || (!preg_match("/[a-zA-Z0-9]$/", $tokens[$j]))): $error = 1; break; endif; } return ($error == 0) ? true : false; } // --------------------------------------------- function listbox_expire_types($fieldname, $key="") { GLOBAL $expire_types; echo "\n"; } // --------------------------------------------- function create_random_passwd() { global $config; $first = rand(0, 100); $second = $first * (int)time(); $third = md5($second); $fourth = substr($third, 0, 6); if ($config['debug']==1) { echo "DEBUG: password generated is [$fourth]
\n"; } return $fourth; } // --------------------------------------------- function display_message($text="") { global $config; print << $text HTML; } //---------------------------------------------------- function display_banreason_dropdown($key) { // These items also need to be updated in: // banusers, admin-usernotes (x3) echo "\n"; } // ----------------------- Send out Confirmation email ---------------------- function send_email($keynum, $remail, $uid) { global $config; $letter=<<IsSMTP(); $mail->Host = $config['smtp_servername']; $mail->From = "DoNotReply@pethobbyist.com"; $mail->FromName = "Club.Kingsnake.com"; $mail->AddAddress( $remail ); $mail->Subject = "Confirm your Club Kingsnake Registration (action needed)"; $mail->Body = $config['autoMessage'] . $letter; if($mail->Send()) { return true; } else { $mydate = date("Y-m-d H:i:s") . ": "; $details = "send_email function; $remail, $uid - " . $mail->ErrorInfo; error_log ("$mydate $error ($THIS_SITE)\n", 3, $config['hd_path'] . "/tmp/error.log"); error_log ("\t\t\t$details\n", 3, $config['hd_path'] . "/tmp/error.log"); return false; } } // end send_email function // --------------------------------------------- function email_ip_monitor ($ip="", $username="", $email="", $groupid="") { if (!$ip || !$username || !$email) { return false; } global $config; $TEXT=<<IsSMTP(); $mail->Host = $config['smtp_servername']; $mail->From = "DoNotReply@pethobbyist.com"; $mail->FromName = "Club.Kingsnake.com"; //$mail->AddAddress("phginger@pethobbyist.com"); $mail->AddAddress($config['community_email']); $mail->Subject = "$ip: New Club Kingsnake Registration from Monitored IP"; $mail->Body = $TEXT; if($mail->Send()) { return true; } else { return false; } } // end email_ip_monitor function // --------------------------------------------- function send_an_email($emailto="", $message="", $subject="", $bcc="") { global $config; if (!$message || !$subject || !$emailto) { return false; } require_once("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = $config['smtp_servername']; $mail->From = "DoNotReply@pethobbyist.com"; $mail->FromName = "Club.Kingsnake.com"; if ($config['bcc']) { $mail->AddBCC($config['bcc']); } if ( is_array($emailto) ) { foreach ($emailto as $sendto) { $mail->AddAddress($sendto); } } else { $mail->AddAddress($emailto); } $mail->Subject = $subject; $mail->Body = displayFormatTEXT($message); if($mail->Send()) { return true; } else { return false; } } // --------------------------------------------- function add_usernote($username="", $userid="", $reason="", $notes="") { global $myaccountdblink; if (!$myaccountdblink) { dbConnectMyAccount(); } $sql = 'LOCK TABLES usernotes WRITE'; $result = @mysqli_query($myaccountdblink, $sql) or error("Unable to lock the database. Please try again later.", $_SERVER['PHP_SELF'] . ": $sql : " . mysqli_error($myaccountdblink) ); $sql = "SELECT MAX(thread_id) AS my_id FROM usernotes"; $result = @mysqli_query($myaccountdblink, $sql); $row = @mysqli_fetch_array($result); $form = array(); $form['thread_id'] = $row['my_id'] + 1; $form['parent_id'] = 0; $form['level'] = 0; $form['thread_pos'] = 0; if ($_SESSION['usernamein']) { $form['enteredby'] = $_SESSION['usernamein']; } else { $form['enteredby'] = 'AutoPilot'; } $form['date'] = date("Y-m-d H:i:s"); $form['username'] = $username; $form['userid'] = $userid; $form['reason'] = $reason; $form['notes'] = $notes; $form['token'] = uniqid(microtime(),1); foreach ($form as $var => $value) { if ($value) { $form[$var] = displayFormatHTML($value); $form[$var] = addslashes($value); } } $fields = array('date', 'userid', 'username', 'reason', 'notes', 'enteredby', 'thread_id', 'parent_id', 'level', 'thread_pos', 'token'); $insert_values = array(); foreach ($fields as $field) { $insert_values[] = "\"" . $form[$field] . "\""; } $sql = "INSERT INTO usernotes (" . join(',',$fields) . ") VALUES (" . join(',',$insert_values) . ")"; $result = @mysqli_query($myaccountdblink, $sql) or error("Unable to save usernotes to the database. Please try again later.", $_SERVER['PHP_SELF'] . ": $sql : " . mysqli_error($myaccountdblink) ); $parent_id = @mysqli_insert_id($myaccountdblink); // Tell MySQL that others can use the pc_message table now $sql = 'UNLOCK TABLES'; $result = @mysqli_query($myaccountdblink, $sql) or error("Unable to unlock the database. Please try again later.", $_SERVER['PHP_SELF'] . ": $sql : " . mysqli_error($myaccountdblink) ); return $parent_id; } // --------------------------------------------- function dump_array($array) { if (is_array($array)) { $size=count($array); if ($size) { $count = 0; $string .= "{ "; // add each element's key and value to the string foreach($array as $var => $value) { $string .= "$var = $value"; if ($count++ < ($size -1)) { $string .= ", "; } } return $string; } else { // If it is not an array, just return it return $array; } } } ?>