Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Directory Listings


I am using the following code to list the files in a directory.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Sorting Directory Listings With Php - Doable?
Curious to see what I can do with php in terms of getting a directory listing and sorting by name, size, and date modified.

I looked at a few functions on php.net, but nothing struck me as what I needed.

Note, there are several hundred files in the target directory... loading filenames, sizes, ect into arrays may not be a good solution here.

Listings In Alphabetical, What About Numbers And Other?
I'm using PHP and mysql so when you click on a link that says A, you get all the titles that start with A. However, how would I do this with numbers and anything else that’s not in the alphabet? I tried doing 1,2,3,4, etc but It caused errors. What SQL code should I use?

PHP Nightmare.....Integration Into EbaY Listings
I've been searching all day for a method on how to integrate the
listings off ebaY onto my website, but I have had no joy whatsoever.

I want to be able to open a listing based on the the item number,
which I can do simply by using,

$ITEMNUMER = ("blah");
http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=$ITEMNUMER

but, I cannot use include(); to achieve what I want to do, because
a) it is having trouble including external webpages
b) the ebaY listing is generated upon arrival, so theres no way it
could interperate it.

I've been trying all kinds of fopen(); techniques, but nothing seems
to be able to open the page, because (I assume) it doesn't exist till
an actual browser visits it, and it calls it values from the ebaY
database.

So, I tied using the ebaY API, but I'll need to pay a hellish amount
to use it, so it seems out the question.

What I really want to do is have a script check a listing for some
text. But, as I cannot get PHP to open the file, I'm stuck !

If anyone knows a way how I can strip some information out of an
external web page using PHP -

Ebay Listings Using Front Page
Anyone know the best way to get page created in front page 2002 in an
ebay listing. I've created a page but a lot of the format and graphics
are missing when viewed in ebay

Newbie: If Then Statement And Expiring Listings
I've tried a couple of variations of coding this but i still haven't
gotten it down.

basically my query pulls all the tables within a certian search
criteria. When it shows the listings it shows a space like:

Name
Address
city, state zip
phone:
<blank space>
url

right now this is the code i have:

Eliminating Passed URL Variables For Multiple Listings On A Page
I have a page with a list of several users, each hyperlinked to another page of 'more info' about that user. The hyperlink contains the UserNumber, UserRegion, and UserStatus, and the receiving page picks up the data in the passed URL. This works well, but I'd like to eliminate the passing of these variables in the URL.

One way is to make a graphic ('More Info') that can be clicked to submit a form. Each 'More info' graphic from the dynamically created page could hold the UserNumber, but how can I pass several variables with a single click? On some pages, there can be 100+ users, and I hate to have 100+ separate forms and hidden fields.

I thought of using session variables, how can I know which user was clicked to set the session variables?

