2004-10-16 00:28:17 +00:00
< ? /*
Copyright ( C ) 2004 by Duane Groth < duane_at_CAcert_dot_org >
This file is part of CAcert .
CAcert has been released under the CAcert Source License
which can be found included with these source files or can
be downloaded from the internet from the following address :
http :// www . cacert . org / src - lic . php
CAcert is distributed WITHOUT ANY WARRANTY ; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE . See the License for more details .
*/ ?>
< ?
loadem ( " index " );
$id = intval ( $id );
$oldid = intval ( $oldid );
$_SESSION [ '_config' ][ 'hostname' ] = $_SERVER [ 'HTTP_HOST' ];
if (( $oldid == 6 || $id == 6 ) && intval ( $_SESSION [ 'lostpw' ][ 'user' ][ 'id' ]) < 1 )
{
unset ( $oldid );
$id = 5 ;
}
if ( $oldid == 6 && $process == _ ( " Next " ))
{
$answers = 0 ;
$qs = array ();
$id = $oldid ;
unset ( $oldid );
if ( $Q1 )
{
$_SESSION [ 'lostpw' ][ 'A1' ] = trim ( mysql_escape_string ( stripslashes ( $A1 )));
if ( strtolower ( $_SESSION [ 'lostpw' ][ 'A1' ]) == strtolower ( $_SESSION [ 'lostpw' ][ 'user' ][ 'A1' ]))
$answers ++ ;
$body .= " System: " . $_SESSION [ 'lostpw' ][ 'A1' ] . " \n Entered: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'A1' ] . " \n " ;
}
if ( $Q2 )
{
$_SESSION [ 'lostpw' ][ 'A2' ] = trim ( mysql_escape_string ( stripslashes ( $A2 )));
if ( strtolower ( $_SESSION [ 'lostpw' ][ 'A2' ]) == strtolower ( $_SESSION [ 'lostpw' ][ 'user' ][ 'A2' ]))
$answers ++ ;
$body .= " System: " . $_SESSION [ 'lostpw' ][ 'A2' ] . " \n Entered: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'A2' ] . " \n " ;
}
if ( $Q3 )
{
$_SESSION [ 'lostpw' ][ 'A3' ] = trim ( mysql_escape_string ( stripslashes ( $A3 )));
if ( strtolower ( $_SESSION [ 'lostpw' ][ 'A3' ]) == strtolower ( $_SESSION [ 'lostpw' ][ 'user' ][ 'A3' ]))
$answers ++ ;
$body .= " System: " . $_SESSION [ 'lostpw' ][ 'A3' ] . " \n Entered: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'A3' ] . " \n " ;
}
if ( $Q4 )
{
$_SESSION [ 'lostpw' ][ 'A4' ] = trim ( mysql_escape_string ( stripslashes ( $A4 )));
if ( strtolower ( $_SESSION [ 'lostpw' ][ 'A4' ]) == strtolower ( $_SESSION [ 'lostpw' ][ 'user' ][ 'A4' ]))
$answers ++ ;
$body .= " System: " . $_SESSION [ 'lostpw' ][ 'A4' ] . " \n Entered: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'A4' ] . " \n " ;
}
if ( $Q5 )
{
$_SESSION [ 'lostpw' ][ 'A5' ] = trim ( mysql_escape_string ( stripslashes ( $A5 )));
if ( strtolower ( $_SESSION [ 'lostpw' ][ 'A5' ]) == strtolower ( $_SESSION [ 'lostpw' ][ 'user' ][ 'A5' ]))
$answers ++ ;
$body .= " System: " . $_SESSION [ 'lostpw' ][ 'A5' ] . " \n Entered: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'A5' ] . " \n " ;
}
$_SESSION [ 'lostpw' ][ 'pw1' ] = trim ( mysql_escape_string ( stripslashes ( $newpass1 )));
$_SESSION [ 'lostpw' ][ 'pw2' ] = trim ( mysql_escape_string ( stripslashes ( $newpass2 )));
if ( $answers < 3 )
{
$body = " Someone has just attempted to update the pass phrase on the following account: \n " .
" Username(ID): " . $_SESSION [ 'lostpw' ][ 'user' ][ 'email' ] . " ( " . $_SESSION [ 'lostpw' ][ 'user' ][ 'id' ] . " ) \n " .
" email: " . $_SESSION [ 'lostpw' ][ 'user' ][ 'email' ] . " \n " .
" Requested Pass Phrase: " . $_SESSION [ 'lostpw' ][ 'pw1' ] . " \n " .
" IP/Hostname: " . $_SERVER [ 'REMOTE_ADDR' ] . " / " . $_SERVER [ 'REMOTE_HOST' ] . " \n " .
" --------------------------------------------------------------------- \n " . $body .
" --------------------------------------------------------------------- \n " ;
mail ( " duane@cacert.org " , " [CAcert.org] Requested Pass Phrase Change " , $body ,
" From: ' " . $_SESSION [ 'lostpw' ][ 'user' ][ 'fname' ] . " ' < " . $_SESSION [ 'lostpw' ][ 'user' ][ 'email' ] . " > \n " .
" Errors-To: returns@cacert.org \n From: Support <duane@cacert.org> " );
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " You failed to get all answers correct, system admins have been notified. " );
} else if ( $_SESSION [ 'lostpw' ][ 'pw1' ] != $_SESSION [ 'lostpw' ][ 'pw2' ] || $_SESSION [ 'lostpw' ][ 'pw1' ] == " " ) {
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " New Pass Phrases specified don't match or were blank. " );
} else if ( strlen ( $_SESSION [ 'lostpw' ][ 'pw1' ]) < 6 ) {
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " The Pass Phrase you submitted was too short. " );
} else {
$score = checkpw ( $_SESSION [ 'lostpw' ][ 'pw1' ], $_SESSION [ 'lostpw' ][ 'user' ][ 'email' ], $_SESSION [ 'lostpw' ][ 'user' ][ 'fname' ],
$_SESSION [ 'lostpw' ][ 'user' ][ 'mname' ], $_SESSION [ 'lostpw' ][ 'user' ][ 'lname' ], $_SESSION [ 'lostpw' ][ 'user' ][ 'suffix' ]);
if ( $score < 3 )
{
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " The Pass Phrase you submitted failed to contain enough differing characters and/or contained words from your name and/or email address. Only scored $score points out of 6. " );
} else {
mysql_query ( " update `users` set `password`=password( " . $_SESSION [ 'lostpw' ][ 'pw1' ] . " )
where `id` = '".$_SESSION[' lostpw '][' user '][' id ']."' " );
showheader ( _ ( " Welcome to CAcert.org " ));
echo _ ( " Your Pass Phrase has been updated and your primary email account has been notified of the change. " );
showfooter ();
exit ;
}
}
}
if ( $oldid == 5 && $process == _ ( " Next " ))
{
$email = $_SESSION [ 'lostpw' ][ 'email' ] = trim ( mysql_escape_string ( stripslashes ( $email )));
$_SESSION [ 'lostpw' ][ 'day' ] = intval ( $day );
$_SESSION [ 'lostpw' ][ 'month' ] = intval ( $month );
$_SESSION [ 'lostpw' ][ 'year' ] = intval ( $year );
$dob = $_SESSION [ 'lostpw' ][ 'year' ] . " - " . $_SESSION [ 'lostpw' ][ 'month' ] . " - " . $_SESSION [ 'lostpw' ][ 'day' ];
$query = " select * from `users` where `email`=' $email ' and `dob`=' $dob ' " ;
$res = mysql_query ( $query );
if ( mysql_num_rows ( $res ) <= 0 )
{
$id = $oldid ;
unset ( $oldid );
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " Unable to match your details with any user accounts on file " );
} else {
$id = 6 ;
$_SESSION [ 'lostpw' ][ 'user' ] = mysql_fetch_assoc ( $res );
}
}
if ( $id == 4 && $_SERVER [ 'HTTP_HOST' ] == " secure.cacert.org " )
{
$query = " select * from `emailcerts` where `serial`=' $_SERVER[SSL_CLIENT_M_SERIAL] ' and `revoked`=0 and
UNIX_TIMESTAMP ( `expire` ) - UNIX_TIMESTAMP () > 0 " ;
$res = mysql_query ( $query );
if ( mysql_num_rows ( $res ) > 0 )
{
$row = mysql_fetch_assoc ( $res );
$_SESSION [ 'profile' ] = mysql_fetch_assoc ( mysql_query ( " select * from `users` where `id`=' $row[memid] ' " ));
$_SESSION [ 'profile' ][ 'loggedin' ] = 1 ;
header ( " location: https:// " . $_SERVER [ 'HTTP_HOST' ] . " /account.php " );
exit ;
}
}
if ( $id == 4 && $_SESSION [ 'profile' ][ 'loggedin' ] == 1 )
{
header ( " location: https:// " . $_SERVER [ 'HTTP_HOST' ] . " /account.php " );
exit ;
}
if ( $oldid == 4 )
{
unset ( $oldid );
$id = 4 ;
$_SESSION [ '_config' ][ 'errmsg' ] = " " ;
$email = mysql_escape_string ( $email );
$pword = mysql_escape_string ( $pword );
$query = " select * from `users` where `email`=' $email ' and `password`=password(' $pword ') " ;
$res = mysql_query ( $query );
if ( mysql_num_rows ( $res ) > 0 )
{
$_SESSION [ 'profile' ] = mysql_fetch_assoc ( $res );
2004-10-16 14:45:32 +00:00
if ( $_SESSION [ 'profile' ][ 'language' ] == " " )
{
$query = " update `users` set `language`=' " . $_SESSION [ '_config' ][ 'language' ] . " '
where `id` = '".$_SESSION[' profile '][' id ']."' " ;
mysql_query ( $query );
2004-10-16 15:11:25 +00:00
} else {
$_SESSION [ '_config' ][ 'language' ] = $_SESSION [ 'profile' ][ 'language' ];
putenv ( " LANG= " . $_SESSION [ '_config' ][ 'language' ]);
setlocale ( LC_ALL , $_SESSION [ '_config' ][ 'language' ]);
$domain = 'messages' ;
bindtextdomain ( " $domain " , " /home/cacert/locale " );
textdomain ( " $domain " );
2004-10-16 14:45:32 +00:00
}
2004-10-16 00:28:17 +00:00
$query = " select sum(`points`) as `total` from `notary` where `to`=' " . $_SESSION [ 'profile' ][ 'id' ] . " ' group by `to` " ;
$res = mysql_query ( $query );
$row = mysql_fetch_assoc ( $res );
$_SESSION [ 'profile' ][ 'points' ] = $row [ 'total' ];
$_SESSION [ 'profile' ][ 'loggedin' ] = 1 ;
if ( $_SESSION [ '_config' ][ 'oldlocation' ] != " " )
header ( " location: https:// " . $_SERVER [ 'HTTP_HOST' ] . " / " . $_SESSION [ '_config' ][ 'oldlocation' ]);
else
header ( " location: https:// " . $_SERVER [ 'HTTP_HOST' ] . " /account.php " );
exit ;
}
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " Incorrect email address and/or Pass Phrase. " );
}
if ( $process && $oldid == 1 )
{
$id = 2 ;
unset ( $oldid );
$_SESSION [ '_config' ][ 'errmsg' ] = " " ;
$_SESSION [ 'signup' ][ 'email' ] = trim ( mysql_escape_string ( stripslashes ( $email )));
$_SESSION [ 'signup' ][ 'fname' ] = trim ( mysql_escape_string ( stripslashes ( $fname )));
$_SESSION [ 'signup' ][ 'mname' ] = trim ( mysql_escape_string ( stripslashes ( $mname )));
$_SESSION [ 'signup' ][ 'lname' ] = trim ( mysql_escape_string ( stripslashes ( $lname )));
$_SESSION [ 'signup' ][ 'suffix' ] = trim ( mysql_escape_string ( stripslashes ( $suffix )));
$_SESSION [ 'signup' ][ 'day' ] = intval ( $day );
$_SESSION [ 'signup' ][ 'month' ] = intval ( $month );
$_SESSION [ 'signup' ][ 'year' ] = intval ( $year );
$_SESSION [ 'signup' ][ 'pword1' ] = mysql_escape_string ( $pword1 );
$_SESSION [ 'signup' ][ 'pword2' ] = mysql_escape_string ( $pword2 );
$_SESSION [ 'signup' ][ 'Q1' ] = trim ( mysql_escape_string ( stripslashes ( $Q1 )));
$_SESSION [ 'signup' ][ 'Q2' ] = trim ( mysql_escape_string ( stripslashes ( $Q2 )));
$_SESSION [ 'signup' ][ 'Q3' ] = trim ( mysql_escape_string ( stripslashes ( $Q3 )));
$_SESSION [ 'signup' ][ 'Q4' ] = trim ( mysql_escape_string ( stripslashes ( $Q4 )));
$_SESSION [ 'signup' ][ 'Q5' ] = trim ( mysql_escape_string ( stripslashes ( $Q5 )));
$_SESSION [ 'signup' ][ 'A1' ] = trim ( mysql_escape_string ( stripslashes ( $A1 )));
$_SESSION [ 'signup' ][ 'A2' ] = trim ( mysql_escape_string ( stripslashes ( $A2 )));
$_SESSION [ 'signup' ][ 'A3' ] = trim ( mysql_escape_string ( stripslashes ( $A3 )));
$_SESSION [ 'signup' ][ 'A4' ] = trim ( mysql_escape_string ( stripslashes ( $A4 )));
$_SESSION [ 'signup' ][ 'A5' ] = trim ( mysql_escape_string ( stripslashes ( $A5 )));
if ( $_SESSION [ 'signup' ][ 'fname' ] == " " || $_SESSION [ 'signup' ][ 'lname' ] == " " )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " First and/or last names were blank. " ) . " <br> \n " ;
}
if ( $_SESSION [ 'signup' ][ 'year' ] < 1900 || $_SESSION [ 'signup' ][ 'month' ] < 1 || $_SESSION [ 'signup' ][ 'month' ] > 12 ||
$_SESSION [ 'signup' ][ 'day' ] < 1 || $_SESSION [ 'signup' ][ 'day' ] > 31 )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " Invalid date of birth " ) . " <br> \n " ;
}
if ( $_SESSION [ 'signup' ][ 'email' ] == " " )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " Email Address was blank " ) . " <br> \n " ;
}
if ( $_SESSION [ 'signup' ][ 'pword1' ] == " " )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " Pass Phrases were blank " ) . " <br> \n " ;
}
if ( $_SESSION [ 'signup' ][ 'pword1' ] != $_SESSION [ 'signup' ][ 'pword2' ])
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " Pass Phrases don't match " ) . " <br> \n " ;
}
$score = checkpw ( $_SESSION [ 'signup' ][ 'pword1' ], $_SESSION [ 'signup' ][ 'email' ], $_SESSION [ 'signup' ][ 'fname' ], $_SESSION [ 'signup' ][ 'mname' ], $_SESSION [ 'signup' ][ 'lname' ], $_SESSION [ 'signup' ][ 'suffix' ]);
if ( $score < 3 )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " The Pass Phrase you submitted failed to contain enough differing characters and/or contained words from your name and/or email address. Only scored $score points out of 6. " );
}
$query = " select * from `email` where `email`=' " . $_SESSION [ 'signup' ][ 'email' ] . " ' and `deleted`=0 " ;
$res1 = mysql_query ( $query );
$query = " select * from `users` where `email`=' " . $_SESSION [ 'signup' ][ 'email' ] . " ' and `deleted`=0 " ;
$res2 = mysql_query ( $query );
if ( mysql_num_rows ( $res1 ) > 0 || mysql_num_rows ( $res2 ) > 0 )
{
$id = 1 ;
$_SESSION [ '_config' ][ 'errmsg' ] .= _ ( " This email address is currently valid in the system. " ) . " <br> \n " ;
}
if ( $id == 2 )
{
$rnd = fopen ( " /dev/urandom " , " r " );
$hash = md5 ( fgets ( $rnd , 64 ));
fclose ( $rnd );
$query = " insert into `users` set `email`=' " . $_SESSION [ 'signup' ][ 'email' ] . " ',
`password` = password ( '".$_SESSION[' signup '][' pword1 ']."' ),
`fname` = '".$_SESSION[' signup '][' fname ']."' ,
`mname` = '".$_SESSION[' signup '][' mname ']."' ,
`lname` = '".$_SESSION[' signup '][' lname ']."' ,
`suffix` = '".$_SESSION[' signup '][' suffix ']."' ,
`dob` = '".$_SESSION[' signup '][' year ']."-".$_SESSION[' signup '][' month ']."-".$_SESSION[' signup '][' day ']."' ,
`Q1` = '".$_SESSION[' signup '][' Q1 ']."' ,
`Q2` = '".$_SESSION[' signup '][' Q2 ']."' ,
`Q3` = '".$_SESSION[' signup '][' Q3 ']."' ,
`Q4` = '".$_SESSION[' signup '][' Q4 ']."' ,
`Q5` = '".$_SESSION[' signup '][' Q5 ']."' ,
`A1` = '".$_SESSION[' signup '][' A1 ']."' ,
`A2` = '".$_SESSION[' signup '][' A2 ']."' ,
`A3` = '".$_SESSION[' signup '][' A3 ']."' ,
`A4` = '".$_SESSION[' signup '][' A4 ']."' ,
`A5` = '".$_SESSION[' signup '][' A5 ']."' " ;
mysql_query ( $query );
$memid = mysql_insert_id ();
$query = " insert into `email` set `email`=' " . $_SESSION [ 'signup' ][ 'email' ] . " ',
`hash` = '$hash' ,
`created` = NOW (),
`memid` = '$memid' " ;
mysql_query ( $query );
$emailid = mysql_insert_id ();
$body = _ ( " Thanks for signing up with CAcert.org, below is the link you need to open to verify your account. Once your account is verified you will be able to start issuing certificates till your hearts' content! " ) . " \n \n " ;
$body .= " http:// $hostname /verify.php?type=email&emailid= $emailid &hash= $hash\n\n " ;
$body .= _ ( " Best regards " ) . " \n " . _ ( " CAcert.org Support! " );
mail ( $_SESSION [ 'signup' ][ 'email' ], " [CAcert.org] " . _ ( " Mail Probe " ), $body , " From: Support <duane@cacert.org> \n Errors-To: returns@cacert.org " );
}
}
if ( $oldid == " 11 " && $process == _ ( " Send " ))
{
$who = mysql_escape_string ( $who );
$email = mysql_escape_string ( $email );
$subject = mysql_escape_string ( $subject );
$message = addslashes ( stripslashes ( $message ));
if ( $who == " " || $email == " " || $subject == " " || $message == " " )
{
$id = $oldid ;
$_SESSION [ '_config' ][ 'errmsg' ] = _ ( " All fields are mandatory. " ) . " <br> \n " ;
unset ( $oldid );
}
}
if ( $oldid == " 11 " && $process == _ ( " Send " ))
{
$message = " From: $who\nEmail : $email\nSubject : $subject\n\nMessage : \n " . $message ;
2004-10-16 15:14:46 +00:00
mail ( " duane@cacert.org " , " [CAcert.org] " . $subject , $message , " From: $email\nErrors -To: returns@cacert.org " );
2004-10-16 00:28:17 +00:00
showheader ( _ ( " Welcome to CAcert.org " ));
echo _ ( " Your message has been sent. " );
showfooter ();
exit ;
}
if ( $_SESSION [ 'signup' ][ 'year' ] < 1900 )
$_SESSION [ 'signup' ][ 'year' ] = " 19XX " ;
showheader ( _ ( " Welcome to CAcert.org " ));
includeit ( $id );
showfooter ();
?>