Help in PHP
Hello, this is a PHP newbie talking, and I would like help coding my new website, it is a torrent site and everything is going good but I need a simple PHP script that searches a specific directory, I don't want it to hook it to a MySQL DB, because I'm currently developing a user account system. If you can help me, Please post a 1 file script. Thanks and on the site I will give credit to the person on my site. P.S. I am looking for some people to help me code my site if you are interested contact [mail]carson768@gmail.com[/mail].:D
what kind of directory, where, and how do you want it to interact with your site?
function dirSearch ($dir) {
$file = "/folder/{$dir}/";
if (file_exists($file)) {
echo "The directory {$dir} exists";
} else {
mkdir("folder/{$dir}", 0777);
echo "The directory {$dir} was successfully created.";
}
}
?> ```
or if it's a local file, use perl:
```markup#!/usr/bin/perl
use warnings;
use strict;
&findDir($ARGV[0]);
sub findDir {
$handle = shift;
qx(if [[ ! -d $handle ]] ;
then
echo "creating directory!";
mkdir $handle;
else
echo "Directory exists!";
fi);
}```
If you haven't noticed, Perl is a beautiful and sleek entity, with glorious masterrace syntax full of mystery and wonder. PHP looks like my slovenian grandmother gargling testicles for money. Do choose wisely, which languages you want to use.
I'm sorry I should have posted more info. The server directory is is http://localhost/torrents/. The server is a windows OS. Plus I don't like CGI/PERL so please post a PHP script.
Ok, but I need it to function as
<form method=get action="this-action.php">
<input type=text name=q size=60>
<input type=submit value=search border=0>
</form>
I am sorry to keep questioning you but, will it funtion work this form and search my directory? EDIT: I feel so stupid, I need it to search for a file in a directory…
Arabian wrote: it will if you add the line
markupdirSearch($GET_['q']);
above the function. It's probably a good idea to actually know how to program before abusing other people's scripts or asking for help that you won't think twice about. Also, learn about POST/GET and how to use PHP. AND, you need to add validation before actually pasting that directly to your site.
goluhaque wrote: [quote]Arabian wrote: it will if you add the line
markupdirSearch($GET_['q']);
above the function. It's probably a good idea to actually know how to program before abusing other people's scripts or asking for help that you won't think twice about. Also, learn about POST/GET and how to use PHP. AND, you need to add validation before actually pasting that directly to your site. [/quote]
SHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHSHHHHHHHHHHHHHHSHHHHHHHSHSHSHSHHSHSHHSSHHSHSHSHSHSH!!!!!!!!!!!!!!!!!!!!!!
>:C
op you know what needs to be done so heres file_exists, realpath and $_GET['q'] is what a get variable would actually look like. now do the work yourself and dont listen to people who dont $_GET['php']; be warned: unicode can really fuck with php
goluhaque wrote: [quote]Arabian wrote: it will if you add the line
markupdirSearch($GET_['q']);
above the function. It's probably a good idea to actually know how to program before abusing other people's scripts or asking for help that you won't think twice about. Also, learn about POST/GET and how to use PHP. AND, you need to add validation before actually pasting that directly to your site. [/quote] The first thing to do should be stripping the entire search string of slashes. Add other validation according to your taste.