Author Topic: PHP newb...  (Read 9871 times)

0 Members and 1 Guest are viewing this topic.

cha0s

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Me on xepher.net
PHP newb...
« 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
xepher puts the SEXY in DYSLEXIA

My Music!
FreeBASIC rox hard

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,325
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
PHP newb...
« Reply #1 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.

cha0s

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Me on xepher.net
PHP newb...
« Reply #2 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.
xepher puts the SEXY in DYSLEXIA

My Music!
FreeBASIC rox hard

griever

  • Sr. Member
  • ****
  • Posts: 457
    • View Profile
PHP newb...
« Reply #3 on: June 24, 2006, 01:44:01 am »
Maybe the person gave $20 and the 19.12 is after Paypal takes its cut?
"You can get all A's and still flunk life." (Walker Percy)

cha0s

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Me on xepher.net
PHP newb...
« Reply #4 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
xepher puts the SEXY in DYSLEXIA

My Music!
FreeBASIC rox hard

Databits

  • Global Moderator
  • *****
  • Posts: 1,607
  • Programming's not just a science, it's an art.
    • View Profile
PHP newb...
« Reply #5 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.
(\_/)    ~Relakuyae D'Selemae
(o.O)    
(")_(")  [Libre Office] [Chrome]

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,325
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
PHP newb...
« Reply #6 on: June 26, 2006, 10:15:34 pm »
Quote from: cha0s
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
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.

cha0s

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Me on xepher.net
PHP newb...
« Reply #7 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:))
xepher puts the SEXY in DYSLEXIA

My Music!
FreeBASIC rox hard

Xepher

  • Techsmith
  • Administrator
  • *****
  • Posts: 4,325
  • Illegitimis non carborundum!
    • View Profile
    • Xepher.net
PHP newb...
« Reply #8 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.)

cha0s

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • Me on xepher.net
PHP newb...
« Reply #9 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. ;)
xepher puts the SEXY in DYSLEXIA

My Music!
FreeBASIC rox hard