Xepher.Net Forums

Community => Knowhow Trading Post => Topic started by: cha0s on June 24, 2006, 12:11:27 AM

Title: PHP newb...
Post by: cha0s on June 24, 2006, 12:11:27 AM
Hey, I'm a real newb with php, and I don't know many functions yet... What I'd like to ask is...

Is there a function I can call to fill an array with the names of the files in a given directory?

I know I can do things like (index.php?filename="blah.txt"), and if I had an array, I could probably foreach it to match if the file exists...

How would I start a download if there was a match in that case..? Is this a bad (not secure) way to go about things?

Thanks for anyone who tries to help...

p.s. i have lots of experience with procedural programming, so i'm not a total dummy... eheh
Title: PHP newb...
Post by: Xepher on June 24, 2006, 12:43:31 AM
Always search http://php.net first. The function list is pretty useful. I believe this is what you want. http://www.php.net/manual/en/function.scandir.php

If you want to check if a file exists, http://www.php.net/manual/en/function.file-exists.php

I'm not sure, however, what you mean by "start a download" in case of a match. What is it you're trying to do.
Title: PHP newb...
Post by: cha0s on June 24, 2006, 01:39:35 AM
Thanks for the linkies, I've been reading php tutes for a while now ;p

I was thinking about having some kind of thing where I could automate downloading music on my page, since as of now it's all hardcoded. I guess I'm hoping that it might look better or something *sigh*. I suck at web design.

btw, I actually got a donation =O 19.12 ...O.o weird number.
Title: PHP newb...
Post by: griever on June 24, 2006, 01:44:01 AM
Maybe the person gave $20 and the 19.12 is after Paypal takes its cut?
Title: PHP newb...
Post by: cha0s on June 24, 2006, 02:01:13 AM
hehe, maybe. After the xepher.net share i get like 14~ bucks. I haven't even taken it yet, I'll leave it in there, and if I realllly need it one day, then it'll be there ;p
Title: PHP newb...
Post by: Databits on June 26, 2006, 08:22:19 PM
I'm thinking of upgrading an account and snagging some paypal direct API code to play with some time in the future.  That way if I ever need to use it in the future I'll have the know how.
Title: PHP newb...
Post by: Xepher on June 26, 2006, 10:15:34 PM
Quote from: cha0shehe, maybe. After the xepher.net share i get like 14~ bucks. I haven't even taken it yet, I'll leave it in there, and if I realllly need it one day, then it'll be there ;p
Actually, your balance reads zero if you login and check it. You have your account set to "passthrough" meaning the full amount goes on to xepher.net. You need to set it to "hold and accumulate" if you want future donations to be held. Either that, or put in a paypal account for them to be sent to. I can manually reverse that previous donation since you seem to have expected t to be held. Let me know if you want me to do that (after you change the option to hold.)


Oh, and the weird amount ($19.12) is because paypal takes their cut of 20. It's something like 30 cents per transaction, then 3% on top of that. That's why it's kinda wasteful to do tiny donations of less than about $5.
Title: PHP newb...
Post by: cha0s on June 27, 2006, 08:14:10 AM
Nah, you know what, keep it Xeph. I did change to accumlate from now on though.

Thanks for hosting my site and music =)


btw, I have another question :P Is there a way to manually set file perms? I'm testing some stuff and i'd like to be able to change them immediately myself if possible. (Yes, I have a server on my computer that I do "real" testing on, but I was going to test to see if I could use the php mail() function from your server, so I could finally give people an easy way to give feedback, if they want...(i hate mailto:))
Title: PHP newb...
Post by: Xepher on June 27, 2006, 09:04:59 AM
Yeah, you can set permissions through FTP as well as SSH/SCP. A lot of FTP client software doesn't support it though. Which is why I always suggest people use http://winscp.net instead. You can easily set permissions with it through the context (right click) menu. PHP files should generally be set to 700 which would be easiest to enter in the "octal" box shown here. http://winscp.net/eng/docs/ui_properties (You may need to enter it as 0700) Or you can just check read/write/execute for Owner (user) and uncheck all permissions for group and other (world.)
Title: PHP newb...
Post by: cha0s on June 27, 2006, 04:02:53 PM
Thanks a lot Xeph. I was glad to see that your server does have SMTP ^^ brilliant. When I asked around a bit a long time ago, everyone said I needed asp. Now I find that php is the OSS answer to php.

Damn I love OSS. ;)