#!/usr/bin/php id); define("INTERNAL_USER_USERNAME", $me->username); $layout = Layout::singleton(); $austria = CountryModel::getFirst(["name" => "Österreich"]); if(!$austria) { die("Österreich nicht gefunden\n"); } foreach(AddressModel::getAll() as $address) { if($address->country_id) continue; $country = false; $c = strtolower(trim($address->country)); if(!$c || $c == "österreich" || $c == "Österreich" || $c == "Österreic" || $c == "Österreicch" || $c == "Österrreich" || $c == "at" || $c == "a" || $c == "ö") { $country = $austria; } if($c == "oesterreic" || $c == "oesterreicch" || $c == "oesterrreich") { $country = $austria; } if(!$country) { $cc = __($address->country, "cc"); if(!$cc) { echo "cc for ".$address->country." not found"; continue; } $country = CountryModel::getFirst(["isocode" => $cc]); if(!$country) { echo "Country for isocode $cc ($c) not found\n"; continue; } } $address->country_id = $country->id; if(!$address->save()) { die(__FILE__.": Error saving address!\n"); } //echo $address->country." => ".$country->name." ".$country->isocode."\n"; }