コード例 #1
1
ファイル: db_readdump.php プロジェクト: CMMCO/Intranet
    $os = $regs[1];
    // this looks better under WinX
    if (eregi("Win", $os)) {
        $crlf = "\r\n";
    }
}
$orig_query = $sql_query;
// $sql_query = str_replace($crlf, "", $sql_query);
$pieces = noQuoteSplit($sql_query, ";", "'");
// $pieces = explode($sql_query, ";");
if (count($pieces) == 1) {
    $sql_query = ereg_replace(";\$", "", trim($sql_query));
    include "sql.php";
    exit;
}
for ($i = 0; $i < count($pieces); $i++) {
    if (!$from_file) {
        $pieces[$i] = stripslashes($pieces[$i]);
    }
    $pieces[$i] = trim($pieces[$i]);
    if (!empty($pieces[$i]) && ereg(";", $pieces[$i])) {
        // echo $pieces[$i], "<br><br>";
        $result = pg_exec($link, pre_query($pieces[$i])) or pg_die(pg_errormessage(), $pieces[$i], __FILE__, __LINE__);
    }
}
if (eregi("create table|drop table|create database|drop database", $sql_query)) {
    $reload = "true";
}
$sql_query = nl2br(stripslashes($orig_query));
$message = $strSuccess;
include "db_details.php";
コード例 #2
0
ファイル: tbl_copy.php プロジェクト: CMMCO/Intranet
function my_handler($sql_insert)
{
    global $table, $link, $new_name;
    $sql_insert = ereg_replace($table, $new_name, $sql_insert);
    $result = pg_exec($link, pre_query($sql_insert)) or pg_die(pg_errormessage($link), $sql_insert, __FILE__, __LINE__);
    $sql_query = $sql_insert;
}
コード例 #3
0
ファイル: trig_properties.php プロジェクト: CMMCO/Intranet
<?php

