Exemplo n.º 1
0
function detect_category_name($name)
{
    global $db;
    $sql = "Select cat_categoryName from categories where cat_categoryName = '{$name}'";
    $stmt = $db->prepare($sql);
    $stmt->execute();
    if ($data = $stmt->fetch()) {
        echo "The Category Name you entered is already in the database, please try another name.";
    } else {
        add_categories($name);
    }
}
Exemplo n.º 2
0
/**
 * Update Posted Log
 */
function update_log_form($mode)
{
    global $cfg, $lang, $row, $text_cols, $log_table;
    $row['id'] = htmlspecialchars($row['id']);
    $row['name'] = htmlspecialchars($row['name']);
    $row['href'] = htmlspecialchars($row['href']);
    $row['category'] = htmlspecialchars($row['category']);
    $row['comment'] = htmlspecialchars($row['comment']);
    $row['mod'] = htmlspecialchars($row['mod']);
    $row['ping_uri'] = htmlspecialchars($row['ping_uri']);
    if ($cfg['xml_lang'] == 'ja') {
        $input_check = 'inputCheck()';
        $confirm_delete = 'confirmDelete()';
    } else {
        $input_check = 'inputCheck_e()';
        $confirm_delete = 'confirmDelete_e()';
    }
    if ($cfg['trackback'] == 'on') {
        if ($row['ping_uri'] == '') {
            $ping_uri = 'http://';
        } else {
            $ping_uri = $row['ping_uri'];
        }
        $trackback_ping_form = <<<EOD
<p id="trackback-form">
<label for="send-ping-uri">{$lang['tb_sendurl']}:</label><br />
<input type="text" id="send-ping-uri" name="send_ping_uri" size="40" accesskey="z" tabindex="1" value="{$ping_uri}" class="bordered" />
<select name="encode" tabindex="1">
<option value="UTF-8" selected="selected">UTF-8</option>
<option value="EUC-JP">EUC-JP</option>
<option value="SJIS">Shift_JIS</option>
</select>
</p>
<p>
{$lang['send_update_ping']} : 
<input type="radio" tabindex="1" name="send_update_ping" value="no" checked="checked" />No
<input type="radio" tabindex="1" name="send_update_ping" value="yes" />Yes
</p>
EOD;
    } else {
        $trackback_ping_form = '';
    }
    if ($mode == 'draft') {
        $date = htmlspecialchars($row['date']);
        $dform = <<<EOD
<label for="date-and-time">{$lang['date_and_time']} :</label><br />
<input type="text" id="date-and-time" name="date" tabindex="1" value="{$date}" size="20" class="bordered" />
<input type="checkbox" id="custom-date" name="custom_date" tabindex="1" /><label for="custom-date">{$lang['use_custom_date']}</label><br />
EOD;
        $target = 'draft_updated';
        $draft_status = $lang['draft'];
        $no_change_mod_time = '';
        $make_private = '';
        $update_submit_title = $lang['draft_update'];
        $delete_submit_title = $lang['draft_destroy'];
    } else {
        $date = '';
        $dform = '';
        $target = 'updated';
        $draft_status = '';
        $no_change_mod_time = '<input type="checkbox" name="no_update_mod" tabindex="1" value="yes" checked="checked" /> ' . $lang['no_update_timestamp'];
        $make_private = '<p><input type="checkbox" name="private" tabindex="1" value="1" /> ' . $lang['make_private'] . '</p>';
        $update_submit_title = $lang['update'];
        $delete_submit_title = $lang['delete'];
    }
    // Set variables
    $id = $row['id'];
    $name = $row['name'];
    $href = $row['href'];
    $comment = $row['comment'];
    $mod = $row['mod'];
    $categories = add_categories();
    $tag_buttons = display_tag_buttons();
    $upload_file_form = display_upload_file_form();
    $hint = hint();
    $contents = <<<EOD
<div class="section">
<h2>{$draft_status} {$lang['update']} : {$lang['log']}ID {$id}</h2>
<div class="section">
<form id="addform" action="./{$target}.php" method="post" enctype="multipart/form-data">
<p>
{$dform}
<label for="article-title">{$lang['title']} :</label><br />
<input type="text" name="name" id="article-title" tabindex="1" value="{$name}" size="40" class="bordered" /><br />
<label for="article-title-uri">URI{$hint['href']} : </label><br />
<input type="text" name="href" id="article-title-uri" tabindex="1" value="{$href}" size="40" class="bordered" /><br />
</p>
{$categories}
<p>
<label for="comment">{$lang['comment']}{$hint['comment']} : </label><br />
{$tag_buttons}
<br />
<textarea id="comment" name="comment" tabindex="1" rows="20" cols="{$text_cols}" >{$comment}</textarea><br />
</p>
{$upload_file_form}
<p>
{$no_change_mod_time}
<input type="hidden" name="mod" value="{$mod}" />
</p>
{$make_private}{$trackback_ping_form}
<div class="submit-button">
<input type="hidden" name="id" value="{$id}" />
<input class="backbutton" tabindex="1" accesskey="u" type="submit" value="{$update_submit_title}" />
</div>
</form>
<form id="del" action="./delete.php" method="post" onsubmit="return {$confirm_delete}">
<div class="submit-button">
<input type="hidden" name="id" value="{$id}" />
<input tabindex="2" accesskey="d" type="submit" value="{$delete_submit_title}" />
</div>
</form>

</div><!-- End .section -->
</div><!-- End .section -->
EOD;
    return $contents;
}
Exemplo n.º 3
0
                $code = filter_input(INPUT_POST, 'code');
                $name = filter_input(INPUT_POST, 'name');
                $price = filter_input(INPUT_POST, 'price');
                if ($category_id == NULL || $category_id == FALSE || $code == NULL || $name == NULL || $price == NULL || $price == FALSE) {
                    $error = "Invalid product data. Check all fields and try again.";
                    include '../errors/error.php';
                } else {
                    add_product($category_id, $code, $name, $price);
                    header("Location: .?category_id={$category_id}");
                }
            } else {
                if ($action == 'list_categories') {
                    list_categories();
                } else {
                    if ($action == 'add_categories') {
                        add_categories();
                    } else {
                        if ($action == 'delete_categories') {
                            delete_categories();
                        } else {
                            if ($action == 'edit_products') {
                                edit_products();
                            }
                        }
                    }
                }
            }
        }
    }
}
function list_categories()