Skip to content

Commit

Permalink
merge -r1145:1146 from branches/branch-1_6 into trunk (bug 329 fixed).
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@1147 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Apr 11, 2006
1 parent fd77b2c commit ca9107a
Showing 1 changed file with 56 additions and 63 deletions.
119 changes: 56 additions & 63 deletions install.php
Expand Up @@ -32,38 +32,6 @@
function guess_lang()
{
return 'en_UK.iso-8859-1';

// $languages = array();
// $i = 0;
// if ($opendir = opendir(PHPWG_ROOT_PATH.'language/'))
// {
// while ( $file = readdir ( $opendir ) )
// {
// if ( is_dir ( PHPWG_ROOT_PATH.'language/'.$file )&& !substr_count($file,'.'))
// {
// $languages[$i++] =$file;
// }
// }
// }

// if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
// {
// $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
// for ($i = 0; $i < sizeof($accept_lang_ary); $i++)
// {
// for ($j=0; $j<sizeof($languages); $j++)
// {
// if (preg_match('#' . substr($languages[$j],0,2) . '#i', substr(trim($accept_lang_ary[$i]),0,2)))
// {
// if (file_exists(PHPWG_ROOT_PATH . 'language/' . $languages[$j].'/install.lang.php'))
// {
// return $languages[$j];
// }
// }
// }
// }
// }
// return 'en_EN';
}

/**
Expand Down Expand Up @@ -155,13 +123,23 @@ function execute_sqlfile($filepath, $replaced, $replacing)
}

//----------------------------------------------------- variable initialization

define('DEFAULT_PREFIX_TABLE', 'phpwebgallery_');

// Obtain various vars
$dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost';
$dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : '';
$dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : '';
$dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : '';

$table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : 'phpwebgallery_';
if (isset($_POST['install']))
{
$table_prefix = $_POST['prefix'];
}
else
{
$table_prefix = DEFAULT_PREFIX_TABLE;
}

$admin_name = (!empty($_POST['admin_name'])) ? $_POST['admin_name'] : '';
$admin_pass1 = (!empty($_POST['admin_pass1'])) ? $_POST['admin_pass1'] : '';
Expand Down Expand Up @@ -251,16 +229,16 @@ function execute_sqlfile($filepath, $replaced, $replacing)
if ( count( $errors ) == 0 )
{
$step = 2;
$file_content = "<?php";
$file_content.= "\n\$cfgBase = '". $dbname."';";
$file_content.= "\n\$cfgUser = '". $dbuser."';";
$file_content.= "\n\$cfgPassword = '". $dbpasswd."';";
$file_content.= "\n\$cfgHote = '". $dbhost."';";
$file_content.= "\n";
$file_content.= "\n\$prefixeTable = '".$table_prefix."';";
$file_content.= "\n";
$file_content.= "\ndefine('PHPWG_INSTALLED', true);";
$file_content.= "\n?".">";
$file_content = '<?php
$cfgBase = \''.$dbname.'\';
$cfgUser = \''.$dbuser.'\';
$cfgPassword = \''.$dbpasswd.'\';
$cfgHote = \''.$dbhost.'\';
$prefixeTable = \''.$table_prefix.'\';
define(\'PHPWG_INSTALLED\', true);
?'.'>';

@umask(0111);
// writing the configuration file
Expand All @@ -275,29 +253,40 @@ function execute_sqlfile($filepath, $replaced, $replacing)
@fclose($fp);

// tables creation, based on phpwebgallery_structure.sql
execute_sqlfile( PHPWG_ROOT_PATH.'install/phpwebgallery_structure.sql'
, 'phpwebgallery_'
, $table_prefix );
execute_sqlfile(
PHPWG_ROOT_PATH.'install/phpwebgallery_structure.sql',
DEFAULT_PREFIX_TABLE,
$table_prefix
);
// We fill the tables with basic informations
execute_sqlfile( PHPWG_ROOT_PATH.'install/config.sql'
, 'phpwebgallery_'
, $table_prefix );
execute_sqlfile(
PHPWG_ROOT_PATH.'install/config.sql',
DEFAULT_PREFIX_TABLE,
$table_prefix
);

$query = 'UPDATE '.CONFIG_TABLE;
$query.= " SET value = '".$admin_mail."'";
$query.= " WHERE param = 'mail_webmaster'";
$query.= ';';
mysql_query( $query );
$query = '
UPDATE '.CONFIG_TABLE.'
SET value = \''.$admin_mail.'\'
WHERE param = \'mail_webmaster\'
;';
mysql_query($query);

$query = 'UPDATE '.CONFIG_TABLE;
$query.= " SET value = '".$language."'";
$query.= " WHERE param = 'default_language'";
$query.= ';';
mysql_query( $query );
$query = '
UPDATE '.CONFIG_TABLE.'
SET value = \''.$language.'\'
WHERE param = \'default_language\'
;';
mysql_query($query);

$query = 'INSERT INTO '.SITES_TABLE;
$query.= " (id,galleries_url) VALUES (1, '".PHPWG_ROOT_PATH."galleries/');";
mysql_query( $query );
$query = '
INSERT
INTO '.SITES_TABLE.'
(id, galleries_url)
VALUES
(1, \''.PHPWG_ROOT_PATH.'galleries/\')
;';
mysql_query($query);

// webmaster admin user
$query = '
Expand Down Expand Up @@ -392,7 +381,11 @@ function execute_sqlfile($filepath, $replaced, $replacing)
'F_DB_HOST'=>$dbhost,
'F_DB_USER'=>$dbuser,
'F_DB_NAME'=>$dbname,
'F_DB_PREFIX'=>$table_prefix,
'F_DB_PREFIX' => (
$table_prefix != DEFAULT_PREFIX_TABLE
? $table_prefix
: DEFAULT_PREFIX_TABLE
),
'F_ADMIN'=>$admin_name,
'F_ADMIN_EMAIL'=>$admin_mail,
'F_LANG_SELECT'=>language_select($language),
Expand Down

0 comments on commit ca9107a

Please sign in to comment.