Location: PHPKode > scripts > CosmicBannerRotator > bannerrotator/printform.inc.php
<?

##-----------------------------------------------------------------##
##                                                                 ##
##                                                                 ##
## © Copyright Stephen Heylings 2003. All rights reserved. No part ##
## of this or any of the attached documents shall be               ##
## reproduced/stored in any way whatsoever without written         ##
## permission from the Copyright holder.                           ##
##   The Copyright holder holds no responsibility for errors or    ##
## omissions. No liability is assumed in any way for damages       ##
## resulting from the use of this document/program.                ##
##                                                                 ##
## Have a nice day.                                                ##
##                                                                 ##
##                                                                 ##
##-----------------------------------------------------------------##


function printform($message="")
	{
		global $lines, $thisfile;

#<-----
		print <<<EndHTML
<html>
<div align=right><font face='Verdana, Arial, Helvetica, sans-serif' size=2><a href="javascript:window.location='banner.php'">logout</a></font></div>
<div align=center><font face='Verdana, Arial, Helvetica, sans-serif' color='#336699' size=5>Banner Configuration</font></div>
<br>
<div align=center><font face='Verdana, Arial, Helvetica, sans-serif' color='#993333' size=3>$message</font></div>
<br>
<body>

<form method='POST' name=picker action='$thisfile'>

<table cellSpacing='0' cellPadding='0' width='500' bgColor='#336699' border='0' align='center'><tr><td>


	<table border='0' cellSpacing='1' cellPadding='4' width='500' height='300' align='center'>
		<tr bgColor='#abd1fc'>
			<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>
			Image Url
			</font></td>
			<td colspan='2'><input size='50' type='text' name='src' /></td>
		</tr>

		<tr bgColor='#abd1fc'>
			<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>
			Alt Text
			</font></td>
			<td colspan='2'><input type='text' name='alt' /></td>
		</tr>

		<tr bgColor='#abd1fc'>
			<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>
			Alignment
			</font></td>
			<td colspan='2'>
			<font face='Verdana, Arial, Helvetica, sans-serif' size=2>Left</font>
			<input type=checkbox name=left>
			<font face='Verdana, Arial, Helvetica, sans-serif' size=2>&nbsp;&nbsp;Center</font>
			<input type=checkbox name=center>
			<font face='Verdana, Arial, Helvetica, sans-serif' size=2>&nbsp;&nbsp;Right</font>
			<input type=checkbox name=right>
			</td>
		</tr>

		<tr bgColor='#abd1fc'>
			<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>
			Preceeding Text
			</font></td>
			<td colspan='2'><input type='text' name='text' /></td>
		</tr>

		<tr bgColor='#abd1fc'>
			<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>
			Link
			</font></td>
			<td colspan='2'><input type='text' name='link' /></td>
		</tr>

		<tr bgColor='#abd1fc' height='*'>
			<td colspan='3' valign='bottom' align='center'><img name='pic' /><br><br></td>
		</tr>

	</table>	
	</td></tr></table>
	<br>
<table cellSpacing='0' cellPadding='0' width='500' bgColor='#336699' border='0' align='center'><tr><td>	
	<table border='0' cellSpacing='1' cellPadding='4' width='500' align=center>
		<tr bgColor='#abd1fc'>
			<td align='center' colspan='3'>
				<select name=sel onchange=chooseimg()>

EndHTML;
#----->

		#print option list of pictures
		reset ($lines);
		while (list ($key, $val) = each ($lines))
		{
			$parts=split("¦", $val);
			echo "					<option value=".$key.">".$parts['0']."</option>";
		}#endwhile



#<-----
print <<<EndHTML
				</select>
			</td>
		</tr>

		<tr bgColor='#abd1fc'>
			<td>
				<input align=left onclick=setMethod('add')  type='submit' value='Add banner'>
			</td>
			<td>
				<input align=center onclick=setMethod('update')  type='submit' value='Update banner'>
			</td>
			<td>
				<input align=right onclick=setMethod('remove') type='submit' value='Remove banner'>
			</td>
		</tr>
	</table>
	</td></tr></table>
	
	<input type='hidden' name='method'>
	<input type='hidden' name='key'>
	<input type='hidden' name='pos'>
</form>

<script language=javascript>
	var alt = new Array();
	var src = new Array();
	var link = new Array();
	var text = new Array();
	var pos = new Array();
EndHTML;
#----->


	#print javascript variable declarations
	reset ($lines);
	while (list ($key, $val) = each ($lines))
	{
	  $parts=split("¦", $val);
	  echo "  src['$key']='".$parts['0']."';";
	  echo "  alt['$key']='".$parts['1']."';";
		echo "  text['$key']='".$parts['2']."';";	  
	  echo "  link['$key']='".$parts['3']."';";
	  echo "  pos['$key']='".$parts['4']."';";
	}#endwhile

	
	
		
#<-----
print <<<EndHTML
function chooseimg()
{
	document.images.pic.alt=alt[document.picker.sel.value];
	document.images.pic.src=src[document.picker.sel.value];
	
	document.picker.alt.value=alt[document.picker.sel.value];
	document.picker.src.value=src[document.picker.sel.value];
	document.picker.link.value=link[document.picker.sel.value];
	document.picker.text.value=text[document.picker.sel.value];

	document.picker.left.checked = false;
	document.picker.right.checked = false;
	document.picker.center.checked = false;
			
	switch (pos[document.picker.sel.value])
	{
		case 'left':
			document.picker.left.checked = true;
			break;
		case 'right':
			document.picker.right.checked = true;
			break;			
		case 'center':
			document.picker.center.checked = true;
			break;			
	}
}

chooseimg();

function setMethod(method)
	{
		document.picker.method.value=method;
		document.picker.key.value=document.picker.sel.value;
		if(document.picker.right.checked){document.picker.pos.value='right'}
		if(document.picker.left.checked){document.picker.pos.value='left'}
		if(document.picker.center.checked){document.picker.pos.value='center'}
	}

	</script>

	</body>
	</html>
EndHTML;
	#---->
}#endfunction

