示例#1
0
function reporton(&$row, &$last_area_room)
{
    global $typel;
    global $enable_periods;
    # Display Area/Room, but only when it changes:
    $area_room = htmlspecialchars($row[8]) . " - " . htmlspecialchars($row[9]);
    if ($area_room != $last_area_room) {
        echo "<hr><h2>" . get_vocab("room") . $area_room . "</h2>\n";
        $last_area_room = $area_room;
    }
    echo "<hr><table width=\"100%\">\n";
    # Brief Description (title), linked to view_entry:
    echo "<tr><td class=\"BL\"><a href=\"view_entry.php?id={$row['0']}\">" . htmlspecialchars($row[3]) . "</a></td>\n";
    # From date-time and duration:
    echo "<td class=\"BR\" align=right>" . (empty($enable_periods) ? describe_span($row[1], $row[2]) : describe_period_span($row[1], $row[2])) . "</td></tr>\n";
    # Description:
    echo "<tr><td class=\"BL\" colspan=2><b>" . get_vocab("description") . "</b> " . nl2br(htmlspecialchars($row[4])) . "</td></tr>\n";
    # Entry Type:
    $et = empty($typel[$row[5]]) ? "?{$row['5']}?" : $typel[$row[5]];
    echo "<tr><td class=\"BL\" colspan=2><b>" . get_vocab("type") . "</b> {$et}</td></tr>\n";
    # Created by and last update timestamp:
    echo "<tr><td class=\"BL\" colspan=2><small><b>" . get_vocab("createdby") . "</b> " . htmlspecialchars($row[6]) . ", <b>" . get_vocab("lastupdate") . "</b> " . date_time_string(MDB_Date::mdbstamp2Unix($row[7])) . "</small></td></tr>\n";
    echo "</table>\n";
}
示例#2
0
function reporton(&$row, &$last_area_room, &$last_date, $sortby, $display)
{
    global $typel;
    global $enable_periods;
    # Display Area/Room, but only when it changes:
    $area_room = htmlspecialchars($row[8]) . " - " . htmlspecialchars($row[9]);
    $date = utf8_strftime("%d-%b-%Y", $row[1]);
    # entries to be sorted on area/room
    if ($sortby == "r") {
        if ($area_room != $last_area_room) {
            echo "<hr><h2>" . get_vocab("room") . ": " . $area_room . "</h2>\n";
        }
        if ($date != $last_date || $area_room != $last_area_room) {
            echo "<hr noshade=\"true\"><h3>" . get_vocab("date") . " " . $date . "</h3>\n";
            $last_date = $date;
        }
        # remember current area/room that is being processed.
        # this is done here as the if statement above needs the old
        # values
        if ($area_room != $last_area_room) {
            $last_area_room = $area_room;
        }
    } else {
        if ($date != $last_date) {
            echo "<hr><h2>" . get_vocab("date") . " " . $date . "</h2>\n";
        }
        if ($area_room != $last_area_room || $date != $last_date) {
            echo "<hr noshade=\"true\"><h3>" . get_vocab("room") . ": " . $area_room . "</h3>\n";
            $last_area_room = $area_room;
        }
        # remember current date that is being processed.
        # this is done here as the if statement above needs the old
        # values
        if ($date != $last_date) {
            $last_date = $date;
        }
    }
    echo "<hr><table width=\"100%\">\n";
    # Brief Description (title), linked to view_entry:
    echo "<tr><td class=\"BL\"><a href=\"view_entry.php?id={$row['0']}\">" . htmlspecialchars($row[3]) . "</a></td>\n";
    # what do you want to display duration or end date/time
    if ($display == "d") {
        # Start date/time and duration:
        echo "<td class=\"BR\" align=right>" . (empty($enable_periods) ? describe_span($row[1], $row[2]) : describe_period_span($row[1], $row[2])) . "</td></tr>\n";
    } else {
        # Start date/time and End date/time:
        echo "<td class=\"BR\" align=right>" . (empty($enable_periods) ? start_to_end($row[1], $row[2]) : start_to_end_period($row[1], $row[2])) . "</td></tr>\n";
    }
    # Description:
    echo "<tr><td class=\"BL\" colspan=2><b>" . get_vocab("description") . "</b> " . nl2br(htmlspecialchars($row[4])) . "</td></tr>\n";
    # Entry Type:
    $et = empty($typel[$row[5]]) ? "?{$row['5']}?" : $typel[$row[5]];
    echo "<tr><td class=\"BL\" colspan=2><b>" . get_vocab("type") . "</b> {$et}</td></tr>\n";
    # Created by and last update timestamp:
    echo "<tr><td class=\"BL\" colspan=2><small><b>" . get_vocab("createdby") . "</b> " . htmlspecialchars($row[6]) . ", <b>" . get_vocab("lastupdate") . "</b> " . date_time_string(MDB_Date::mdbstamp2Unix($row[7])) . "</small></td></tr>\n";
    echo "</table>\n";
}
 /**
  * Testing transaction support
  */
 function testTransactions()
 {
     if (!$this->supported('Transactions')) {
         return;
     }
     $this->db->autoCommit(0);
     $row = 0;
     $data = array();
     $data['user_name'] = "user_{$row}";
     $data['user_password'] = '******';
     $data['subscribed'] = (bool) ($row % 2);
     $data['user_id'] = $row;
     $data['quota'] = strval($row / 100);
     $data['weight'] = sqrt($row);
     $data['access_date'] = MDB_Date::mdbToday();
     $data['access_time'] = MDB_Date::mdbTime();
     $data['approved'] = MDB_Date::mdbNow();
     $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $this->types);
     $this->insertTestValues($prepared_query, $data);
     $result = $this->db->executeQuery($prepared_query);
     $this->db->rollback();
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue($this->db->endOfResult($result), 'Transaction rollback did not revert the row that was inserted');
     $this->db->freeResult($result);
     $this->insertTestValues($prepared_query, $data);
     $result = $this->db->executeQuery($prepared_query);
     $this->db->commit();
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue(!$this->db->endOfResult($result), 'Transaction commit did not make permanent the row that was inserted');
     $this->db->freeResult($result);
     $result = $this->db->query('DELETE FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error deleting from users' . $result->getMessage());
         $this->db->rollback();
     }
     $autocommit = $this->db->autocommit(1);
     $this->assertTrue(!MDB::isError($autocommit), 'Error autocommiting transactions');
     $this->db->freePreparedQuery($prepared_query);
     $result = $this->db->query('SELECT * FROM users');
     if (MDB::isError($result)) {
         $this->assertTrue(false, 'Error selecting from users' . $result->getMessage());
     }
     $this->assertTrue($this->db->endOfResult($result), 'Transaction end with implicit commit when re-enabling auto-commit did not make permanent the rows that were deleted');
     $this->db->freeResult($result);
 }
