Added Readme, setup script and document information header
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* @project: ImgAnnotations
|
||||
* @author: Bram Prieshof
|
||||
*/
|
||||
?>
|
||||
|
||||
<style>
|
||||
a.button {
|
||||
background-color: Gainsboro;
|
||||
@@ -13,10 +20,6 @@
|
||||
|
||||
<?php
|
||||
include 'db.php';
|
||||
//Debug
|
||||
echo "<br>";echo "ID:"; echo $_POST["TheID"];echo "<br>";
|
||||
//EndDebugs
|
||||
|
||||
//Check if data was send
|
||||
if (empty($_POST["TheNewData"])) {
|
||||
echo 'No data has been submitted <br><button onclick="history.back()">Go Back</button>';
|
||||
@@ -39,6 +42,4 @@ else {
|
||||
|
||||
echo 'Data has been saved<br> <a href="Editor.php" class="button">Editor</a><a> </a><a href="Viewer.php" class="button">Viewer</a>';
|
||||
}
|
||||
|
||||
//echo $_POST["TheNewData"]
|
||||
?>
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @project: ImgAnnotations
|
||||
* @author: Bram Prieshof
|
||||
*/
|
||||
|
||||
//ID Check
|
||||
if (empty($_POST["TheID"])) {
|
||||
echo '<style type="text/css">.EditorDialog{display:none;}</style>';
|
||||
|
||||
5
ReadMe.md
Normal file
5
ReadMe.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# ImgAnnotations
|
||||
Basic intergration of picture-annotation library for PHP and MySQL
|
||||
Library link: https://github.com/mkalus/picture-annotation
|
||||
|
||||
Inital setup can be done after cloning into a webroot with PHP, and then going to setup.php
|
||||
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* @project: ImgAnnotations
|
||||
* @author: Bram Prieshof
|
||||
*/
|
||||
|
||||
//ID Check
|
||||
if (empty($_POST["TheID"])) {
|
||||
echo '<style type="text/css">.EditorDialog{display:none;}</style>';
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @project: ImgAnnotations
|
||||
* @author: Bram Prieshof
|
||||
*/
|
||||
|
||||
// DB Credentials
|
||||
define('DB_HOST', 'localhost');
|
||||
|
||||
90
setup.php
Normal file
90
setup.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @project: ImgAnnotations
|
||||
* @author: Bram Prieshof
|
||||
*/
|
||||
|
||||
//NOTE That sample file need to be in the same folder and be called "db.php.sample"
|
||||
|
||||
//seting Vars
|
||||
//Location of sample config file
|
||||
$sampleconfigfilePath = 'db.php.sample';
|
||||
//Location of new config file
|
||||
$configfilePath = 'db.php';
|
||||
//Name of SQL File
|
||||
$sqlfileName = 'DB-Template.sql';
|
||||
|
||||
if(isset($_POST['submit']))
|
||||
{
|
||||
//Get the form data
|
||||
$DBName = $_POST["DBName"];
|
||||
$DBUser = $_POST["DBUser"];
|
||||
$DBPass = $_POST["DBPassword"];
|
||||
|
||||
echo "$DBname";
|
||||
echo "$DBUser";
|
||||
echo "$DBpass";
|
||||
//Open your .txt file
|
||||
$filecontent = file_get_contents("$sampleconfigfilePath");
|
||||
$filecontent = str_replace("DBName","$DBName",$filecontent);
|
||||
$filecontent = str_replace("DBUserName","$DBUser",$filecontent);
|
||||
$filecontent = str_replace("DBPassword","$DBPass",$filecontent);
|
||||
$file = fopen("$configfilePath", 'w+');
|
||||
ftruncate($file, 0);
|
||||
fwrite($file , $filecontent);
|
||||
fclose($file);
|
||||
die(header("Location: setup.php?step=2"));
|
||||
}
|
||||
$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 1;
|
||||
?>
|
||||
|
||||
<?php
|
||||
$serv = $_SERVER['PHP_SELF'];
|
||||
|
||||
if ($step == '1') {
|
||||
echo"Setup Database connection";
|
||||
echo"<form method='post' action='$serv'>";
|
||||
echo "DBName:<br><input type='text' name='DBName' ><br>";
|
||||
echo "DBUser:<br><input type='text' name='DBUser' ><br>";
|
||||
echo "DBPassword:<br><input type='password' name='DBPassword' ><br>";
|
||||
echo "<input type='submit' name='submit' value='Create config' ><br>";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
if ($step == '2') {
|
||||
echo "<a href='setup.php?step=1'>If conection faild click here</a><br>";
|
||||
require_once "$configfilePath";
|
||||
mysqli_close($mysqli);
|
||||
header("Location: setup.php?step=3");
|
||||
}
|
||||
|
||||
|
||||
if ($step == '3') {
|
||||
echo "Populating DB";
|
||||
require_once "$configfilePath";
|
||||
$templine = '';
|
||||
$lines = file($sqlfileName);
|
||||
$error = '';
|
||||
foreach ($lines as $line){
|
||||
if(substr($line, 0, 2) == '--' || $line == ''){
|
||||
continue;
|
||||
}
|
||||
$templine .= $line;
|
||||
if (substr(trim($line), -1, 1) == ';'){
|
||||
if(!$mysqli->query($templine)){
|
||||
$error .= 'Error performing query "<b>' . $templine . '</b>": ' . $mysqli->error . '<br /><br />';
|
||||
}
|
||||
$templine = '';
|
||||
}
|
||||
}
|
||||
header("Location: setup.php?step=4");
|
||||
}
|
||||
|
||||
if ($step == '4') {
|
||||
echo "Setup done,removed unnecessary setup files<br><a href='/'>Go to index</a>";
|
||||
unlink("$sqlfileName");
|
||||
unlink("$sampleconfigfilePath");
|
||||
unlink('setup.php');
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user