0) && ctype_digit($_REQUEST["debug"])) {
$debug = $_REQUEST["debug"];
} else {
$debug = 0;
}
if (isset($_REQUEST["auto"]) && (strlen($_REQUEST["auto"]) > 0) && ctype_digit($_REQUEST["auto"])) {
$auto = $_REQUEST["auto"];
} else {
$auto = 0;
}
if (isset($_REQUEST["album_id"]) && (strlen($_REQUEST["album_id"]) > 0) && ctype_digit($_REQUEST["album_id"])) {
$album_id = $_REQUEST["album_id"];
} else {
$album_id = 1;
}
if (isset($_REQUEST["roll_id"]) && (strlen($_REQUEST["roll_id"]) > 0) && ctype_digit($_REQUEST["roll_id"])) {
$roll_id = $_REQUEST["roll_id"];
} else {
$roll_id = 0;
}
if (isset($_REQUEST["page_id"]) && (strlen($_REQUEST["page_id"]) > 0) && ctype_digit($_REQUEST["page_id"])) {
$page_id = $_REQUEST["page_id"];
} else {
$page_id = 0;
}
if (isset($_REQUEST["pic_id"]) && (strlen($_REQUEST["pic_id"]) > 0) && ctype_digit($_REQUEST["pic_id"])) {
$pic_id = $_REQUEST["pic_id"];
} else {
$pic_id = 0;
}
if ($debug & $debug_trace) { printf("Debug: debug set to: %s for %s;
", $debug, $_SERVER['PHP_SELF']); };
if ($debug & $debug_trace) { printf("Debug: db_host: %s; db_name: %s;
", $db_host, $db_name); };
if ($debug & $debug_info) { phpinfo(); };
if ($debug & $debug_trace) { printf("Debug: parms set to: Roll: %s, Page: %s, Pic: %s
", $roll_id, $page_id, $pic_id); };
?>
", $sql); };
$result = mysql_query($sql, $db_conn) or die(mysql_error());
$onerow = mysql_fetch_assoc($result);
$album_title = $onerow['album_title'];
if ($debug & $debug_trace) { printf("Debug: Selected Album is: %s
", $album_title); };
// List of all rolls for menu bar
$sql = "select *";
$sql .= " from rolls";
$sql .= " inner join album_contents on rolls.roll_id = album_contents.roll_id";
$sql .= " where album_contents.album_id = " . $album_id;
$sql .= " order by rolls.roll_sort";
if ($debug & $debug_trace) { printf("Debug: Roll Query: %s
", $sql); };
$rolls = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: Roll Query resulted in %s rows
", mysql_num_rows($rolls)); };
if (mysql_num_rows($rolls) == 1) { $theroll = mysql_fetch_assoc($rolls); $roll_id = $theroll['roll_id']; }
// if a roll has been selected, we should get info about that roll and a list of all the pages in that roll for the menubar
if ($roll_id > 0) {
$sql = "select *";
$sql .= " from rolls";
$sql .= " where rolls.roll_id = " . $roll_id;
$sql .= " order by rolls.roll_sort";
if ($debug & $debug_trace) { printf("Debug: Roll_id Query: %s
", $sql); };
$result = mysql_query($sql, $db_conn) or die(mysql_error());
$onerow = mysql_fetch_assoc($result);
$roll_title = $onerow['roll_title'];
$roll_desc = $onerow['roll_desc'];
if ($debug & $debug_trace) { printf("Debug: Selected Roll is: %s
", $roll_title); };
$sql = "select *";
$sql .= " from pages";
$sql .= " inner join roll_contents on pages.page_id = roll_contents.page_id";
$sql .= " where roll_contents.roll_id = " . $roll_id;
$sql .= " order by pages.page_sort";
if ($debug & $debug_trace) { printf("Debug: Page Query: %s
", $sql); };
$pages = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: Page Query resulted in %s rows
", mysql_num_rows($pages)); };
// if (mysql_num_rows($pages) == 1) { $thepage = mysql_fetch_assoc($pages); $page_id = $thepage['page_id']; }
// if we have a roll but no page, the next prev button refer to the roll, so we have to figure out what those should be
if ($page_id == 0) {
$sql = "select Rolls.roll_id";
$sql .= " from Rolls";
$sql .= " order by Rolls.roll_sort";
if ($debug & $debug_trace) { printf("Debug: Roll Index Query: %s
", $sql); };
$index = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: Page Index Query resulted in %s rows
", mysql_num_rows($index)); };
mysql_data_seek($index, mysql_num_rows($index)-1); $row_index = mysql_fetch_assoc($index); $last_roll = $row_index['roll_id'];
mysql_data_seek($index, 0); $row_index = mysql_fetch_assoc($index); $first_roll = $row_index['roll_id'];
$up = sprintf("", $thispage);
$prev_roll = $first_roll;
$next_roll = $last_roll;
while (($row_index) && ($row_index['roll_id'] <> $roll_id)) {
$prev_roll = $row_index['roll_id'];
$row_index = mysql_fetch_assoc($index);
}
if ($row_index) { $row_index = mysql_fetch_assoc($index); }
if ($row_index) { $next_roll = $row_index['roll_id']; }
}
}
// so we have a roll and a page. we already did the query for the roll, now we need info about the page and the pictures on it
if ($page_id > 0) {
$sql = "select *";
$sql .= " from pages";
$sql .= " where pages.page_id = " . $page_id;
if ($debug & $debug_trace) { printf("Debug: Page_id Query: %s
", $sql); };
$result = mysql_query($sql, $db_conn) or die(mysql_error());
$thepage = mysql_fetch_assoc($result);
if ($debug & $debug_trace) { printf("Debug: Selected Page is: %s
", $thepage['page_title']); };
// if we have a roll and a page but no picture - we need info on all the pictures so we can display the index
if ($pic_id == 0) {
$sql = "select pictures.pic_id, pictures.pic_filename, pictures.pic_cols, pictures.pic_desc, rolls.roll_path, pages.page_path, page_contents.page_id, roll_contents.roll_id";
$sql .= " from pictures";
$sql .= " inner join page_contents on pictures.pic_id = page_contents.pic_id";
$sql .= " inner join pages on pages.page_id = page_contents.page_id";
$sql .= " inner join roll_contents on page_contents.page_id = roll_contents.page_id";
$sql .= " inner join rolls on roll_contents.roll_id = rolls.roll_id";
$sql .= " where page_contents.page_id = " . $page_id;
$sql .= " order by pictures.pic_sort";
if ($debug & $debug_trace) { printf("Debug: pictures Query: %s
", $sql); };
$pictures = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: pictures Query resulted in %s rows
", mysql_num_rows($pictures)); };
// if (mysql_num_rows($pictures) == 1) { $thepic = mysql_fetch_assoc($pictures); $pic_id = $thepic['pic_id']; }
// The prev and next buttons refer to pages, so we need to do a little research
$sql = "select roll_contents.page_id, roll_contents.roll_id";
$sql .= " from roll_contents";
$sql .= " left join rolls on roll_contents.roll_id = rolls.roll_id";
$sql .= " left join pages on roll_contents.page_id = pages.page_id";
$sql .= " where roll_contents.roll_id = " . $roll_id;
$sql .= " order by rolls.roll_sort, pages.page_sort";
if ($debug & $debug_trace) { printf("Debug: Page Index Query: %s
", $sql); };
$index = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: Page Index Query resulted in %s rows
", mysql_num_rows($index)); };
mysql_data_seek($index, mysql_num_rows($index)-1); $row_index = mysql_fetch_assoc($index); $last_roll = $row_index['roll_id']; $last_page = $row_index['page_id'];
mysql_data_seek($index, 0); $row_index = mysql_fetch_assoc($index); $first_roll = $row_index['roll_id']; $first_page = $row_index['page_id'];
if (!isset($up)) { $up = sprintf("", $thispage, $roll_id); }
$prev_roll = $first_roll; $prev_page = $first_page;
$next_roll = $last_roll; $next_page = $last_page;
while (($row_index) && ($row_index['page_id'] <> $page_id)) {
$prev_roll = $row_index['roll_id']; $prev_page = $row_index['page_id'];
$row_index = mysql_fetch_assoc($index);
}
if ($row_index) { $row_index = mysql_fetch_assoc($index); }
if ($row_index) { $next_roll = $row_index['roll_id']; $next_page = $row_index['page_id']; }
}
}
// OK, so we finally have a roll, a page and a picture
if ($pic_id > 0) {
$sql = "select pictures.pic_id, pictures.pic_title, pictures.pic_desc, pictures.pic_text, pictures.pic_filename, page_contents.page_id, pages.page_path, roll_contents.roll_id, rolls.roll_path";
$sql .= " from pictures";
$sql .= " inner join page_contents on pictures.pic_id = page_contents.pic_id";
$sql .= " inner join pages on page_contents.page_id = pages.page_id";
$sql .= " inner join roll_contents on page_contents.page_id = roll_contents.page_id";
$sql .= " inner join rolls on roll_contents.roll_id = rolls.roll_id";
$sql .= " where pictures.pic_id = " . $pic_id;
if ($debug & $debug_trace) { printf("Debug: picture Query: %s
", $sql); };
$picture = mysql_query($sql, $db_conn) or die(mysql_error());
$row_pics = mysql_fetch_assoc($picture);
// this time, the prev and next buttons refer to pictures - time for research
$sql = "select pictures.pic_id, page_contents.page_id, roll_contents.roll_id";
$sql .= " from pictures";
$sql .= " inner join page_contents on pictures.pic_id = page_contents.pic_id";
$sql .= " inner join roll_contents on page_contents.page_id = roll_contents.page_id";
$sql .= " left join rolls on roll_contents.roll_id = rolls.roll_id";
$sql .= " left join pages on page_contents.page_id = pages.page_id";
$sql .= " where roll_contents.roll_id = " . $roll_id;
$sql .= " order by rolls.roll_sort, pages.page_sort, pictures.pic_sort";
if ($debug & $debug_trace) { printf("Debug: Index Query: %s
", $sql); };
$index = mysql_query($sql, $db_conn) or die(mysql_error());
if ($debug & $debug_trace) { printf("Debug: Index Query resulted in %s rows
", mysql_num_rows($index)); };
mysql_data_seek($index, mysql_num_rows($index)-1); $row_index = mysql_fetch_assoc($index); $last_roll = $row_index['roll_id']; $last_page = $row_index['page_id']; $last_pic = $row_index['pic_id'];
mysql_data_seek($index, 0); $row_index = mysql_fetch_assoc($index); $first_roll = $row_index['roll_id']; $first_page = $row_index['page_id']; $first_pic = $row_index['pic_id'];
if (!isset($up)) { $up = sprintf("", $thispage, $roll_id, $page_id); }
$prev_roll = $first_roll; $prev_page = $first_page; $prev_pic = $first_pic;
$next_roll = $last_roll; $next_page = $last_page; $next_pic = $last_pic;
while (($row_index) && ($row_index['pic_id'] <> $row_pics['pic_id'])) {
$prev_roll = $row_index['roll_id']; $prev_page = $row_index['page_id']; $prev_pic = $row_index['pic_id'];
$row_index = mysql_fetch_assoc($index);
}
if ($row_index) { $row_index = mysql_fetch_assoc($index); }
if ($row_index) { $next_roll = $row_index['roll_id']; $next_page = $row_index['page_id']; $next_pic = $row_index['pic_id']; }
}
?>
![]() ![]() ![]() ![]() |
", $thispage); ?>
", $next_roll); ?> ", $next_page); ?> ", $next_pic); ?> ", $auto); ?> | 0) {?>
![]() ![]() ![]() ![]() |
0) {?>
![]() ![]() ![]() ![]() |