Jump to content

Best way to allow loads of uploads on one page?


ActaNonVerba1

Recommended Posts

Heya guys

 

The other day i got the error:

 

[28-Jan-2011 12:07:40] PHP Warning:  POST Content-Length of 16970062 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

 

Basically this means my server provider doesn't allow the total $_POST data on one page to be above 8MB, and being on shared hosting i cannot fix this  :( :(

 

So, whats the best way to get around this? Ajax?

Options and code samples please :)

 

I think this will help a lot of people as i haven't seen many answers after lots of research on the web.

 

Thanks

Danny.

 

This is my code

 

[Page where user uploads files -Edit-Page.php]

<?php
session_start();
if ($_SESSION['adminlogin'] == 1){
	//Run
}
else {
header('Location: Log-In.php');
exit;
}
$url = $_POST['url'];
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Edit Page | Worldwide Lighthouses</title> 
                          <script>
						<!--
						  function fixForm(select) {
							var inputCount = parseInt(select);
							var newHTML = '';
							for(i=1; i<=inputCount; i++) {
							  newHTML += '<label>Thumbnail '+i+' | Size: 200px x 430px | Format: PNG</label>\n'+
										 '<input type="file" name="thumbnail'+i+'" size="100" accept="image/x-png" class="File">\n'+
										 '<label>Accompanying Large Image | Size : Large | Format: PNG</label>\n'+
										 '<input type="file" name="large'+i+'" size="100000000" accept="image/x-png" class="File"><br><br>\n'
										 ;
							  if(i < inputCount) {
								newHTML += '<br>\n\n';
							  } else {
								newHTML += '\n\n';
							  }
							}
							document.getElementById('formInputs').innerHTML=newHTML;
						  }
						//-->

					function setVisibility(id, visibility) {
					document.getElementById(id).style.display = visibility;
					}
						</script>
                <style>
			input:focus, textarea:focus {
			background:#9CDCCB;
			}
			form#Page {
				width:80%;
				margin-top:10px;
				margin-bottom:10px;
				margin-left:auto; margin-right:auto;
				background-colour: rgb(33, 33, 33); /* The Fallback */
				background: rgba(33, 33, 33, 0.;
				border-radius:10px;
				padding:20px;
			}
			label {
				display:block;
				width:100%;
				color:#FFF;
			}
			.TitleInput {
				width:660px;
			}
			.info {
				width:260px;	
				height:80px;
			}
			.url {
				width:660px;
			}
			#IntroParagraph{
				width:660px;
				height:120px;	
			}
			#MainParagraph{
				width:660px;
				height:240px;
			}
			.File {
				width:660px;	
			}
			#loading {
			position: fixed;
			top: 25%;
			left: 25%;
			width: 50%;
			height: 50%;
			background:url(../../layout-resources/article-background.jpg);
			border:3px #333 solid;
			border-radius:10px;
			text-align:center;
			color:#1D5A4B;
			display:none;
			}
			#loadinginfo {
			position: absolute;
			top: 25%;
			left: 25%;
			width: 50%;
			height: 50%;
			}
		</style>
            </head>
