<?php
// INCLUDE HEADER IN PAGE
include('other_header.php');
// GET CURRENT DATE AND TIME
$date = date('Y-m-d H:i:s');
if(isset($_POST['success'])) {
	if($_POST['success'] == 'loggedin') {
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong>Well done!</strong> Successfully logged in.
	</div>
	<?php
	}
}

///////////////////////////////////////////////////////////////////
			if(isset($_POST['submitimage'])) {
				$name = $_POST['name'];
				$directory = $_POST['directory'];
				$activated = $_POST['activated'];
				$version = $_POST['version'];
				$masterfile = $_POST['masterfile'];
				$headername = $_POST['headername'];
				$backfile = $_POST['backfile'];
				$data1 = $_POST['data1'];
				$data2 = $_POST['data2'];
				$data3 = $_POST['data3'];
				$data4 = $_POST['data4'];
				$data5 = $_POST['data5'];
				$data6 = $_POST['data6'];
				$data7 = $_POST['data7'];
				$data8 = $_POST['data8'];
				$data9 = $_POST['data9'];
				$data10 = $_POST['data10'];
				$sqledit = mysql_query("INSERT INTO Web_Plugins VALUES('','$name','$activated','1','$directory','$version','$masterfile','$headername','$backfile','$data1','$data2','$data3','$data4','$data5','$data6','$data7','$data8','$data9','$data10')");
						
				?>
					<div style="margin-top: -80px;" class="alert alert-success" role="alert">
						<strong>Well done!</strong> Plugin created
					</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
			if(isset($_POST['editimage'])) {
				$imageid = $_POST['imageid'];
				$name = $_POST['name'];
				$directory = $_POST['directory'];
				$activated = $_POST['activated'];
				$version = $_POST['version'];
				$masterfile = $_POST['masterfile'];
				$headername = $_POST['headername'];
				$backfile = $_POST['backfile'];
				$data1 = $_POST['data1'];
				$data2 = $_POST['data2'];
				$data3 = $_POST['data3'];
				$data4 = $_POST['data4'];
				$data5 = $_POST['data5'];
				$data6 = $_POST['data6'];
				$data7 = $_POST['data7'];
				$data8 = $_POST['data8'];
				$data9 = $_POST['data9'];
				$data10 = $_POST['data10'];
				$sqledit = mysql_query("UPDATE Web_Plugins SET name='$name',directory='$directory',activated='$activated',version='$version',masterfile='$masterfile',headername='$headername',backfile='$backfile',data1='$data1',data2='$data2',data3='$data3',data4='$data4',data5='$data5',data6='$data6',data7='$data7',data8='$data8',data9='$data9',data10='$data10' WHERE id='$imageid'");
						
				?>
					<div style="margin-top: -80px;" class="alert alert-success" role="alert">
						<strong>Well done!</strong> Plugin edited
					</div>
				<?php

			}// WHEN FORM NOT SUBMITTED
///////////////////////////////////////////////////////////////////
if(isset($_POST['deleterequest'])) {
	$imageid = $_POST['imageid'];
	$delete = mysql_query("DELETE FROM Web_Plugins WHERE id='$imageid'");
	?>
	<div style="margin-top: -80px;" class="alert alert-success" role="alert">
		<strong>Well done!</strong> Plugin successfully deleted.
	</div>
	<?php
}
?>
  <div class="container">
    <div class="text-center">
      <h1><?php echo $title; ?>
      	<small>/Active is: Admin Account
			</small>
		</h1>
 	 </div>
 	 </br>
 	 <?php
 	 	if(isset($_POST['editrequest'])) {
 	 		$imageid = $_POST['imageid'];
 	 		$pgs = mysql_query("SELECT * FROM Web_Plugins WHERE id='$imageid'");
			$pgsr = mysql_fetch_array($pgs);
			
			$name = $pgsr['name'];
			$directory = $pgsr['directory'];
			$activated = $pgsr['activated'];
			$version = $pgsr['version'];
			$masterfile = $pgsr['masterfile'];
			$headername = $pgsr['headername'];
			$backfile = $pgsr['backfile'];
			$data1 = $pgsr['data1'];
			$data2 = $pgsr['data2'];
			$data3 = $pgsr['data3'];
			$data4 = $pgsr['data4'];
			$data5 = $pgsr['data5'];
			$data6 = $pgsr['data6'];
			$data7 = $pgsr['data7'];
			$data8 = $pgsr['data8'];
			$data9 = $pgsr['data9'];
			$data10 = $pgsr['data10'];
	?>
		<div class="row">
      <div class="col-md-10 col-md-offset-1">
		<div class="well">
			<div class="row">
				<center>
				<form name="csrf_form" id="campaignform" action="" method="POST">
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<input type='hidden' name='imageid' value='<?php echo $imageid; ?>'>
							<input class="form-control" value='<?php echo $name; ?>' placeholder="Plugin Name" name="name" type="text">
							<input class="form-control" value='<?php echo $directory; ?>' placeholder="Plugin directory" name="directory" type="text">
							<input class="form-control" value='<?php echo $activated; ?>' placeholder="Activated" name="activated" type="text">
							<input class="form-control" value='<?php echo $version; ?>' placeholder="Version" name="version" type="text">
							<input class="form-control" value='<?php echo $masterfile; ?>' placeholder="Master File [File to load all functions]" name="masterfile" type="text">
							<input class="form-control" value='<?php echo $headername; ?>' placeholder="Admin Header Menu Name" name="headername" type="text">
							<input class="form-control" value='<?php echo $backfile; ?>' placeholder="Admin BackEnd .php file" name="backfile" type="text">
							<input class="form-control" value='<?php echo $data1; ?>' placeholder="data1" name="data1" type="text">
							<input class="form-control" value='<?php echo $data2; ?>' placeholder="data2" name="data2" type="text">
							<input class="form-control" value='<?php echo $data3; ?>' placeholder="data3" name="data3" type="text">
							<input class="form-control" value='<?php echo $data4; ?>' placeholder="data4" name="data4" type="text">
							<input class="form-control" value='<?php echo $data5; ?>' placeholder="data5" name="data5" type="text">
							<input class="form-control" value='<?php echo $data6; ?>' placeholder="data6" name="data6" type="text">
							<input class="form-control" value='<?php echo $data7; ?>' placeholder="data7" name="data7" type="text">
							<input class="form-control" value='<?php echo $data8; ?>' placeholder="data8" name="data8" type="text">
							<input class="form-control" value='<?php echo $data9; ?>' placeholder="data9" name="data9" type="text">
							<input class="form-control" value='<?php echo $data10; ?>' placeholder="data10" name="data10" type="text">
							<span class="input-group-btn">
								<input value="Edit template" class="btn btn-default" style="width: 150px;" name="editimage" type="submit">
							</span>
					</div>
					<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
				</form>
				</br>
				</center>
			</div>
        </div>
      </div>
    </div>
	<?php
	}
	if(!isset($_POST['editrequest'])) {
 	 ?>
	<div class="row">
      <div class="col-md-10 col-md-offset-1">
		<div class="well">
			<div class="row">
				<center>
				<form name="csrf_form" id="campaignform" action="" method="POST">
					<div data-original-title="Enter your long URL" data-toggle="tooltip" data-placement="top" title="555" class="input-group">
							<input class="form-control" placeholder="Plugin Name" name="name" type="text">
							<input class="form-control" placeholder="Plugin directory" name="directory" type="text">
							<input class="form-control" placeholder="Activated" name="activated" type="text">
							<input class="form-control" placeholder="Version" name="version" type="text">
							<input class="form-control" placeholder="Master File [File to load all functions]" name="masterfile" type="text">
							<input class="form-control" placeholder="Admin Header Menu Name" name="headername" type="text">
							<input class="form-control" placeholder="Admin BackEnd .php file" name="backfile" type="text">
							<input class="form-control" placeholder="data1" name="data1" type="text">
							<input class="form-control" placeholder="data2" name="data2" type="text">
							<input class="form-control" placeholder="data3" name="data3" type="text">
							<input class="form-control" placeholder="data4" name="data4" type="text">
							<input class="form-control" placeholder="data5" name="data5" type="text">
							<input class="form-control" placeholder="data6" name="data6" type="text">
							<input class="form-control" placeholder="data7" name="data7" type="text">
							<input class="form-control" placeholder="data8" name="data8" type="text">
							<input class="form-control" placeholder="data9" name="data9" type="text">
							<input class="form-control" placeholder="data10" name="data10" type="text">
							<span class="input-group-btn">
								<input value="Create Plugin" class="btn btn-default" style="width: 150px;" name="submitimage" type="submit">
							</span>
					</div>
					<input type="hidden" name="csrf_token" value="<?php echo $token; ?>">
				</form>
				</br>
				</center>
			</div>
        </div>
      </div>
    </div>
    	<?php
 		}
	 	?>
	
   <div class="text-center">
      <h1><small>Templates</small></h1>
 	</div>
		<div class="col-sm-12">
          <table class="table table-bordered" style="width:100%;max-width:100%"  data-effect="fade">
										<thead>
											<tr>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>#</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Name</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'>Directory</th>
												<th style='color: #DF691A; background-color: #2B3E50;border-collapse: collapse;border: 1px solid #DF691A;'><?php echo $a061; ?></th>
											</tr>
										</thead>
											<?php
			$query = "SELECT * FROM Web_Plugins ORDER BY id ASC";
			$result = mysql_query($query) or die('Error, query failed');

			// print the random numbers
			
			if(mysql_num_rows($result)<1){
   echo "
						<tr>
							<td>No Templates</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
   ";
   }else{
	$numberoflink = 0;
     while($row = mysql_fetch_array($result))
				{
						$numberoflink = $numberoflink + 1;
						?>
										<tr>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $numberoflink; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['name']; ?></h5>
											</td>
											<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
												<h5><?php echo $row['directory']; ?></h5>
											</td>
											<form name='actions' action='' method='POST'>
												<td style='color: #FFF; background-color: #DF691A;border-collapse: collapse;border: 1px solid #2B3E50;'>
													<input type='hidden' name='imageid' value='<?php echo $row['id'];?>'>
													<?php
													if($row['turnable'] == 0) {
														?>
														<input style='float:right' value='System built' class='btn btn-default' type='button'>
														<?php
													}else {
														?>
														<input style='float:right' name='deleterequest' value='Delete' class='btn btn-default' type='submit'>
														<input style='float:right' name='editrequest' value='Edit' class='btn btn-default' type='submit'>
														<?php
													}
													?>
												</td>
											</form>
										</tr>
						<?php 
				}

       }
	?>
									</table>
        </div>
</div>

<?php
include('other_footer.php');
?>
