"Tofu_Session", "auth" => "Tofu_Default_Auth", "perm" => "Tofu_Perm", "user" => "Tofu_User") ); function edit($row) { echo "
\n"; } function load($id) { if (! is_numeric($id)) { return ''; } $query ="select restaurant.id as restaurant_id, restaurant.contributor_id as restaurant_contributor_id, restaurant.name as restaurant_name, restaurant.phone as restaurant_phone, restaurant.address as restaurant_address, restaurant.city as restaurant_city, restaurant.state as restaurant_state, restaurant.zip as restaurant_zip, restaurant.country as restaurant_country, restaurant.url as restaurant_url, restaurant.date_added as restaurant_date_added, restaurant.date_updated as restaurant_date_updated, restaurant.vegetarian_id as restaurant_vegetarian_id, restaurant.vegan_id as restaurant_vegan_id, restaurant.chain_id as restaurant_chain_id, restaurant.ethnicity_id as restaurant_ethnicity_id from restaurant left join ethnicity on restaurant.ethnicity_id = ethnicity.id where restaurant.id = $id"; $res = run_query($query); return mysql_fetch_array($res); } function view($view, $id, $search_parms) { global $db_tofu; $valid_parms = array ('ethnicity_id' => 1, 'vegetarian_id' => 1, 'vegan_id' => 1, 'state' => a ); $query = "select restaurant.id, DATE_FORMAT( restaurant.date_updated, '%M %D, %Y') as date_updated, DATE_FORMAT( restaurant.date_added, '%M %D, %Y') as date_added, restaurant.name, restaurant.address, restaurant.city, restaurant.state, restaurant.zip, restaurant.country, restaurant.phone, restaurant.url, restaurant.chain_id, restaurant.ethnicity_id, restaurant.contributor_id, user.login as contributor_login, ethnicity.name as ethnicity, vegetarian.name as vegetarian, vegan.name as vegan from restaurant, ethnicity, vegan, vegetarian, user where restaurant.ethnicity_id = ethnicity.id and restaurant.vegetarian_id = vegetarian.id and restaurant.vegan_id = vegan.id and restaurant.contributor_id = user.id "; for(reset($search_parms); $parm=key($search_parms); next($search_parms)) { if ($valid_parms[$parm] == 1) { if (is_numeric($search_parms[$parm])) { $query .= " and restaurant.$parm = '$search_parms[$parm]'\n"; } } elseif ($valid_parms[$parm] == 'a') { if (strlen($search_parms[$parm]) == 2) { $query .= " and restaurant.$parm = '$search_parms[$parm]'\n"; } } else { err("Rejecting $parm = $search_parms[$parm]"); unset($search_parms[$parm]); } } if (is_numeric($id)) { $query .= "\n and restaurant.id = $id "; } if ($GLOBALS['sort']) { $query .= "\n order by " . $GLOBALS['sort']; } else { $query .= "\n order by country, state, city, name\n"; } $res = run_query($query); #restaurant_search_form(); if ($view == 'long') { while ($db_tofu->next_record()) { longView($db_tofu->Record); } } else { echo "Reviews
\n\n";
while ($row = mysql_fetch_array($res)) {
echo "";
echo "{$row['login']}\n";
echo "{$row['review_date_updated']}\n";
if ($row['review_rank'] > 0) {
echo "({$row['review_rank']})";
}
if (($row['user_id'] == $GLOBALS['auth']->auth['tofu_id']) || ($GLOBALS['perm']->have_perm('admin')) ) {
echo "
";
echo "
";
echo " Edit review\n";
}
echo "
\n{$row['review']}
\n\n"; } echo ""; if ($reviewer_id) { echo "All reviewers | "; } echo "Add a review \n"; } function avgRank($restaurant_id) { if (! is_numeric($restaurant_id)) { return 0; } $query = "select count(*) as count, avg(rank) as avg from review where restaurant_id=$restaurant_id and rank > 0"; $res = run_query($query); while ($row = mysql_fetch_array($res)) { //echo "Of " . $row['count'] . " votes " . $row['avg'] . " is the average."; $avg = $row['avg']; } return $avg; } function longView($row) { global $db_tofu; echo "| ";
echo "\n {$row['name']} \n Fare Contact Submitted: {$row['date_added']} ";
echo "by {$row['contributor_login']} It's a chain.
| \n";
$image_row = getImage('restaurant', $row['id']);
if (! empty($image_row['name'])) {
echo " |
It looks like you shouldn't be editing this. You currently can't update something another user posted. We hope to fix that soon. Thanks for trying. Why don't you tell us what needs changed?
"; print "";
var_dump($tables);
print "";
} else {
$auth->login_if(! $perm->have_perm('user'));
$new_id = update($tables);
if (! empty($restaurant__id)) {
header("Location: /restaurant.php3?view=long&id=$restaurant__id");
} else {
header("Location: /restaurant.php3?view=long&id=$new_id");
}
}
} else {
if (is_numeric($id)) {
$title = "Edit Restaurant #" . $id . " " . getName('restaurant', $id);
} else {
$title = "Add Restaurant";
}
include("header.inc.php3");
edit(load($id));
}
} else {
if ($id) {
$title = "View Restaurant #" . $id . " " . getName('restaurant', $id);
} else {
$title = "All Restaurants";
}
include("header.inc.php3");
$search_parms['ethnicity_id'] = $ethnicity_id;
$search_parms['vegetarian_id'] = $vegetarian_id;
$search_parms['vegan_id'] = $vegan_id;
$search_parms['state'] = $state;
view($view,$id,$search_parms);
}
footer();
//--------- main program
include("footer.inc.php3");
page_close()
?>