1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Administration</title>
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<style rel="stylesheet" type="text/css">
#myTable{
outline:none;
clear:left;
display:inline-block;
}
tr, td,th{
border-collapse: collapse;
border:1px solid;
border-radius:4px;
padding:2px;
}
th{
background-color:#FABA48;
}
td{
height:22px;
min-width:125px;
background-color:#FAD884;
}
nav[data-type="table-tools"] ul li{
display:inline-block;
list-style-type:none;
margin-right:10px;
background-color:darkgoldenrod;
border-radius:5px;
padding:5px;
}
#deleteButtons td{
background-color:darkgoldenrod;
}
nav[data-type="table-tools"] ul li a, #deleteButtons a{
font-weight:bold;
text-decoration:none;
color:#000;
opacity:0.6;
}
nav[data-type="table-tools"] ul li:hover > a, #deleteButtons a:hover{
color:#FFF;
}
#deleteButtons{
display:inline-block;
clear:right;
text-align:center;
}
</style>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">"http://jquery.com"</script>
<script type="text/javascript">
$(document).ready(function(){$("#deleteButtons").css("display","none");var getTable=function(){$("#myTable").html("");$.get("myTable.html",function(callback_data){var table=callback_data;document.getElementById("myTable").innerHTML=table})};getTable();$("#addRow").click(function(event){event.preventDefault();var colNumber=$($("#myTable tbody tr")[0]).children("td").length;var tr=document.createElement("tr");var td="";for(var i=0;i<colNumber;i++){td=document.createElement("td");td.appendChild(document.createTextNode("\n"));
tr.appendChild(td)}$("#myTable tbody").append(tr)});$("#addColumn").click(function(event){event.preventDefault();$.each($("#myTable table thead tr"),function(){$(this).append("<th></th>")});$.each($("#myTable table tbody tr"),function(){$(this).append("<td></td>")})});$("#saveTable").click(function(event){event.preventDefault();var table=$("#myTable").html();$.post("saveTable.php",{"myTable":table},function(callback_data){$("#myTable").slideToggle("fast");if($("#deleteButtons")[0].style.display!=
"none")$("#deleteButtons").slideToggle("fast");setTimeout(function(){getTable();setTimeout(function(){$("#myTable").slideToggle();if($("#deleteButtons")[0].style.display=="none")$("#deleteButtons").slideToggle()},50)},500)})});$("#deleteRow").click(function(){if($("#deleteButtons")[0].style.display!="none"){$(this).text("Show Delete Table");$("#deleteButtons").slideToggle("fast")}else{showDeleteTable();$(this).text("Hide Delete Table")}});$("body").on("click","a.deleteRow",function(){var index=$(this).data("row-number");
$("#myTable table tbody").children("tr").eq(index).remove();showDeleteTable()});$("body").on("click","a.deleteColumn",function(){var index=$(this).data("column-number");$("#myTable table thead tr").children("th").eq(index).remove();$.each($("#myTable table tbody tr"),function(){$(this).children("td").eq(index).remove()});showDeleteTable()});function showDeleteTable(){$("#deleteButtons").html("<thead><tr><th>Delete Row</th><th>Delete Column</th></tr></thead><tbody></tbody>");var rowCount=$("#myTable table tbody tr").length;
var columnCount=$("#myTable table tbody tr").eq(0).children("td").length;var tbody=$("#deleteButtons tbody");for(var i=1;i<=rowCount;i++){var tr=document.createElement("tr");if(rowCount>1)$(tr).append('<td><a href="#" class="deleteRow" data-row-number="'+(i-1)+'">Delete Row '+i+"</a></td>");else $("#deleteButtons thead tr th").eq(0).remove();if(i<=columnCount&&columnCount>1)$(tr).append('<td><a href="#" class="deleteColumn" data-column-number="'+(i-1)+'">Delete Column '+i+"</a></td>");tbody.append(tr)}$("#deleteButtons").show()}
});
</script>
<?php
if(isset($_POST['submit'])){
$productID = $_POST['productid'];
if(empty($productID)){
die("Please enter the Product ID!");
}
$folderName = "upload_folder";
if ( !file_exists($folderName) ) {
mkdir($folderName,0775);
}
$uploadDir = $folderName. '/';
$image_name = $productID;
$allowedExts = array("gif", "jpeg", "jpg", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 20971520)
&& in_array($extension, $allowedExts)){
if ($_FILES["file"]["error"] > 0){
echo "ERROR CODE: " . $_FILES["file"]["error"];
}else{
$path_parts = pathinfo($_FILES["file"]["name"]);
$extension = $path_parts['extension'];
$final_name = $uploadDir . $image_name . '.' . $extension;
move_uploaded_file($_FILES["file"]["tmp_name"], $final_name);
echo "Image Uploaded Sucessfully to: " . $final_name;
}
}else{
echo "INVALID FILE";
}
http://georgiouminecraft.weebly.com/Uploaded files
}
?>
</head>
<body>
<h1>Table administration</h1>
<form method="post" action="" enctype="multipart/form-data">
Product ID<input type="text" name="productid" id="productid" value="" /><br />
<input type="file" name="file" id="file" /><br />
<input type="submit" name="submit" value="Upload File" />
</form>
<br /><br />
<section>
<article>
<div id="myTable" contenteditable></div>
<table id="deleteButtons">
<thead><tr><th>Delete Row</th><th>Delete Column</th></tr></thead>
<tbody></tbody>
</table>
<nav data-type="table-tools">
<ul>
<li>
<a href="#" id="addRow">New row</a>
</li>
<li>
<a href="#" id="addColumn">New column</a>
</li>
<li>
<a href="#" id="saveTable">Save table</a>
</li>
<li><a href="#" id="deleteRow">Show Delete Table</a></li>
</ul>
</nav>
</article>
</section>
</body>
</html>
|