Page 1 of 1

[SOLVED]Deleate the extention while reading a directory?

Posted: Fri Jan 09, 2004 11:39 pm
by William
Hello, I am trying to read a directory but i want it to deleate the extention zip and replace it with .rwx, Now I can make it put .rwx on it with out replacing it. Is it possible to make this put the directorys files to .rwx? or jsut deleate teh externtions all together? heres teh code:

Code: Select all

<?php
if( $user == "(Deleated)" && $pass == "(Deleated)" ) {
$dirname = "./";
$dh = opendir($dirname) or die("Can't Open:" . $dirname);

while ($file = readdir($dh)) {
	if(is_file($dirname.$file)) {
echo "$file<br />";
	} else {
Print "Sorry, There has been an error.";
	}
}

closedir($dh);
} Else { ?>
<html>
<head>
<title>Sign In</title>
</head>
<body bgcolor="#FFFFFF">
<form action="<?php $PHP_SELF ?>" method="post" name="form">
<table cellpadding="0" cellspacing="0" width="225"align="center" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid;">
<tr>
<th>Sign In</th>
</tr>
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" width="225" align="center" style="border-top: #000000 1px solid;">
<tr>
<td width="100">&nbsp;&nbsp;<b>Username</b>:</td>
<td width="175"><input type="text" name="user" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<td width="100">&nbsp;&nbsp;<b>Password</b>:</td>
<td width="175"><input type="password" name="pass" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<th width="225" colspan="2"><input type="submit" name="submit" value="Enter" style="border-top: #FFFFFF 1px solid; border-right: #FFFFFF 1px solid; border-bottom: #FFFFFF 1px solid; border-left: #FFFFFF 1px solid; background: #FFFFFF; color: #000000;" /></th>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php }
?>

And is there a way to read the fils in a directory if its not on your server? Thanks

Posted: Sat Jan 10, 2004 12:28 am
by William
here is the code:

Code: Select all

<?php
if( $user == "(Deleated)" && $pass == "(Deleated)" ) {
$dirname = "./";
$dh = opendir($dirname) or die("Can't Open:" . $dirname);

while ($file = readdir($dh)) {
	if(is_file($dirname.$file)) {
$file = explode(".", $file);
$file = $file[0];
echo "{$file}.rwx<br />";
	} else {
Print "Sorry, There has been an error.";
	}
}

closedir($dh);
} Else { ?>
<html>
<head>
<title>Sign In</title>
</head>
<body bgcolor="#FFFFFF">
<form action="<?php $PHP_SELF ?>" method="post" name="form">
<table cellpadding="0" cellspacing="0" width="225"align="center" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid;">
<tr>
<th>Sign In</th>
</tr>
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" width="225" align="center" style="border-top: #000000 1px solid;">
<tr>
<td width="100">&nbsp;&nbsp;<b>Username</b>:</td>
<td width="175"><input type="text" name="user" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<td width="100">&nbsp;&nbsp;<b>Password</b>:</td>
<td width="175"><input type="password" name="pass" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<th width="225" colspan="2"><input type="submit" name="submit" value="Enter" style="border-top: #FFFFFF 1px solid; border-right: #FFFFFF 1px solid; border-bottom: #FFFFFF 1px solid; border-left: #FFFFFF 1px solid; background: #FFFFFF; color: #000000;" /></th>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php }
?>

Posted: Sat Jan 10, 2004 12:28 am
by Nay
He's got it fixed after bothering me in MSN =\.

Code: Select all

<?php
if( $user == "(Deleated)" && $pass == "(Deleated)" ) {
$dirname = "./";
$dh = opendir($dirname) or die("Can't Open:" . $dirname);

while ($file = readdir($dh)) {
   if(is_file($dirname.$file)) {
$file = explode(".", $file);
$file = $file[0];
echo "{$file}.rwx<br />";
   } else {
Print "Sorry, There has been an error.";
   }
}

closedir($dh);
} Else { ?>
<html>
<head>
<title>Sign In</title>
</head>
<body bgcolor="#FFFFFF">
<form action="<?php $PHP_SELF ?>" method="post" name="form">
<table cellpadding="0" cellspacing="0" width="225"align="center" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid;">
<tr>
<th>Sign In</th>
</tr>
<tr>
<td>
<table cellpadding="5" cellspacing="0" border="0" width="225" align="center" style="border-top: #000000 1px solid;">
<tr>
<td width="100">  <b>Username</b>:</td>
<td width="175"><input type="text" name="user" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<td width="100">  <b>Password</b>:</td>
<td width="175"><input type="password" name="pass" style="border-top: #000000 1px solid; border-right: #000000 1px solid; border-bottom: #000000 1px solid; border-left: #000000 1px solid; background: #FFFFFF; color: #000000;" /></td>
</tr>
<tr>
<th width="225" colspan="2"><input type="submit" name="submit" value="Enter" style="border-top: #FFFFFF 1px solid; border-right: #FFFFFF 1px solid; border-bottom: #FFFFFF 1px solid; border-left: #FFFFFF 1px solid; background: #FFFFFF; color: #000000;" /></th>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php }
?>
Basicly, he only needed to add:

Code: Select all

$file = explode(".", $file);
$file = $file[0];
echo "{$file}.rwx<br />";
doh! =D =\

-Nay

Posted: Sat Jan 10, 2004 4:59 am
by William
Naughty Naughty nay! Look at the first code you posted... See the hole

Code: Select all

<?php }
thing? haha let me help you :-)

Code: Select all

<?php } ?>
:-P And I didn;t bother you on MSN i send you a message on PHPDN and you biuged me on MSN :-) Good day its 4:50 AM here and i was up till 7:00 AM yestyuday and woke up ast 12:00 PM 5 hours of slep wasnt fun night all

Posted: Sat Jan 10, 2004 5:06 am
by JAM
I'm thinking about posting a sticky;
You are also welcome to message Nay personally on AIM if you have ANY problem...
He likes that.
;)

Posted: Sat Jan 10, 2004 6:55 am
by Nay
AIM? mmm, wonder when was the last time I used it :lol:

*covers that message up*

-Nay