, '".addslashes($_POST['lastname'])."'
		 , '".addslashes($_POST['nickname'])."'
		 , '".addslashes($_POST['password'])."'
		 , '".addslashes($_POST['nation'])."'			 
		 , '".addslashes($_POST['gender'])."'
		 , '".addslashes($_POST['birthdate'])."'
		 , '".$session_time."'
		 , '".time()."'
		 , '".addslashes($_POST['email'])."'
		 , '".$actkey."'
		 )";
		 if( $db->sql_query($sql)) {
			$email_body=sprintf(_Pilot_confirm_subscription,$CONF['site']['name'],$r['user_name'],
				$_SERVER['SERVER_NAME'],
				str_replace('//','/',$_SERVER['SERVER_NAME'].getRelMainDir().'/'.$CONF_mainfile),$actkey );
			LeonardoMail::sendMail('[Leonardo] - Confirmation email',utf8_decode($email_body),$_POST['email'],addslashes($_POST['firstname']));
			
			$msg="<p align='center'>".sprintf(_Server_send_conf_email,$_POST['email'])."</p>";
		 }
    } else {
		 // var_dump($r); 
         $msg="<p align ='center'>". _User_already_registered."</p>"; 
    }  
	      
	echo $msg; closeMain();return;	
	
}



if( !isset($_POST['registerForm'])&& !isset($_GET['rkey'])){
            for ($k = $linesNum - 1; $k > 0; $k--) {
                if (substr($lines[$k], 0, 8) == 'PDF URL:') {
                    $pdfUrls[] = substr($lines[$k], 8);
                }
                if (substr($lines[$k], 0, 9) == 'START PDF') {
                    // echo "Found start of pdf list, breaking <br>";
                    break;
                }
            }
            // print_r($pdfUrls);
            $tmpDir = md5($url);
            $pdfFile = leoPdf::createPDFmulti($pdfUrls, $tmpDir);
            // $pdfFile=$tmpDir.'/logbook.pdf';
            $helperUrl = $CONF['pdf']['helperUrl'];
            if ($helperUrl) {
                $helperUrl = $helperUrl . '/';
            }
            if ($pdfFile) {
                $pdfFile = $helperUrl . $CONF['pdf']['tmpPathRel'] . '/' . $pdfFile;
                //echo "<a href='".$helperUrl.$CONF['pdf']['tmpPathRel'].'/'.$pdfFile."' target='_blank'>PDF is ready</a>";
                // echo "\n\n".$moduleRelPath.'/'.$CONF['pdf']['tmpPathRel'].'/'.$pdfFile;
            } else {
                // echo "ERROR: PDF creation failed";
            }
        }
        $mailBody = "PDF File is ready. <a href='{$pdfFile}'>Download it from here</a>\n";
        echo "PDF FILE: {$pdfFile}\n";
        LeonardoMail::sendMail("Your Leonardo PDF is ready", $mailBody, $userEmail, '');
        leoJob::updateJob($job['jobID']);
    }
}
    // $commentData['dateAdded']=
    $commentData['commentID'] = $newCommentID;
    $commentID = $newCommentID;
    $commentDepth = $newCommentDepth;
    $flight = new flight();
    $flight->getFlightFromDB($commentData['flightID']);
    if ($flight->userID != $userID) {
        global $LeoCodeBase;
        require_once dirname(__FILE__) . '/CL_user.php';
        require_once dirname(__FILE__) . '/CL_mail.php';
        // send email notification to user
        $userEmail = leoUser::getEmail($flight->userID);
        // echo " userEmail= $userEmail";
        $link = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $commentData['flightID'])));
        $email_body = sprintf(_New_comment_email_body, $CONF['site']['name'], $link, $commentData['text']);
        LeonardoMail::sendMail("[Leonardo] " . $CONF['site']['name'] . " - " . sprintf(_You_have_a_new_comment, $_SERVER['SERVER_NAME']), $email_body, $userEmail, addslashes($userEmail), '', '', true);
        // echo "<pre>$email_body</pre>";
    }
    include dirname(__FILE__) . '/INC_comment_row.php';
    echo $str;
    //echo " newCommentID=$newCommentID, flightID=$flightID
    //		parentID=$parentID, guestName=$guestName, userID=$userID,
    //		<hr> $commentText <BR>";
    //echo "OK";
} else {
    if ($op == 'edit') {
        $flightID = makeSane($_POST['flightID']);
        $commentID = makeSane($_POST['commentID']) + 0;
        $commentText = $_POST['commentText'];
        $flightComments = new flightComments($flightID);
        $result = $flightComments->changeComment(array('commentID' => $commentID, 'text' => $commentText));
        // gen a new password with 6 char long;
        //$emailtime=0;
        if ($emailtime + $CONF['userdb']['edit']['password_change_expire_time'] < $ltime) {
            //  print "$emailtime | $ltime";
            $actkey = md5(uniqid(rand(), true));
            $newpass = generatePassword($CONF['userdb']['edit']['password_minlength']);
            if (function_exists('leonardo_hash')) {
                $newPassword = leonardo_hash($newpass);
            } else {
                $newPassword = md5($newpass);
            }
            $sql = "UPDATE " . $CONF['userdb']['users_table'] . " set user_emailtime='" . time() . "', user_newpasswd='" . $newPassword . "',user_actkey='{$actkey}' where " . $CONF['userdb']['user_id_field'] . "=" . $res['user_id'];
            if ($db->sql_query($sql)) {
                $msg = "<span class='ok'><b>" . _Email_new_password . "</b></span>";
                $email_body = sprintf(_Password_recovery_email, $CONF['site']['name'], $res['username'], $_SERVER['SERVER_NAME'], $res['username'], $res['user_civlid'], $newpass, str_replace('//', '/', $_SERVER['SERVER_NAME'] . getRelMainDir() . '/' . $CONF_mainfile), $actkey);
                LeonardoMail::sendMail("[Leonardo] " . $CONF['site']['name'] . " - " . _Password_subject_confirm, utf8_decode($email_body), $res['user_email'], addslashes($_POST['name']));
            }
        } else {
            $expiretime = date("d/M/Y H:i:s", $emailtime + $CONF['userdb']['edit']['password_change_expire_time']);
            $msg = "<span class='alert'><b>" . sprintf(_impossible_to_gen_new_pass, $expiretime) . "</b></span>";
        }
    } else {
        $msg = "<span class='alert'><b>" . _informed_user_not_found . "</b></span>";
    }
}
?>
<style type="text/css">
<!--
.alertMsg a {
	color: #FF0000;
	font-size: 11px;