Location: PHPKode > projects > My Scrapbook > myscrapbook_3_1/bookcontents.php
<? 
//-----------------------------------------------------------------
//MyScrapBook online book program by Eric Gerdes (Crafty Syntax . Com )
//-----------------------------------------------------------------
// Feel free to change this code to better fit your website. I am
// open for any suggestions on how to improve the program and 
// you can submit suggestions and/or bugs to:
// http://craftysyntax.com/myscrapbook/updates/
// if you like using this program and feel it is a good program 
// feel free to send a donation by going to:
// http://craftysyntax.com/myscrapbook/abouts.php
//-----------------------------------------------------------------

require "config.php";
require "functions.php";

if( (has_access("F",$section)) && ($whattodo == "reorderpages")){
  
  while (list($key, $val) = each($HTTP_POST_VARS)) {                 
    $array = split("__",$key);
    if($array[0] == "ordernum") {               
         $query = "UPDATE scrapbook_words set ordernum='$val' WHERE id='$array[1]' ";
         $mydatabase->sql_query($query);
    }
  }
}


$next =  $page + 1;
$back =  $page - 1;
$current = $page;
$othercurrent = $current + 1;
$displayedsomething = 0;

$query = "SELECT * FROM scrapbook_contents WHERE recno='$section'";
$result = $mydatabase->select($query);
$top_r = $result[0];

?>

<HTML><TITLE>-  -</title>

