/*
+---------------------------------------------------------------+
| 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 = 'Register Your Pilot Accounts';
$text = ' ';
// Form Processing Follows here
if ($_POST){ // check to see if a POST has been done..
switch ($_GET['cmd']){
// Use Switch to change how post is handled on a per cmd/post basis
case 'remove': // Removing link from user to pilot
// Check to make sure that password has been passed
if ($_POST['p_pass']){ // Yes
foreach ($_POST['p_pass'] as $key=>$value){
if ($value == ''){ continue; }
// Now we need to verify if information is correct.
$result = $GLOBALS['services']->sql_query('SELECT nick_id,nick FROM nick WHERE nick_id='.$key.' AND pass=sha1(concat("'.$value.'",salt))');
if ($GLOBALS['services']->sql_numrows() == 0){ // Query did not run fine.
$error = 'One or More Passwords do not match what is in the database. Please double
check the password(s), and try again. ';
break; // End loop to allow for displaying with error.
}
}
// If no error, then remove the information from the database.
if (!$error){
foreach ($_POST['p_pass'] as $key=>$value){
if ($value == ''){ continue; }
$result = $GLOBALS['e107db']->sql_query('DELETE FROM e107_name_link WHERE nick_id='.$key.' and user_id='.USERID);
if ($GLOBALS['e107db']->sql_affectedrows($result) <= 0){
$error = 'There was a problem with the database: ';
$error .= join(' ',$GLOBALS['e107db']->sql_error($result));
$error .= ' ';
break; // End loop to allow for display of error.
}
// If it was successful, then remove the pilot from the user's object
$_SESSION['uobject']->removePilot($key);
}
if (!$error){ $successful = 1; }
}
}
break; // End execution of Remove Process
case 'add': // Links a Pilot to an account
// First things first, lets make sure that the user doesn't already have this nick registered to them
if ($_SESSION['uobject']->pilotExists($_POST['plogin'])){
// Pilot is already assigned, don't allow multiple assignements
$error .= 'This pilot is already linked to your account. ';
break;
}
// Next we need to see how many they already have linked, to make sure they don't add more than 5
if ($_SESSION['uobject']->countPilots() >= 5){
// There are already too many pilots on tied to the account.
$error .= 'You already have 5 pilots linked to this account. If you want to have
link another pilot you must first remove a pilot. ';
break;
}
// We need to make sure that the information provided is correct
$result = $GLOBALS['services']->sql_query('SELECT nick_id,nick FROM nick WHERE nick="'.$_POST['plogin'].'" AND pass=sha1(concat("'.$_POST['ppass'].'",salt))');
if ($GLOBALS['services']->sql_numrows($result) <= 0){ // No valid nick/pass combination
$error .= 'The Pilot Login or Password are not correct. Please verify the information and
try again. ';
break;
}
// extract the results
$array = $GLOBALS['services']->sql_fetchrow($result);
// Now check to see if this pilot is already linked to another User
$result = $GLOBALS['e107db']->sql_query('SELECT user_id FROM e107_name_link WHERE nick_id='.$array['nick_id']);
if ($GLOBALS['e107db']->sql_numrows($result) > 0){ // someone has this pilot already
$subarray = $GLOBALS['e107db']->sql_fetchrow($result);
// Since this pilot belongs to someone else, findout who
$farray = $GLOBALS['e107db']->sql_fetchrow($GLOBALS['e107db']->sql_query('SELECT user_name FROM e107_user WHERE user_id='.$subarray['user_id']));
$error .= error_layout(''.$farray['user_name'].' already has this pilot assigned to them. Please contact them if you feel this is in error.');
break;
}
// Since a lack of an onweb account is a problem, create onweb account if missing
$result = $GLOBALS['services']->sql_query('SELECT * FROM onweb WHERE nick_id='.$array['nick_id']);
if ($GLOBALS['services']->sql_numrows($result) < 1){
// No onweb account, so create one
$result = $GLOBALS['services']->sql_query('INSERT INTO onweb (nick_id,squad_id,group_id) VALUES ('.$array['nick_id'].',0,0)');
if ($GLOBALS['services']->sql_affectedrows($result) < 0){
$error = error_layout('Problem updating database: '.join(' ',$GLOBALS['services']->sql_error($result)));
break;
}
}
// Account exists and has been verified. Now link it.
$result = $GLOBALS['e107db']->sql_query('INSERT INTO e107_name_link (user_id,nick_id) VALUES ('.USERID.','.$array['nick_id'].')');
if ($GLOBALS['e107db']->sql_affectedrows($result) <= 0){
$error = 'There was a problem with the database: ';
$error .= join(' ',$GLOBALS['e107db']->sql_error($result));
$error .= ' ';
break;
}
// Provided everything has worked up to this point, now we need add the pilot's info to user class.
if (!$error){
$_SESSION['uobject']->addPilot($array['nick_id']);
$successful = 1;
}
}
}
// Display processing Follows here
if (!$_SESSION['uobject']){
// This person has not logged in yet.
$text .= NOTLOGGEDINMSG;
} else if ($_GET['cmd'] == 'remove'){
$caption .= '-- Remove Linked Pilot';
// They are wanting to remove a linked pilot
if (!$successful) {
$text .= "You can remove a pilot from your account by typing in the password for that account.
If you do not know the password for the account you want removed click on the
'REQUEST INFO' link, and your password will be emailed to you, or atleast to
the email associated with that account.";
$text .= $error; // Used to dump errors to the user if they have tried to do stuff.
// We have to generate a line for each Pilot associated with the account
if ($_SESSION['uobject']->hasLinkedPilots()){
$text .= $_SESSION['out']->formStart();
foreach($_SESSION['uobject']->pilots as $pilots)
$text .= $_SESSION['out']->formLine('[ REQUEST INFO ] '.
$pilots->nick.':', 'password','p_pass['.$pilots->id.']',$_POST['p_pass'][$pilots->id]);
$text .= $_SESSION['out']->formEnd('Remove Pilots');
} else { // No pilots associated with this user.
$text .= 'You do not have any Pilots to unlink. ';
}
}
else
{
$text = 'The following were successfuly unlinked to your account:
';
// Go through array and get nick information so you can display here
foreach($_POST['p_pass'] as $key=>$value){
if ($value == ''){ continue; }
$result = $GLOBALS['services']->sql_query('SELECT nick FROM nick WHERE nick_id='.$key);
$array = $GLOBALS['services']->sql_fetchrow($result);
$text .= ' [ X ] '.$array['nick'].' ';
}
$text .= ' If you would like to link new pilots to your account, please click here.';
}
} else if ($_GET['cmd'] == 'add' && $successful == 1){
$text = 'The following has been successfully linked to your account:
';
$text .= ' [ X ] '.$array['nick'].' ';
$text .= ' If you would like to link new pilots to your account, please click here.';
} else {
// Person is a valid user, so now we must give them the ability to link pilots
$text .= "You can use the form here to associate a pilot with your account. You need to know
the login name and the password for your pilot. If you have forgotten either of
these things you can click here to request the information be emailed to you.
";
$text .= $error;
// Now create form for client side
$text .= $_SESSION['out']->formStart('register.php?cmd=add');
$text .= $_SESSION['out']->formLine('Pilot Login:','text','plogin',$_POST['plogin']);
$text .= $_SESSION['out']->formLine('Pilot Password:','password','ppass',$_POST['ppass']);
$text .= $_SESSION['out']->formEnd('Link Pilot Info');
$text .= '
';
// Now add link to remove pilots that are linked.
$text .= 'Or, if you need to remove a pilot that you have linked, please click here.';
}
// 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);
?> |