示例#4
0
 /**
  * Reads auth_user_id, passwd, is_active flag
  * lastlogin timestamp from the database
  * If only $handle is given, it will read the data
  * from the first user with that handle and return
  * true on success.
  * If $handle and $passwd are given, it will try to
  * find the first user with both handle and password
  * matching and return true on success (this allows
  * multiple users having the same handle but different
  * passwords - yep, some people want this).
  * If no match is found, false is being returned.
  *
  * @access private
  * @param  string   user handle
  * @param  boolean  user password
  * @return boolean  true upon success, false otherwise
  */
 function _readUserData($handle, $passwd = false)
 {
     if (!$this->init_ok) {
         return false;
     }
     $success = false;
     $fields = array();
     foreach ($this->authTableCols as $key => $value) {
         if (sizeof($value) > 0) {
             foreach ($value as $alias => $field_data) {
                 $fields[] = $field_data['name'] . ' AS ' . $alias;
                 $types[] = $field_data['type'];
             }
         }
     }
     if ($passwd !== false) {
         // If $passwd is set, try to find the first user with the given
         // handle and password.
         $sql = 'SELECT ' . implode(',', $fields) . '
                    FROM ' . $this->authTable . '
                    WHERE ' . $this->authTableCols['required']['handle']['name'] . '=' . $this->dbc->getValue($this->authTableCols['handle']['type'], $handle) . '
                     AND ' . $this->authTableCols['required']['passwd']['name'] . '=' . $this->dbc->getValue($this->authTableCols['passwd']['type'], $this->encryptPW($passwd));
     } else {
         // If only $handle is set, try to find the first matching user
         $sql = 'SELECT ' . implode(',', $fields) . '
                    FROM  ' . $this->authTable . '
                    WHERE ' . $this->authTableCols['required']['handle']['name'] . '=' . $this->dbc->getValue($this->authTableCols['handle']['type'], $handle);
     }
     // Query database
     $result = $this->dbc->queryRow($sql, $types, MDB_FETCHMODE_ASSOC);
     // If a user was found, read data into class variables and set
     // return value to true
     if (!MDB::isError($result) && is_array($result)) {
         $this->handle = $result['handle'];
         $this->passwd = $this->decryptPW($result['passwd']);
         $this->isActive = !isset($result['is_active']) || $result['is_active'] ? true : false;
         $this->authUserId = $result['auth_user_id'];
         $this->lastLogin = !empty($result['lastlogin']) ? MDB_Date::mdbstamp2Unix($result['lastlogin']) : '';
         $success = true;
     }
     return $success;
 }
