function getDispInfo($mid, $uid) { $userInfo = $this->where("uid={$uid}")->find(); $no = array("id", "uid"); foreach ($userInfo as $k => $v) { if (!in_array($k, $no)) { if (getPrivacy($v, $mid, $uid)) { $k = getFieldName($k); $userInfo_out[$k] = getValue($v); } } } return $userInfo_out; }
function getDispInfo($mid, $uid) { $userInfo_o = $this->find($uid); $no = array("id", "email", "passwd", "handle", "baseinfoprivacy", "admin_level", "active", "current_city", "current_area", "company", "school", "name"); foreach ($userInfo_o as $k => $v) { if (!in_array($k, $no)) { if ($v && $v != "null") { if ($k == "current_province") { $province_arr = explode("-", $v); $privacy = getPrivNum($province_arr); $v = $province_arr[0] . " " . $userInfo_o["current_city"] . " " . $userInfo_o["current_area"] . $privacy; $k = "current"; } if ($k == "sex") { $sex_arr = explode("-", $v); $privacy = getPrivnum($sex_arr); $v = $sex_arr[0] == "1" ? "男" : "女"; $v .= $privacy; } if ($k == "status") { $status_arr = explode("-", $v); $privacy = getPrivNum($status_arr); switch ($status_arr[0]) { case "0": $v = "其他" . $privacy; break; case "1": $v = $userInfo_o["school"] . $privacy; $k = "school"; break; case "2": $v = $userInfo_o["company"] . $privacy; $k = "company"; break; } } $userInfo[$k] = $v; } } } foreach ($userInfo as $k => $v) { if (getPrivacy($v, $mid, $uid)) { $k = getFieldName($k); $userInfo_out[$k] = getValue($v); } } return $userInfo_out; }
//$config['theme'] = "skyblue"; if (!file_exists(getcwd() . '/themes/' . $config['theme'])) { $config['theme'] = 'default'; if (!file_exists(getcwd() . '/themes/' . $config['theme'])) { die('Error in the themes directory'); } } //echo getcwd().'/themes/'.$config['theme'].'<br>'; readAuthors(); $morepriv = " status = 1 and "; //echo "More Priv = ".$morepriv."<br>"; if ($_SESSION['logged_in']) { $author = $_SESSION['username']; $morepriv = " (status = 1 or author = '{$author}') and "; } getPrivacy(); $firstTime = false; if (!file_exists($postdb)) { $firstTime = true; } if (function_exists('sqlite_open')) { if ($config['db'] = sqlite_open($postdb, 0666, $sqliteerror)) { if ($firstTime) { @sqlite_query($config['db'], 'DROP TABLE posts'); @sqlite_query($config['db'], 'DROP TABLE comments'); @sqlite_query($config['db'], 'DROP TABLE stats'); @sqlite_query($config['db'], 'DROP TABLE active_guests'); @sqlite_query($config['db'], 'DROP TABLE active_users'); @sqlite_query($config['db'], 'DROP TABLE plugins'); @sqlite_query($config['db'], 'DROP TABLE ipban'); @sqlite_query($config['db'], 'DROP TABLE logs');
} //get cookbook id that is being edited $cookbook_id = $_GET["cookbook_id"]; include 'db-credentials.php'; $link = new mysqli($servername, $username, $password, $dbname); if ($link->connect_error) { die("Connection failed: " . $link->connect_error); } //Do not have access to edit, if not owner of cookbook $isOwner = isOwner($user_id, $cookbook_id, $link); if ($isOwner == false) { header('Location: fail.php'); } $title = getCookbookTitle($cookbook_id, $link); //get title of cookbook $privacy = getPrivacy($cookbook_id, $link); //get privacy of cookbook //Check if privacy is friendly if ($privacy == "FRIENDLY") { $allemails = getFriends($cookbook_id, $link); } $sql = "SELECT name FROM Tag WHERE type='COOKBOOK' AND type_id = '{$cookbook_id}'"; $result = $link->query($sql); $i = 0; while ($row = $result->fetch_assoc()) { $tagsfromdb[$i] = $row['name']; $i++; } //all possible tags $alltags_array = array('1' => 'appetizer', '2' => 'paleo', '3' => 'american', '4' => 'beef', '5' => 'pork', '6' => 'asian', '7' => 'beverages', '8' => 'poultry', '9' => 'desi', '10' => 'breakfast/brunch', '11' => 'salad', '12' => 'greek', '13' => 'chicken', '14' => 'seafood', '15' => 'italian', '16' => 'desserts', '17' => 'soup', '18' => 'jamaican', '19' => 'gluten-free', '20' => 'vegan', '21' => 'latin', '22' => 'lunch', '23' => 'vegetarian'); if ($i > 0) {
<?php session_start(); include 'create-recipe-form.php'; include 'db-credentials.php'; //if form submitted if ($_SERVER['REQUEST_METHOD'] == "POST") { //connect to db $conn = connectToDb($servername, $username, $password, $dbname); $userId = getAuthorId($conn, $_SESSION["username"]); //if friend does not have account if (!checkPrivacy($conn)) { exit("Sorry, your friend(s) is not a registered user."); } $recipeName = getRecipeName($conn); $allSteps = getAllSteps($conn); $privacy = getPrivacy(); $recipeId = insertRecipeIntoDB($recipeName, $userId, $allSteps, $privacy, $conn); //if error in inserting recipe into db if ($recipeId < 0) { exit("Sorry, could not access database when adding recipe. Please try again."); } $photoPath = NULL; //check if image uploaded if (checkImageUploaded()) { $photo = getImageTmpName(); $photoPath = getImagePath($recipeId); if (!mkdir("images/" . $recipeId, 0777, true)) { exit('Could not upload image to server.'); } if (!move_uploaded_file($photo, "images/" . $photoPath)) { exit('Could not create space on server for image.');