File: D:/HostingSpaces/SBogers10/vangogh.komma-mediadesign.nl/wwwroot/kms/lgoboek_wijzigen.php
<?php
include("ckeditor/ckeditor.php");
$ontwikkeling_id = $_GET['ontwikkeling_id'];
$ontwikkeling_id = checkData($ontwikkeling_id);
if(!isset($_POST['verzenden'])){
$q_nieuws = sprintf("SELECT kms_projectontwikkeling.naam, kms_projectontwikkeling.introductie, kms_projectontwikkeling.omschrijving, kms_projectontwikkeling.image_dir FROM kms_projectontwikkeling WHERE ontwikkeling_id='%s'", $ontwikkeling_id);
$r_nieuws = mysql_query($q_nieuws);
$rec_nieuws = mysql_fetch_array($r_nieuws);
$naam = html_entity_decode($rec_nieuws['naam']);
$introductie = html_entity_decode($rec_nieuws['introductie']);
$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($verzenden && $valid_naam){
$naam_test = checkData($_POST['naam']);
$test_url = friendlyURL($naam_test);
$q_cases = sprintf("SELECT kms_projectontwikkeling.url FROM kms_projectontwikkeling WHERE kms_projectontwikkeling.url='%s'", $test_url);
$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_projectontwikkeling.url FROM kms_projectontwikkeling WHERE ontwikkeling_id='%s'", $ontwikkeling_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['introductie'])){
$introductie = $_POST['introductie'];
$introductie = trim($introductie);
$introductie = strlen($introductie);
if(($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($_FILES['image_file']['tmp_name']){
$valid_file = true;
$extensions = array("image/jpg", "image/jpeg", "image/pjpeg");
if(in_array($_FILES['image_file']['type'], $extensions)) {
$valid_type = true;
}else{
$valid_type = false;
}
}else{
$valid_file = true;
$valid_type = true;
}
if($verzenden && $valid_naam && $bestaat_niet && $valid_introductie && $valid_omschrijving && $valid_type && !$file_tegroot){
if($_FILES['image_file']['tmp_name']){
$root = $_SERVER['DOCUMENT_ROOT']."/";
if($valid_file && $_FILES['image_file']['tmp_name']){
$dirname = $image;
$extensions = array("image/jpg", "image/jpeg", "image/pjpeg");
if(in_array($_FILES['image_file']['type'], $extensions))
{
if($_FILES['image_file']['type'] == "image/jpg"){
$ext = ".jpg";
}else if($_FILES['image_file']['type'] == "image/jpeg"){
$ext = ".jpg";
}else if($_FILES['image_file']['type'] == "image/pjpeg"){
$ext = ".jpg";
}
$picture = $_FILES['image_file']['tmp_name'];
list($width, $height) = getimagesize($picture);
unlink($root . '/ontwikkeling_images/'. $image.'/ontwikkeling_foto.jpg');
$objResize = new RVJ_ImageResize($_FILES['image_file']['tmp_name'], $root . '/ontwikkeling_images/'. $dirname . '/ontwikkeling_foto.jpg', 'W', '250');
}
}
}
$url = friendlyURL($naam);
$naam = utf8_decode($naam);
$naam = htmlentities($naam);
$naam = checkData($naam);
$introductie = checkData($_POST['introductie']);
$omschrijving = checkData($_POST['omschrijving']);
$q_account = sprintf("UPDATE kms_projectontwikkeling SET naam = '%s', introductie = '%s', omschrijving = '%s', url = '%s' WHERE kms_projectontwikkeling.ontwikkeling_id='%s'",
$naam,
$introductie,
$omschrijving,
$url,
$ontwikkeling_id);
$r_account = mysql_query($q_account);
if($r_account){
echo("Projectontwikkeling succesvol gewijzigd!<br /><br />");
echo("<br /><br /><a href=\"index.php?p=ontwikkeling_overzicht\" title=\"Terug naar het overzicht\">Terug naar het overzicht</a>");
}else{
echo("Er is iets fout gegaan.");
}
}else{
?>
<h1>Projectontwikkeling wijzigen</h1>
<p>Vul onderstaande gegevens in om deze projectontwikkeling te wijzigen.</p>
<span class="label">* = verplicht</span><br /><br />
<form enctype="multipart/form-data" 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>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 />
<label>Foto wijzigen <br />(.jpg)</label>
<input class="file_input" type="file" name="image_file" />
<br />
<?php if(!$valid_type && !$valid_file && $verzenden && !$file_tegroot){ print("<span class=\"error\"><br />(Selecteer een afbeelding)</span>"); }?>
<?php if(!$valid_type && $valid_file && $verzenden && !$file_tegroot){ print("<span class=\"error\"><br />(Alleen jpg bestanden)</span>"); }?>
<?php if($file_tegroot && $verzenden){ print("<span class=\"error\"><br />(Uw bestand is te groot. Max 1 MB)</span>"); }?><br />
<br /><br />
<input name="verzenden" type="submit" value="Wijzigen" class="submit" />
<a class="submit_annuleren" href="index.php?p=ontwikkeling_overzicht" title="Annuleren">Annuleren</a>
</div>
</form>
<?php
}
?>