xtrapsp
2012-11-07 05:02:56
PHP Script Repository
Hey guys,
This is my own small project. It's a lite repository which allows people to Share scripts on their own site. I will use Mat as an example… he has a bunch of scripts but lets say he wants to share them… well with a repository he can!
I've only really messed with the back panel however I'm working on a front panel etc :) I'm open to any advice haha.
Thanks!
Features to be included:
Admin Panel:

Credits go to Mat for the inspiration behind this idea however mine is slightly different :)
The layout will change I just want to get the code finished :P
Deleting a script:

Code:
Index.php:
Uploader:
delete.php:
Hey guys,
This is my own small project. It's a lite repository which allows people to Share scripts on their own site. I will use Mat as an example… he has a bunch of scripts but lets say he wants to share them… well with a repository he can!
I've only really messed with the back panel however I'm working on a front panel etc :) I'm open to any advice haha.
Thanks!
Features to be included:
- Inbuilt code editor or previewer
- Along with the top part (Hopefully have it so it removes any usernames and passwords left in by accident
- Categories
Admin Panel:

Credits go to Mat for the inspiration behind this idea however mine is slightly different :)
The layout will change I just want to get the code finished :P
Deleting a script:

Code:
Index.php:
<html><link href="stylesheet.css" rel="stylesheet" type="text/css">
<head>
</head>
<body>
<div id="Container">
<div id="header">
<div id="Statistics"><?php
// integer starts at 0 before counting
$i = 0;
$dir = 'uploads/';
if ($handle = opendir($dir)) {
while (($file = readdir($handle)) !== false){
if (!in_array($file, array('.', '..')) && !is_dir($dir.$file))
$i++;
}
}
// prints out how many are $1 in the directory
echo "There are $i files in the directory";
?></div>
</div>
<div id="upload">
<div id="tabHeader">Upload A Script:</div>
<br>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
<br />
<br>
<input type="submit" value="Upload File" />
</div>
</form>
<div id="DeleteFile">
<div id="tabHeader">Delete A Script:</div>
<!-- This php is the form which grabs s from the directory -->
<form action="delete.php" method="POST">
Choose a file to delete:
<?php
$full_path = "uploads/";
$handle = @opendir($full_path) or die ("Unable to open directory");
echo '<select name="filename">';
while ($file = readdir($handle)) {
if (substr($file,0,1) != ".") {
echo "<option name='deletedfile' value ='$file'>$file</option>";
}
}
echo '</select>';
closedir($handle);
?>
<input type="Submit" value="Delete File" /></form>
</div>
<br>
<div id="Latestuploads">
</div>
</div>
</body>
</html>Uploader:
<html><link href="stylesheet.css" rel="stylesheet" type="text/css">
<head>
</head>
<body>
<div id="Container">
<p>
<div id="header"><p>
<div id="uploaded">
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<img src='images/tick.png' title='Successful' alt='Successful' />";
echo "The file has been uploaded";
} else{
echo "Could not upload file";
}?>
</div>
</div>
</div>
<META HTTP-EQUIV="refresh" CONTENT="5;URL="http://domain.co.uk">
</body>
</html>
delete.php:
<html><link href="stylesheet.css" rel="stylesheet" type="text/css">
<head>
</head>
<body>
<div id="Container">
<p>
<div id="header"><p>
<div id="uploaded">
<?php
$filename = $_POST['filename'];
$directory = 'uploads/';
if (unlink($directory.$filename)) {
echo 'File <strong>' .$filename. ' has successfully been deleted.';
} else {
echo 'Cannot Delete file';
}
echo '<br>'
?>
<?print_r($_POST); die();?>
</div>
</div>
</div>
<META HTTP-EQUIV="refresh" CONTENT="5;URL="http://domain.co.uk">
</body>
</html>
