File: extended_sql/all_sql.php

Recommend this page to a friend!
  Classes of Dave Smith  >  PHP Deprecated Function Checker  >  extended_sql/all_sql.php  >  Download  
File: extended_sql/all_sql.php
Role: Application script
Content type: text/plain
Description: Process all files and save in database
Class: PHP Deprecated Function Checker
Find deprecated functions and suggest replacements
Author: By
Last change:
Date: 6 years ago
Size: 4,054 bytes
 

Contents

Class file image Download
<?php

/*
depcheck class - php deprecated checker
Copyright (c) 2015, Wagon Trader

all.php - example by Gerry Danen

all_sql.php - Extended by: Tony Russo
All rights reserved.
*/

//set amount of memory and execution time - adjust to your choosing
ini_set("memory_limit","100M"); //ini_set("memory_limit","25M");
ini_set("max_execution_time", 3600); // max_execution_time in seconds, 1hr = 60 sec & 60 min = 3600


//databse crdentials
$db_server = 'localhost';
$db_user = 'your user name';
$db_password = 'your password';
//$db_database = 'syntax'; //optional
//$db_table = 'depcheck'; //optional
//$db_charset = 'latin1'; //optional

//path parameters
$docRoot = 'c:/source'; //set to any folder of your choosing as the doc root
$docFolder = '/web'; //set folder off document root to start or leave blank to start at document root

//logging
$logging = true;
$logfile = 'c:/depcheck/depcheck.log'; //set to path and file name for log file


//files to check
$extType = array('php', 'inc', 'html', 'htm' );
$recurisve = true; //true include sub directories, false exclude sub directories

//php version
$phpVersion = PHP_VERSION;
$ignoreVersion = true; //ignore installed PHP version

//titles
$pageTitle = 'PHP Deprecated Function Checker for Entire Site';
$pageSubTitle = 'Example provide by Gerry Danen';
$pageSubTitle2 = 'Extend by Tony Russo';

//$cli = false;

//-------------------


require_once 'depcheck.class.php'; //original base class
require_once 'depcheck.class.extended.php'; //extend base class
require_once 'db.mysqli.class.php'; //database abstraction layer - can be modifiy to different database or use PDO.

$dpc = new depcheck_extended(); //create instance of extended class and load depricated function names
$dpc->db = new db_mysqli(); //create instance of database and use $dpc-db as ref to database class

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

$dpc->logging( $logging );
$dpc->logfile( $logfile );

/*
  $dpc->db->connect( $db_server, $db_user, $db_password, $db_database, $db_table, $db_charset ); //connect to database

  (string) $db_server - your database host name or ip address
  (string) $db_user - your database user name
  (string) $db_password - your password
[ (string) $db_database] - optional, default 'syntax' ] - see depcheck.database_table.sql for info
[ (string) $db_table - optional, default 'depcheck' ] - see depcheck.database_table.sql for info
[ (string) $db_charset - optional, default 'latin1' ]
*/
$dpc->db->connect( $db_server, $db_user, $db_password ); //connect to database

$docRootLength = strlen($docRoot);
$filesToProcess = array();
$fileCount = 0;
$fileTotal = 0;
$total_issues = 0;
//$eol = $cli ? "\r\n" : "<br>";

$dpc->write( $pageTitle );
$dpc->write( $pageSubTitle );
$dpc->write( $pageSubTitle2 );

$dpc->write( "Running PHP version {$phpVersion}" );
$dpc->write( "Using deprecated csv file '{$dpc->depFile}'" );
$dpc->write( "Start checking all files at '{$docRoot}{$docFolder}'" );

//processDirectory uses/requries $docRootLength, $filesToProcess, $extType;
$dpc->processDirectory( $docRoot.$docFolder, $recurisve ); //updates $fileToProcess array
asort( $filesToProcess ); // sort the array

//check files
foreach( $filesToProcess AS $fileName )
{
   
$fileTotal ++ ;
   
   
$dpc->setFile($fileName); //set file to check
   
$dpc->checkFile_sql(); //use extend checkFile function

   
if ( $dpc->depFlag === true )
    {
       
$fileCount ++ ;
       
$total_issues = $total_issues + $dpc->issue_count;
       
$results = "{$fileName} issues: " . $dpc->issue_count;
       
$dpc->write( $results );
    }
}

$dpc->write( "\r\n" . "{$total_issues} Issues in $fileCount of $fileTotal files" );

$dpc->db->close(); //close database


?>

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