Esempio n. 1
0
function save_config($config, $holder, $redirect, $save_blocks = true)
{
    global $form, $lang_system, $lang_admin;
    if ($save_blocks) {
        $form['blocks'] = $_POST['blocks'] ? count($_POST['blocks']) == $_POST['blocks_count'] ? '' : implode(', ', $_POST['blocks']) : 'NULL';
    }
    foreach ($form as $key => $value) {
        if (isset($config[$key]) && $config[$key] != $value) {
            $value ? sql_query('
					UPDATE ' . DB_PREFIX . 'config
					SET content = ' . (is_numeric($value) ? $value : '"' . $value . '"') . '
					WHERE name = "' . $key . '" AND holder = "' . $holder . '"') : sql_query('DELETE FROM ' . DB_PREFIX . 'config WHERE name = "' . $key . '" AND holder = "' . $holder . '"');
        } elseif (!isset($config[$key]) && $value) {
            sql_query('
				INSERT INTO ' . DB_PREFIX . 'config (holder, name, content)
				VALUES ("' . $holder . '", "' . $key . '", ' . (is_numeric($value) ? (int) $value : '"' . $value . '"') . ')');
        }
    }
    sql_error() ? negative(array($lang_system['ERROR_SQL'], sql_error())) : positive($lang_admin['SAVED_SUCCESSFUL']) . redirect($redirect);
}
Esempio n. 2
0
<?php

// KioCMS - Kiofol Content Managment System
// admin/configuration/server.php
defined('KioCMS') || (include_once '../ajax.php');
$save = $_POST['save'] ? true : false;
$form = array('db_host' => $save ? $_POST['db_host'] : db_host, 'db_name' => $save ? $_POST['db_name'] : db_name, 'db_user' => $save ? $_POST['db_user'] : db_user, 'db_pass' => $save ? $_POST['db_pass'] : db_pass, 'db_prefix' => $save ? $_POST['db_prefix'] : db_prefix, 'db_type' => $save ? $_POST['db_type'] : db_type, 'local_dir' => $save ? $_POST['local_dir'] : local_dir, 'site_url' => $save ? $_POST['site_url'] : site_url, 'cookie_name' => $save ? $_POST['cookie_name'] : cookie_name, 'logs' => $save ? $_POST['logs'] : logs ? 1 : 0, 'errors' => $save ? $_POST['errors'] : errors, 'lock_config' => is_writable(root_dir . 'config.php') ? $save ? $_POST['lock_config'] : false : true);
if ($save) {
    $errors = array(!is_writable(root_dir . 'config.php') ? 'Plik <strong>config.php</strong> jest chroniony przed zapisem.' : '', !$form['db_host'] ? 'Pole <strong>serwer</strong> nie może zostać puste.' : '', !$form['db_name'] ? 'Pole <strong>nazwa</strong> nie może zostać puste.' : '', !$form['db_user'] ? 'Pole <strong>użytkownik</strong> nie może zostać puste.' : '', !$form['db_pass'] ? 'Pole <strong>hasło</strong> nie może zostać puste.' : '', !$form['db_prefix'] ? 'Pole <strong>prefix tabel<</strong> nie może zostać puste.' : '', !$form['db_type'] ? 'Pole <strong>typ</strong> nie może zostać puste.' : '', !$form['site_url'] ? 'Pole <strong>adres strony</strong> nie może zostać puste.' : '', !$form['local_dir'] ? 'Pole <strong>folder zawierający skrypt</strong> nie może zostać puste.' : '', !is_numeric($form['errors']) ? 'Typ <strong>raportowania błędów</strong> jest nieprawidłowy.' : '', !$form['cookie_name'] ? 'Pole <strong>nazwa ciasteczek</strong> nie może zostać puste.' : '');
    if (!in_array(true, $errors)) {
        $config_file = fopen(root_dir . 'config.php', 'w');
        fwrite($config_file, "<?php\n // KioCMS - Kiofol Content Managment System\n// config.php\n\ndefined('KioCMS') || exit;\n\$constants = array(\n\t'db_host'     => '" . $form['db_host'] . "', // Database host\n\t'db_name'     => '" . $form['db_name'] . "', // Database name\n\t'db_user'     => '" . $form['db_user'] . "', // Database user\n\t'db_pass'     => '" . $form['db_pass'] . "', // Database password\n\t'db_prefix'   => '" . $form['db_prefix'] . "', // Tables prefix\n\t'db_type'     => '" . $form['db_type'] . "', // Type of database\n\t'site_url'    => '" . $form['site_url'] . "', // Website address\n\t'local_dir'   => '" . $form['local_dir'] . "', // Local directory\n\t'cookie_name' => '" . $form['cookie_name'] . "', // Cookie name\n\t'logs'        => " . $form['logs'] . ", // Saving logs\n\t'errors'      => " . $form['errors'] . "); // Errors reporting\narray_map('define', array_keys(\$constants), array_values(\$constants));\n?>");
        $form['lock_config'] && flock($config_file, 2);
        fclose($config_file);
        positive($lang_admin['SAVED_SUCCESSFUL']);
        redirect(local_url . 'admin/system/server');
    } else {
        negative($errors);
    }
} else {
    neutral(array('<strong>Zmiana tych parametrów może sparaliżować całą witrynę!</strong>', 'Poniższe ustawienia są zapisane w pliku config.php', $lang_system['REQUIRED']));
}
// Form
echo '<form action="' . local_url . 'admin/system/server" method="post"><table class="form">
<tr class="top title"><th>&nbsp;</th><td class="title">Baza danych</td></tr>
<tr><th><label for="f_db_host"><span class="required">*</span> Serwer</label></th><td><input type="text" name="db_host" value="' . $form['db_host'] . '" class="big' . ($errors[1] ? ' error' : '') . '" id="f_db_host" /></td></tr>
<tr><th><label for="f_db_name"><span class="required">*</span> Nazwa</label></th><td><input type="text" name="db_name" value="' . $form['db_name'] . '" class="big' . ($errors[2] ? ' error' : '') . '" id="f_db_name" /></td></tr>
<tr><th><label for="f_db_user"><span class="required">*</span> Użytkownik</label></th><td><input type="text" name="db_user" value="' . $form['db_user'] . '" class="big' . ($errors[3] ? ' error' : '') . '" id="f_db_user" /></td></tr>
<tr><th><label for="f_db_pass"><span class="required">*</span> Hasło</label></th><td><input type="text" name="db_pass" value="' . $form['db_pass'] . '" class="big' . ($errors[4] ? ' error' : '') . '" id="f_db_pass" /></td></tr>
<tr><th><label for="f_db_prefix"><span class="required">*</span> Prefix tabel</label></th><td><input type="text" name="db_prefix" value="' . $form['db_prefix'] . '" class="big' . ($errors[5] ? ' error' : '') . '" id="f_db_prefix" /></td></tr>
<tr><th><label for="f_db_type"><span class="required">*</span> Typ</label></th><td><select name="db_type" id="f_db_type"><option value="mysql">MySQL</option></select></td></tr>
Esempio n. 3
0
					' . $form['category'] . ')') ? sql_query($form['category'] ? array('UPDATE ' . db_prefix . 'news_categories SET entries = entries + 1 WHERE id = ' . $form['category'], 'UPDATE ' . db_prefix . 'stats SET value = value + 1 WHERE key = "posted_news"') : 'UPDATE ' . db_prefix . 'stats SET value = value + 1 WHERE key = "posted_news"') . redirect(local_url . 'admin/news') : negative(array($lang_system['ERROR_SQL'], sql_error()));
        } else {
            sql_query('
				UPDATE ' . db_prefix . 'news
				SET
					title = "' . $form['title'] . '",
					author = "' . $form['author'] . '",
					added = ' . (int) mktime($form['added'][3], $form['added'][4], 0, $form['added'][1], $form['added'][0], $form['added'][2]) . ',
					/*type = "' . $form['type'] . '",*/
					description = "' . $form['description'] . '",
					keywords = "' . $form['keywords'] . '",
					content = "' . $form['content'] . '",
					extended_content = "' . $form['extended_content'] . '",
					author_id = ' . $form['author_id'] . ',
					category_id = ' . $form['category'] . '
				WHERE id = ' . $e) ? positive($lang['SUCCESS_MESSAGE_EDIT']) . redirect(local_url . 'admin/news') : negative(array($lang_system['ERROR_SQL'], sql_error()));
        }
    } else {
        negative($errors);
    }
} else {
    neutral($lang_system['REQUIRED']);
}
// Form
echo '<form action="' . local_url . 'admin/news/' . ($edit_mode ? 'edit/' . $e : 'write') . '" method="post" id="form"><table class="form">
<tr class="title"><th>&nbsp;</th><td>' . $lang['MAIN_INFORMATIONS'] . '</td></tr>
<tr class="top"><th><label for="form-title"' . ($errors[0] ? ' class="error"' : '') . '><span class="required">*</span> ' . $lang['TITLE'] . '</label></th><td><input class="text" type="text" name="title" id="form-title" value="' . $form['name'] . '" size="35" /></td></tr>
<tr><th><label for="form-category">' . $lang['CATEGORY'] . '</label></th><td><select name="category" id="form-category"><option value="0">-</option>';
$query = sql_query('SELECT id, name FROM ' . db_prefix . 'news_categories');
while ($category = sql_fetch_array($query)) {
    echo '<option value="' . $category['id'] . '"' . ($form['category'] == $category['id'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
Esempio n. 4
0
					"")') ? sql_query($form['category_id'] ? array('UPDATE ' . DB_PREFIX . 'news_categories SET entries = entries + 1 WHERE id = ' . $form['category_id'], 'UPDATE ' . DB_PREFIX . 'stats SET value = value + 1 WHERE key = "posted_news"') : 'UPDATE ' . DB_PREFIX . 'stats SET value = value + 1 WHERE key = "posted_news"') . redirect(HREF . 'admin/modules/news') : negative($lang_system['SQL_ERROR']);
        } else {
            sql_query('
				UPDATE ' . DB_PREFIX . 'news
				SET
					title = "' . $form['title'] . '",
					author = "' . $form['author'] . '",
					author_id = ' . $form['author_id'] . ',
					added = ' . mktime($form['added'][3], $form['added'][4], 0, $form['added'][1], $form['added'][0], $form['added'][2]) . ',
					publication = "' . $form['publication'] . '",
					description = "' . $form['description'] . '",
					keywords = "' . $form['keywords'] . '",
					content = "' . $form['content'] . '",
					extended_content = "' . $form['extended_content'] . '",
					category_id = ' . $form['category_id'] . '
				WHERE id = ' . $e) ? positive($lang['SUCCESS_MESSAGE_EDIT']) . redirect(HREF . 'admin/modules/news') : negative($lang_system['SQL_ERROR']);
        }
    } else {
        negative($errors);
    }
} else {
    neutral($lang_system['REQUIRED']);
}
$query = sql_query('SELECT id, name FROM ' . DB_PREFIX . 'news_categories');
while ($row = sql_fetch_assoc($query)) {
    $categories[] = $row;
}
$tpl = get_template('modules/news/admin/manage_entry');
$tpl->module = $module;
$tpl->system = $system;
$tpl->form = $form;