<body>
<div id="loading"><div id="loadinginfo"><img src="upload.gif" width="128" height="15" alt="Uploading"><br><h1>Uploading images...</h1><p>Please Wait, this could take a while.</p></div></div>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
        <?php
	if ($_SESSION['adminlogin']==1) {
		echo '<div id="logout">
			  <div style="float:left; width:30%; text-align:left;!important">
			  <a href="Log-In-Accept-Deny.php">Back to Admin Home</a>
			  </div>
			  <div style="float:right; width:70%;">
			  <a href="Logout.php">Log Out of Admin</a>
			  <p style="font-size:10px;">Always Sign Out when Finished!</p>
			  </div></div>';}
?> 
<article>
    <h1 class="Title">Enter Page Information</h1>
  <div class="Textbox"> 
    <form action="Preview-and-Confirm-Page-Changes.php" enctype="multipart/form-data" method="post" id="Page">
    <input type="hidden" value="<?php echo $url ?>" name="url">
    	  <label>Type of Page</label>
          <br>
<input type="radio" name="typeofpage" value="englandtrinityhouse" checked> English - Trinity House <br>
          <input type="radio" name="typeofpage" value="englandprivate"> English - Privately Owned <br>
          <input type="radio" name="typeofpage" value="welshtrinityhouse"> Welsh - Trinity House <br>
          <input type="radio" name="typeofpage" value="welshprivate"> Welsh - Privately Owned <br>
          <input type="radio" name="typeofpage" value="northernlighthouseboard"> Scottish - Northern Lighthouse Board <br>
          <input type="radio" name="typeofpage" value="scottishprivate"> Scottish - Privately Owned <br>
          <input type="radio" name="typeofpage" value="channelislandstrinityhouse"> Channel Islands - Trinity House <br>
          <input type="radio" name="typeofpage" value="channelislandsprivate"> Channel Islands - Privately Owned <br>
          <input type="radio" name="typeofpage" value="francelb"> French - Lighthouse Board <br>
          <input type="radio" name="typeofpage" value="franceprivate"> French - Privately Owned <br>
          <input type="radio" name="typeofpage" value="switzerland"> Switzerland <br>
       	  <input type="radio" name="typeofpage" value="norway"> Norway <br>
          <input type="radio" name="typeofpage" value="lightshiptrinityhouse"> Lightship - Trinity House <br>
          <input type="radio" name="typeofpage" value="lightshipprivate"> Lightship - Private <br>
          <br>
          <label>Folder Name (Usually title of page with hyphens eg. Beachy-Head) Just provide the last section</label>
          <input type="text" name="foldername">
  <label>Title of Page<br>(eg.Beachy Head Lighthouse. Dont Include | Worldwide Lighthouses, this is automatically added)</label><input type="text" placeholder="Title of Page" name="title" class="TitleInput"><br><br>
          <input type="hidden" name="MAX_FILE_SIZE" value="100000000000000000000000000000" />
          <label>Main Page Image | Size: 170x170px Format:PNG</label><input type="file" name="mainpageimage" size="100" accept="image/x-png" class="File"><br><br>
          <h2>Information</h2>
          <label>Date Established:</label><input type="text" placeholder="Date Established" name="established" required="true" class="TitleInput"><br>
          <label>Current Lighthouse Built:</label><input type="text" placeholder="Date Current Lighthouse Established" name="currentlighthousebuilt" required="true" class="TitleInput"><br>
          <label>Height (In Metres, Will automatically convert to show feet and metres on same page)</label><input type="number" placeholder="Heigtht in metres" name="height" required="true" class="TitleInput"><br>
          <label>Date Automated:</label><input type="text" placeholder="Date Automated" name="automated" required="true" class="TitleInput"><br>
          <label>Date Electrified:</label><input type="text" placeholder="Date Electrified" name="electrified" required="true" class="TitleInput"><br>
          <label>Range (In Nautical Miles):</label><input type="number" placeholder="Range in Nautical Miles" name="range" required="true" class="TitleInput"><br>
          <label>Operator:</label><input type="text" placeholder="Operator" name="operator" required="true" class="TitleInput"><br><br> 
          <h2>Media</h2>
          <label>Link to Video Page: (if none leave blank)</label><input type="url" name="video">
          <label>Link to Audio Page: (if none leave blank)</label><input type="url" name="audio">
          <h2>Write up</h2>
          <label>Paragraph:</label><textarea id="MainParagraph" name="paragraph"></textarea>
          <h2>Thumbnails</h2> 
          <label> Number of Thumbnails </label>
          <select name="numberofthumbnails" onChange="fixForm(this.options[selectedIndex].text);"> 
          	<option value="0">0</option>
            <option value="2">2</option>
            <option value="4">4</option>
            <option value="6">6</option>
            <option value="8">8</option>
            <option value="10">10</option>
            <option value="12">12</option>
            <option value="14">14</option>
            <option value="16">16</option>
            <option value="18">18</option>
            <option value="20">20</option>
            <option value="22">22</option>
            <option value="24">24</option>
          </select>      
          <br><br>
          <span id="formInputs">
          </span>
          <input type="submit" value="Preview Page" onClick="setVisibility('loading', 'block');">
    </form>
      <?php
      if ($_SESSION['adminlogin'] == 1){
	echo "<br>Logged in on server side.";
}?>
    </div>
</article>
    <footer>
    <ul>
	<li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

Link to comment
Share on other sites

[Page where data is processed, images are uploaded - Preview-and-Confirm-Page-Changes.php]

<?php
session_start();
if ($_SESSION['adminlogin'] == 1){
	//Run
}
else {
header('Location: Log-In.php');
exit;
}
ini_set($post_max_size,'40M');
$url = $_POST['url'];
$title = $_POST['title'];
$established = $_POST['established'];
$currentlighthousebuilt = $_POST['currentlighthousebuilt'];
$height = $_POST['height'];
$heightinfeet = $height/3.28;
$automated = $_POST['automated'];
$electrified = $_POST['electrified'];
$range = $_POST['range'];
$operator = $_POST['operator'];
$paragraph = $_POST['paragraph'];
$typeofpage = $_POST['typeofpage'];
$foldername = $_POST['foldername'];
$numberofthumbnails = $_POST['numberofthumbnails'];
$videourl = $_POST['video'];
$audiourl = $_POST['audio'];

//Set up colour of page dependant on type of page	
if ($typeofpage=='englandtrinityhouse') 
{ $titletype = 'Title';
  $textboxtype = 'Textbox';
  $sideboxtype = 'Sidebox';
}
if ($typeofpage=='englandprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}
if ($typeofpage=='welshtrinityhouse')
{
  $titletype = 'Title';
  $textboxtype = 'Textbox';
  $sideboxtype = 'Sidebox';
}
if ($typeofpage=='welshprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}
if ($typeofpage=='northernlighthouseboard')
{
  $titletype = 'TitleGold' ;
  $textboxtype = 'TextBoxGold';
  $sideboxtype = 'SideboxGold';
}
if ($typeofpage=='scottishprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}
if ($typeofpage=='channelislandstrinityhouse')
{
  $titletype = 'Title' ;
  $textboxtype = 'Textbox';
  $sideboxtype = 'Sidebox';
}
if ($typeofpage=='channelislandsprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}
if ($typeofpage=='francelb')
{
  $titletype = 'TitleBlack' ;
  $textboxtype = 'TextBoxBlack';
  $sideboxtype = 'SideboxBlack';
}
if ($typeofpage=='franceprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}
if ($typeofpage=='switzerland')
{
  $titletype = 'TitleRed' ;
  $textboxtype = 'TextBoxRed';
  $sideboxtype = 'SideboxRed';
}
if ($typeofpage=='norway')
{
  $titletype = 'TitleRed' ;
  $textboxtype = 'TextBoxRed';
  $sideboxtype = 'SideboxRed';
}	
if ($typeofpage=='lightshiptrinityhouse')
{
  $titletype = 'TitleRed' ;
  $textboxtype = 'TextBoxRed';
  $sideboxtype = 'SideboxRed';
}	
if ($typeofpage=='lightshipprivate')
{
  $titletype = 'TitleBlue' ;
  $textboxtype = 'TextBoxBlue';
  $sideboxtype = 'SideboxBlue';
}	

//Set up which image folder the images will go on, dependent on type of page
if ($typeofpage=='lightshiptrinityhouse')
{
  $folderlocation = 'Lighthships' ;
}
else
{
	if ($typeofpage=='lightshipprivate'){$folderlocation = 'Lightships';}
	else {
		$folderlocation='Lighthouses';
	}
}

//Decide on how many thumbnails to show, based on user input.
	$displaythumbs = '<br>';
	$cd = 0;
	while ($cd < $numberofthumbnails) {
	$cd++;
	$displaythumbs = $displaythumbs. '<div class="ThumbnailHolder">
    	<div class="LeftThumb"><a class="group" href="http://www.worldwidelighthouses.com/Images/'.$folderlocation.'/'.$foldername.'/large-'.$cd.'.png"><img src="http://www.worldwidelighthouses.com/Images/'.$folderlocation.'/'.$foldername.'/Mini/Thumbnail-'.$cd.'.png" width="430" height="200" alt="Thumbnail '.$cd.' - '.$title.'"></a></div>';
	$cd++;
	$displaythumbs = $displaythumbs.'
    	<div class="RightThumb"><a class="group" href="http://www.worldwidelighthouses.com/Images/'.$folderlocation.'/'.$foldername.'/large-'.$cd.'.png"><img src="http://www.worldwidelighthouses.com/Images/'.$folderlocation.'/'.$foldername.'/Mini/Thumbnail-'.$cd.'.png" width="430" height="200" alt="Thumbnail '.$cd.' - '.$title.'"></a></div></div>
';
}	

#################################################################
#####################IMAGE UPLOAD SCRIPT#########################
#################################################################


// Where the mainimage file is going to be placed
$target_path_mainimage = "../../Images/Main-Page-Pictures/";
// Where the thumbnail images will be placed
$target_path_thumbnails = "../../Images/".$folderlocation."/".$foldername."/Mini/";
$target_path_thumbnails_without_mini = "../../Images/".$folderlocation."/".$foldername;

if (file_exists($target_path_thumbnails)) {
	//Do nothing.
} else {
	if (file_exists ($target_path_thumbnails_without_mini)) {
		mkdir($target_path_thumbnails,0777);
	} 
	else {
	mkdir($target_path_thumbnails_without_mini,0777);
	mkdir($target_path_thumbnails,0777);
	}
}	
//Main image location
$target_path_mainimage = $target_path_mainimage.basename($_FILES['mainpageimage']['name']); 
//Larges Image location
$target_path_larges = '../../Images/'.$folderlocation.'/'.$foldername.'/';
//Warnings	
$warnings = '<b>Errors:</b><br>';
//Move the main image file to its location
if(move_uploaded_file($_FILES['mainpageimage']['tmp_name'], $target_path_mainimage)) {
} else{
	$warnings = $warnings."There was an error uploading the main image file, please try again!<br>";
}

//Move the Large Images to their location (But only if they have been uploaded) If not, add an error to the warning log.
if (isset($_FILES['large1'])){
if(move_uploaded_file($_FILES['large1']['tmp_name'], $target_path_larges.'large-1.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 1st large image file, please try again!<br>";
}
}
if (isset($_FILES['large2'])){
if(move_uploaded_file($_FILES['large2']['tmp_name'], $target_path_larges.'large-2.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 2nd large image file, please try again!<br>";
}
}

if (isset($_FILES['large3'])){
if(move_uploaded_file($_FILES['large3']['tmp_name'], $target_path_larges.'large-3.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 3rd large image file, please try again!<br>";
}
}
if (isset($_FILES['large4'])){
if(move_uploaded_file($_FILES['large4']['tmp_name'], $target_path_larges.'large-4.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 4th large image file, please try again!<br>";
}
}
if (isset($_FILES['large5'])){
if(move_uploaded_file($_FILES['large5']['tmp_name'], $target_path_larges.'large-5.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 5th large image file, please try again!<br>";
}
}
if (isset($_FILES['large6'])){
if(move_uploaded_file($_FILES['large6']['tmp_name'], $target_path_larges.'large-6.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 6th large image file, please try again!<br>";
}
}
if (isset($_FILES['large7'])){
if(move_uploaded_file($_FILES['large7']['tmp_name'], $target_path_larges.'large-7.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 7th large image file, please try again!<br>";
}
}
if (isset($_FILES['large8'])){
if(move_uploaded_file($_FILES['large8']['tmp_name'], $target_path_larges.'large-8.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 8th large image file, please try again!<br>";
}
}
if (isset($_FILES['large9'])){
if(move_uploaded_file($_FILES['large9']['tmp_name'], $target_path_larges.'large-9.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 9th large image file, please try again!<br>";
}
}
if (isset($_FILES['large10'])){
if(move_uploaded_file($_FILES['large10']['tmp_name'], $target_path_larges.'large-10.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 10th large image file, please try again!<br>";
}
}
if (isset($_FILES['large11'])){
if(move_uploaded_file($_FILES['large11']['tmp_name'], $target_path_larges.'large-11.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 11th large image file, please try again!<br>";
}
}
if (isset($_FILES['large12'])){
if(move_uploaded_file($_FILES['large12']['tmp_name'], $target_path_larges.'large-12.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 13th large image file, please try again!<br>";
}
}
if (isset($_FILES['large13'])){
if(move_uploaded_file($_FILES['large13']['tmp_name'], $target_path_larges.'large-13.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 14th large image file, please try again!<br>";
}
}
if (isset($_FILES['large14'])){
if(move_uploaded_file($_FILES['large14']['tmp_name'], $target_path_larges.'large-14.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 15th large image file, please try again!<br>";
}
}
if (isset($_FILES['large15'])){
if(move_uploaded_file($_FILES['large15']['tmp_name'], $target_path_larges.'large-15.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 16th large image file, please try again!<br>";
}
}
if (isset($_FILES['large16'])){
if(move_uploaded_file($_FILES['large16']['tmp_name'], $target_path_larges.'large-16.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 17th large image file, please try again!<br>";
}
}
if (isset($_FILES['large17'])){
if(move_uploaded_file($_FILES['large17']['tmp_name'], $target_path_larges.'large-17.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 18th large image file, please try again!<br>";
}
}
if (isset($_FILES['large18'])){
if(move_uploaded_file($_FILES['large18']['tmp_name'], $target_path_larges.'large-18.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 19th large image file, please try again!<br>";
}
}
if (isset($_FILES['large19'])){
if(move_uploaded_file($_FILES['large19']['tmp_name'], $target_path_larges.'large-19.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 20th large image file, please try again!<br>";
}
}
if (isset($_FILES['large20'])){
if(move_uploaded_file($_FILES['large20']['tmp_name'], $target_path_larges.'large-20.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 21st large image file, please try again!<br>";
}
}
if (isset($_FILES['large21'])){
if(move_uploaded_file($_FILES['large21']['tmp_name'], $target_path_larges.'large-21.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 22nd large image file, please try again!<br>";
}
}
if (isset($_FILES['large22'])){
if(move_uploaded_file($_FILES['large22']['tmp_name'], $target_path_larges.'large-22.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 23rd large image file, please try again!<br>";
}
}
if (isset($_FILES['large23'])){
if(move_uploaded_file($_FILES['large23']['tmp_name'], $target_path_larges.'large-23.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 24th large image file, please try again!<br>";
}
}
if (isset($_FILES['large24'])){
if(move_uploaded_file($_FILES['large24']['tmp_name'], $target_path_larges.'large-24.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 3rd large image file, please try again!<br>";
}
}	

//Move the thumbnail images to their location (But only if they have been uploaded) If not, add an error to the warning log.

if (isset($_FILES['thumbnail1'])){
if(move_uploaded_file($_FILES['thumbnail1']['tmp_name'], $target_path_thumbnails.'Thumbnail-1.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 1st thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail2'])){
if(move_uploaded_file($_FILES['thumbnail2']['tmp_name'], $target_path_thumbnails.'Thumbnail-2.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 2nd thumbnail image file, please try again!<br>";
}
}

if (isset($_FILES['thumbnail3'])){
if(move_uploaded_file($_FILES['thumbnail3']['tmp_name'], $target_path_thumbnails.'Thumbnail-3.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 3rd thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail4'])){
if(move_uploaded_file($_FILES['thumbnail4']['tmp_name'], $target_path_thumbnails.'Thumbnail-4.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 4th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail5'])){
if(move_uploaded_file($_FILES['thumbnail5']['tmp_name'], $target_path_thumbnails.'Thumbnail-5.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 5th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail6'])){
if(move_uploaded_file($_FILES['thumbnail6']['tmp_name'], $target_path_thumbnails.'Thumbnail-6.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 6th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail7'])){
if(move_uploaded_file($_FILES['thumbnail7']['tmp_name'], $target_path_thumbnails.'Thumbnail-7.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 7th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail8'])){
if(move_uploaded_file($_FILES['thumbnail8']['tmp_name'], $target_path_thumbnails.'Thumbnail-8.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 8th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail9'])){
if(move_uploaded_file($_FILES['thumbnail9']['tmp_name'], $target_path_thumbnails.'Thumbnail-9.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 9th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail10'])){
if(move_uploaded_file($_FILES['thumbnail10']['tmp_name'], $target_path_thumbnails.'Thumbnail-10.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 10th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail11'])){
if(move_uploaded_file($_FILES['thumbnail11']['tmp_name'], $target_path_thumbnails.'Thumbnail-11.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 11th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail12'])){
if(move_uploaded_file($_FILES['thumbnail12']['tmp_name'], $target_path_thumbnails.'Thumbnail-12.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 13th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail13'])){
if(move_uploaded_file($_FILES['thumbnail13']['tmp_name'], $target_path_thumbnails.'Thumbnail-13.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 14th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail14'])){
if(move_uploaded_file($_FILES['thumbnail14']['tmp_name'], $target_path_thumbnails.'Thumbnail-14.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 15th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail15'])){
if(move_uploaded_file($_FILES['thumbnail15']['tmp_name'], $target_path_thumbnails.'Thumbnail-15.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 16th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail16'])){
if(move_uploaded_file($_FILES['thumbnail16']['tmp_name'], $target_path_thumbnails.'Thumbnail-16.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 17th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail17'])){
if(move_uploaded_file($_FILES['thumbnail17']['tmp_name'], $target_path_thumbnails.'Thumbnail-17.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 18th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail18'])){
if(move_uploaded_file($_FILES['thumbnail18']['tmp_name'], $target_path_thumbnails.'Thumbnail-18.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 19th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail19'])){
if(move_uploaded_file($_FILES['thumbnail19']['tmp_name'], $target_path_thumbnails.'Thumbnail-19.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 20th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail20'])){
if(move_uploaded_file($_FILES['thumbnail20']['tmp_name'], $target_path_thumbnails.'Thumbnail-20.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 21st thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail21'])){
if(move_uploaded_file($_FILES['thumbnail21']['tmp_name'], $target_path_thumbnails.'Thumbnail-21.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 22nd thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail22'])){
if(move_uploaded_file($_FILES['thumbnail22']['tmp_name'], $target_path_thumbnails.'Thumbnail-22.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 23rd thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail23'])){
if(move_uploaded_file($_FILES['thumbnail23']['tmp_name'], $target_path_thumbnails.'Thumbnail-23.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 24th thumbnail image file, please try again!<br>";
}
}
if (isset($_FILES['thumbnail24'])){
if(move_uploaded_file($_FILES['thumbnail24']['tmp_name'], $target_path_thumbnails.'Thumbnail-24.png')) {
} else{
	$warnings = $warnings."There was an error uploading the 3rd thumbnail image file, please try again!<br>";
}
}

$mainimage = 'http://www.worldwidelighthouses.com/Images/Main-Page-Pictures/'.basename($_FILES['mainpageimage']['name']);
##############################################################################
######################### END IMAGE UPLOAD SCRIPT ############################
##############################################################################	

//Generate Media Buttons if needed
if ($audiourl == "") {
    // Do nothing
} else {
	$audiolink = '<div id="Audio"><a href="'.$audiourl.'"><img src="http://www.worldwidelighthouses.com/layout-resources/green-video.png" width="128" height="126" alt="Click to Play Audio">Audio</a></div>';
}

if ($videourl == "") {
    // Do nothing
} else {
	$videolink = '<div id="Video"><a href="'.$videourl.'"><img src="http://www.worldwidelighthouses.com/layout-resources/green-video.png" width="128" height="126" alt="Click to Play Video">Video</a></div>';
}
if ($videourl == "" and $audiourl == ""){
	$videolink = "None available <br><br><br><br>";
}
//Add in spaces when typed by users

function nl2p($string, $line_breaks = false, $xml = false)
{
    // Remove existing HTML formatting to avoid double-wrapping things
    $string = str_replace(array('<p>', '</p>', '<br>', '<br />'), '', $string);
    
    // It is conceivable that people might still want single line-breaks
    // without breaking into a new paragraph.
    if ($line_breaks == true)
        return '<p>'.preg_replace(array("/([\n]{2,})/i", "/([^>])\n([^<])/i"), array("</p>\n<p>", '<br'.($xml == true ? ' /' : '').'>'), trim($string)).'</p>';
    else 
        return '<p>'.preg_replace("/([\n]{1,})/i", "</p>\n<p>", trim($string)).'</p>';
}  

$paragraph = nl2p($paragraph);

$pagecode = ' 
<!DOCTYPE HTML>
<html lang="en-GB">
            <head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="http://www.worldwidelighthouses.com/Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="http://www.worldwidelighthouses.com/Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <link rel="stylesheet" href="http://www.worldwidelighthouses.com/js/Image-Viewer/jquery.fancybox-1.3.4.css" media="screen and (min-width: 481px)">
            <script src="http://www.worldwidelighthouses.com/js/jquery-1.4.3.min.js"></script>
            <script src="http://www.worldwidelighthouses.com/js/Image-Viewer/jquery.fancybox-1.3.4.pack.js"></script>
	    <script src="http://www.worldwidelighthouses.com/js/customTransition.js"></script>
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="http://www.worldwidelighthouses.com/Page-Layout.css"><link rel="stylesheet" href="http://www.worldwidelighthouses.com/js/Image-Viewer/jquery.fancybox-1.3.4.css"><![endif]-->
		<meta name="application-name" content="Worldwide Lighthouses"> 
		<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
		<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
           	<title>'.$title.' | Worldwide Lighthouses</title> 
            </head>
<body>
	 <header>
	 	<h1 id="WWLH">Worldwide Lighthouses</h1>
 	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
     	<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
     	<input type="submit" value="Search">
     	<input type="hidden" name="search" value="1"> 
 	</form>
     </header>
 <nav>
	 	<ul id="Nav">
 		<li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li>
     		<li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
     		<li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li>
     		<li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
     		<li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li>
     		<li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li>
     		<li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li>
     	</ul>
 </nav>
<article>
  <h1 class="'.$titletype.'">'.$title.'</h1>
      <div id="Media"><img src="'.$mainimage.'" width="597" height="557" alt="'.$title.'"></div>
      <div id="Sidebar"> 
      	<div class="'.$sideboxtype.'">
            <h1 class="SideBoxTitle">Information</h1>
            <hr>
            <p>Established: '.$established.'</p>
            <p>Current Lighthouse Built: '.$currentlighthousebuilt.'</p>
            <p>Height: '.$height.' Metres ('.$heightinfeet.' Feet)</p>
            <p>Automated: '.$automated.'</p>
            <p>Electrified: '.$electrified.'</p>
		<p>Light Characteristic: '.$lightchar.'</p>
            <p>Range: '.$range.' Nautical Miles </p>
            <p>Operator: '.$operator.'</p>
        </div>
      	<div class="'.$sideboxtype.'">
      		<h1 class="SideBoxTitle">Media</h1> 
      		<hr>
	'.$videolink.'
	'.$audiolink.'
      	</div>
      	</div>
  	<div class="'.$textboxtype.'"> 
	'.$paragraph.'
	<div id="Social">
	<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="WWlighthouses">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
        <object id="Facebook" data="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fworldwidelighthouses.com/&layout=button_count&show_faces=false&width=450&action=like&colorscheme=light&height=21"></object>  
    </div>
    </div>'.$displaythumbs.'
    </div>
</article>
    <footer>
    <ul>
    	<li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y")?> </footer>
</body>
';
$previewfile = 'temp/preview.php';
$openfile = fopen($previewfile, 'w') or die ("Couldnt't Save Preview File");
$data = $pagecode;
fwrite($openfile, $pagecode);
fclose($openfile);
?>
<!DOCTYPE HTML>
<html lang="en-GB">
<head>
            <meta charset="utf-8">
            <!--Search Engine Meta Tags--> 
            <meta name="author" content="Worldwide Lighthouses">
            <meta name="keywords" content="Lighthouses,Lightships,Trinity House,Fog Signals,Fog Horns,Fresnel">
            <meta name="description" content="Worldwide Lighthouses is the number 1 source of information, pictures and videos on the Subject of Lighthouses and Lightships">
            <!--Stylesheets/Javascript-->
            <link rel="stylesheet" href="../../Page-Layout.css" media="screen and (min-width: 481px)">
            <link rel="stylesheet" href="../../Mobile-Page-Layout.css" media="only screen and (max-width:480px)">
            <!--Mobile Browser Support-->
            <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
            <!--IE Support-->
            <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link rel="stylesheet" href="../Page-Layout.css"><![endif]-->
<meta name="application-name" content="Worldwide Lighthouses"> 
	<meta name="msapplication-starturl" content="http://worldwidelighthouses.com/"> 
        	<meta name="msapplication-tooltip" content="Worldwide Lighthouses: Your number one source of Lighthouse Information, Videos and Pictures"> 
        	<meta name="msapplication-task" content="name=Lighthouses;action-uri=http://worldwidelighthouses.com/Lighthouses.php;icon-uri=http://worldwidelighthouses.com/IE9/Lighthouses.ico"> 
        	<meta name="msapplication-task" content="name=Lightships;action-uri=http://worldwidelighthouses.com/Lightships.php;icon-uri=http://worldwidelighthouses.com/IE9/Lightships.ico"> 
	<meta name="msapplication-task" content="name=Fog Signals;action-uri=http://worldwidelighthouses.com/Fog-Signals.php;icon-uri=http://worldwidelighthouses.com/IE9/Fog-Signals.ico"> 
       		<meta name="msapplication-task" content="name=Glossary;action-uri=http://worldwidelighthouses.com/Glossary.php;icon-uri=http://worldwidelighthouses.com/IE9/Glossary.ico">
            	<title>Confirm Changes to Page | Worldwide Lighthouses</title> 
          </head>
<body>
  <header>
	<h1 id="WWLH">Worldwide Lighthouses</h1>
	<form method="get" action="http://www.worldwidelighthouses.com/Search/search.php" id="Search-Box">
		<input type="search" placeholder="Search Worldwide Lighthouses" name="query" id="query" size="30" value="" autocomplete="off">	
		<input type="submit" value="Search">
           		<input type="hidden" name="search" value="1"> 
  		</form>
</header> 	<nav>
  		<ul id="Nav">
		<li class="MenuButton" id="Index"><a href="http://www.worldwidelighthouses.com/Index.php"><p class="Nav">Home</p></a></li>
       		<li class="MenuButton" id="Lighthouses"><a href="http://www.worldwidelighthouses.com/Lighthouses.php"><p class="Nav">Lighthouses</p></a></li>
       		<li class="MenuButton" id="Lightships"><a href="http://www.worldwidelighthouses.com/Lightships.php"><p class="Nav">Lightships</p></a></li>
       		<li class="MenuButton" id="FogSignals"><a href="http://www.worldwidelighthouses.com/Fog-Signals.php"><p class="Nav">Fog Signals</p></a></li>
            <li class="MenuButton" id="Daymarks"><a href="http://www.worldwidelighthouses.com/Daymarks.php"><p class="Nav">Daymarks</p></a></li>
            <li class="MenuButton" id="Buoys"><a href="http://www.worldwidelighthouses.com/Buoys.php"><p class="Nav">Buoys</p></a></li>
       		<li id="MenuButtonLast"><a href="http://www.worldwidelighthouses.com/Glossary.php"><p class="Nav">Glossary</p></a></li>
	</ul>
</nav>
        <?php
	if ($_SESSION['adminlogin']==1) {
		echo '<div id="logout">
			  <div style="float:left; width:30%; text-align:left;!important">
			  <a href="Log-In-Accept-Deny.php">Back to Admin Home</a>
			  </div>
			  <div style="float:right; width:70%;">
			  <a href="Logout.php">Log Out of Admin</a>
			  <p style="font-size:10px;">Always Sign Out when Finished!</p>
			  </div></div>';}
?> 
<article>
    <h1 class="Title">Page Preview - Confirm Changes</h1>
    <?php if ($warnings == '<b>Errors:</b><br>') {
	//Do Nothing
		}
	else {
       echo '<div style="width:100%; background:red; color:#FFF; border: 3px #333 Solid; border-radius:10px; margin-top:10px;margin-left:auto;margin-right:auto;">'.$warnings.'</div>';
	}
	?>
  <div class="Textbox">
      Save changes? (This cannot be undone)<br>
      <form method="post" action="Save-Page.php" style="display:inline-block;">
      <input type="hidden" name="url" value="<?php $url?>">
      <input type="submit" value="Yes, Save">
      </form>
      <form method="post" action="Edit-Page.php" style="display:inline-block;">
      <input type="hidden" name="url" value="<?php $url?>">
      <input type="submit" value="No, return to edit">
      </form>
      </div>
  <iframe src="temp/preview.php" width="100%" height="1000px"> </iframe>
      <div class="Textbox">
      <?php
      if ($_SESSION['adminlogin'] == 1){
	echo "Logged in on server side.";
}
?>
    </div>
</article>
    <footer>
    <ul>
	<li><a href="http://www.worldwidelighthouses.com/About.php">About</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Contact-us.php">Contact</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Use-Our-Media.php">Use our media</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Search/search.php">Search</a></li>
        <li><a href="http://www.worldwidelighthouses.com/Social-Networking.php">Social</a></li>
        <li><a href="#Top">Back to top</a></li>
    </ul>
    <br>
    <br>
    	&#169; Worldwide Lighthouses <?php echo date("Y"); ?>
</footer>
</body>

 

 

Thanks :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.