[ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* $Id: update.php,v 1.1 2001/01/16 00:10:11 pkellum Exp $ */ 3 include '../mysql.php'; 4 // if a readme.txt file exists, display it to the user 5 if(!$read_me) { 6 if(file_exists('readme.txt')) { 7 $readme_file = 'readme.txt'; 8 } 9 elseif(file_exists('README')) { 10 $readme_file = 'README'; 11 } 12 elseif(file_exists('readme')) { 13 $readme_file = 'readme'; 14 } 15 if($readme_file) { 16 $readme = file($readme_file); 17 print "<CENTER><TABLE BORDER=\"1\" WIDTH=\"75%\" CELLPADDING=\"2\" CELLSPACING=\"0\"><TR BGCOLOR=\"#e7e7cc\"><TD>\n"; 18 print nl2br(htmlentities(implode($readme, ' '))); 19 print "<HR NOSHADE SIZE=\"1\"><CENTER><A HREF=\"update.php?read_me=1\"><B>Continue</B></A></CENTER>\n"; 20 print "</TD></TR></TABLE>\n"; 21 exit; 22 } 23 } 24 // list all sql files in this directory for the user to choose from 25 if(!$filename) { 26 print "<B>Select an SQL file to install.</B><UL>\n"; 27 $files = dir('.'); 28 while($f = $files->read()) { 29 if(substr($f, -4, 4) == '.sql') { 30 print "<LI><A HREF=\"update.php?read_me=1&filename=$f\">$f</A>"; 31 $sql_file = file($f); 32 if(substr($sql_file[0], 0, 8) == '# Brief:') { 33 print " - " . htmlentities(substr($sql_file[0], 9)); 34 } 35 print "</LI>\n"; 36 } 37 } 38 print "</UL>"; 39 } 40 // look like we've decided on a file 41 else { 42 // read in the sql file and parse it into a form 43 if(!$action) { 44 $sql_file = file($filename); 45 $sql_statements = array(); 46 // create a new array containing just the lines we want. 47 foreach($sql_file as $k=>$v) { 48 // get rid of whitespace 49 $sql = trim($v); 50 // no comments, please 51 if(substr($sql, 0, 1) == '#') { 52 continue; 53 } 54 // no blank lines 55 if(!$sql) { 56 continue; 57 } 58 // insert the current sql line into a buffer 59 $cur_sql .= $sql . ' '; 60 // get the ending character. if it's a ';' then we have a full statement, otherwise keep appending until we do. 61 if(substr($sql, -1, 1) == ';') { 62 $sql_statements[] = substr(trim($cur_sql), 0, -1); 63 $cur_sql = ''; 64 } 65 } 66 // ok, we got our new array 'sql_statements' containing a full sql statement per element 67 // now, let's display them in a form to allow modification before commiting 68 print "<B>Check over the following SQL statements and make sure they are correct for your server. If so, click the "Commit" button.</B><BR><BR>\n"; 69 print "<FORM METHOD=\"post\" ACTION=\"update.php\">\n"; 70 print "<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"commit\">\n"; 71 print "<INPUT TYPE=\"hidden\" NAME=\"filename\" VALUE=\"$filename\">\n"; 72 print "<INPUT TYPE=\"hidden\" NAME=\"read_me\" VALUE=\"1\">\n"; 73 foreach($sql_statements as $k=>$v) { 74 print "<B>" . $k . ":</B> <TEXTAREA NAME=\"sql_statements[$k]\" ROWS=\"3\" COLS=\"40\" WRAP=\"soft\">" . htmlentities($v) . "</TEXTAREA><BR><BR>\n"; 75 } 76 print "<INPUT TYPE=\"submit\" VALUE=\"Commit\">"; 77 print "</FORM>"; 78 } 79 // commit the changes to the database 80 else { 81 foreach($sql_statements as $k=>$v) { 82 $result = mysql_query(stripslashes($v)); 83 if(!$result) { 84 print "<B>Error:</B> the following SQL statement didn't work.<BR>\n"; 85 print mysql_error() . '<BR><BR>'; 86 print "<BLOCKQUOTE>\n" . htmlentities(stripslashes($v)) . "\n</BLOCKQUOTE>"; 87 print "<HR NOSHADE SIZE=\"1\">"; 88 } 89 } 90 print "<H1 ALIGN=\"center\">SQL Database Updated!</H1>"; 91 } 92 } 93 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |