stdhead(T_("FAQ_MANAGEMENT"));
    begin_frame();
    print "<h1 align=\"center\">Add Section</h1>";
    print "<form method=\"post\" action=\"faq-actions.php?action=addnewsect\">";
    print "<table border=\"0\" class=\"table_table\" cellspacing=\"0\" cellpadding=\"10\" align=\"center\">\n";
    print "<tr><td class='table_col1'>Title:</td><td class='table_col1'><input style=\"width: 300px;\" type=\"text\" name=\"title\" value=\"\" /></td></tr>\n";
    print "<tr><td class='table_col2'>Status:</td><td class='table_col2'><select name=\"flag\" style=\"width: 110px;\"><option value=\"0\" style=\"color: #ff0000;\">Hidden</option><option value=\"1\" style=\"color: #000000;\" selected=\"selected\">Normal</option></select></td></tr>";
    print "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"edit\" value=\"Add\" style=\"width: 60px;\" /></td></tr>\n";
    print "</table></form>";
    end_frame();
    stdfoot();
} elseif ($_GET[action] == "addnewitem" && $_POST[question] != NULL && $_POST[answer] != NULL && is_valid_int($_POST[flag]) && is_valid_int($_POST[categ])) {
    $question = sqlesc($_POST[question]);
    $answer = sqlesc($_POST[answer]);
    $res = SQL_Query_exec("SELECT MAX(`order`) FROM `faq` WHERE `type`='item' AND `categ`='{$_POST['categ']}'");
    while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) {
        $order = $arr[0] + 1;
    }
    SQL_Query_exec("INSERT INTO `faq` (`type`, `question`, `answer`, `flag`, `categ`, `order`) VALUES ('item', {$question}, {$answer}, '{$_POST['flag']}', '{$_POST['categ']}', '{$order}')");
    header("Refresh: 0; url=faq-manage.php");
} elseif ($_GET[action] == "addnewsect" && $_POST[title] != NULL && is_valid_int($_POST[flag])) {
    $title = sqlesc($_POST[title]);
    $res = SQL_Query_exec("SELECT MAX(`order`) FROM `faq` WHERE `type`='categ'");
    while ($arr = mysql_fetch_array($res, MYSQL_BOTH)) {
        $order = $arr[0] + 1;
    }
    SQL_Query_exec("INSERT INTO `faq` (`type`, `question`, `answer`, `flag`, `categ`, `order`) VALUES ('categ', {$title}, '', '{$_POST['flag']}', '0', '{$order}')");
    header("Refresh: 0; url=faq-manage.php");
} else {
    header("Refresh: 0; url=faq-manage.php");
}
Beispiel #2
0
/**
 * Check for valid decimal/float, requiring only 1 . and integers on either side of it
 *
 * @param float $value
 * @param bool|false $unsigned
 * @return bool
 */
function is_valid_decimal($value = 0.0, $unsigned = false)
{
    if (!is_numeric($value)) {
        return false;
    }
    $parts = explode('.', $value);
    if (count($parts) > 2) {
        return false;
    }
    return is_valid_int($parts[0], $unsigned) && is_valid_int($parts[1], true);
}