Пример #1
0
function find_results_with_tag_like($tag)
{
    $sql = 'SELECT * FROM *PREFIX*eBook_library WHERE tags LIKE ?';
    $stmt = OCP\DB::prepare($sql);
    $res = $stmt->execute(array($tag));
    return $res;
}
Пример #2
0
 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare('SELECT * FROM `calendar_calendars` WHERE `userid` = ?');
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each calendar
                 $calendarquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_calendars` (`userid`,`displayname`,`uri`,`ctag`,`calendarorder`,`calendarcolor`,`timezone`,`components`) VALUES(?,?,?,?,?,?,?,?)');
                 $calendarquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['ctag'], $row['calendarorder'], $row['calendarcolor'], $row['timezone'], $row['components']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid('*PREFIX*calendar_calendars');
                 // Make the calendar active
                 OC_Calendar_Calendar::setCalendarActive($idmap[$row['id']], true);
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare('SELECT * FROM `calendar_objects` WHERE `calendarid` = ?');
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the objects
                     $objectquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_objects` (`calendarid`,`objecttype`,`startdate`,`enddate`,`repeating`,`summary`,`calendardata`,`uri`,`lastmodified`) VALUES(?,?,?,?,?,?,?,?,?)');
                     $objectquery->execute(array($newid, $row['objecttype'], $row['startdate'], $row['enddate'], $row['repeating'], $row['summary'], $row['calendardata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
Пример #3
0
 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare("SELECT * FROM contacts_addressbooks WHERE userid LIKE ?");
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each bookmark, saving its id into the map
                 $query = OCP\DB::prepare("INSERT INTO *PREFIX*contacts_addressbooks (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)");
                 $query->execute(array($this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid();
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare("SELECT * FROM contacts_cards WHERE addressbookid LIKE ?");
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the tags for this bookmark, using the new bookmark id
                     $query = OCP\DB::prepare("INSERT INTO *PREFIX*contacts_cards (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)");
                     $query->execute(array($newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
Пример #4
0
function getShortcode($url) {
	$shortcode = '';
	$query = OCP\DB::prepare('SELECT shortcode FROM *PREFIX*shorten WHERE url=?');
	$results = $query->execute(Array($url))->fetchAll();
	if ($results) {
		foreach($results as $result) {
			$shortcode = $result['shortcode'];	
		}
	}
	if ($shortcode == "") {
		$shortcode = rand_chars(6);
		$found = true;
		while ($found) {
			$query = OCP\DB::prepare('SELECT id FROM *PREFIX*shorten WHERE shortcode=?');
			$results = $query->execute(Array($shortcode))->fetchAll();
			if (!$results) {
				$found = false;
				$uid = \OCP\User::getUser();
				$query = OCP\DB::prepare('INSERT INTO *PREFIX*shorten (uid, shortcode, url) VALUES (?,?,?)');
				$query->execute(Array($uid,$shortcode,$url));
				$id = OCP\DB::insertid('*PREFIX*shorten');
			} else
				$shortcode = rand_chars(6);
		}
	}
	return $shortcode;
}
Пример #5
0
 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare("SELECT * FROM bookmarks WHERE user_id LIKE ?");
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each bookmark, saving its id into the map
                 $query = OCP\DB::prepare("INSERT INTO *PREFIX*bookmarks(url, title, user_id, public, added, lastmodified) VALUES (?, ?, ?, ?, ?, ?)");
                 $query->execute(array($row['url'], $row['title'], $this->uid, $row['public'], $row['added'], $row['lastmodified']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid();
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare("SELECT * FROM bookmarks_tags WHERE bookmark_id LIKE ?");
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the tags for this bookmark, using the new bookmark id
                     $query = OCP\DB::prepare("INSERT INTO *PREFIX*bookmarks_tags(bookmark_id, tag) VALUES (?, ?)");
                     $query->execute(array($newid, $row['tag']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
Пример #6
0
 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare('SELECT * FROM `contacts_addressbooks` WHERE `userid` LIKE ?');
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each addressbook
                 $addressbookquery = OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_addressbooks` (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)');
                 $addressbookquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid('*PREFIX*contacts_addressbooks');
                 // Make the addressbook active
                 OC_Contacts_Addressbook::setActive($idmap[$row['id']], true);
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare('SELECT * FROM `contacts_cards` WHERE `addressbookid` LIKE ?');
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the contacts
                     $contactquery = OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_cards` (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)');
                     $contactquery->execute(array($newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
Пример #7
0
 public static function scan($id, $path, $storage)
 {
     $file = $storage->getLocalFile($path);
     $result = OC_Files_Antivirus::clamav_scan($file);
     switch ($result) {
         case CLAMAV_SCANRESULT_UNCHECKED:
             \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR);
             break;
         case CLAMAV_SCANRESULT_INFECTED:
             $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
             if ($infected_action == 'delete') {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR);
                 unlink($file);
             } else {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR);
             }
             break;
         case CLAMAV_SCANRESULT_CLEAN:
             $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
             try {
                 $result = $stmt->execute(array($id, time()));
                 if (\OC_DB::isError($result)) {
                     \OC_Log::write('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             }
             break;
     }
 }
Пример #8
0
 public static function log($target, $source, $mode)
 {
     $query = OCP\DB::prepare('SELECT * FROM `*PREFIX*sharing` WHERE `source` = ? AND `target` = ?');
     $info = $query->execute(array($source, $target))->fetchAll();
     $info = $info[0];
     //var_dump($info);
     $query = OCP\DB::prepare('INSERT INTO `*PREFIX*sharing_log` VALUES (?,?,?,?,?)');
     $query->execute(array($info['uid_owner'], $source, OCP\User::getUser(), time(), $mode));
     //die;
 }
Пример #9
0
 /**
  * find the user that can be authenticated with an openid identity
  */
 public static function findUserForIdentity($identity)
 {
     $query = OCP\DB::prepare('SELECT `userid` FROM `*PREFIX*preferences` WHERE `appid`=? AND `configkey`=? AND `configvalue`=?');
     $result = $query->execute(array('user_openid', 'identity', $identity))->fetchAll();
     if (count($result) > 0) {
         return $result[0]['userid'];
     } else {
         return false;
     }
 }
Пример #10
0
 function search($query)
 {
     $stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*gallery_albums` WHERE `uid_owner` = ? AND `album_name` LIKE ?');
     $result = $stmt->execute(array(OCP\USER::getUser(), '%' . $query . '%'));
     $results = array();
     while ($row = $result->fetchRow()) {
         $results[] = new OC_Search_Result($row['album_name'], '', OCP\Util::linkTo('gallery', 'index.php') . '?view=' . $row['album_name'], (string) $l->t('Galleries'));
     }
     return $results;
 }
 /**
  * @brief Finds the last modified date and time of the event
  * @param Event ID
  * @return date|boolean (timestamp|false)
  */
 public static function getModifiedTime($eid)
 {
     try {
         $query = OCP\DB::prepare('SELECT `lastmodified` FROM `*PREFIX*clndr_objects` WHERE `id`=?');
         $result = $query->execute(array($eid));
         $row = $result->fetchRow();
         return $row ? $row['lastmodified'] : false;
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
Пример #12
0
 /**
  * @brief Fetch the details of the given project
  * @param Project ID
  * @return Array|boolean (Details of the project|false)
  */
 public static function readProject($pid)
 {
     try {
         $sql = 'SELECT * FROM `*PREFIX*collaboration_project` WHERE `pid`=?';
         $query = OCP\DB::prepare($sql);
         $result = $query->execute(array($pid))->fetchAll();
         return $result[0];
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
Пример #13
0
 /**
  * @brief chek the login parameters
  * @param user object $meUser
  * @param write the basic user data to db
  * @returns the login data
  *
  * This function tries to load the configured login data for roundcube and return it.
  */
 public static function checkLoginData($meUser, $written = 0)
 {
     $mailID = self::existLoginData($meUser);
     if (isset($mailID) && $mailID != '') {
         $stmt = OCP\DB::prepare("SELECT id,ocUser,mailUser,mailPass FROM *PREFIX*roundcube WHERE id = {$mailID}");
         $result = $stmt->execute();
         $row = $result->fetchRow();
         return $row;
     } elseif ($written == 0) {
         self::writeBasicData($meUser);
     }
 }
Пример #14
0
 /**
  * get the sha256 hash of the password needed for ampache
  * @param array $params, parameters passed from OC_Hook
  */
 public static function loginListener($params)
 {
     if (isset($params['uid']) and $params['password']) {
         $name = $params['uid'];
         $query = OCP\DB::prepare("SELECT `user_id` from `*PREFIX*media_users` WHERE `user_id` LIKE ?");
         $uid = $query->execute(array($name))->fetchAll();
         if (count($uid) == 0) {
             $password = hash('sha256', $_POST['password']);
             $query = OCP\DB::prepare("INSERT INTO `*PREFIX*media_users` (`user_id`, `user_password_sha256`) VALUES (?, ?);");
             $query->execute(array($name, $password));
         }
     }
 }
Пример #15
0
 function import()
 {
     $existingURIs = array();
     $existingNames = array();
     $query = $this->content->prepare('SELECT `displayname`, `uri` FROM *PREFIX*contacts_addressbooks WHERE userid = ?');
     $results = $query->execute(array($this->uid));
     while ($row = $results->fetchRow()) {
         \OCP\Util::writeLog('contacts', __METHOD__ . ', row: ' . print_r($row, true), \OCP\Util::DEBUG);
         $existingURIs[] = $row['uri'];
         $existingNames[] = $row['displayname'];
     }
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare('SELECT * FROM contacts_addressbooks WHERE userid = ?');
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             while ($row = $results->fetchRow()) {
                 // Import each addressbook
                 $addressbookquery = OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_addressbooks` (`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)');
                 $uriSuffix = '';
                 $nameSuffix = '';
                 while (in_array($row['uri'] . $uriSuffix, $existingURIs)) {
                     $uriSuffix++;
                 }
                 while (in_array($row['displayname'] . $nameSuffix, $existingNames)) {
                     $nameSuffix++;
                 }
                 $addressbookquery->execute(array($this->uid, $row['displayname'] . $nameSuffix, $row['uri'] . $uriSuffix, $row['description'], $row['ctag']));
                 // Map the id
                 $idmap[$row['id']] = OCP\DB::insertid('*PREFIX*contacts_addressbooks');
                 // Make the addressbook active
                 OCA\Contacts\Addressbook::setActive($idmap[$row['id']], true);
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare('SELECT * FROM contacts_cards WHERE addressbookid = ?');
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the contacts
                     $contactquery = OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_cards` (`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)');
                     $contactquery->execute(array($newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
Пример #16
0
 private function getBookmarks()
 {
     $filters = OCP\Config::getUserValue($this->user, "ocDashboard", "ocDashboard_bookmarks_tags", "");
     // default value doesnt work if empty
     if (empty($filters)) {
         $filters = $this->getDefaultValue("tags");
     }
     $filters = explode(',', $filters);
     $params = array(OCP\USER::getUser());
     $sql = "SELECT *, (SELECT GROUP_CONCAT(`tag`) from `*PREFIX*bookmarks_tags` WHERE `bookmark_id` = `b`.`id`) as `tags`\n\t\t\t\tFROM `*PREFIX*bookmarks` `b`\n\t\t\t\tWHERE `user_id` = ? ";
     // filter clause
     $sql .= " AND\texists (SELECT `id` FROM  `*PREFIX*bookmarks_tags`\n\t\t\t`t2` WHERE `t2`.`bookmark_id` = `b`.`id` AND ( `tag` = ? " . str_repeat(' OR `tag` = ? ', count($filters) - 1) . " ) ) ";
     $params = array_merge($params, $filters);
     $sql .= " ORDER BY lastmodified DESC ";
     $query = OCP\DB::prepare($sql);
     $results = $query->execute($params)->fetchAll();
     $this->bookmarks = $results;
 }
Пример #17
0
<?php

$currentVersion = OC_Appconfig::getValue('search_lucene', 'installed_version');
if (version_compare($currentVersion, '0.5.0', '<')) {
    //force reindexing of files
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*lucene_status` WHERE 1=1');
    $stmt->execute();
    //clear old background jobs
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*queuedtasks` WHERE `app`=?');
    $stmt->execute(array('search_lucene'));
}
Пример #18
0
 public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath)
 {
     $stmt = OCP\DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?");
     $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
 }
Пример #19
0
{
	// first remove any entries already marked as 'deleted'
	$query = OCP\DB::prepare ( OC_Shorty_Query::URL_REMOVE );
	$result = $query->execute(array(':user'=>OCP\User::getUser()));
	// now comes the real list selection
//   define ('PAGE_SIZE', 100);
//   $p_offset = OC_Shorty_Type::req_argument ( 'page', OC_Shorty_Type::INTEGER, FALSE) * PAGE_SIZE;
	// pre-sort list according to user preferences
	$p_sort = OC_Shorty_Type::$SORTING[OCP\Config::getUserValue(OCP\User::getUser(),'shorty','list-sort-code','cd')];
	$param = array (
		':user'   => OCP\User::getUser ( ),
		':sort'   => $p_sort,
// 		':offset' => $p_offset,
// 		':limit'  => PAGE_SIZE,
	);
	$query = OCP\DB::prepare ( OC_Shorty_Query::URL_LIST );
	$result = $query->execute($param);
	$reply = $result->fetchAll();
	foreach (array_keys($reply) as $key) {
		if (isset($reply[$key]['id']))
		{
			// enhance all entries with the relay url
			$reply[$key]['relay']=OC_Shorty_Tools::relayUrl ( $reply[$key]['id'] );
			// make sure there is _any_ favicon contained, otherwise layout in MS-IE browser is broken...
			if (empty($reply[$key]['favicon']))
				$reply[$key]['favicon'] = OCP\Util::imagePath('shorty', 'blank.png');
		}
	} // foreach

	// swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure
	OC_Shorty_Tools::ob_control ( FALSE );
Пример #20
0
 /**
  * Get data by users for monthly evolution
  * 
  * @param $user The
  *            user
  * @return Array
  */
 private static function getDataByUserToHistoChart($user)
 {
     $months = array(date('Ym', mktime(0, 0, 0, date('m') - 11)), date('Ym', mktime(0, 0, 0, date('m') - 10)), date('Ym', mktime(0, 0, 0, date('m') - 9)), date('Ym', mktime(0, 0, 0, date('m') - 8)), date('Ym', mktime(0, 0, 0, date('m') - 7)), date('Ym', mktime(0, 0, 0, date('m') - 6)), date('Ym', mktime(0, 0, 0, date('m') - 5)), date('Ym', mktime(0, 0, 0, date('m') - 4)), date('Ym', mktime(0, 0, 0, date('m') - 3)), date('Ym', mktime(0, 0, 0, date('m') - 2)), date('Ym', mktime(0, 0, 0, date('m') - 1)), date('Ym', mktime(0, 0, 0, date('m'))));
     $return = array();
     foreach ($months as $km => $month) {
         $query = OCP\DB::prepare("SELECT AVG(stc_used) as stc_used FROM *PREFIX*storagecharts2 WHERE oc_uid = ? AND stc_month = ?");
         $result = $query->execute(array($user, $month))->fetchAll();
         if (count($result) > 0) {
             $return[] = $result[0]['stc_used'];
         } else {
             $return[] = 0;
         }
     }
     $last = 0;
     foreach ($return as $key => $value) {
         if ($value == 0) {
             $return[$key] = $last;
         }
         $last = $return[$key];
     }
     return $return;
 }
Пример #21
0
 public static function removeFromGroupShare($arguments)
 {
     $query = OCP\DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?');
     $query->execute(array($arguments['uid'] . '@' . $arguments['gid']));
     self::updateFolder($arguments['uid']);
 }
Пример #22
0
<?php

$installedVersion = \OC::$server->getConfig()->getAppValue('files_antivirus', 'installed_version');
if (version_compare($installedVersion, '0.6', '<')) {
    $query = OCP\DB::prepare('SELECT COUNT(*) AS `count`, `fileid` FROM `*PREFIX*files_antivirus` GROUP BY `fileid` HAVING COUNT(*) > 1');
    $result = $query->execute();
    while ($row = $result->fetchRow()) {
        $deleteQuery = OCP\DB::prepare('DELETE FROM `*PREFIX*files_antivirus` WHERE `fileid` = ?', $row['count'] - 1);
        $deleteQuery->execute(array($row['fileid']));
    }
}
if (version_compare($installedVersion, '0.6.1', '<') && version_compare($installedVersion, '0.5', '>=')) {
    $alterQuery = OCP\DB::prepare('ALTER TABLE `*PREFIX*files_antivirus_status` RENAME TO `*PREFIX*files_avir_status`');
    $alterQuery->execute();
}
Пример #23
0
 /**
  * Use the pulic key of the respective user to encrypt the given
  * email identity and store it in the data-base.
  *
  * @param owncloud $ocUser            
  * @param roundcube $emailUser            
  * @param roundcube $emailPassword            
  * @param
  *            set to false if don't want to persist/read data to db $persist
  * @return The IMAP credentials.|unknown
  */
 public static function cryptEmailIdentity($ocUser, $emailUser, $emailPassword, $persist = true)
 {
     OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->cryptEmailIdentity(): Updating roundcube profile for ' . $ocUser . ' (mail user: '******')', OCP\Util::DEBUG);
     $pubKey = self::getPublicKey($ocUser);
     if ($pubKey === false) {
         OCP\Util::writeLog('roundcube', 'Found no valid public key for user ' . $ocUser . ' (mail user: '******')', OCP\Util::ERROR);
         return false;
     }
     OCP\Util::writeLog('roundcube', 'Found  valid public key for user ' . $ocUser . ': ' . $pubKey . ')', OCP\Util::DEBUG);
     if ($persist) {
         $mail_userdata_entries = self::checkLoginData($ocUser);
         $mail_userdata = $mail_userdata_entries[0];
         if ($mail_userdata_entries === false) {
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->cryptEmailIdentity():  Found no valid mail login data ', OCP\Util::ERROR);
             return false;
         } else {
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->cryptEmailIdentity():  Found valid mail login data for user ' . $ocUser . ' (mail user: '******')', OCP\Util::INFO);
         }
     }
     $mail_username = self::cryptMyEntry($emailUser, $pubKey);
     $mail_password = self::cryptMyEntry($emailPassword, $pubKey);
     if ($mail_username === false || $mail_password === false) {
         OCP\Util::writeLog('roundcube', 'Encryption error for user ' . $ocUser, OCP\Util::ERROR);
         return false;
     }
     if ($persist) {
         OCP\Util::writeLog('roundcube', 'Updating roundcube user data (' . $emailUser . ')for oc user ' . $ocUser, OCP\Util::INFO);
         $stmt = OCP\DB::prepare("UPDATE *PREFIX*roundcube SET mail_user = ?, mail_password = ? WHERE oc_user = ?");
         $result = $stmt->execute(array($mail_username, $mail_password, $ocUser));
         OCP\Util::writeLog('roundcube', 'Done updating roundcube login data for user ' . $ocUser . ' (mail user: '******')' . $ocUser, OCP\Util::INFO);
     } else {
         $result = array('mail_user' => $mail_username, 'mail_password' => $mail_password);
     }
     return $result;
 }
Пример #24
0
<?php

$currentVersion = OC_Appconfig::getValue('gallery', 'installed_version');
if (version_compare($currentVersion, '0.5.0', '<')) {
    $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS `*PREFIX*gallery_photos`');
    $stmt->execute();
    $stmt = OCP\DB::prepare('DROP TABLE IF EXISTS `*PREFIX*gallery_albums`');
    $stmt->execute();
    \OC_DB::createDbFromStructure(OC_App::getAppPath($appid) . '/appinfo/database.xml');
}
Пример #25
0
 public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath)
 {
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*gallery_photos` SET `file_path` = ?, `album_id` = ? WHERE `album_id` = ? AND `file_path` = ?');
     $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
 }
Пример #26
0
 public static function moveToCalendar($id, $calendarid)
 {
     $calendar = OC_Calendar_Calendar::find($calendarid);
     if ($calendar['userid'] != OCP\User::getUser()) {
         $sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
         if (!$sharedCalendar || !($sharedCalendar['permissions'] & OCP\PERMISSION_DELETE)) {
             throw new Exception(OC_Calendar_App::$l10n->t('You do not have the permissions to add events to this calendar.'));
         }
     }
     $stmt = OCP\DB::prepare('UPDATE `*PREFIX*clndr_objects` SET `calendarid`=? WHERE `id`=?');
     $stmt->execute(array($calendarid, $id));
     OC_Calendar_Calendar::touchCalendar($calendarid);
     OCP\Util::emitHook('OC_Calendar', 'moveEvent', $id);
     return true;
 }
Пример #27
0
 /**
  * @brief removes a calendar
  * @param integer $id
  * @return boolean
  */
 public static function deleteCalendar($id)
 {
     $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_calendars WHERE id = ?');
     $stmt->execute(array($id));
     $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_objects WHERE calendarid = ?');
     $stmt->execute(array($id));
     return true;
 }
Пример #28
0
    $stmt = OCP\DB::prepare('UPDATE `*PREFIX*contacts_addressbooks` SET `active`=0');
    $result = $stmt->execute(array());
    // Then get all the active address books.
    $stmt = OCP\DB::prepare('SELECT `userid`,`configvalue` FROM `*PREFIX*preferences` WHERE `appid`=\'contacts\' AND `configkey`=\'openaddressbooks\'');
    $result = $stmt->execute(array());
    // Prepare statement for updating the new 'active' field.
    $stmt = OCP\DB::prepare('UPDATE `*PREFIX*contacts_addressbooks` SET `active`=? WHERE `id`=? AND `userid`=?');
    while ($row = $result->fetchRow()) {
        $ids = explode(';', $row['configvalue']);
        foreach ($ids as $id) {
            $r = $stmt->execute(array(1, $id, $row['userid']));
        }
    }
    // Remove the old preferences.
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*preferences` WHERE `appid`=\'contacts\' AND `configkey`=\'openaddressbooks\'');
    $result = $stmt->execute(array());
}
if (version_compare($installedVersion, '0.3.0.14', '==')) {
    // Rebuild this while we can
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_ocu_cards`');
    $result = $stmt->execute(array());
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_ocu_cards_properties`');
    $result = $stmt->execute(array());
}
if (version_compare($installedVersion, '0.3.0.18', '<')) {
    $stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*contacts_cards_properties`
							WHERE NOT EXISTS(SELECT NULL
                    		FROM `*PREFIX*contacts_cards`
                   			WHERE `*PREFIX*contacts_cards`.id = `*PREFIX*contacts_cards_properties`.contactid)');
    $result = $stmt->execute(array());
}
Пример #29
0
 /**
  * @brief Move card(s) to an address book
  * @param integer $aid Address book id
  * @param $id Array or integer of cards to be moved.
  * @return boolean
  *
  */
 public static function moveToAddressBook($aid, $id)
 {
     OC_Contacts_App::getAddressbook($aid);
     // check for user ownership.
     if (is_array($id)) {
         $id_sql = join(',', array_fill(0, count($id), '?'));
         $prep = 'UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id IN (' . $id_sql . ')';
         try {
             $stmt = OCP\DB::prepare($prep);
             //$aid = array($aid);
             $vals = array_merge((array) $aid, $id);
             $result = $stmt->execute($vals);
         } catch (Exception $e) {
             OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::moveToAddressBook:, exception: ' . $e->getMessage(), OCP\Util::DEBUG);
             OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::moveToAddressBook, ids: ' . join(',', $vals), OCP\Util::DEBUG);
             OCP\Util::writeLog('contacts', 'SQL:' . $prep, OCP\Util::DEBUG);
             return false;
         }
     } else {
         try {
             $stmt = OCP\DB::prepare('UPDATE *PREFIX*contacts_cards SET addressbookid = ? WHERE id = ?');
             $result = $stmt->execute(array($aid, $id));
         } catch (Exception $e) {
             OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::moveToAddressBook:, exception: ' . $e->getMessage(), OCP\Util::DEBUG);
             OCP\Util::writeLog('contacts', 'OC_Contacts_VCard::moveToAddressBook, id: ' . $id, OCP\Util::DEBUG);
             return false;
         }
     }
     OC_Contacts_Addressbook::touch($aid);
     return true;
 }
Пример #30
0
		case 'id':
		case 'shorty':
			// this looks like the request refers to a Shortys ID, lets see if we know that one
			$id     = OC_Shorty_Type::req_argument($key,OC_Shorty_Type::ID,FALSE);
			$param  = array ( ':id' => OC_Shorty_Type::normalize($id,OC_Shorty_Type::ID) );
			$query  = OCP\DB::prepare ( OC_Shorty_Query::URL_BY_ID );
			break 2; // skip switch AND foreach, we have all details we need...
		case 'url':
		case 'uri':
		case 'ref':
		case 'source':
		case 'target':
			// this looks like the request refers to a full url, lets see if we know that one as a Shortys source
			$source = OC_Shorty_Type::req_argument($key,OC_Shorty_Type::URL,FALSE);
			$param  = array ( ':source' => OC_Shorty_Type::normalize($source,OC_Shorty_Type::URL) );
			$query  = OCP\DB::prepare ( OC_Shorty_Query::URL_BY_SOURCE );
			break 2; // skip switch AND foreach, we have all details we need...
	} // switch
} // foreach

// generate qrcode for the specified id/url, IF it exists and has not expired in the database
try
{
	if ( $query )
	{
		$result = $query->execute($param)->FetchAll();
		if ( FALSE===$result )
			throw new OC_Shorty_HttpException ( 500 );
		elseif ( ! is_array($result) )
			throw new OC_Shorty_HttpException ( 500 );
		elseif ( 0==sizeof($result) )