/* $Id: trig_properties.php,v 1.3 2001/02/02 06:03:08 dwilson Exp $ */
if (!isset($message)) {
    include "header.inc.php";
} else {
    show_message($message);
}
$sql_trigger_props = "\n\tSELECT \n\t\tpt.oid,\n\t\tpt.*, \n\t\tpp.proname, \n\t\tpc.relname, \n\t\tpy.typname\n\tFROM \n\t\tpg_trigger pt, pg_proc pp, pg_class pc, pg_type py\n\tWHERE \n\t\tpp.oid = pt.tgfoid\n\t\tAND pt.tgtype = py.oid\n\t\tAND pt.tgrelid = pc.oid\n\t\tAND tgname = '{$trigger}'\n";
if (!($res_props = pg_exec($link, pre_query($sql_trigger_props)))) {
    pg_die(pg_errormessage(), $sql_trigger_props, __FILE__, __LINE__);
} else {
    $row = @pg_fetch_array($res_props, 0);
    // Construct function definition
    $query = "?db={$db}&server={$server}&rel_type=function&function_oid={$row['tgfoid']}";
    $fn = "<a href=\"func_properties.php{$query}\">" . $row[proname] . "</a>";
    // Strip off trailing delimiter
    $tgargs = trim(substr($row[tgargs], 0, strlen($row[tgargs]) - 4));
    $params = explode('\\000', $tgargs);
    for ($i = 0; $i < sizeof($params); $i++) {
        $params[$i] = str_replace("'", "\\'", $params[$i]);
    }
    $defn = implode("', '", $params);
    $tg_query = "?db={$db}&rel_type=trigger&server={$server}";
    ?>
	<table border=<?php 
    echo $cfgBorder;
    ?>
>
	<TR>
	<TH><?php 
コード例 #4
0
ファイル: tbl_properties.inc.php プロジェクト: CMMCO/Intranet
        echo "\n\t\t\t\t<th>{$strReferences}</th>\n\t\t\t\t<th>{$strPrimary}</th>\n\t\t\t";
        $sql_get_fields = "\n\t\t\t\tSELECT \n\t\t\t\t\ta.attnum,\n\t\t\t\t\ta.attname AS field,\n\t\t\t\t\tc.relname AS table_name\n\t\t\t\tFROM \n\t\t\t\t\tpg_class c, pg_attribute a\n\t\t\t\tWHERE \n\t\t\t\t\tc.relname NOT LIKE 'pg%'\n\t\t\t\t\tAND relkind = 'r'\n\t\t\t\t\tAND a.attnum > 0\n\t\t\t\t\tAND a.attrelid = c.oid\n\t\t\t\tORDER BY\n\t\t\t\t\ttable_name, attnum\n\t\t\t\t";
        $fields = @pg_exec($link, pre_query($sql_get_fields)) or pg_die(pg_errormessage(), $sql_get_fields, __FILE__, __LINE__);
        $num_fields_fk = @pg_numrows($fields);
        for ($i_field = 0; $i_field < $num_fields_fk; $i_field++) {
            $field = pg_result($fields, $i_field, "field");
            $table_name = pg_result($fields, $i_field, "table_name");
            $strFKFields .= "<option value='" . addslashes("{$cfgQuotes}{$table_name}{$cfgQuotes}({$cfgQuotes}{$field}{$cfgQuotes})") . "'>{$table_name}({$field})\n";
            // $aryField[] = "$cfgQuotes$sel_tables[$i_tabs]$cfgQuotes.$cfgQuotes$field$cfgQuotes";
        }
    }
    echo "\n\t\t\t<th>{$strIndex}</th>\n\t\t\t<th>{$strUnique}</th>\n\t\t";
}
echo "</tr>";
$sql_get_types = "\n\t\tSELECT typname \n\t\tFROM pg_type pt\n\t\tWHERE typname NOT LIKE '\\\\_%' AND typrelid = 0\n\t\tORDER BY typname\n\t";
$types = pg_exec($link, pre_query($sql_get_types)) or pg_die(pg_errormessage(), $sql_get_types);
for ($i = 0; $i < $num_fields; $i++) {
    if (isset($result)) {
        $row = pg_fetch_array($result, $i);
    }
    $bgcolor = $cfgBgcolorOne;
    $i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
    ?>
    <tr bgcolor="<?php 
    echo $bgcolor;
    ?>
">
    <td valign=\"top\">
      <input type="text" name="field_name[]" size="20" value="<?php 
    if (isset($row) && isset($row[field])) {
        echo $row[field];
コード例 #5
0
	/**
	 * @param $record
	 * @return array
	 */
	public static function getTrtInfo($record)
	{
		global $Proj, $project_id;
		$trtinfo = array();
		$baseline_event_id = $Proj->firstEventId;
		$randomization_date = get_single_field($record, $project_id, $baseline_event_id, 'rand_suppex_rndstdtc', null);
		if ($randomization_date != '') {
			$trtinfo['rand_date'] = $randomization_date;
			$trtinfo['rfxstdtc'] = get_single_field($record, $project_id, $baseline_event_id, 'dm_rfxstdtc', null);
			$trtinfo['rfstdtc'] = get_single_field($record, $project_id, $baseline_event_id, 'dm_rfstdtc', null);
			$trtinfo['regimen'] = $regimen = strtolower(get_single_field($record, $project_id, $baseline_event_id, 'rand_suppex_randreg', null));
			$trtinfo['dur'] = $duration = get_single_field($record, $project_id, $baseline_event_id, $regimen . '_suppex_trtdur', null);
			$trtinfo['num'] = $num = substr($duration, strpos($duration, 'P') + 1, strlen($duration) - 2);
			$trtinfo['arm'] = $num . ' Weeks';
			/**
			 * check to see if the subject has an existing schedule on an existing arm
			 */
			$sub = "SELECT DISTINCT e.arm_id from redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id";
			$sched_arm_result = db_query("SELECT arm_name FROM redcap_events_arms WHERE project_id = $project_id AND arm_id IN (" . pre_query($sub) . ") LIMIT 1");
			if ($sched_arm_result) {
				$trtinfo['timing_arm'] = db_result($sched_arm_result, 0, 'arm_name');
				db_free_result($sched_arm_result);
			}
			$timing_arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = $project_id AND arm_name = '{$trtinfo['arm']}' LIMIT 1");
			if ($timing_arm_result) {
				$trtinfo['timing_arm_num'] = db_result($timing_arm_result, 0, 'arm_num');
				db_free_result($timing_arm_result);
			}
			$q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = {$trtinfo['timing_arm_num']} order by m.day_offset, m.descrip");
			if ($q) {
				while ($q_row = db_fetch_assoc($q)) {
					$trtinfo['timing_events'][$q_row['descrip']] = $q_row['event_id'];
					$trtinfo['timing_offsets'][$q_row['descrip']] = $q_row['day_offset'];
					$trtinfo['timing_min'][$q_row['descrip']] = $q_row['offset_min'];
					$trtinfo['timing_max'][$q_row['descrip']] = $q_row['offset_max'];
				}
			}
		}
		return $trtinfo;
	}
コード例 #6
0
ファイル: tbl_alter_drop.php プロジェクト: CMMCO/Intranet
    $client = getenv("HTTP_USER_AGENT");
    if (ereg('[^(]*\\((.*)\\)[^)]*', $client, $regs)) {
        $os = $regs[1];
        // this looks better under WinX
        if (eregi("Win", $os)) {
            $crlf = "\r\n";
        }
    }
    $drop_field = $field;
    $create_table = get_table_def($link, $table, $crlf);
    unset($sql_query);
    $exec_query = "CREATE TABLE {$cfgQuotes}{$new_table}{$cfgQuotes} AS SELECT {$strFieldList} FROM {$cfgQuotes}{$table}{$cfgQuotes}";
    pg_exec($link, pre_query($exec_query)) or pg_die(pg_errormessage(), $exec_query, __FILE__, __LINE__);
    $sql_query .= $exec_query . ";\n";
    $exec_query = "DROP TABLE {$cfgQuotes}{$table}{$cfgQuotes}";
    pg_exec($link, pre_query($exec_query)) or pg_die(pg_errormessage(), $exec_query, __FILE__, __LINE__);
    $sql_query .= $exec_query . ";\n";
    $exec_query = $create_table;
    pg_exec($link, pre_query($exec_query)) or pg_die(pg_errormessage(), $exec_query, __FILE__, __LINE__);
    $sql_query .= $exec_query;
    $exec_query = "INSERT INTO {$cfgQuotes}{$table}{$cfgQuotes} SELECT * FROM {$cfgQuotes}{$new_table}{$cfgQuotes}";
    pg_exec($link, pre_query($exec_query)) or pg_die(pg_errormessage(), $exec_query, __FILE__, __LINE__);
    $sql_query .= $exec_query . ";\n";
    $exec_query = "DROP TABLE {$cfgQuotes}{$new_table}{$cfgQuotes}";
    pg_exec($link, pre_query($exec_query)) or pg_die(pg_errormessage(), $exec_query, __FILE__, __LINE__);
    $sql_query .= $exec_query . ";\n";
    $message = "{$strTable} {$table} {$strHasBeenAltered}";
    include "tbl_properties.php";
    exit;
}
include "footer.inc.php";
コード例 #7
0
/**
 * @param $record
 * @param $event_id
 * @param $group_id
 * @param $debug
 */
function schedule_surveys($record, $event_id, $group_id, $debug)
{
	global $Proj, $project_id, $user_rights, $table_pk;
	/**
	 * if the user is in a DAG
	 */
	if ($user_rights['group_id'] != "") {
		/**
		 * does this record exist?
		 */
		$q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' LIMIT 1");
		if (db_num_rows($q) > 0) {
			/**
			 * is the record in this users DAG?
			 */
			$q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' AND field_name = '__GROUPID__' AND value = '{$user_rights['group_id']}' LIMIT 1");
			if (db_num_rows($q) < 1) {
				/**
				 * record is not in Users DAG!
				 */
				REDCap::logEvent('Scheduled record is not in users DAG', '', '', $record, $event_id, $project_id);
				exit;
			}
		}
	}
	/**
	 * check to see if the subject has an existing schedule on an existing arm
	 */
	$sub = "SELECT DISTINCT e.arm_id from redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id";
	$sched_arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = $project_id AND arm_id IN (" . pre_query($sub) . ")");
	if ($sched_arm_result) {
		$trt = Treatment::getTrtInfo($record);
		if ($debug) {
			error_log(print_r($trt, true));
		}
		$tx_start_date = $trt['rfxstdtc'];
		$rand_date = $trt['rand_date'];
		$dates = array();
		$arm_num = db_result($sched_arm_result, 0, 'arm_num');
		if (isset($arm_num) && $arm_num != '') { // subject has an existing schedule. keep existing event_id > arm structure
			if ($arm_num != '1') { // make sure we don't put anything in the first arm
				$q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip");
				if ($q) {
					while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty
						/**
						 * get the event date ($rand_date for baseline and $tx_start_date + day_offset)
						 */
						$row['day_offset'] = $arm_num != $trt['timing_arm_num'] ? $trt['timing_offsets'][$row['descrip']] : $row['day_offset'];
						if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) {
							$this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null;
						} else {
							$this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null;
						}
						$dates[$row['event_id']] = $this_event_date;
					}
					db_free_result($q);
				}
			} else {
				REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id);
			}
		} else { // subject's schedule is new. put dates into event_ids for this arm
			$arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = '$project_id' AND arm_name = '{$trt['arm']}'");
			if ($arm_result) {
				$arm_num = db_result($arm_result, 0, 'arm_num');
				if ($arm_num != '1') {
					$q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip");
					if ($q) {
						while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty
							/**
							 * get the event date ($rand_date for baseline and $tx_start_date + day_offset)
							 */
							if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) {
								$this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null;
							} else {
								$this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null;
							}
							$dates[$row['event_id']] = $this_event_date;
						}
						db_free_result($q);
					}
				} else {
					REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id);
				}
				db_free_result($arm_result);
			}
		}
		if ($debug) {
			error_log(print_r($dates, true));
		}
		if (!empty($dates)) {
			/**
			 * do we have an existing schedule?
			 */
			$sql = "SELECT c.event_date, c.baseline_date, e.* FROM redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id AND e.arm_id IN (" . pre_query($sub) . ")";
			$sched_result = db_query($sql);
			if ($sched_result) {
				$sql_all = array();
				$sql_errors = array();
				if (db_num_rows($sched_result) > 0) {
					while ($sched_row = db_fetch_assoc($sched_result)) {
						$base_date = in_array($sched_row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc'];
						/**
						 * if the scheduled date is in the $dates array, we don't care about it, so ignore it and remove from $dates
						 * if we have an existing schedule and the dates have changed, update the schedule and remove from $dates
						 * if the base date has changed, update it and the schedule
						 * whatever is left will be new dates, insert into schedule
						 */
						if ($dates[$sched_row['event_id']] == $sched_row['event_date']) {
							unset($dates[$sched_row['event_id']]);
						}
						if (isset($dates[$sched_row['event_id']]) && $dates[$sched_row['event_id']] != '' && $sched_row['event_date'] != $dates[$sched_row['event_id']]) { // the date has changed. update the date.
							$sql = "UPDATE redcap_events_calendar SET event_date = '{$dates[$sched_row['event_id']]}' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND event_date = '{$sched_row['event_date']}'";
							if (!$debug) {
								if (db_query($sql)) {
									$sql_all[] = $sql;
									log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event");
								} else {
									$sql_errors[] = $sql;
								}
							} else {
								error_log($sql);
							}
							unset($dates[$sched_row['event_id']]);
						}
						if ($base_date != $sched_row['baseline_date']) { // the base_date has changed. this will only occur if the treatment start date or randomization date are changed in the study.
							$sql = "UPDATE redcap_events_calendar SET baseline_date = '" . prep($base_date) . "' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND baseline_date = '{$sched_row['baseline_date']}'";
							if (!$debug) {
								if (db_query($sql)) {
									$sql_all[] = $sql;
									log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event");
								} else {
									$sql_errors[] = $sql;
								}
							} else {
								error_log($sql);
							}
							unset($dates[$sched_row['event_id']]);
						}
					}
					foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule
						$base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc'];
						if (isset($date) && $date != "") { //Add to table
							$sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')";
							if (!$debug) {
								if (db_query($sql)) {
									$sql_all[] = $sql;
								} else {
									$sql_errors[] = $sql;
								}
							} else {
								error_log($sql);
							}
						} else {
							REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id);
						}
					}
					log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling");
				} else {
					foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule
						$base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc'];
						if (isset($date) && $date != "") { //Add to table
							$sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')";
							if (!$debug) {
								if (db_query($sql)) {
									$sql_all[] = $sql;
								} else {
									$sql_errors[] = $sql;
								}
							} else {
								error_log($sql);
							}
						} else {
							REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id);
						}
					}
					log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling");
				}
			}
			db_free_result($sched_result);
		}
		db_free_result($sched_arm_result);
	}
}
コード例 #8
0
ファイル: tbl_properties.php プロジェクト: CMMCO/Intranet
            ?>
