File: D:/HostingSpaces/SBogers10/vangogh.komma-mediadesign.nl/wwwroot/kms/project_wijzigen.php
<?php
include("ckeditor/ckeditor.php");
$project_id = $_GET['project_id'];
$project_id = checkData($project_id);
if(!isset($_POST['verzenden'])){
$q_nieuws = sprintf("SELECT kms_projecten.naam, kms_projecten.categorie, kms_projecten.bouwmaand, kms_projecten.bouwjaar, kms_projecten.architect, kms_projecten.locatie, kms_projecten.omschrijving, kms_projecten.image_dir FROM kms_projecten WHERE project_id='%s'", $project_id);
$r_nieuws = mysql_query($q_nieuws);
$rec_nieuws = mysql_fetch_array($r_nieuws);
$naam = html_entity_decode($rec_nieuws['naam']);
$categorie = html_entity_decode($rec_nieuws['categorie']);
$bouwmaand = html_entity_decode($rec_nieuws['bouwmaand']);
$bouwjaar = html_entity_decode($rec_nieuws['bouwjaar']);
$architect = html_entity_decode($rec_nieuws['architect']);
$locatie = html_entity_decode($rec_nieuws['locatie']);
$omschrijving = html_entity_decode($rec_nieuws['omschrijving']);
$image = $rec_nieuws['image_dir'];
}
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 < 150)){
$valid_naam = true;
$te_lang_naam = false;
}else{
$valid_naam = false;
if($lengte_naam != 0){
$te_lang_naam = true;
}
}
}else{
$valid_naam = false;
}
if(isset($_POST['categorie'])){
$categorie = $_POST['categorie'];
}
if($verzenden && $valid_naam && !empty($_POST['categorie'])){
$naam_test = checkData($_POST['naam']);
$categorie_test = checkData($_POST['categorie']);
$test_url = friendlyURL($naam_test);
$q_cases = sprintf("SELECT kms_projecten.url FROM kms_projecten WHERE kms_projecten.url='%s' AND kms_projecten.categorie = '%s'", $test_url, $categorie_test);
$r_cases = mysql_query($q_cases);
$rec_cases = mysql_fetch_array($r_cases);
$uitkomst = $rec_cases['url'];
if($test_url == $uitkomst){
$bestaat_niet = false;
}else{
$bestaat_niet = true;
}
$q_cases2 = sprintf("SELECT kms_projecten.url FROM kms_projecten WHERE project_id='%s'", $project_id);
$r_cases2= mysql_query($q_cases2);
$rec_cases2 = mysql_fetch_array($r_cases2);
$org_name = $rec_cases2['url'];
if($test_url == $org_name){
$bestaat_niet = true;
}
}
//check if al bestaat
if(isset($_POST['bouwmaand'])){
$bouwmaand = $_POST['bouwmaand'];
}
if(isset($_POST['bouwjaar'])){
$bouwjaar = $_POST['bouwjaar'];
$bouwjaar = trim($bouwjaar);
$lengte_bouwjaar = strlen($bouwjaar);
if($lengte_bouwjaar == 4){
$valid_bouwjaar = true;
}else{
$valid_bouwjaar = false;
}
}else{
$valid_bouwjaar = false;
}
if(isset($_POST['architect'])){
$architect = $_POST['architect'];
$architect = trim($architect);
$lengte_architect = strlen($architect);
if($lengte_architect > 1 && $lengte_architect < 150){
$valid_architect = true;
}else{
$valid_architect = false;
if($lengte_architect != 0){
$te_lang_architect = true;
}
}
}else{
$valid_architect = false;
}
if(isset($_POST['locatie'])){
$locatie = $_POST['locatie'];
$locatie = trim($locatie);
$lengte_locatie = strlen($locatie);
if($lengte_locatie > 0 && $lengte_locatie < 150){
$valid_locatie = true;
}else{
$valid_locatie = false;
if($lengte_locatie != 0){
$te_lang_locatie = true;
}
}
}else{
$valid_locatie = 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 && !empty($categorie) && !empty($bouwmaand) && $valid_bouwjaar && $valid_architect && $valid_locatie && $valid_omschrijving ){
$url = friendlyURL($naam);
$naam = utf8_decode($naam);
$naam = htmlentities($naam);
$naam = checkData($naam);
$categorie = checkData($categorie);
$bouwmaand = checkData($bouwmaand);
$bouwjaar = utf8_decode($bouwjaar);
$bouwjaar = htmlentities($bouwjaar);
$bouwjaar = checkData($bouwjaar);
$kmstand = utf8_decode($kmstand);
$kmstand = htmlentities($kmstand);
$kmstand = checkData($kmstand);
$architect = utf8_decode($architect);
$architect = htmlentities($architect);
$architect = checkData($architect);
$locatie = utf8_decode($locatie);
$locatie = htmlentities($locatie);
$locatie = checkData($locatie);
$omschrijving = checkData($_POST['omschrijving']);
$q_account = sprintf("UPDATE kms_projecten SET naam = '%s', categorie = '%s', bouwmaand = '%s', bouwjaar = '%s', architect = '%s',
locatie = '%s', omschrijving = '%s', url = '%s' WHERE kms_projecten.project_id='%s'",
$naam,
$categorie,
$bouwmaand,
$bouwjaar,
$architect,
$locatie,
$omschrijving,
$url,
$project_id);
$r_account = mysql_query($q_account);
if($r_account){
echo("Project succesvol gewijzigd!<br /><br />");
echo("<a href=\"index.php?p=projectfoto_overzicht&project_id=".$project_id."\" title=\"Foto's beheren\">Foto's van dit project beheren</a>");
echo("<br /><br /><a href=\"index.php?p=project_overzicht\" title=\"Terug naar het overzicht\">Terug naar het overzicht</a>");
}else{
echo("Er is iets fout gegaan.");
}
}else{
?>
<h1>Project wijzigen</h1>
<p>Vul onderstaande gegevens in om het project te wijzigen.</p>
<span class="label">* = verplicht</span><br /><br />
<form action="<?php $_SERVER['PHP_SELF']; ?>" id="aanmelden" name="aanmelden" method="post">
<div>
<label>Naam*</label>
<input name="naam" type="text" value="<?php echo($naam); ?>" />
<?php if(!$valid_naam && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?>
<?php if(!$valid_naam && $verzenden && $te_lang_naam){ echo("<span class=\"error\"><br />(invoer te lang)</span>"); }?>
<?php if($valid_naam && $verzenden && !$bestaat_niet){ echo("<span class=\"error\"><br />(de naam bestaat al)</span>"); }?><br />
<label>Categorie:*</label>
<select name="categorie" >
<option></option>
<option value="onderhanden_werk" <?php if ($categorie == "onderhanden_werk") { echo("selected=\"selected\"");} ?>>Onderhanden werk</option>
<option value="utiliteitsbouw" <?php if ($categorie == "utiliteitsbouw") { echo("selected=\"selected\"");} ?>>Utiliteitsbouw</option>
<option value="woningbouw" <?php if ($categorie == "woningbouw") { echo("selected=\"selected\"");} ?>>Woningbouw</option>
<option value="verbouw_en_aanbouw" <?php if ($categorie == "verbouw_en_aanbouw") { echo("selected=\"selected\"");} ?>>Verbouw & aanbouw</option>
</select>
<?php if(empty($categorie) && $verzenden){ echo("<span class=\"error\"> (selecteer een categorie)</span>"); }?>
<br /><br />
<label>Bouwmaand*</label>
<select name="bouwmaand" >
<option></option>
<option value="jan" <?php if ($bouwmaand == "jan") { echo("selected=\"selected\"");} ?>>Jan</option>
<option value="feb" <?php if ($bouwmaand == "feb") { echo("selected=\"selected\"");} ?>>Feb</option>
<option value="mrt" <?php if ($bouwmaand == "mrt") { echo("selected=\"selected\"");} ?>>Mrt</option>
<option value="apr" <?php if ($bouwmaand == "apr") { echo("selected=\"selected\"");} ?>>Apr</option>
<option value="mei" <?php if ($bouwmaand == "mei") { echo("selected=\"selected\"");} ?>>Mei</option>
<option value="juni" <?php if ($bouwmaand == "juni") { echo("selected=\"selected\"");} ?>>Juni</option>
<option value="juli" <?php if ($bouwmaand == "juli") { echo("selected=\"selected\"");} ?>>Juli</option>
<option value="aug" <?php if ($bouwmaand == "aug") { echo("selected=\"selected\"");} ?>>Aug</option>
<option value="sept" <?php if ($bouwmaand == "sept") { echo("selected=\"selected\"");} ?>>Sept</option>
<option value="okt" <?php if ($bouwmaand == "okt") { echo("selected=\"selected\"");} ?>>Okt</option>
<option value="nov" <?php if ($bouwmaand == "nov") { echo("selected=\"selected\"");} ?>>Nov</option>
<option value="dec" <?php if ($bouwmaand == "dec") { echo("selected=\"selected\"");} ?>>Dec</option>
</select>
<?php if(empty($bouwmaand) && $verzenden){ echo("<span class=\"error\"> (selecteer een bouwmaand)</span>"); }?>
<br /><br />
<label>Bouwjaar*</label>
<input name="bouwjaar" type="text" value="<?php echo($bouwjaar); ?>" />
<?php if(!$valid_bouwjaar && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?><br />
<label>Architect*</label>
<input name="architect" type="text" value="<?php echo($architect); ?>" />
<?php if(!$valid_architect && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?>
<?php if(!$valid_architect && $verzenden && $te_lang_architect){ echo("<span class=\"error\"><br />(invoer te lang)</span>"); }?><br />
<label>Locatie*</label>
<input name="locatie" type="text" value="<?php echo($locatie); ?>" />
<?php if(!$valid_locatie && $verzenden){ echo("<span class=\"error\"> (foutieve invoer)</span>"); }?>
<?php if(!$valid_locatie && $verzenden && $te_lang_locatie){ echo("<span class=\"error\"><br />(invoer te lang)</span>"); }?><br />
<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 />
<input name="verzenden" type="submit" value="Wijzigen" class="submit" />
<a class="submit_annuleren" href="index.php?p=project_overzicht" title="Annuleren">Annuleren</a>
</div>
</form>
<?php
}
?>