public static function getThumbnail($image_name, $owner = null) { if (!$owner) { $owner = OCP\USER::getUser(); } $save_dir = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/gallery/'; $save_dir .= dirname($image_name) . '/'; $image_path = $image_name; $thumb_file = $save_dir . basename($image_name); if (!is_dir($save_dir)) { mkdir($save_dir, 0777, true); } if (file_exists($thumb_file)) { $image = new OC_Image($thumb_file); } else { $image_path = OC_Filesystem::getLocalFile($image_path); if (!file_exists($image_path)) { return null; } $image = new OC_Image($image_path); if ($image->valid()) { $image->centerCrop(200); $image->fixOrientation(); $image->save($thumb_file); } } if ($image->valid()) { return $image; } else { $image->destroy(); } return null; }
function check_dir_exists($current_dir, $dir) { $owner = OCP\USER::getUser(); $path = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/reader'; $path .= $current_dir . $dir; if (!is_dir($path)) { mkdir($path, 0777, true); return true; } else { return true; } }
public static function createThumbnails($albumName, $files) { // create gallery thumbnail $file_count = min(count($files), 10); $thumbnail = imagecreatetruecolor($file_count * 200, 200); for ($i = 0; $i < $file_count; $i++) { $image = OC_Gallery_Photo::getThumbnail($files[$i]); if ($image && $image->valid()) { imagecopyresampled($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200, 200, 200); $image->destroy(); } } imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory") . '/' . OCP\USER::getUser() . '/gallery/' . $albumName . '.png'); imagedestroy($thumbnail); }
public function __construct() { /* * Récupération des données du fichier config général /config/config.php */ $serveur_Search = OCP\Config::getSystemValue('serveur_Search', 'error'); $port = OCP\Config::getSystemValue('port', 'error'); $this->racineAMU = OCP\Config::getSystemValue('racineAMU', 'error'); $this->racineAMUGRP = OCP\Config::getSystemValue('racineAMUGRP', 'error'); $AMU_nuage_dn = OCP\Config::getSystemValue('AMU_nuage_dn', 'error'); $AMU_nuage_pw = OCP\Config::getSystemValue('AMU_nuage_pw', 'error'); $this->ds = ldap_connect($serveur_Search, $port) or die("Impossible de se connecter au serveur LDAP {$serveur_Search}"); ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($this->ds, LDAP_OPT_NETWORK_TIMEOUT, 5); $ldapbind = ldap_bind($this->ds, $AMU_nuage_dn, $AMU_nuage_pw); if ($ldapbind != '1') { return false; } }
function addBookmark($url, $title, $tags = '') { $CONFIG_DBTYPE = OCP\Config::getSystemValue("dbtype", "sqlite"); if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $_ut = "strftime('%s','now')"; } elseif ($CONFIG_DBTYPE == 'pgsql') { $_ut = 'date_part(\'epoch\',now())::integer'; } else { $_ut = "UNIX_TIMESTAMP()"; } //FIXME: Detect when user adds a known URL $query = OCP\DB::prepare("\n\t\tINSERT INTO `*PREFIX*bookmarks`\n\t\t(`url`, `title`, `user_id`, `public`, `added`, `lastmodified`)\n\t\tVALUES (?, ?, ?, 0, {$_ut}, {$_ut})\n\t\t"); if (empty($title)) { $metadata = getURLMetadata($url); if (isset($metadata['title'])) { // Check for problems fetching the title $title = $metadata['title']; } } if (empty($title)) { $l = OC_L10N::get('bookmarks'); $title = $l->t('unnamed'); } $params = array(htmlspecialchars_decode($url), htmlspecialchars_decode($title), OCP\USER::getUser()); $query->execute($params); $b_id = OCP\DB::insertid('*PREFIX*bookmarks'); if ($b_id !== false) { $query = OCP\DB::prepare("\n\t\t\tINSERT INTO `*PREFIX*bookmarks_tags`\n\t\t\t(`bookmark_id`, `tag`)\n\t\t\tVALUES (?, ?)\n\t\t\t"); $tags = explode(' ', urldecode($tags)); foreach ($tags as $tag) { if (empty($tag)) { //avoid saving blankspaces continue; } $params = array($b_id, trim($tag)); $query->execute($params); } return $b_id; } }
<?php OCP\User::checkAdminUser(); OCP\Util::addScript("apptemplate", "admin"); $tmpl = new OCP\Template('apptemplate', 'settings'); $tmpl->assign('url', OCP\Config::getSystemValue("somesetting", '')); return $tmpl->fetchPage();
$breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path='); $maxUploadFilesize = OCP\Util::maxUploadFilesize($path); $folder = new OCP\Template('files', 'index', ''); $folder->assign('fileList', $list->fetchPage()); $folder->assign('breadcrumb', $breadcrumbNav->fetchPage()); $folder->assign('dir', $getPath); $folder->assign('isCreatable', false); $folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic', true); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('usedSpacePercent', 0); $tmpl->assign('folder', $folder->fetchPage()); $allowZip = OCP\Config::getSystemValue('allowZipDownload', true) && $totalSize <= OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB')); $tmpl->assign('allowZipDownload', intval($allowZip)); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } else { $tmpl->assign('dir', $dir); // Show file preview if viewer is available if ($type == 'file') { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download'); } else { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } } $tmpl->printPage(); } exit; } else {
$isCreatable = \OC\Files\Filesystem::isCreatable($dir . '/'); $fileHeader = (!isset($files) or count($files) > 0); $emptyContent = ($isCreatable and !$fileHeader) or $ajaxLoad; OCP\Util::addscript('files', 'fileactions'); OCP\Util::addscript('files', 'files'); OCP\Util::addscript('files', 'keyboardshortcuts'); $tmpl = new OCP\Template('files', 'index', 'user'); $tmpl->assign('fileList', $list->fetchPage()); $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage()); $tmpl->assign('dir', $dir); $tmpl->assign('isCreatable', $isCreatable); $tmpl->assign('permissions', $permissions); $tmpl->assign('files', $files); $tmpl->assign('trash', $trashEnabled); $tmpl->assign('trashEmpty', $trashEmpty); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $tmpl->assign('usedSpacePercent', (int) $storageInfo['relative']); $tmpl->assign('isPublic', false); $tmpl->assign('publicUploadEnabled', $publicUploadEnabled); $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles()); $tmpl->assign("mailNotificationEnabled", \OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'yes')); $tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes')); $tmpl->assign("encryptionInitStatus", $encryptionInitStatus); $tmpl->assign('disableSharing', false); $tmpl->assign('ajaxLoad', $ajaxLoad); $tmpl->assign('emptyContent', $emptyContent); $tmpl->assign('fileHeader', $fileHeader); $tmpl->printPage(); }
<?php /** * ownCloud - App Template Example * * @author Frank Karlitschek * @author Florian Hülsmann * @copyright 2011 Frank Karlitschek karlitschek@kde.org * @copyright 2012 Florian Hülsmann fh@cbix.de * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Check if we are a user OCP\User::checkLoggedIn(); $somesetting = OCP\Config::getSystemValue("somesetting", ''); OCP\App::setActiveNavigationEntry('apptemplate'); $tmpl = new OCP\Template('apptemplate', 'main', 'user'); $tmpl->assign('somesetting', $somesetting); $tmpl->printPage();
<?php /** * ownCloud - First Run Wizard * * @author Frank Karlitschek * @copyright 2012 Frank Karlitschek frank@owncloud.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Check if we are a user OCP\User::checkLoggedIn(); $defaults = new \OCP\Defaults(); //links to clients $clients = array('desktop' => OCP\Config::getSystemValue('customclient_desktop', $defaults->getSyncClientUrl()), 'android' => OCP\Config::getSystemValue('customclient_android', $defaults->getAndroidClientUrl()), 'ios' => OCP\Config::getSystemValue('customclient_ios', $defaults->getiOSClientUrl())); $tmpl = new OCP\Template('firstrunwizard', 'wizard', ''); $tmpl->assign('logo', OCP\Util::linkTo('core', 'img/logo-inverted.svg')); $tmpl->assign('clients', $clients); $tmpl->printPage();
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('user_migrate'); if (!empty($_POST)) { // CSRF check OCP\JSON::callCheck(); $root = OC::$SERVERROOT . "/"; $importname = "owncloud_import_" . date("y-m-d_H-i-s"); // Save data dir for later $datadir = OCP\Config::getSystemValue('datadirectory'); // Copy the uploaded file $from = $_FILES['owncloud_import']['tmp_name']; $to = get_temp_dir() . '/' . $importname . '.zip'; if (!move_uploaded_file($from, $to)) { $error = array('error' => 'Failed to move the uploaded file', 'hint' => 'Try checking the permissions of the ' . get_temp_dir() . ' dir.'); OCP\Util::writeLog('user_migrate', "Failed to copy the uploaded file", OCP\Util::ERROR); $tmpl = new OCP\Template('user_migrate', 'settings'); $tmpl->assign('error', $error); return $tmpl->fetchPage(); } $response = json_decode(OC_Migrate::import($to, 'user')); if (!$response->success) { $error = array('error' => 'There was an error while importing the user!', 'hint' => 'Please check the logs for a more detailed explaination'); $tmpl = new OCP\Template('user_migrate', 'settings'); $tmpl->assign('error', $error);
/** * Caches the general LDAP configuration. */ private static function readConfiguration($force = false) { if (!self::$configured || $force) { self::$ldapHost = OCP\Config::getAppValue('user_ldap', 'ldap_host', ''); self::$ldapPort = OCP\Config::getAppValue('user_ldap', 'ldap_port', 389); self::$ldapAgentName = OCP\Config::getAppValue('user_ldap', 'ldap_dn', ''); self::$ldapAgentPassword = base64_decode(OCP\Config::getAppValue('user_ldap', 'ldap_agent_password', '')); self::$ldapBase = OCP\Config::getAppValue('user_ldap', 'ldap_base', ''); self::$ldapBaseUsers = OCP\Config::getAppValue('user_ldap', 'ldap_base_users', self::$ldapBase); self::$ldapBaseGroups = OCP\Config::getAppValue('user_ldap', 'ldap_base_groups', self::$ldapBase); self::$ldapTLS = OCP\Config::getAppValue('user_ldap', 'ldap_tls', 0); self::$ldapNoCase = OCP\Config::getAppValue('user_ldap', 'ldap_nocase', 0); self::$ldapUserDisplayName = strtolower(OCP\Config::getAppValue('user_ldap', 'ldap_display_name', 'uid')); self::$ldapUserFilter = OCP\Config::getAppValue('user_ldap', 'ldap_userlist_filter', 'objectClass=person'); self::$ldapLoginFilter = OCP\Config::getAppValue('user_ldap', 'ldap_login_filter', '(uid=%uid)'); self::$ldapGroupDisplayName = strtolower(OCP\Config::getAppValue('user_ldap', 'ldap_group_display_name', LDAP_GROUP_DISPLAY_NAME_ATTR)); self::$ldapIgnoreNamingRules = OCP\Config::getSystemValue('ldapIgnoreNamingRules', false); if (empty(self::$ldapBaseUsers)) { OCP\Util::writeLog('ldap', 'Base for Users is empty, using Base DN', OCP\Util::INFO); self::$ldapBaseUsers = self::$ldapBase; } if (empty(self::$ldapBaseGroups)) { OCP\Util::writeLog('ldap', 'Base for Groups is empty, using Base DN', OCP\Util::INFO); self::$ldapBaseGroups = self::$ldapBase; } if (!empty(self::$ldapHost) && !empty(self::$ldapPort) && (!empty(self::$ldapAgentName) && !empty(self::$ldapAgentPassword) || empty(self::$ldapAgentName) && empty(self::$ldapAgentPassword)) && !empty(self::$ldapBase) && !empty(self::$ldapUserDisplayName)) { self::$configured = true; } } }
function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); $file = OCP\Config::getSystemValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $owner . '/files' . urldecode($photo); header('Content-Type: ' . OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); }
/** * Create a user session * @global array $profile * @global array $proto */ function user_session() { global $proto, $profile; session_name('phpMyID_Server'); if (OCP\Config::getSystemValue("forcessl", false)) { ini_set("session.cookie_secure", "on"); } @session_start(); $profile['authorized'] = isset($_SESSION['auth_username']) && $_SESSION['auth_username'] == $profile['auth_username'] ? true : false; debug('Started user session: ' . session_id() . ' Auth? ' . $profile['authorized']); }
<?php // Get the data $imageData = $_POST['canv_data']; $title = rtrim($_POST['title'], 'pdf'); $location = urldecode(dirname($_POST['location'])); if ($location != '/') { $location = $location . '/'; } $filteredData = substr($imageData, strpos($imageData, ",") + 1); $owner = OCP\USER::getUser(); $save_dir = OCP\Config::getSystemValue("datadirectory") . '/' . $owner . '/reader'; $save_dir .= $location; $thumb_file = $save_dir . $title; if (!is_dir($save_dir)) { mkdir($save_dir, 0777, true); } $image = new OC_Image($filteredData); if ($image->valid()) { $image->centerCrop(100); $image->fixOrientation(); $image->save($thumb_file . 'png'); }
/** * @brief Finds all bookmarks, matching the filter * @param offset result offset * @param sqlSortColumn sort result with this column * @param filter can be: empty -> no filter, a string -> filter this, a string array -> filter for all strings * @param filterTagOnly if true, filter affacts only tags, else filter affects url, title and tags * @return void */ public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly) { //OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG); $CONFIG_DBTYPE = OCP\Config::getSystemValue('dbtype', 'sqlite'); $params = array(OCP\USER::getUser()); if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $_gc_separator = ', \' \''; } else { $_gc_separator = 'SEPARATOR \' \''; } if ($filter) { if ($CONFIG_DBTYPE == 'pgsql') { $tagString = 'array_to_string(array_agg(tag), \' \')'; } else { $tagString = 'tags'; } $sqlFilterTag = 'HAVING '; if (is_array($filter)) { $first = true; $filterstring = ''; foreach ($filter as $singleFilter) { $filterstring = $filterstring . ($first ? '' : ' AND ') . $tagString . ' LIKE ? '; $params[] = '%' . $singleFilter . '%'; $first = false; } $sqlFilterTag = $sqlFilterTag . $filterstring; } else { $sqlFilterTag = $sqlFilterTag . $tagString . ' LIKE ? '; $params[] = '%' . $filter . '%'; } } else { $sqlFilterTag = ''; } if ($CONFIG_DBTYPE == 'pgsql') { $query = OCP\DB::prepare(' SELECT `id`, `url`, `title`, ' . ($filterTagOnly ? '' : '`url` || `title` ||') . ' array_to_string(array_agg(`tag`), \' \') as `tags` FROM `*PREFIX*bookmarks` LEFT JOIN `*PREFIX*bookmarks_tags` ON `*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id` WHERE `*PREFIX*bookmarks`.`user_id` = ? GROUP BY `id`, `url`, `title` ' . $sqlFilterTag . ' ORDER BY `*PREFIX*bookmarks`.`' . $sqlSortColumn . '` DESC', 10, $offset); } else { if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $concatFunction = '(url || title || '; } else { $concatFunction = 'Concat(Concat( url, title), '; } $query = OCP\DB::prepare(' SELECT `id`, `url`, `title`, ' . ($filterTagOnly ? '' : $concatFunction) . 'CASE WHEN `*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id` THEN GROUP_CONCAT( `tag` ' . $_gc_separator . ' ) ELSE \' \' END ' . ($filterTagOnly ? '' : ')') . ' AS `tags` FROM `*PREFIX*bookmarks` LEFT JOIN `*PREFIX*bookmarks_tags` ON 1=1 WHERE (`*PREFIX*bookmarks`.`id` = `*PREFIX*bookmarks_tags`.`bookmark_id` OR `*PREFIX*bookmarks`.`id` NOT IN ( SELECT `*PREFIX*bookmarks_tags`.`bookmark_id` FROM `*PREFIX*bookmarks_tags` ) ) AND `*PREFIX*bookmarks`.`user_id` = ? GROUP BY `url` ' . $sqlFilterTag . ' ORDER BY `*PREFIX*bookmarks`.`' . $sqlSortColumn . '` DESC', 10, $offset); } $bookmarks = $query->execute($params)->fetchAll(); return $bookmarks; }
/** * Add a set of tags for a bookmark * * @param int $bookmarkId The bookmark reference * @param array $tags Set of tags to add to the bookmark * @return null **/ private static function addTags($bookmarkId, $tags) { $sql = 'INSERT INTO `*PREFIX*bookmarks_tags` (`bookmark_id`, `tag`) select ?, ? '; $dbtype = OCP\Config::getSystemValue('dbtype', 'sqlite'); if ($dbtype === 'mysql') { $sql .= 'from dual '; } $sql .= 'where not exists(select * from `*PREFIX*bookmarks_tags` where `bookmark_id` = ? and `tag` = ?)'; $query = OCP\DB::prepare($sql); foreach ($tags as $tag) { $tag = trim($tag); if (empty($tag)) { //avoid saving white spaces continue; } $params = array($bookmarkId, $tag, $bookmarkId, $tag); $query->execute($params); } }
$folder->assign('permissions', OCP\PERMISSION_READ); $folder->assign('isPublic', true); $folder->assign('publicUploadEnabled', 'no'); $folder->assign('files', $files); $folder->assign('uploadMaxFilesize', $maxUploadFilesize); $folder->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize)); $folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true))); $folder->assign('usedSpacePercent', 0); $folder->assign('fileHeader', $fileHeader); $folder->assign('disableSharing', true); $folder->assign('trash', false); $folder->assign('emptyContent', $emptyContent); $folder->assign('ajaxLoad', false); $tmpl->assign('folder', $folder->fetchPage()); $maxInputFileSize = OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB')); $allowZip = OCP\Config::getSystemValue('allowZipDownload', true) && ($maxInputFileSize === 0 || $totalSize <= $maxInputFileSize); $tmpl->assign('allowZipDownload', intval($allowZip)); $tmpl->assign('showDownloadButton', intval($allowZip)); $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } else { $tmpl->assign('showDownloadButton', true); $tmpl->assign('dir', $dir); // Show file preview if viewer is available if ($type == 'file') { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download'); } else { $tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath)); } } $tmpl->printPage(); }
<?php $currentVersion = OCP\Config::getAppValue('search_lucene', 'installed_version'); if (version_compare($currentVersion, '0.5.2', '<')) { //delete duplicate id entries $dbtype = OCP\Config::getSystemValue('dbtype', 'sqlite3'); if ($dbtype === 'mysql') { // fix MySQL ERROR 1093 (HY000), see http://stackoverflow.com/a/12969601 $sql = 'DELETE FROM `*PREFIX*lucene_status` WHERE `fileid` IN ( SELECT `fileid` FROM ( SELECT `fileid` FROM `*PREFIX*lucene_status` GROUP BY `fileid` HAVING count(`status`) > 1 ) AS `mysqlerr1093hack` ) '; } else { $sql = 'DELETE FROM `*PREFIX*lucene_status` WHERE `fileid` IN ( SELECT `fileid` FROM `*PREFIX*lucene_status` GROUP BY `fileid` HAVING count(`status`) > 1 ) '; } $stmt = OCP\DB::prepare($sql); $stmt->execute(); }
/** * @brief Finds all bookmarks, matching the filter * @param offset result offset * @param sqlSortColumn sort result with this column * @param filter can be: empty -> no filter, a string -> filter this, a string array -> filter for all strings * @param filterTagOnly if true, filter affacts only tags, else filter affects url, title and tags * @return void */ public static function findBookmarks($offset, $sqlSortColumn, $filter, $filterTagOnly) { //OCP\Util::writeLog('bookmarks', 'findBookmarks ' .$offset. ' '.$sqlSortColumn.' '. $filter.' '. $filterTagOnly ,OCP\Util::DEBUG); $CONFIG_DBTYPE = OCP\Config::getSystemValue('dbtype', 'sqlite'); $params = array(OCP\USER::getUser()); if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $_gc_separator = ', \' \''; } else { $_gc_separator = 'SEPARATOR \' \''; } if ($filter) { if ($CONFIG_DBTYPE == 'pgsql') { $tagString = 'array_to_string(array_agg(tag), \' \')'; } else { $tagString = 'tags'; } $sqlFilterTag = 'HAVING '; if (is_array($filter)) { $first = true; $filterstring = ''; foreach ($filter as $singleFilter) { $filterstring = $filterstring . ($first ? '' : ' AND ') . $tagString . ' LIKE ? '; $params[] = '%' . $singleFilter . '%'; $first = false; } $sqlFilterTag = $sqlFilterTag . $filterstring; } else { $sqlFilterTag = $sqlFilterTag . $tagString . ' LIKE ? '; $params[] = '%' . $filter . '%'; } } else { $sqlFilterTag = ''; } if ($CONFIG_DBTYPE == 'pgsql') { $query = OCP\DB::prepare(' SELECT id, url, title, ' . ($filterTagOnly ? '' : 'url || title ||') . ' array_to_string(array_agg(tag), \' \') as tags FROM *PREFIX*bookmarks LEFT JOIN *PREFIX*bookmarks_tags ON *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id WHERE *PREFIX*bookmarks.user_id = ? GROUP BY id, url, title ' . $sqlFilterTag . ' ORDER BY *PREFIX*bookmarks.' . $sqlSortColumn . ' DESC LIMIT 10 OFFSET ' . $offset); } else { if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $concatFunction = '(url || title || '; } else { $concatFunction = 'Concat(Concat( url, title), '; } $query = OCP\DB::prepare(' SELECT id, url, title, ' . ($filterTagOnly ? '' : $concatFunction) . 'CASE WHEN *PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id THEN GROUP_CONCAT( tag ' . $_gc_separator . ' ) ELSE \' \' END ' . ($filterTagOnly ? '' : ')') . ' AS tags FROM *PREFIX*bookmarks LEFT JOIN *PREFIX*bookmarks_tags ON 1=1 WHERE (*PREFIX*bookmarks.id = *PREFIX*bookmarks_tags.bookmark_id OR *PREFIX*bookmarks.id NOT IN ( SELECT *PREFIX*bookmarks_tags.bookmark_id FROM *PREFIX*bookmarks_tags ) ) AND *PREFIX*bookmarks.user_id = ? GROUP BY url ' . $sqlFilterTag . ' ORDER BY *PREFIX*bookmarks.' . $sqlSortColumn . ' DESC LIMIT ' . $offset . ', 10'); } $bookmarks = $query->execute($params)->fetchAll(); return $bookmarks; }
<?php OCP\User::checkAdminUser(); OCP\Util::addScript("user_oauth", "admin"); $tmpl = new OCP\Template('user_oauth', 'settings'); $tmpl->assign('introspectionEndpoint', OCP\Config::getSystemValue("introspectionEndpoint", 'https://frko.surfnetlabs.nl/workshop/php-oauth/introspect.php')); return $tmpl->fetchPage();
<?php OCP\User::checkAdminUser(); OCP\Util::addScript("user_oauth", "admin"); $tmpl = new OCP\Template('user_oauth', 'settings'); $tmpl->assign('tokenInfoEndpoint', OCP\Config::getSystemValue("tokenInfoEndpoint", 'https://www.googleapis.com/oauth2/v1/tokeninfo')); return $tmpl->fetchPage();
* version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); OCP\JSON::checkAppEnabled('bookmarks'); $CONFIG_DBTYPE = OCP\Config::getSystemValue("dbtype", "sqlite"); if ($CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3') { $_ut = "strftime('%s','now')"; } elseif ($CONFIG_DBTYPE == 'pgsql') { $_ut = 'date_part(\'epoch\',now())::integer'; } elseif ($CONFIG_DBTYPE == 'oci') { $_ut = '(oracletime - to_date(\'19700101\',\'YYYYMMDD\')) * 86400'; } else { $_ut = "UNIX_TIMESTAMP()"; } $bookmark_id = (int) $_POST["id"]; $user_id = OCP\USER::getUser(); //TODO check using CURRENT_TIMESTAMP? prepare already does magic when using now() $query = OCP\DB::prepare(' UPDATE `*PREFIX*bookmarks` SET `url` = ?, `title` = ?, `lastmodified` = ' . $_ut . '
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); $maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size)); if ($_POST && OC_Util::isCallRegistered()) { if (isset($_POST['maxUploadSize'])) { if (($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) { $maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize); } } if (isset($_POST['maxZipInputSize'])) { $maxZipInputSize = $_POST['maxZipInputSize']; OCP\Config::setSystemValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize)); } if (isset($_POST['submitFilesAdminSettings'])) { OCP\Config::setSystemValue('allowZipDownload', isset($_POST['allowZipDownload'])); } } $maxZipInputSizeDefault = OCP\Util::computerFileSize('800 MB'); $maxZipInputSize = OCP\Util::humanFileSize(OCP\Config::getSystemValue('maxZipInputSize', $maxZipInputSizeDefault)); $allowZipDownload = intval(OCP\Config::getSystemValue('allowZipDownload', true)); OCP\App::setActiveNavigationEntry("files_administration"); $htaccessWritable = is_writable(OC::$SERVERROOT . '/.htaccess'); $tmpl = new OCP\Template('files', 'admin'); $tmpl->assign('uploadChangable', $htaccessWorking and $htaccessWritable); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // max possible makes only sense on a 32 bit system $tmpl->assign('displayMaxPossibleUploadSize', PHP_INT_SIZE === 4); $tmpl->assign('maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX)); $tmpl->assign('allowZipDownload', $allowZipDownload); $tmpl->assign('maxZipInputSize', $maxZipInputSize); return $tmpl->fetchPage();
<?php /** * @author Arthur Schiwon <*****@*****.**> * @author Christopher Schäpers <*****@*****.**> * @author Joas Schilling <*****@*****.**> * * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet'); if ($state === 'doSet') { OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); } OCP\Backgroundjob::registerJob('OCA\\user_ldap\\lib\\Jobs'); OCP\Backgroundjob::registerJob('\\OCA\\User_LDAP\\Jobs\\CleanUp');
public static function checkAuth($auth) { if (is_array($auth)) { if (isset($auth['auth'])) { $auth = $auth['auth']; } else { return false; } } $CONFIG_DBTYPE = OCP\Config::getSystemValue("dbtype", "sqlite"); if ($CONFIG_DBTYPE == 'psql') { $interval = ' \'600s\'::interval '; } else { $interval = '600'; } //remove old sessions $query = OCP\DB::prepare("DELETE FROM `*PREFIX*media_sessions` WHERE `start`<(NOW() - " . $interval . ")"); $query->execute(); $query = OCP\DB::prepare("SELECT `user_id` FROM `*PREFIX*media_sessions` WHERE `token`=?"); $users = $query->execute(array($auth))->fetchAll(); if (count($users) > 0) { OC_MEDIA_COLLECTION::$uid = $users[0]['user_id']; OC_User::setUserId($users[0]['user_id']); return $users[0]['user_id']; } else { return false; } }
public static function post_login($parameters) { $uid = $parameters['uid']; $wuid = $uid; $casBackend = new OC_USER_CAS(); $userDB = new OC_User_Database(); /* * Récupération des données du fichier config général /config/config.php */ $serveur_Search = OCP\Config::getSystemValue('serveur_Search', 'error'); $port = OCP\Config::getSystemValue('port', 'error'); $racineAMU = OCP\Config::getSystemValue('racineAMU', 'error'); $racineAMUGRP = OCP\Config::getSystemValue('racineAMUGRP', 'error'); $AMU_nuage_dn = OCP\Config::getSystemValue('AMU_nuage_dn', 'error'); $AMU_nuage_pw = OCP\Config::getSystemValue('AMU_nuage_pw', 'error'); $PQuota = OCP\Config::getSystemValue('PQuota', 'unManaged'); $EQuota = OCP\Config::getSystemValue('EQuota', 'unManaged'); $LDAP = new LDAP_Infos($serveur_Search, $AMU_nuage_dn, $AMU_nuage_pw, $racineAMUGRP, $racineAMUGRP); $restrictGrp = array("cn", "member"); /* * Récupération tableau Groupes * Si le tableau 'groupMapping' est vide pas de contrôle sur les groupes */ $AccesCloud = 0; OCP\Util::writeLog('user_cas', "Authentification (Mapping groups=" . $casBackend->groupMapping . ")", OCP\Util::DEBUG); if ($casBackend->groupMapping) { $wTabGrp = str_replace(array('<br>', '<br />', "\n", "\r"), array('@', '', '@', ''), $casBackend->groupMapping); $tabGRP = explode("@", $wTabGrp); $i = 0; $mesGroupes = array(); foreach ($tabGRP as $key => $value) { $ListeMembre = $LDAP->getMembersOfGroup($value, $restrictGrp); if (in_array($uid, $ListeMembre)) { $AccesCloudAMU = 1; } } } else { $AccesCloud = 1; } /* * Si pas d'acces, alors déconnexion */ if ($AccesCloud == 0) { /* * On vérifie si le compte utilisé est un compte local */ if (!$userDB->userExists($uid)) { OCP\Util::writeLog('user_cas', "Aucun droit d'accès pour l'utilisateur " . $uid, OCP\Util::ERROR); \OC_User::logout(); } else { OCP\Util::writeLog('user_cas', "Authentification locale pour l'utilisateur " . $uid, OCP\Util::DEBUG); OC::$REQUESTEDAPP = ''; OC_Util::redirectToDefaultPage(); exit(0); } } /** * Récupère les groupes liés à l'utilisateur avec la racine définie dans le formulaire 'cas_group_root' * Si 'cas_group_root' n'est pas renseingé => pas de récupération de groupes */ $mesGroupes = array(); OCP\Util::writeLog('user_cas', "Authentification (Racine Groupes LDAP=" . $casBackend->groupRoot . ")", OCP\Util::DEBUG); if ($casBackend->groupRoot) { $i = 0; $ListeGRP = $LDAP->getMemberOf($uid); $a = sizeof($ListeGRP); OCP\Util::writeLog('user_cas', "Taille=" . $a . " UID=" . $uid, OCP\Util::ERROR); OCP\Util::writeLog('user_cas', "Racine Groupe=" . $casBackend->groupRoot, OCP\Util::ERROR); foreach ($ListeGRP as $key => $value) { if (strstr($value, $casBackend->groupRoot)) { $mesGroupes[$i] = strtoupper(str_replace(':', '_', substr($value, 8))); OCP\Util::writeLog('user_cas', "Groupe[{$i}]=" . $mesGroupes[$i], OCP\Util::ERROR); $i++; } } } if (phpCAS::checkAuthentication()) { //$attributes = phpCAS::getAttributes(); $cas_uid = phpCAS::getUser(); if ($cas_uid == $uid) { /* * Récupération des information utilisateur (LDAP) */ $tabLdapUser = $LDAP->getUserInfo($uid); if ($tabLdapUser) { $DisplayName = $tabLdapUser['displayName']; } if (!$userDB->userExists($uid)) { if (preg_match('/[^a-zA-Z0-9 _\\.@\\-]/', $uid)) { OCP\Util::writeLog('cas', 'Utilisateur invalide "' . $uid . '", caracteres autorises "a-zA-Z0-9" and "_.@-" ', OCP\Util::DEBUG); return false; } else { /* * Dans le cas d'une création */ $random_password = \OC_Util::generateRandomBytes(20); $userDB->createUser($uid, $tabLdapUser['userpassword']); $userDB->setDisplayName($uid, $DisplayName); /* * Mise à jour du quota si gestion dans fichier de configuration */ if ($EQuota != "unManaged" && $tabLdapUser['eduPersonPrimaryAffiliation'] == 'student') { update_quota($uid, $EQuota); } if ($PQuota != "unManaged" && $tabLdapUser['eduPersonPrimaryAffiliation'] != 'student') { update_quota($uid, $PQuota); } } } /* * Mise à jour des groupes associés */ if (sizeof($mesGroupes) > 0) { $cas_groups = $mesGroupes; update_groups($uid, $cas_groups, $casBackend->protectedGroups, true); } /* * Mise à jour du mail */ update_mail($uid, $tabLdapUser['Mail']); /* * Mise à jour du display name */ $userDB->setDisplayName($uid, $DisplayName); return true; } } return false; }
<?php /** * ownCloud - First Run Wizard * * @author Frank Karlitschek * @copyright 2012 Frank Karlitschek frank@owncloud.org * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ // Check if we are a user OCP\User::checkLoggedIn(); $defaults = new \OCP\Defaults(); //links to clients $clients = array('desktop' => OCP\Config::getSystemValue('customclient_desktop', $defaults->getSyncClientUrl()), 'android' => OCP\Config::getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.owncloud.android'), 'ios' => OCP\Config::getSystemValue('customclient_ios', 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8')); $tmpl = new OCP\Template('firstrunwizard', 'wizard', ''); $tmpl->assign('logo', OCP\Util::linkTo('core', 'img/logo-inverted.svg')); $tmpl->assign('clients', $clients); $tmpl->printPage();
<form id="versions"> <fieldset class="personalblock"> <input type="checkbox" name="versions" id="versions" value="1" <?php if (OCP\Config::getSystemValue('versions', 'true') == 'true') { echo ' checked="checked"'; } ?> /> <label for="versions"><?php echo $l->t('Enable Files Versioning'); ?> </label> <br/> </fieldset> </form>
/** * @method OC_Shorty_Tools::db_timestamp * @brief Current timestamp as required by db engine * @return string: Current timestamp as required by db engine * @throws OC_Shorty_Exception In case of an unknown database engine * @access public * @author Christian Reiner * @todo not really required any more, we rely on CURRENT_TIMESTAMP instead */ static function db_timestamp ( ) { $type = OCP\Config::getSystemValue( "dbtype", "sqlite" ); switch ( $type ) { case 'sqlite': case 'sqlite3': return "strftime('%s','now')"; case 'mysql': return 'UNIX_TIMESTAMP()'; case 'pgsql': return "date_part('epoch',now())::integer"; } throw new OC_Shorty_Exception ( "unknown database backend type '%1'", array($type) ); } // function db_timestamp