Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Commit

Permalink
Global : 1st commit of my 1st PHP project
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Baptiste FAREZ committed Dec 2, 2013
0 parents commit 1910f55
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 0 deletions.
690 changes: 690 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
__UploadStation__ is a simple file upload tool that allow to publish files and
provide a web access to it.

![](http://i.imgur.com/UrXGXsk.png)

Features
--------

- Simple and unpretentious web interface.
- Generate uniq url.
- Store files in distinct directories.
- Send mail to the user when the file is uploaded.
- Can filter allowed file type (MIME).


Download
--------

Source is hosted on github:

[github.com/jbfarez/uploadstation](http://github.com/jbfarez/uploadstation)


Requirements
------------

* A safe webserver ;-)
* PHP 5.2 or higher

This application was tested on Linux Debian 6.0 (Squeeze) with PHP 5.3.3
1 change: 1 addition & 0 deletions _htpasswd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<MY_USER>:<MY_CRYPTED_PASSWORD>
30 changes: 30 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
## Global configuration
## --
$config = array( 'url' => 'http://<URL>', # Base URL (http://dl.mysite.com)
'port' => '<PORT>', # If different of 80
'uploadDir' => '/data/uploader', # Root directory for uploads
'linkDir' => '/sites/uploader/links', # Links storage
'urlDir' => 'links', # Directory url
'maxFileSize' => '104857600', # Define max upload file size
);

## Upload configuration
## --

# Allowed file type
$allowed = array( 'application/vnd.ms-word' => 'doc',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
'application/vnd.ms-excel' => 'xls',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
'application/vnd.ms-powerpoint' => 'ppt',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx',
'application/pdf' => 'pdf',
'application/x-pdf' => 'pdf',
'image/jpeg' => 'jpg',
'image/gif' => 'gif',
'image/png' => 'png',
'application/zip' => 'zip',
);

?>
47 changes: 47 additions & 0 deletions css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
font-size: 14px;
background-color: white;
font-family: 'Lucida Grande', Tahoma, Arial, Helvetica, sans-serif;
}

div#main {
width: 1024px;
margin-left: auto;
margin-right: auto;
padding: 10px;
border-radius: 15px 15px 15px 15px;
background-color: white;
z-index: 1;!important;
position: relative;
}

div#header {
width: 940px;
height: 79px;
margin: 15px 15px;
background :url(../static/images/banniere.jpg) left no-repeat;
}

div#header a {
display: block;
width: 241px;
height: 79px;
background: url(../static/images/logo.png) right no-repeat;
float: right;
}

div#uploadForm {
margin: 15px 15px;
}

div#footer {
margin: auto;
margin-top: 15px;
text-align: center;
font-size: 10px;
clear: both;
}
38 changes: 38 additions & 0 deletions functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// JS function library for Uploader
// --

// FIXME : This is not yet implemented to interface
// but the concept is to allow notifications
// to multiple contacts
function addDest(){
fields = 0;
var cont = document.getElementById('mailForm');

if ( fields <= 4 ){
var div = document.createElement('div');

var inp = document.createElement('input');
inp.type = 'text';
inp.name = 'mail[]';
inp.size = '40';
inp.maxlength = '100';
inp.setAttribute('onChange', 'addDest(this)');

stringAppend(div, 'E-Mail 2 : ');
div.appendChild(inp);
cont.appendChild(div);

fields += 1;
}else{
document.getElementById('mailForm').innerHTML += "<br/>Only 4 upload fields allowed.";
document.createElement.disabled = true;
}
}

function stringAppend( o , s ){
if ( typeof(o.textContent) != 'undefined' ){
o.textContent += s;
}else{
o.firstChild.nodeValue += s;
}
}
76 changes: 76 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

require('config.php');
require('upload.php');
require('mail.php');

?><!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<link rel="icon" href="./favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="./favicon.ico">

<link rel="stylesheet" href="css/global.css" type="text/css">

<script type="text/javascript" src="functions.js"></script>

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Upload Station</title>
</head>
<body>

<div id="main">
<?php
try{
process_post();
}catch(Exception $e){
echo '<div id=error>'.$e->getMessage().'</div>';
}
?>
<div id="header">
<a href="index.php"></a>
</div>
<div id="uploadForm">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
<table border=0 align=center>
<tr>
<td colspan=2 align=center bgcolor="#aba49e" style="padding:10px;margin:10px;border-radius:10px 10px;">
<font color="white" size="5">File Store</font>
</td>
</tr>
<tr>
<td border=1 colspan=2 style="padding:10px;margin:10px;" bgcolor="white">
<font color="#aba49e" size="5">File informations</font><br/>
<li>Max file size : <b>100 Mo</b></li>
<li>Max files : <b>Illimit&eacute;</b></li>
<li>Max retention time : <b>15 Days</b></li>
<li>Authorized file type : <b>Office documents (doc[x],xls[x],ppt[x]), PDFs, Images, Archives .zip</b></li>
<font color="red" size="1">* Warning : File name cannot contain any blank spaces, you can substitute it by - or _ .</font>
</td>
</tr>
<tr>
<td colspan=2 style="padding:10px;margin:10px;" bgcolor="white">
<b>File to upload<font color="red"> *</font> :</b>
<input id="fileName" type="file" name="fileName">
</td>
</tr>
<tr>
<td colspan=2 style="padding:10px;margin:10px;" bgcolor="white">
<font color="#aba49e" size="5">Contact informations</font><br/>
E-Mail : <input id="mail" type="text" name="sender" size="40" maxlength="100"><br/>
<br/>
</td>
</tr>
<tr>
<td align=center style="padding:10px;margin:10px;">
<input type="submit" name="send" value="Envoyer"></td>
</tr>
</table>
</form>
</div>
<div id="footer">
&copy; <b>#YOUR_SIGN#</b> <?php echo date('Y'); ?> - <a href="<A_CONTACT_FORM>">Contact</a>
</div>
</div>
</body>
</html>
25 changes: 25 additions & 0 deletions mail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
function sendMyMail($mailto, $link){
global $config;

$to = $mailto;
$subject = '<MAIL_SUBJECT>';

$message = "
<html>
<head>
<title>A file has been uploaded ...</title>
</head>
<body>
#HTML_BODY#
</body>
</html>
";

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf8' . "\r\n";
$headers .= 'From: #FROM_FIELD# <#FROM_EMAIL#>' . "\r\n";

mail($to, $subject, $message, $headers);
}
?>
Loading

0 comments on commit 1910f55

Please sign in to comment.