SRL Archive - Research & Development Lounge

PHP Repository


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:

  • 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>

CynicRus

2012-11-07 05:19:20

Nice. Keep it up!

Kyle Undefined

2012-11-07 17:25:58

Why no database?

xtrapsp

2012-11-07 17:40:03

From: Kyle Undefined
Why no database?


I could hook it up to a database :) This is early stages!

footballjds

2012-11-07 18:01:21

I'll stick to svn and google code. but nice project man (:

xtrapsp

2012-11-07 18:02:49

From: footballjds
I'll stick to svn and google code. but nice project man (:


Haha thats all fine :P I'm only doing it for the sakes of it… might never finish it depends if I get bored etc

Kyle Undefined

2012-11-07 19:33:18

GitHub works just as good.

xtrapsp

2012-11-07 19:34:15

From: Kyle Undefined
GitHub works just as good.


I Know… this is as I stated just a small project of mine…

Justin

2012-11-07 21:29:18

Nice work you have there Brad. Keep it up

LordJashin

2012-11-09 18:31:11

Don't go on here much. But couldn't resist on this one, here is me and ShadowRecon's (mostly shadows) script uploader thingy:


site is here if anyone is interested in the dead thing. You don't get access to this though unless me and shadow make you a script dev on the forums…

xtrapsp

2012-11-09 18:48:14

I really like that project of yours, it's developed alot further than mine :P Goodluck with it

Dgby714

2012-11-09 20:00:26

Ew, PHP, I'd have went with python….

Might make one too, tho Wizzup did make Kirby, might use that as a base and add administration and users =)

xtrapsp

2012-11-09 21:38:18

From: Dgby714
Ew, PHP, I'd have went with python….

Might make one too, tho Wizzup did make Kirby, might use that as a base and add administration and users =)


Only learning PHP cause it's what Wordpress uses and I started to learn it. From that point onwards it became semi-fluent :P

grats

2012-11-13 06:54:27

pretty cool, I like to learn with silly projects

why do you have two </html> in everything?

xtrapsp

2012-11-13 07:25:21

From: grats
pretty cool, I like to learn with silly projects

why do you have two </html> in everything?


I don't know O.o probably a typo. Thanks for spotting :)

grats

2012-11-14 01:58:53

From: xtrapsp
I don't know O.o probably a typo. Thanks for spotting :)


lol I was tired as shit when I noticed that.. read through it like 20 times trying to see if the php was printing a page if something else it'd print another page (which makes sense to have two html start / close etc) but that's clearly not the case.. I guess I just couldn't figure it out

also what are the bottom meta tags? I've never really done any meta tag stuff, but those are the auto refresh ones? or auto redirect, why two?

xtrapsp

2012-11-14 04:11:05

From: grats
lol I was tired as shit when I noticed that.. read through it like 20 times trying to see if the php was printing a page if something else it'd print another page (which makes sense to have two html start / close etc) but that's clearly not the case.. I guess I just couldn't figure it out

also what are the bottom meta tags? I've never really done any meta tag stuff, but those are the auto refresh ones? or auto redirect, why two?


auto redirect after a set amount of seconds :)

grats

2012-11-14 04:57:54

From: xtrapsp
auto redirect after a set amount of seconds :)


Yea, why are there two though O_o

xtrapsp

2012-11-14 05:10:33

From: grats
Yea, why are there two though O_o


Fixed. Haha Thanks

NKN

2012-11-14 06:48:33

From: xtrapsp
Fixed. Haha Thanks


<p>


You going to make this complete, then start a whole website on it for the users of SRL? ;)

xtrapsp

2012-11-17 07:42:16

From: NKN
<p>


You going to make this complete, then start a whole website on it for the users of SRL? ;)


I don't think I've constructed the base properly to handle lots of users… its more for specific scripters to distribute their scripts :P