Ignore:
Timestamp:
Nov 23, 2007, 11:29:33 PM (17 years ago)
Author:
george
Message:

Minimanager 0.1.5b

File:
1 edited

Legend:

Unmodified
Added
Removed
  • minimanager/run_patch.php

    r19 r142  
    88 * License: GNU General Public License v2(GPL)
    99 */
    10  
     10
    1111require_once("header.php");
    1212valid_login(3);
     
    1616//#####################################################################################################
    1717function 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;
    1919
    2020if (isset($_FILES["uploaded_file"]["name"])){
    2121 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"])){
    2323        $buffer = implode('', file($_FILES["uploaded_file"]["tmp_name"]));
    2424        } else error($lang_run_patch['file_not_found']);
    2525 } else $buffer = "";
    26  
     26
    2727        $upload_max_filesize=ini_get("upload_max_filesize");
    2828        if (eregi("([0-9]+)K",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
    2929        if (eregi("([0-9]+)M",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
    30  
     30
    3131        $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
    3333                                (".round ($upload_max_filesize/1024/1024)." Mbytes)<br />
    3434                <table class=\"hidden\">
     
    4444                                <tr>
    4545                                 <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']}:
    4747                                 <select name=\"use_db\">";
    4848         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>";
    4950         $output .= "<option value=\"{$realm_db['name']}\">{$realm_db['name']}</option>
    5051                                 </select>
     
    5253                                <tr><td colspan=\"2\"><textarea name=\"query\" rows=\"14\" cols=\"93\">$buffer</textarea></td></tr>
    5354                                <tr><td colspan=\"2\">";
    54                                         makebutton($lang_run_patch['run_sql'], "javascript:do_submit('form1',0)",200);
    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 />";
    5859}
    5960
     
    6364//#####################################################################################################
    6465function 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;
    6667
    6768 if ( empty($_POST['query']) || empty($_POST['use_db']) ) redirect("run_patch.php?error=1");
     
    6970 $sql = new SQL;
    7071 $sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
    71  
     72
    7273 $use_db = $sql->quote_smart($_POST['use_db']);
    7374 $query = $_POST['query'];
    74  
     75
    7576 if ($use_db == $realm_db['name']) $sql->db($realm_db['name']);
    7677        else {
    7778                foreach ($mangos_db as $db)
    7879                        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']);
    7982        }
    80        
     83
    8184 $new_queries = array();
    8285 $good = 0;
    8386 $bad = 0;
    8487 $line = 0;
    85  
     88
    8689 $queries = explode("\n",$query);
    8790 for($i=0; $i<count($queries); $i++) {
    8891    $queries[$i] = trim($queries[$i]);
    89        
     92
    9093    if(strpos ($queries[$i], '#') === 0 || strpos ($queries[$i], '--') === 0)  $line++;
    9194                else array_push($new_queries, $queries[$i]);
    9295   }
    9396 $qr=split(";\n",implode("\n",$new_queries));
    94  
     97
    9598 foreach($qr as $qry) {
    9699        $line++;
     
    106109
    107110 $sql->close();
    108  
     111
    109112 if ($queries) redirect("run_patch.php?error=2&tot=$good");
    110113        else redirect("run_patch.php?error=3");
Note: See TracChangeset for help on using the changeset viewer.