Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
pat_db_install.php
Package: Generateur_v13.rar [view]
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 4k
Category:
WEB Mail
Development Platform:
PHP
- <?php
- /*
- * SQL file parser
- *
- * by Jean Philippe Giot <jpgiot@ifrance.com>
- *
- * GNU GPL
- */
- function get_begin_str($subject,$separator)
- {
- return substr($subject, 0, strlen($subject)-strlen (strstr ($subject,$separator)));
- }
- /*
- * CLASS for parsing and storing all instructions
- *
- */
- class sql_instructions
- {
- var $instructions = array();
- var $show_parse = FALSE;
- // number of comments during parsing
- var $comment = 0;
- // internal. stores current instruction during parsing
- var $current_instruction = '';
- function new_instruction($content='')
- {
- // we save old instruction
- if ('' != $this->current_instruction)
- {
- $this->instructions[] = $this->current_instruction;
- }
- // we save text
- $this->current_instruction = $content;
- }
- function add_text($text='')
- {
- if ('' != $this->current_instruction)
- $this->current_instruction .= $text;
- }
- function get_instructions()
- {
- $this->new_instruction();
- return $this->instructions;
- }
- function parse_file($filename)
- {
- $lines = file($filename);
- $comment = 0;
- $blank = 0;
- $unknown = 0;
- $unknowns = array();
- $parsed_instructions = array('create' => 0,'insert' => 0,'update' => 0,'drop' => 0);
- if ($this->show_parse) echo "<table border=1 cellpadding=2 cellspacing=0>";
- foreach ($lines as $id => $linecontent)
- {
- $begining = strtolower(get_begin_str($linecontent,' '));
- switch ($begining)
- {
- case 'insert' :
- case 'create' :
- case 'update' :
- {
- $parsed_instructions[$begining]++;
- if ($this->show_parse) echo "<tr><th>$begining</th><td>";
- $this->new_instruction($linecontent);
- break;
- }
- case '#' :
- {
- $this->comment++;
- if ($this->show_parse) echo "<tr><th>Comment</th><td>";
- break;
- }
- default :
- {
- if (trim($linecontent) == '#')
- {
- $comment++;
- if ($this->show_parse) echo "<tr><th>Comment</th><td>";
- break;
- }
- elseif (trim($linecontent) == '')
- {
- // added to content
- if ($this->show_parse) echo "<tr><th>Separator</th><td>";
- $this->add_text($linecontent);
- break;
- }
- else
- {
- $unknowns[] = $linecontent;
- $unknown++;
- if ($this->show_parse) echo "<tr><th>Unknown</th><td>";
- // will be added if an instuction is currently available
- $this->add_text($linecontent);
- }
- break;
- }
- }
- if ($this->show_parse) echo $linecontent."</td></tr>n";
- }
- if ($this->show_parse)
- {
- echo "</table>";
- echo 'comment '.$comment."<br>n";
- echo 'blank '.$blank."<br>n";
- echo 'unknown '.$unknown." :<br>n";
- foreach($unknowns as $id => $value) echo $id." ".$value."<br>n";
- }
- }
- }