if (isset($_GET['aufruf'])) { $aufruf = $_GET['aufruf']; $aufruf = preg_replace('/[^a-zA-Z0-9äÄöÖüÜß., ]/', '', $aufruf); } if (substr($aufruf,0,1) == "c") { $aufruf = substr(strip_tags($aufruf),1,99); require('index.php'); exit(); } if (isset($_GET['todo'])) { $todo = $_GET['todo']; } if (isset($_POST['todo'])) { $todo = $_POST['todo']; } if (isset($_POST['aufruf'])) { $aufruf = $_POST['aufruf']; } if (($todo == "save") && ($aufruf == "new")) { $db_host = "localhost"; $db_user = "mnutzer"; $db_pw = "kIdasdko134"; $db_name = "scheissewaskocheichheute"; try{ $pdo = new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset=utf8', $db_user, $db_pw,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }catch(PDOException $e){ die('Error connecting to database'.$e); } $userid = 10000; $data = [ 'titel' => $_POST['titel'], 'userid' => $userid, 'rezepttext' => $_POST['zutatenliste']."\n[PREPARATION]\n".$_POST['rezepttext'] ]; $sql = "INSERT INTO rezepte (titel, userid, rezepttext) VALUES (:titel, :userid, :rezepttext)"; $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); try{ $stmt= $pdo->prepare($sql); } catch(Exception $e) { echo 'Exception -> '; var_dump($e->getMessage()); } $stmt->execute($data); $newid = $pdo->lastInsertId(); //echo $url."/recipe.php?aufruf=".$newid; header("Location: ".$url."/recipe.php?todo=edit&aufruf=".$newid."-irgendwas"); exit(); } if ($aufruf == "new") { $todo = "edit"; } if (isset($_GET['link'])) { $link = $_GET['link']; } if ($aufruf == "new") { $todo = "edit"; // We're having a new recipe } else { if ($aufruf > 0) { if (strpos($aufruf,"-") > 0) { $aufruf = substr($aufruf,0,strpos($aufruf,"-")); } else { if ($aufruf > 0) { } else { header("Location:http://www.scheissewaskocheichheute.de"); exit(); } } require("/var/www/www.scheissewaskocheichheute.de/inc/config.inc.php"); // $ssql = "SELECT * FROM rezepte WHERE id='".mysql_escape_string($aufruf)."'"; try{ $pdo = new PDO('mysql:host='.$db_host.';dbname='.$db_name.';charset=utf8', $db_user, $db_pw,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'")); }catch(PDOException $e){ die('Error connecting to tags database '.$db_name.' '.$e); } $ssql = "SELECT * FROM rezepte WHERE id=:id"; $stmt = $pdo->prepare($ssql); $stmt->execute(['id' => $aufruf]); // $stmt->debugDumpParams(); $row=$stmt->fetch(PDO::FETCH_OBJ); $set = (array) $row; $thisrezept = $set; $ko = $thisrezept['id']; $thisrezept['count_clicks'] = $thisrezept['count_clicks'] + 1; try { $pdo = new PDO('mysql:host='.$db_host.';dbname='.$db_name, $db_user, $db_pw); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare('UPDATE rezepte SET count_clicks=:count_clicks WHERE id=:id'); $stmt->execute(array( ':count_clicks' => $thisrezept['count_clicks'], ':id' => $ko )); } catch(PDOException $e) { echo 'Error: ' . $e->getMessage(); } } $hostname = @gethostbyaddr($_SERVER[REMOTE_ADDR]); $ip = @gethostbyname($hostname); require("/var/www/www.flewid.net/social/boterkennung.inc.php"); if ($ip == "217.10.65.248") { // $bothere = "google"; } if ($thisrezept['url'] == "") { if (($todo != "edit") && ($todo != "view")) { if ($userdata['facebook_id'] == "") { header("Location: https://scheissewaskocheichheute.de"); } } } $thisrezept = cleanUpRecipe($thisrezept); if ($ip != "37.201.227.195") { if (substr($thisrezept['remoteimage'],0,1) == '/') { $thisrezept['image'] = ""; $thisrezept['remoteimage'] = ""; } } session_start(); if (is_array($_SESSION['userdata'])) { $userdata = $_SESSION['userdata']; } if ($userdata['facebook_id'] == "10155308865556699") { $forward = false; } } ?>