function login($message="")
{
print <<<EndHTML

	<html>
	<form name=login method=post action=banner.php>
	
	<div align=center><font face='Verdana, Arial, Helvetica, sans-serif' color='#336699' size=5>Log-in</font></div>
	<br>
	<div align=center><font face='Verdana, Arial, Helvetica, sans-serif' color='#993333' size=3>$message</font></div>	
	<br>
	<table cellSpacing='0' cellPadding='0' width='250' bgColor='#336699' border='0' align='center'><tr><td>
	<table border='0' cellSpacing='1' cellPadding='4' width='250' align='center'>
	<tr bgColor='#abd1fc'>
		<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>Username:</font></td>
		<td><input type=text name=user /></td>
	</tr>
	
	<tr bgColor='#abd1fc'>
		<td><font face='Verdana, Arial, Helvetica, sans-serif' size=2>Password:</font></td>
		<td><input type=password name=pass /></td>
	</tr>
	</table>
	</table>
	<br>
	<div align=center><input type=submit value='Log In' /></div>
		<input type=hidden name=method value=admin />
		
		</form>
	</html>

EndHTML;
	
}#endfunction

	function checkpass()
	{
	
	  
	  $user = $_POST['user'];
	  $pass = $_POST['pass'];
	  $filename = "$user.txt";
	  
	  if (is_writable($filename))
		{
		  #open file to read
		  if (!$handle = fopen($filename, 'r+'))
		  {
		  	#failed to open file
		  	return false;
		  }#endif
		        
		  $contents = fread ($handle, filesize ($filename));
		  		       
		  fclose($handle);
		}#endif
		else
		{
		  #file not writable-ie user doesn't exist
		  return false;
  	}#endelse
	  
	  
	  if (crypt($pass,$contents) == $contents) 
	  {
			#correct password
			return true;
		}
		else
		{
			#wrong password
			return false;
		}
	  
	}

?>
Return current item: CosmicBannerRotator