Changeset 142 for minimanager/run_patch.php
- Timestamp:
- Nov 23, 2007, 11:29:33 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
minimanager/run_patch.php
r19 r142 8 8 * License: GNU General Public License v2(GPL) 9 9 */ 10 10 11 11 require_once("header.php"); 12 12 valid_login(3); … … 16 16 //##################################################################################################### 17 17 function print_upload(){ 18 global $lang_run_patch, $lang_global, $backup_dir, $output, $realm_db, $mangos_db, $realm_id ;18 global $lang_run_patch, $lang_global, $backup_dir, $output, $realm_db, $mangos_db, $realm_id, $characters_db; 19 19 20 20 if (isset($_FILES["uploaded_file"]["name"])){ 21 21 if ($_FILES["uploaded_file"]["type"] != "application/octet-stream" && $_FILES["uploaded_file"]["type"] != "text/plain") error("{$lang_run_patch['run_sql_file_only']}<br />". $_FILES["uploaded_file"]["type"]); 22 if (file_exists($_FILES["uploaded_file"]["tmp_name"])){ 22 if (file_exists($_FILES["uploaded_file"]["tmp_name"])){ 23 23 $buffer = implode('', file($_FILES["uploaded_file"]["tmp_name"])); 24 24 } else error($lang_run_patch['file_not_found']); 25 25 } else $buffer = ""; 26 26 27 27 $upload_max_filesize=ini_get("upload_max_filesize"); 28 28 if (eregi("([0-9]+)K",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024; 29 29 if (eregi("([0-9]+)M",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024; 30 30 31 31 $output .= "<center>{$lang_run_patch['select_sql_file']} :<br /> 32 {$lang_run_patch['max_filesize']} $upload_max_filesize bytes 32 {$lang_run_patch['max_filesize']} $upload_max_filesize bytes 33 33 (".round ($upload_max_filesize/1024/1024)." Mbytes)<br /> 34 34 <table class=\"hidden\"> … … 44 44 <tr> 45 45 <td align=\"left\">{$lang_run_patch['run_rules']}</td> 46 <td align=\"right\">{$lang_run_patch['select_db']}: 46 <td align=\"right\">{$lang_run_patch['select_db']}: 47 47 <select name=\"use_db\">"; 48 48 foreach ($mangos_db as $db) $output .= "<option value=\"{$db['name']}\">{$db['name']}</option>"; 49 foreach ($characters_db as $db) $output .= "<option value=\"{$db['name']}\">{$db['name']}</option>"; 49 50 $output .= "<option value=\"{$realm_db['name']}\">{$realm_db['name']}</option> 50 51 </select> … … 52 53 <tr><td colspan=\"2\"><textarea name=\"query\" rows=\"14\" cols=\"93\">$buffer</textarea></td></tr> 53 54 <tr><td colspan=\"2\">"; 54 55 $output .= "</td></tr>56 </table>57 </form></center><br />"; 55 makebutton($lang_run_patch['run_sql'], "javascript:do_submit('form1',0)",200); 56 $output .= "</td></tr> 57 </table> 58 </form></center><br />"; 58 59 } 59 60 … … 63 64 //##################################################################################################### 64 65 function do_run_patch(){ 65 global $lang_run_patch, $lang_global, $output, $mangos_db, $realm_db ;66 global $lang_run_patch, $lang_global, $output, $mangos_db, $realm_db, $characters_db; 66 67 67 68 if ( empty($_POST['query']) || empty($_POST['use_db']) ) redirect("run_patch.php?error=1"); … … 69 70 $sql = new SQL; 70 71 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']); 71 72 72 73 $use_db = $sql->quote_smart($_POST['use_db']); 73 74 $query = $_POST['query']; 74 75 75 76 if ($use_db == $realm_db['name']) $sql->db($realm_db['name']); 76 77 else { 77 78 foreach ($mangos_db as $db) 78 79 if ($use_db == $db['name']) $sql->connect($db['addr'], $db['user'], $db['pass'], $db['name']); 80 foreach ($characters_db as $db) 81 if ($use_db == $db['name']) $sql->connect($db['addr'], $db['user'], $db['pass'], $db['name']); 79 82 } 80 83 81 84 $new_queries = array(); 82 85 $good = 0; 83 86 $bad = 0; 84 87 $line = 0; 85 88 86 89 $queries = explode("\n",$query); 87 90 for($i=0; $i<count($queries); $i++) { 88 91 $queries[$i] = trim($queries[$i]); 89 92 90 93 if(strpos ($queries[$i], '#') === 0 || strpos ($queries[$i], '--') === 0) $line++; 91 94 else array_push($new_queries, $queries[$i]); 92 95 } 93 96 $qr=split(";\n",implode("\n",$new_queries)); 94 97 95 98 foreach($qr as $qry) { 96 99 $line++; … … 106 109 107 110 $sql->close(); 108 111 109 112 if ($queries) redirect("run_patch.php?error=2&tot=$good"); 110 113 else redirect("run_patch.php?error=3");
Note:
See TracChangeset
for help on using the changeset viewer.