"Tofu_Session", "auth" => "Tofu_Default_Auth", "perm" => "Tofu_Perm", "user" => "Tofu_User")); //$auth->login_if(! $perm->have_perm('user')); // login if not authenticated as a user function edit($row) { echo "
\n"; echo "\n"; // name echo "\n"; echo " \n"; echo " \n"; echo "\n\n"; // email echo "\n"; echo " \n"; echo " \n"; echo "\n\n"; // description echo "\n"; echo " \n"; echo " \n"; echo "\n\n"; /* // category echo "\n"; echo " \n"; echo " \n"; echo "\n\n"; */ if (empty($row['link_date_added']) ) { $date = date('Ymd'); echo " \n"; } // submit echo "\n"; echo " \n"; echo " auth["tofu_id"]; echo "\">\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n\n"; echo "
URL:
Anchor:
Description:
Category:
\n"; echo "
\n"; } function load($id) { if (! is_numeric($id)) { return ''; } $query ="select link.id as link_id, link.url as link_url, link.anchor as link_anchor, link.contributor_id as link_contributor_id, link.description as link_description, DATE_FORMAT( link.date_added, '%M %D, %Y') as link_date_added from link where link.id = $id "; $res = run_query($query); return mysql_fetch_array($res); } function view($view, $id, $sort) { $query = "select link.id, link.url, link.anchor, link.description, DATE_FORMAT( link.date_added, '%M %D, %Y') as date_added, link.contributor_id, user.login as login, user.id as user_id from link, user where link.contributor_id = user.id "; if (! empty($id)) { $query .= "\n and link.id = $id "; } if ($sort) { $query .= "\n order by " . $sort; } else { $query .= "\n order by anchor\n"; } $res = run_query($query); if ($view == 'long') { while ($row = mysql_fetch_array($res)) { longView($row); } } else { echo "
\n"; while ($row = mysql_fetch_array($res)) { compactView($row); } echo "
"; } } function longView($row) { //$image_row = getImage('link', $row['id']); if (empty($image_row['name'])) { $no_image = 1; } echo "
\n"; echo "
\n"; echo "

" . $row['anchor'] . "

\n"; echo "URL: " . $row['url'] . "
\n"; if (! empty($row['description'])) { echo "Description:

" . $row['description'] . "

\n"; } echo "

Contributor: " . $row['login'] . "
\n"; echo "Added: " . $row['date_added'] . "

\n"; if (($row['user_id'] == $GLOBALS['auth']->auth['tofu_id']) || ($GLOBALS['perm']->have_perm(' admin')) ) { echo "
"; echo ""; echo " Edit\n"; } if ($no_image) { // not yet // echo "Add Image
"; } echo "
"; if (! empty($image_row['name'])) { echo "" . $image_row["; } else { echo " "; } echo "
\n"; } function compactView($row) { static $count; if ($count++ < 1) { echo "\n"; echo " Anchor\n"; echo " URL\n"; echo " Added\n"; echo " Contributor\n"; echo " Edit\n"; echo "\n"; } echo "\n"; echo " " . $row['anchor'] . "
\n"; echo "  " . $row['url'] . "\n"; echo " " . $row['date_added'] . " \n"; echo " " . $row['login'] . "\n"; if ($GLOBALS['auth']->auth['uname'] == $row['login']) { echo "Edit\n"; } else if ($GLOBALS['perm']->have_perm('admin')) { echo "Edit\n"; } else { echo " \n"; } echo "\n"; } function footer() { if ($GLOBALS['id']) { echo "
All |\n"; } echo "Long | "; echo "Compact\n"; if ($GLOBALS['perm']->have_perm("admin")) { echo "| Add Link
"; } } //--------- main program if (!isset($title)) { $title = 'Links'; } include("lib.tofuguide.php3"); include("db.inc.php3"); $tables = parse_tables(); if ($mode == 'edit') { if ($submit == 'Update') { if (($tables['link']['contributor_id'] != $auth->auth['tofu_id']) and (! $perm->have_perm('admin')) ) { include("header.inc.php3"); echo "

It looks like you shouldn't be editing this

"; } else { $auth->login_if(! $perm->have_perm('user')); $new_id = update($tables); if (! empty($link__id)) { header("Location: http://www.tofuguide.com" . $GLOBALS['SCRIPT_NAME'] . "?view=long&id=$link__id"); } else { header("Location: http://www.tofuguide.com" . $GLOBALS['SCRIPT_NAME'] . "?view=long&id=$new_id"); } } } else { include("header.inc.php3"); edit(load($id)); } } else { include("header.inc.php3"); view($view,$id,$sort); } footer(); //--------- main program include("footer.inc.php3"); page_close(); ?>