示例#5
0
 /**
  * Reads user data from the given data source
  * If only $handle is given, it will read the data
  * from the first user with that handle and return
  * true on success.
  * If $handle and $passwd are given, it will try to
  * find the first user with both handle and password
  * matching and return true on success (this allows
  * multiple users having the same handle but different
  * passwords - yep, some people want this).
  * if only an auth_user_id is passed it will try to read the data based on the id
  * If no match is found, false is being returned.
  *
  * @param  string user handle
  * @param  string user password
  * @param  bool|int if the user data should be read using the auth user id
  * @return bool true on success or false on failure
  *
  * @access public
  */
 function readUserData($handle = '', $passwd = '', $auth_user_id = false)
 {
     $fields = $types = array();
     foreach ($this->tables['users']['fields'] as $field => $req) {
         $fields[] = $this->alias[$field] . ' AS ' . $field;
         $types[] = $this->fields[$field];
     }
     // Setting the default query.
     $query = 'SELECT ' . implode(',', $fields) . '
                FROM ' . $this->prefix . $this->alias['users'] . '
                WHERE  ';
     if ($auth_user_id) {
         $query .= $this->alias['auth_user_id'] . '=' . $this->dbc->getValue($this->fields['auth_user_id'], $auth_user_id);
     } else {
         if (!is_array($this->handles) || empty($this->handles)) {
             $this->stack->push(LIVEUSER_ERROR_CONFIG, 'exception', array('reason' => 'No handle set in storage config.'));
             return false;
         }
         $handles = array();
         foreach ($this->handles as $field) {
             $handles[] = $this->alias[$field] . '=' . $this->dbc->getValue($this->fields[$field], $handle);
         }
         $query .= '(' . implode(' OR ', $handles) . ')';
         if (!is_null($this->tables['users']['fields']['passwd'])) {
             // If $passwd is set, try to find the first user with the given
             // handle and password.
             $query .= ' AND   ' . $this->alias['passwd'] . '=' . $this->dbc->getValue($this->fields['passwd'], $this->encryptPW($passwd));
         }
     }
     // Query database
     $result = $this->dbc->queryRow($query, $types, MDB_FETCHMODE_ASSOC);
     if (PEAR::isError($result)) {
         $this->stack->push(LIVEUSER_ERROR, 'exception', array('reason' => $result->getMessage() . '-' . $result->getUserInfo()));
         return false;
     }
     if (!is_array($result)) {
         return null;
     }
     // User was found, read data into class variables and set return value to true
     if (array_key_exists('lastlogin', $result) && !empty($result['lastlogin'])) {
         $result['lastlogin'] = MDB_Date::mdbstamp2Unix($result['lastlogin']);
     }
     $this->propertyValues = $result;
     return true;
 }
