本文整理汇总了PHP中OC_DB::executeAudited方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_DB::executeAudited方法的具体用法?PHP OC_DB::executeAudited怎么用?PHP OC_DB::executeAudited使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_DB
的用法示例。
在下文中一共展示了OC_DB::executeAudited方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateFolderSize
/**
* get the size of a folder and set it in the cache
*
* @param string $path
* @return int
*/
public function calculateFolderSize($path)
{
if ($path !== '/' and $path !== '' and $path !== 'files') {
return parent::calculateFolderSize($path);
}
$totalSize = 0;
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
$sql = 'SELECT SUM(`size`) AS f1, ' . 'SUM(`unencrypted_size`) AS f2 FROM `*PREFIX*filecache` ' . 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
list($sum, $unencryptedSum) = array_values($row);
$totalSize = (int) $sum;
$unencryptedSize = (int) $unencryptedSum;
if ($entry['size'] !== $totalSize) {
$this->update($id, array('size' => $totalSize));
}
if ($entry['unencrypted_size'] !== $unencryptedSize) {
$this->update($id, array('unencrypted_size' => $unencryptedSize));
}
}
}
return $totalSize;
}
示例2: calculateFolderSize
/**
* get the size of a folder and set it in the cache
*
* @param string $path
* @param array $entry (optional) meta data of the folder
* @return int
*/
public function calculateFolderSize($path, $entry = null)
{
if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') {
return parent::calculateFolderSize($path, $entry);
} elseif ($path === '' or $path === '/') {
// since the size of / isn't used (the size of /files is used instead) there is no use in calculating it
return 0;
}
$totalSize = 0;
if (is_null($entry)) {
$entry = $this->get($path);
}
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$id = $entry['fileid'];
$sql = 'SELECT SUM(`size`) AS f1, ' . 'SUM(`unencrypted_size`) AS f2 FROM `*PREFIX*filecache` ' . 'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
list($sum, $unencryptedSum) = array_values($row);
$totalSize = 0 + $sum;
$unencryptedSize = 0 + $unencryptedSum;
$entry['size'] += 0;
$entry['unencrypted_size'] += 0;
if ($entry['size'] !== $totalSize) {
$this->update($id, array('size' => $totalSize));
}
if ($entry['unencrypted_size'] !== $unencryptedSize) {
$this->update($id, array('unencrypted_size' => $unencryptedSize));
}
}
}
return $totalSize;
}
示例3: getMimeTypeIdFromDB
/**
* Returns the id of a given mime type or null
* if it does not exist.
*/
private function getMimeTypeIdFromDB($mimeType) {
$sql = 'SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?';
$results = \OC_DB::executeAudited($sql, [$mimeType]);
$result = $results->fetchOne();
if ($result) {
return $result['id'];
}
return null;
}
示例4: removeShare
/**
* @brief remove all shares for a given file if the file was deleted
*
* @param string $path
*/
private static function removeShare($path)
{
$fileSource = self::$toRemove[$path];
if (!\OC\Files\Filesystem::file_exists($path)) {
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `file_source`=?');
try {
\OC_DB::executeAudited($query, array($fileSource));
} catch (\Exception $e) {
\OCP\Util::writeLog('files_sharing', "can't remove share: " . $e->getMessage(), \OCP\Util::WARN);
}
}
unset(self::$toRemove[$path]);
}
示例5: exists
public static function exists($storageId)
{
if (strlen($storageId) > 64) {
$storageId = md5($storageId);
}
$sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
$result = \OC_DB::executeAudited($sql, array($storageId));
if ($row = $result->fetchRow()) {
return true;
} else {
return false;
}
}
示例6: getNextFileId
/**
* get the next fileid in the cache
*
* @param int $previous
* @param bool $folder
* @return int
*/
private static function getNextFileId($previous, $folder)
{
if ($folder) {
$stmt = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND `mimetype` = ? ORDER BY `fileid` ASC', 1);
} else {
$stmt = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `fileid` > ? AND `mimetype` != ? ORDER BY `fileid` ASC', 1);
}
$result = \OC_DB::executeAudited($stmt, array($previous, self::getFolderMimetype()));
if ($row = $result->fetchRow()) {
return $row['fileid'];
} else {
return 0;
}
}
示例7: checkPassword
/**
* Check if the password is correct without logging in the user
*
* @param string $uid The username
* @param string $password The password
*
* @return true/false
*/
public function checkPassword($uid, $password) {
$user = OC_DB::executeAudited(
'SELECT * FROM `*PREFIX*users`'
. ' WHERE `uid` = ?',
array($uid)
)->fetchRow();
OCP\Util::writeLog('user_external', 'LOG: $user is now:'.print_r($user));
$Hasher = new PasswordHash(8, false);
$hashed_password = $Hasher->HashPassword($password);
if($hashed_password === $user['password']){
$uid=mb_strtolower($uid);
$this->storeUser($uid);
return $uid;
}else{
return false;
}
/* if (!function_exists('imap_open')) {
OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR);
return false;
}
$mbox = @imap_open($this->mailbox, $uid, $password, OP_HALFOPEN, 1);
imap_errors();
imap_alerts();
if($mbox !== FALSE) {
imap_close($mbox);
$uid = mb_strtolower($uid);
$this->storeUser($uid);
return $uid;
}else{
return false;
}*/
}
示例8: remove
/**
* remove the entry for the storage
*
* @param string $storageId
*/
public static function remove($storageId)
{
$storageCache = new Storage($storageId);
$numericId = $storageCache->getNumericId();
if (strlen($storageId) > 64) {
$storageId = md5($storageId);
}
$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
\OC_DB::executeAudited($sql, array($storageId));
$sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
\OC_DB::executeAudited($sql, array($numericId));
}
示例9: getItemSharedWithUser
/**
* Get the item of item type shared with a given user by source
* @param string $itemType
* @param string $itemSource
* @param string $user User to whom the item was shared
* @param string $owner Owner of the share
* @param int $shareType only look for a specific share type
* @return array Return list of items with file_target, permissions and expiration
*/
public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null, $shareType = null)
{
$shares = array();
$fileDependent = false;
$where = 'WHERE';
$fileDependentWhere = '';
if ($itemType === 'file' || $itemType === 'folder') {
$fileDependent = true;
$column = 'file_source';
$fileDependentWhere = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` ';
$fileDependentWhere .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` ';
} else {
$column = 'item_source';
}
$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent);
$where .= ' `' . $column . '` = ? AND `item_type` = ? ';
$arguments = array($itemSource, $itemType);
// for link shares $user === null
if ($user !== null) {
$where .= ' AND `share_with` = ? ';
$arguments[] = $user;
}
if ($shareType !== null) {
$where .= ' AND `share_type` = ? ';
$arguments[] = $shareType;
}
if ($owner !== null) {
$where .= ' AND `uid_owner` = ? ';
$arguments[] = $owner;
}
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $fileDependentWhere . $where);
$result = \OC_DB::executeAudited($query, $arguments);
while ($row = $result->fetchRow()) {
if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
continue;
}
if ($fileDependent && (int) $row['file_parent'] === -1) {
// if it is a mount point we need to get the path from the mount manager
$mountManager = \OC\Files\Filesystem::getMountManager();
$mountPoint = $mountManager->findByStorageId($row['storage_id']);
if (!empty($mountPoint)) {
$path = $mountPoint[0]->getMountPoint();
$path = trim($path, '/');
$path = substr($path, strlen($owner) + 1);
//normalize path to 'files/foo.txt`
$row['path'] = $path;
} else {
\OC::$server->getLogger()->warning('Could not resolve mount point for ' . $row['storage_id'], ['app' => 'OCP\\Share']);
}
}
$shares[] = $row;
}
//if didn't found a result than let's look for a group share.
if (empty($shares) && $user !== null) {
$groups = \OC_Group::getUserGroups($user);
if (!empty($groups)) {
$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
$arguments = array($itemSource, $itemType, $groups);
$types = array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
if ($owner !== null) {
$where .= ' AND `uid_owner` = ?';
$arguments[] = $owner;
$types[] = null;
}
// TODO: inject connection, hopefully one day in the future when this
// class isn't static anymore...
$conn = \OC_DB::getConnection();
$result = $conn->executeQuery('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $arguments, $types);
while ($row = $result->fetch()) {
$shares[] = $row;
}
}
}
return $shares;
}
示例10: getItemSharedWithUser
/**
* Get the item of item type shared with a given user by source
* @param string $itemType
* @param string $itemSource
* @param string $user User user to whom the item was shared
* @param int $shareType only look for a specific share type
* @return array Return list of items with file_target, permissions and expiration
*/
public static function getItemSharedWithUser($itemType, $itemSource, $user, $shareType = null)
{
$shares = array();
$fileDependend = false;
if ($itemType === 'file' || $itemType === 'folder') {
$fileDependend = true;
$column = 'file_source';
$where = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` WHERE';
} else {
$column = 'item_source';
$where = 'WHERE';
}
$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependend);
$where .= ' `' . $column . '` = ? AND `item_type` = ? ';
$arguments = array($itemSource, $itemType);
// for link shares $user === null
if ($user !== null) {
$where .= ' AND `share_with` = ? ';
$arguments[] = $user;
}
if ($shareType !== null) {
$where .= ' AND `share_type` = ? ';
$arguments[] = $shareType;
}
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where);
$result = \OC_DB::executeAudited($query, $arguments);
while ($row = $result->fetchRow()) {
$shares[] = $row;
}
//if didn't found a result than let's look for a group share.
if (empty($shares) && $user !== null) {
$groups = \OC_Group::getUserGroups($user);
$query = \OC_DB::prepare('SELECT *
FROM
`*PREFIX*share`
WHERE
`' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)');
$result = \OC_DB::executeAudited($query, array($itemSource, $itemType, implode(',', $groups)));
while ($row = $result->fetchRow()) {
$shares[] = $row;
}
}
return $shares;
}
示例11: testLastInsertId
public function testLastInsertId() {
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
$id1 = OC_DB::insertid('*PREFIX*'.$this->table2);
// we don't know the id we should expect, so insert another row
$result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2'));
$id2 = OC_DB::insertid('*PREFIX*'.$this->table2);
// now we can check if the two ids are in correct order
$this->assertGreaterThan($id1, $id2);
}
示例12: remove
/**
* remove the entry for the storage
*
* @param string $storageId
*/
public static function remove($storageId)
{
$storageId = self::adjustStorageId($storageId);
$numericId = self::getNumericStorageId($storageId);
$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
\OC_DB::executeAudited($sql, array($storageId));
if (!is_null($numericId)) {
$sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
\OC_DB::executeAudited($sql, array($numericId));
}
}
示例13: getChildren
/**
* get all child items of an item from the legacy cache
*
* @param int $id
* @return array
*/
function getChildren($id)
{
$result = \OC_DB::executeAudited('SELECT * FROM `*PREFIX*fscache` WHERE `parent` = ?', array($id));
$data = $result->fetchAll();
foreach ($data as $i => $item) {
$data[$i]['etag'] = $this->getEtag($item['path'], $item['user']);
}
return $data;
}
示例14: fixOfficeMimeTypes
private function fixOfficeMimeTypes()
{
// update wrong mimetypes
$wrongMimetypes = array('application/mspowerpoint' => 'application/vnd.ms-powerpoint', 'application/msexcel' => 'application/vnd.ms-excel');
$existsStmt = \OC_DB::prepare('
SELECT count(`mimetype`)
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
');
$getIdStmt = \OC_DB::prepare('
SELECT `id`
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
');
$insertStmt = \OC_DB::prepare('
INSERT INTO `*PREFIX*mimetypes` ( `mimetype` )
VALUES ( ? )
');
$updateWrongStmt = \OC_DB::prepare('
UPDATE `*PREFIX*filecache`
SET `mimetype` = (
SELECT `id`
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
) WHERE `mimetype` = ?
');
$deleteStmt = \OC_DB::prepare('
DELETE FROM `*PREFIX*mimetypes`
WHERE `id` = ?
');
foreach ($wrongMimetypes as $wrong => $correct) {
// do we need to remove a wrong mimetype?
$result = \OC_DB::executeAudited($getIdStmt, array($wrong));
$wrongId = $result->fetchOne();
if ($wrongId !== false) {
// do we need to insert the correct mimetype?
$result = \OC_DB::executeAudited($existsStmt, array($correct));
$exists = $result->fetchOne();
if (!$exists) {
// insert mimetype
\OC_DB::executeAudited($insertStmt, array($correct));
}
// change wrong mimetype to correct mimetype in filecache
\OC_DB::executeAudited($updateWrongStmt, array($correct, $wrongId));
// delete wrong mimetype
\OC_DB::executeAudited($deleteStmt, array($wrongId));
}
}
$updatedMimetypes = array('docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation');
$updateByNameStmt = \OC_DB::prepare('
UPDATE `*PREFIX*filecache`
SET `mimetype` = (
SELECT `id`
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
) WHERE `name` LIKE ?
');
// separate doc from docx etc
foreach ($updatedMimetypes as $extension => $mimetype) {
$result = \OC_DB::executeAudited($existsStmt, array($mimetype));
$exists = $result->fetchOne();
if (!$exists) {
// insert mimetype
\OC_DB::executeAudited($insertStmt, array($mimetype));
}
// change mimetype for files with x extension
\OC_DB::executeAudited($updateByNameStmt, array($mimetype, '%.' . $extension));
}
}
示例15: all
/**
* @return array
*/
public function all()
{
$sql = 'SELECT * from `*PREFIX*hub_notifications` ORDER BY `timestamp` DESC';
$result = \OC_DB::executeAudited($sql);
return $result->fetchAll();
}