From 84686273a0ae5e6d6b0a2c3f216515a1a37def16 Mon Sep 17 00:00:00 2001 From: "Paula V. Quispe" Date: Fri, 22 Jul 2016 13:17:45 -0400 Subject: [PATCH] HOR-1472 remove webdav PROPPATCH function HOR-1472 --- gulliver/bin/tasks/pakeGulliver.php | 36 ------- gulliver/system/class.dbMaintenance.php | 99 +------------------ .../drivers/pgsql/metadata/PgSQLTableInfo.php | 32 +++--- .../sqlite/metadata/SQLiteTableInfo.php | 4 +- .../pear/HTTP/WebDAV/Server/Filesystem.php | 48 --------- workflow/engine/classes/class.webdav.php | 38 ------- workflow/engine/classes/class.wsTools.php | 2 - 7 files changed, 19 insertions(+), 240 deletions(-) diff --git a/gulliver/bin/tasks/pakeGulliver.php b/gulliver/bin/tasks/pakeGulliver.php index ea21f2039..a8959ed15 100755 --- a/gulliver/bin/tasks/pakeGulliver.php +++ b/gulliver/bin/tasks/pakeGulliver.php @@ -63,12 +63,6 @@ pake_task('pack-plugin', 'project_exists'); pake_desc("generate basic CRUD files for an existing class\n args: "); pake_task('propel-build-crud', 'project_exists'); -pake_desc("backup a workspace\n args: [-c|--compress] [|]"); -pake_task('workspace-backup', 'project_exists'); - -pake_desc("restore a previously backed-up workspace\n args: [-o|--overwrite] "); -pake_task('workspace-restore', 'project_exists'); - /*----------------------------------********---------------------------------*/ pake_desc("check standard code\n args: "); pake_task('check-standard-code', 'project_exists' ); @@ -2108,25 +2102,6 @@ function run_workspace_backup($task, $args) { if (!isset($gzipPath)) $tar->_compress = $compress; - /*** WORKFLOW DATABASE BACKUP ***/ - $dbSettings = getDataBaseConfiguration($configuration['datasources']['workflow']['connection']); - backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir); - printf("Copying folder: %s \n", pakeColor::colorize( $tmpDir, 'INFO')); - backupAddTarFolder( $tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir ); - - /*** RBAC DATABASE BACKUP ***/ - $dbSettings = getDataBaseConfiguration($configuration['datasources']['rbac']['connection']); - backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir); - printf("Copying folder: %s \n", pakeColor::colorize( $tmpDir, 'INFO')); - backupAddTarFolder( $tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir ); - - /*** RP DATABASE BACKUP ***/ - $dbSettings = getDataBaseConfiguration($configuration['datasources']['rp']['connection']); - backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir); - printf("Copying folder: %s \n", pakeColor::colorize( $tmpDir, 'INFO')); - backupAddTarFolder( $tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir ); - - $pathSharedBase = PATH_DATA . 'sites' . PATH_SEP . $workspace . PATH_SEP; printf("copying folder: %s \n", pakeColor::colorize($pathSharedBase, 'INFO')); backupAddTarFolder($tar, $pathSharedBase, PATH_DATA . 'sites'); @@ -2167,17 +2142,6 @@ function run_workspace_backup($task, $args) { } } -function backupDB($host, $user, $passwd, $dbname, $tmpDir){ - $oDbMaintainer = new DataBaseMaintenance($host, $user, $passwd); - //stablishing connetion with host - $oDbMaintainer->connect($dbname); - //set temporal dir. for maintenance for oDbMaintainer object - $oDbMaintainer->setTempDir($tmpDir . $dbname . PATH_SEP); - //create the backup - $oDbMaintainer->backupDataBaseSchema($oDbMaintainer->getTempDir() . "$dbname.sql"); - $oDbMaintainer->backupSqlData(); -} - /** * Parse and get the database parameters from a dns connection * dsn sample mysql://wf_os:w9j14dkf5v0m@localhost:3306/wf_os?encoding=utf8 diff --git a/gulliver/system/class.dbMaintenance.php b/gulliver/system/class.dbMaintenance.php index 8d9518832..71a005eeb 100755 --- a/gulliver/system/class.dbMaintenance.php +++ b/gulliver/system/class.dbMaintenance.php @@ -308,23 +308,6 @@ class DataBaseMaintenance return true; } - /** - * backupSqlData - * - * @return boolean true or false - */ - function backupSqlData () - { - $aTables = $this->getTablesList(); - foreach ($aTables as $table) { - $fsize = $this->dumpSqlInserts( $table ); - $file = basename( $this->outfile ); - - } - - return true; - } - /** * restoreAllData * @@ -419,67 +402,6 @@ class DataBaseMaintenance $mysqli->close(); } - function lockTables () - { - $aTables = $this->getTablesList(); - if (empty( $aTables )) - return false; - printf( "%-70s", "LOCK TABLES" ); - if (@mysql_query( 'LOCK TABLES ' . implode( ' READ, ', $aTables ) . ' READ; ' )) { - echo " [OK]\n"; - return true; - } else { - echo "[FAILED]\n" . mysql_error() . "\n"; - return false; - } - } - - function unlockTables () - { - printf( "%-70s", "UNLOCK TABLES" ); - if (@mysql_query( "UNLOCK TABLES;" )) { - echo " [OK]\n"; - } else { - echo "[FAILED]\n" . mysql_error() . "\n"; - } - } - - /** - * dumpSqlInserts - * - * @param string $table - * - * @return integer $bytesSaved; - */ - function dumpSqlInserts ($table) - { - - $bytesSaved = 0; - $result = @mysql_query( 'SELECT * FROM `'.$table.'`' ); - - $num_rows = mysql_num_rows( $result ); - $num_fields = mysql_num_fields( $result ); - - $data = ""; - for ($i = 0; $i < $num_rows; $i ++) { - - $row = mysql_fetch_object( $result ); - $data .= "INSERT INTO `$table` VALUES ("; - - for ($x = 0; $x < $num_fields; $x ++) { - $field_name = mysql_field_name( $result, $x ); - - $data .= ($row->$field_name === null) ? 'NULL' : "'" . mysql_real_escape_string( $row->$field_name ) . "'"; - $data .= ($x < ($num_fields - 1)) ? ", " : false; - } - - $data .= ");\n"; - } - - printf( "%-59s%20s", "Dump of table $table", strlen( $data ) . " Bytes Saved\n" ); - return $data; - } - /** * backupDataBaseSchema * @@ -638,23 +560,4 @@ class DataBaseMaintenance $str = preg_replace( "/\#[\w\W]*\\n/", '', $str ); return $str; } -} - -/* -// Sample to use -$oDbMaintainer = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); -$oDbMaintainer->setTempDir('/home/erik/backs/'); -$oDbMaintainer->setDbName('rb_os'); -$oDbMaintainer->connect(); -$oDbMaintainer->backupDataBaseSchema('/home/erik/backs/schema_os.sql'); -$oDbMaintainer->backupSqlData(); -$oDbMaintainer->createDb('neyek12', true); - -$o2 = new DataBaseMaintenance('localhost', 'root', 'atopml2005'); -$o2->setTempDir('/home/erik/backs/'); -$o2->setDbName('neyek12'); -$o2->connect(); - -$o2->restoreFromSql('/home/erik/backs/schema_os.sql'); -$o2->restoreAllData('sql'); -*/ +} \ No newline at end of file diff --git a/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php b/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php index 8694c660b..095cf364d 100755 --- a/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php +++ b/gulliver/thirdparty/creole/drivers/pgsql/metadata/PgSQLTableInfo.php @@ -99,10 +99,10 @@ class PgSQLTableInfo extends TableInfo { FROM pg_attribute att JOIN pg_type ty ON ty.oid=att.atttypid LEFT OUTER JOIN pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum - WHERE att.attrelid = %d AND att.attnum > 0 + WHERE att.attrelid = $1 AND att.attnum > 0 AND att.attisdropped IS FALSE ORDER BY att.attnum"; - $result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid)); + $result = $this->executePgQuery($this->conn->getResource(), $query, $this->oid); if (!$result) { throw new SQLException("Could not list fields for table: " . $this->name, pg_last_error($this->conn->getResource())); @@ -235,9 +235,9 @@ class PgSQLTableInfo extends TableInfo { INNER JOIN pg_type b ON b.oid = CASE WHEN d.typndims > 0 then d.typelem ELSE d.typbasetype END WHERE d.typtype = 'd' - AND d.typname = '%s' + AND d.typname = '$1' ORDER BY d.typname"; - $result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $strDomain)); + $result = $this->executePgQuery($this->conn->getResource(), $query, $strDomain); if (!$result) { throw new SQLException("Query for domain [" . $strDomain . "] failed.", pg_last_error($this->conn->getResource())); @@ -291,11 +291,11 @@ class PgSQLTableInfo extends TableInfo { LEFT JOIN pg_catalog.pg_attribute a2 ON a2.attrelid = ct.conrelid WHERE contype='f' - AND conrelid = %d + AND conrelid = $1 AND a2.attnum = ct.conkey[1] AND a1.attnum = ct.confkey[1] ORDER BY conname"; - $result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid)); + $result = $this->executePgQuery($this->conn->getResource(), $query, $this->oid); if (!$result) { throw new SQLException("Could not list foreign keys for table: " . $this->name, pg_last_error($this->conn->getResource())); } @@ -379,9 +379,9 @@ class PgSQLTableInfo extends TableInfo { indisunique FROM pg_index idx JOIN pg_class cls ON cls.oid=indexrelid - WHERE indrelid = %d AND NOT indisprimary + WHERE indrelid = $1 AND NOT indisprimary ORDER BY cls.relname"; - $result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid)); + $result = $this->executePgQuery($this->conn->getResource(), $query, $this->oid); if (!$result) { @@ -411,9 +411,9 @@ class PgSQLTableInfo extends TableInfo { $query = "SELECT a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid - WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped + WHERE c.oid = '$1' AND a.attnum = $2 AND NOT a.attisdropped ORDER BY a.attnum"; - $result2 = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum)); + $result2 = $this->executePgQuery($this->conn->getResource(), $query, array($this->oid, $intColNum)); if (!$result2) { throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource())); @@ -454,9 +454,9 @@ class PgSQLTableInfo extends TableInfo { indisunique FROM pg_index idx JOIN pg_class cls ON cls.oid=indexrelid - WHERE indrelid = %s AND indisprimary + WHERE indrelid = $1 AND indisprimary ORDER BY cls.relname"; - $result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid)); + $result = $this->executePgQuery($this->conn->getResource(), $query, $this->oid); if (!$result) { throw new SQLException("Could not list primary keys for table: " . $this->name, pg_last_error($this->conn->getResource())); } @@ -483,9 +483,9 @@ class PgSQLTableInfo extends TableInfo { $query = "SELECT a.attname FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid - WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped + WHERE c.oid = '$1' AND a.attnum = $2 AND NOT a.attisdropped ORDER BY a.attnum"; - $result2 = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum)); + $result2 = $this->executePgQuery($this->conn->getResource(), $query, array($this->oid, $intColNum)); if (!$result2) { throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource())); @@ -500,8 +500,8 @@ class PgSQLTableInfo extends TableInfo { $this->pkLoaded = true; } - function executePgQuery($conn, $query){ - $result = pg_query($conn, $query); + function executePgQuery($conn, $var, $values = array()){ + $result = pg_query_params($conn, $var, $values); return $result; } diff --git a/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php b/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php index cd828b3fa..23ce9de5b 100755 --- a/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php +++ b/gulliver/thirdparty/creole/drivers/sqlite/metadata/SQLiteTableInfo.php @@ -123,8 +123,8 @@ class SQLiteTableInfo extends TableInfo { $this->indexes[$name] = new IndexInfo($name); // get columns for that index - $query = "PRAGMA index_info('".$name."')"; - $res2 = sqlite_query($this->conn->getResource(), $filter->preventSqlInjection($query)); + $var = "PRAGMA index_info('".$name."')"; + $res2 = sqlite_query($this->conn->getResource(), $var); while($row2 = sqlite_fetch_array($res2, SQLITE_ASSOC)) { $colname = $row2['name']; $this->indexes[$name]->addColumn($this->columns[ $colname ]); diff --git a/gulliver/thirdparty/pear/HTTP/WebDAV/Server/Filesystem.php b/gulliver/thirdparty/pear/HTTP/WebDAV/Server/Filesystem.php index 41dbdf521..bc8d5e146 100755 --- a/gulliver/thirdparty/pear/HTTP/WebDAV/Server/Filesystem.php +++ b/gulliver/thirdparty/pear/HTTP/WebDAV/Server/Filesystem.php @@ -617,54 +617,6 @@ return ($new && !$existing_col) ? "201 Created" : "204 No Content"; } - /** - * PROPPATCH method handler - * - * @param array general parameter passing array - * @return bool true on success - */ - function PROPPATCH(&$options) - { - global $prefs, $tab; - - $msg = ""; - - $path = $options["path"]; - - $dir = dirname($path)."/"; - $base = basename($path); - - if (!class_exists('G')) { - $realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] ); - $docuroot = explode( '/', $realdocuroot ); - array_pop( $docuroot ); - $pathhome = implode( '/', $docuroot ) . '/'; - array_pop( $docuroot ); - $pathTrunk = implode( '/', $docuroot ) . '/'; - require_once($pathTrunk.'gulliver/system/class.g.php'); - } - G::LoadSystem('inputfilter'); - $filter = new InputFilter(); - - foreach($options["props"] as $key => $prop) { - if ($prop["ns"] == "DAV:") { - $options["props"][$key]['status'] = "403 Forbidden"; - } else { - if (isset($prop["val"])) { - $query = "REPLACE INTO properties SET path = '%s', name = '%s', ns= '%s', value = '%s'"; - $query = $filter->preventSqlInjection($query, Array($options['path'],$prop['name'],$prop['ns'],$prop['val'])); - error_log($query); - } else { - $query = "DELETE FROM properties WHERE path = '%s' AND name = '%s' AND ns = '%s'"; - $query = $filter->preventSqlInjection($query, Array($options['path'],$prop['name'],$prop['ns'])); - } - mysql_query($query); - } - } - - return ""; - } - /** * LOCK method handler diff --git a/workflow/engine/classes/class.webdav.php b/workflow/engine/classes/class.webdav.php index 3b56c1068..e1d478132 100755 --- a/workflow/engine/classes/class.webdav.php +++ b/workflow/engine/classes/class.webdav.php @@ -886,44 +886,6 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server return ($new && !$existing_col) ? "201 Created" : "204 No Content"; } - /** - * PROPPATCH method handler - * - * @param array general parameter passing array - * @return bool true on success - */ - public function PROPPATCH(&$options) - { - global $prefs, $tab; - - $msg = ""; - - $path = $options["path"]; - - $dir = dirname($path) . "/"; - $base = basename($path); - - G::LoadSystem('inputfilter'); - $filter = new InputFilter(); - - foreach ($options["props"] as $key => $prop) { - if ($prop["ns"] == "DAV:") { - $options["props"][$key]['status'] = "403 Forbidden"; - } else { - if (isset($prop["val"])) { - $query = "REPLACE INTO properties SET path = '%s', name = '%s', ns= '%s', value = '%s'"; - $query = $filter->preventSqlInjection($query, Array($options['path'],$prop['name'],$prop['ns'],$prop['val'])); - error_log($query); - } else { - $query = "DELETE FROM properties WHERE path = '%s' AND name = '%s' AND ns = '%s'"; - $query = $filter->preventSqlInjection($query, Array($options['path'],$prop['name'],$prop['ns'])); - } - mysql_query($query); - } - } - return ""; - } - /** * LOCK method handler * diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index e2f1800c5..f3e321a4c 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -1136,10 +1136,8 @@ class workspaceTools $oDbMaintainer = new DataBaseMaintenance($dbInfo["host"], $dbInfo["user"], $dbInfo["pass"]); CLI::logging("Saving database {$dbInfo["name"]}\n"); $oDbMaintainer->connect($dbInfo["name"]); - $oDbMaintainer->lockTables(); $oDbMaintainer->setTempDir($path . "/"); $oDbMaintainer->backupDataBase($oDbMaintainer->getTempDir() . $dbInfo["name"] . ".sql"); - $oDbMaintainer->unlockTables(); $dbNames[] = $dbInfo; } return $dbNames;