"Paging" (First/Previous/Next/Last To Limit # Of Listings Per Page)
I'm trying to get a handle on the best way to handle setting up my listings
so that I display groups of about 25 records per page. I currently have a
page that returns over 1,000 names/addresses, which is obviously not very
efficient. Does anyone have any suggestions on the best way to approach
this, or recommendations on what pitfalls to avoid? I'm assuming that I need
to be able to count the total number of records that match the search
criteria, possibly at the top of the page before any HTML output, then find
some way to identify/track the first record, next record, etc...? I know I
should replace my existing query with something that limits it to about 25
records at a time, right?

<?php include('dbconnect.php');
echo "<TABLE width="100%" align="center" border="0"
cellpadding="0" cellspacing="0">";
$query="SELECT * from artists
WHERE mentor=&#390;'
ORDER BY country DESC, state ASC, city ASC, lastname ASC";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$firstname = (ucwords(strtolower($row['firstname'])));
$lastname = (ucwords(strtolower($row['lastname'])));
$mentor= $row['mentor'];
$city= (ucwords(strtolower($row['city'])));
$state= (strtoupper($row['state']));
$country= (strtoupper($row['country']));
//....etc....
echo "
<TD align="left" valign="top" width="50%"><FONT size="2"
face="Arial, Helvetica, sans-serif">
<A HREF="javascript:;"
onClick="openProfile('artist.php?artistID=".$artistID.
"','Artist','resizable=yes,width=750,height=400')">".$firstname."
".$lastname."</A></FONT></TD>
//....etc....

Active Directory / Exchange / Active Directory.
I'm creating an Intranet module for a client (Forum, files upload...etc...etc). This client already has a huge server running on WIN2000 + IIS 4 + Exchange + Microsoft Active directory + proxy and finally PHP 4.03 + MySql.

Problem #1 :
All passwords are changed every weeks, so I want to be able to import users/pass from Microsoft exchange .... Does anyone have an idea to do such thing with PHP ?

Problem #2:
I would like that the user logged from the firm's network do not have to log. again when connecting the module. So, is it possible to do such thing ?

PHP As Directory
How would I go about using a PHP file like a directory, for example,
"http://mysite.com/index.php/virtual_page23"? I would like to use that
form instead of "http://mysite.com/index.php?p=virtual_page23". Also,
is this possible in IIS?

Directory
In php is the way to upload all the contents of a user selected directory up to a certain spot on a website?

About Directory
How to check correctly if the directory already exist in the
webroot? I've tried with this syntax:
....
bool $state = mkdir( "test" );
if ( $state == false ) chdir( "test" );
....

This Directory
Is there a way to read all of the files in the same directory without writing out the directory path? I want to put the same index file into a bunch of different folders and I want a way to say "This Folder" instead of changing the file each time.

Directory
How is it possible to return the current folder's name?  I tried explode("",getcwd()) but that doesn't seem to work.

Basically, getcwd yields C:path ofile

I want to be able to return just the end (in this case, file)

Regarding OS Directory
What I'd like to do.. is hide the table "Links" if there's none there to be shown instead of having "There are no links here" I myself don't know how to do this but what i have noticed is if you don't have any categories it doesn't show up the table... just wanting the same thing to happen with the links table... I'm using OpenLD btw Code:

Uploading A Directory
It's very easy to upload a file using the post method with php. The user selects the file that he will upload and submits the form... What I want to do is uploading all the contents of a directory. The user will select a directory and all the files in that directory will be sent to the server. Is it possible to do this with php ? If so how ?

Creating Directory
I am trying to make my webpage create a file for each person that submits a file, so at first I was using...

$myfile=fopen("create/$user.txt","w");

This worked, and it would create the file if it was not there. Then I decided that each user would recieve their own directory, and that the first file to be edited was called options.txt, in their user directory. So, I used this:

$myfile=fopen("create/$user/options.txt","w");

But it came back saying that the directory did not exist. Is there a way to create a directory along with the new file that goes into it?

Best Way Of Showing Directory
Im tring to create a script that will show directorys and files..
but.. i cant get it ti show another directory.. for example
right now the main directory is lets say.. bo and its showing
another directory that is named images.. how can i get my file.
that is in the boo directory to view the images directory...

Use File_exists On One Directory Only??
I am developing a system in php which enables users to upload files. Users can then select a directory and the files in that directory are then outputted in a table.

However, I do not want users to be able to upload a file to a directory if a file of the same name already exists within that directory.

I thought I could use file_exists but as I want to restrict the search to one folder at a time, as opposed to the whole file system, I dont think this will work.

Another option was to run a loop on each file name in the directory and compare it to the name of the file being uploaded. This wont work either however as php considers test.doc and Test.doc to be different where as a file server considers them to be the same. Therefore if a file called test.doc already exists and a user tries to upload a file called Test.doc they will not be considered the same and the upload would be allowed by php.
This would then overwrite the original file (test.doc) with Test.doc.

Directory Deleted
So far i m using following code for deleting folders and files.But it will
only delete those folders which r empty.I want to delete those folders also
which has some files.pls give me the solution

<?php
error_reporting(0);
include("../connection.php");
$date = date("m/d/Y"); //For finding current current
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1],
$date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}
?>
....................

Files From Directory
I'm looking for a function that returns all files from a given
directory...

PHP Scripts To Run In Another Directory With IIS
I would like to have PHP for windows run in another directory than
c:inetpubwwwroot. I have tride changeing parameters in php.ini in my
c:php directory. But nothing changes. When I run the phpinfo() I always get
Configuration File (php.ini) Path as c:windows. But I do not have the
php.ini file there. Is there something I am doing wrong or is it a bug....

Chmod A Directory
How can I chmod a directory to 0777. I tried chmod ($myDirectory, 0777); but nothing happens.

Can't Get PHP To Run On ISS Virtual Directory.
I can't get PHP to run on ISS virtual directory. PHP runs fine if run from
the www root, but if I create a virtual directory to another local drive and
put the PHP files in there I cannot run them. If I put a normal html file
in the virtual directory that works fine.

I have checked the app mappings and PHP is in there and mapped, any ideas?

How To Get Current Directory ?
How to get the current directory under windows and linux (both share the same code)?
I cannot use getcwd , because the server only support php3.

Enquiry On /tmp Directory
Warning : "The sessions directory does not exist: /tmp. Sessions will not work until this directory is created."

I am getting this warning in my php based website, despite creating /tmp folder in the root dir where php is installed.