示例#6
0
}
if (NULL == $row) {
    fatal_error(0, $series ? get_vocab('invalid_series_id') : get_vocab('invalid_entry_id'));
}
# Note: Removed stripslashes() calls from name and description. Previous
# versions of MRBS mistakenly had the backslash-escapes in the actual database
# records because of an extra addslashes going on. Fix your database and
# leave this code alone, please.
$name = htmlspecialchars($row[0]);
$description = htmlspecialchars($row[1]);
$create_by = htmlspecialchars($row[2]);
$room_name = htmlspecialchars($row[3]);
$area_name = htmlspecialchars($row[4]);
$type = $row[5];
$room_id = $row[6];
$updated = time_date_string(MDB_Date::mdbstamp2Unix($row[7]));
# need to make DST correct in opposite direction to entry creation
# so that user see what he expects to see
$duration = $row[8] - cross_dst($row[9], $row[10]);
if ($enable_periods) {
    list($start_period, $start_date) = period_date_string($row[9]);
} else {
    $start_date = time_date_string($row[9]);
}
if ($enable_periods) {
    list(, $end_date) = period_date_string($row[10], -1);
} else {
    $end_date = time_date_string($row[10]);
}
$rep_type = 0;
if ($series == 1) {
示例#7
0
 /**
  * convert a MDB timestamp into a unix timestamp
  *
  * @param integer $mdb_timestamp a valid MDB timestamp
  * @return string unix timestamp with the time stored in the MDB format
  * @access public
  */
 function mdbstamp2Unix($mdb_timestamp)
 {
     $arr = MDB_Date::mdbstamp2Date($mdb_timestamp);
     return mktime($arr['hour'], $arr['minute'], $arr['second'], $arr['month'], $arr['day'], $arr['year'], 0);
 }
示例#8
0
 /**
  * http://pear.php.net/bugs/bug.php?id=946
  */
 function testBug946()
 {
     $data = array();
     $total_rows = 5;
     $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name, user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $this->types);
     for ($row = 0; $row < $total_rows; $row++) {
         $data[$row]['user_name'] = "user_{$row}";
         $data[$row]['user_password'] = '******';
         $data[$row]['subscribed'] = (bool) ($row % 2);
         $data[$row]['user_id'] = $row;
         $data[$row]['quota'] = sprintf("%.2f", strval(1 + ($row + 1) / 100));
         $data[$row]['weight'] = sqrt($row);
         $data[$row]['access_date'] = MDB_Date::mdbToday();
         $data[$row]['access_time'] = MDB_Date::mdbTime();
         $data[$row]['approved'] = MDB_Date::mdbNow();
         $this->insertTestValues($prepared_query, $data[$row]);
         $result = $this->db->executeQuery($prepared_query);
         if (MDB::isError($result)) {
             $this->assertTrue(false, 'Error executing prepared query' . $result->getMessage());
         }
     }
     $this->db->freePreparedQuery($prepared_query);
     $result = $this->db->limitQuery('SELECT * FROM users', null, 1, 3);
     $numrows = $this->db->numRows($result);
     while ($row = $this->db->fetchInto($result)) {
         if (MDB::isError($row)) {
             $this->assertTrue(false, 'Error fetching a row' . $row->getMessage());
         }
     }
     $this->db->freeResult($result);
     $result = $this->db->query('SELECT * FROM users');
     $numrows = $this->db->numRows($result);
     while ($row = $this->db->fetchInto($result)) {
         if (MDB::isError($row)) {
             $this->assertTrue(false, 'Error fetching a row with limit' . $row->getMessage());
         }
     }
     $this->db->freeResult($result);
 }
function MetabaseTime()
{
    return MDB_Date::mdbTime();
}
示例#10
0
                    if (0 == $counte)
                    {
				  		//There are no overlaps
				  		if (4 == $area)
                        {
					  		$name = $jpnames[mt_rand(1,count($jpnames)-1)];
				  		}
                        else
                        {
					  		$name = $ennames[mt_rand(1,count($ennames)-1)];
				  		}
				  		$type = $intext[mt_rand(1,2)];
                  		$id = $mdb->nextId('mrbs_entry_id');
                        $sql_4_data = array($id, $room, $REMOTE_ADDR, $starttime,
                        					$endtime, $type, $name, 'A meeting',
                                            MDB_Date::mdbNow());
                        $param_types = array('integer', 'integer', 'text', 'integer',
                        					 'integer', 'text', 'text', 'text', 'timestamp');
                        $res = $mdb->execute($prepared_query_4, NULL, $sql_4_data,
                        					 $param_types);
                        if (MDB::isError($res))
              			{
                			echo $res->getMessage() . "<BR>";
                			die($res->getUserInfo());
            			}
        			}
                    echo "$area - $room ($starthour,$length), $type<br>";
		  		}
	  		}
  		}
 	}