Skip to content

Commit

Permalink
merge -r1281:1283 from branch 1.6 to trunk (bug 228 fixed one more ti…
Browse files Browse the repository at this point in the history
…me, and

other little things)


git-svn-id: http://piwigo.org/svn/trunk@1284 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Apr 27, 2006
1 parent f8d72e4 commit b0751af
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 82 deletions.
4 changes: 2 additions & 2 deletions admin/include/functions.php
Expand Up @@ -1606,13 +1606,13 @@ function create_virtual_category($category_name, $parent_id=null)
}
else
{
$insert{'status'} = boolean_to_string($conf['newcat_default_status']);
$insert{'status'} = $conf['newcat_default_status'];
}
}
else
{
$insert{'visible'} = boolean_to_string($conf['newcat_default_visible']);
$insert{'status'} = boolean_to_string($conf['newcat_default_status']);
$insert{'status'} = $conf['newcat_default_status'];
$insert{'global_rank'} = $insert{'rank'};
}

Expand Down
2 changes: 1 addition & 1 deletion admin/site_update.php
Expand Up @@ -252,7 +252,7 @@
'uploadable' => $site_is_remote
? false
: boolean_to_string($conf['newcat_default_uploadable']),
'status' => boolean_to_string($conf{'newcat_default_status'}),
'status' => $conf{'newcat_default_status'},
'visible' => boolean_to_string($conf{'newcat_default_visible'}),
);

Expand Down
27 changes: 1 addition & 26 deletions include/common.inc.php
Expand Up @@ -162,32 +162,7 @@
// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
// since basic gallery information is not available
//
$query = '
SELECT param,value
FROM '.CONFIG_TABLE.'
;';
if (!($result = pwg_query($query)))
{
die("Could not query config information");
}

while ( $row =mysql_fetch_array( $result ) )
{
if ( isset( $row['value'] ) )
{
$conf[$row['param']] = $row['value'];
}
else
{
$conf[$row['param']] = '';
}
// If the field is true or false, the variable is transformed into a
// boolean value.
if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' )
{
$conf[$row['param']] = get_boolean( $conf[$row['param']] );
}
}
load_conf_from_db();

include(PHPWG_ROOT_PATH.'include/user.inc.php');

Expand Down
32 changes: 32 additions & 0 deletions include/functions.inc.php
Expand Up @@ -881,4 +881,36 @@ function get_available_upgrade_ids()
return $available_upgrade_ids;
}

/**
* Add configuration parameters from database to global $conf array
*
* @return void
*/
function load_conf_from_db()
{
global $conf;

$query = '
SELECT param,value
FROM '.CONFIG_TABLE.'
;';
$result = pwg_query($query);

if (mysql_num_rows($result) == 0)
{
die('No configuration data');
}

while ($row = mysql_fetch_array($result))
{
$conf[ $row['param'] ] = isset($row['value']) ? $row['value'] : '';

// If the field is true or false, the variable is transformed into a
// boolean value.
if ($conf[$row['param']] == 'true' or $conf[$row['param']] == 'false')
{
$conf[ $row['param'] ] = get_boolean($conf[ $row['param'] ]);
}
}
}
?>
18 changes: 16 additions & 2 deletions include/functions_user.inc.php
Expand Up @@ -446,10 +446,23 @@ function create_user_infos($user_id)

list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));

if ($user_id == $conf['webmaster_id'])
{
$status = 'webmaster';
}
else if ($user_id == $conf['guest_id'])
{
$status = 'guest';
}
else
{
$status = 'normal';
}

$insert =
array(
'user_id' => $user_id,
'status' => $user_id == $conf['webmaster_id'] ? 'admin' : 'normal',
'status' => $status,
'template' => $conf['default_template'],
'nb_image_line' => $conf['nb_image_line'],
'nb_line_page' => $conf['nb_line_page'],
Expand All @@ -460,7 +473,8 @@ function create_user_infos($user_id)
'maxwidth' => $conf['default_maxwidth'],
'maxheight' => $conf['default_maxheight'],
'registration_date' => $dbnow,
'enabled_high' => $conf['newuser_default_enabled_high']
'enabled_high' =>
boolean_to_string($conf['newuser_default_enabled_high']),
);

include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
Expand Down
82 changes: 31 additions & 51 deletions install.php
Expand Up @@ -247,8 +247,12 @@ function execute_sqlfile($filepath, $replaced, $replacing)
{
$html_content = htmlentities( $file_content, ENT_QUOTES );
$html_content = nl2br( $html_content );
$template->assign_block_vars('error_copy',
array('FILE_CONTENT'=>$html_content));
$template->assign_block_vars(
'error_copy',
array(
'FILE_CONTENT' => $html_content,
)
);
}
@fputs($fp, $file_content, strlen($file_content));
@fclose($fp);
Expand All @@ -268,65 +272,41 @@ function execute_sqlfile($filepath, $replaced, $replacing)

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

$query = '
UPDATE '.CONFIG_TABLE.'
SET value = \''.$language.'\'
WHERE param = \'default_language\'
;';
mysql_query($query);
$query = '
INSERT
INTO '.SITES_TABLE.'
(id, galleries_url)
VALUES
(1, \''.PHPWG_ROOT_PATH.'galleries/\')
;';
mysql_query($query);

// fill $conf global array
load_conf_from_db();

$insert = array(
'id' => 1,
'galleries_url' => PHPWG_ROOT_PATH.'galleries/',
);
mass_inserts(SITES_TABLE, array_keys($insert), array($insert));

// webmaster admin user
$query = '
INSERT INTO '.USERS_TABLE.'
(id,username,password,mail_address)
VALUES
(1,\''.$admin_name.'\',\''.md5($admin_pass1).'\',\''.$admin_mail.'\')
;';
mysql_query($query);
$inserts = array(
array(
'id' => 1,
'username' => $admin_name,
'password' => md5($admin_pass1),
'mail_address' => $admin_mail,
),
array(
'id' => 2,
'username' => 'guest',
),
);
mass_inserts(USERS_TABLE, array_keys($inserts[0]), $inserts);

$query = '
INSERT INTO '.USER_INFOS_TABLE.'
(user_id,status,language,enabled_high)
VALUES
(1, \'webmaster\', \''.$language.'\',\''.$conf['newuser_default_enabled_high'].'\')
;';
mysql_query($query);
create_user_infos(1);
create_user_infos(2);

$query = '
UPDATE '.USER_INFOS_TABLE.'
SET feed_id = \''.find_available_feed_id().'\'
WHERE user_id = 1
;';
mysql_query($query);

// guest user
$query = '
INSERT INTO '.USERS_TABLE.'
(id,username,password,mail_address)
VALUES
(2,\'guest\',\'\',\'\')
;';
mysql_query($query);

$query = '
INSERT INTO '.USER_INFOS_TABLE.'
(user_id,status,language,enabled_high)
VALUES
(2, \'guest\', \''.$language.'\',\'false\')
SET language = \''.$language.'\'
;';
mysql_query($query);

Expand Down

0 comments on commit b0751af

Please sign in to comment.