Checksum Of A Directory
I am trying to write a function wherein any change in the files in any folder on my webserver would shoot me an email alert. I thought that one easy way of doing it would be via monitoring files/folders for their checksum at periodic intervals but I have no clue how to calculate checksum for a file or folder via php.

Can anyone point me in the right direction. I tried searching on google, but I guess I might be using the wrong keywords..

Hidden Php Directory
I've recently had what looks like an attack on a web server. The
machine is running iis 6 on windows 2003 server. with php 5.0.3 and
mySQL 4.1.8 installed and running. The attack has deleted my phpMyAdmin
folder plus files and has hiddene the C:php directory. The folder
isn't visible in Windows Explorer, but it can be viewed with the
command line using the Run application. It also appears the folder with
php in their name are also not visible.
If anyone has any idea whatmight be causing this phenomena, please
send whatever knowledge you have.

Renaming Directory
Anyone know how to rename a directory with php code. Or does the rename($file_old_name, $file_new_name); work with directories too??

Image Directory
I'm having problems with the directory structure of my website, the website is in php and each page has several includes. the problem is the includes keep changing their directory paths to images.

so how do I link to images so that it is universally accepted througout the site, without using the http://www.mywebsite.com/images/.... way as this way takes longer for the webserver to process.

PHP And Active Directory
Via a PHP script (running on a LAMP configuration - PHP with LDAP
support), I run queries on the LDAP server of our office (users and
arguments). Now, I want to put the result of this query (user
information) in a Windows 2003 AD.
I use PHP-ldap functions to connect with the domain controller: making
connection is no problem, but binding (authenticated, I even tried
Domain Administrator credentials) doesn't work...
Does anyone has experience with this matter (PHP and AD
connection/communucation)?

IIS+PHP: The Directory Name Is Invalid.
I have recently migrated from win98+PWS to winXP+IIS, and after that an
problem has occured. When I open some of my PHP pages, I get this
instead of the page I shlud get:

<html><head><title>Error</title></head><body>The directory name is
invalid. </body></html>

Now, the interesting part is the fact that this doesn't happen every
time I try to open a specific page (it happens in 80% of cases, but
sometimes it (the page) just opens like nothing's wrong) and that it
happens on all of my PHP pages! I presume I have misconfigured IIS...
but I don't know where to start searching for a problem... does IIS have
logging? Does PHP have logging?

Or, has anybody encountered similar problem?

I use:
IIS 5.1
PHP Version 4.3.0
IE 6.0

Finding Directory
would like to know if there is a way to locate a specific directory on your site. I have a script which scans a directory, but it is not always running in the same directory, so the relative path to the scanned directory will be changed.

Is there a way to find the location of the directory to be scanned, and build a relative url to it?

Run PHP Scripts Outside Of The Web Directory
Is it possible to run a script that will be used from all the websites
on the server outside of the web dir ?
At the moment for every site I have I upload the script in the web dir
of the specific site...

Specifically it is a RichEditor so it has javascripts as well ...
But it is difficult to maintain updates of the script to all websites
so I would prefer if I had only one place to update it...

Getting Current Directory
Can anyone tell me how i can get php to retrieve the directory i am working from (Home Directory)the reason i ask is i am getting a directory listing of my images folder and i dont want to have to enter the complete path to that directory (C:lahdahimages) i want to be able to just enter the images folder as my folder to retrieve.

Current Directory
Anyone know that how to find the current directory's name in php? I need the php automatic to find its current directory's name.

Php Directory Structure
im a little worried about security in a site im designing and have a proposition.. i thought about keeping every single php and inc file in a directory beneath the web directory.. such that NONE of the files can be accessed from a web browser.. then.. when a user requests, for example, to use the built in login page which is entitled login.php.. i simply use apache to forward this page login.php in a different directory.. i can as well use mod rewrite to accomplish similar things..

im trying to think of the reasons that something like this would NOT be a good idea.. i imagine i could create all the php files in a seperate folder on the same level, perhaps title pseudoWWW, and have the entire web strucutre of phps' and incs' in there, and then, when someone requests www/login.html, it doesnt have to have a specific directive in apache to go to login.php, rather, go to the file in the pseudo directory with the same name, but a php extension, run the script, output the results.. then the user wouldn't have any idea that the php script even exists, let alone where it is and what it's doing.

Creating Directory
i've stored as "MPEG PAL" in a string variable say $directory.(i've tested using is_string() function).Now when creating a directory using exec(mkdir $directory);

it creates two directories MPEG and PAL. I need these two to be a single directory MPEG PAL. How can i do it.i've stored into $directory from text box.

PHP Create Directory.
im strugling with this for days now... so please help ih you know...

