Menu: <a href="?action=connect">Connect</a> <a href="?action=export_personer">Export personer</a> <a href="?action=export_trafik">Export trafik</a> <br><br> <?php //conf $month_map = array("01" => "januar", "02" => "februar", "03" => "marts", "04" => "april", "05" => "maj", "06" => "juni", "07" => "juli", "08" => "august", "09" => "september", "10" => "oktober", "11" => "november", "12" => "december"); //action if (isset($_GET['action'])) { if ($_GET['action'] === "connect") { for ($year = 2000; $year <= 2016; $year++) { if ($year === 2006) { continue; } $con = new ODBCWrapper("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:/dwork/bs_trafik_data/Trafikstatistik {$year}.mdb", "", ""); echo "{$year}: "; echo $con->get_single_value("\tSELECT count(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM PersonOplysninger\n\t\t\t\t\t\t\t\t\t\t\t\t\t"); echo "<br>"; } } elseif ($_GET['action'] === "export_personer") { for ($year = 2000; $year <= 2016; $year++) { if ($year === 2006) { continue; } $con = new ODBCWrapper("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:/dwork/bs_trafik_data/Trafikstatistik {$year}.mdb", "", ""); $dbf = new DatabaseFunctions($con); $dbf->sql_to_csv_file("\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\t\tFROM PersonOplysninger\n\t\t\t\t\t\t\t\t\t\t\t\tORDER BY navn\n\t\t\t\t\t\t\t\t\t\t\t\t", "export_files/personoplysniner{$year}.csv"); echo "personoplysniner {$year} exported<br>"; } } elseif ($_GET['action'] === "export_trafik") {
$sql = file_get_contents("data.sql"); db()->query("UPDATE medlemmer SET salt = GET_RANDOM(4)"); db()->query("UPDATE medlemmer SET pass = MD5(CONCAT(salt, username))"); echo "All passwords set to the username.<br>"; } elseif ($_GET['action'] === "load_testnames") { $sql = file_get_contents("test_names.sql"); db()->multi_execute($sql); echo "Names loaded.<br>"; } elseif ($_GET['action'] === "connect") { $con = new ODBCWrapper("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:/dwork/Trafikstatistik 2000.mdb", "", ""); $dbf = new DatabaseFunctions($con); echo $dbf->implode_query("\tSELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM PersonOplysninger\n\t\t\t\t\t\t\t\t\t\t\t"); } elseif ($_GET['action'] === "gen_test_data") { db()->query("truncate table medlemmer"); $test_names = db()->query("SELECT name,email FROM test_names"); $con = new ODBCWrapper("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:/dwork/Trafikstatistik 2000.mdb", "", ""); $query = $con->query("SELECT * FROM PersonOplysninger ORDER BY navn"); while ($row = $query->fetch_row()) { $ano_row = $test_names->fetch_row(); $ano_name = $ano_row[0]; // out($row); $username = trim_name_to_username($ano_name); $sql = <<<ASDF t\t\t\t\tINSERT INTO medlemmer (`username`, `pass`, `salt`, `navn`, `adresse`, `kommune`, `email`, `nyhedsbrev`, `status`, `created`) t\t\t\t\t\tVALUES ('{$username}', t\t\t\t\t\t\t\t'', t\t\t\t\t\t\t\t'', t\t\t\t\t\t\t\t'{$ano_name}', t\t\t\t\t\t\t\t'', t\t\t\t\t\t\t\t'København', t\t\t\t\t\t\t\t'{$username}@example.com',