PHP Version Finder

Find what version of PHP your script requires. We have just started selling scripts online. When asked what version of PHP is required to run our scripts we didn’t have a definitive answer. We created this software to determine the PHP version, and then we took it to another level by seeking out deprecated functions. But we didn’t stop just at that. We included PHP Extensions and language constructs. We almost called it good at that, but then we wondered… how many times we used these functions. Excessive use of the same function can be degrading on performance. Monitoring how many times a function is used can help determine if a “User Created Function” can be created to reduce code and increase performance.

Detection

PHP Version Finder tracks: 3044 PHP Functions, 2260 PHP Extensions, 23 Language Constructs, 19 Alternative Suggestions, 7 Tips/Tricks/Notes. (plus 69 Experimental, 20 Deprecated, 47 “svn” functions)

The code does NOT have to be complete nor functioning. It does not even have to make sense. As long as it is between <?php and ?> it will be evaluated.

Deprecated Detection

PHP Version Finder lets you know if any functions you used are deprecated.

Current Features (v 1.0.0) 12/1/2010

  • Optional Database
  • Deprecated Detection
  • File Upload Processing
  • Directory Processing
  • Pasted Code Processing
  • AutoComplete
  • Syntax Highlighter
  • 3044 PHP Functions
  • 2260 PHP Extensions
  • 23 Language Constructs
  • 19 Alternative Suggestions
  • 7 Tips/Tricks/Notes
  • Plus 69 Experimental Functions
  • Plus 20 Deprecated Functions
  • Plus 47 “svn”/unknown Functions

Update v 1.0.1 12/3/2010

  • Fixed Notice Warnings
  • Fixed “Undefined Variables” Errors
  • Fixed Spelling Errors
  • Updated Help File to reflect changes
  • Added Licensing Explanation
  • Cleaned up the “Report File”

Update v 1.0.2 12/4/2010

  • Fixed Notice Warnings
  • Fixed “Undefined Variables” Errors
  • Updated Help File to reflect changes

Update v 1.0.3 12/7/2010

  • Cleaned up code
  • Rewrote how stats are tallied.
  • Rewrote the “Report File”

There are two versions of PHP Version Finder. One requires the database, one does not.

Non Database Version

Simply copy the entire “phpversion” folder to your web server.

If you uploaded it to the root of your domain, simply go to:

http://www.domain-name.com/phpversion/index.php

You are not allowed to share access to this software with the public! Make sure you use .htaccess (or another form of authorization) to secure the directory!! Further Explanation Here

Database Version

Simply copy the entire “phpversion_db” folder to your web server.

If you uploaded it to the root of your domain, simply go to:

http://www.domain-name.com/phpversion/index.php

You are not allowed to share access to this software with the public! Make sure you use .htaccess (or another form of authorization) to secure the directory!! Further Explanation Here

Setup a MySQL database on your host. If you need assistance with this please contact your hosting provider.

You will need the following information to finish installing PHP Version Finder.

  • Database Host
  • Database User Name
  • Database Password
  • Database Name

Edit lines 3,4,5 & 6 in the config.php file located in the database directory and upload to the database directory on your server.

phpversion_db/database/config.php

Point your browser to /database/build_database.php

http://your-domain.com/phpversion_db/database/build_database.php

Once the process is complete it will say “All Done”. This process creates a new file in the database directory called “locked”. If you want to update the database, you will need to remove this locked file!

Edit the config.php file located in the main phpversion directory.

http://www.domain-name.com/phpversion/config.php

$absolute_path

This path should point to the root directory you want to process. if you have a specific “projects” folder, you can point this path to that folder to eliminate all other folders outside of your project folder.

$absolute_path = “/home/user-name/public_html/project_folder”;

$file_exts

Add any file extensions you want PHP Version Finder to process looking for PHP code.

$file_exts = array( ‘php’, ‘php3′, ‘php4′, ‘php5′, ‘inc’);

$ignore

Add any directories that you do NOT want in the autocomplete, or do NOT want to be processed.

$ignore = array(‘phpversion’,’cgi-bin’,’.’,’..’,’cache’,’img’,’images’);

Usage is pretty strait forward.

No matter the method you use, the php code MUST include at least the opening <? and the closing ?> tags! Files and code can contain html, it will simply be ignored.

Upload a file, apply any options you want, then click submit.

To populate the autocomplete just click the purple link (“Index for auto-complete”) under your “server path”

If the file you want to process is on the server, put a forward slash “/” into the path box and find the file in the autocomplete dropdown.

Or you can simply paste code into the big square box and click submit.


Options Explained – Both Versions

These are the checkboxes on the front end.

Comprehensive Processing comprehensive processing only applies when processing directories! If processing a single file or pasted code comprehensive is “already applied”

When comprehensive process is NOT applied, each time a function is found it is “removed” from the list of php functions.

Hold on to your hats, this is going to get ugly!

