[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.23.92.50: ~ $
<?php
	$page_title = "Edit Session | CES Admin";
	include_once($_SERVER['DOCUMENT_ROOT'] . "/php/common_functions.php"); //common functions in the course registartion system
	include_once($_SERVER['DOCUMENT_ROOT'] . "/php/config.php"); //holds global config variables	
	require_once($_SERVER['DOCUMENT_ROOT'] . "/phplist/config/config.php"); //phplist config values
 	check_if_authenticated('admin');//check if user is logged in
	include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/top-admin.php"); //get the HTML heading common to all pages in the CES admin module
	
?>

 <article class="ces-admin">
        <h2>CES Admin - Edit Session</h2>

<?php

	include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/nav-admin.php");

	if(isset($_GET['m']) && $_GET['m']=='success')
		echo "<p class='alert alert-success'>The session was successfully added. Please add instructors and files.</p>";


 	//opens connection to database

	$db = mysqli_connect($mysql_server, $user, $pass, $database);



	if(isset($_GET['action']) && $_GET['action']=='lock_session' && isset($_GET['session_id'])){
		if (lock_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session locked successfully</p>\n";		    
		} else {
		    echo "<p class='alert alert-error'>Error locking Session</p>\n";
		}
	}

	if(isset($_GET['action']) && $_GET['action']=='open_session' && isset($_GET['session_id'])){
		if (open_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session opened successfully</p>\n";		    
		} else {
		    echo "<p class='alert alert-error'>Error opening Session</p>\n";
		}
	}


	if(isset($_GET['action']) && $_GET['action']=='hide_session' && isset($_GET['session_id'])){
		if (hide_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session hidden successfully from the public.</p>\n";		    
		} else {
		    echo "<p class='alert alert-error'>Error hiding session. Session is still showing.</p>\n";
		}
	}

	if(isset($_GET['action']) && $_GET['action']=='show_session' && isset($_GET['session_id'])){
		if (show_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session is now showing to the public.</p>\n";		    
		} else {
		    echo "<p class='alert alert-error'>Error showing session. Session is still hidden.</p>\n";
		}
	}

	if(isset($_GET['action']) && $_GET['action']=='uncancel_session' && isset($_GET['session_id'])){
		if (uncancel_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session reinstated successfully</p>\n"; 
		} else {
		    echo "<p class='alert alert-error'>Error reinstating Session.</p>\n";
		}

	}

	if(isset($_GET['action']) && $_GET['action']=='cancel_session' && isset($_GET['session_id'])){
		if (cancel_session($_GET['session_id'])) {
			echo "<p class='alert alert-success'>Session cancelled successfully</p>\n"; 
		} else {
		    echo "<p class='alert alert-error'>Error cancelling Session.</p>\n";
		}

	}


	if(isset($_GET['action']) && $_GET['action']=='delete_session' && isset($_GET['session_id'])){
		$delete_session_sql = "DELETE FROM ces_sessions WHERE session_id = '$_GET[session_id]'";
		$delete_instructor_sql = "DELETE FROM ces_instructors_to_sessions WHERE session_id = '$_GET[session_id]'";
		if(registered_users($_GET['session_id']) == 0 && file_count($_GET['session_id']) == 0){
			if (mysqli_query($db, $delete_session_sql)) {
				if (mysqli_query($db, $delete_instructor_sql)){
					echo "<p class='alert alert-success'>Session deleted successfully</p>\n";
				}
				else{
					echo "<p class='alert alert-error'>Session deleted successfully, however there was an error unlinking the Instructors:<br> " . mysqli_error($db). "</p>\n";
				}
			    
			} else {
			    echo "<p class='alert alert-error'>Error deleting Session:<br> " . mysqli_error($db). "</p>\n";
			}
		}else{
			echo "<p class='alert alert-error'>Error deleting Session, there are still registered users or files attached to this session.</p>\n";
		}
	}
	//form has been submitted, update database with new values
	elseif(isset($_POST['submit'])){ 
		
		$telehealth = (isset($_POST['session_type']) && $_POST['session_type'] == 'telehealth')? 1 : 0;
	    $online = (isset($_POST['session_type']) && $_POST['session_type'] == 'online')? 1 : 0;
	    $webex = (isset($_POST['session_type']) && $_POST['session_type'] == 'webex')? 1 : 0;
	    $location_id = (isset($_POST['location_id']) && $online == 0 && $webex == 0)? $_POST['location_id'] : 'NULL';
	    $url = (isset($_POST['url']) && $online == 1)? '"'.$_POST['url'].'"' : 'NULL';
	    $webex_meeting_key = (isset($_POST['webex_meeting_key']) && $webex == 1)? str_replace(" ", "", trim($_POST['webex_meeting_key'])) : 'NULL';
	    $webex_url = (isset($_POST['webex_url']) && $webex == 1)? '"'.$_POST['webex_url'].'"' : 'NULL';
	    $webex_password = (isset($_POST['webex_password']) && $webex == 1)? '"'.$_POST['webex_password'].'"' : 'NULL';


		//convert the timestamps to 24 hour clock as that is what mysql needs
		$start_dt_hour = convert_hour($_POST['start_dt_hour'], $_POST['start_dt_meridiem']);	
		$end_dt_hour = convert_hour($_POST['end_dt_hour'], $_POST['end_dt_meridiem']);
			
		//now combine all the date fields into one timestamp
		$start_dt = $_POST['start_dt_year'] . "-" . $_POST['start_dt_month'] . "-" . $_POST['start_dt_day'] . " " . $start_dt_hour . ":" . $_POST['start_dt_minute'] . ":00";
		$end_dt = $_POST['end_dt_year'] . "-" . $_POST['end_dt_month'] . "-" . $_POST['end_dt_day'] . " " . $end_dt_hour . ":" . $_POST['end_dt_minute'] . ":00";
		
		//make sue the session start date is less than the end date
		if(strtotime($start_dt) >= strtotime($end_dt)){
			echo "<div class=error>Error - Start Date (" . $start_dt . ") can not be greater than or equal to the End Date (" . $end_dt . ").<br>
			Please correct the dates.</div>";
		}//if
		elseif(!checkdate($_POST['start_dt_month'], $_POST['start_dt_day'], $_POST['start_dt_year'])){
			echo "<div class=error>Error - The start date (" . $start_dt . ") you entered is not a valid date.<br>";
			echo "Please correct the date.</div>";	
		}//elseif
		elseif(!checkdate($_POST['end_dt_month'], $_POST['end_dt_day'], $_POST['end_dt_year'])){
			echo "<div class=error>Error - The end date (" . $end_dt . ") you entered is not a valid date.<br>";
			echo "Please correct the date.</div>";	
		}//elseif
		else{
			$session_sql = "UPDATE ces_sessions 
			SET start_dt='$start_dt',
			end_dt='$end_dt', 
			telehealth='$telehealth',
			location_id= $location_id,
			online = '$online',
			url = $url,
			webex = '$webex',
			webex_meeting_key = $webex_meeting_key,
			webex_url = $webex_url,
			webex_password = $webex_password
			WHERE session_id='$_POST[session_id]'";
			
			if (mysqli_query($db, $session_sql)){ //updates the ces_session table
				echo "<div class='alert alert-success'>Record updated successfully.</div>";
				//update all current registered users with new location
				$update_location_sql = "UPDATE `ces_course_registration`
										SET location_id='$_POST[location_id]'
										WHERE session_id='$_POST[session_id]'";
				if (mysqli_query($db, $update_location_sql)){
				}else{
					print_sql_error('Error - location update failed when doing:', $session_sql);
				}

				//2016-02-11 - nwmosses - added an extra waitlist check to catch location changes that have larger capacities
				check_waitlist($_POST['session_id'],$_POST['location_id']);

			}
			else
				print_sql_error('Error - session update failed when doing:', $session_sql);
				
			//if instructor_id is 0, we do not want to add an instructor, but if it is not 0, add instructor to session
			if($_POST['instructor_id'] != 0){ 
				$instructor_sql = "INSERT INTO ces_instructors_to_sessions (session_id, instructor_id) VALUES ('$_POST[session_id]', '$_POST[instructor_id]')";
				if (!mysqli_query($db, $instructor_sql)) //updates the ces_insructors_to_sessions table
					print_sql_error('Error - instructor update failed when doing:', $instructor_sql);
				else{
					echo "<div class='alert alert-success'>Instructor added successfully</div>";
				}
			}//if 
			
		}//else		
	} //if
	//delete one instructor from the session
	elseif(isset($_GET['action']) && $_GET['action'] == 'remove_instructor'){ 
		$instructor_sql = "DELETE FROM ces_instructors_to_sessions WHERE session_id = '$_GET[session_id]' AND instructor_id = '$_GET[instructor_id]'";
		
		if(mysqli_query($db, $instructor_sql)){ //delete the instructor from the session, but if the update did not happen output an error
			echo "<p class='alert alert-success'>Instructor successfully removed from this Session.</p>";
		}else{
			print_sql_error('<br>Error - instructor removal failed when trying to do:', $instructor_sql);
		} 	
	}//elseif
	//delete one file from the session and from the filesystem
	elseif(isset($_GET['action']) && $_GET['action'] == 'remove_file'){ 
		$file_sql = "DELETE FROM ces_files_to_sessions WHERE session_id = '$_GET[session_id]' AND filename = '$_GET[filename]'";
		
		if(!mysqli_query($db, $file_sql)){ //delete the file reference from the database, but if the update did not happen output an error
			print_sql_error('<br>Error - file removal failed when trying to do:', $file_sql);
		} //end if
	

		$file_name = "/sessions/files/".$_GET['filename'];

		//needed on windows as : is replaced by _ in filenames
		if($_SERVER['SERVER_SOFTWARE'] == 'Apache/2.4.9 (Win64) PHP/5.5.12');
			$file_name = str_replace(":", "_", $file_name);
	
		//now delete the file from the filesystem
		unlink(realpath($file_name));
	
	}//elseif

	//we can identify the record, session_id is the primary key in the database, print out the record and allow updates
	if((isset($_GET['session_id']) || isset($_POST['session_id'])) && !isset($_POST['delete'])){ 
	
		$session_id = isset($_GET['session_id']) ? $_GET['session_id'] : $_POST['session_id'];

		$sql = mysqli_query($db, "SELECT session_id, unix_timestamp(start_dt) as start_dt, unix_timestamp(end_dt) as end_dt, course_id, location_id, telehealth, cancelled, display, open, online, url, webex, webex_meeting_key, webex_url, webex_password FROM ces_sessions WHERE session_id=$session_id");


		echo "\n<form method='post'>";
		
		$course_id = 0;
		while ($query = mysqli_fetch_array($sql)) {
			$course_id = $query['course_id'];
			$cancelled = $query['cancelled'];
			$display = $query['display'];
			$open = $query['open'];
			if( $cancelled == 1)
				echo "<p class='alert alert-error'>This session has been cancelled. <a href='edit.php?session_id=". $session_id."&action=uncancel_session'>Undo Cancel</a></p>"; //add button to uncancel
			if( $display == 0)
				echo "<p class='alert alert-error'>This session is hidden from the public. <a href='edit.php?session_id=". $session_id."&action=show_session'>Show Session</a></p>"; //add button to show
			if( $open == 0)
				echo "<p class='alert alert-error'>This session is closed to registration. <a href='edit.php?session_id=". $session_id."&action=open_session'>Unlock Session</a></p>"; //add button to open

			echo "<input type='hidden' name='session_id' value=" . $session_id . ">"; //so we can keep track of which record we're modifying
			
?>
			<div class="form-group">
				<label>Start Date:</label>
				<div class="ces-session-start-date">
				<?php //output the date select boxes
					month_name_select('start_dt_month', date('m', $query["start_dt"]));
					days_in_month_select('start_dt_day', date('j', $query["start_dt"]));
					year_select('start_dt_year', date('Y', $query["start_dt"]));
					echo "&nbsp;";
					hours_in_day_select('start_dt_hour', date('g', $query["start_dt"]));
					echo ":";
					minutes_in_hour_select('start_dt_minute', date('i', $query["start_dt"]));
					meridiem_select('start_dt_meridiem', date('A', $query["start_dt"]));
				?>
				</div>
			</div>

			<div class="form-group">
			<label>End Date:</label>
				<div class="ces-session-end-date">
				<?php //output the date select boxes
					month_name_select('end_dt_month', date('m', $query["end_dt"]));
					days_in_month_select('end_dt_day', date('j', $query["end_dt"]));
					year_select('end_dt_year', date('Y', $query["end_dt"]));
					echo "&nbsp;";
					hours_in_day_select('end_dt_hour', date('g', $query["end_dt"]));
					echo ":";
					minutes_in_hour_select('end_dt_minute', date('i', $query["end_dt"]));
					meridiem_select('end_dt_meridiem', date('A', $query["end_dt"]));
				?>
				</div>
			</div>

	        <div class="form-group">
	        <label>Session Type:</label>        
	            <select class='form-control width-25' name="session_type" id="session-type" onchange="showInput()">
	                <option value="in-person" <?php echo ($query['telehealth'] == 0 && $query['online'] == 0 && $query['webex'] == 0? 'selected': '') ?>>In Person</option>
	                <option value="telehealth" <?php echo ($query['telehealth'] == 1 ? 'selected': '') ?>>Telehealth</option>
	                <option value="online" <?php echo ($query['online'] == 1? 'selected': '') ?>>Online</option>
	                <option value="webex" <?php echo ($query['webex'] == 1? 'selected': '') ?>>WebEx</option>
	            </select>
	        </div>

			<div class="form-group" id="location">
	        <label>Location:</label>        
	            <?php 
	                $location_sql = mysqli_query($db, "SELECT location_id, location_name FROM ces_locations ORDER BY location_name");
	                //output the query results in select list format
	                build_db_select_list_with_blank($location_sql, 'location_id', $query['location_id'], 'location_name', 'id="location-select"');
	            ?>
	        </div>
	        
	        <div class="form-group" id="video-url">
	            <label for='url'>Video Link: </label>
	            <small class="help">(Please ensure that the videos are in WMV format)</small>
	            <input class="form-control" type='text' name='url' id="video-link" value='<?php  echo $query['url'] ?>'>
	        </div>
	        
	        <div id="meeting-key">

			    <div class="form-group">
	                <label for='webex_url'>Event address for attendees: </label>
	                <input class="form-control" type='url' name='webex_url' id='webex-url' value='<?php  echo $query['webex_url'] ?>'>
	            </div>
	            <div class="form-group">
	                <label for='webex_meeting_key'>Event number: </label>
	                <input class="form-control width-20" type='text' name='webex_meeting_key' id='webex-meeting-key' value='<?php  echo $query['webex_meeting_key'] ?>'>
	            </div>
	            <div class="form-group">
	                <label for='webex_password'>Event password: </label>
	                <input class="form-control width-20" type='text' name='webex_password' id='webex-password' value='<?php  echo $query['webex_password'] ?>'>
	            </div> 
		    </div>

			<div class="form-group">
				<label for="add_instructor">Add Instructor:</label>
<?php
			//get a list of active instructors that are not already added to this session 
			$instructor_sql = mysqli_query($db, "SELECT instructor_id, concat_ws(' ', first_name, last_name) AS instructor_name FROM ces_instructors WHERE active = '1' AND instructor_id NOT IN (SELECT instructor_id FROM ces_instructors_to_sessions WHERE session_id = '$session_id') UNION SELECT '0', '' ORDER BY 2");
			//output the instructors in select list format
			build_db_select_list($instructor_sql, 'instructor_id', '', 'instructor_name');
?>
			</div>

			
<?php
			$instructor_sql = mysqli_query($db, "SELECT its.session_id, its.instructor_id, concat_ws(' ', instructor.first_name, instructor.last_name) AS instructor_name FROM ces_instructors_to_sessions its LEFT OUTER JOIN ces_instructors instructor on its.instructor_id = instructor.instructor_id WHERE its.session_id = '$session_id' ORDER BY instructor.first_name, instructor.last_name");
			if(mysqli_num_rows($instructor_sql) > 0){
				echo '<div class="form-group">';
				echo '  <label for="current_instructors">Current Instructors:</label>';

				while ($instructor_query = mysqli_fetch_array($instructor_sql)) {
				echo "<div>" . $instructor_query["instructor_name"] . " <a href=" . $_SERVER['PHP_SELF'] . "?action=remove_instructor&session_id=" . $instructor_query["session_id"] . "&instructor_id=" . $instructor_query["instructor_id"] . "><span class='fa fa-minus'></span></a></div>"; 
				}//while

				echo '</div>';
			}	
?>

			<div class="form-group">
				<label for="list_files">Files: <a href='../files/add.php?session_id=<?php echo $session_id ?>'><span class="fa fa-plus blue-icon" aria-hidden="true"></span></a></label>
<?php					
			//list the files that are attached to this session
			$file_sql = mysqli_query($db, "SELECT filename, file_description, display_immediately FROM ces_files_to_sessions WHERE session_id = '$session_id' ORDER BY file_description");
			

			if(mysqli_num_rows($file_sql) > 0 ){
				echo "<table class='table table-striped'>\n";
				echo "  <thead>\n";
				echo "  	<th>Name</th>\n";
				echo "  	<th>Size</th>\n";
				echo "  	<th>Display Immediately</th>\n";
				echo "  	<th>Date Modified</th>\n";
				echo "  	<th>Delete</th>\n";
				echo "  </thead>";
				echo "  <body>";

				while ($file_query = mysqli_fetch_array($file_sql)) {
					$file_name = $file_query['filename'];
					//needed on windows as : is replaced by _ in filenames
					//if($_SERVER['SERVER_SOFTWARE'] == 'Apache/2.4.9 (Win64) PHP/5.5.12');
					//	$file_name = str_replace(":", "_", $file_name);
					echo "    <tr>\n";
					echo "      <td><a href=\"/sessions/files/" . addslashes($file_name) . "\" target=_new>" . $file_query['file_description'] . "</a></td>\n";
					echo "      <td>".human_filesize(filesize($file_name), 0) ."</td>\n";					
					echo "      <td>".($file_query['display_immediately']?'Yes': 'No') ."</td>\n";
					echo "      <td>".date ("F d Y H:i:s.",filemtime($file_name))."</td>\n";
					echo "		<td><a class='no-icon' href=\"" . $_SERVER['PHP_SELF'] . "?action=remove_file&session_id=" . $session_id . "&filename=" . $file_query['filename'] . "\"><span class='fa fa-trash'></span></a></td>"; 
					echo "    </tr>";
				}//while
				echo "  </body>";
				echo "</table>\n";
			}else{
				echo "<p>No Files attached</p>";
			}
						
			echo "</div>";
		} //while
		
	
		echo "\n<input class='btn btn-lg btn-block ces-green-btn' type='submit' name='submit' value=\"Update Session\">";
		echo "\n<a class='btn btn-lg btn-block ces-orange-btn' href='../courses/#".$course_id."'>Back</a>";
		echo "\n</form>";
/// MANAGE SESSION ///

		echo "\n<div class='alert alert-info'>";

			if(registered_users($session_id) == 0 && file_count($session_id) == 0){
				echo "<a href='/admin/courses/?session_id=". $session_id."&action=delete_session' class='btn ces-green-btn'><span class='fa fa-trash' title='Delete Session'></span> Delete Session</a>";
				
			}else{
				echo "\n<p>";
				echo "There are ". registered_users($session_id) . " people registered in this session. To delete this session remove all <a href='attendees.php?session_id=" . $session_id . "'>registered users</a> and attached files. ";
				echo '</p>';
			}

			if($open)
				echo "<a href='edit.php?session_id=". $session_id."&action=lock_session' class='btn ces-red-btn'><span class='fa fa-lock' title='Session is currently open. Click to lock registration for this session.'></span> Lock</a>";
			else
				echo "<a href='edit.php?session_id=". $session_id."&action=open_session' class='btn ces-green-btn'><span class='fa fa-unlock' title='Session is currently locked. Click to open Session'></span> Open</a>";
			
			if($display)
				echo "<a href='edit.php?session_id=". $session_id."&action=hide_session' class='btn ces-red-btn'><span class='fa fa-eye-slash' title='This session is viewable '></span> Hide</a>";
			else
				echo "<a href='edit.php?session_id=". $session_id."&action=show_session' class='btn ces-green-btn'><span class='fa fa-eye' title='Show Session'></span> Show</a>";

			if(!$cancelled)
				echo "<a href='edit.php?session_id=". $session_id."&action=cancel_session' class='btn ces-red-btn'><span class='fa fa-ban' title='Cancel Session'></span> Cancel Session</a>";
			else
				echo "<a href='edit.php?session_id=". $session_id."&action=uncancel_session' class='btn ces-green-btn'><span class='fa fa-check-circle' title='Undo session cancellation.'></span> Undo Cancel</a>";
			echo "\n<hr><p><strong>Locking</strong> a session will prevent any new users from registering for this session. Users who are already registered will remain registered.</p>";
			echo "\n<p><strong>Hiding</strong> a session will stop the session from being displayed on the public course lists (both current and past). This doesn't prevent users from registering for this session.</p>";
			echo "\n<p><strong>Canceling</strong> a session will mark it as canceled. The reminder email is not sent out for canceled courses, however the user list will remain intact. Communication to the attendees can be done from the <a href='attendees.php?session_id=".$session_id."'>Attendee List</a>. User registration is also blocked, and a message of cancellation is displayed on the current session list where the session is still displayed.</p>";
		
		echo "</div>";
	}	

	
?>
  </article>
    


  </section><!-- #middle-->

</div><!-- #wrapper --> 
 
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/require/footer.php';?>
<!-- end admin_html_bottom.php -->

<script type="text/javascript">

          showInput();


    function showInput() {
        if (document.getElementById('session-type').selectedIndex == "0") {
            document.getElementById('location').style.display = 'block';
            document.getElementById('video-url').style.display = 'none';
            document.getElementById('meeting-key').style.display = 'none'; 
        }
        else if (document.getElementById('session-type').selectedIndex == "1") {
            document.getElementById('location').style.display = 'block';
            document.getElementById('video-url').style.display = 'none';
            document.getElementById('meeting-key').style.display = 'none';
        } 
        else if (document.getElementById('session-type').selectedIndex == "2") {
            document.getElementById('location').style.display = 'none';
            document.getElementById('video-url').style.display = 'block';
            document.getElementById('meeting-key').style.display = 'none';
        } 
        else if (document.getElementById('session-type').selectedIndex == "3") {
            document.getElementById('location').style.display = 'none';
            document.getElementById('video-url').style.display = 'none';
            document.getElementById('meeting-key').style.display = 'block';
        } 
    }
</script>

Filemanager

Name Type Size Permission Actions
files Folder 0755
add.php File 11.66 KB 0644
attendees.php File 19.54 KB 0644
edit.php File 22.29 KB 0644
email-attendees.php File 8.04 KB 0644
error_log File 9.19 KB 0644
remove-attendee.php File 6.17 KB 0644