include_once('../init.php'); sql_fix(array('m', 'event', 'edit')); if (isset($logout)) { unset($jeg); unset($nick); unset($_SESSION['jeg']); unset($_SESSION['nick']); } elseif (isset($_POST['login']) && $_POST['login']!='') { $res = mysql_query("SELECT id, nick, password FROM bl_events_members WHERE lower(name)=lower('" . $_POST[login] . "')"); $num = mysql_num_rows($res); if ($num == 0) { $error = 1; } else { list($uid, $nick, $pass) = mysql_fetch_row($res); $check = md5($_POST['password']); if ($check == $pass) { $jeg = $uid; $_SESSION['jeg'] = $jeg; $_SESSION['nick'] = $nick; } else $error = 1; } if ($error) { unset($jeg); unset($nick); print "Feil brukernavn og/eller passord
"; } } elseif ($_SESSION['jeg']) { $jeg = $_SESSION['jeg']; $nick = $_SESSION['nick']; } if (isset($_POST['viskun'])) { $viskun = $_POST['viskun']; $_SESSION['viskun'] = $viskun; } else { $viskun = $_SESSION['viskun']; } if (isset($_GET['event'])) { $event = $_GET['event']; $_SESSION['event'] = $event; } else { $event = $_SESSION['event']; } if ($save && $jeg) { if ($edit == 'new') { reset($m); $fv = array(); $vv = array(); while (list($k, $v) = each($m)) { array_push($fv, $k); array_push($vv, "'$v'"); } $fields = implode(',', $fv); $values = implode(',', $vv); $query = "INSERT INTO bl_events_lego (event_id, member_id, $fields) VALUES ($event, $jeg, $values)"; mysql_query($query); $edit = mysql_insert_id(); mail('matija@ifi.uio.no', "[BrikkeLauget] Ny modell fra $nick", "Modellnavn: $m[name]\nLink: http://puma.inet.hr/brikkelauget/events/index.php?edit=$edit\n\n", 'From: matija@ifi.uio.no'); } else { reset($m); $uv = array(); while (list($k, $v) = each($m)) { array_push($uv, "$k='$v'"); } $update = implode(',', $uv); if ($jeg != 1) $and = " AND member_id=$jeg"; else $and = ''; $query = "UPDATE bl_events_lego SET $update WHERE id=$edit $and"; mysql_query($query); } if (isset($_FILES) && count($_FILES)>0 && $_FILES['filnavn']['tmp_name']!='') { $path = 'bilder/'; $base = basename($_FILES['filnavn']['name']); $newbase = preg_replace('/[^\w\d\.\-\_]/', '_', $base); $upfile = $path . $newbase; $newfile = $edit . '_' . $newbase; if(move_uploaded_file($_FILES['filnavn']['tmp_name'], $upfile)) { $res = mysql_query("SELECT filename FROM bl_events_lego WHERE id=$edit"); list($oldfile) = mysql_fetch_row($res); if ($oldfile && $oldfile!='' && file_exists($path . $oldfile)) unlink($path . $oldfile); system("/usr/bin/convert $upfile -geometry 320x800 $path$newfile"); unlink($upfile); $query = "UPDATE bl_events_lego SET filename='$newfile' WHERE id=$edit"; if ($jeg != 1) $query .=" AND member_id=$jeg"; mysql_query($query); } else { print "Noe galt har skjedd... mulig bildet er for stort (5MB er max)
"; } } unset($edit); } elseif ($nochanges) { unset($edit); } if ($event || $edit) { $loginVisible = 0; } else { $loginVisible = 1; } ?>
if (!($jeg>0)): ?>
Hvem er du? |
Event | Date |
$descr | $start - $end |
if (!$edit) {
if ($jeg>0)
$table = 'legg til ny modell
';
else
$table = '';
$res = mysql_query("
SELECT m.id, m.nick, l.id, l.name, studs_w, studs_h, filename, layout, layout_area, amount
FROM bl_events_lego l, bl_events_members m
WHERE l.member_id = m.id
AND
l.event_id = $event
ORDER BY layout DESC, m.nick ASC, l.name ASC
");
$num = mysql_num_rows($res);
$found = 0;
if ($num) {
$total_al = $total_as = 0;
while (list($m_id, $m_nick, $l_id, $l_name, $w, $h, $l_filename, $l_layout, $l_area, $l_antall) = mysql_fetch_row($res)) {
if ($viskun == 0 || $viskun == $m_id) {
if (!$found)
$table .= '
| ![]() |
";
print "Arealet til felles-layouten: " . sprintf("%.2f", $total_al * 0.000064) . " kvm (" . $total_al . " knotter)
";
print "Arealet til selvstendige modeller: " . sprintf("%.2f", $total_as * 0.000064) . " kvm (" . $total_as . " knotter)
";
print $table;
} else
print $table;
if (!$found)
print "
Ingen registrerte modeller";
} else {
if ($edit != 'new') {
$res = mysql_query("SELECT * FROM bl_events_lego WHERE id=$edit");
$m = mysql_fetch_array($res);
$me = $m[member_id];
}
$canedit = ((isset($jeg) && $jeg>0) && ($me==$jeg || $jeg==1 || $edit=='new'));
?>