2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 authenticate(AT_PRIV_ADMIN);
18 if (isset($_POST['regenerate'])) {
19 $password = strtoupper(substr(md5(rand()), 3, 8));
21 $sql = "UPDATE ".TABLE_PREFIX."course_access SET `password`='$password' WHERE course_id=".$_SESSION['course_id'];
22 $result = mysql_query($sql, $db);
23 if (!mysql_affected_rows($db)) {
24 // conflict. try again
25 $password = strtoupper(substr(md5(rand()), 2, 7));
26 $sql = "UPDATE ".TABLE_PREFIX."course_access SET `password`='$password' WHERE course_id=".$_SESSION['course_id'];
27 $result = mysql_query($sql, $db);
30 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
31 header('Location: '.$_SERVER['PHP_SELF']);
33 } else if (isset($_POST['cancel'])) {
34 $msg->addFeedback('CANCELLED');
35 header('Location: '.$_SERVER['PHP_SELF']);
37 } else if (isset($_POST['submit'])) {
38 $auth = intval($_POST['auth']);
41 if (intval($_POST['expiry_date'])) {
42 $day_expire = intval($_POST['day_expire']);
43 $month_expire = intval($_POST['month_expire']);
44 $year_expire = intval($_POST['year_expire']);
45 $hour_expire = intval($_POST['hour_expire']);
46 $min_expire = intval($_POST['min_expire']);
48 if (strlen($month_expire) == 1){
49 $month_expire = "0$month_expire";
51 if (strlen($day_expire) == 1){
52 $day_expire = "0$day_expire";
54 if (strlen($hour_expire) == 1){
55 $hour_expire = "0$hour_expire";
57 if (strlen($min_expire) == 1){
58 $min_expire = "0$min_expire";
60 $expiry_date = "$year_expire-$month_expire-$day_expire $hour_expire:$min_expire:00";
65 $sql = "UPDATE ".TABLE_PREFIX."course_access SET `expiry_date`='$expiry_date', enabled=$auth WHERE course_id=".$_SESSION['course_id'];
66 $result = mysql_query($sql, $db);
68 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
69 header('Location: '.$_SERVER['PHP_SELF']);
73 require(AT_INCLUDE_PATH.'header.inc.php');
75 if ($system_courses[$_SESSION['course_id']]['access'] == 'public') {
76 // if this course is public, then we can't use this feature
77 echo '<div class="toolcontainer">';
78 $msg->printInfos('ACCESS_PUBLIC');
80 require(AT_INCLUDE_PATH.'footer.inc.php');
84 $sql = "SELECT password, expiry_date+0 AS expiry_date, enabled FROM ".TABLE_PREFIX."course_access WHERE course_id=".$_SESSION['course_id'];
85 $result = mysql_query($sql, $db);
87 if ($row = mysql_fetch_assoc($result)) {
88 $enabled = $row['enabled'];
89 $password = $row['password'];
90 $expiry = $row['expiry_date'];
93 $password = strtoupper(substr(md5(rand()), 3, 8));
95 $sql = "INSERT INTO ".TABLE_PREFIX."course_access VALUES ('$password', {$_SESSION['course_id']},'0000-00-00 00:00:00', 0)";
96 $result = mysql_query($sql, $db);
98 $url = AT_BASE_HREF.'acl.php?'.$password;
101 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
102 <div class="input-form">
103 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('regenerate'); ?></legend>
105 <?php echo _AT('auth_access_text'); ?>
108 <?php echo _AT('url'); ?><br />
109 <kbd><?php echo $url; ?></kbd>
111 <div class="row buttons">
112 <input type="submit" name="regenerate" value="<?php echo _AT('regenerate'); ?>" />
117 <div class="input-form">
118 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('authenticated_access'); ?></legend>
120 <?php echo _AT('authenticated_access'); ?><br />
121 <input type="radio" name="auth" id="enable" value="1" <?php if($enabled) { echo 'checked="checked"'; } ?> /> <label for="enable"><?php echo _AT('enable'); ?></label> <input type="radio" name="auth" id="disable" value="0" <?php if(!$enabled) { echo 'checked="checked"'; } ?> /> <label for="disable"><?php echo _AT('disable'); ?></label>
125 <?php echo _AT('expiry_date'); ?><br />
127 $exp_no = $exp_yes = '';
129 if (intval($expiry)) {
130 $exp_yes = ' checked="checked"';
132 $today_day = substr($expiry, 6, 2);
133 $today_mon = substr($expiry, 4, 2);
134 $today_year = substr($expiry, 0, 4);
135 $today_hour = substr($expiry, 8, 2);
136 $today_min = substr($expiry, 10, 2);
139 $exp_no = ' checked="checked"';
140 $today_day = date('d');
141 $today_mon = date('m');
142 $today_year = date('Y');
146 <input type="radio" name="expiry_date" value="0" id="expire_never" <?php echo $exp_no; ?> /> <label for="expire_never"><?php echo _AT('expire_never'); ?></label><br />
148 <input type="radio" name="expiry_date" value="1" id="expire_on" <?php echo $exp_yes; ?> /> <label for="expire_on"><?php echo _AT('expire_on'); ?></label>
151 require(AT_INCLUDE_PATH.'html/release_date.inc.php');
155 <div class="row buttons">
156 <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" />
157 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
162 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>