File: cli_batch/all_batch.php

Recommend this page to a friend!
  Classes of Dave Smith  >  PHP Deprecated Function Checker  >  cli_batch/all_batch.php  >  Download  
File: cli_batch/all_batch.php
Role: Application script
Content type: text/plain
Description: Command Line Batch Processing
Class: PHP Deprecated Function Checker
Find deprecated functions and suggest replacements
Author: By
Last change:
Date: 6 years ago
Size: 2,313 bytes
 

Contents

Class file image Download
<?php
if ( count($argv) > 1 ) $_SERVER['DOCUMENT_ROOT'] = $argv[1];
$showCheckedFiles = false;
if (
count($argv) > 2 AND $argv[2] == "Y" ) $showCheckedFiles = true;

require_once
'depcheck.class.php';
$dpc = new depcheck(); // get some info first
$phpVersion = PHP_VERSION;
$csvFile = $dpc->depFile;
$docRoot = $dpc->docRoot;
$pageTitle = 'PHP Deprecated Function Checker for Entire Site';

//check files with these extensions
$extType = array(
   
'php',
   
'inc'
);

//ignore installed PHP version
$dpc->ignoreVersion = true;

echo
"\n",$pageTitle;
echo
"\nRunning PHP version ",$phpVersion;
echo
"\nUsing deprecated csv file ",$csvFile;
echo
"\nStart checking all files at $docRoot\n";

$docRootLength = strlen($docRoot) + 1;
$filesToProcess = array();
$fileCount = 0;
$fileTotal = 0;

if(!
is_dir($docRoot)) {
    echo
"\n",$docRoot," is not a directory\n";
} else {
   
processDirectory( $docRoot );
   
asort( $filesToProcess ); // sort the array
}
//check files
foreach( $filesToProcess AS $fileName )
{
   
$fileTotal ++ ;
   
//set file to check
   
$dpc->setFile($fileName);
    if (
$dpc->errorFlag === true ) {
        echo
"\nFile ",$fileName," $dpc->errorMessage\n";
    } else {
       
$dpc->checkFile();
        if (
$dpc->errorFlag === true ) {
            echo
"\nFile ",$fileName," $dpc->errorMessage\n";
        } else {
            if (
$dpc->depFlag === true ) {
               
$result = str_replace("<br>","\n",$dpc->resultMessage);
               
$fileCount ++ ;
                echo
"\nFile ",$fileName,"\nResults:\n$result\n";
            } else {
                if (
$showCheckedFiles ) echo "\nFile ",$fileName," Checked\n";
            }
        }
    }
}
echo
"\n\nIssues in $fileCount of $fileTotal files\n\n";


// recursive
function processDirectory( $name )
{
    global
$docRootLength, $filesToProcess, $extType;

    if (
$dh = opendir($name) )
    {
        while ( (
$file = readdir($dh)) !== FALSE )
        {
           
$F = $name . '/' . $file;
           
$fileType = @filetype($F);
            if (
$fileType == 'file' )
            {
               
$ext = strtolower( pathinfo($F, PATHINFO_EXTENSION) );
                if (
in_array($ext,$extType) )
                {
                   
$filesToProcess[] = substr($F,$docRootLength);
                }
            }
            if (
$fileType == 'dir' )
            {
                if ( ! (
$file == '.' OR $file == '..') )
                {
                   
processDirectory( $F );
                }
            }
        }
       
closedir($dh);
    }
}

For more information send a message to info at phpclasses dot org.