![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5
![]() |
I started learning php 3 days ago, so my code might not be so good.....
I am (trying to) make a code repository using text files, below is the basic code I have done so far. At the moment this is not fully functional.... Index.php <HTML> <a href="admin.php">Admin</a> <BR> <a href="seecode.php">Browse Code</a> <BR> <a href="addcode.php">Add Code</a> </HTML> seecode.php <?PHP
$lang = $_POST['lang'];
echo '<form method="POST">';
echo '<select name="lang">';
$d = opendir('langs/');
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
echo '<option value="langs/'.$f.'/">'.$f;
}
}
echo '</select>';
echo '<input type="submit" value=" Go--> " name="submit">';
echo '</form>';
if ($lang != '')
{
$d = opendir($lang);
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
$lines = file($lang.$f);
echo '<A HREF="'.$lang.$f.'" target="tehframe">'.$lines[0].'</A><BR>';
}
}
}
?>
<HTML>
<BR><BR><BR>
<iframe width="100%" height="300" name="tehframe"></iframe>
</HTML>addcode.php <?PHP
$lang = $_POST['lang'];
$title = $_POST['title'];
$code = $_POST['code'];
$agree = $_POST['agree'];
echo '<form method="POST">';
echo '<select name="lang">';
$d = opendir('langs/');
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
echo '<option value="langs/'.$f.'">'.$f;
}
}
echo '</select>';
echo '<input type="text" value="Title" name="title"><BR>';
echo '<input type="submit" value=" Post--> " name="submit">';
echo '</form>';
if ($agree == 'YES')
{
$code = $title.'<BR>'.'CODE: <BR><BR>'.$code;
$title = $lang.$title.'.txt';
$file = fopen($title,'w+');
}
?>admin.php <?PHP
if ($_POST['pass'] =='password'){
echo 'Admin control panel';
}
else
{
echo<<<END
<form method="post">
Password?
<input type="text" name="pass">
<input type="submit" value="Go-->">
</form>
END;
}I think I will be able to upload a working version this weekend ![]()
__________________
[SIGPIC][/SIGPIC] |
|
|
|
|
|
#2 |
|
Expert Programmer
|
Sounds Good
![]() |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
Cool, will you have it live somewhere?
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I suggest looking into MySQL.
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
This is a good idea Overmind. I was thinking of having a code repository to my site... I'll check out your code for that purpose... I agree with Ooble about MySQL... but at the moment MySQL is giving me fits on Fedora Core 3 w/ Apache.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#6 | |
|
Professional Programmer
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5
![]() |
I was thinking of making one with MySQL as well, after this.
As it stands now, it works (but with no admin options)...but there are people who just want to mess things up, eg making a title 100 characters long. Lots needs to be done... Quote:
__________________
[SIGPIC][/SIGPIC] |
|
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5
![]() |
Are there any features you people think I could add?
__________________
[SIGPIC][/SIGPIC] |
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5
![]() |
Well, I have finished it, though there are still things I want to add and change, but the same basic code will be the same. here it is I have trashed the idea of an admin place for now.
index.php <HTML class="body"><LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<A HREF="addcode.php">Add Code</A>
<table border="0">
<tr>
<td valign="top">
<?PHP
$lang = $_POST['lang'];
echo '<form method="POST">';
echo '<select name="lang" class="inputbutton">';
$d = opendir('langs/');
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
echo '<option value="langs/'.$f.'/">'.$f;
}
}
echo '</select>';
echo '<input type="submit" value=" Go--> " name="submit" class="inputbutton">';
echo '</form>';
if ($lang != '')
{
$d = opendir($lang);
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
$lines = file($lang.$f);
$title = $lines[2];
$num = 20;
if(strlen($title) > $num)
{
$temp = substr( $title, 0, $num-2);
$temp .= "...";
$title = $temp;
}
echo '<A HREF="'.$lang.$f.'" target="tehframe">'.$title.'</A><BR>';
}
}
}
?>
<HTML></td>
<td>
<BR><BR>
<iframe width="650" height="300" name="tehframe" align="center"></iframe>
</td>
</tr>
</table>
<BR><BR>
<font color="white" size="1">
<CENTER>--------------------------------<BR>
c0de rep0sit0ry v1.0<BR>
<A HREF="http://www.jethro.za.net/">www.jethro.za.net</a></font>
</HTML>addcode.php <HTML class="body"><LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<A HREF="index.php" class="hover">Browse Code</A><BR><BR>
<?PHP
$lang = $_POST['lang'];
$title = $_POST['title'];
$code = $_POST['code'];
$agree = $_POST['agree'];
echo '<form method="POST">';
echo '<textarea cols=80 rows=10 name="code" class="inputbutton"></textarea><BR><BR>';
echo 'Language? <select name="lang" class="inputbutton">';
$d = opendir('langs/');
while (false !== ($f = readdir($d))) {
if ($f == '..' || $f == '.') { $f = '';}
else {
echo '<option value="langs/'.$f.'">'.$f;
}
}
echo '</select><BR>';
echo 'Title? <input type="text" value="Title" name="title" class="inputbutton"><BR>';
echo 'Do you agree to our <A href="conditions.php" target="blahwin">"terms & conditions</a>? <select name="agree" class="inputbutton">';
echo '<option value="NO">NO';
echo '<option value="YES">YES';
echo '</select><BR>';
echo '<input type="submit" value=" Post--> " name="submit" class="inputbutton"><BR>';
echo '</form>';
if ($agree == 'YES')
{
$name = strftime('%c');
$code = ">TITLE<\n---------\n".$title."\n\n>CODE<\n---------\n".$code;
$title = $lang."/".$name.'_'.$title.'.txt';
$file = fopen($title,'w+');
$code = stripslashes($code);
fwrite($file,$code);
fflush($file);
fclose($file);
}
?>
<HTML>
<BR><BR>
<font color="white" size="1">
<CENTER>--------------------------------<BR>
c0de rep0sit0ry v1.0<BR>
<A HREF="http://www.jethro.za.net/">www.jethro.za.net</a></font>
</HTML><style>
.inputbox {
border-top:#333333 solid thin;
border-bottom:#333333 solid thin;
border-right:#333333 solid thin;
border-left:#333333 solid thin;
font-family: verdana, helvetica, sans-serif;
color: #57c6f9;
background-color: #57c6f9
}
.inputbutton {
font-size: 100%;
font-family: verdana, helvetica, sans-serif;
color: #FFFFFF;
background-color: #57c6f9
}
.body {
background-color: #57c6f9
}
</style>:dancing:
__________________
[SIGPIC][/SIGPIC] |
|
|
|
|
|
#9 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
![]() |
|
|
|
|
|
|
#10 |
|
Programming Guru
![]() ![]() ![]() |
Looks pretty cool Overmind... I added a good-bye world prog, just for testing... please delete it... The only thing I can think of that would be helpful at this stage is the ability to tab for indentation when adding code... but that's really a luxury, not a necessity. Good job man.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|