<?
/* display open graphic */
if ($current == -1){

if($viewis =="editmode"){
 $query = "SELECT * FROM scrapbook_contents where recno='$section'";
 $data = $mydatabase->select($query);
 $data = $data[0];
	?>
<link REL="stylesheet" HREF="style.css" TYPE="text/css">
<body background=images/bkbook.gif bgcolor=ffffff text=664411 link=996633 vlink=996633>
<center>
<form action=updatechapter.php method=post  ENCTYPE="multipart/form-data">
<input type=hidden name=recno value=<?= $data[recno] ?> >
<input type=hidden name=largeimage value=<?= $data[openimage] ?> >
<table>
<tr><td>Chapter Number:</td><td><select name=ordernum>
<?
for($i=1;$i<41;$i++){
 print "<option value=$i ";
 if($data[ordernum] == $i){ 
 print " SELECTED ";
 }
 print ">$i</option>\n";
}
?>
</select></td></tr>
<tr><td>Chapter Name:</td><td><input type=text size=20 name=name value="<? echo "$data[name]"; ?>"></td></tr>
<tr><td>optional Image:</td><td>
<?
if ($data[openimage] != ""){ 
  print "<img src=userimages/$data[openimage]><br><i>to change this image use the below upload<br></i>";	
  print "<input type=checkbox name=removephoto value=YES><font color=990000>Check this box to REMOVE above image</font><br>";
}
?>
<input type=FILE size=35 name=myfile ><br>
<? if ( ($Processor == "netpbm") || ($Processor == "ImageMagick") ){ ?>
re-size new image to: <select name=maxwidth><option>500</option><option>450</option><option>400</option><option>350</option><option SELECTED>300</option><option>250</option><option>200</option><option>150</option><option>100</option></select>width
<? } ?><br><br>
</td></tr>

<?
$no_ent = $yes_ent = "";
if($data[entriespage] == "Y"){ $yes_ent = " SELECTED "; } 
if($data[entriespage] == "C"){ $con_ent = " SELECTED "; } 
if($data[entriespage] == "N"){ $no_ent = " SELECTED "; } 
?>
<tr><td><b>Entries/contents/Opening page:</b></td><td><select name=entriespage>
<option value=Y <?= $yes_ent ?> >start with opening page</option>
<option value=C <?= $con_ent ?> >start with contents page</option>
<option value=N <?= $no_ent ?> >start with page 1</option>
</select>
</td></tr>
<?
$exp_ent = $no_ent = $yes_ent = "";
if($data[formatpage] == 2){ $yes_ent = " SELECTED "; }
if($data[formatpage] == 1){ $no_ent = " SELECTED "; }
if($data[formatpage] == 0){ $exp_ent = " SELECTED "; }
?>
<tr><td><b>Page layout format:</b></td><td><select name=formatpage>
<option value=2 <?= $yes_ent ?> >2 Page Layout</option>
<option value=1 <?= $no_ent ?> >1 Page Layout</option>
</select>
</td></tr>
<tr><td colspan=2><b>Chapter entries features:<br>
<table>
<?
$no_ent = $yes_ent = "";
if($data[showname] == "Y"){ $showname_ent = " CHECKED "; } 
if($data[showemail] == "Y"){ $showemail_ent = " CHECKED "; } 
if($data[showurl] == "Y"){ $showurl_ent = " CHECKED "; } 
if($data[showimage] == "Y"){ $showimage_ent = " CHECKED "; } 
?>
<tr><td><input type=checkbox name=showname value=Y <?= $showname_ent ?> ></td><td>- Name</td>
<td><input type=checkbox name=showemail value=Y <?= $showemail_ent ?> ></td><td>- e-mail</td>
<td><input type=checkbox name=showurl value=Y <?= $showurl_ent ?> ></td><td>- URL</td>
<td><input type=checkbox name=showimage value=Y <?= $showimage_ent ?> ></td><td>- Image Upload</td></tr>

</table>
</td></tr>
<tr><td>New submissions Notify e-mail:</td><td><input type=text size=40 name=notifyemail value="<? echo "$data[notifyemail]"; ?>"></td></tr>
<tr><td colspan=2>
<b>Opening Message:</b><br>
<TEXTAREA NAME="opentext" COLS=55 ROWS=10 WRAP=Virtual><? echo "$data[opentext]"; ?></TEXTAREA>
<br><input type="submit" name=whattodo value="UPDATE">
</td></tr>
<tr><td colspan=2><b>Permissions:</b><br>
<?

// if a removeal was made
if ($removeaccess != ""){
   $query = "DELETE FROM scrapbook_access WHERE recno='$removeaccess'";
   $mydatabase->sql_query($query);
}


  $query = "SELECT * FROM scrapbook_access WHERE contentsid='$section'";
  $data_t = $mydatabase->select($query);
?>
<table border=1><tr bgcolor=DDDDDD><td>Name</td><td>username</td><td>ACCESS</td><td>actions</td></tr>
<tr><td></td><td>admin</td><td>
ALL ACCESS (read/write/edit)
</td></tr>
<tr><td></td><td><font color=000077>EVERYONE</font></td><td>
<select name=permissions>
<option value=none <? if ($data[permissions] == "none"){ print " SELECTED "; } ?> >No Access (Private Chapter)</option>
<option value=read <? if ($data[permissions] == "read"){ print " SELECTED "; } ?> >Read Only</option>
<option value=approval <? if ($data[permissions] == "approval"){ print " SELECTED "; } ?> >Can Add with approval</option>
<option value=all <? if ($data[permissions] == "all"){ print " SELECTED "; } ?> >Can Add WITHOUT approval</option>
</select>
</td></tr>
<?
  for($i=0;$i< count($data_t); $i++){
    $myrow = $data_t[$i];
    $query = "SELECT * FROM scrapbook_users where recno='$myrow[userid]'";
    $data_user = $mydatabase->select($query);
    $data_user = $data_user[0];     
    print "<tr><td>$data_user[name] </td><td>$data_user[myusername]</td><td>";
?>
<select name=myaccess_<?= $myrow[recno] ?>>
<option value=R <? if ($myrow[myaccess] == "R"){ print " SELECTED "; } ?> >Read Only</option>
<option value=A <? if ($myrow[myaccess] == "A"){ print " SELECTED "; } ?> >Can Add with approval</option>
<option value=m <? if ($myrow[myaccess] == "m"){ print " SELECTED "; } ?> >Can Add WITHOUT approval</option>
<option value=F <? if ($myrow[myaccess] == "F"){ print " SELECTED "; } ?> >ALL ACCESS (read/write/edit)</option>
</select>    
<?
  print "</td><td>[<font color=990000><a href=bookcontents.php?section=$section&page=-1&viewis=editmode&removeaccess=$myrow[recno]>Remove ACCESS</font>]</td>";
  print "</tr>";      	
}

?>

<tr><td colspan=4>
<b>Existing Users:</b>
<?
 $query = "SELECT * FROM scrapbook_users order by myusername";
 $data_users = $mydatabase->select($query);
 if (count($data_users) != 0){
?>
<select name=adduser>
<?

 for($j=0;$j< count($data_users); $j++){
    $data_users_d = $data_users[$j];  
    print "<option value=$data_users_d[recno]>$data_users_d[myusername] : $data_users_d[name]</option>\n";
  }
?>
</select>
<input type=submit value="GIVE ACCESS" name=whattodo><br>
<? } else {
  print "<i>No Users have been added. Click</i> EDIT USER LIST <i>to add users</i>";	
	
}?>
<hr><input type="submit" name=whattodo value="EDIT USER LIST"> <input type="submit" name=whattodo value="UPDATE PERMISSIONS">
</td></tr></table>
</td></tr>


</table>
<table width=80%><tr><td width=50%>
<input type="submit" name=whattodo value="UPDATE">
</td>
<td width=50%>
<input type="submit" name=whattodo value="REMOVE">
</td></tr></table>
</form>	

	<?
	} else {
?>
</HEAD>
<link REL="stylesheet" HREF="style.css" TYPE="text/css">
<body bgcolor=ffffff background="images/bkbook.gif" bgcolor=ffffff text=664411 link=996633 vlink=996633>
<center>
<?
if ($top_r[openimage] != ""){ 
     $imagehw = GetImageSize("userimages/$top_r[openimage]"); 
   $width = $imagehw[0]; 
   $height = $imagehw[1]; 
   if($width > 350){ $width=" width=350 "; $mylink= "<br><a href=userimages/$top_r[openimage] target=_blank>click here for larger view.</a>"; } else { $width= ""; }	
  print "<img src=userimages/$top_r[openimage] $width >$mylink</center>";
 }
?>
<center>
<table><tr><td>
<?= $top_r[opentext] ?>
</td></tr></table>
<br><br><br>

<font size=1>Powered By:
<a href=http://craftysyntax.com/myscrapbook/ target=_blank>MyScrapbook <font color=000077><?= $version ?></font></a> 
<br><br></center>
</body></html>
<? $displayedsomething = 1; ?>
<? }} ?>

