<?php

if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
	require_once(dirname(__FILE__) . '/SSI.php');
elseif(!defined('SMF'))
	die('<b>Error:</b> Cannot install - please verify that you put this file in the same place as SMF\'s index.php and SSI.php files.');

if ((SMF == 'SSI') && !$user_info['is_admin'])
	die('Admin privileges required.');

global $modSettings, $sourcedir;
$smileyName = 'F9';
$smileySet = 'f9';

$smiley_sets_known = $modSettings['smiley_sets_known'] . ",$smileySet";

$temp = explode(PHP_EOL, $modSettings['smiley_sets_names']);
$temp[] = $smileyName;
$temp = implode(PHP_EOL, $temp);
$smiley_sets_names = $temp;

updateSettings(
	array(
		'smiley_sets_known'		=> $smiley_sets_known,
		'smiley_sets_names'		=> $smiley_sets_names,
		'smiley_sets_default'	=> $smileySet,
	)
);

/*
$smileys = [@@SMILEYS@@];

$i = 0;
foreach ($smileys as $smiley) {
    $i++;
    $smcFunc['db_insert']('replace',
        '{db_prefix}smiley_files',
        array(
            'id_smiley' => 'int', 'smiley_set' => 'string-48', 'filename' => 'string-48',
        ),
        array(
            "$i", $smileySet, $smiley . '.gif',
        ),
        array('id_smiley', 'smiley_set')
    );
}
*/

require_once($sourcedir . '/ManageSmileys.php');

ImportSmileys($smileySet);

if (SMF == 'SSI')
    echo 'Database changes are complete! Please wait ...';

?>