Lets say you have two files in a directory. file_1.php and file_2.php. Both of these files have some of the same PHP functions. For example, well say date(); When comprehensive processing is NOT activated (no check in the box), PHP Version finder will process file_1.php and pickup the PHP function date(); It will add it to the list of detected functions (each further detection will increase its hit count) and then remove it from the list of functions to look for. In the list of files processed (right column) it will only display date(); one time in one file. Seems how both files are in the same directory, they are assumed to be part of the same project. So it is a waste of resources to keep processing the same function over and over. However, the unique functions found in the file_2.php will be processed as normal.

If comprehensive processing is ON it will process every occurrence of every function in every file – however, this comes at a cost – it can take a great deal longer to process a directory! For these types of requests, we have the timeout pushed up to 5 minutes (300 seconds)

If two files contain the exact same functions, with comprehensive OFF PHP Version Finder will not list the second file as being processed in the right column.

Highlight the code syntax When processing a single file or a block of code you can turn on and off syntax highlighting. Syntax highlighting does not apply to directory processing.

Ignore Multi-line Comments (/* comment */) By default, PHP Version Finder will process all functions – including functions that have been commented out. This is for two reasons. If we ignored the commented code and a customer purchased your script believe it only required PHP Version 4, and then they uncommented the some of the code, this could raise the minimum required PHP Version which could cause error if they don’t have the newly required versions. The second reason is all about speed. Ignoring comments take longer to process.

Ignore Inline Comments (// comment ) read the description above! Same thing.

Show Statistics Shows statistical information about what PHP Version Finder finds. eg: How many files it processed, how many functions it found, etc…

Build Report If checked this will generate a portable file with the results of PHP Version Finder. At the very bottom of the right hand column You will see a link titled “Report”. You can click this link to see what the report contains. You can right click the link and choose “Save Target As” or “Save Link As” to save it to your local computer so that it can be included with your script.


Custom Notes – Both Versions (database version has note at end)

PHP Version Finder allows you to attach notes to functions. There are two ways of doing this.

Long Notes

Long winded notes requires editing two files.

functs/notes.php

tips.php

Edit the functs/notes.php file to include the following on a new line before “);”

functin_name“=>”<a class=\”pink function_name\” href=\”#\”>Note</a>”,

DO NOT forget the comma at the end of the line! Make sure the function_name is the name of the function you are attaching a note to. The double quotes inside the link must be escaped with a backslash


Edit tips.php to include your note is a two step process:

First Step:

include the following inside of the <script> tags on a new line before “});”

$(“.functin_name“).colorbox({width:”auto”, inline:true, href:”#functin_name“});

Second Step:

add the following format to the end of the file:

<div style=’display:none’>

<div id=’function_name‘ style=’padding:10px; background:#fff;’>

<h3>function_name</h3>

<pre>Add anything you would like right here</pre>

</div>

</div>


 

Short Notes

For short notes edit notes.php:

functs/notes.php

Edit the functs/notes.php file. On a new line add:

functin_name“=>”You can put anthing you want right here, just remember \”escape\” with backslash”,

DO NOT forget the comma at the end of the line! Make sure the function_name is the name of the function you are attaching a note to. The double quotes inside must be escaped with a backslash


Alternative Functions – Both Versions (database version has note at end of page)

PHP Version Finder allows you to suggest alternative functions.

Edit

functs/instead.php

to include the following on a new line before “);”

functin_name“=>”alternative_function“,

DO NOT forget the comma at the end of the line! Make sure the function_name is the name of the function you are attaching the alternative_function to.

for example: ereg_replace has an alternative function (preg_replace) that does the same thing and works on older versions of PHP.

“ereg_replace”=>”preg_replace”,

Not every instance of ereg_replace can be replaced with preg_replace – this is why we call them alternative suggestions.

Alternative Suggestions are more of a personal thing this is why we only included a few rather universal suggestions.


Database Version Only

Once you have edited the files in accordance with the directions above, You MUST remove the ‘locked’ file from the database directory. You will need to run the build_database.php again.


Misc Info

**backwards compatibility is NOT detected by PHP Version Finder!**

If you run PHP Version Finder on itself it will report back that it requires PHP 5.0
when in actuality, it only requires version 4.0.

This is because we use file_put_contents() which does require PHP version 5. However,
in our script we check to see if file_put_contents exists. If it does, the script will
use file_put_contents to write the data to the file. If file_put_contents does NOT exist
we create a user function called file_put_contents that uses fwrite instead. This way
servers that have PHP 5 can use the file_put_contents and those that dont will use the
our user created function.

So with that out of the way, it should say that we need 4.3 because we used file_get_contents.
Which is true, however, just like file_put_contents, we created a function that uses the fopen
instead.

So, with file_put_contents and file_get_contents both out of the way, the next highest version
required is…. you guessed it 4.0!

Why go though the effort? Not everyone has PHP 5 – although they SHOULD! Knocking the
required version down to 4.3 was good enough, but to knock it down to 4.0 was only
three more lines of code so we figured why not!

If you are unable to solve the issue by the above reading; feel free to email us at the link provided above. If we cannot verify you have purchased this software we cannot help you.


Once again, thank you so much for purchasing this PHP Version Finder software. As we said at the beginning, we’d be glad to help you if you have any questions relating to this PHP Version Finder software. No guarantees, but we’ll do my best to assist.