Show
Ignore:
Timestamp:
12/02/06 05:17:10 (14 years ago)
Author:
exi
Message:

Reduced one potential sql-bug.
Added ability to identify items as t2 via their techlevel rather than just 'II'.
Fixed item location 0 to not cause skipping that item.
Added anzahl/quantity-replace for the german killpreparser.
Fixed final blow award to show correct numbers.
Removed unnecessary code from db.php.
Added a table data check to the sql importer and made the importer more verbose, this should minimize support requests caused by empty table data.
Fixed a small misalignment of the comment block.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dev/install/install_step4.php

    r103 r133  
    2020            $optcnt++; 
    2121            $opt[$table][] = $file; 
     22            asort($opt[$table]); 
    2223        } 
    2324        else 
     
    2627            $datacnt++; 
    2728            $data[$table][] = $file; 
    28         } 
    29     } 
    30 } 
     29            asort($data[$table]); 
     30        } 
     31    } 
     32} 
     33 
    3134$db = mysql_pconnect($_SESSION['sql']['host'], $_SESSION['sql']['user'], $_SESSION['sql']['pass']); 
    3235mysql_select_db($_SESSION['sql']['db']); 
     
    9497                    continue; 
    9598                } 
    96                 echo 'Inserting data ('.$i.'/'.$datacnt.') into '.$table.' from file '.$file.'...'; 
     99                echo 'Inserting data ('.$i.'/'.$datacnt.') into '.$table.' from file '.$file.'...<br/>'; 
     100 
     101                $error = ''; 
    97102                $querys = file('./sql/'.$file); 
     103                $lines = count($querys); 
     104                $errors = 0; 
    98105                foreach ($querys as $query) 
    99106                { 
    100107                    if (trim($query)) 
    101108                    { 
     109                        $query_count++; 
    102110                        $id = mysql_query($query); 
     111                        if (!$id) 
     112                        { 
     113                            $error .= 'error: '.mysql_error().'<br/>'; 
     114                            $errors++; 
     115                        } 
    103116                    } 
    104117                } 
    105                 if ($id) 
     118                echo 'File '.$file.' had '.$lines.' lines with '.$query_count.' querys. '.$errors.' Querys failed.<br/>'; 
     119                if (!$error) 
    106120                { 
    107121                    echo 'done<br/>'; 
     
    111125                else 
    112126                { 
    113                     echo 'error: '.mysql_error().'<br/>'; 
     127                    echo $error; 
    114128                    echo '<meta http-equiv="refresh" content="20; URL=?step=4&sub=data" />'; 
    115129                    echo 'Automatic reload in 20s for next chunk because of the error occured. <a href="?step=4&sub=data">Manual Link</a><br/>'; 
     
    179193    if (!$did) 
    180194    { 
    181         echo 'All tables imported. You can now create or search your corporation/alliance: <a href="?step=5">Continue</a><br/>'; 
    182195        $stoppage = false; 
    183     } 
    184     echo '<a href="?step=4&sub=datasel&do=reset">Reset</a><br/>'; 
     196        echo 'All tables imported. Checking tables for correct data...<br/>'; 
     197        $check = file('./sql/tbl_check.txt'); 
     198        foreach ($check as $line) 
     199        { 
     200            $tmp = explode(chr(9), $line); 
     201            $table = trim($tmp[0]); 
     202            $count = trim($tmp[1]); 
     203            echo 'Checking table '.$table.': '; 
     204            $result = mysql_query('SELECT count(*) as cnt FROM '.$table); 
     205            $test = mysql_fetch_array($result); 
     206            if ($test['cnt'] != $count) 
     207            { 
     208                echo $test['cnt'].'/'.$count.' - FAILED'; 
     209                $stoppage = true; 
     210            } 
     211            else 
     212            { 
     213                echo $test['cnt'].'/'.$count.' - PASSED'; 
     214            } 
     215            echo '<br/>'; 
     216        } 
     217        if ($stoppage) 
     218        { 
     219            echo 'There has been an error with one of the tables, please <a href="?step=4&do=reset">Reset</a> and try again.<br/>'; 
     220        } 
     221        else 
     222        { 
     223            echo '<br/>All tables passed.<br/>'; 
     224            echo 'You can now create or search your corporation/alliance: <a href="?step=5">Next Step</a><br/>'; 
     225        } 
     226    } 
     227    echo '<br/>Use <a href="?step=4&sub=datasel&do=reset">Reset</a> to step back to the sql-opt select.<br/>'; 
    185228} 
    186229?> 
     
    197240if (!$structadd && $_REQUEST['sub'] != 'datasel' && $_REQUEST['sub'] != 'data') 
    198241{ 
    199     echo 'All table structures seem to be in the database, please continue with <a href="?step=4&sub=datasel">Importing Data</a><br/>'; 
     242    echo 'All table structures seem to be in the database.<br/>'; 
     243    echo 'I will now check some table structures in case you are upgrading from a previous version... '; 
     244    include('install_step4_tblchk.php'); 
     245    echo 'done<br/>Please continue with <a href="?step=4&sub=datasel">Importing Data</a><br/>'; 
     246 
    200247    echo '<br/><br/>In case you aborted the install and you got already data in those table you can bypass the import now by with <a href="?step=5">this link</a><br/>'; 
     248    echo 'To be sure i will check some table data for you now:<br/>'; 
     249    $check = file('./sql/tbl_check.txt'); 
     250    foreach ($check as $line) 
     251    { 
     252        $tmp = explode(chr(9), $line); 
     253        $table = trim($tmp[0]); 
     254        $count = trim($tmp[1]); 
     255        echo 'Checking table '.$table.': '; 
     256        $result = mysql_query('SELECT count(*) as cnt FROM '.$table); 
     257        $test = mysql_fetch_array($result); 
     258        $failed = 0; 
     259        if ($test['cnt'] != $count) 
     260        { 
     261            echo $test['cnt'].'/'.$count.' - FAILED'; 
     262            $failed++; 
     263        } 
     264        else 
     265        { 
     266            echo $test['cnt'].'/'.$count.' - PASSED'; 
     267        } 
     268        echo '<br/>'; 
     269    } 
     270    echo 'Checking table kb3_items: '; 
     271    $result = mysql_query('SELECT count(*) as cnt FROM kb3_items'); 
     272    $test = mysql_fetch_array($result); 
     273    $failed = 0; 
     274    if ($test['cnt'] <= 5000) 
     275    { 
     276        echo $test['cnt'].'<5000 - FAILED'; 
     277        $failed++; 
     278    } 
     279    else 
     280    { 
     281        echo $test['cnt'].'>5000 - PASSED'; 
     282    } 
     283    echo '<br/>'; 
     284    if (!$failed) 
     285    { 
     286        echo 'All important table data seems to be there, you are safe to bypass the import.<br/>'; 
     287    } 
     288    else 
     289    { 
     290        echo 'There was an error in one of the important tables, please run the import.<br/>'; 
     291    } 
    201292} 
    202293elseif ($structadd)