2 if (!defined('AT_INCLUDE_PATH')) { exit; }
3 error_reporting(E_ALL ^ E_NOTICE);
5 /* atutor default configuration options */
6 /* used on: ustep1.php, step3.php, step5.php */
7 $_defaults['admin_username'] = ($_POST['old_path'] ? 'admin' : '');
8 $_defaults['admin_password'] = '';
9 $_defaults['admin_email'] = '';
11 $_defaults['site_name'] = 'Course Server';
12 $_defaults['header_img'] = '';
13 $_defaults['header_logo'] = '';
14 $_defaults['home_url'] = '';
16 $_defaults['email_notification'] = 'TRUE';
17 $_defaults['email_confirmation'] = 'TRUE';
18 $_defaults['allow_instructor_requests'] = 'TRUE';
19 $_defaults['auto_approve_instructors'] = 'FALSE';
21 $_defaults['max_file_size'] = '1048576';
22 $_defaults['max_course_size'] = '10485760';
23 $_defaults['max_course_float'] = '2097152';
24 $_defaults['ill_ext'] = 'exe, asp, php, php3, bat, cgi, pl, com, vbs, reg, pcd, pif, scr, bas, inf, vb, vbe, wsc, wsf, wsh';
25 $_defaults['cache_dir'] = '';
27 $_defaults['theme_categories'] = 'FALSE';
28 $_defaults['content_dir'] = realpath('../').DIRECTORY_SEPARATOR.'content';
30 $_defaults['course_backups'] = 5;
32 require('include/classes/sqlutility.php');
35 function my_add_null_slashes( $string ) {
36 return @mysql_real_escape_string(stripslashes($string));
38 function my_null_slashes($string) {
42 if ( get_magic_quotes_gpc() == 1 ) {
43 $addslashes = 'my_add_null_slashes';
44 $stripslashes = 'stripslashes';
46 $addslashes = 'mysql_real_escape_string';
47 $stripslashes = 'my_null_slashes';
50 function queryFromFile($sql_file_path){
51 global $db, $progress, $errors;
55 if (!file_exists($sql_file_path)) {
59 $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
60 SqlUtility::splitSqlFile($pieces, $sql_query);
62 foreach ($pieces as $piece) {
63 $piece = trim($piece);
64 // [0] contains the prefixed query
65 // [4] contains unprefixed table name
68 if ($_POST['tb_prefix'] || ($_POST['tb_prefix'] == '')) {
69 $prefixed_query = SqlUtility::prefixQuery($piece, $_POST['tb_prefix']);
71 $prefixed_query = $piece;
74 if ($prefixed_query != false ) {
75 $table = $_POST['tb_prefix'].$prefixed_query[4];
76 if($prefixed_query[1] == 'CREATE TABLE'){
77 if (mysql_query($prefixed_query[0],$db) !== false) {
78 $progress[] = 'Table <strong>'.$table . '</strong> created successfully.';
80 if (mysql_errno($db) == 1050) {
81 $progress[] = 'Table <strong>'.$table . '</strong> already exists. Skipping.';
83 $errors[] = 'Table <strong>' . $table . '</strong> creation failed.';
87 elseif($prefixed_query[1] == 'INSERT INTO'){
88 mysql_query($prefixed_query[0],$db);
89 }elseif($prefixed_query[1] == 'REPLACE INTO'){
90 mysql_query($prefixed_query[0],$db);
91 }elseif($prefixed_query[1] == 'ALTER TABLE'){
92 if (mysql_query($prefixed_query[0],$db) !== false) {
93 $progress[] = 'Table <strong>'.$table.'</strong> altered successfully.';
95 if (mysql_errno($db) == 1060)
96 $progress[] = 'Table <strong>'.$table . '</strong> fields already exists. Skipping.';
97 elseif (mysql_errno($db) == 1091)
98 $progress[] = 'Table <strong>'.$table . '</strong> fields already dropped. Skipping.';
100 $errors[] = 'Table <strong>'.$table.'</strong> alteration failed.';
103 }elseif($prefixed_query[1] == 'DROP TABLE'){
104 mysql_query($prefixed_query[1] . ' ' .$table,$db);
105 }elseif($prefixed_query[1] == 'UPDATE'){
106 mysql_query($prefixed_query[0],$db);
113 function print_errors( $errors ) {
116 <table border="0" class="errbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
119 <h3 class="err"><img src="images/bad.gif" align="top" alt="" class="img" /> Error</h3>
122 foreach ($errors as $p) {
123 echo '<li>'.$p.'</li>';
133 function print_feedback( $feedback ) {
136 <table border="0" class="fbkbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
138 <td><h3 class="feedback2"><img src="images/feedback.gif" align="top" alt="" class="img" /> Feedback</h3>
141 foreach ($feedback as $p) {
142 echo '<li>'.$p.'</li>';
152 function store_steps($step) {
154 global $stripslashes;
156 foreach($_POST as $key => $value) {
157 if (substr($key, 0, strlen('step')) == 'step') {
159 } else if ($key == 'step') {
161 } else if ($key == 'action') {
163 } else if ($key == 'submit') {
167 $_POST['step'.$step][$key] = urlencode($stripslashes($value));
172 function print_hidden($current_step) {
173 for ($i=1; $i<$current_step; $i++) {
174 if (is_array($_POST['step'.$i])) {
175 foreach($_POST['step'.$i] as $key => $value) {
176 echo '<input type="hidden" name="step'.$i.'['.$key.']" value="'.$value.'" />'."\n";
182 function print_progress($step) {
183 global $install_steps;
185 echo '<div class="install"><h3>Installation Progress</h3><p>';
187 $num_steps = count($install_steps);
188 for ($i=0; $i<$num_steps; $i++) {
190 echo '<strong style="margin-left: 12px; color: #006699;">Step '.$i.': '.$install_steps[$i]['name'].'</strong>';
192 echo '<small style="margin-left: 10px; color: gray;">';
194 echo '<img src="../images/check.gif" height="9" width="9" alt="Step Done!" /> ';
196 echo '<img src="../images/clr.gif" height="9" width="9" alt="" /> ';
198 echo 'Step '.$i.': '.$install_steps[$i]['name'].'</small>';
200 if ($i+1 < $num_steps) {
204 echo '</p></div><br />';
206 echo '<h3>'.$install_steps[$step]['name'].'</h3>';
210 if (version_compare(phpversion(), '5.0') < 0) {
211 function scandir($dirstr) {
213 $fh = opendir($dirstr);
214 while (false !== ($filename = readdir($fh))) {
215 array_push($files, $filename);
223 * Print the HTML of the meta forward codes
225 function print_meta_redirect(){
226 $body = 'ATutor appears to have been installed already. <br/>';
227 $body .= '<a href="../index.php">Click here<a/> to login.';
230 $html .= '<body>'.$body.'</body>'."\n";
231 $html .= "</html>\n";
237 * This function is used for printing variables for debugging.
239 * @param mixed $var The variable to output
240 * @param string $title The name of the variable, or some mark-up identifier.
241 * @author Joel Kronenberg
243 function debug($var, $title='') {
244 echo '<pre style="border: 1px black solid; padding: 0px; margin: 10px;" title="debugging box">';
246 echo '<h4>'.$title.'</h4>';
251 $str = ob_get_contents();
254 $str = str_replace('<', '<', $str);
256 $str = str_replace('[', '<span style="color: red; font-weight: bold;">[', $str);
257 $str = str_replace(']', ']</span>', $str);
258 $str = str_replace('=>', '<span style="color: blue; font-weight: bold;">=></span>', $str);
259 $str = str_replace('Array', '<span style="color: purple; font-weight: bold;">Array</span>', $str);