it's UNIX server,

i'm trying to find working script that would create directories
recursively...

script is in www.server.com/cp/uploadfiles/script.php
and function should be called like 'createDir ("../../files/aa/bb")'

-> only "../../files" exists.

Mapping A Directory...
I was wondering if anyone here knows how to use PHP to 'map' a folder and all sub-folders and files within it... Anyone who has been to tabcrawler knows sorta what I mean...

I need a folder such as 'guides' to be taken and a list of sub-directories ('x-box', 'gamecube', etc) to be shown in the form of links. When clicked, the links should open to look almost identical to the first one with the sub-directory acting as the new directory and the files contained in it as the new sub-directories, only, these files should open regularly into the browser..

Getting Directory Contests Using DIR
I was wondering to try something like this:

exec("dir "".$sSearchPath."*.pdf" >c:hhh.txt");

though, it hangs at that point. I tried system(), shell_exec/() etc
similar result.

Fake Directory
I have a CMS for links on my site, but I actually want the category to be seen within the URL without physically have to insert a new category on my site. So e.g. if I have a category Cardiology, I want the URL to be: www.mysite.nl/Cardiology/ But the directory Cardiology doesn't actually exist. Am I making it clear?

What's The Best Directory Script?
Which existing directory script is the best one?

Directory Listing
I'm trying to open a directory and set the names of the files in that directory in an array (ei. file[0], file[1],file[2]...) for howmany files there mey be in the dir.

Uploading Directory
I'm writing an app which uploads pictures. I've finished the section for uploading single files, but wondered if it's possible to have the user select a directory (or group-select files) locally and upload the lot.

Can anyone point me in the right direction? I looked into using FTP to upload the pics, but still have a problem where choosing a directory is concerned.

Set A Directory As The DefaultType?
I have an annoying problem. Every time I try to access a folder on my server
(Apache) without adding a slash at the end, I get a "page cannot be
displayed" message. For example, on my server I have a folder within htdocs
called "ct", and I want to access the index.php page in it from the address
http://localhost/ct. But when I try that, it gives me the "page cannot be
displayed" message. So I have to type http://localhost/ct/ (with a forward
slash / at the end). It's not a big deal but it is an annoyance and if I
ever run my own server I would like to know how to fix that.

I wonder if maybe setting the DefaultType directive to a directory is the
way to go? And if so, what's the MIME type for a directory?

Directory Listing ...
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

Directory Problem
When I upload pictures I put them into a directory structure such as

photos/1000/1/Jon.jpg

where 1000 is the account number of the customer and 1 is the agentID of the
particular customer employee who requested it be put there.

To view the files I do a directory search (code after this explanation) to
build a list, $filelist, that I will put up in the html area with a <?php
echo $filelist ?>

The result of all this is that it finds the one file that is that directory
(Jon.jpg) and prints it out the link and the name (see code below).
However, when I click on it to actually view the picture, it gives a page
not found. What I don't understand is why this is happening when I got the
name from the directory search.

Data in the form
$TOP ="http://www.mywebsite.com/";
$accountNumber = 1000;
$agentID = "1";
$authCode = "something"; // This is for later when I check against a
database to validate permissions)

Code:
<?php
$accountNumber = $_POST['accountNumber'];
$agentID = $_POST['agentID'];
$authCode = $_POST['authCode'];

$empty = (strlen($accountNumber) == 0) && (strlen($agentID) == 0) &&
(strlen($authCode) == 0);
$ok = false;
if (isset($_POST['viewPic']) && !$empty) {
$ok = true;
$dir = "photos/" . $accountNumber . "/" . $agentID;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$filelist .= '<a href="' . $TOP . $dir . "/" .$file . '">' .
$file . "</a><br>";
}
}
closedir($handle);
}
}

?>

The view source gives:
<a href="http://www.mywebsite.com/photos/1000/1/Jon.jpg">Jon.jpg</a>

So, the directory search finds it to build the link, but I a get a page not
found on the click. Any ideas? (It is probably something so simple that it
is a DUH!, but I have not been able to see it).

Make A Directory
How do I create a directory using PHP?

Directory-View With PHP
I've programmed an access-control via header()-function. It
checks an username and password in database ... nothing special.

Currently, the control gives access to a download, but I would
like to allow special users to view the complete directory.

AFAIK this is only possibly through ".htaccess" (Apache webserver).
But then, I need to create an entry for each user in the database
in the file :-(

Would it be possible to allow this direclty through PHP?
Of course, I could write dynamically into htaccess, but if
several users would access the file at the same time ... URGHS :-)


Copyright © 2005-08 www.BigResource.com, All rights reserved