2 if (!defined('AT_INCLUDE_PATH')) { exit; }
3 error_reporting(E_ALL ^ E_NOTICE);
6 /* atutor default configuration options */
7 /* used on: ustep1.php, step3.php, step5.php */
8 $_defaults['admin_username'] = ($_POST['old_path'] ? 'admin' : '');
9 $_defaults['admin_password'] = '';
10 $_defaults['admin_email'] = '';
12 $_defaults['site_name'] = 'Course Server';
13 $_defaults['header_img'] = '';
14 $_defaults['header_logo'] = '';
15 $_defaults['home_url'] = '';
17 $_defaults['email_notification'] = 'TRUE';
18 $_defaults['email_confirmation'] = 'TRUE';
19 $_defaults['allow_instructor_requests'] = 'TRUE';
20 $_defaults['auto_approve_instructors'] = 'FALSE';
22 $_defaults['max_file_size'] = '1048576';
23 $_defaults['max_course_size'] = '10485760';
24 $_defaults['max_course_float'] = '2097152';
25 $_defaults['ill_ext'] = 'exe, asp, php, php3, bat, cgi, pl, com, vbs, reg, pcd, pif, scr, bas, inf, vb, vbe, wsc, wsf, wsh';
26 $_defaults['cache_dir'] = '';
28 $_defaults['theme_categories'] = 'FALSE';
29 $_defaults['content_dir'] = realpath('../').DIRECTORY_SEPARATOR.'content';
31 $_defaults['course_backups'] = 5;
33 require('include/classes/sqlutility.php');
36 function my_add_null_slashes( $string ) {
37 return @mysql_real_escape_string(stripslashes($string));
39 function my_null_slashes($string) {
43 if ( get_magic_quotes_gpc() == 1 ) {
44 $addslashes = 'my_add_null_slashes';
45 $stripslashes = 'stripslashes';
47 $addslashes = 'mysql_real_escape_string';
48 $stripslashes = 'my_null_slashes';
51 function queryFromFile($sql_file_path){
52 global $db, $progress, $errors;
56 if (!file_exists($sql_file_path)) {
60 $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
61 SqlUtility::splitSqlFile($pieces, $sql_query);
63 foreach ($pieces as $piece) {
64 $piece = trim($piece);
65 // [0] contains the prefixed query
66 // [4] contains unprefixed table name
69 if ($_POST['tb_prefix'] || ($_POST['tb_prefix'] == '')) {
70 $prefixed_query = SqlUtility::prefixQuery($piece, $_POST['tb_prefix']);
72 $prefixed_query = $piece;
75 if ($prefixed_query != false ) {
76 $table = $_POST['tb_prefix'].$prefixed_query[4];
77 if($prefixed_query[1] == 'CREATE TABLE'){
78 if (mysql_query($prefixed_query[0],$db) !== false) {
79 $progress[] = 'Table <strong>'.$table . '</strong> created successfully.';
81 if (mysql_errno($db) == 1050) {
82 $progress[] = 'Table <strong>'.$table . '</strong> already exists. Skipping.';
84 $errors[] = 'Table <strong>' . $table . '</strong> creation failed.';
88 elseif($prefixed_query[1] == 'INSERT INTO'){
89 mysql_query($prefixed_query[0],$db);
90 }elseif($prefixed_query[1] == 'REPLACE INTO'){
91 mysql_query($prefixed_query[0],$db);
92 }elseif($prefixed_query[1] == 'ALTER TABLE'){
93 if (mysql_query($prefixed_query[0],$db) !== false) {
94 $progress[] = 'Table <strong>'.$table.'</strong> altered successfully.';
96 if (mysql_errno($db) == 1060)
97 $progress[] = 'Table <strong>'.$table . '</strong> fields already exists. Skipping.';
98 elseif (mysql_errno($db) == 1091)
99 $progress[] = 'Table <strong>'.$table . '</strong> fields already dropped. Skipping.';
101 $errors[] = 'Table <strong>'.$table.'</strong> alteration failed.';
104 }elseif($prefixed_query[1] == 'DROP TABLE'){
105 mysql_query($prefixed_query[1] . ' ' .$table,$db);
106 }elseif($prefixed_query[1] == 'UPDATE'){
107 mysql_query($prefixed_query[0],$db);
114 function print_errors( $errors ) {
117 <table border="0" class="errbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
120 <h3 class="err"><img src="images/bad.gif" align="top" alt="" class="img" /> Error</h3>
123 foreach ($errors as $p) {
124 echo '<li>'.$p.'</li>';
134 function print_feedback( $feedback ) {
137 <table border="0" class="fbkbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
139 <td><h3 class="feedback2"><img src="images/feedback.gif" align="top" alt="" class="img" /> Feedback</h3>
142 foreach ($feedback as $p) {
143 echo '<li>'.$p.'</li>';
153 function store_steps($step) {
155 global $stripslashes;
157 foreach($_POST as $key => $value) {
158 if (substr($key, 0, strlen('step')) == 'step') {
160 } else if ($key == 'step') {
162 } else if ($key == 'action') {
164 } else if ($key == 'submit') {
168 $_POST['step'.$step][$key] = urlencode($stripslashes($value));
173 function print_hidden($current_step) {
174 for ($i=1; $i<$current_step; $i++) {
175 if (is_array($_POST['step'.$i])) {
176 foreach($_POST['step'.$i] as $key => $value) {
177 echo '<input type="hidden" name="step'.$i.'['.$key.']" value="'.$value.'" />'."\n";
183 function print_progress($step) {
184 global $install_steps;
186 echo '<div class="install"><h3>Installation Progress</h3><p>';
188 $num_steps = count($install_steps);
189 for ($i=0; $i<$num_steps; $i++) {
191 echo '<strong style="margin-left: 12px; color: #006699;">Step '.$i.': '.$install_steps[$i]['name'].'</strong>';
193 echo '<small style="margin-left: 10px; color: gray;">';
195 echo '<img src="../images/check.gif" height="9" width="9" alt="Step Done!" /> ';
197 echo '<img src="../images/clr.gif" height="9" width="9" alt="" /> ';
199 echo 'Step '.$i.': '.$install_steps[$i]['name'].'</small>';
201 if ($i+1 < $num_steps) {
205 echo '</p></div><br />';
207 echo '<h3>'.$install_steps[$step]['name'].'</h3>';
211 if (version_compare(phpversion(), '5.0') < 0) {
212 function scandir($dirstr) {
214 $fh = opendir($dirstr);
215 while (false !== ($filename = readdir($fh))) {
216 array_push($files, $filename);
224 * Print the HTML of the meta forward codes
226 function print_meta_redirect(){
227 $body = 'ATutor appears to have been installed already. <br/>';
228 $body .= '<a href="../index.php">Click here<a/> to login.';
231 $html .= '<body>'.$body.'</body>'."\n";
232 $html .= "</html>\n";
238 * This function is used for printing variables for debugging.
240 * @param mixed $var The variable to output
241 * @param string $title The name of the variable, or some mark-up identifier.
242 * @author Joel Kronenberg
244 function debug($var, $title='') {
245 echo '<pre style="border: 1px black solid; padding: 0px; margin: 10px;" title="debugging box">';
247 echo '<h4>'.$title.'</h4>';
252 $str = ob_get_contents();
255 $str = str_replace('<', '<', $str);
257 $str = str_replace('[', '<span style="color: red; font-weight: bold;">[', $str);
258 $str = str_replace(']', ']</span>', $str);
259 $str = str_replace('=>', '<span style="color: blue; font-weight: bold;">=></span>', $str);
260 $str = str_replace('Array', '<span style="color: purple; font-weight: bold;">Array</span>', $str);