| version 1.40, 2005/03/05 11:17:35 |
version 1.41, 2005/03/24 17:15:54 |
|
|
| * http://platon.sk/projects/phpMyEdit/ |
* http://platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEditSetup.php,v 1.39 2004/11/28 23:16:56 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEditSetup.php,v 1.40 2005/03/05 11:17:35 nepto Exp $ */ |
| |
|
| ?> |
?> |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
|
| |
|
| <?php |
<?php |
| |
|
| |
if (! defined('PHP_EOL')) { |
| |
define('PHP_EOL', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? "\r\n" |
| |
: strtoupper(substr(PHP_OS, 0, 3) == 'MAC') ? "\r" : "\n"); |
| |
} |
| |
|
| $hn = @$HTTP_POST_VARS['hn']; |
$hn = @$HTTP_POST_VARS['hn']; |
| $un = @$HTTP_POST_VARS['un']; |
$un = @$HTTP_POST_VARS['un']; |
| $pw = @$HTTP_POST_VARS['pw']; |
$pw = @$HTTP_POST_VARS['pw']; |
|
|
| |
|
| function echo_html($x) |
function echo_html($x) |
| { |
{ |
| echo htmlspecialchars($x),"\n"; |
echo htmlspecialchars($x),PHP_EOL; |
| } |
} |
| |
|
| function echo_buffer($x) |
function echo_buffer($x) |
| { |
{ |
| global $buffer; |
global $buffer; |
| $buffer .= $x."\n"; |
$buffer .= $x.PHP_EOL; |
| } |
} |
| |
|
| $self = basename($HTTP_SERVER_VARS['PHP_SELF']); |
$self = basename($HTTP_SERVER_VARS['PHP_SELF']); |
| Line 102 $dbl = @mysql_pconnect($hn, $un, $pw); |
|
| Line 107 $dbl = @mysql_pconnect($hn, $un, $pw); |
|
| if ((!$dbl) or empty($submit)) { |
if ((!$dbl) or empty($submit)) { |
| echo '<h1>Please log in to your MySQL database</h1>'; |
echo '<h1>Please log in to your MySQL database</h1>'; |
| if (!empty($submit)) { |
if (!empty($submit)) { |
| echo '<h2>Sorry - login failed - please try again</h2>'."\n"; |
echo '<h2>Sorry - login failed - please try again</h2>'.PHP_EOL; |
| } |
} |
| if (! isset($hn)) { |
if (! isset($hn)) { |
| $hn = 'localhost'; |
$hn = 'localhost'; |
| Line 122 if ((!$dbl) or empty($submit)) { |
|
| Line 127 if ((!$dbl) or empty($submit)) { |
|
| </tr> |
</tr> |
| </table><br> |
</table><br> |
| <input type="submit" name="submit" value="Submit"> |
<input type="submit" name="submit" value="Submit"> |
| </form>'."\n"; |
</form>'.PHP_EOL; |
| } else if (! isset($db)) { |
} else if (! isset($db)) { |
| $dbs = @mysql_list_dbs($dbl); |
$dbs = @mysql_list_dbs($dbl); |
| $num_dbs = @mysql_num_rows($dbs); |
$num_dbs = @mysql_num_rows($dbs); |
| Line 131 if ((!$dbl) or empty($submit)) { |
|
| Line 136 if ((!$dbl) or empty($submit)) { |
|
| <input type="hidden" name="hn" value="'.htmlspecialchars($hn).'"> |
<input type="hidden" name="hn" value="'.htmlspecialchars($hn).'"> |
| <input type="hidden" name="un" value="'.htmlspecialchars($un).'"> |
<input type="hidden" name="un" value="'.htmlspecialchars($un).'"> |
| <input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
| <table border="1" cellpadding="1" cellspacing="1" summary="Database selection">'."\n"; |
<table border="1" cellpadding="1" cellspacing="1" summary="Database selection">'.PHP_EOL; |
| for ($i = 0; $i < $num_dbs; $i++) { |
for ($i = 0; $i < $num_dbs; $i++) { |
| $db = @mysql_db_name($dbs, $i); |
$db = @mysql_db_name($dbs, $i); |
| $checked = ! strcasecmp($un, $db) ? ' checked' : ''; |
$checked = ! strcasecmp($un, $db) ? ' checked' : ''; |
| $db = htmlspecialchars($db); |
$db = htmlspecialchars($db); |
| echo '<tr><td><input'.$checked.' type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'."\n"; |
echo '<tr><td><input'.$checked.' type="radio" name="db" value="'.$db.'"></td><td>'.$db.'</td></tr>'.PHP_EOL; |
| } |
} |
| echo '</table><br> |
echo '</table><br> |
| <input type="submit" name="submit" value="Submit"> |
<input type="submit" name="submit" value="Submit"> |
| <input type="submit" name="cancel" value="Cancel"> |
<input type="submit" name="cancel" value="Cancel"> |
| </form>'."\n"; |
</form>'.PHP_EOL; |
| } else if (!isset($tb)) { |
} else if (!isset($tb)) { |
| echo '<h1>Please select a table from database: '.htmlspecialchars($db).'</h1> |
echo '<h1>Please select a table from database: '.htmlspecialchars($db).'</h1> |
| <form action="'.htmlspecialchars($self).'" method="POST"> |
<form action="'.htmlspecialchars($self).'" method="POST"> |
| Line 149 if ((!$dbl) or empty($submit)) { |
|
| Line 154 if ((!$dbl) or empty($submit)) { |
|
| <input type="hidden" name="un" value="'.htmlspecialchars($un).'"> |
<input type="hidden" name="un" value="'.htmlspecialchars($un).'"> |
| <input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
| <input type="hidden" name="db" value="'.htmlspecialchars($db).'"> |
<input type="hidden" name="db" value="'.htmlspecialchars($db).'"> |
| <table border="1" cellpadding="1" cellspacing="1" summary="Table selection">'."\n"; |
<table border="1" cellpadding="1" cellspacing="1" summary="Table selection">'.PHP_EOL; |
| $tbs = @mysql_list_tables($db, $dbl); |
$tbs = @mysql_list_tables($db, $dbl); |
| $num_tbs = @mysql_num_rows($tbs); |
$num_tbs = @mysql_num_rows($tbs); |
| for ($j = 0; $j < $num_tbs; $j++) { |
for ($j = 0; $j < $num_tbs; $j++) { |
| $tb = @mysql_tablename($tbs, $j); |
$tb = @mysql_tablename($tbs, $j); |
| $tb = htmlspecialchars($tb); |
$tb = htmlspecialchars($tb); |
| $checked = $j == 0 ? ' checked' : ''; |
$checked = $j == 0 ? ' checked' : ''; |
| echo '<tr><td><input'.$checked.' type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'."\n"; |
echo '<tr><td><input'.$checked.' type="radio" name="tb" value="'.$tb.'"></td><td>'.$tb.'</td></tr>'.PHP_EOL; |
| } |
} |
| echo '</table><br> |
echo '</table><br> |
| <input type="submit" name="submit" value="Submit"> |
<input type="submit" name="submit" value="Submit"> |
| <input type="submit" name="cancel" value="Cancel"> |
<input type="submit" name="cancel" value="Cancel"> |
| </form>'."\n"; |
</form>'.PHP_EOL; |
| } else if (!isset($id)) { |
} else if (!isset($id)) { |
| echo ' <h1>Please select an identifier from table: '.htmlspecialchars($tb).'</h1> |
echo ' <h1>Please select an identifier from table: '.htmlspecialchars($tb).'</h1> |
| <p> |
<p> |
| Line 180 if ((!$dbl) or empty($submit)) { |
|
| Line 185 if ((!$dbl) or empty($submit)) { |
|
| <input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
<input type="hidden" name="pw" value="'.htmlspecialchars($pw).'"> |
| <input type="hidden" name="db" value="'.htmlspecialchars($db).'"> |
<input type="hidden" name="db" value="'.htmlspecialchars($db).'"> |
| <input type="hidden" name="tb" value="'.htmlspecialchars($tb).'"> |
<input type="hidden" name="tb" value="'.htmlspecialchars($tb).'"> |
| <table border="1" cellpadding="1" cellspacing="1" summary="Key selection">'."\n"; |
<table border="1" cellpadding="1" cellspacing="1" summary="Key selection">'.PHP_EOL; |
| // <tr><td><input type="radio" name="id" value=""> |
// <tr><td><input type="radio" name="id" value=""> |
| // <td><i>None</i></td><td><i>No id field required</i></td></tr> |
// <td><i>None</i></td><td><i>No id field required</i></td></tr> |
| @mysql_select_db($db); |
@mysql_select_db($db); |
| Line 198 if ((!$dbl) or empty($submit)) { |
|
| Line 203 if ((!$dbl) or empty($submit)) { |
|
| echo '</table><br> |
echo '</table><br> |
| <input type="submit" name="submit" value="Submit"> |
<input type="submit" name="submit" value="Submit"> |
| <input type="submit" name="cancel" value="Cancel"> |
<input type="submit" name="cancel" value="Cancel"> |
| </form>'."\n"; |
</form>'.PHP_EOL; |
| |
|
| } else if (!isset($options)) { |
} else if (!isset($options)) { |
| echo '<h1>Please select additional options</h1> |
echo '<h1>Please select additional options</h1> |
| Line 219 if ((!$dbl) or empty($submit)) { |
|
| Line 224 if ((!$dbl) or empty($submit)) { |
|
| <input type="submit" name="submit" value="Submit"> |
<input type="submit" name="submit" value="Submit"> |
| <input type="submit" name="cancel" value="Cancel"> |
<input type="submit" name="cancel" value="Cancel"> |
| <input type="hidden" name="options" value="1"> |
<input type="hidden" name="options" value="1"> |
| </form>'."\n"; |
</form>'.PHP_EOL; |
| } else { |
} else { |
| echo '<h1>Here is your phpMyEdit calling program</h1>'."\n"; |
echo '<h1>Here is your phpMyEdit calling program</h1>'.PHP_EOL; |
| echo '<h2>You may now copy and paste it into your PHP editor</h2>'."\n"; |
echo '<h2>You may now copy and paste it into your PHP editor</h2>'.PHP_EOL; |
| if ($pageHeader) { |
if ($pageHeader) { |
| echo_buffer('<h3>'.$pageTitle.'</h3>'); |
echo_buffer('<h3>'.$pageTitle.'</h3>'); |
| } |
} |
| Line 396 appear in generated list. Here are some |
|
| Line 401 appear in generated list. Here are some |
|
| $outstr = explode("','", $outstr); |
$outstr = explode("','", $outstr); |
| $outstr = str_replace("''", "'", $outstr); |
$outstr = str_replace("''", "'", $outstr); |
| $outstr = str_replace('"', '\\"', $outstr); |
$outstr = str_replace('"', '\\"', $outstr); |
| $outstr = implode("\",\n$indent\"", $outstr); |
$outstr = implode('",'.PHP_EOL.$indent.'"', $outstr); |
| echo_buffer(" 'values' => array(\n$indent\"".$outstr.'"),'); |
echo_buffer(" 'values' => array(".PHP_EOL.$indent.'"'.$outstr.'"),'); |
| } |
} |
| // automatic support for Default values |
// automatic support for Default values |
| if ($row[4] != '' && $row[4] != 'NULL') { |
if ($row[4] != '' && $row[4] != 'NULL') { |
|
|
| $buffer = $css_directive . $buffer; |
$buffer = $css_directive . $buffer; |
| } |
} |
| // write the content include file |
// write the content include file |
| echo 'Trying to write content file to: <b>'.'./'.$contentFile.'</b><br>'."\n"; |
echo 'Trying to write content file to: <b>'.'./'.$contentFile.'</b><br>'.PHP_EOL; |
| $filehandle = @fopen('./'.$contentFile, 'w+'); |
$filehandle = @fopen('./'.$contentFile, 'w+'); |
| if ($filehandle) { |
if ($filehandle) { |
| fwrite($filehandle, $buffer); |
fwrite($filehandle, $buffer); |
|
|
| echo '<br><hr>'; |
echo '<br><hr>'; |
| echo '<pre>'; |
echo '<pre>'; |
| echo_html($buffer); |
echo_html($buffer); |
| echo '</pre><hr>'."\n"; |
echo '</pre><hr>'.PHP_EOL; |
| } |
} |
| |
|
| ?> |
?> |