View Single Post
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