commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/phpforms/src gnue-forms.php database.inc c...


From: Jan Ischebeck
Subject: gnue/phpforms/src gnue-forms.php database.inc c...
Date: Wed, 17 Jul 2002 17:40:01 -0400

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jan Ischebeck <address@hidden>  02/07/17 17:40:01

Modified files:
        phpforms/src   : gnue-forms.php database.inc connection.php 
Added files:
        phpforms/src   : common.php settings.php 

Log message:
        finally fixed the bug restoring resultsets, postgres should work again
        split gnue-forms into forms and "common" part
        add settings.php with settings to customize phpforms.
        (like allow_formdef_upload, ways to load your own forms without 
uploading etc.)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/common.php?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/settings.php?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/gnue-forms.php.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/database.inc.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/phpforms/src/connection.php.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/phpforms/src/connection.php
diff -c gnue/phpforms/src/connection.php:1.1 
gnue/phpforms/src/connection.php:1.2
*** gnue/phpforms/src/connection.php:1.1        Mon May  6 18:52:10 2002
--- gnue/phpforms/src/connection.php    Wed Jul 17 17:40:01 2002
***************
*** 13,22 ****
                               "DBNAME"=>"gnue");
  $connections["gnueA"] = array("COMMENT"=>"Connection to a ".
                               "database dedicated to gnue",
!                              "PROVIDER"=>"XMLRPCtoCommonGateway",
                               "HOST"=>"localhost",
                               "PATH"=>"/",
!                              "PORT"=>"8766",
                               "DBNAME"=>"gnue");
  $connections["gnue2"] = array("COMMENT"=>"Connection to a ".
                               "database dedicated to gnue",
--- 13,23 ----
                               "DBNAME"=>"gnue");
  $connections["gnueA"] = array("COMMENT"=>"Connection to a ".
                               "database dedicated to gnue",
!                              "PROVIDER"=>"appserver",
!                              "RPCTYPE"=>"xmlrpc",
                               "HOST"=>"localhost",
                               "PATH"=>"/",
!                              "PORT"=>"8765",
                               "DBNAME"=>"gnue");
  $connections["gnue2"] = array("COMMENT"=>"Connection to a ".
                               "database dedicated to gnue",
Index: gnue/phpforms/src/database.inc
diff -c gnue/phpforms/src/database.inc:1.4 gnue/phpforms/src/database.inc:1.5
*** gnue/phpforms/src/database.inc:1.4  Thu Jul 11 19:02:11 2002
--- gnue/phpforms/src/database.inc      Wed Jul 17 17:40:01 2002
***************
*** 159,189 ****
          }                 
      }
      // ****
!     function getEmptyResultSet($table) {  
          $r=new PGSQL_Resultset;
          $r->setDatabase($this);
          $r->setTable($table);
          return $r;
      }
      function getResultSet($table,$query,$order_by=Null) {
!         $r=$this->getEmptyResultSet($table);
          // create sql
!         $sql = "select OID,* from ".$this->attr["TABLE"];
!         reset($this->query);
!         while (list($k,$v)=each($this->query)) {
!             if (strlen($v)>0) {
!                 $where=$where2." ".$k." LIKE '".$v."' ";
!                 $where2=$where."AND";
!                 // get field info like: defaultQuery
!                 // ignoreCaseOnquery, sloopyQuery...
              }
          };
          if (isset($where))
              $sql=$sql." WHERE ".$where;          
          if (isset($order_by))
              $sql=$sql." ORDER BY ".$order_by;
! 
!         $res=$this->select($query);
          if (count($res)>0) $r->setCache($res);
          return $r;
      }
--- 159,191 ----
          }                 
      }
      // ****
