<?php
// $Id: country.php,v 1.2 2002/09/16 14:43:36 mattboy99 Exp $
// PHP-Personals [Raden St. Release]
// ----------------------------------
// country.php : Insert Countries into phpBB database
//
// Copyright (C) 2002 Matt Jarjoura. <hide@address.com>
//
// Original Code Derived from "phpBB 2.0.2"
// Copyright (C) 2001 The phpBB Group.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);
$data = initFile("countries.dat");
for ($i = 0; $i < $data[0]; $i++) {
$tmp = "'".$data[$i + 1]."'";
$sql = "INSERT INTO forum_country (country) VALUES ( $tmp )";
$result = $db->sql_query($sql);
if (!$result) {
echo "SQL: <strong>$sql</strong> <br /><br />";
message_die(CRITICAL_ERROR, "Could not add countries to database", "", __LINE__, __FILE__, $sql);
}
}
message_die(MESSAGE_GENERAL, "Successfully added countries to database.<br /><br />");
function initFile($fn)
{
$file = fopen($fn, "r");
$buffer[0] = 0;
while (!feof ($file)) {
$tmpRet = fgets($file, 255);
$tmpRet = addslashes(trim($tmpRet));
if(strlen($tmpRet) > 0) {
$buffer[$totalLines+1] = $tmpRet;
$totalLines++;
}
}
$buffer[0] = $totalLines++;
fclose ($file);
return $buffer;
}
?>