setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e){ echo( "Error: " . $e->getMessage() ); } } try{ // prepare sql and bind parameters $stmt = $dbConnection->prepare( "INSERT INTO ".$someOptions['tableName']." (datum, betreff, nachricht, autor, promoImg) VALUES (:datum, :betreff, :nachricht, :autor, :promoImg)" ); $stmt->bindParam(':datum', $aNews['datum']); $stmt->bindParam(':betreff', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], $aNews['betreff'])); $stmt->bindParam(':nachricht', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], Parsedown::instance()->text( $aNews['text'] ))); $stmt->bindParam(':autor', iconv($someOptions['newsCharset'], $someOptions['dbCharset'], $aNews['autor'])); $stmt->bindParam(':promoImg', json_encode( $aNews['promoImg'] ) ); // insert a row $stmt->execute(); echo "New records created successfully"; } catch(PDOException $e){ echo( "Error: " . $e->getMessage() ); } return; } $defaultPromoImg['src'] = "http://cwsvjudo.bplaced.net/ressourcen/graphiken/logos/cwsvJudoLogoWappen.x256.png"; $defaultPromoImg['width'] = "207"; $defaultPromoImg['height'] = "256"; /// Auslesen des Newsarrays if( empty($_POST['nachrichtenPromoImg']) ) $newsArticle['promoImg'] = $defaultPromoImg; else{ $newsArticle['promoImg']['src'] = $_POST['nachrichtenPromoImg']['src']; $newsArticle['promoImg']['width'] = $_POST['nachrichtenPromoImg']['width']; $newsArticle['promoImg']['height'] = $_POST['nachrichtenPromoImg']['heigth']; if( !is_positive_integer($newsArticle['promoImg']['width']) || !is_positive_integer($newsArticle['promoImg']['height']) ){ $newsArticle['promoImg']['path'] = $basePath.urldecode(parse_url( $newsArticle['promoImg']['src'] )['path']); if(file_exists( $newsArticle['promoImg']['path'] ) ){ list( $newsArticle['promoImg']['width'], $newsArticle['promoImg']['height'] ) = array_slice( getimagesize( $newsArticle['promoImg']['path'] ), 0, 2); } else{ // @todo: Wirklich nötig? Es könnte ja auch auf einem anderen Server liegen... // $newsArticle['promoImg'] = null; } } } // @todo Validierung! $newsArticle['datum'] = !empty($_POST['nachrichtenDatum']) ? $_POST['nachrichtenDatum'] : strftime ( "%F" ); $newsArticle['betreff'] = !empty($_POST['nachrichtenBetreff']) ? $_POST['nachrichtenBetreff'] : "Kein Betreff!"; $newsArticle['text'] = !empty($_POST['nachrichtenText']) ? $_POST['nachrichtenText'] : "Kein Text!"; $newsArticle['autor'] = !empty($_POST['nachrichtenAutor']) ? $_POST['nachrichtenAutor'] : "Kein Autor!"; if( !empty($_POST['action']) ){ if( $_POST['action'] == "submitToDb" ){ submitNewsToDb( $newsArticle, ['dbConfig' => $cwsvJudoConfig['db']] ); $dbConnection = null; } } ?> Nachrichtenadministration $newsArticle['datum'], 'betreff' => $newsArticle['betreff'], 'promoImg' => $newsArticle['promoImg'], 'nachricht' => Parsedown::instance()->text($newsArticle['text']), 'autor' => $newsArticle['autor'] )));?>

"/> "/> "/>
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $newsList = getNews($dbConnection, array('limit'=>6)); } catch(PDOException $e){ echo "Error: " . $e->getMessage(); } $dbConnection = null; if(!empty($newsList)) foreach( $newsList as $news) echo("
".getHtmlNews($news)); else echo("Keine Nachrichten gefunden!") ?>