!     function getEmptyResultSet($table,$order_by=Null) {  
          $r=new PGSQL_Resultset;
          $r->setDatabase($this);
          $r->setTable($table);
          return $r;
      }
      function getResultSet($table,$query,$order_by=Null) {
!         $r=$this->getEmptyResultSet($table,$order_by);
          // create sql
!         $sql = "select OID,* from ".$table;
!         if (count($query)) {
!             reset($query);
!             while (list($k,$v)=each($query)) {
!                 if (strlen($v)>0) {
!                     $where=$where2." ".$k." LIKE '".$v."' ";
!                     $where2=$where."AND";
!                     // get field info like: defaultQuery
!                     // ignoreCaseOnquery, sloopyQuery...
!                 }
              }
          };
          if (isset($where))
              $sql=$sql." WHERE ".$where;          
          if (isset($order_by))
              $sql=$sql." ORDER BY ".$order_by;
!          print $sql;
!         $res=$this->select($sql);
          if (count($res)>0) $r->setCache($res);
          return $r;
      }
Index: gnue/phpforms/src/gnue-forms.php
diff -c gnue/phpforms/src/gnue-forms.php:1.6 
gnue/phpforms/src/gnue-forms.php:1.7
*** gnue/phpforms/src/gnue-forms.php:1.6        Thu Jul 11 19:02:11 2002
--- gnue/phpforms/src/gnue-forms.php    Wed Jul 17 17:40:01 2002
***************
*** 34,255 ****
  $clientversion="0.0.8";     // new database abstraction layer, gfd source
                              // code print out
  $clientversion="0.0.8.1";   // changes to database/datasource creation code
  
  
- // set debug level
- $debuglevel=9;  // > 10 very detailed
-                 // > 3 normal
-                 // > 1 just basics
-                 //   0,1 no debugging messages
  
  require_once("connection.php");
  require_once("xmlrpc.inc");  // has to be included here to get global scope
  
- // +++++++++++++ Debugging Code ++++++++++++++++++++++++++++++
  
