This repository has been archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Global : 1st commit of my 1st PHP project
- Loading branch information
Jean-Baptiste FAREZ
committed
Dec 2, 2013
0 parents
commit 1910f55
Showing
9 changed files
with
1,107 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<MY_USER>:<MY_CRYPTED_PASSWORD> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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é</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"> | ||
© <b>#YOUR_SIGN#</b> <?php echo date('Y'); ?> - <a href="<A_CONTACT_FORM>">Contact</a> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
?> |
Oops, something went wrong.