newpost.php (1510B)
1 <?php 2 ####################### 3 # flush browser cache # 4 ####################### 5 //header("Cache-Control: no-cache, must-revalidate, no-store"); 6 7 ob_start(); 8 9 ############################### 10 # include files from root dir # 11 ############################### 12 $root_1 = realpath($_SERVER["DOCUMENT_ROOT"]); 13 $currentdir = getcwd(); 14 $root_2 = str_replace($root_1, '', $currentdir); 15 $root_3 = explode("/", $root_2); 16 if ($root_3[1] == 'core') { 17 $root = realpath($_SERVER["DOCUMENT_ROOT"]); 18 }else{ 19 $root = $root_1 . '/' . $root_3[1]; 20 } 21 include($root . '/core/config/variables.config.php'); 22 include($root . '/core/config/connect.db.inc.php'); 23 24 while (ob_get_status()) { 25 if (mysqli_connect_errno()) { 26 printf("Verbindung fehlgeschlagen: %s\n", mysqli_connect_error()); 27 exit(); 28 } 29 if ($resultat = $connection->query('SELECT id FROM posts')) { 30 while($daten = $resultat->fetch_object() ){ 31 $post_id_clean = $daten->id; 32 $ids = $post_id_clean+1; 33 //var_dump($daten); 34 } 35 #$resultat->close(); 36 } 37 38 $author = $_POST["author"]; 39 $author = $_POST['author']; 40 $title = $_POST['title']; 41 $text = $_POST['content']; 42 $category = $_POST['category']; 43 if (!empty($title)){ 44 if ($resultat = $connection->query("INSERT INTO posts (id,text,title,author,date,category) VALUES ('$ids', '$text', '$title', '$author', NOW(), '$category')")) { 45 } 46 $connection->close(); 47 } 48 ob_end_clean(); 49 } 50 header("HTTP/1.1 301 Moved Permanently", true, 301); 51 header( "Location: ../../../../?file=admin.php#newpost2" ); 52 ?>