<?
/* display entries */
if ($current == 0){ ?>
<html><title><? print "$section"; ?></title>
<link REL="stylesheet" HREF="style.css" TYPE="text/css">
<body background=images/bkbook.gif bgcolor=ffffff text=664411 link=996633 vlink=996633>
<center><b>Entries in <? print "$top_r[name]"; ?>:</b>

<? if(has_access("F",$section)){ ?> 
<FORM ACTION=bookcontents.php METHOD=POST>
<input type=hidden name=whattodo value=reorderpages>
<input type=hidden name=page value=<?= $page ?> >
<input type=hidden name=section value=<?= $section ?> >
<? } 

 $query = "SELECT formatpage FROM scrapbook_contents where recno='$section'";
 $data = $mydatabase->select($query);
 $data = $data[0];
 $formatpage = $data[formatpage];

$query = "SELECT * FROM scrapbook_words WHERE contentsid='$section' AND approved='Y' ORDER By ordernum";
$result = $mydatabase->select($query);
$num = count($result);

$i=0;
$counter = -1;
$evenodd = 1;
echo "<table>";
while($i<$num){
$result_row = $result[$i];
$id = $result_row[id];
$ordernum = $result_row[ordernum];
$title = $result_row[title];
$name = $result_row[name];
if (($evenodd % 2) == 1){  $counter = $counter + 2; }
if($formatpage != 2){
echo "<TR><td valign=top>";
if(has_access("F",$section)){
  print "<input type=text size=4 name=ordernum__$id value=$ordernum >";
}
echo "<font color=000000>$evenodd</font>.</td><td><a href=singlepage.php?html=bookcontents.php&footer=1&section=$section&page=$evenodd target=_top>$title</a>-$name<br></td></tr>";
} else {
echo "<TR><td valign=top>";
if(has_access("F",$section)){
  print "<input type=text size=5 name=ordernum__$id value=$ordernum >";
}
echo "<font color=000000>$evenodd</font>.</td><td><a href=index.php?section=$section&page=$counter target=_top>$title</a>-$name<br></td></tr>";
}
$evenodd++; 
$i++;
}
echo "</table>";
if(has_access("F",$section)){
print "<font color=990000>Submissions that Need approval:</font><br>";	
$query = "SELECT * FROM scrapbook_words WHERE contentsid='$section' AND approved='N' ORDER By ordernum";
$result = $mydatabase->select($query);
$num = count($result);

$i=0;
$counter = -1;
$evenodd = 1;
echo "<table>";
while($i<$num){
$result_row = $result[$i];
$title = $result_row[title];
$name = $result_row[name];
$id = $result_row[id];
if (($evenodd % 2) == 1){  $counter = $counter + 2; }
echo "<TR bgcolor=DDDDDD><td valign=top><font color=000000>$evenodd</font>.</td><td><a href=singlepage.php?html=unapproved.php&id=$id target=_top>$title</a>-$name<br></td></tr>";
$evenodd++; 
$i++;
}
echo "</table>";
}
if(has_access("F",$section)){
	print "<input type=submit value=\"RE-OREDER PAGES\">";
	}
print "</form></body></html>";
?>

<? } ?>

<?
/* display info */
if ($current > 0){ ?>
<link REL="stylesheet" HREF="style.css" TYPE="text/css">
<body background=images/bkbook.gif bgcolor=ffffff text=664411 link=996633 vlink=996633>
<center>
<?php 
$query = "SELECT * FROM scrapbook_words WHERE contentsid='$section' AND approved='Y' ORDER By ordernum";
$result = $mydatabase->select($query);
$num = count($result);
if ($num < $current ){

$name = "";
$title = "";
$email = "";
$webaddress = "";

 $query = "SELECT formatpage FROM scrapbook_contents where recno='$section'";
 $data = $mydatabase->select($query);
 $data = $data[0];
 $formatpage = $data[formatpage];

if ($formatpage == 1){ 

$comment = "<SCRIPT>window.location.replace(\"contents.php\");</SCRIPT> <a href=contents.php>Click here</a>";

 } else { 
 if(($current % 2) == 1){
   $comment = "<SCRIPT>window.location.replace(\"contents.php\");</SCRIPT> <a href=contents.php>Click here</a>";
 }	
 } 
	
} else {

$result_row = $result[$back];
$ordernum = $result_row[ordernum];
$name = $result_row[name];
$title = $result_row[title];
$email = $result_row[email];
$webaddress = $result_row[webaddress];
$webname = $result_row[webname];
$id = $result_row[id];
$comment = $result_row[comment];
$contentsid = $result_row[contentsid];
$myimage = $result_row[myimage];
}


if ($viewis == "editmode"){
  print "<font color=990000 size=+3><b> EDIT PAGE:</b></font><br><hr><br>";
  print "<form action=editpage.php method=post  ENCTYPE=\"multipart/form-data\">";
  print "<b>Chapter:</b><select name=contentsid>";
  $query = "SELECT * from scrapbook_contents";
  $data = $mydatabase->select("$query");
  for($i=0;$i< count($data); $i++){
  $row = $data[$i];
  print "<option value=\"$row[recno]\" ";
  if($contentsid == $row[recno]){ print " SELECTED "; }
  print ">$row[name]</option>\n";
  }
  ?>
  </select>
  <?
  print "<input type=hidden name=idnum value=$id><br>";
}
?>
<? 
if ($viewis == "editmode"){
print "<br><b>TITLE:</b> <input type=text size=30 name=title value=\"$title\" >";
} else {
?> 
<center><b><? echo "$title"; ?></b>
<?
if ($myimage != ""){ 
     $imagehw = GetImageSize("userimages/$myimage"); 
   $width = $imagehw[0]; 
   $height = $imagehw[1]; 
   if($width > 350){ $width=" width=350 "; $mylink= "<br><a href=userimages/$myimage target=_blank>click here for larger view.</a>"; } else { $width= ""; }	
  print "<br><img src=userimages/$myimage $width >$mylink</center>";
 }
?>

<? } ?>
<br>
<? 
if ($viewis == "editmode"){
print "<TEXTAREA rows=15 cols=60 name=comment WRAP=VIRTUAL> $comment </TEXTAREA>\n";
print "<br><input type=submit name=what value=update>";
} else {
 echo "<table><tr><Td>$comment</td></tr></table>";
} ?>
<br>
<font color=000000> 
<? 
if ($viewis == "editmode"){

if ($myimage != ""){ 
  print "<img src=userimages/$myimage><br><i>to change this image use the below upload<br></i><br>";	
  print "<input type=checkbox name=removephoto value=YES><font color=990000>Check this box to REMOVE above image</font><br>";
}
  print "Image: <input type=FILE size=35 name=myimage ><br>";
  ?>
  <br>
<? if ( ($Processor == "netpbm") || ($Processor == "ImageMagick") ){ ?>
re-size new image to: <select name=maxwidth><option>500</option><option>450</option><option>400</option><option>350</option><option SELECTED>300</option><option>250</option><option>200</option><option>150</option><option>100</option></select>width 
<? } ?><br><br>
  <?	
	
print "name:<input type=text size=30 name=name value=\"$name\" ><br>";
} else {
 echo "$name"; } ?> </font>
<?
if ($viewis == "editmode"){
print "e-mail:<input type=text size=30 name=email value=\"$email\" ><br>";
print "webaddress:<input type=text size=30 name=webaddress value=\"$webaddress\" ><br>";
print "webname:<input type=text size=30 name=webname value=\"$webname\" ><br>";
} else {
 if ($email != "") { echo "<font color=000077>($email)</font>"; } ?>
<br>
<? if ($webname != "none") { echo "<a href=$webaddress target=other>$webname</a>"; } }?>
</p>
<?
if ($viewis == "editmode"){
print "<center><table width=50%><tr><td><input type=submit name=what value=update></td><td><input type=submit name=what value=DELETE></td></tr></table></center>";
	
}
?>
<? } ?>

Return current item: My Scrapbook