Skip to content

Commit

Permalink
WIP: almost there!
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRannou committed Dec 2, 2011
1 parent 21d2d46 commit 515045d
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 101 deletions.
63 changes: 34 additions & 29 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
# imagebank

FEATURES:
-MAMP, javascipt and html
-easy setup
-admin secured area
-encrypted passwords in db
-php page requires login (if user not logged in an tries to access page, he is redirected to login page)
-secured against sql injection (TODO: check the command too)
-upload image
-can run any command from convert (maybe not enough restricted...?)
-for each user: 1 folder for original and 1 folder for processed images


# Pre requiered
MySQL
Php
Apache

ImageMagick
http://www.imagemagick.org/script/binary-releases.php
put location in script

# Extract files
1-copy this folder to your websites directory

# Create MySQL user
2-phpMyadmin: add user that we will use
2- check create table with same name
2-check create table with same name
3-update user and pass in admin/.my.conf

# Install image magick
5-http://www.imagemagick.org/script/binary-releases.php
6-update "$env_vars" in ajax/executecommand.php (mac issue?)

# Choose admin password
4-update admin password
7-get new username and passord
http://www.addedbytes.com/lab/password-protect-a-directory-with-htaccess/#result
8- update admin/.htpasswd

FEATURES:
-MAMP, javascipt and html
-easy setup
-admin secured area
-encrypted passwords in db
-php page requires login (if user not logged in an tries to access page, he is redirected to login page)
-secured against sql injection (TODO: check the command too)
-upload image
-can run any command from convert (maybe not enough restricted...?)
-for each user: 1 folder for original and 1 folder for processed images
-if file already on server it's fine
# Create the tables
9- go to the website, to the admin section: imagebank/admin
10- enter your username, password then create DB

# Everything is setup now!

TODO:
-preview not saved
Expand All @@ -41,16 +51,11 @@ TODO:
-login page refresh
-upload/process update DB
-2 images with same name..?

user modifies password
admin modifies pass
admin can do more stuffs -> send emails to user,

limit size max of image directory
some refresh issues, field are getting empty, etc.

chmod 777 some files
images still visible after refresh

command modified
check command input
-save images in db
-user modifies password
-admin modifies pass
-admin can do more stuffs -> send emails to user,
-limit size max of image directory
-some refresh issues, field are getting empty, etc.
-check valid emails, etc.
-check command input
10 changes: 6 additions & 4 deletions ajax/executecommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
$image = $_SESSION["currentimage"];


$test = split("\.", $image, 2);
$test2 = split("\/", $test[0], 4);
$imagenoextension = split("\.", $image, 2);
$location = split("\/", $imagenoextension[0], 4);
$filter = split(" ", $command, 3);

$newimage = $test2[0] . "/" . $test2[1] . "/modified/" . $test2[3] . $filter[1] . "." . $test[1];
$newimage = $location[0] . "/" . $location[1] . "/modified/" . $location[3] . $filter[1] . $filter[2] . "." . $imagenoextension[1];

# session variables
$_SESSION["newimage"] = $newimage;
$_SESSION["command"] = $command;

$env_vars = "/Users/nr52/INSTALL/ImageMagick-6.7.3/bin/";

# clean the command
$fullcommand = $env_vars . escapeshellarg($command) . " ../" . $image . " ../" . $newimage;
$fullcommand = $env_vars . $command . " ../" . $image . " ../" . $newimage;

system($fullcommand);

Expand Down
Binary file added bank/.DS_Store
Binary file not shown.
Binary file removed bank/original/25696c5.jpg
Binary file not shown.
Binary file removed bank/rannou/modified/25696c5-flip-rotate.jpg
Binary file not shown.
Binary file removed bank/rannou/modified/25696c5-flip.jpg
Binary file not shown.
Binary file removed bank/rannou/modified/25696c5-rotate.jpg
Binary file not shown.
Binary file removed bank/rannou/original/25696c5-flip.jpg
Binary file not shown.
Binary file removed bank/rannou/original/25696c5.jpg
Binary file not shown.
Binary file removed bank/rannou/original/arrow_down.png
Binary file not shown.
46 changes: 1 addition & 45 deletions css/registeredarea.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,16 @@ margin:0;
padding:0
}

#slidedown_top {
height: 70px;
background-color:#666;
}

#slidedown_bottom {
position: absolute;
width: 100%;
height:100%;
background-color:#666;
}

#slidedown_content {
position: absolute;
width: 100%;
height: 250px;
top: -205px;
text-align:center;
background:url(libs/bg.gif) repeat-x 0 bottom;
z-index:999;
}

#slidedown_content .content {
margin:0 auto;
width:830px;
height:205px;
}

/* Styles for content */

#slidedown_content .content .block {
float:left;
width:250px;
padding:0 4px 0 4px;
margin: 0 4px 0 4px;

text-align:left;
font-family:georgia;
font-size:11px;
color:#ccc;
}

#slidedown_content .footer {
height:40px;
}

#slidedown_content .content li {
padding:0;
margin:4px 0
}

.clear {clear:both}

.example {
.demo {
float: left;
margin: 15px;
}
Expand Down
18 changes: 9 additions & 9 deletions register.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@
{
?>

<p>Enter account informations</p>
<form method="post">
<p>
Email*: <input type="text" name="email"><br>
Password*: <input type="text" name="pass"><br>
<input type="submit" value="Register">
</p>
<p>* Required fields</p>
</form>
<p>Enter account informations</p>
<form method="post">
<p>
Email*: <input type="text" name="email"><br>
Password*: <input type="text" name="pass"><br>
<input type="submit" value="Register">
</p>
<p>* Required fields</p>
</form>

<?php
}
Expand Down
18 changes: 12 additions & 6 deletions registeredarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@
require("login.php");
?>

<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Registered area</title>

<!-- requiered scripts -->

<script type="text/javascript" src="js/ajax.js"></script>
<link href="css/registeredarea.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="libs/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="libs/js/jquery.easing.1.3.js"></script>
<script src="libs/jqueryFileTree.js" type="text/javascript"></script>
<link href="libs/jqueryFileTree.css" rel="stylesheet" type="text/css" media="screen" />

<!-- Create the tree and input in javascript -->

<script type="text/javascript">
var directory = '../../bank/';
var a = "<?php echo $_SESSION['myemail']; ?>";
var full = String(directory.concat(a));
var full2 = full.concat("/");
var myemail = "<?php echo $_SESSION['myemail']; ?>";
var fullpath = directory.concat(myemail);

$(document).ready( function() {
$('#fileTree').fileTree({ root: full2, script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
$('#fileTree').fileTree({ root: fullpath.concat("/"), script: 'libs/connectors/jqueryFileTree.php' }, function(file) {
openImage(file)
;}) ;});
$(document).ready(function() {
Expand All @@ -37,7 +43,7 @@
<body>

<div id="slidedown_bottom">
<div class="example">
<div class="demo">
<h2>
<?php echo 'Welcome ' ?>
<?php echo $_SESSION["myemail"] ?>
Expand Down
7 changes: 0 additions & 7 deletions todo.txt

This file was deleted.

2 changes: 1 addition & 1 deletion upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
else {
echo "Sorry, there was a problem uploading your file.";
}
echo "<meta http-equiv='refresh' content='5;url=registeredarea.php'>";
echo "<meta http-equiv='refresh' content='2;url=registeredarea.php'>";
?>

0 comments on commit 515045d

Please sign in to comment.