Exemplo 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);
}
Exemplo n.º 2
0
// 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>
<tr class="title"><th>&nbsp;</th><td class="title">Pozostałe</td></tr>
<tr><th><label for="f_site_url"><span class="required">*</span> Adres strony</label></th><td><input type="text" name="site_url" value="' . $form['site_url'] . '" class="big" id="f_site_url" /></td></tr>
Exemplo n.º 3
0
<?php

// KioCMS - Kiofol Content Managment System
// admin/comments/settings.php
defined('KioCMS') || (include_once '../ajax.php');
$total = sql_fetch_array(sql_query('SELECT COUNT(`id`) AS `comments` FROM `' . db_prefix . 'comments`'));
$total_pages = ceil($total['comments'] / 30);
$p = ctype_digit(u3) ? u3 : '';
$p = $p && $p <= $total_pages && $total['comments'] > 0 && $p > 1 ? $p : 1;
if (is_numeric($_POST['delete_id'])) {
    sql_query('DELETE FROM `' . db_prefix . 'comments` WHERE `id` = ' . (int) $_POST['delete_id']) ? redirect(strpos($_SERVER['HTTP_REFERER'], 'admin') ? $_SERVER['HTTP_REFERER'] : '#comments') : negative(array($lang_system['ERROR_SQL'], sql_error()));
}
if ($total['comments']) {
    $query = sql_query('
		SELECT u.`username` ' . ($cfg->system['styled_usernames'] ? ', u.`style` AS `u_style`, g.`name` AS `g_name`, g.`style` AS `g_style`' : '') . ', c.`id`, c.`for`, c.`for_id`, c.`backlink`, c.`time`, c.`author`, c.`author_id`, c.`author_ip`, c.`content`
		FROM `' . db_prefix . 'comments` AS `c`
		LEFT JOIN `' . db_prefix . 'users` AS `u` ON u.`id` = c.`author_id`
		' . ($cfg->system['styled_usernames'] ? 'LEFT JOIN `' . db_prefix . 'users_groups` AS `g` ON g.`id` = u.`group_id`' : '') . '
		ORDER BY c.`id` DESC
		LIMIT 30
		OFFSET ' . ($p - 1) * 30);
    $pagination = pagination($total_pages, $p, local_url . 'admin/comments/entries');
    echo '<fieldset class="sort">awdawdawdaw<br /></fieldset>
<form method="post" id="check_all" action=""><table class="list"><thead>
<tr><td class="pagination" colspan="5">' . $pagination . '<p class="total">Wszystkich komentarzy: <strong>' . $total['comments'] . '</strong></p></td></tr>
<tr><th class="first"><input type="checkbox" /></th><th class="second left">Autor</th><th class="third">Dodany</th><th class="sixth left">Treść / Lokacja</th><th class="last">Opcje</th></tr></thead><tfoot><tr><td class="pagination" colspan="5">' . $pagination . '<p class="total">Wszystkich komentarzy: <strong>' . $total['comments'] . '</strong></p></td></tr></tfoot><tbody>';
    while ($db = sql_fetch_array($query)) {
        echo "\n" . '<tr id="comment-' . $db['id'] . '"><td class="first"><input type="checkbox" name="entry" value="' . $db['id'] . '" /></td><td class="second left">' . user($db['author_id'], $db['username'] ? $db['username'] : $db['author'], $db['u_style'], $db['g_name'], $db['g_style']) . '<div class="note">' . $db['author_ip'] . '</div></td><td class="third">' . timer($cfg->system['date_format'], $db['time']) . '</td><td class="sixth left">' . $db['content'] . '<div class="note"><a href="' . local_url . $db['backlink'] . '#comments" class="block">' . $db['backlink'] . '</a></div></td><td class="last"><a href="' . local_url . $db['backlink'] . '/edit_comment/' . $db['id'] . '#form" class="edit">E</a> | <a  href="#delete-comment-' . $db['id'] . '" class="delete" accesskey="' . $db['id'] . '">U</a></td></tr>';
    }
    echo '</tbody></table></form>';
} else {
Exemplo n.º 4
0
function comments2($connector_id, $holder_sql, $total_comments, $backlink)
{
    global $system, $lang_system, $m, $user;
    if (is_file(ROOT . 'plugins/comments/index.php')) {
        $lang_comments = get_lang('plugins/comments/main');
        $comments = get_config('comments');
        if ($total_comments != -1 && !$comments['see_only_logged']) {
            ob_start();
            include_once ROOT . 'plugins/comments/index.php';
            $comments = ob_get_contents();
            ob_end_clean();
            return $comments;
        } elseif ($total_comments != -1) {
            return '<br />' . negative(array('Komentarze są widoczne tylko dla zalogowanych osób.', '<a href="' . HREF . 'registration">Zarejestruj się</a> jeśli nie masz jeszcze konta.'));
        }
    }
}
Exemplo n.º 5
0
    echo colorYellow($d, $imageHash);
}
if ($filterId == 11) {
    echo contrastH($d, $imageHash);
}
if ($filterId == 12) {
    echo contrastL($d, $imageHash);
}
if ($filterId == 13) {
    echo edgeD($d, $imageHash);
}
if ($filterId == 14) {
    echo gBlur($d, $imageHash);
}
if ($filterId == 15) {
    echo negative($d, $imageHash);
}
if ($filterId == 16) {
    echo sBlur($d, $imageHash);
}
if ($filterId == 17) {
    echo sepiaThree($d, $imageHash);
}
if ($filterId == 18) {
    echo sepiaTwo($d, $imageHash);
}
if ($filterId == 19) {
    echo sepia($d, $imageHash);
}
function grayScale($imgs, $imageHashs)
{
Exemplo n.º 6
0
<?php

// KioCMS - Kiofol Content Managment System
// admin/comments/settings.php
defined('KioCMS') || (include_once '../ajax.php');
$save = $_POST['save'] ? true : false;
$form = $save ? $_POST['form'] : $module;
$form['bbcode'] = $save ? $_POST['bbcode'] : $module['bbcode'] ? 1 : 0;
$form['see_only_logged'] = $save ? $_POST['see_only_logged'] : $module['see_only_logged'] ? 1 : 0;
$form['add_only_logged'] = $save ? $_POST['add_only_logged'] : $module['add_only_logged'] ? 1 : 0;
if ($save) {
    $errors[] = !$form['content_max'] ? 'Pole <strong>limit znaków wpisu</strong> nie może zostać puste.' : '';
    $errors[] = !$form['order_by'] ? 'Należy określić <strong>sortowanie wpisów</strong>.' : '';
    !in_array(true, $errors) ? save_config($module, 'comments', local_url . 'admin/comments/settings', false) : negative($errors);
} else {
    neutral(array('Poniższa konfiguracja dotyczy wyłącznie komentarzy.', $lang_system['REQUIRED']));
}
// Form
echo '<form action="' . local_url . 'admin/comments/settings" method="post"><table class="form">
<tr class="top title"><th>&nbsp;</th><td>Personalizacja</td></tr>
<tr><th><label for="f_content_max"><span class="required">*</span>Limit znaków wpisu</label></th><td><input type="text" name="form[content_max]" id="f_content_max" value="' . $form['content_max'] . '" class="auto" size="3" /></td></tr>
<tr><th><label for="f_order_by"><span class="required">*</span>Sortowanie wpisów</label></th><td><select name="form[order_by]" id="f_order_by"><option value="ASC"' . ($form['order_by'] == 'ASC' ? ' selected="selected"' : '') . '>Rosnąco</option><option value="DESC"' . ($form['order_by'] == 'DESC' ? ' selected="selected"' : '') . '>Malejąco</option></select></td></tr>
<tr><th rowspan="3"><label>Opcje</label></th><td><label><input name="see_only_logged" type="checkbox" ' . ($form['see_only_logged'] ? ' checked="checked"' : '') . '/> Komentarze widoczne tylko po zalogowaniu</label><div class="description">Właczenie tej opcji automatycznie zablokuje dodawanie komentarzy przez gości</div></td></tr>
<tr><td><label><input name="add_only_logged" type="checkbox" ' . ($form['add_only_logged'] ? ' checked="checked"' : '') . '/> Komentowanie tylko po zalogowaniu</label></td></tr>
<tr><td><label><input name="bbcode" type="checkbox" ' . ($form['bbcode'] ? ' checked="checked"' : '') . '/> BBCode</label><div class="description">Formatuje tekst (np. [b]pogrubienie[/b[)<br />Zaznaczenie nie odniesie skutku jeśli BBCode zostanie wyłączony w konfiguracji systemowej</div></td></tr>';
form_end(false);
Exemplo n.º 7
0
Arquivo: hw3.php Projeto: AlenaIv/hw3
<?php

$array = [];
for ($i = 0; $i < 20; $i++) {
    $array[$i] = rand(0, 100) - 50;
}
var_dump($array);
echo '<br>';
echo negative($array);
echo '<br>';
echo product($array, 2, 6);
echo '<br>';
echo prod_2($array, -7, 38);
echo '<br>';
echo prod_min($array);
function negative($a)
{
    $neg = 0;
    foreach ($a as $e) {
        if ($e < 0) {
            $neg++;
        }
    }
    return $neg;
}
function product($a, $b, $d)
{
    /*функция, которая умножает элементы с номером от b до d */
    $prod = 1;
    if ($b > $d) {
        $tmp = $b;
Exemplo n.º 8
0
<?php

// KioCMS - Kiofol Content Managment System
// admin/news/settings.php
defined('KioCMS') || (include_once '../ajax.php');
$save = $_POST['save'] ? true : false;
$form = $save ? $_POST['form'] : $module;
$form['bbcode'] = $save ? $_POST['bbcode'] : $module['bbcode'] ? 1 : 0;
$form['allow_signatures'] = $save ? $_POST['allow_signatures'] : $module['allow_signatures'] ? 1 : 0;
$form['blocks'] = $save ? $_POST['blocks'] : ($module['blocks'] ? explode(', ', $module['blocks']) : '');
if ($save) {
    $errors[] = !$form['entries_per_page'] ? 'Pole <strong>wpisów na stronę</strong> nie może zostać puste.' : '';
    $errors[] = !$form['order_by'] ? 'Należy określić <strong>sortowanie wpisów</strong>.' : '';
    !in_array(true, $errors) ? save_config($module, 'news', local_url . 'admin/news/settings') : negative($errors);
} else {
    neutral(array($lang_admin['MODULE_SETTINGS'], $lang_system['REQUIRED']));
}
// Form
form_begin(local_url . 'admin/news/settings');
echo '<tr><th><label for="f_message_max">Limit znaków krótkiej treści</label></th><td><input type="text" name="form[message_max]" id="f_message_max" value="' . $form['message_max'] . '" class="auto" size="3" /></td></tr>
<tr><th><label for="f_entries_per_page"><span class="required">*</span>Wpisów na stronę</label></th><td><input type="text" name="form[entries_per_page]" id="f_entries_per_page" value="' . $form['entries_per_page'] . '" class="auto" size="2" /></td></tr>
<tr><th><label for="f_order_by"><span class="required">*</span>Sortowanie wpisów</label></th><td><select name="form[order_by]" id="f_order_by"><option value="ASC"' . ($form['order_by'] == 'ASC' ? ' selected="selected"' : '') . '>Rosnąco</option><option value="DESC"' . ($form['order_by'] == 'DESC' ? ' selected="selected"' : '') . '>Malejąco</option></select></td></tr>

<tr><th rowspan="2"><label>Opcje</label></th><td><label><input name="bbcode" type="checkbox" ' . ($form['bbcode'] ? ' checked="checked"' : '') . '/> BBCode</label><div class="description">Formatuje tekst (np. [b]pogrubienie[/b])<br />Zaznaczenie nie odniesie skutku jeśli BBCode zostanie wyłączony w konfiguracji systemowej</div></td></tr>
<tr><td><label><input name="allow_signatures" type="checkbox" ' . ($form['allow_signatures'] ? ' checked="checked"' : '') . '/> Pokaż podpis użytkownika pod wpisem</label></td></tr>';
form_end();