Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Existing Project Development (http://www.programmingforums.org/forum51.html)
-   -   Code Repository Thingy (http://www.programmingforums.org/showthread.php?t=1471)

Overmind Dec 8th, 2004 2:52 PM

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;
}

other: a directory named "langs"

I think I will be able to upload a working version this weekend :)

thechristelegacy Dec 8th, 2004 4:47 PM

Sounds Good :)

Pizentios Dec 8th, 2004 4:47 PM

Cool, will you have it live somewhere?

Ooble Dec 8th, 2004 6:32 PM

I suggest looking into MySQL.

Infinite Recursion Dec 8th, 2004 8:07 PM

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.

Overmind Dec 10th, 2004 12:09 PM

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:

Cool, will you have it live somewhere?
When it works properly. :wacko:

Overmind Dec 10th, 2004 12:35 PM

Are there any features you people think I could add?

Overmind Dec 10th, 2004 9:29 PM

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.
:D

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.css
:

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

A least it works....for now....until someone breaks it.
:dancing:

Ooble Dec 11th, 2004 5:54 AM

Quote:

Originally posted by Overmind@Dec 11 2004, 03:29 AM
A least it works....for now....until someone breaks it.
:dancing:

I'll get right on it. :lol:

Infinite Recursion Dec 11th, 2004 9:08 PM

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.


All times are GMT -5. The time now is 2:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC