2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 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 /************************************************************************/
13 if (!defined('TR_INCLUDE_PATH')) { exit; }
14 error_reporting(E_ALL ^ E_NOTICE);
16 /* AContent default configuration options */
17 /* used on: step3.php, step4.php, step5.php */
18 $_defaults['admin_username'] = 'admin';
19 $_defaults['admin_password'] = '';
20 $_defaults['admin_email'] = '';
22 $_defaults['site_name'] = 'AContent';
23 $_defaults['header_img'] = '';
24 $_defaults['header_logo'] = '';
25 $_defaults['home_url'] = '';
27 $_defaults['email_confirmation'] = 'TRUE';
29 $_defaults['max_file_size'] = '1048576';
30 $_defaults['ill_ext'] = 'exe, asp, php, php3, bat, cgi, pl, com, vbs, reg, pcd, pif, scr, bas, inf, vb, vbe, wsc, wsf, wsh';
31 $_defaults['cache_dir'] = '';
33 $_defaults['theme_categories'] = 'FALSE';
34 $_defaults['content_dir'] = realpath('../').DIRECTORY_SEPARATOR.'content';
36 require('include/classes/sqlutility.php');
39 function my_add_null_slashes( $string ) {
40 return @mysql_real_escape_string(stripslashes($string));
42 function my_null_slashes($string) {
46 if ( get_magic_quotes_gpc() == 1 ) {
47 $addslashes = 'my_add_null_slashes';
48 $stripslashes = 'stripslashes';
50 $addslashes = 'mysql_real_escape_string';
51 $stripslashes = 'my_null_slashes';
54 function queryFromFile($sql_file_path)
56 global $db, $progress, $errors;
60 if (!file_exists($sql_file_path)) {
61 $progress[] = $sql_file_path . ': file not exists.';
65 $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
66 SqlUtility::splitSqlFile($pieces, $sql_query);
68 foreach ($pieces as $piece)
70 $piece = trim($piece);
71 // [0] contains the prefixed query
72 // [4] contains unprefixed table name
75 if ($_POST['tb_prefix'] || ($_POST['tb_prefix'] == ''))
76 $prefixed_query = SqlUtility::prefixQuery($piece, $_POST['tb_prefix']);
78 $prefixed_query = $piece;
80 if ($prefixed_query != false )
82 $table = $_POST['tb_prefix'].$prefixed_query[4];
84 if($prefixed_query[1] == 'CREATE TABLE')
86 if (mysql_query($prefixed_query[0],$db) !== false)
87 $progress[] = 'Table <strong>'.$table . '</strong> created successfully.';
89 if (mysql_errno($db) == 1050)
90 $progress[] = 'Table <strong>'.$table . '</strong> already exists. Skipping.';
92 $errors[] = 'Table <strong>' . $table . '</strong> creation failed.';
94 elseif($prefixed_query[1] == 'INSERT INTO')
95 mysql_query($prefixed_query[0],$db);
96 elseif($prefixed_query[1] == 'REPLACE INTO')
97 mysql_query($prefixed_query[0],$db);
98 elseif($prefixed_query[1] == 'ALTER TABLE')
100 if (mysql_query($prefixed_query[0],$db) !== false)
101 $progress[] = 'Table <strong>'.$table.'</strong> altered successfully.';
103 if (mysql_errno($db) == 1060)
104 $progress[] = 'Table <strong>'.$table . '</strong> fields already exists. Skipping.';
105 elseif (mysql_errno($db) == 1091)
106 $progress[] = 'Table <strong>'.$table . '</strong> fields already dropped. Skipping.';
108 $errors[] = 'Table <strong>'.$table.'</strong> alteration failed.';
110 elseif($prefixed_query[1] == 'DROP TABLE')
111 mysql_query($prefixed_query[1] . ' ' .$table,$db);
112 elseif($prefixed_query[1] == 'UPDATE')
113 mysql_query($prefixed_query[0],$db);
119 function print_errors( $errors ) {
122 <table border="0" class="errbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
125 <h3 class="err"><img src="images/bad.gif" align="top" alt="" class="img" /> Error</h3>
128 foreach ($errors as $p) {
129 echo '<li>'.$p.'</li>';
139 function print_feedback( $feedback ) {
142 <table border="0" class="fbkbox" cellpadding="3" cellspacing="2" width="90%" summary="" align="center">
144 <td><h3 class="feedback2"><img src="images/feedback.gif" align="top" alt="" class="img" /> Feedback</h3>
147 foreach ($feedback as $p) {
148 echo '<li>'.$p.'</li>';
158 function store_steps($step) {
160 global $stripslashes;
162 foreach($_POST as $key => $value) {
163 if (substr($key, 0, strlen('step')) == 'step') {
165 } else if ($key == 'step') {
167 } else if ($key == 'action') {
169 } else if ($key == 'submit') {
173 $_POST['step'.$step][$key] = urlencode($stripslashes($value));
178 function print_hidden($current_step) {
179 for ($i=1; $i<$current_step; $i++) {
180 if (is_array($_POST['step'.$i])) {
181 foreach($_POST['step'.$i] as $key => $value) {
182 echo '<input type="hidden" name="step'.$i.'['.$key.']" value="'.$value.'" />'."\n";
188 function print_progress($step) {
189 global $install_steps;
191 echo '<div class="install"><h3>Installation Progress</h3><p>';
193 $num_steps = count($install_steps);
194 for ($i=0; $i<$num_steps; $i++) {
196 echo '<strong style="margin-left: 12px; color: #006699;">Step '.$i.': '.$install_steps[$i]['name'].'</strong>';
198 echo '<small style="margin-left: 10px; color: gray;">';
200 echo '<img src="../images/check.gif" height="9" width="9" alt="Step Done!" /> ';
202 echo '<img src="../images/clr.gif" height="9" width="9" alt="" /> ';
204 echo 'Step '.$i.': '.$install_steps[$i]['name'].'</small>';
206 if ($i+1 < $num_steps) {
210 echo '</p></div><br />';
212 echo '<h3>'.$install_steps[$step]['name'].'</h3>';
216 if (version_compare(phpversion(), '5.0') < 0) {
217 function scandir($dirstr) {
219 $fh = opendir($dirstr);
220 while (false !== ($filename = readdir($fh))) {
221 array_push($files, $filename);
229 * This function is used for printing variables for debugging.
231 * @param mixed $var The variable to output
232 * @param string $title The name of the variable, or some mark-up identifier.
233 * @author Joel Kronenberg
235 function debug($var, $title='') {
236 echo '<pre style="border: 1px black solid; padding: 0px; margin: 10px;" title="debugging box">';
238 echo '<h4>'.$title.'</h4>';
243 $str = ob_get_contents();
246 $str = str_replace('<', '<', $str);
248 $str = str_replace('[', '<span style="color: red; font-weight: bold;">[', $str);
249 $str = str_replace(']', ']</span>', $str);
250 $str = str_replace('=>', '<span style="color: blue; font-weight: bold;">=></span>', $str);
251 $str = str_replace('Array', '<span style="color: purple; font-weight: bold;">Array</span>', $str);