</a></td>
		<?php 
        }
        // end print view
        ?>
		</tr>
		<?php 
    }
    ?>
   </table>
   <?php 
}
$sql_pri_keys = "\n\t\tSELECT \n\t\t\tic.relname AS index_name, \n\t\t\tbc.relname AS tab_name, \n\t\t\tta.attname AS column_name,\n\t\t\ti.indisunique AS unique_key,\n\t\t\ti.indisprimary AS primary_key\n\t\tFROM \n\t\t\tpg_class bc,\n\t\t\tpg_class ic,\n\t\t\tpg_index i,\n\t\t\tpg_attribute ta,\n\t\t\tpg_attribute ia\n\t\tWHERE \n\t\t\tbc.oid = i.indrelid\n\t\t\tAND ic.oid = i.indexrelid\n\t\t\tAND ia.attrelid = i.indexrelid\n\t\t\tAND ta.attrelid = bc.oid\n\t\t\tAND bc.relname = '{$table}'\n\t\t\tAND ta.attrelid = i.indrelid\n\t\t\tAND ta.attnum = i.indkey[ia.attnum-1]\n\t\tORDER BY \n\t\t\tindex_name, tab_name, column_name\n\t";
// echo $sql_pri_keys;
if (!($pri_result = pg_exec($link, pre_query($sql_pri_keys)))) {
    pg_die(pg_errormessage(), $sql_pri_keys, __FILE__, __LINE__);
} else {
    $num_keys = @pg_numrows($pri_result);
    //	echo "Num keys: ", $num_keys;
    if ($num_keys > 0) {
        ?>
		<br>
		<table border=<?php 
        echo $cfgBorder;
        ?>
>
		<tr>
		<th><?php 
        echo $strKeyname;
        ?>
コード例 #9
0
ファイル: view_create.php プロジェクト: CMMCO/Intranet
        ?>
	<form method=POST>
		<?php 
        echo $strView, " ", $strName;
        ?>
		<br>
		<input type=text name="view_name" value=""><br>
		<?php 
        echo $strFields, "<br>";
        ?>
		<select name="sel_fields[]" multiple size=10>
	<?php 
        for ($i_tabs = 0; $i_tabs < count($sel_tables); $i_tabs++) {
            $strSelTables .= "<input type=hidden name=\"sel_tables[]\" value=\"{$sel_tables[$i_tabs]}\">\n";
            $sql_get_fields = "\n\t\t\tSELECT \n\t\t\t\ta.attnum,\n\t\t\t\ta.attname AS field\n\t\t\tFROM \n\t\t\t\tpg_class c, pg_attribute a\n\t\t\tWHERE \n\t\t\t\tc.relname = '{$sel_tables[$i_tabs]}'\n\t\t\t\tAND a.attnum > 0\n\t\t\t\tAND a.attrelid = c.oid\n\t\t\tORDER BY\n\t\t\t\tattnum\n\t\t\t";
            $fields = @pg_exec($link, pre_query($sql_get_fields)) or pg_die(pg_errormessage(), $sql_get_fields, __FILE__, __LINE__);
            $num_fields = @pg_numrows($fields);
            for ($i_field = 0; $i_field < $num_fields; $i_field++) {
                $field = pg_result($fields, $i_field, "field");
                echo "<option value='" . addslashes("{$cfgQuotes}{$sel_tables[$i_tabs]}{$cfgQuotes}.{$cfgQuotes}{$field}{$cfgQuotes}") . "'>{$cfgQuotes}{$sel_tables[$i_tabs]}{$cfgQuotes}.{$cfgQuotes}{$field}{$cfgQuotes}\n";
                $aryField[] = "{$cfgQuotes}{$sel_tables[$i_tabs]}{$cfgQuotes}.{$cfgQuotes}{$field}{$cfgQuotes}";
            }
        }
        ?>
		</select>
		
		<br>
		<?php 
        $arFields[] = " ";
        for ($i_prim = 0; $i_prim < count($aryField); $i_prim++) {
            $arFields[] = $aryField[$i_prim];
コード例 #10
0
ファイル: tbl_dump.php プロジェクト: ColBT/php_tut
 }
 print "{$crlf}  {$strDatabase}: {$cfgQuotes}{$db}{$cfgQuotes}{$crlf}";
 print "  {$rel_text} : {$cfgQuotes}{$table}{$cfgQuotes} {$crlf}";
 print "  " . date("Y-m-d H:m:i") . $crlf;
 print "-------------------------------------------------------- */ {$crlf} {$crlf}";
 if ($rel_type == "table") {
     if ($drop) {
         print "DROP TABLE {$cfgQuotes}{$table}{$cfgQuotes};{$crlf}";
     }
     print get_table_def($link, $table, $crlf) . "{$crlf}";
 } else {
     if ($drop) {
         print "DROP VIEW {$cfgQuotes}{$table}{$cfgQuotes};{$crlf}";
     }
     $sql_get_views = "SELECT * FROM pg_views WHERE viewname = '{$table}'";
     $views = @pg_exec($link, pre_query($sql_get_views));
     if (pg_numrows($views)) {
         $view = pg_fetch_array($views, 0);
         print "CREATE VIEW {$cfgQuotes}{$table}{$cfgQuotes} AS {$crlf}  {$view['definition']} {$crlf}";
     }
 }
 if ($what == "data") {
     if ($rel_type == "table") {
         print "{$crlf}/* -------------------------------------------------------- {$crlf}";
         print "  {$strDumpingData} {$cfgQuotes}{$table}{$cfgQuotes} {$crlf}";
         print "-------------------------------------------------------- */ {$crlf}";
         get_table_content($link, $table, "my_handler");
     } else {
         print "{$crlf}/* -----------------  No Data In Views  ---------------- */ {$crlf}";
     }
 }
コード例 #11
0
ファイル: user_admin.php プロジェクト: CMMCO/Intranet
    $iNumUsers = pg_numrows($rsUsers);
    if ($iNumUsers > 0) {
        echo "\n\t\t\t\t<table border=\"{$cfgBorder}\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>{$strUserName}</th>\n\t\t\t\t\t\t<th>{$strSysID}</th>\n\t\t\t\t\t\t<th>{$strCreateDB}</th>\n\t\t\t\t\t\t<th>{$strSuperUser}</th>\n\t\t\t\t\t\t<!--th>{$strCatUpd}</th-->\n\t\t\t\t\t\t<th>{$strExpires}</th>\n\t\t\t\t\t\t<th>{$strAction}</th>\n\t\t\t\t\t</tr>\n\t\t\t";
        for ($iUsers = 0; $iUsers < $iNumUsers; $iUsers++) {
            $aryUsers = pg_fetch_array($rsUsers, $iUsers);
            $strBGcolor = $cfgBgcolorOne;
            $iRows++ % 2 ? 0 : ($strBGcolor = $cfgBgcolorTwo);
            $qrDel = urlencode("DROP USER {$cfgQuotes}{$aryUsers['usename']}{$cfgQuotes}");
            $strDelZR = urlencode("User {$aryUsers['usename']} deleted successfully.");
            echo "\n\t\t\t\t\t<tr bgcolor=\"{$strBGcolor}\">\n\t\t\t\t\t\t<td>{$aryUsers['usename']}</td>\n\t\t\t\t\t\t<td>{$aryUsers['usesysid']}</td>\n\t\t\t\t\t\t<td>" . bool_YesNo($aryUsers[usecreatedb]) . "</td>\n\t\t\t\t\t\t<td>" . bool_YesNo($aryUsers[usesuper]) . "</td>\n\t\t\t\t\t\t<!--td>" . bool_YesNo($aryUsers[usecatupd]) . "</td-->\n\t\t\t\t\t\t<td>{$aryUsers['valuntil']}</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<a href=\"sql.php?server={$server}&sql_query={$qrDel}&goto=user_admin.php&zero_rows={$strDelZR}\">{$strDelete}</a> |\n\t\t\t\t\t\t\t<a href=\"user_admin.php?server={$server}&action=edit&usr={$aryUsers['usename']}\">{$strEdit}</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
        }
        echo "</table>";
    }
} elseif ($action == "edit" || $action == "new_user") {
    $qrUserInfo = "SELECT * FROM pg_shadow WHERE usename = '{$usr}'";
    $rsUserInfo = @pg_exec($link, pre_query($qrUserInfo));
    $aryUser = @pg_fetch_array($rsUserInfo, 0);
    if ($aryUser[usecreatedb] == "t") {
        $strSelCreateDB = "checked";
    } else {
        unset($strSelCreateDB);
    }
    if ($aryUser[usesuper] == "t") {
        $strSelSuper = "checked";
    } else {
        unset($strSelSuper);
    }
    if ($aryUser[usecatupd] == "t") {
        $strSelCatUpd = "checked";
    } else {
        unset($strSelCatUpd);
コード例 #12
0
ファイル: tbl_rename.php プロジェクト: CMMCO/Intranet
<?php

/* $Id: tbl_rename.php,v 1.2 2001/02/02 06:03:08 dwilson Exp $ */
$old_name = $table;
$table = $new_name;
include "header.inc.php";
$sql_query = "ALTER TABLE {$cfgQuotes}{$old_name}{$cfgQuotes} RENAME TO {$cfgQuotes}{$new_name}{$cfgQuotes}";
$result = pg_exec($link, pre_query($sql_query)) or pg_die(pg_errormessage(), $sql_query, __FILE__, __LINE__);
$table = $old_name;
eval("\$message = \"{$strRenameTableOK}\";");
$table = $new_name;
include "tbl_properties.php";
exit;
include "footer.inc.php";
コード例 #13
0
ファイル: left.php プロジェクト: CMMCO/Intranet
			<a class="item" HREF="javascript:void(0)" onClick="expandIt('el200'); return false;"><img NAME="imEx" SRC="images/plus.gif" BORDER="0" ALT="+" width="9" height="9" ID="el200Img"></a>&nbsp;<a class="item"><font color="black" class="heada"><?php 
    echo $strSystemTables;
    ?>
</font></a>
		</div>
		<div ID="el200Child" CLASS="child">
<?php 
    $db = $cfgDefaultDB;
    $conn_str = "user={$cfgServer['stduser']} password={$cfgServer['stdpass']} ";
    if (!$cfgServer[local]) {
        $conn_str .= "host={$cfgServer['host']} ";
    }
    $conn_str .= "port={$cfgServer['port']} dbname={$db}";
    $dbh_tbl = pg_connect($conn_str) or pg_die(pg_errormessage(), $conn_str, __FILE__, __LINE__);
    $sql_get_tbls = "select relname from pg_class where relname ~ 'pg_.*' and relkind = 'r' or relkind = 'v' order by relname";
    $tbl_res = pg_exec($dbh_tbl, pre_query($sql_get_tbls));
    $num_tables = @pg_numrows($tbl_res);
    for ($j = 0; $j < $num_tables; $j++) {
        $table = pg_result($tbl_res, $j, "relname");
        $query_str = "sql_query=" . urlencode("SELECT * FROM {$cfgQuotes}{$table}{$cfgQuotes}") . "&server={$server}&db={$db}&table=" . urlencode($table);
        ?>
&nbsp;&nbsp;<a target="main" href="sql.php?<?php 
        echo $query_str;
        ?>
&goto=tbl_properties.php"><img src="images/browse.gif" border="0" alt="<?php 
        echo "{$strBrowse} {$strTable}: {$table}";
        ?>
"></a>&nbsp;<a class="item" target="main" HREF="tbl_properties.php?server=<?php 
        echo $server;
        ?>
&db=<?php 
コード例 #14
0
ファイル: db_details.php プロジェクト: ColBT/php_tut
                        echo $strDrop;
                        ?>
</td>
					<?php 
                    }
                    ?>
					</tr>
					<?php 
                }
                echo "</table>\n";
            }
            break;
        case "trigger":
            // Triggers
            $sql_get_trig = "\n\t\t\t\tSELECT ptr.*, pt.typname as result, pc.relname as relname\n\t\t\t\tFROM pg_trigger ptr, pg_type pt, pg_class pc\n\t\t\t\tWHERE ptr.tgtype = pt.oid \n\t\t\t\tAND ptr.tgrelid = pc.oid\n\t\t\t\tAND tgname !~ 'pg_.*' \n\t\t\t\tORDER BY tgname\n\t\t\t";
            $triggers = @pg_exec($link, pre_query($sql_get_trig)) or pg_die(pg_errormessage(), $sql_get_trig, __FILE__, __LINE__);
            $num_triggers = @pg_numrows($triggers);
            if ($num_triggers == 0) {
                echo "<br/><b>{$strNo} {$strTriggers} {$strFound}</b><br/>";
                echo "<li><a href=\"trig_create.php?server={$server}&db={$db}&goto=main.php\">{$strCreateNew} {$strTrigger}</a><br/>";
            } else {
                echo "<table border={$cfgBorder}>\n<tr bgcolor=lightgrey><th align=center>{$strRetType}</th><th align=center>{$strTrigger}</th>";
                echo "<th align=center>{$strTable}</th><th align=center>{$strIsConstraint}</th><th colspan=2>{$strAction}</th></tr>\n";
                for ($i = 0; $i < $num_triggers; $i++) {
                    $trig_ary = pg_fetch_array($triggers, $i);
                    $bgcolor = $cfgBgcolorOne;
                    $i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
                    $classname = $trig_ary[relname];
                    $trig_disp = "{$trig_ary['tgname']}";
                    $trig_is_const = bool_YesNo($trig_ary[tgisconstraint]);
                    // $trig_is_const = ($trig_ary[tgisconstraint]) == 't') ? 'Y' : 'N';
コード例 #15
0
ファイル: lib.inc.php プロジェクト: ColBT/php_tut
 function get_table_def($link, $table, $crlf)
 {
     global $drop, $drop_field, $cfgQuotes, $noACL;
     unset($schema_create);
     if (!empty($drop)) {
         //		$schema_create .= "DROP TABLE IF EXISTS $table;$crlf";
     }
     $schema_create .= "CREATE TABLE {$cfgQuotes}{$table}{$cfgQuotes} ({$crlf}";
     $sql_get_fields = "\n\t\tSELECT \n\t\t\ta.attnum,\n\t\t\ta.attname AS field, \n\t\t\tt.typname AS type, \n\t\t\ta.attlen AS length,\n\t\t\ta.atttypmod AS lengthvar,\n\t\t\ta.attnotnull AS notnull\n\t\tFROM \n\t\t\tpg_class c, \n\t\t\tpg_attribute a, \n\t\t\tpg_type t\n\t\tWHERE \n\t\t\tc.relname = '{$table}'\n\t\t\tand a.attnum > 0\n\t\t\tand a.attrelid = c.oid\n\t\t\tand a.atttypid = t.oid\n\t\tORDER BY a.attnum\n\t";
     $result = pg_exec($link, pre_query($sql_get_fields)) or pg_die(pg_errormessage(), $sql_get_fields, __FILE__, __LINE__);
     $i = 0;
     while ($row = @pg_fetch_array($result, $i++)) {
         if ($row[field] != $drop_field) {
             $sql_get_default = "\n\t\t\t\tSELECT d.adsrc AS rowdefault\n\t\t\t\tFROM pg_attrdef d, pg_class c \n\t\t\t\tWHERE \n\t\t\t\t\tc.relname = '{$table}' \n\t\t\t\t\tAND c.oid = d.adrelid \n\t\t\t\t\tAND d.adnum = {$row['attnum']}\n\t\t\t";
             $def_res = pg_exec($link, pre_query($sql_get_default)) or pg_die(pg_errormessage(), $sql_get_default, __FILE__, __LINE__);
             if (!$def_res) {
                 unset($row[rowdefault]);
             } else {
                 $row[rowdefault] = @pg_result($def_res, 0, "rowdefault");
             }
             if ($row[type] == "bpchar") {
                 // Internally stored as bpchar, but isn't accepted in a CREATE TABLE
                 $row[type] = "char";
             }
             $schema_create .= "   {$cfgQuotes}{$row['field']}{$cfgQuotes} {$row['type']}";
             if (eregi("char", $row[type])) {
                 if ($row[lengthvar] > 0) {
                     $schema_create .= "(" . ($row[lengthvar] - 4) . ")";
                 }
             }
             if (eregi("numeric", $row[type])) {
                 //Marcellus fixed problem on 5-25-00
                 $schema_create .= "(";
                 $schema_create .= sprintf("%s,%s", $row[lengthvar] >> 16 & 0xffff, $row[lengthvar] - 4 & 0xffff);
                 $schema_create .= ")";
             }
             if (!empty($row[rowdefault])) {
                 if (eregi("text|name|char|date|time|bool", $row[type])) {
                     //$delim = "'";
                 } else {
                     unset($delim);
                 }
                 $schema_create .= " DEFAULT " . $delim . $row[rowdefault] . $delim;
             }
             if ($row["notnull"] == "t") {
                 $schema_create .= " NOT NULL";
             }
             $schema_create .= ",{$crlf}";
         }
     }
     // Generate constraint clauses for UNIQUE and PRIMARY KEY constraints
     $sql_pri_keys = "\n\t\tSELECT \n\t\t\tic.relname AS index_name, \n\t\t\tbc.relname AS tab_name, \n\t\t\tta.attname AS column_name,\n\t\t\ti.indisunique AS unique_key,\n\t\t\ti.indisprimary AS primary_key\n\t\tFROM \n\t\t\tpg_class bc,\n\t\t\tpg_class ic,\n\t\t\tpg_index i,\n\t\t\tpg_attribute ta,\n\t\t\tpg_attribute ia\n\t\tWHERE \n\t\t\tbc.oid = i.indrelid\n\t\t\tAND ic.oid = i.indexrelid\n\t\t\tAND ia.attrelid = i.indexrelid\n\t\t\tAND ta.attrelid = bc.oid\n\t\t\tAND bc.relname = '{$table}'\n\t\t\tAND ta.attrelid = i.indrelid\n\t\t\tAND ta.attnum = i.indkey[ia.attnum-1]\n\t\tORDER BY \n\t\t\tindex_name, tab_name, column_name\n\t";
     $result = @pg_exec($link, pre_query($sql_pri_keys)) or pg_die(pg_errormessage(), $sql_pri_keys, __FILE__, __LINE__);
     $i = 0;
     while ($row = @pg_fetch_array($result, $i++)) {
         if ($row[column_name] != $drop_field) {
             if ($row[primary_key] == "t") {
                 if (!empty($primary_key)) {
                     $primary_key .= ", ";
                 }
                 $primary_key .= "{$cfgQuotes}{$row['column_name']}{$cfgQuotes}";
                 $primary_key_name = $row[index_name];
             } else {
                 // We have to store all this info becuase it's possible that there is a multi-column key..
                 // .. we can then loop through it again and build the statement
                 $index_rows[$row[index_name]][table] = $table;
                 $index_rows[$row[index_name]][unique] = $row[unique_key] == "t" ? " UNIQUE" : "";
                 $index_rows[$row[index_name]][column_names] .= "{$cfgQuotes}{$row['column_name']}{$cfgQuotes}, ";
             }
         }
     }
     if (!empty($index_rows)) {
         while (list($idx_name, $props) = each($index_rows)) {
             $props[column_names] = ereg_replace(", \$", "", $props[column_names]);
             $index_create .= "CREATE " . $props[unique] . " INDEX {$cfgQuotes}{$idx_name}{$cfgQuotes} ON {$cfgQuotes}{$table}{$cfgQuotes} (" . $props[column_names] . ");{$crlf}";
         }
     }
     if (!empty($primary_key)) {
         $schema_create .= "   CONSTRAINT {$cfgQuotes}{$primary_key_name}{$cfgQuotes} PRIMARY KEY ({$primary_key}),{$crlf}";
     }
     // Generate constraint clauses for CHECK constraints
     $sql_checks = "\n\t\tSELECT \n\t\t\trcname as index_name, \n\t\t\trcsrc \n\t\tFROM \n\t\t\tpg_relcheck,\n\t\t\tpg_class bc\n\t\tWHERE \n\t\t\trcrelid = bc.oid \n\t\t\tand bc.relname = '{$table}'\n\t\t\tand not exists \n\t\t\t(select * from pg_relcheck as c, pg_inherits as i \n\t\t\twhere i.inhrelid = pg_relcheck.rcrelid \n\t\t\tand c.rcname = pg_relcheck.rcname \n\t\t\tand c.rcsrc = pg_relcheck.rcsrc \n\t\t\tand c.rcrelid = i.inhparent)\n\t";
     $result = @pg_exec($link, $sql_checks) or pg_die(pg_errormessage(), $sql_checks, __FILE__, __LINE__);
     $i = 0;
     while ($row = @pg_fetch_array($result, $i++)) {
         $schema_create .= "   CONSTRAINT {$cfgQuotes}{$row['index_name']}{$cfgQuotes} CHECK {$row['rcsrc']},{$crlf}";
     }
     $schema_create = ereg_replace("," . $crlf . "\$", "", $schema_create);
     $index_create = ereg_replace("," . $crlf . "\$", "", $index_create);
     $schema_create .= "{$crlf});{$crlf}";
     if (!empty($index_create)) {
         $schema_create .= $index_create;
     }
     if (!$noACL) {
         $sql_get_privilege = "SELECT relacl FROM pg_class WHERE relname = '{$table}'";
         if (!($res = @pg_exec($link, $sql_get_privilege))) {
             pg_die(pg_errormessage($link), $sql_get_privilege, __FILE__, __LINE__);
         } else {
             // query must return exactely one row (check this ?)
             $row = pg_fetch_array($res, 0);
             if (!empty($row[relacl])) {
                 $priv = trim(ereg_replace("[\\{\"]", "", $row[relacl]));
                 $users = explode(",", $priv);
                 for ($iUsers = 0; $iUsers < count($users); $iUsers++) {
                     $aryUser = explode("=", $users[$iUsers]);
                     if ($aryUser[0] == "") {
                         $user = "******";
                     } else {
                         if (eregi("^group", $aryUser[0])) {
                             $user = eregi_replace("^group ([[:alnum:]]+)", "GROUP {$cfgQuotes}\\1{$cfgQuotes}", $aryUser[0]);
                         } else {
                             $user = "******";
                         }
                     }
                     $privileges = $aryUser[1];
                     unset($acl_priv);
                     if (strchr($privileges, "a")) {
                         $acl_priv .= "INSERT,";
                     }
                     if (strchr($privileges, "r")) {
                         $acl_priv .= "SELECT,";
                     }
                     if (strchr($privileges, "w")) {
                         $acl_priv .= "UPDATE,DELETE,";
                     }
                     if (strchr($privileges, "R")) {
                         $acl_priv .= "RULE,";
                     }
                     $acl_priv = ereg_replace(",\$", "", $acl_priv);
                     if ($acl_priv == "INSERT,SELECT,UPDATE,DELETE,RULE") {
                         $acl_priv = "ALL";
                     }
                     if (!empty($acl_priv)) {
                         $acl_schema .= "GRANT {$acl_priv} ON {$cfgQuotes}{$table}{$cfgQuotes} TO {$user};{$crlf}";
                     } else {
                         // $acl_schema .= "REVOKE ALL ON $cfgQuotes$table$cfgQuotes FROM $cfgQuotes$user$cfgQuotes;$crlf";
                     }
                 }
                 // Close for loop
             }
             $schema_create .= $acl_schema;
         }
     }
     return stripslashes($schema_create);
 }
コード例 #16
0
ファイル: func_properties.php プロジェクト: CMMCO/Intranet
<?php

if (!isset($message)) {
    include "header.inc.php";
} else {
    show_message($message);
}
$strRevArgs = ereg_replace(",", " ", $arg_list);
$sql_func_props = "\n\tSELECT \n\t\tpc.oid,\n\t\tproname, \n\t\tlanname as language,\n\t\tpt.typname as return_type,\n\t\tpa.typname as argtype,\n\t\tprosrc as source,\n\t\toidvectortypes(pc.proargtypes) AS arguments\n\tFROM \n\t\tpg_proc pc, pg_language pl, pg_type pt, pg_type pa\n\tWHERE \n\t\tpc.oid = '{$function_oid}'::oid\n\t\tAND pc.prolang = pl.oid\n\t\tAND pc.prorettype = pt.oid\n\tUNION\n\tSELECT \n\t\tpc.oid,\n\t\tproname, \n\t\tlanname AS language,\n\t\t'OPAQUE' AS return_type,\n\t\tpa.typname AS argtype,\n\t\tprosrc AS source,\n\t\toidvectortypes(pc.proargtypes) AS arguments\n\tFROM \n\t\tpg_proc pc, pg_language pl, pg_type pa\n\tWHERE \n\t\tpc.oid = '{$function_oid}'::oid\n\t\tAND pc.prolang = pl.oid\n\t\tAND pc.prorettype = 0\n\t";
// echo $sql_func_props;
$res_props = pg_exec($link, pre_query($sql_func_props)) or pg_die(pg_errormessage(), $sql_func_props, __FILE__, __LINE__);
$row = @pg_fetch_array($res_props, 0);
$strArgList = ereg_replace(" ", ", ", $row[arguments]);
$query = "?server={$server}&db={$db}&rel_type={$rel_type}&function_oid={$row['oid']}";
$func_sql = "{$cfgQuotes}{$row['proname']}{$cfgQuotes}" . "({$strArgList})";
?>
<table border=<?php 
echo $cfgBorder;
?>
>
<TR>
<TH><?php 
echo $strFunc;
?>
</TH>
<TH><?php 
echo $strRetType;
?>
</TH>
<TH><?php 
echo $strLang;
コード例 #17
0
ファイル: oper_properties.php プロジェクト: CMMCO/Intranet
<?php

if (!isset($message)) {
    include "header.inc.php";
} else {
    show_message($message);
}
$sql_operator_props = "\n\tSELECT\n      po.oid,\n      po.oprname,\n      po.oprcanhash,\n      po.oprcode,\n      po.oprrest,\n      po.oprjoin,\n      po.oprcom,\n      po.oprnegate,\n      po.oprlsortop as oprlsortop_orig,\n      po.oprrsortop as oprrsortop_orig,\n\t\t(select typname from pg_type pt where pt.oid=po.oprleft) as leftarg,\n\t\t(select typname from pg_type pt where pt.oid=po.oprright) as rightarg,\n\t\t(select oprname from pg_operator po1 where po1.oid=po.oprcom) as commutator,\n\t\t(select oprname from pg_operator po1 where po1.oid=po.oprnegate) as negator,\n      (select oprname from pg_operator po1 where po1.oid=po.oprlsortop) as oprlsortop,\n      (select oprname from pg_operator po1 where po1.oid=po.oprrsortop) as oprrsortop,\n\t\t(select typname from pg_type pt where pt.oid=po.oprresult) as result\n\tFROM\n\t\tpg_operator po\n\tWHERE\n\t\tpo.oid = '{$operator_oid}'\n";
if (!($res_props = pg_exec($link, pre_query($sql_operator_props)))) {
    pg_die(pg_errormessage(), $sql_operator_props, __FILE__, __LINE__);
} else {
    $row = @pg_fetch_array($res_props, 0);
    // Construct operator link
    $query = "?db={$db}&server={$server}&rel_type=operator&operator_oid=%s";
    $op = "<a href=\"oper_properties.php{$query}\">%s</a>";
    $pr_query = "?db={$db}&rel_type=operator&server={$server}";
    ?>
	<table border=<?php 
    echo $cfgBorder;
    ?>
>
	<TR>
	<TH><?php 
    echo $strProperty;
    ?>
</TH>
	<TH><?php 
    echo $strValue;
    ?>
</TH>
	</TR>
コード例 #18
0
ファイル: oper_create.php プロジェクト: CMMCO/Intranet
<?php

include "header.inc.php";
if (!isset($submit)) {
    // Set max built-in oid
    $max = 0;
    // First, get all available types
    $sql_get_types = "\n\t\t\t\t(\n\t\t\t\tSELECT typname\n\t\t\t\tFROM pg_type pt\n\t\t\t\tWHERE typname NOT LIKE '\\\\_%'\n\t\t\t\t)\n\t\t\t\tEXCEPT\n\t\t\t\t(\n\t\t\t\tSELECT relname\n\t\t\t\tFROM pg_class\n\t\t\t\tWHERE \n\t\t\t\t\trelkind = 'S' OR relname LIKE 'pg%'\n\t\t\t\t) ORDER BY typname\n\t\t\t\t";
    $types = pg_exec($link, pre_query($sql_get_types)) or pg_die(pg_errormessage(), $sql_get_types, __FILE__, __LINE__);
    // And get functions (userland) as well
    $sql_get_func = "\n\t\t\t\tSELECT \n\t\t\t\t\tproname\n\t\t\t\tFROM \n\t\t\t\t\tpg_proc pc, pg_user pu\n\t\t\t\tWHERE\n\t\t\t\t\tpc.proowner = pu.usesysid\n\t\t\t\t\tAND pc.oid > '{$max}'::oid\n            ORDER BY proname\n\t\t\t";
    $funcs = pg_exec($link, pre_query($sql_get_func)) or pg_die(pg_errormessage(), $sql_get_func, __FILE__, __LINE__);
    ?>
	<form method=POST>
	<table border="<?php 
    echo $cfgBorder;
    ?>
">
	<tr>
		<th><?php 
    echo $strProperty;
    ?>
</th>
		<th><?php 
    echo $strValue;
    ?>
</th>
	</tr>
	<tr><td><?php 
    echo $strOperator;
    ?>
コード例 #19
0
 }
 /**
  * RECORD SELECTION DROP-DOWN
  */
 print "<select id='record' class='x-form-text x-form-field' style='max-width:350px;' onchange=\"\n\t\t\t\t\twindow.location.href = app_path_webroot+page+'?pid='+pid+'&arm={$arm}&id=' + this.value + addGoogTrans();\n\t\t\t\t\">";
 print "\t<option value=''>{$lang['data_entry_91']}</option>";
 // Limit records pulled only to those in user's Data Access Group
 if ($user_rights['group_id'] == "") {
     $group_sql = "";
 } else {
     $group_sql = "and record in (" . pre_query("select record from redcap_data where field_name = '__GROUPID__' and\n\t\t\t\tvalue = '{$user_rights['group_id']}' and project_id = {$project_id}") . ")";
 }
 //If a Double Data Entry project, only look for entry-person-specific records by using SQL LIKE
 if ($double_data_entry && $user_rights['double_data'] != 0) {
     //If a designated entry person
     $qsql = "select distinct substring(record,1,locate('--',record)-1) as record FROM redcap_data\n\t\t\t\t\t where project_id = {$project_id} and record in (" . pre_query("select distinct record from redcap_data where\n\t\t\t\t\t project_id = {$project_id} and record like '%--{$user_rights['double_data']}'") . ") {$group_sql}";
 } else {
     //If NOT a designated entry person OR not double data entry project
     $qsql = "select distinct record FROM redcap_data where project_id = {$project_id} and field_name = '{$table_pk}'\n\t\t\t\t\tand event_id in (" . prep_implode($Proj->getEventsByArmNum($arm)) . ") {$group_sql}";
 }
 $study_id_array = array();
 $QQuery = db_query($qsql);
 while ($row = db_fetch_array($QQuery)) {
     $study_id_array[] = $row['record'];
 }
 natcasesort($study_id_array);
 foreach ($study_id_array as $this_record) {
     // Check for custom labels
     $secondary_pk_text = isset($secondary_pk_disptext[$this_record]) ? $secondary_pk_disptext[$this_record] : "";
     $custom_record_text = isset($dropdownid_disptext[$this_record]) ? $dropdownid_disptext[$this_record] : "";
     //Render drop-down options
コード例 #20
0
ファイル: func_edit.php プロジェクト: CMMCO/Intranet
        $typename = pg_result($types, $i_type, "typname");
        if (trim($typename) == trim($func[return_type])) {
            $strSelType = " selected";
        } else {
            unset($strSelType);
        }
        echo "<option value=\"{$typename}\"{$strSelType}>{$typename}";
    }
    ?>
			</select>
		</td>
		<td>
			<select name="language">
			<?php 
    $sql_get_langs = "SELECT lanname FROM pg_language ORDER BY lanname DESC";
    $langs = pg_exec($link, pre_query($sql_get_langs)) or pg_die(pg_errormessage(), $sql_get_langs, __FILE__, __LINE__);
    for ($i_lang = 0; $i_lang < @pg_numrows($langs); $i_lang++) {
        $langname = pg_result($langs, $i_lang, "lanname");
        if ($func[language] == $langname) {
            $strSelLang = " selected";
        } else {
            unset($strSelLang);
        }
        echo "<option value=\"{$langname}\"{$strSelLang}>{$langname}";
    }
    ?>
			</select>
		</td>
	</tr>
	<tr><th colspan=4><?php 
    echo $strSrc;
コード例 #21
0
ファイル: grp_admin.php プロジェクト: CMMCO/Intranet
 echo "<table border={$cfgBorder}>\n\t\t\t\t<form method=\"post\">\n\t\t";
 $qrGroups = "SELECT groname, grolist, grosysid FROM pg_group WHERE groname = '{$groname}' ORDER BY groname";
 $rsGroups = @pg_exec($link, pre_query($qrGroups));
 $aryGroups = pg_fetch_array($rsGroups, 0);
 $members = $aryGroups[grolist];
 $members = ereg_replace("\\{|\\}", "", $members);
 echo "\n\t\t\t<tr><th colspan=\"2\">{$strGroup}: {$aryGroups['groname']}</th><th>{$strGroupModify}</th></tr>\n\t\t\t<tr bgcolor={$cfgMember}><td colspan=\"3\"><b>{$strMember}</b></td></tr>\n\t\t";
 if (!empty($members)) {
     $strCheckMem = "usesysid NOT IN ({$members}) AND ";
     $qMember = "SELECT usename, 1 as dummy, usesysid \n\t\t\t            FROM pg_user \n\t\t\t\t\t\tWHERE usesysid in ({$members}) AND \n\t\t\t\t\t\t      usename NOT IN ('root', '{$cfgSuperUser}')\n\t\t\t";
     $rsMember = pg_exec($link, pre_query($qMember)) or pg_die(pg_errormessage($link), $qMember, __FILE__, __LINE__);
     $nMemRows = pg_numrows($rsMember);
 }
 $qNon = "SELECT usename, 0 as dummy, usesysid \n\t\t\t\t\tFROM pg_user \n\t\t\t\t\tWHERE {$strCheckMem} \n\t\t\t\t\t\t  usename NOT IN ('root', '{$cfgSuperUser}')\n   \t\t\t\t    ORDER BY dummy, usename\n\t\t";
 // echo $qNon, "<br>";
 $rsNon = pg_exec($link, pre_query($qNon)) or pg_die(pg_errormessage($link), $qNon, __FILE__, __LINE__);
 $nNonRows = pg_numrows($rsNon);
 for ($iMem = 0; $iMem < $nMemRows; $iMem++) {
     $bgcolor = $cfgBgcolorOne;
     $iMem % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
     $aryMem = pg_fetch_array($rsMember, $iMem);
     echo "\n\t\t\t\t<tr bgcolor={$bgcolor}>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td>{$aryMem['usename']}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<input name=\"mem[{$aryMem['usesysid']}]\" value=\"{$aryMem['usename']}\" type=checkbox>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t";
 }
 echo "<tr bgcolor=\"{$cfgNonMember}\"><td colspan=3><b>{$strNonMember}</b></td></tr>";
 for ($iNon = 0; $iNon < $nNonRows; $iNon++) {
     $bgcolor = $cfgBgcolorOne;
     $iNon % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
     $aryNon = pg_fetch_array($rsNon, $iNon);
     echo "\n\t\t\t\t<tr bgcolor={$bgcolor}>\n\t\t\t\t\t<td>&nbsp;</td>\n\t\t\t\t\t<td>{$aryNon['usename']}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<input name=\"non[{$aryNon['usesysid']}]\" value=\"{$aryNon['usename']}\" type=checkbox>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t";
 }
 echo "\n\t\t\t\t<tr><td colspan=3>&nbsp;</td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan=3>\n\t\t\t\t\t\t<input type=\"submit\" value=\"{$strGroupModify}\">\n\t\t\t\t\t\t<input type=\"button\" value=\"{$strCancel}\" onClick=\"history.back()\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"todo\" value=\"modify\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"save_action\" value=\"1\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"groname\" value=\"{$groname}\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"server\" value=\"{$server}\">\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t</form>\n\t\t\t</table>\n\t\t";
コード例 #22
0
ファイル: tbl_form.inc.php プロジェクト: CMMCO/Intranet
 if ($row_table_def["lengthvar"] > 0) {
     $len = $row_table_def["lengthvar"] - 4;
 } else {
     if ($row_table_def["length"] > 0) {
         $len = $row_table_def["length"];
     } else {
         // $len = "var";
         unset($len);
     }
 }
 unset($selected_func);
 unset($funcs);
 if (!$edit && $row_table_def["hasdefault"] == "t" && $show_defaults) {
     $sql_get_default = "\n\t\t\t\tSELECT d.adsrc AS \"default_val\"\n\t\t\t\tFROM pg_attrdef d, pg_class c \n\t\t\t\tWHERE \n\t\t\t\t\tc.relname = '{$table}' AND \n\t\t\t\t\tc.oid = d.adrelid AND\n\t\t\t\t\td.adnum = {$row_table_def['attnum']}\n\t\t\t";
     // echo "<p>", $sql_get_default, "<p>";
     if (!($def_res = @pg_exec($link, pre_query($sql_get_default)))) {
         pg_die(pg_errormessage(), $sql_get_default, __FILE__, __LINE__);
         unset($row[$field]);
     } else {
         if (pg_numrows($def_res) > 0) {
             $row[$field] = @pg_result($def_res, 0, "default_val");
             if (eregi("([[:alnum:]_]+)\\(([[:alnum:][:punct:][:cntrl:][:space:]]*)\\)\$", $row[$field], $vals)) {
                 $selected_func = $vals[1];
                 $row[$field] = $vals[2];
                 $row[$field] = ereg_replace("^'", "'{$cfgQuotes}", $row[$field]);
                 $row[$field] = ereg_replace("'::", "{$cfgQuotes}'::", $row[$field]);
                 $row[$field] = ereg_replace("'\$", "{$cfgQuotes}'", $row[$field]);
             }
         } else {
             unset($row[$field]);
         }
コード例 #23
0
 public static function getFormStatus($project_id = null, $records = array())
 {
     global $user_rights, $double_data_entry;
     // Verify project_id as numeric
     if (!is_numeric($project_id)) {
         return false;
     }
     // Get array list of form_names
     $allForms = self::getFormNames($project_id);
     // Get table_pk
     $table_pk = self::getTablePK($project_id);
     // Determine if using Double Data Entry and if DDE user (if so, add --# to end of Study ID when querying data table)
     $isDDEuser = $double_data_entry && isset($user_rights['double_data']) && $user_rights['double_data'] != 0;
     // Create "where" clause for records provided, if provided
     $recordSql = is_array($records) && !empty($records) ? "and d.record in (" . prep_implode($records) . ")" : "";
     // Limit by DAGs, if in a DAG
     $dagSql = "";
     if (isset($user_rights['group_id']) && $user_rights['group_id'] != "") {
         $dagSql = "and d.record in (" . pre_query("SELECT record FROM redcap_data where project_id = {$project_id} \n\t\t\t\t\t   and field_name = '__GROUPID__' AND value = '" . $user_rights['group_id'] . "'") . ")";
     }
     // Set "record" field in query if a DDE user
     $record_dde_where = $isDDEuser ? "and d.record like '%--{$user_rights['double_data']}'" : "";
     // Query to get resources from table
     $sql = "select distinct d.record, d.event_id, m.form_name, if(d2.value is null, '0', d2.value) as value \n\t\t\t\tfrom (redcap_data d, redcap_metadata m) left join redcap_data d2 \n\t\t\t\ton d2.project_id = m.project_id and d2.record = d.record and d2.event_id = d.event_id \n\t\t\t\tand d2.field_name = concat(m.form_name, '_complete')\n\t\t\t\twhere d.project_id = {$project_id} and d.project_id = m.project_id and m.element_type != 'calc' and m.field_name != '{$table_pk}'\n\t\t\t\tand d.field_name = m.field_name and m.form_name in (" . prep_implode($allForms) . ")\n\t\t\t\t{$recordSql} {$dagSql} {$record_dde_where}\n\t\t\t\torder by m.field_order";
     $q = db_query($sql);
     if (!$q) {
         return false;
     }
     // Array to collect the record data
     $data = array();
     while ($row = db_fetch_assoc($q)) {
         // If record is not in the array yet, prefill forms with blanks
         if (!isset($data[$row['record']][$row['event_id']])) {
             foreach ($allForms as $this_form) {
                 $data[$row['record']][$row['event_id']][$this_form] = '';
             }
         }
         // Add the form values to array (ignore table_pk value since it was only used as a record placeholder anyway)
         $data[$row['record']][$row['event_id']][$row['form_name']] = $row['value'];
     }
     // Order by record
     natcaseksort($data);
     // Return array of form status data for records
     return $data;
 }
コード例 #24
0
ファイル: sql.php プロジェクト: CMMCO/Intranet
 if (!empty($sql_query)) {
     // Pull in the primary keys for this table
     $pri_query = "\n\t\t\tSELECT \n\t\t\t\ta.attname AS column_name,\n\t\t\t\ti.indisunique AS unique_key,\n\t\t\t\ti.indisprimary AS primary_key\n\t\t\tFROM \n\t\t\t\tpg_class bc,\n\t\t\t\tpg_class ic,\n\t\t\t\tpg_index i,\n\t\t\t\tpg_attribute a\n\t\t\tWHERE \n\t\t\t\ti.indrelid = bc.oid\n\t\t\t\tand i.indexrelid = ic.oid\n\t\t\t\tand \n\t\t\t\t(\n\t\t\t\t\ti.indkey[0] = a.attnum \n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[1] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[2] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[3] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[4] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[5] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[6] = a.attnum\n\t\t\t\t\tor\n\t\t\t\t\ti.indkey[7] = a.attnum\n\t\t\t\t)\n\t\t\t\tand a.attrelid = bc.oid\n\t\t\t\tand i.indproc = '0'::oid\n\t\t\t\tand bc.relname = '{$table}'\n\t\t\t\tand (i.indisprimary = 't' or i.indisunique = 't')\n\t\t";
     $pri_result = @pg_exec($link, pre_query($pri_query)) or pg_die(pg_errormessage(), $pri_query, __FILE__, __LINE__);
     $pri_num = @pg_numrows($pri_result);
     for ($i_pri_rows = 0; $i_pri_rows < $pri_num; $i_pri_rows++) {
         $my_pri_key = pg_result($pri_result, $i_pri_rows, "column_name");
         // if (!eregi($my_pri_key, $sql_query)) {
         // Need to figure out a way to determine whether the primary key for the table has been selected
         // If not, then we need to pull it in.  This is for use with the actions.
         // }
         $pri_keys[] = $my_pri_key;
     }
     $sql_query = isset($sql_query) ? stripslashes($sql_query) : '';
     $sql_order = isset($sql_order) ? stripslashes($sql_order) : '';
     if (!($result = @pg_exec($link, pre_query($sql_query . $sql_order)))) {
         include "header.inc.php";
         pg_die(pg_errormessage($link), $sql_query . $sql_order, __FILE__, __LINE__);
     }
     $num_rows = @pg_numrows($result);
 }
 if ($num_rows < 1 || $rel_type == "sequence" && eregi($sql_query, "setval")) {
     if (eregi("delete|insert|update", $sql_query)) {
         $affected_rows = @pg_cmdtuples($result);
     } else {
         unset($affected_rows);
     }
     if (file_exists("./{$goto}")) {
         include "header.inc.php";
         if (isset($zero_rows) && !empty($zero_rows)) {
             $message = $zero_rows;
コード例 #25
0
ファイル: db_dump.php プロジェクト: ColBT/php_tut
        }
        if ($drop) {
            print "DROP FUNCTION {$cfgQuotes}{$func_info['proname']}{$cfgQuotes}({$strArgList});{$crlf}";
        }
        echo "CREATE FUNCTION {$cfgQuotes}{$func_info['proname']}{$cfgQuotes}({$strArgList}) RETURNS {$func_info['return_type']} AS {$strBin}'{$func_info['source']}' LANGUAGE '{$func_info['language']}'; {$crlf}";
    }
}
// Output triggers
// Some definitions
$TRIGGER_TYPE_ROW = 1 << 0;
$TRIGGER_TYPE_BEFORE = 1 << 1;
$TRIGGER_TYPE_INSERT = 1 << 2;
$TRIGGER_TYPE_DELETE = 1 << 3;
$TRIGGER_TYPE_UPDATE = 1 << 4;
$sql_get_triggers = "\n\tSELECT \n\t\tpt.*, pp.proname, pc.relname\n\tFROM \n\t\tpg_trigger pt, pg_proc pp, pg_class pc\n\tWHERE \n\t\tpp.oid=pt.tgfoid\n\t\tand pt.tgrelid=pc.oid\n\t\tand relname !~ '^pg_'\n";
$triggers = @pg_exec($link, pre_query($sql_get_triggers));
if (!($num_triggers = @pg_numrows($triggers))) {
    print "{$crlf}/* {$strNo} {$strTriggers} {$strFound} */{$crlf}";
} else {
    print "{$crlf}/* -------------------------------------------------------- {$crlf}";
    print "  {$strTriggers} {$crlf}";
    print "-------------------------------------------------------- */ {$crlf}";
    for ($i_triggers = 0; $i_triggers < $num_triggers; $i_triggers++) {
        $trigger = pg_fetch_array($triggers, $i_triggers);
        // Constraint or not
        if ($trigger[tgisconstraint] == 't') {
            print "CREATE CONSTRAINT TRIGGER";
        } else {
            print "CREATE TRIGGER";
        }
        // Name
コード例 #26
0
ファイル: tbl_qbe.php プロジェクト: CMMCO/Intranet
if ($row < 0) {
    $row = 0;
}
$sql_get_tables = "SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg%'";
$tbl_result = pg_exec($link, pre_query($sql_get_tables));
$i = 0;
$k = 0;
if (!empty($TableList)) {
    for ($x = 0; $x < sizeof($TableList); $x++) {
        $tbl_names[$TableList[$x]] = "selected";
    }
}
while ($i < pg_numrows($tbl_result)) {
    $tbl = pg_result($tbl_result, $i, "tablename");
    $sql_get_fields = "\n\t\tSELECT \n\t\t\tattname \n\t\tFROM \n\t\t\tpg_attribute a, pg_class c \n\t\tWHERE \n\t\t\tc.oid = a.attrelid \n\t\t\tAND c.relname = '{$tbl}'\n\t";
    $fld_results = pg_exec($link, pre_query($sql_get_fields));
    $j = 0;
    if (empty($tbl_names[$tbl]) && !empty($TableList)) {
        $tbl_names[$tbl] = "";
    } else {
        $tbl_names[$tbl] = "selected";
    }
    if ($tbl_names[$tbl] == "selected") {
        $fld[$k++] = "{$tbl}.*";
        while ($j < pg_numrows($fld_results)) {
            $fld[$k] = pg_result($fld_results, $j, "attname");
            $fld[$k] = "{$tbl}.{$fld[$k]}";
            $k++;
            $j++;
        }
    }
コード例 #27
0
ファイル: tbl_replace.php プロジェクト: CMMCO/Intranet
            }
        }
        if (empty($funcs[$key])) {
            $valuelist .= "{$val}, ";
        } else {
            // $val = str_replace("'", "\"", $val);
            $valuelist .= "{$funcs[$key]}(" . stripslashes($val) . "), ";
        }
    }
    $fieldlist = ereg_replace(", \$", "", $fieldlist);
    $valuelist = ereg_replace(", \$", "", $valuelist);
    $query = "INSERT INTO {$cfgQuotes}{$table}{$cfgQuotes} ({$fieldlist}) VALUES ({$valuelist})";
    // echo $query, "<p>";
}
$sql_query = $query;
if (!($result = @pg_exec($link, pre_query($query)))) {
    include "header.inc.php";
    pg_die(pg_errormessage(), $query, __FILE__, __LINE__);
} else {
    if (eregi("delete|insert|update", $sql_query)) {
        $affected_rows = @pg_cmdtuples($result);
    } else {
        unset($affected_rows);
    }
    if (file_exists("./{$goto}")) {
        include "header.inc.php";
        $message = $strModifications;
        include preg_replace('/\\.\\.*/', '.', $goto);
    } else {
        Header("Location: {$goto}");
    }