Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 8th, 2004, 2:52 PM   #1
Overmind
Professional Programmer
 
Overmind's Avatar
 
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5 Overmind is on a distinguished road
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
__________________
[SIGPIC][/SIGPIC]
Overmind is offline   Reply With Quote
Old Dec 8th, 2004, 4:47 PM   #2
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 707
Rep Power: 4 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Sounds Good
thechristelegacy is offline   Reply With Quote
Old Dec 8th, 2004, 4:47 PM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Cool, will you have it live somewhere?
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Dec 8th, 2004, 6:32 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I suggest looking into MySQL.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 8th, 2004, 8:07 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,464
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Dec 10th, 2004, 12:09 PM   #6
Overmind
Professional Programmer
 
Overmind's Avatar
 
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5 Overmind is on a distinguished road
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:
__________________
[SIGPIC][/SIGPIC]
Overmind is offline   Reply With Quote
Old Dec 10th, 2004, 12:35 PM   #7
Overmind
Professional Programmer
 
Overmind's Avatar
 
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5 Overmind is on a distinguished road
Are there any features you people think I could add?
__________________
[SIGPIC][/SIGPIC]
Overmind is offline   Reply With Quote
Old Dec 10th, 2004, 9:29 PM   #8
Overmind
Professional Programmer
 
Overmind's Avatar
 
Join Date: Jun 2004
Location: South Africa, Johannesburg
Posts: 301
Rep Power: 5 Overmind is on a distinguished road
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.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:
__________________
[SIGPIC][/SIGPIC]
Overmind is offline   Reply With Quote
Old Dec 11th, 2004, 5:54 AM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 11th, 2004, 9:08 PM   #10
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,464
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:57 AM.

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