Location: PHPKode > projects > Standardized Test Practice Engine > stpe/admin/editimg.php
<?php
/*
Copyright 2004 by Jonathan Bell and Daniel Perelman
This file is part of STPE - the Standardized Test Practice Engine.

    STPE is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    STPE is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
include_once("../globals.inc.php");
?>
<?php
include("login.inc.php");

if(!(
     (isset($_GET['top']) && isset($_GET['sub']))
    )
  )
{
        header("Location: editimgwhich.php");
        exit;
}
$wantedtopic = $_GET['top'];
$wantedsection = $_GET['sub'];
include_once("../dbinit.inc.php");
$sql = "SELECT * FROM `users` WHERE topicnum=$wantedtopic && sectionnum=$wantedsection";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);

while ($row = mysql_fetch_array($total_result)) {
	$id=$row['id'];
	$groupid=$row['group_id'];
    $topicnum=$row['topicnum'];
    $topicdesc=$row['topicdesc'];
    $sectionnum=$row['sectionnum'];
    $sectiondesc=$row['sectiondesc'];
    $names=$row['names'];
    $code=$row['code'];
	$x++;
}

$sql = "SELECT * FROM `reviews` where group_id = $groupid";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);

while ($row = mysql_fetch_array($total_result)) {
    $chcktopicnum=$row['topic_id'];
    $chcksectionnum=$row['section_id'];
    $review=$row['review'];
}
	
$sql = "SELECT * FROM `links` where group_id = $groupid";
$total_result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
$total_found = @mysql_num_rows($total_result);
$x=0;
while ($row = mysql_fetch_array($total_result)) {
    $links[$x]=$row['link'];
    $link_id[$x]=$row['id'];
	$x++;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><?php echo $site_name; ?>: Adimin: Image Edit: <?php
echo $topicdesc." : ".$sectiondesc;
?></title>

<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<?php include("../header.inc.php"); ?>
	<table>
		<tr valign="top">
			<?php include("../nav.inc.php"); ?>
			<td class="maincontent">
				<p>Now editing images for the subject:
				<?php
					echo $topicdesc." : ".$sectiondesc;
					
					function br2nl( $data ) {
					   return preg_replace( '!<br.*>!iU', "\n", $data );
					}
					$review = br2nl(str_replace(array("\n", "\r"), "", $review));
				?>
				</p>
				<form action = "editimgsubmit.php" method = "post" enctype = "multipart/form-data">
				<input type = "hidden" name = "top" value = "<?php echo $wantedtopic; ?>" />
				<input type = "hidden" name = "sub" value = "<?php echo $wantedsection; ?>" />
				
				<table>
					<tr style = "font-weight: bold;">
						<td>Image</td>
						<td>HTML</td>
						<td>Change</td>
						<td>Delete</td>
					</tr>
					<?php
					$highimgnum = -1;
					foreach(glob("../reviewpix/$wantedtopic-$wantedsection-*") as $img)
					{
						?>
						<tr>
						<?php
						preg_match("/$wantedtopic-$wantedsection-(\\d*)\\./", $img, $matches);
						$imgnum = $matches[1];
						$highimgnum = max($imgnum, $highimgnum);
						
						echo("<td><img src = \"$img\" /></td>");
						echo("<td>&lt;img src = \"" . str_replace("../reviewpix", "reviewpix", $img) 
							. "\" /></td>");
					    // NOTE: filename realitive to admin/
						echo("<input type = \"hidden\" name = \"filename$imgnum\" value = \"$img\" />");
						echo("<td><input type = \"file\" name = \"upload$imgnum\" />");
						// WARNING: the values of the submit buttons are used in
						// editimgsubmit.php, if these values are changed be sure to change
						// them in editimgsubmit.php, too.
						echo("<input type = \"submit\" name = \"submitupload$imgnum\" value = \"Upload Replacement Image\" /></td>");
						echo("<td><input type = \"submit\" name = \"delete$imgnum\" value = \"Delete This Image\" /></td>");
						?>
						</td>
						<?php
					}
					//print out highest image number so new image can be written one higher.
					echo("<input type = \"hidden\" name = \"highimgnum\" value = \"$highimgnum\" />");
					?>
				</table>
				<br />
				<br />
				New image: <input type = "file" name = "uploadnew" />
				<input type = "submit" name = "uploadnewsubmit" value = "Upload New Image" />
				</form>
				<p>This review was created by: <?php echo $names; ?></p>
			</td>
		</tr>
	</table>
<?php include("../footer.inc.php") ?>
</body>
</html>
Return current item: Standardized Test Practice Engine