Internationale Vegetarier-Union (IVU)
IVU logo
Recipes Around the World Rezepte aus aller Welt

Recipes Around the World
Over 3,000 vegan recipes in English


5) { // ----- Get template from remote server: ------------------------------ $t = 'http://'.stripslashes($t); $template = file_get_contents($t); if ($template === false) { echo "
Incorrect Templatename. Can't read '$t' template! $template
"; die(); } } else { // ----- Get template from database: ------------------------------ if (strlen($t)==0) $t = $main; if (empty($t)) die('Template-number needed!'); $SQL = "SELECT source FROM recipe_template WHERE id=$t"; $result = mysql_query($SQL); if (mysql_num_rows($result)<1) { echo "
Template doesn't exist!
"; die(); } else { $template=mysql_result($result,0,'source'); } mysql_free_result($result); $template = str_replace ('{language}',$language,$template); } // Send header if needed: if (isset($makeheader)) { ?> EVU-Recipelist: template-test "; } ?> $start_of_template {BEGIN entry} $start_loop {BEGIN ingredients} $ingredients_loop {END ingredients} $end_loop {END entry} $end_of_template ***********************************/ $SQLa = "SELECT recipe.id AS recipe_id, recipe.main_language, recipe.download_counter, recipe.forhowmany,"; $SQLa.= " recipe.inputfrom_name, recipe.inputfrom_email, recipe.source_text, recipe.source_link, recipe.source_picture_id, recipe.source_picture_text, "; $SQLa.= " recipe.picture_id, recipe.picture_text, recipe.lastupdate, recipe.name,"; if (!isset($noTexts)) $SQLa.= " recipe.text1, recipe.preparation, recipe.text2,"; $SQLa.= " recipe_category.course, recipe_category.special_diet, recipe_category.geographic, recipe_category.duration, recipe_category.worktime, recipe_category.utensil "; $SQLb.= "FROM recipe "; $SQLb.= "LEFT JOIN recipe_category ON recipe_category.id=recipe.id "; if ((!empty($ingredient))|(!empty($noingredient))) { /* SELECT recipe.id FROM recipe LEFT JOIN recipe_category ON recipe_category.id=recipe.id LEFT JOIN recipe_ingredientslist ON recipe_ingredientslist.recipe_id=recipe.id LEFT JOIN recipe_ingredient ON recipe_ingredient.id=recipe_ingredientslist.ingredient_id WHERE recipe_ingredient.en LIKE '%tofu%' GROUP BY recipe.id */ $SQLb.= "LEFT JOIN recipe_ingredientslist ON recipe_ingredientslist.recipe_id=recipe.id "; $SQLb.= "LEFT JOIN recipe_ingredient ON recipe_ingredient.id=recipe_ingredientslist.ingredient_id "; } $search_ingredients_number = 1; if (empty($lang)) $SQLb.= "WHERE 1 "; else { $SQLb.= "WHERE (main_language='$language') "; $search_ingredients_recipeID = array(); if (!empty($ingredient)) { $separator = ";"; $ingredient = trim($ingredient); $ingredientarray = explode($separator,$ingredient); $search_ingredients_number = count($ingredientarray); $ingredientitem = array_shift($ingredientarray); $SQLb.= "AND (recipe_ingredient.".$language." LIKE '%".$ingredientitem."%') "; $search_ingredients_recipeID = getRecipeIDarray_with_ingredient($ingredientitem); if ($search_ingredients_number>1) { $i = 1; foreach ($ingredientarray as $ingredientitem) { $ingredientitem = trim($ingredientitem); if (!empty($ingredientitem)) { $search_ingredients_recipeID = array_intersect($search_ingredients_recipeID, getRecipeIDarray_with_ingredient($ingredientitem)); $i++; } } $search_ingredients_number = $i; } } } if (!empty($filter)) { $filter = str_replace ("recipe_id", "recipe.id", $filter); // $filter = str_replace ("\'", "'", $filter); $SQLb.= "AND ($filter) "; $recipe_hit = strpos($filter,"recipe.id=",0); if (!($recipe_hit===false)) { $recipe_hit+=10; } else { $recipe_hit = strpos($filter,"recipe.id =",0); if (!($recipe_hit===false)) { $recipe_hit+=11; } } if (!($recipe_hit===false)) { $temp = substr($filter,$recipe_hit); $temp_id = intval($temp); // echo "
temp: $temp [$temp_id]
"; $hit_SQL = "UPDATE recipe SET download_counter=download_counter+1 WHERE id=$temp_id"; $temp_result = mysql_query($hit_SQL); } } $SQLb.= "GROUP BY recipe.id "; if (!isset($countonly)) { if (isset($order) & (strlen($order)>0)) { $order = str_replace ("recipe_id", "recipe.id", $order); $SQLb.= "ORDER BY $order "; } else { $SQLb.= "ORDER BY name "; } } $result = mysql_query(stripslashes("SELECT recipe.id ".$SQLb)); $n_recipes_total = mysql_num_rows($result); if (!isset($first)) $first =0; $num_noingredient_recipes_before_first = 0; $num_noingredient_recipes_after_first = 0; if (!empty($noingredient) or $search_ingredients_number>1) { if (!empty($noingredient)) { $separator = ";"; $noingredient = trim($noingredient); $noingredientarray = explode($separator,$noingredient); $search_noingredients_number = count($noingredientarray); $noingredientitem = array_shift($noingredientarray); $noingredient_recipes = getRecipeIDarray_with_ingredient($noingredientitem); // gets array with all recipes-ID that use the $noingredient if ($search_noingredients_number>1) { $i = 1; foreach ($noingredientarray as $noingredientitem) { $noingredientitem = trim($noingredientitem); if (!empty($noingredientitem)) { $noingredient_recipes = array_merge($noingredient_recipes, getRecipeIDarray_with_ingredient($noingredientitem)); $i++; } } $search_noingredients_number = $i; $noingredient_recipes = array_unique($noingredient_recipes); } } else { $noingredient_recipes = array() ; } // $SQLb.= "AND (recipe_ingredient.".$language." NOT LIKE '%".$noingredient."%') "; // ############################################# if ($first==0) { while ($row = mysql_fetch_row ($result)) { if (in_array($row[0], $noingredient_recipes) or (($search_ingredients_number>1) and !in_array($row[0],$search_ingredients_recipeID))) { $n_recipes_total--; $num_noingredient_recipes_after_first++; } } // print_r($search_ingredients_recipeID); } else { $z = 0; while ($row = mysql_fetch_row ($result)) { if (in_array ($row[0], $noingredient_recipes) or (($search_ingredients_number>1) and !in_array($row[0],$search_ingredients_recipeID))) { $n_recipes_total--; if ($first>$z) $num_noingredient_recipes_before_first++; else $num_noingredient_recipes_after_first++; } else { $z++; } } } } else { $noingredient_recipes = array(); } mysql_free_result($result); if (isset($countonly)) { echo $n_recipes_total; // return $n_recipes_total; // doesn't work!!! die(); } // ----------------------------------------------------------------------------------------------------------------- if (!isset($limit)) $limit = 300; // never show more then the first 300 records if ($first>0) { $SQLb.= " LIMIT ".($first+$num_noingredient_recipes_before_first).",".($limit+$num_noingredient_recipes_after_first); } else { $SQLb.= " LIMIT ".($limit+$num_noingredient_recipes_after_first); } $SQL = $SQLa.$SQLb; // echo "
*".$SQL."*

"; // ################################################### $result = mysql_query(stripslashes($SQL)); $n_recipes = mysql_num_rows($result); if (!empty($noingredient)) { while ($row = mysql_fetch_row ($result)) { if (in_array ($row[0], $noingredient_recipes)) $n_recipes--; } mysql_data_seek($result,0); } if ($n_recipes<1) { die("Sorry. No entry available."); } //------------------------ //echo $start_of_template; $Parser->add_var("n_recipes_total",$n_recipes_total); $Parser->add_var("n_recipes",$n_recipes); $Parser->add_var("language",$language); echo $Parser->parse($start_of_template); //------------------------ if (isset($template_loop)) $dummy = $Parser->compilation_only($template_loop); $c = 0; // counter while ($row = mysql_fetch_array ($result)) { if (in_array ($row[0], $noingredient_recipes)) continue; if ($search_ingredients_number>1) if (!in_array ($row[0], $search_ingredients_recipeID)) continue; $c++; if ($c>$limit) break; $Parser->reset_var(); $Parser->add_var('c',$c); $Parser->add_var('number_of_recipes',$number_of_recipes); $Parser->add_var('language',$language); $Parser->add_var('recipe_id',$row['recipe_id']); $Parser->add_var('name',$row['name']); if (!isset($noTexts)) { $Parser->add_var('text1',nl2br($row['text1'])); $Parser->add_var('preparation',nl2br($row['preparation'])); $Parser->add_var('text2',nl2br($row['text2'])); } $main_language = $row['main_language']; $Parser->add_var('main_language',$main_language); $Parser->add_var('download_counter',$row['download_counter']); $Parser->add_var('forhowmany',$row['forhowmany']); $Parser->add_var('inputfrom_name',$row['inputfrom_name']); $Parser->add_var('inputfrom_email',$row['inputfrom_email']); $Parser->add_var('source_text',$row['source_text']); $Parser->add_var('source_link',$row['source_link']); $Parser->add_var('lastupdate',$row['lastupdate']); $Parser->add_var('picture_text',$row['picture_text']); $p_id = $row['picture_id']; $Parser->add_var('picture_id',$p_id); if ($p_id!=0) { $pic_row = mysql_fetch_array(mysql_query("SELECT picture_filename FROM recipe_picture WHERE id=$p_id")); $myurl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $pic_url = str_replace (strrchr($myurl,"/"), "/show_picture.php?id=$p_id&filename=".$pic_row['picture_filename'], $myurl); $Parser->add_var('picture',"".$row["); $Parser->add_var('picture50',"".$pic_row["); $Parser->add_var('picture75',"".$pic_row["); $Parser->add_var('picture_w300',"".$pic_row["); $Parser->add_var('picture_w500',"".$pic_row["); $Parser->add_var('picture_w800',"".$pic_row["); } else { $Parser->add_var('picture',''); } $Parser->add_var('source_picture_text',$row['source_picture_text']); $sp_id = $row['source_picture_id']; $Parser->add_var('source_picture_id',$sp_id); if ($sp_id!=0) { $pic_row = mysql_fetch_array(mysql_query("SELECT picture_filename FROM recipe_picture WHERE id=$sp_id")); $myurl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $pic_url = str_replace (strrchr($myurl,'/'), "/show_picture.php?id=$sp_id&filename=".$pic_row['picture_filename'], $myurl); $Parser->add_var('source_picture',"".$row["); } else { $Parser->add_var('source_picture',''); } $duration = $row['duration']; $dummy = settype($duration,'integer'); // to eliminate the trailing zeroes: 1.00 -> 1 $Parser->add_var('duration',$duration); $worktime = $row['worktime']; $dummy = settype($worktime,'integer'); // to eliminate the trailing zeroes: 1.00 -> 1 $Parser->add_var('worktime',$worktime); $Parser->add_var('course', translate_language($row['course'])); $Parser->add_var('course_orig', $row['course']); $Parser->add_var('special_diet',translate_language($row['special_diet'])); $Parser->add_var('special_diet_orig',$row['special_diet']); $Parser->add_var('geographic', translate_language($row['geographic'])); $Parser->add_var('geographic_orig',$row['geographic']); $Parser->add_var('utensil', translate_language($row['utensil'])); $Parser->add_var('utensil_orig', $row['utensil']); $Parser->add_var($s,true); if (isset($template_loop)) { echo $Parser->parse_again($template_loop); } else { // with ingredients: echo $Parser->parse($start_loop); $SQL = "SELECT recipe_ingredientslist.ingredient_id, recipe_ingredient.$main_language AS ingredientname, recipe_ingredient.$language AS ingredientname_trans, "; $SQL.= " recipe_ingredientslist.amount, recipe_units.$main_language AS unitname, recipe_units.$language AS unitname_trans, recipe_ingredientslist.unit "; $SQL.= "FROM recipe_ingredientslist "; $SQL.= "LEFT JOIN recipe_ingredient ON recipe_ingredient.id = recipe_ingredientslist.ingredient_id "; $SQL.= "LEFT JOIN recipe_units ON recipe_units.id = recipe_ingredientslist.unit "; $SQL.= "WHERE recipe_ingredientslist.recipe_id=".$row['recipe_id']." "; $SQL.= "ORDER BY recipe_ingredientslist.ordernumber"; $ingredients_result = mysql_query(stripslashes($SQL)); $i = 1; while ($row = mysql_fetch_array ($ingredients_result)) { $amount = $row['amount']; //$dummy = settype($amount,"double"); // to eliminate the trailing zeroes: 1.00 -> 1 $Parser->add_var('ingredient_amount',$amount); $Parser->add_var('ingredient_unit',$row['unitname']); $Parser->add_var('ingredient_unit_trans',$row['unitname_trans']); $Parser->add_var('ingredient_name',$row['ingredientname']); $Parser->add_var('ingredient_name_trans',$row['ingredientname_trans']); $Parser->add_var('ingredient_id',$row['ingredient_id']); if ($row['unit']==1) $Parser->add_var('ingredient_title',true); else $Parser->add_var('ingredient_title',false); $Parser->add_var('ingredient_number',$i++); echo $Parser->parse($ingredients_loop); } // end ingredients loop echo $Parser->parse($end_loop); mysql_free_result($ingredients_result); } } // end while (loop for every recipe) //------------------------ $Parser->add_var('n_recipes_total',$n_recipes_total); $Parser->add_var('n_recipes',$n_recipes); $Parser->add_var('language',$language); echo $Parser->parse($end_of_template); if (! empty($makeheader)) { echo ''; } //----------------------------------------------------------- function translate_language($text) { GLOBAL $language_array; if (empty($text)) return $text; reset ($language_array); while (list ($key, $val) = each ($language_array)) { $text = str_replace ($key, $val, $text); } return $text; } function getRecipeIDarray_with_ingredient($ingredient) { GLOBAL $lang,$language; $SQL = "SELECT recipe.id FROM recipe LEFT JOIN recipe_ingredientslist ON recipe_ingredientslist.recipe_id=recipe.id "; $SQL.= "LEFT JOIN recipe_ingredient ON recipe_ingredient.id=recipe_ingredientslist.ingredient_id "; if (empty($lang)) $SQL.= "WHERE (recipe_ingredient.".$language." LIKE '%".$ingredient."%') "; else $SQL.= "WHERE (main_language='$language') AND (recipe_ingredient.".$language." LIKE '%".$ingredient."%') "; $SQL.= "GROUP BY recipe.id"; // echo "
$SQL
"; $ar = array(); $result = mysql_query(stripslashes($SQL)); $n_recipes = mysql_num_rows($result); if ($n_recipes<1) { return $ar; } while ($row = mysql_fetch_row ($result)) { //echo $row[0]; $ar[] = $row[0]; } mysql_free_result ($result); return $ar; } ?>
Zurück zur Rezepteliste.


Vegane Kochbücher