- if ($debuglevel>8) {
-     error_log ("\n\n".
-                "****************************************\n".
-                "            phpforms restarted          \n".
-                "****************************************\n\n",
-                3, "/tmp/phpforms-errors.log");
- }
- 
- function DEBUG($level,$str) {
-     global $debuglevel;
-     if ($level<=$debuglevel) {
-         $estr="DEBUG (".$level."):".$str;
-         # print($estr."<BR>");
-         error_log ($estr."\n", 3, "/tmp/phpforms-errors.log");
-     }
- }
- ############### FILE UI.PHP ############ BEGIN ###########
- 
- class htmlproducer {
-     var $output;
-     function write($s) {
-         $this->output.=$s;
-     }
-     function writedown() {
-         echo $this->output;
-     }
- }
- $out=new htmlproducer;
- $out->writedown();
- 
- ############### FILE UI.PHP ############ END #############
- 
- ############### FILE CLASSDEF.PHP ###### BEGIN ###########
- 
- class database {
-     var $connected;
-     var $attr;
-     var $status;
-     function database() {
-         $this->connected=false;
-         $this->attr=array();
-     }
-     function setAttr($attr) {
-         $this->attr=$attr;
-     }
- 
-     function restoreResultSet($table,$data) {
-         $r=$this->getEmptyResultSet($table,$order_by);
-         $r->restoreData($data);
-     }
-     function getEmptyResultSet($table,$order_by) {  
-         $r=new Resultset;
-         $r->setDatabase($this);
-         $r->setTable($table);
-         return $r;
-     }
-     function getResultSet($table,$query,$order_by) {
-         return $this->getEmptyResultSet($table,$order_by);
-     }
-     // global commit /rollback
-     function commit() {
-     } 
-     function rollback() {
-     } 
-     // BACKUP / RESTORE FUNCTIONS
-     function getBackupData() {
-         return $this->attr;
-     }
-     function restoreData($data) {
-         $this->attr=$data;
-     }    
- }
- class Resultset {
-     var $lastentry;
-     var $dbcon;  // set by the database itself, or by the datasoure
-     var $table;
-     function Resultset() {   
-     }
-     function setDatabase($dbcon) {
-         $this->dbcon=&$dbcon;
-     }
-     function setTable($table) {
-         $this->table=$table;
-     }
-     // cache functions
-     function isSaved() {
-     }
-     function markforRemoval($recordno) {
-     }
-     function ismarkedforRemoval ($recordno) {
-     }
-     function getLastRecordNumber() {
-         return $lastentry;
-     } 
-     function commit($dbcon,$table) {  // write datacache
-     } 
-     function newEntry($pos=-1) {
-     }
-     function getField($fieldname,$pos) {         
-     }
-     function setField($fieldname,$pos,$data) {
-     }
-     // BACKUP / RESTORE FUNCTIONS
-     function getBackupData() {
-         return $this->attr;
-     }
-     function restoreData($data) {        
-         $this->attr=$data;
-     }
- }
- 
- function getDatabaseOfType($type) {
-     if ($type=="appserver") {        
-         require_once("gcomm.php");
-         $db=new GNURPCtoAppServer;
-         // Attr: Commonprovider
-     }
-     if (($type=="pgsql")||
-         ($type=="popy")||
-         ($type=="psycopg")||
-         ($type=="pypgsql")) {
-         require_once("database.inc");
-         $db=new PGSQL_DB;
-     }
-     if ($type=="MailGateway") {
-         // Attr: Email-Addr.
-         // MODES: Delete-after-commit
-     }
-     if ($type=="SessionCache") {
-         // Attr: MaxEntrys
-        require_once("database.inc");
-        $db=new SessionCacheDB;
-     }
-     if (!isset($db)) {
-         require_once("database.inc");
-         $db=new database; 
-     } 
-     return $db;
- }
- function databaseFactory($name,$attr) {
-     $db=&getDatabaseOfType($attr["PROVIDER"]);
-     $db->setAttr($attr);
-     return $db;
- }
- function restoreDatabase($name,$data) {
-     $db=&getDatabaseOfType($data["PROVIDER"]);
-     $db->restoreData($data);
-     return $db;
- }
- 
- 
- class xmlEntity {  // persistent Object
-     var $type; 
-     var $name;
-     var $attr;
-     var $_parent;
-     function xmlEntity() {
-         $this->type="XMLEntity"; 
-         $this->name="";
-     }
-     function setName($n) {
-         $this->name=$n;
-     }
-     function getName() {
-         return $this->name;
-     }
-     function setParent(&$p) {
-         $this->_parent=&$p;
-     }
-     function getParent() {
-         return $this->_parent;
-     }
-     function setAttr($attr) {
-         $this->attr=$attr;
-         if (isset($attr["NAME"])) {
-             $this->name=$attr["NAME"];
-         }
-     }    
-     function getAttr() {
-         return $this->attr;
-     }       
-     function dump() {
-         $p=$this->_parent;
-         $this->_parent="PARENT";
-         if (isset($this->_parent->type)) 
-             $this->_parent=$this->_parent->type; 
-         var_dump($this);
-         $this->_parent=$p;
-     }
-     function getBackupData() {
-         // for all datasources do getBackupData
-         // echo "MYTYPE: ".$this->type."<BR><BR>";
-         $data= array("name"=>$this->name,
-                      "attr"=>$this->attr,
-                      "type"=>$this->type);
-         return $data;
-     }
-     function restoreData($data) {
-         $this->attr=$data["attr"];
-         $this->type=$data["type"]; 
-         $this->name=$data["name"]; 
-     }
- } 
  /*
  +------------+-----------+---------+
  | Attribute  | Datatype  | Default | Supported?
--- 34,51 ----
  $clientversion="0.0.8";     // new database abstraction layer, gfd source
                              // code print out
  $clientversion="0.0.8.1";   // changes to database/datasource creation code
+ $clientversion="0.0.8.2";   // added appserver driver but broke postgres driv.
+ $clientversion="0.0.8.3";   // split gnue-forms.php in more files, 
+                             // added settings.php
  
  
  
+ require_once("settings.php");
  require_once("connection.php");
  require_once("xmlrpc.inc");  // has to be included here to get global scope
+ require_once("common.php");  
  
  
  /*
  +------------+-----------+---------+
  | Attribute  | Datatype  | Default | Supported?
***************
*** 308,321 ****
      }   
      function doPreQuery($preq) {
          if ($this->attr["TABLE"]=="") return;
!         $this->clearCache(); // possibly double call
!         // if dbdriver=postscript get OIDs
!         $sql = "SELECT OID,* FROM ".$this->attr["TABLE"];
!         if ($preq!="") 
!             $sql = $sql." WHERE ".$preq;
!         if (isset($this->attr["ORDER_BY"]))
!             $sql=$sql." ORDER BY ".$this->attr["ORDER_BY"];
!         $dts=$this->dbcon->getResultSet($this->attr["TABLE"],$sql);
          $this->Dataset=&$dts;
      }
  
--- 104,123 ----
      }   
      function doPreQuery($preq) {
          if ($this->attr["TABLE"]=="") return;
! 
!         # TO IMPLEMENT: parse prequery string ($preq)
!         $querytable=array();
! 
!         if (isset($this->attr["ORDER_BY"])) {
!             
!             $dts=$this->dbcon->getResultSet($this->attr["TABLE"],
!                                             $querytable,
!                                             $this->attr["ORDER_BY"]); 
!         } else {
!             
!             $dts=$this->dbcon->getResultSet($this->attr["TABLE"],
!                                             $querytable);
!         };
          $this->Dataset=&$dts;
      }
  
***************
*** 419,425 ****
          DEBUG(3,"Restoring DATASOURCE: database='".$dbname."'");
          $this->dbcon=&$this->_parent->dbcons[$dbname];
          $this->Dataset=
!              $this->dbcon->restoreResultSet($this->attr["TABLE"],
                                              $data["dataset"]);
          $this->Dataset->dbcon=&$this->_parent->dbcons[$dbname];
      }
--- 221,227 ----
          DEBUG(3,"Restoring DATASOURCE: database='".$dbname."'");
          $this->dbcon=&$this->_parent->dbcons[$dbname];
          $this->Dataset=
!              &$this->dbcon->restoreResultSet($this->attr["TABLE"],
                                              $data["dataset"]);
          $this->Dataset->dbcon=&$this->_parent->dbcons[$dbname];
      }
***************
*** 1781,1786 ****
--- 1583,1589 ----
  
  function writeHTMLheader() {
      global $PHP_SELF;
+     global $showGNUElogo;
  ?>
  <HTML>
  <HEAD>
***************
*** 1793,1800 ****
    .A { padding=0pt 0pt 0pt }
    INPUT { font-family:monospace; font-size: 12pt }
  -->
! </STYLE>
! <CENTER><IMG SRC="img/gnue.png"></CENTER>
  <SCRIPT LANGUAGE="JavaScript"><!--
       function do_action_now(c,a) { 
           do_action(c,a)
--- 1596,1604 ----
    .A { padding=0pt 0pt 0pt }
    INPUT { font-family:monospace; font-size: 12pt }
  -->
! </STYLE><?php
!       if ($showGNUElogo) print "<CENTER><IMG SRC=\"img/gnue.png\"></CENTER>";
! ?>
  <SCRIPT LANGUAGE="JavaScript"><!--
       function do_action_now(c,a) { 
           do_action(c,a)
***************
*** 1914,1920 ****
  
  
          // check for uploaded form
!         if (isset($HTTP_POST_FILES['userfile']['name'])) {
              $tmpfile=$HTTP_POST_FILES['userfile']['tmp_name'];
              $this->gfdFileName=$HTTP_POST_FILES['userfile']['name'];
              exec("rm /tmp/test.gfd");            
--- 1718,1725 ----
  
  
          // check for uploaded form
!         if ((isset($HTTP_POST_FILES['userfile']['name'])) &&
!             ($GLOBALS["allowformsupload"])) {
              $tmpfile=$HTTP_POST_FILES['userfile']['tmp_name'];
              $this->gfdFileName=$HTTP_POST_FILES['userfile']['name'];
              exec("rm /tmp/test.gfd");            
***************
*** 1928,1961 ****
          $this->HTTPinput=$HTTP_POST_VARS;
      }   
      function load() {
!         global $resultform,$PHP_SELF;
          $this->loadSessionVars();
          $this->checkHTTPinput();
          if ($this->command=="close") {
!             // show a "do you really want page."
              session_destroy();
              $this->gfdFile="";
          }
!         if ($this->command=="demo") {
!             $this->gfdFile="/home/jan/public_html/intro.gfd";
!             $this->gfdFileName="intro.gfd";
!             parseGFDfile($this->gfdFile);        
!             $this->form=&$resultform;
!         }
!         if ($this->command=="demo2") {
!             $this->gfdFile="/home/jan/public_html/state_maint.gfd";
!             $this->gfdFileName="state_maint.gfd";
!             parseGFDfile($this->gfdFile);        
!             $this->form=&$resultform;
!         }  
!         if ($this->command=="demo3") {
!             $this->gfdFile="/home/jan/public_html/contact.gfd";
!             $this->gfdFileName="contact.gfd";
!             // load form data from file
              parseGFDfile($this->gfdFile);        
              $this->form=&$resultform;
          }
!         if ($this->command=="showsource") {
              include("print-gfd.inc");
              prettyPrintGFDfile($this->gfdFile,$this->gfdFileName);
              echo "<BR><CENTER><A HREF=\"".$PHP_SELF.
--- 1733,1755 ----
          $this->HTTPinput=$HTTP_POST_VARS;
      }   
      function load() {
!         global $resultform,$PHP_SELF,$localforms;
          $this->loadSessionVars();
          $this->checkHTTPinput();
          if ($this->command=="close") {
!             // show a "do you really want to leave" page.
!             // then jump to $GLOBALS["oncloseformGoto"]
              session_destroy();
              $this->gfdFile="";
          }
!         if (isset($localforms[$this->command])) {
!             $this->gfdFile=$localforms[$this->command];
!             $this->gfdFileName=$localforms[$this->command];
              parseGFDfile($this->gfdFile);        
              $this->form=&$resultform;
          }
!         if (($this->command=="showsource") &&
!             ($GLOBALS["allowformsSrcshow"])) {
              include("print-gfd.inc");
              prettyPrintGFDfile($this->gfdFile,$this->gfdFileName);
              echo "<BR><CENTER><A HREF=\"".$PHP_SELF.
***************
*** 2025,2033 ****
              } else {
                  // show Form
                  $this->form->showPage();
!                 echo "<P ALIGN=\"RIGHT\">Used GFD file: \"<A HREF=\"".
!                     $PHP_SELF."?c=showsource\">".$this->gfdFileName.
!                     "</A>\"</P>";
                  echo "<FONT COLOR=WHITE>";
                  // trick to make every page become different
                  list($usec, $sec) = explode(' ', microtime());
--- 1819,1829 ----
              } else {
                  // show Form
                  $this->form->showPage();
!                 if ($GLOBALS["allowformsSrcshow"]) {
!                     echo "<P ALIGN=\"RIGHT\">Used GFD file: \"<A HREF=\"".
!                         $PHP_SELF."?c=showsource\">".$this->gfdFileName.
!                         "</A>\"</P>";
!                 };
                  echo "<FONT COLOR=WHITE>";
                  // trick to make every page become different
                  list($usec, $sec) = explode(' ', microtime());



reply via email to

[Prev in Thread] Current Thread [Next in Thread]