Jump to content

Search and output all .php files in a variable containing a php source code.


xcislav

Recommended Posts

editor.php:

<form action="somesense.php" 
...
j=new XMLHttpRequest();
j.open("POST","updatenine.php"
...
j.open("GET","lb.php?

IN RESULT:

(editor.php contains)

somesense.php

updatenine.php

lb.php

 

 

For example, all three files one by one have been being put into array by echoing it with strpos (from that large variable).

When searching is under way and strpos comes with it's results ".php" it adds all letters/numbers (until some other leading character).

 

For example

for the first strpos finds:

"lb.php?

.php and adds lb, finishing with lb.php , cutting " and ? from the found line (from code). It cuts " and ? because those symbols aren't proper file names.

 

----- -----

First found

Find pathnames matching a pattern - http://php.net/glob
with it's

array glob(string pattern [, int flags])

 

Seems to have some limits, imposed on the forms of representation. I would intend to search within large files.
 

from php's man:

The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.

"common shells" aren't the best choice for the large-scaled searches.

 

What would you recommend?

Glob searches filenames within the current directory... it doesn't search within a file...???

 

Why strpos, why not use preg_grep? (simpler, better results, can do all at once, but maybe slightly slower)

 

As for common shells... nothing wrong with them since most applications are written in C, e.g. glob.

 

 

 

Can you simplify your question? Are you just wanting to know to best (fastest or memory efficient) way to search files?

Should the search be optimised for memory or speed?

 

What would you recommend?

 

Using a database and not hunting directories and files.

 

 

I would intend to search within large files.

 

Yes for sure a database.

One major downfall is no matter how little the data is you want to fetch from a file...the entire file has to be loaded regardless.

Why strpos, why not use preg_grep? (simpler, better results, can do all at once, but maybe slightly slower)

Because I can't imagine an array of program source. What type of "chunks" of this array could you imagine when it's just a source code...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.