File: D:/HostingSpaces/SBogers10/molen.komma.pro/wwwroot/kms/categorie_toevoegen.php
<?php
include("ckeditor/ckeditor.php");
if(isset($_POST['verzenden'])){
$verzenden = true;
}
if(isset($_POST['naam'])){
$naam = $_POST['naam'];
$naam = trim($naam);
$lengte_naam = strlen($naam);
if(($lengte_naam > 1) && ($lengte_naam < 100)){
$valid_naam = true;
$te_lang_naam = false;
}else{
$valid_naam = false;
if($lengte_naam != 0){
$te_lang_naam = true;
}
}
}else{
$valid_naam = false;
}
if($verzenden && $valid_naam){
$test_url = friendlyURL($naam);
$q_cases = sprintf("SELECT kms_categories.url FROM kms_categories WHERE url='%s'", $test_url);
$r_cases = mysql_query($q_cases);
$rec_cases = mysql_fetch_assoc($r_cases);
$uitkomst = $rec_cases['url'];
if($test_url == $uitkomst){
$bestaat_niet = false;
}else{
$bestaat_niet = true;
}
}
//check if al bestaat
if(isset($_POST['introductie'])){
$introductie = $_POST['introductie'];
$introductie = trim($introductie);
$lengte_introductie = strlen($introductie);
if(($lengte_introductie > 1)){
$valid_introductie = true;
}else{
$valid_introductie = false;
}
}else{
$valid_introductie = false;
}
if(isset($_POST['omschrijving'])){
$omschrijving = $_POST['omschrijving'];
$omschrijving = trim($omschrijving);
$lengte_omschrijving = strlen($omschrijving);
if(($lengte_omschrijving > 1)){
$valid_omschrijving = true;
}else{
$valid_omschrijving = false;
}
}else{
$valid_omschrijving = false;
}
if($verzenden && $valid_naam && $bestaat_niet && $valid_introductie && $valid_omschrijving){
$url = friendlyURL($naam);
$naam = utf8_decode($naam);
$naam = htmlentities($naam);
$naam = checkData( $naam ) ;
$introductie = checkData($_POST['introductie']);
$omschrijving = checkData($_POST['omschrijving']);
$q_cases = sprintf("INSERT INTO kms_categories (categorie_name, introduction, description, url) VALUES ('%s','%s','%s','%s')", $naam, $introductie, $omschrijving, $url);
$r_cases = mysql_query($q_cases);
if($r_cases){
echo("Categorie succesvol toegevoegd!<br /><br />");
echo("<a href=\"index.php?p=categorie_overzicht\" title=\"Terug naar het overzicht\">Terug naar het overzicht</a>");
}else{
echo("Er is iets fout gegaan.");
}
}else{
?>
<h1>Categorie toevoegen</h1>
<p>Vul onderstaande gegevens in om een categorie toe te voegen.</p>
<span class="label">* = verplicht</span><br /><br />
<form action="<?php $_SERVER['PHP_SELF']; ?>" id="aanmelden" name="aanmelden" method="post">
<div>
<label>Categorie naam*</label>
<input name="naam" type="text" value="<?php echo(htmlspecialchars($naam)); ?>" />
<?php if(!$valid_naam && $verzenden){ print("<span class=\"error\"> (foutieve invoer)</span>"); }?>
<?php if(!$valid_naam && $verzenden && $te_lang_naam){ print("<span class=\"error\"><br />(invoer te lang)</span>"); }?>
<?php if($valid_naam && $verzenden && !$bestaat_niet){ print("<span class=\"error\"><br />(de categorie bestaat al)</span>"); }?><br />
<br />
<label>Introductie* <?php if(!$valid_introductie && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?></label><br /><br />
<?php
// Create class instance.
$CKEditor_intro = new CKEditor();
// Do not print the code directly to the browser, return it instead
$CKEditor_intro->returnOutput = true;
// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
// $CKEditor->basePath = '/ckeditor/'
// If not set, CKEditor will try to detect the correct path.
$CKEditor_intro->basePath = 'ckeditor/';
// Set global configuration (will be used by all instances of CKEditor).
$CKEditor_intro->config['width'] = 400;
$CKEditor_intro->config['toolbar'] = 'Basic';
// Change default textarea attributes
$CKEditor_intro->textareaAttributes = array("cols" => 80, "rows" => 10);
// The initial value to be displayed in the editor.
$initialValue_intro = $introductie;
// Create first instance.
$code_intro = $CKEditor_intro->editor("introductie", $initialValue_intro);
echo $code_intro;
?>
<br />
<p style="width:560px;"><em><strong>Opmerkingen:</strong> Door in de editor op "enter" te drukken wordt een nieuwe paragraaf gestart.
Wanneer u een "normale enter" wilt zetten kan dit via de combinatie "shift" + "enter".</em></p>
<br />
<label>Omschrijving* <?php if(!$valid_omschrijving && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?></label><br /><br />
<?php
// Create class instance.
$CKEditor = new CKEditor();
// Do not print the code directly to the browser, return it instead
$CKEditor->returnOutput = true;
// Path to CKEditor directory, ideally instead of relative dir, use an absolute path:
// $CKEditor->basePath = '/ckeditor/'
// If not set, CKEditor will try to detect the correct path.
$CKEditor->basePath = 'ckeditor/';
// Set global configuration (will be used by all instances of CKEditor).
$CKEditor->config['width'] = 600;
$CKEditor->config['toolbar'] = 'Basic';
// Change default textarea attributes
$CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10);
// The initial value to be displayed in the editor.
$initialValue = $omschrijving;
// Create first instance.
$code = $CKEditor->editor("omschrijving", $initialValue);
echo $code;
?>
<br />
<p style="width:560px;"><em><strong>Opmerkingen:</strong> Door in de editor op "enter" te drukken wordt een nieuwe paragraaf gestart.
Wanneer u een "normale enter" wilt zetten kan dit via de combinatie "shift" + "enter".</em></p>
<br />
<br /><br />
<input name="verzenden" type="submit" value="Toevoegen" class="submit" />
<a class="submit_annuleren" href="index.php?p=categorie_overzicht" title="Annuleren">Annuleren</a>
</div>
</form>
<?php
}
?>