2 //==============================================================================
3 // Name: JPGENDBDRIVER.PHP
4 // Description: Driver for scanning project files to update the DB
5 // Created: 2002-06-06 22:50
6 // Author: johanp@aditus.nu
7 // Version: $Id: jpgendbdriver.php,v 1.10 2002/09/02 14:26:27 aditus Exp $
10 // Copyright (C) 2002 Johan Persson
12 //==============================================================================
14 include 'de_utils.php';
15 include 'jpgendb.php';
22 function ScanProjFiles($aDBUtils) {
23 $this->iDBUtils = $aDBUtils;
24 $this->iDB = $aDBUtils->iDBServer;
27 function Run($aProjname,$aForceUpdate=false) {
28 $this->iProjname = $aProjname;
30 HTMLGenerator::CloseWinButton();
32 echo "<b>Scanning files for project '$aProjname'</b><br>";
34 // Find full filename of all project files in the project
35 $proj = $this->iDBUtils->GetProject($aProjname);
36 $projidx = $proj['fld_key'];
38 echo "<i>($proj[fld_projdir])</i><p>\n";
40 $q = "SELECT * FROM tbl_projfiles WHERE fld_projidx=$projidx";
41 $res = $this->iDB->Query($q);
43 $ptimer = new JpgTimer();
46 $fname = $proj['fld_projdir'].'/'.$r['fld_name'];
47 $modtime=@filemtime($fname);
48 if( $modtime == false ) {
49 die("Can't access file: $fname");
52 $dbtime = strtotime($r['fld_dbupdtime']);
53 if( $aForceUpdate || $modtime > $dbtime ) {
55 echo "Parsing '".basename($fname)."'...\n";flush();
56 $dbdriver = new DBDriver($aProjname,$fname,$this->iDB);
59 $t = round($ptimer->Pop()/1000,2);
60 $q = "UPDATE tbl_projfiles SET fld_dbupdtime=now() WHERE fld_key=".$r['fld_key'];
61 $this->iDB->Query($q);
62 echo "[in $t s]<br>\n";
65 echo "DB is up to date for '".basename($fname)."'<br>\n";
68 echo "<p><h3>Done.</h3>";
69 HTMLGenerator::CloseWinButton();
73 class DbGenDriver extends DocEditDriver {
74 function Run($aForceUpdate=false) {
75 if( !empty($this->iProjidx) && $this->iProjidx > 0 ) {
76 $scan = new ScanProjFiles($this->iDBUtils);
77 $projname = $this->iDBUtils->GetProjNameForKey($this->iProjidx);//$regen_projidx);
78 $scan->Run($projname,$aForceUpdate);
80 else echo "No project index";
84 $force = @$HTTP_GET_VARS['force'] ;
86 if( isset($force) && $force=='true' )
91 $driver = new DbGenDriver();