I really can't tell from PHP.net, but could
someone point out which functions, etc. to look up
to modify my php upload script to do:
When you upload a file, shows the names.file extention
of all files in the /uploads folder?
Here's the script I made for uploading:
<?php
// This is the opening of the PHP script
$uploaddir = '/home/defcon/public_html/uploads/';
// This tells the script to upload it to defconrpg.com/uploads'
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
// This is telling it to take the file from the computer
// and upload it to the director stated in uploaddir
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print_r($_FILES);
} else {
print "File could not be uploaded. ";
print_r($_FILES);
}
print "</pre>";
?>
So, what exactly would I need to do
so it shows the files in a list?
Also the files are links so u
can click to open it in a new window...
I don't nessarly want anyone to tell me
exactly how to do it; more of what I should
look up on PHP.net to do it, as I want to try
and truly do this on my own well to get the extention
substr()
&
strrchr()
but what do yo mean show them in a list? you can only upload the one form wha tI can see so what list? do you mean after i tuploads you want to show a list of all uploads that you have done?
then look up opendir() and readdir() to do that.thanks for the reply; and yes,
I meant show what all (up-to-that-point)
had been uploaded to the folder.Finally, done
<!-- m --><a class="postlink" href="http://www.defconrpg.com/process.php">http://www.defconrpg.com/process.php</a><!-- m --> <-- final/file part
<!-- m --><a class="postlink" href="http://www.defconrpg.com/upload.php">http://www.defconrpg.com/upload.php</a><!-- m --> <-- upload part
Hmm ~ what would I need to create a Hit counter
that tracks a surfer's IP, and logs only one hit
per unique IP, per day?
Also it'd take this information and store
in like a .txt or mysql file.
Perferbly in a .txt, so it'd be easier for me
to create, as well as I'd like to be able to use
php include, so if I wanted to, I could display
the number of hits on my site.Well ~ I wrote a ip-tracker, this:
<?php
$filename = 'hitcounter.txt';// Name of the text file it writes to
$ip = getenv("REMOTE_ADDR");// Get the IP number of the user
$content = "$ip\n";// The content we want to add; we want to add the output of $ip
// Let's see if the file exists and is writable
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open <b>($filename)</b>!";
exit;
}
// Write $content to our now opened file
if (!fwrite($handle, $content)) {
echo "Cannot write to <b>($filename)</b>!";
exit;
}
// Now let's have it say if its was successfully
echo "Success! Wrote <i>($content)</i> to <b>($filename)</b>!";
fclose($handle);
} else {
echo "<b>$filename</b> is not writable!";
}
?>
But how do I put it so that it makes a time-stamp
everytime an IP (even if same) is written to the file?
So then I could
1) see how many times over the
course of a day, someone (IP) visit's my site.
2) count every unique IP once for every 24-hour peroid,
so I may see how many unique visitors I get ever 24-hours.Most webservers already create daily log files for you. Ask your host for access to them if you don't already have it.
There is a "common logfile format" that servers use too. Google for information on that.
There are also many example PHP scripts out there that replicate that function for people who do not have direct log file access.I have access to my log files;
I was just trying to create my own script.
Anyways, I got it all done basicly, except
I have to work on it. I impliment it using
php include; but it only picks up the
IP of the server, not the surfer.if you are referring to the access.log file than yes, the surfer's IP is in there if it is sent.
someone point out which functions, etc. to look up
to modify my php upload script to do:
When you upload a file, shows the names.file extention
of all files in the /uploads folder?
Here's the script I made for uploading:
<?php
// This is the opening of the PHP script
$uploaddir = '/home/defcon/public_html/uploads/';
// This tells the script to upload it to defconrpg.com/uploads'
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
// This is telling it to take the file from the computer
// and upload it to the director stated in uploaddir
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print_r($_FILES);
} else {
print "File could not be uploaded. ";
print_r($_FILES);
}
print "</pre>";
?>
So, what exactly would I need to do
so it shows the files in a list?
Also the files are links so u
can click to open it in a new window...
I don't nessarly want anyone to tell me
exactly how to do it; more of what I should
look up on PHP.net to do it, as I want to try
and truly do this on my own well to get the extention
substr()
&
strrchr()
but what do yo mean show them in a list? you can only upload the one form wha tI can see so what list? do you mean after i tuploads you want to show a list of all uploads that you have done?
then look up opendir() and readdir() to do that.thanks for the reply; and yes,
I meant show what all (up-to-that-point)
had been uploaded to the folder.Finally, done
<!-- m --><a class="postlink" href="http://www.defconrpg.com/process.php">http://www.defconrpg.com/process.php</a><!-- m --> <-- final/file part
<!-- m --><a class="postlink" href="http://www.defconrpg.com/upload.php">http://www.defconrpg.com/upload.php</a><!-- m --> <-- upload part
Hmm ~ what would I need to create a Hit counter
that tracks a surfer's IP, and logs only one hit
per unique IP, per day?
Also it'd take this information and store
in like a .txt or mysql file.
Perferbly in a .txt, so it'd be easier for me
to create, as well as I'd like to be able to use
php include, so if I wanted to, I could display
the number of hits on my site.Well ~ I wrote a ip-tracker, this:
<?php
$filename = 'hitcounter.txt';// Name of the text file it writes to
$ip = getenv("REMOTE_ADDR");// Get the IP number of the user
$content = "$ip\n";// The content we want to add; we want to add the output of $ip
// Let's see if the file exists and is writable
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open <b>($filename)</b>!";
exit;
}
// Write $content to our now opened file
if (!fwrite($handle, $content)) {
echo "Cannot write to <b>($filename)</b>!";
exit;
}
// Now let's have it say if its was successfully
echo "Success! Wrote <i>($content)</i> to <b>($filename)</b>!";
fclose($handle);
} else {
echo "<b>$filename</b> is not writable!";
}
?>
But how do I put it so that it makes a time-stamp
everytime an IP (even if same) is written to the file?
So then I could
1) see how many times over the
course of a day, someone (IP) visit's my site.
2) count every unique IP once for every 24-hour peroid,
so I may see how many unique visitors I get ever 24-hours.Most webservers already create daily log files for you. Ask your host for access to them if you don't already have it.
There is a "common logfile format" that servers use too. Google for information on that.
There are also many example PHP scripts out there that replicate that function for people who do not have direct log file access.I have access to my log files;
I was just trying to create my own script.
Anyways, I got it all done basicly, except
I have to work on it. I impliment it using
php include; but it only picks up the
IP of the server, not the surfer.if you are referring to the access.log file than yes, the surfer's IP is in there if it is sent.