<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

//options

$showonlygamingsquads = true;  //only show gaming squads (=true) or show all squads (=false)?

//php below this line ;)

$action = $_GET['action'];

if($action=="save") {

  $squad = $_POST['squad'];
  $nick = $_POST['nick'];
  $name = $_POST['name'];
  $email = $_POST['email'];
  $messenger = $_POST['messenger'];
  $age = $_POST['age'];
  $city = $_POST['city'];
  $clanhistory = $_POST['clanhistory'];
  $info = $_POST['info'];

	$CAPCLASS = new Captcha;
	if(!$CAPCLASS->check_captcha($_POST['captcha'], $_POST['captcha_hash'])) {
			$error="The security code was wrong!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($nick)))) {
	    $error="you forgot to enter your nickname!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($name)))) {
	    $error="you forgot to enter your realname!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($messenger)))) {
	    $error="you have no icq, msn, aim etc?";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($age)))) {
	    $error="you forgot to enter your age!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($city)))) {
	    $error="you forgot to enter your city!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	if(!(strlen(trim($clanhistory)))) {
	    $error="you forgot to enter your clanhistory!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}
	$sem = '^[a-z0-9_\.-]+@[a-z0-9_-]+\.[a-z0-9_\.-]+$';
	if(!(eregi($sem, $email))) {
	    $error="your e-mail is not valid!";
		die('<b>ERROR: '.$error.'</b><br><br><input type="button" class="button" onClick="javascript:history.back()" value="Back">');
	}

	$ergebnis=safe_query("SELECT userID FROM ".PREFIX."squads_members WHERE joinmember='1' AND squadID='".$squad."'");
	while($ds=mysql_fetch_array($ergebnis)) {
		$touser[]=$ds[userID];
	}

	if($touser[0] != "") {
	$message = '[b]Someone want do join your Squad ('.$squad.')![/b]
         His/her nickname: '.$nick.'
         Name: '.$name.'
         Age: '.$age.'
         Mail: [URL]mailto:'.$email.'[/url]
         Messenger: '.$messenger.'
         City: '.$city.'
         Clanhistory: '.$clanhistory.'

         Information:
         '.$info.'
         ';
	foreach($touser as $id) {
    sendmessage($id,'Join us',$message);
   }
	}
	redirect('index.php?site=joinus', 'thank you for your entry, you will got mail.');
}
else {
    echo'<h2>Join us</h2>';

	if($showonlygamingsquads)	$squads=getgamesquads();
	else $squads=getsquads();

	$CAPCLASS = new Captcha;
	$captcha = $CAPCLASS->create_captcha();
	$hash = $CAPCLASS->get_hash();
	$CAPCLASS->clear_oldcaptcha();
	
	$bg1 = BG_1;

	eval ("\$joinus = \"".gettemplate("joinus")."\";");
    echo $joinus;
}
?>


