PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
William
Forum Contributor
Posts: 332 Joined: Sat Oct 25, 2003 4:03 am
Location: New York City
Post
by William » Fri Jan 09, 2004 11:39 pm
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"> <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 }
?>
And is there a way to read the fils in a directory if its not on your server? Thanks
William
Forum Contributor
Posts: 332 Joined: Sat Oct 25, 2003 4:03 am
Location: New York City
Post
by William » Sat Jan 10, 2004 12:28 am
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"> <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 }
?>
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Sat Jan 10, 2004 12:28 am
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
William
Forum Contributor
Posts: 332 Joined: Sat Oct 25, 2003 4:03 am
Location: New York City
Post
by William » Sat Jan 10, 2004 4:59 am
Naughty Naughty nay! Look at the first code you posted... See the hole
thing? haha let me help you
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
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Sat Jan 10, 2004 5:06 am
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.
Nay
Forum Regular
Posts: 951 Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia
Post
by Nay » Sat Jan 10, 2004 6:55 am
AIM? mmm, wonder when was the last time I used it
*covers that message up*
-Nay