/*
+---------------------------------------------------------------+
| e107 website system
|
| ©Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+---------------------------------------------------------------+
*/
//$ec_dir = e_PLUGIN."calendar_menu/";
$lan_file = $ec_dir."languages/".e_LANGUAGE.".php";
include(file_exists($lan_file) ? $lan_file : e_PLUGIN."calendar_menu/languages/English.php");
$datearray = getdate();
$current_day = $datearray['mday'];
$current_month = $datearray['mon'];
$current_year = $datearray['year'];
// get first and last days of month in unix format---------------------------------------------------
$monthstart= mktime(0,0,0,$current_month,1,$current_year);
$firstdayarray = getdate($monthstart);
$monthend = mktime(0,0,0,$current_month+1,0,$current_year);
$lastdayarray = getdate($monthend);
// ----------------------------------------------------------------------------------------------------------
// get events from current month----------------------------------------------------------------------
$sql -> db_Select("event", "*", "(event_start>='$monthstart' AND event_start<= '$monthend') OR (event_rec_y='$current_month')");
$events = $sql -> db_Rows();
while($row = $sql -> db_Fetch()){
extract($row);
$evf = getdate($event_start);
$tmp = $evf['mday'];
$event_true[$tmp] = $event_category;
}
// -----------------------------------------------------------------------------------------------------------
// set up arrays for calender display ------------------------------------------------------------------
$week = Array(EC_LAN_25,EC_LAN_19,EC_LAN_20,EC_LAN_21,EC_LAN_22,EC_LAN_23,EC_LAN_24);
$months = Array(EC_LAN_0,EC_LAN_1,EC_LAN_2,EC_LAN_3,EC_LAN_4,EC_LAN_5,EC_LAN_6,EC_LAN_7,EC_LAN_8,EC_LAN_9,EC_LAN_10,EC_LAN_11);
$calendar_title = $months[$datearray[mon]-1]." ".$current_year;
// -----------------------------------------------------------------------------------------------------------
$text = "";
if($events){
$text .= EC_LAN_26 . ": ".$events;
}else{
$text .= EC_LAN_27;
}
$start = $monthstart;
$text .= "
";
foreach($week as $day){
$text .= "| ".$day." | ";
}
$text .= " ";
$thismonth = $datearray['mon'];
$thisday = $datearray['mday'];
for($c=0; $c<$firstdayarray['wday']; $c++){
$text .= "
| ";
}
$loop = $firstdayarray['wday'];
for($c=1; $c<=31; $c++){
$dayarray = getdate($start+($c*84460));
if($dayarray['mon'] == $thismonth){
if($thisday == $c){
$text .= "";
}else{
$text .=" | ";
}
if($event_true[($c)]){
$sql -> db_Select("event_cat", "*", "event_cat_id='".$event_true[($c)]."' ");
$icon = $sql -> db_Fetch();
extract($icon);
$img = " ";
}else{
$img = " ";
}
$linkut = mktime(0 ,0 ,0 ,$dayarray['mon'], $c, $datearray['year']);
$text .="$img $c";
if($thisday == $c){
}
$text .= " | \n";
$loop++;
if($loop == 7){
$loop = 0;
$text .= " ";
}
}
}
for($a=($loop+1); $a<=7; $a++){
$text .="| | ";
}
$text .= "
";
$ns -> tablerender($calendar_title, $text);
?>
|
// Area Identification
$caption = 'Managing Your Pilots';
$text = ' ';
// Form processing follows here
if ($_SESSION['uobject'] && $_GET['id']){ // We are doing work on a specific pilot
// Before we get started we need to make sure that this pilot is indeed linked to
// the present defined USERID.
if ($_POST){ // Everything is cool, this is not a hacking attempt
switch($_GET['cmd']){
case 'assign':
// Assign a pilot to a group
// Although technically a group function, starting from the group
// didn't provide the necessary information
if(!$pinfo){ $pinfo = new Pilot_Class($_GET['id']); }
// First make sure there is something to do
if ($_POST['g_pid'] == ''){ break; }
// Okay they have selected one, so now lets double check that this is a
// valid id.
$array = $GLOBALS['services']->sql_autofetch('SELECT group_name FROM groups WHERE group_id='.$_POST['g_pid']);
if ($array['group_name'] == ''){ // id not found
$error = error_layout('No group was found matching the parameters passed.');
break;
}
// This is a valid ID so lets get to updating
$squad = $pinfo->squad;
$groups = $squad->groups;
// Search through groups to find right one
foreach($groups as $group){
if ($group->id == $_POST['g_pid']){
$found = $group; // catch for if never found, cant use error ;-)
$error = $group->addToGroup($_GET['id']);
if ($error){
$error = error_layout($error);
break;
}
}
}
if (!$found){
$error = error_layout('No group was found to assign this pilot to.');
}
// Everything worked fine.
$successful = 1;
break;
case 'join':
// They are joining a faction.
// In doing so their scores have to be cleared.
// First make sure they submitted something
if (!$_POST['p_faction']) { break; }
// Now lets assign them to the faction
$error = $pinfo->joinFaction($_POST['p_faction']);
if ($error){
$error = error_layout($error);
break;
} else {
$successful = 1;
}
break; // end Join Process
case 'leave':
// They are leaving their current faction
// There is quite a bit of work to remove someone from a faction
// 1) They have to be removed from any squad they are part of.
// a) if they are the squad leader the squad must be deleted.
// 2) They must be removed from any group they are apart of
// a) If they were the squad leader then the entire group gets deleted
// b) If they are the co of the group it needs to be deleted.
// 3) Faction info then has to be removed.
// First make sure they submitted something
if (!$_POST['p_quit']){ break; }
// We don't have to do lots of checks becuase the id is already guaranteed.
// But we do need to check that the no was not selected.
if ($_POST['p_quit'] == 'N'){
// They selected no, so give them back to the default screen.
$_GET['cmd'] = '';
break;
}
// They did select Yes so we need to remove them.
// Are they part of a squad (which then means they are part of a group most likely)
if ($pinfo->inSquad()) { // yes
// Okay now is this person a squad leader?
if ($pinfo->isSquadLeader()){ //yes
// Okay we just going to call the delete command from the class and let it figure
// out how to remove everything.
$error = $pinfo->deleteSquad();
} else { // no not squad leader
// Now we have to be delicate, so we have to prune both squad and group
$error = $pinfo->removeFromSquad();
if (!$error && $pinfo->inGroup()){ // Makes sure there is a group to have the Pilot removed from
$error = $pinfo->removeFromGroup();
}
}
}
if ($error){
// There was a problem so quit process
$error = error_layout($error);
break;
} else {
// Now that squad and group are handled, remove person from faction
$error = $pinfo->removeFromFaction();
if ($error){ // failed
$error = error_layout($error);
} else { // succeeded
$successful = 1;
}
}
break; // End Leave process
case 'passwd':
// They are changing the password for their pilot
// First check is to make sure they submitted something.
if ($_POST['p_pass1'] == ''){ break; }
// Next make sure that pass1 == pass2
if ($_POST['p_pass1'] != $_POST['p_pass2']){
$error = error_layout('The passwords you have entered do not match. Please re-enter them,
and click submit');
break;
}
// Everything is good, so update the database with the new information
$result = $GLOBALS['services']->sql_query('UPDATE nick SET pass=sha1(concat("'.$_POST['p_pass1'].'",salt)) WHERE nick_id='.$_GET['id']);
if ($GLOBALS['services']->sql_affectedrows($result) < 0){ // query failed.
$error = error_layout('There was a problem updating the database: '.
join(' ',$GLOBALS['services']->sql_error($result)));
break;
} else { // query was successful
$successful = 1;
}
break; // end Password change Process
case 'rename':
// They are renaming their pilot
// First check to see if they even submitted a name to rename their pilot to.
// Blanks are not allowed and will just reshow them the enter in box.
if ($_POST['p_name'] == ''){ break; }
// Check to see if they are using illegal characters
if (eregi('[!@#\$%^&*\(\)=/]',$_POST['p_name'])){
// They are using illegal characters
$error = error_layout('Your new Nick has characters that are not allowed on our IRC server.
Disallowed characters are: ! @ # $ % ^ & * ( ) = /');
break;
}
// Now we need to see if the nick is already in use to prevent accidental overlap
$result = $GLOBALS['services']->sql_query('SELECT nick FROM nick WHERE nick="'.$_POST['p_name'].'"');
if ($GLOBALS['services']->sql_numrows($result) > 0){ // Someone already has that nick
$error = error_layout('Someone is already using that Nick. Please try a different one.');
break;
}
// Everything seems good so far. Now update the database.
$result = $GLOBALS['services']->sql_query('UPDATE nick SET nick="'.$_POST['p_name'].'" WHERE nick_id='.$_GET['id']);
if ($GLOBALS['services']->sql_affectedrows($result) < 0){ // query failed
$error = error_layout('There was a problem updating the database: '.
join(' ',$GLOBALS['services']->sql_error($result)));
break;
} else {
$successful = 1;
}
break; // Exit renaming process
}
}
}
// Display processing follows here
if (!$_SESSION['uobject']){
// This person has not logged in yet.
$text .= NOTLOGGEDINMSG;
} else if ($_GET['cmd'] == 'assign'){
$caption .= '-- Assign To Group';
// SL is trying to assign this pilot to a group
if(!$pinfo){ $pinfo = new Pilot_Class($_GET['id']); }
if (!$successful){
$text .= 'You have selected to assign the following pilot to a group: ';
$text .= '
';
$text .= '[ X ] '.$pinfo->nick.'';
$text .= '
';
$squad = $pinfo->squad;
// Run query before error output so that any problems can be addressed
$result = $GLOBALS['services']->sql_query('SELECT group_id,group_name
FROM groups
WHERE (player2 = 0
OR player3 = 0
OR player4 = 0
OR player5 = 0
OR player6 = 0)
AND squad_id='.$squad->id);
if ($GLOBALS['services']->sql_numrows($result) < 1){ // there are no available groups
$error = error_layout('There are not available groups for this squad.');
} else { // there are available groups
while ($array = $GLOBALS['services']->sql_fetchrow($result)){
// process each pilot for select
$options[] = Array($array['group_id'],$array['group_name']);
}
}
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine('Select Group To Join:','select','g_pid',$_POST['g_pid'],$options);
$text .= $_SESSION['out']->formEnd('ASSIGN TO GROUP');
} else { // was successful
// Find group so we can display it's name
$text .= ''.$pinfo->nick.' has been assigned to the following group:';
$text .= '
';
$text .= '[ X ] '.$found->name.'';
$text .= '
';
$text .= 'Go back to viewing your squad by clicking here.';
}
} else if ($_GET['cmd'] == 'join'){
$caption .= '-- Join A Faction';
// User is joining a faction. This will clear their current stats.
if (!$successful){
// You need to have them select which faction they want to join.
if (!$disabletext){
$text .= 'Remember, when you join the faction your current stats
will be cleared and you will be starting over.';
$text .= '
';
$text .= 'Please select from below which faction you would like to join: ';
$text .= '
';
// Run a query to get all possible factions
$result = $GLOBALS['services']->sql_query('SELECT * FROM factions ORDER BY faction');
if ($GLOBALS['services']->sql_numrows($result) <= 0){
$error = error_layout('Problem updating database: '.join(' ',$GLOBALS['services']->sql_error($result)));
}
}
$text .= $error;
if (!$disabletext){
$text .= $_SESSION['out']->formStart();
// Now process each faction and give them a radio button
while($array = $GLOBALS['services']->sql_fetchrow($result)){
$text .= $_SESSION['out']->formLine('','radio','p_faction',$_POST['p_faction'],Array(Array($array['faction_id'],''.$array['faction'].' ('.$array['faction_abbrev'].')')));
}
$text .= $_SESSION['out']->formEnd('JOIN FACTION');
}
} else { // successful
// Pull faction data from the database for display purposes
$array = $GLOBALS['services']->sql_autofetch('SELECT faction,faction_abbrev FROM factions WHERE faction_id='.$_POST['p_faction']);
$text .= 'The stats for this pilot have been reset.';
$text .= '
';
$text .= 'You have been successfully assigned to the following faction:';
$text .= '
';
$text .= '[ X ] '.$array['faction'].' ('.$array['faction_abbrev'].')';
$text .= '
';
$text .= 'Welcome to your new faction, '.$pinfo->nick.'. May you be a help to their plans and goals!';
$text .= '
';
$text .= 'Click here to view your pilots.';
}
} else if ($_GET['cmd'] == 'leave'){
$caption .= '-- Leave Your Current Faction';
// User is leaving a faction. This will cause them to lose all stats
if (!$successful){
// We need to verify that they want to really be removed from the faction
if (!$disabletext){
$text .= 'You are about to remove yourself from the following faction:';
$text .= '
';
$text .= '[ X ] '.$pinfo->faction.' ('.$pinfo->faction_abbrev.')';
$text .= '
';
// Let the player know that their stats are gonna get zapped!
$text .= 'Remember that when you go to join another faction, or even rejoin this faction, your stats
will be cleared. ';
// Is this person part of a squad?
if ($pinfo->inSquad()){
$squad = $pinfo->squad;
// Check to see if this person is a squad leader or not
if ($pinfo->isSquadLeader()){ // is a squad leader
$text .= 'Your squad ('.$squad->name.' - '.$squad->abbrev.') will also
be deleted, as well as any affiliated groups for your squad. ';
} else { // isn't a squad leader
$text .= 'You will be removed from your squad ('.$squad->name.' - '.$squad->abbrev.')
as well as from any groups affiliated with that squad.';
}
}
$text .= $error;
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine('So, are you sure?', 'radio','p_quit','',Array(Array('Y','YES'),Array('N','NO')));
$text .= $_SESSION['out']->formEnd();
} else {
$text .= $error;
}
} else {
// They were successful in being removed from the faction
$text .= 'You have been succesfully removed from the Faction:';
$text .= '
';
$text .= '[ X ] '.$pinfo->faction.' ('.$pinfo->faction_abbrev.')';
$text .= '
';
// Is this person part of a squad?
if ($pinfo->inSquad()){
$squad = $pinfo->squad;
// Change final display based on whether they were a squad leader or not
if ($pinfo->isSquadLeader()){
$text .= 'The following squads and affiliated groups were also removed from the database:';
} else {
$text .= 'You were removed from the following squad and the associated group:';
}
$text .= '
';
$text .= '[ X ] '.$squad->name.' ('.$squad->abbrev.')';
$text .= '
';
}
// Inform the user that their stats will be reset
$text .= 'Now that you have quit your faction, the next time you join a faction your stats will be reset.';
$text .= '
';
$text .= 'Click here to view your pilots.';
}
} else if ($_GET['cmd'] == 'passwd'){
$caption .= '-- Change Pilot Password';
// User is trying to change a pilot's password
if (!$successful){
if (!$disabletext){
$text .= "You can change your Pilot's (".$pinfo->nick.') password by
typing it into the form below. Remember to enter the password again in the password verify
field. When you are done click submit to save the password change.';
}
$text .= $error;
if (!$disabletext){
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine("Pilot's Password:", 'password', 'p_pass1', $_POST['p_pass1']);
$text .= $_SESSION['out']->formLine('Verify Password:', 'password', 'p_pass2', $_POST['p_pass2']);
$text .= $_SESSION['out']->formEnd();
}
} else { // Process was completed successfully
$text .= "Your Pilot's password has been changed, and an email reflecting the change has
been sent to the email account on file.";
$text .= '
';
$text .= 'Click here to view your pilots.';
}
} else if ($_GET['cmd'] == 'rename'){
$caption .= '-- Rename Pilot';
// User is trying to rename his pilot
if (!$successful){
if (!$disabletext){
$text .= 'To rename your Pilot ('.$pinfo->nick.'), just replace
the current text in the text box with what you would like it to be, and click submit.';
}
// This is displayed by itself if it is a hacking attempt.
$text .= $error;
// Quick fix for getting the right name to display in the text field.
if (!$_POST['p_name']){ // Is the Post var missing? yes
$pname = $pinfo->nick;
} else { // no
$pname = $_POST['p_name'];
}
if (!$disabletext){
$text .= $_SESSION['out']->formStart();
$text .= $_SESSION['out']->formLine("Pilot's Name", 'text','p_name', $pname);
$text .= $_SESSION['out']->formEnd();
}
} else { // Process has successfully completed
$text .= 'Your pilot has been successfully renamed to: '.$_POST['p_name'].'';
$text .= '
';
$text .= 'Click here to view your pilots.';
}
} else {
// Default display for functionality
if ($_SESSION['uobject']->countPilots() == 0){ // No pilots linked to account
$text .= 'You do not have any Pilots to manage. If you would like to link a pilot
to your account, please click here.';
} else { // There are pilots linked to account
$text .= 'Below are the pilots that you have linked to your account:
';
// For each pilot we want to give a table with the tools available to the user
// As this display is this area specific, lets pull the pilots out from the
// user object and call it's display function.
foreach($_SESSION['uobject']->pilots as $pilots){
$text .= $pilots->fullDisplay().' ';
}
}
}
// Fix caption
$caption =''.$caption.' ';
if ($_GET['cmd']){
$caption .= '[ « ]';
}
$caption .= '[ ^ ] ';
// Display main Box
$ns->gen_tablerend($caption,$text);
?>
|
// Seconday area for holding things like the search tools and linked pilots info
// Do we have linked pilots?
if ($_SESSION['uobject'] && $_SESSION['uobject']->hasLinkedPilots()){
$ns->tablerender("Linked Pilots",$_SESSION['uobject']->displayPilots());
}
?>
|
// Display external template
require_once(FOOTERF);
?> |