<?php
$query = "ALTER TABLE `currency` CHANGE `symbol` `symbol` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
$result = mysql_query($query) or die("ERROR in query: $query");

$currencies = array(
    'CHF' => array('Swiss Franc', 'CHF', 'CHF', 'left', 2, 1, 1),
    'MYR' => array('Malaysian Ringgit', 'RM', 'MYR', 'left', 2, 1, 1),
    'AUD' => array('Australian Dollar', '$', 'AUD', 'left', 2, 1, 1),
    'USD' => array('United States Dollar', '$', 'USD', 'left', 2, 1, 1),
    'CAD' => array('Canadian Dollar', '$', 'CAD', 'left', 2, 1, 1),
    'NZD' => array('New Zealand Dollars', '$', 'NZD', 'left', 2, 1, 1),
    'SAR' => array('Saudi Riyal', 'SR', 'SAR', 'left', 2, 1, 1),
    'TRY' => array('Turkish Lira', 'TL', 'TRY', 'right', 2, 1, 1),
    'SEK' => array('Swedish Krona', 'kr', 'SEK', 'left', 2, 1, 1),
    'SGD' => array('Singapore Dollar', '$', 'SGD', 'left', 2, 1, 1),
    'EUR' => array('Euro', '€', 'EUR', 'left', 2, 1, 1),
    'INR' => array('Indian Rupees', 'Rs.', 'INR', 'left', 2, 1, 1),
    'PHP' => array('Philippine Peso', '₱', 'PHP', 'left', 2, 1, 1),
    'JPY' => array('Yen', '¥', 'JPY', 'left', 2, 1, 1),
    'GBP' => array('Pound Sterling (GBP)', '£', 'GBP', 'left', 2, 1, 1),
    'IDR' => array('Indonesian Rupiah (Rp)', 'Rp', 'IDR', 'left', 2, 1, 1),
    'ARS' => array('Argentine Peso', '$', 'ARS', 'left', 2, 1, 1),
    'AED' => array('United Arab Emirates Dirham', 'د.إ', 'AED', 'right', 2, 1, 0),
    'ZAR' => array('South African Rand', 'R', 'ZAR', 'left', 2, 1, 0),
    'MXN' => array('Mexican Peso', '$', 'MXN', 'left', 2, 1, 0),
    'BRL' => array('Brazilian Real', 'R$', 'BRL', 'left', 2, 1, 0),
    'XPF' => array('CFP Franc', 'F', 'XPF', 'left', 2, 1, 0),
    'RON' => array('Romania New Lei', 'lei', 'RON', 'right', 2, 1, 0),
    'EGP' => array('Egyptian Pound', 'E£', 'EGP', 'left', 3, 1, 0),
    'PLN' => array('Polish Złoty', 'zł', 'PLN', 'left', 2, 1, 0),
    'IRR' => array('Iranian Rial', 'IRR', 'IRR', 'left', 2, 1, 0),
);

$query2 = "SELECT `abrv` FROM `currency`";
$result2 = mysql_query($query2) or die("ERROR in query: $query2");

while(list($abrv) = mysql_fetch_row($result2)){
    if(array_key_exists(strtoupper($abrv), $currencies)){
        unset($currencies[strtoupper($abrv)]);
    }
}

foreach($currencies AS $currency){
    $query4 = "INSERT INTO `currency` "
             ."SET `name` = '".$currency[0]."', "
             ."`symbol` = '".$currency[1]."', "
             ."`abrv` = '".$currency[2]."', "
             ."`alignment` = '".$currency[3]."', "
             ."`precision` = ".$currency[4].", "
             ."`rate` = ".$currency[5].", "
             ."`enabled` = ".$currency[6]." ";
    mysql_query($query4) or die("ERROR in query: $query4");
}
?>