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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

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...

Edited by xcislav
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.