$text
|
|
EOT;
}
// Added for allowing user to select which aspect of thumbnails to scale
function form_scale($text, $name)
{
global $CONFIG, $lang_config_php ;
$value = $CONFIG[$name];
$any_selected = ($value == 'max') ? 'selected' : '';
$ht_selected = ($value == 'ht') ? 'selected' : '';
$wd_selected = ($value == 'wd') ? 'selected' : '';
echo <<
$text
|
|
EOT;
}
function form_lang_theme($text, $name)
{
global $CONFIG, $lang_yes, $lang_no, $lang_config_php;
$value = $CONFIG[$name];
$no_selected = ($value == '0') ? 'checked="checked"' : '';
$yes_1_selected = ($value == '1') ? 'checked="checked"' : '';
$yes_2_selected = ($value == '2') ? 'checked="checked"' : '';
echo <<
$text
|
|
EOT;
}
function form_lang_debug($text, $name)
{
global $CONFIG, $lang_yes, $lang_no, $lang_config_php;
$value = $CONFIG[$name];
$no_selected = ($value == '0') ? 'checked="checked"' : '';
$yes_1_selected = ($value == '1') ? 'checked="checked"' : '';
$yes_2_selected = ($value == '2') ? 'checked="checked"' : '';
echo <<
$text
|
|
EOT;
}
function form_number_dropdown($text, $name)
{
global $CONFIG, $lang_config_php ;
echo <<
$text
|
|
EOT;
}
function create_form(&$data)
{
foreach($data as $element) {
if ((is_array($element))) {
switch ($element[2]) {
case 0 :
form_input($element[0], $element[1]);
break;
case 1 :
form_yes_no($element[0], $element[1]);
break;
case 2 :
form_img_pkg($element[0], $element[1]);
break;
case 3 :
form_sort_order($element[0], $element[1]);
break;
case 4 :
form_charset($element[0], $element[1]);
break;
case 5 :
form_language($element[0], $element[1]);
break;
case 6 :
form_theme($element[0], $element[1]);
break;
// Thumbnail scaling
case 7 :
form_scale($element[0], $element[1]);
break;
// Language + Theme selection
case 8 :
form_lang_theme($element[0], $element[1]);
break;
// debug mode selection
case 9 :
form_lang_debug($element[0], $element[1]);
break;
// tabbed display fix
case 10 :
form_number_dropdown($element[0], $element[1]);
break;
default:
die('Invalid action');
} // switch
} else {
form_label($element);
}
}
}
if (count($HTTP_POST_VARS) > 0) {
if (isset($HTTP_POST_VARS['update_config'])) {
$need_to_be_positive = array('albums_per_page',
'album_list_cols',
'max_tabs',
'picture_width',
'subcat_level',
'thumb_width',
'thumbcols',
'thumbrows',
// Show filmstrip
'max_film_strip_items');
// Code to rename system thumbs in images folder
$old_thumb_pfx =& $CONFIG['thumb_pfx'];
if ($old_thumb_pfx != $HTTP_POST_VARS['thumb_pfx']) {
$folders = array('images/', $THEME_DIR.'images/');
foreach ($folders as $folder) {
$thumbs = cpg_get_system_thumb_list($folder);
foreach ($thumbs as $thumb) {
@rename($folder.$thumb['filename'],
$folder.str_replace($old_thumb_pfx,$HTTP_POST_VARS['thumb_pfx'],$thumb['filename']));
}
}
}
foreach ($need_to_be_positive as $parameter)
$HTTP_POST_VARS[$parameter] = max(1, (int)$HTTP_POST_VARS[$parameter]);
foreach($lang_config_data as $element) {
if ((is_array($element))) {
if ((!isset($HTTP_POST_VARS[$element[1]]))) cpg_die(CRITICAL_ERROR, "Missing config value for '{$element[1]}'", __FILE__, __LINE__);
$value = addslashes($HTTP_POST_VARS[$element[1]]);
db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '$value' WHERE name = '{$element[1]}'");
}
}
pageheader($lang_config_php['title']);
msg_box($lang_config_php['info'], $lang_config_php['upd_success'], $lang_continue, 'index.php');
} elseif (isset($HTTP_POST_VARS['restore_config'])) {
$default_config = 'sql/basic.sql';
$sql_query = fread(fopen($default_config, 'r'), filesize($default_config));
$sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query);
db_query("TRUNCATE TABLE {$CONFIG['TABLE_CONFIG']}");
db_query("TRUNCATE TABLE {$CONFIG['TABLE_FILETYPES']}");
$sql_query = remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, ';');
$sql_count = count($sql_query);
for($i = 0; $i < $sql_count; $i++) if (strpos($sql_query[$i],'_config') || strpos($sql_query[$i],'_filetypes')) db_query($sql_query[$i]);
pageheader($lang_config_php['title']);
msg_box($lang_config_php['info'], $lang_config_php['restore_success'], $lang_continue, $PHP_SELF);
}
pagefooter();
exit;
}
pageheader($lang_config_php['title']);
$signature = 'Coppermine Photo Gallery ' . COPPERMINE_VERSION;
starttable('100%', "{$lang_config_php['title']} - $signature", 2);
echo <<
EOT;
create_form($lang_config_data);
echo <<
|
EOT;
endtable();
pagefooter();
ob_end_flush();
?>