print $reason ?>
Please use your browser's BACK button to return to your previous page.
The information submitted has NOT been processed
include ("../teenerrorfooter.inc");
}
elseif ($type == "email_error")
{
// include ("../teenerrorheader.inc");
?>
An error has been detected in the EMail Address you submitted.
print $reason; ?>
Please use your browser's BACK button to return to the previous page and
correct the error.
The form you submitted has NOT been processed.
include ("../teenerrorfooter.inc");
}
elseif ($type == "bad_referer")
{
// include ("../teenerrorheader.inc");
?>
An error has been detected in the Referring Address you presented.
print $reason; ?>
Please use your browser's BACK button to return to the previous page and
proceed correctly from there.
The request you submitted has been REFUSED.
include ("../teenerrorfooter.inc");
}
elseif ($type == "URL_error")
{
// include ("../teenerrorheader.inc");
?>
An error has been detected in the URL you submitted.
print $reason; ?>
Please use your browser's BACK button to return to the previous page and
correct the error.
The form you submitted has NOT been processed.
include ("../teenerrorfooter.inc");
}
else // for everything else
{
// include ("../teenerrorheader.inc");
?>
The Information was NOT processed because of the following reason(s):
print $reason ?>
Please use your Browser's 'BACK' button to return to the previous page.
include ("../teenerrorfooter.inc");
}
echo "
\n";
exit;
}
class UsersOnline
{
/* public: connection parameters */
var $host = 'localhost';
var $database = 'websapp';
var $user = '';
var $password = '';
var $timeoutSeconds = 120;
var $numberOfUsers = 0;
function UsersOnline()
{
$this->refresh();
}
function getNumber()
{
return $this->numberOfUsers;
}
function printNumber()
{
if($this->numberOfUsers == 1)
{
echo "$this->numberOfUsers User online";
}
else
{
echo "$this->numberOfUsers Users online";
}
}
function refresh()
{
global $REMOTE_ADDR, $PHP_SELF;
$currentTime = time();
$timeout = $currentTime - $this->timeoutSeconds;
mysql_connect($this->host, $this->user, $this->password)
or die('Error conecting to database');
mysql_db_query($this->database, "INSERT INTO usersonline VALUES ('$currentTime','$REMOTE_ADDR','$PHP_SELF')")
or die('Error writing to database');
mysql_db_query($this->database, "DELETE FROM usersonline WHERE timestamp < $timeout")
or die('Error deleting from database');
$result = mysql_db_query($this->database, "SELECT DISTINCT ip FROM usersonline WHERE file='$PHP_SELF'")
or die('Error reading from database');
$this->numberOfUsers = mysql_num_rows($result);
mysql_close();
}
}
?>
$link;
connectToDB($SERVER_NAME);
function connectToDB($server)
{
global $link;
if ($server == "griffon.personals.net.au")
{
$link = mysql_connect("localhost", "personals", "274401" );
if ( ! $link )
{
die( "FATAL ERROR : Could not connect to Griffon's MySQL Database.
" );
}
mysql_select_db( "personals", $link )
or die ( "FATAL ERROR : Could not open Griffon's MySQL Database: ".mysql_error() );
}
else
{
$link = mysql_connect("mysql13.powweb.com", "tpnpersonals", "c1048576h" );
if ( ! $link )
{
die( "FATAL ERROR : Could not connect to the Teens Personals Network™ MySQL Database" );
}
mysql_select_db( "tpnpersonals", $link )
or die ( "FATAL ERROR : Could not open the Teens Personals Network™ MySQL Database: ".mysql_error() );
}
}
function checkPass( $username, $password, $newmember )
{
global $link;
if ( $newmember == true )
{
if (substr_count($newmember, ".") ) // Is there a '.' in $newmember ? If so then $random_no is set
{
$res1 = explode(".", $newmember); // split sequence number at '.'
$newmember = $res1[0]; // so make $newmember first number - before the '.'
$query1 = "AND RANDOM_NO='$res1[1]'"; // and add this to for random seed number in mySQL query
}
$row = mysql_query( "SELECT * FROM TEMP WHERE USERNAME='$username'",$link ); // get password from database
$getrow = mysql_fetch_array( $row ); // make row of data into array
$salt = substr($getrow[PASSWORD],0,2); // Extract salt from password
$cryptedpwd = crypt( $password, $salt ); // encrypt form password and use in membership query
$query = "SELECT ID, USERNAME, PASSWORD FROM TEMP WHERE USERNAME='$username' AND PASSWORD='$cryptedpwd' AND ID='$newmember' $query1";
$result = mysql_query( $query,$link );
if ( ! $result )
die ( "checkPass FATAL ERROR: ".mysql_error() );
if ( mysql_num_rows( $result ) )
return mysql_fetch_array( $result );
else
return false;
}
else
{
$row = mysql_query( "SELECT * FROM USERS WHERE USERNAME='$username'",$link );
$geturow = mysql_fetch_array( $row );
$salt = substr($geturow[PASSWORD],0,2);
$cryptedpwd = crypt( $password, $salt );
$query = "SELECT UID, USERNAME, PASSWORD FROM USERS WHERE USERNAME='$username' AND PASSWORD='$cryptedpwd'";
$result = mysql_query( $query,$link );
if ( ! $result )
die ( "Teen checkPass FATAL ERROR: ".mysql_error() );
if ( mysql_num_rows( $result ) )
{
mysql_query( "UPDATE USERS set LOGINS = (LOGINS+1) where UID = $geturow[UID] ", $link );
return mysql_fetch_array( $result );
}
else
return false;
}
}
function updateTable( $table,$column,$data,$tableid,$tid )
{
global $link;
$result = mysql_query( "update $table set $column='$data' where $tableid='$tid'", $link);
if ( ! $result )
Print ( "updateTable Failed : ".mysql_error() );
return ( mysql_affected_rows($link) );
}
function log_user ( $id, $username, $action, $log_ip, $address ) // log logins and logouts
{
global $link;
$query = "INSERT into LOG ( UID, USERNAME, ACTION, LOG_IP, ADDRESS ) ";
$query .= "VALUES ( '$id', '$username', '$action', '$log_ip', '$address' )";
mysql_query( $query, $link );
}
function changePwd( $userid, $password )
{
global $link;
$result = mysql_query( "update USERS set PASSWORD='$password' WHERE UID='$userid'",$link );
if (!$result)
return false; // not changed
else
return true; // changed successfully
}
function getRow( $table, $fnm, $fval )
{
global $link;
$result = mysql_query( "SELECT * FROM $table WHERE $fnm='$fval'",$link );
if ( ! $result )
{
die ( "getRow FATAL error: ".mysql_error() );
}
return mysql_fetch_array( $result );
}
function countAds( $user_id ) // Counts the total number of Ads per UID & return Ad numbers
{
global $link;
$count = mysql_query ("select COUNT(*) from PROFILES where UID='$user_id' ", $link );
return mysql_fetch_array( $count );
}
function AdNumbers( $user_id ) // Gives Ad numbers - Used by contact.html
{
global $link;
$result = mysql_query( "Select SID from PROFILES where UID='$user_id' AND STATUS=1 ", $link );
$ret = array();
while ( $row = mysql_fetch_array( $result ) )
array_push( $ret, $row[0] );
return $ret;
}
function getItem( $table, $column, $item, $itemvalue ) // In $table, retrieve $column value where item = itemvalue
{
global $link;
$result = mysql_query( "SELECT $column FROM $table WHERE $item='$itemvalue'", $link );
if ( ! $result )
{
die ( "getRow FATAL error: ".mysql_error() );
}
return mysql_fetch_array( $result );
}
function checkAdmin ( $username )
{
global $link;
$resultant = mysql_query("SELECT UID FROM USERS where USERNAME='$username'", $link );
if ( ! $result1 )
{
Print ( "CheckAdmin Failed : " .mysql_error() );
}
return $resultant;
}
function newUser( $username,$password,$random_no,$gender,$country, $dob,$email,$ip )
{
global $link;
$ts = mktime();
$timestamp = date("j M Y H:i:s", $ts );
$result = mysql_query( "INSERT INTO TEMP (USERNAME,PASSWORD,RANDOM_NO,TIMESTAMP,GENDER,COUNTRY,DOB,EMAIL,IP,REG_SITE)
VALUES ('$username','$password','$random_no','$timestamp','$gender','$country','$dob','$email','$ip','TEENS' )", $link);
if ( ! $result )
{
die ( "newUser Insert Failed : " .mysql_error() );
}
return mysql_insert_id( $link );
}
function updateToAdult($defsite,$uid,$mage)
{
global $teen, $link;
if ($uid == $teen[UID])
$resultant = mysql_query("UPDATE USERS set DEFSITE='$defsite', AGE='$mage' where UID='$teen[id]'", $link );
if ( ! $resultant )
{
Print ( "updateToAdult Failed : " .mysql_error() );
}
return ( mysql_affected_rows($link) );
}
function updateMember( $username,$password,$ustat,$firstname,$lastname,$street,$suburb,$town,$state,$country,$postcode,$email,$dob,
$age,$gender,$icqnum,$timestamp,$term_date,$reg_ip,$sw_icqnum,$uid,$defsite )
{
global $link;
$ts = mktime();
$tstamp = date("j M Y H:i:s", $ts );
if ( ! $uid ) // New member because $uid NOT set
{
$query = "INSERT INTO USERS ( USERNAME, PASSWORD, FIRSTNAME, LASTNAME, STREET, SUBURB, TOWN, STATE, COUNTRY,
POSTCODE, EMAIL, DOB, AGE, GENDER, ICQNUM, TIMESTAMP, TERM_DATE, REG_IP, LASTTIMESTAMP,
SW_ICQNUM, DEFSITE )
VALUES( '$username', '$password', '$firstname', '$lastname', '$street', '$suburb', '$town', '$state', '$country', '$postcode',
'$email', '$dob', '$age', '$gender', '$icqnum', '$timestamp', '$term_date', '$reg_ip', '$tstamp',
'$sw_icqnum', '$defsite' )";
$result = mysql_query( $query, $link );
if ( ! $result )
die ( "insertMember error #1 : ".mysql_error() );
return mysql_insert_id( $link ); // return id
}
if ( $uid ) // must be Update - $uid set
{
$query = "UPDATE USERS set FIRSTNAME='$firstname',LASTNAME='$lastname',USTATUS='$ustat',STREET='$street',SUBURB='$suburb',
TOWN='$town',STATE='$state',COUNTRY='$country',POSTCODE='$postcode',EMAIL='$email',DOB='$dob',AGE='$age',GENDER='$gender',
ICQNUM='$icqnum',TIMESTAMP='$timestamp',TERM_DATE='$term_date',LAST_IP='$reg_ip', SW_ICQNUM='$sw_icqnum'
WHERE UID='$uid'";
$result = mysql_query( $query, $link );
if ( ! $result )
die ( "updateMember update Failed: ".mysql_error() );
return mysql_insert_id( $link ); // return id
}
}
function writeOptionList( $table, $id )
{
global $link;
$query = "select * from $table ";
if ( ( $table == CATADULT ) || ( $table == CATEGORIES ) || ( $table == CATTEEN ) )
$query .= "ORDER BY ORDER_BY, CATNAME";
$result = mysql_query( $query, $link );
if ( ! $result )
{
print "Failed to open $table
"; return false; } while ( $a_row = mysql_fetch_row( $result ) ) { print "\n"; } } function updateAd( $teen_id, $firstname, $lastname, $street, $suburb, $town, $state, $country, $postcode, $email, $dob, $age, $gender, $timestamp, $term_date, $sw_icqnum ) { global $link; $query = "UPDATE USERS set FIRSTNAME='$firstname', LASTNAME='$lastname', STREET='$street', SUBURB='$suburb', "; $query = " TOWN='$town', STATE='$state', COUNTRY='$country', POSTCODE='$postcode', EMAIL='$email', DOB='$dob', AGE='$age', GENDER='$gender', TIMESTAMP='$timestamp', TERM_DATE='$term_date', SW_ICQNUM='$sw_icqnum' WHERE UID='$teen_id'"; $result = mysql_query( $query, $link ); if ( ! $result ) { die ( "updateAd update error: ".mysql_error() ); } } function insertAd( $ad_title, $sex_ori, $what_seek, $available, $occupation, $personality, $looks, $photo, $love, $loathe, $url, $appearcountry, $appearcity, $appearstate, $status, $last_update, $last_ip, $nickname, $incat1, $sw_chat, $my_say, $sitecode, $user_id, $ad_id ) { global $link; if ( ! $ad_id ) // LAST_UPDATE = TIMESTAMP & $LAST_IP = FIRST_IP on insert! { $timestamp = $last_update; $uptime = date("j M Y H:i:s", $timestamp ); // Set UPTIME to human readable form $query = "INSERT INTO PROFILES (AD_TITLE, SEX_ORI, WHAT_SEEK, AVAILABLE, OCCUPATION, PERSONALITY, LOOKS, LOVE, LOATHE, URL, STATUS, APPEARCOUNTRY, APPEARCITY, APPEARSTATE, UPTIME, TIMESTAMP, LAST_UPDATE, FIRST_IP, NICKNAME, INCAT1, SW_CHAT, MY_SAY, SITECODE, UID ) VALUES( '$ad_title', '$sex_ori', '$what_seek', '$available', '$occupation', '$personality', '$looks', '$love', '$loathe', '$url', '$status', '$appearcountry', '$appearcity', '$appearstate', '$uptime', '$timestamp', '$last_update', '$last_ip', '$nickname', '$incat1', '$sw_chat', '$my_say', '$sitecode', '$user_id' )"; } else { $query = "UPDATE PROFILES SET AD_TITLE='$ad_title', SEX_ORI='$sex_ori', WHAT_SEEK='$what_seek', AVAILABLE='$available', OCCUPATION='$occupation', PERSONALITY='$personality', LOOKS='$looks', PHOTO='$photo', LOVE='$love', LOATHE='$loathe', URL='$url', STATUS='$status', APPEARCOUNTRY='$appearcountry', APPEARCITY='$appearcity', APPEARSTATE='$appearstate', LAST_UPDATE='$last_update', LASTIP='$last_ip', NICKNAME='$nickname', INCAT1='$incat1', SW_CHAT='$sw_chat', MY_SAY='$my_say', SITECODE='$sitecode' WHERE SID='$ad_id' AND UID='$user_id'"; } $result = mysql_query( $query, $link ); if ( ! $result ) die ( "insertad error: ".mysql_error() ); return mysql_insert_id( $link ); } function deleteAd( $sid, $uid ) { global $link; $query = "UPDATE PROFILES SET UID='0', STATUS='99', OLD_UID='$uid' WHERE SID='$sid' and UID='$uid'"; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "deleteAd FATAL error: ".mysql_error() ); return ( mysql_affected_rows( $link ) ); } function suspendUser( $user_id ) { global $link; $query = "UPDATE PROFILES set STATUS='2' where UID='$user_id'"; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "suspendUser FATAL error: ".mysql_error() ); return ( mysql_affected_rows($link) ); } function getUsers( $country="", $lastname="", $id="" ) { global $link; $query = "SELECT * "; $query .= "FROM USERS, WHERE "; if ( $lastname != "" && ! empty( $lastname ) ) $query .= "USERS.LASTNAME='$lastname' "; if ( ( $lastname != "" ) && (! empty( $lastname ) ) && ($id != "" && ! empty( $id ) ) ) $query .= "AND "; if ( $id != "" && ! empty( $id ) ) $query .= "USERS.UID='$id' "; $query .= "ORDER BY USERS.UID"; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "getUsers Fatal Error: ".mysql_error() ); $ret = array(); while ( $row = mysql_fetch_array( $result ) ) array_push( $ret, $row ); return $ret; } function getUserJoined( $id ) { global $link; $query = "SELECT USERS.* "; $query .= "FROM USERS WHERE "; $query .= "USERS.UID='$id'"; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "getUserJoined Fatal Error: ".mysql_error() ); return mysql_fetch_array( $result ); } function retrieveAds ( $email, $username, $user_id, $firstname, $lastname, $nickname, $town, $state, $country, $category, $ad_id, $sitecode, $fromage, $toage ) { global $link; $nowdate = date("U")-31536000; $query = "Select PROFILES.*, USERS.*, SEEKTEEN.SEEK as WHATSEEK, gender.gender as GENDERTYPE "; $query .= "FROM PROFILES, USERS, SEEKTEEN, gender WHERE "; $query .= "PROFILES.UID=USERS.UID AND PROFILES.WHAT_SEEK=SEEKTEEN.ID AND PROFILES.SEX_ORI=gender.id "; if ( ! empty( $email ) ) $query .= "AND USERS.EMAIL like '$email%' "; if ( ! empty( $username ) ) $query .= "AND USERS.USERNAME like '$username%' "; if ( ! empty( $user_id ) ) $query .= "AND USERS.UID='$user_id' "; if ( ! empty( $firstname ) ) $query .= "AND USERS.FIRSTNAME like '$firstname%' "; if ( ! empty( $lastname ) ) $query .= "AND USERS.LASTNAME like '$lastname%' "; if ( ! empty( $nickname ) ) $query .= "AND PROFILES.NICKNAME like '$nickname%' "; if ( ! empty( $country ) && $country != "ANY" ) $query .= "AND USERS.COUNTRY like '$country' "; if ( ! empty( $category ) && $category != "ANY" ) $query .= "AND PROFILES.INCAT1='$category' "; if ( ! empty( $town ) ) $query .= "AND PROFILES.APPEARCITY like '$town%' "; if ( ! empty( $state ) ) $query .= "AND USERS.STATE like '$state%' "; if ( ! empty( $ad_id ) ) $query .= "AND PROFILES.SID='$ad_id' "; if ( ! empty( $fromage ) && ( empty( $toage ) ) ) $query .= "AND USERS.AGE='$fromage' "; if ( ! empty( $fromage ) && ( ! empty( $toage ) ) ) $query .= "AND USERS.AGE BETWEEN '$fromage' AND '$toage' "; $query .= "AND USERS.USTATUS = '1' "; // 1 = user status = active member $query .= "AND USERS.TERM_DATE >= '$nowdate' "; // and not not expired $query .= "AND PROFILES.STATUS = '1' "; // 1 = Visible $query .= "AND USERS.AGE<=19 "; // aged 20 or less $query .= "AND USERS.DEFSITE = 'TEENS' "; $query .= "ORDER BY PROFILES.LAST_UPDATE desc LIMIT 0,25 "; // Limit the output to 25 rows $result = mysql_query( $query, $link ); if ( ! $result ) die ( "retreiveAds Fatal Error: ".mysql_error() ); $teen[countrows] = mysql_num_rows( $result ); $ret = array(); while ( $row = mysql_fetch_array( $result ) ) array_push( $ret, $row ); return $ret; } function getAds( $user_id ) //Used by reviewads.php { global $link; $query = "Select PROFILES.*, USERS.*, "; $query .= "CATEGORIES.CATNAME as CATEGORIESNAME, "; $query .= "SEEK.SEEK as WHATSEEK, "; $query .= "gender.gender as GENDERTYPE "; $query .= "FROM PROFILES, USERS, SEEK, gender, CATEGORIES WHERE "; $query .= "PROFILES.UID=USERS.UID "; $query .= "AND PROFILES.INCAT1=CATEGORIES.CATID "; $query .= "AND PROFILES.WHAT_SEEK=SEEK.ID "; $query .= "AND USERS.GENDER=gender.id "; $query .= "AND PROFILES.UID='$user_id' "; $querey .= "AND PROFILES.STATUS=1"; $query .= "ORDER BY PROFILES.SID "; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "getads Fatal Error: ".mysql_error() ); $teen[countrows] = mysql_num_rows( $result ); $ret = array(); while ( $row = mysql_fetch_array( $result ) ) array_push( $ret, $row ); return $ret; } function getAdverts( $ad_id ) { global $link; $query = "Select PROFILES.*, CATEGORIES.CATNAME as CATEGORIESNAME "; $query .= "FROM PROFILES, CATEGORIES WHERE "; $query .= "PROFILES.INCAT1=CATEGORIES.CATID "; $query .= "AND PROFILES.UID='$ad_id' "; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "getads Fatal Error: ".mysql_error() ); $teen[countrows] = mysql_num_rows( $result ); $ret = array(); while ( $row = mysql_fetch_array( $result ) ) array_push( $ret, $row ); return $ret; } function getAd( $ad_id ) { global $link; $query = "Select PROFILES.*, USERS.*, CATEGORIES.CATNAME as CATEGORIESNAME "; $query .= "FROM PROFILES, USERS, CATEGORIES WHERE "; $query .= "PROFILES.INCAT1=CATEGORIES.CATID "; $query .= "AND PROFILES.UID=USERS.UID "; $query .= "AND PROFILES.SID='$ad_id' "; $query .= "AND USERS.USTATUS=1 "; $querey .= "AND PROFILES.STATUS=1"; $result = mysql_query( $query, $link ); if ( ! $result ) die ( "getAd Fatal Error: ".mysql_error() ); return mysql_fetch_array( $result ); } ?> session_start(); session_register('teen'); function setUserSession( $id, $username, $password, $newmember ) { global $teen; $teen[id] = $id; $teen[username] = $username; $teen[login] = $username; $teen[password] = $password; $teen[logged_in] = true; $teen[data] = true; $teen[newmember] = $newmember; } function getCount( $db ) //Counts the total number of rows in the nominated table { global $link; $count = mysql_query ("SELECT COUNT(*) FROM $db;", $link ); if ( ! $count) die ( "getCount FATAL ERROR : " .mysql_error() ); return mysql_fetch_array( $count ); } function checkSessionActive () // Has Session timed out ? { global $teen; if ( $teen[logged_in] == false ) { $teen[sessionend] = "Your Login Session has timed out or is invalid"; header( "Location: login.php" ); // send to Login with explanation. } else return true; } function checkUser($agent=0,$referrer=0,$uri=0,$remoteaddr=0,$self=0,$server=0) // Security { global $teen, $link; $teen[logged_in] = false; $teen[data] = false; $user_row = getRow( "USERS", "UID", $teen[id] ); $salt = substr($user_row[PASSWORD],0,2); $cryptpwd = crypt($teen[password], $salt ); if ( ( ! $user_row ) || ( $user_row[USERNAME] != $teen[login] ) || ( $user_row[PASSWORD] != $cryptpwd ) ) { mail( "ads@personals.net.au","checkUser() ERROR","Site : TEENS $teen[id] : $user_row[USERNAME] $teen[username] ServerName = $server PHP_Self = $self User IPAddress: $remoteaddr Requested URL: $uri Requester Page: $referrer User Client : $agent", "FROM: webmaster@teens.personals.net.au\r\n"); $teen[message]="You are not logged in or your login expired."; session_unregister("teen"); // session_destroy(); header( "Location: login.php" ); exit; } $teen[logged_in] = true; $nowdate = date("U"); if ( empty( $user_row[FIRSTNAME] ) || empty( $user_row[LASTNAME] ) || empty( $user_row[STREET] ) || ( $user_row[TERM_DATE] <= $nowdate ) || $user_row[USTATUS] >= "9" ) { $teen[data] = false; } else { $teen[data] = true; } return $user_row; } function checkUserData( $userarray ) // checks basic user data is valid { global $teen; if ( ! isset( $userarray[FIRSTNAME] ) || ! isset( $userarray[LASTNAME] ) || ! isset( $userarray[STREET] ) || ! isset( $userarray[EMAIL] ) || ! isset( $userarray[COUNTRY] ) || ! isset( $userarray[TOWN] ) ) { $teen[data] = false; // was $teen[details] ! 080202 10:24 header( "Location: updateuser.php?".SID ); exit; } } function html( $str ) { if ( is_array( $str ) ) { foreach ( $str as $key=>$val ) $str[$key] = htmlstr( $val ); return $str; } return htmlstr( $str ); } function htmlstr( $str ) { $str = htmlspecialchars( $str ); $str = nl2br( $str ); return $str; } ?>
An error was detected. Correct and try again."; ?>
"; print "$message
include ("../teenfooter.inc"); ?>Lost Your Password ?
You MUST fill out ALL fields !
Enter the details below and ensure it is correct.
On submission, a new password will be sent to you.