Welcome to Esato.com




a few more new webside coding questions

Click to view updated thread with images


Posted by EastCoastStar
okay, i have a few new coding questions. i want a page where users can load songs and stuff to a folder on my site. so i have a folder named "anything", i want users, from the web, to be able to load songs, pictures, whatever they want. ALSO IF POSSIABLE, i want them to have to have a username and password. if not, thats fine. i can always create a password protected page.

ANOTHER THING...

im looking for a code for people to play music on their myspace page. I am charging people (unless some esato users want to do it, it will be free), where they can load a few songs, and have a choice of a few players for their myspace page (or their own if they wish). I want it to have my website name in it and all, adn say the song name if possiable. If anyone can help with that, or even just point me in the right direction, it would be greatly appreciated. (btw, im not computer dumb, i knwo alot ) thanks all.


Posted by Jim
Use the mkdir function in php to make a folder when people sign up and in the same time create a .htaccess file (I'm sure it's possible in php but don't know the function) wich will have the username and password of the member and of course your info also so you will have access at every folder.

Example for mkdir: mkdir ("/home/www/files/$username", 0744);

Edit: I'm not sure if .htaccess and md5 use the same way to code a password but it's worth a shot

Edit2: yeah I was correct, htpasswd use a modified md5 so you need the crypt() function

Here is an ugly example with a form but it works (tested it out):

Quote:

$password = $_POST['password'];
$username = $_POST['username'];

$md5password = md5($password); ---> use for mysql
$cryptpassword = crypt($password); ---> use for .htpasswd

mkdir ("/home/www/files/$username", 0777); (change the 0777)

$myFile = "files/$r_username/.htaccess";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "AuthUserFile /home/www/files/$username/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic

require user $username";
fwrite($fh, $stringData);

$myFile2 = "files/$username/.htpasswd";
$fh2 = fopen($myFile2, 'w') or die("can't open file");

$stringData2 = "$username:$cryptpassword";
fwrite($fh2, $stringData2);



[ This Message was edited by: Jim on 2006-04-09 14:29 ]

Posted by Jim
Allways my pleasure

Pfffff

Posted by parsnip
gave me an error....

Posted by Jim
Of course, it miss the form and some other variables but as he said he knows things then I suppose I don't need to make him the full script .

Posted by parsnip
ok

Posted by EastCoastStar
i completley didnt even see a response for this!
i will try it when i get home (im at work) it actually looks liek it will work. and seems pretty basic, idk why i didnt think of it. but, i will definatley try it. thank you much!! we will see how it goes

Posted by Johnex
Use the database!
Make a simple login and logout with sessions, then make a simple file lister.

Posted by Jim
Isn't their a risk of sql injection ?

Posted by Johnex
Not if you do it right You need to use strip_tags() or some custom method.

Posted by Jim
Yeah never could do it right, I dropped a project because of security issues that I couldn't solve on my own, c'est la vie ...

Posted by Johnex
As you might alreay know, i have a nice system in the making beta.johnex.se, has taken me years to mold, it will soon be ready. It also works on wap, which is my usual johnex.se/wap/

Posted by Jim
Seems great, good luck with it

Posted by Johnex
tanks


Click to view updated thread with images


© Esato.com - From the Esato mobile phone discussion forum