diff options
42 files changed, 164 insertions, 206 deletions
diff --git a/apps/admin_dependencies_chk/appinfo/app.php b/apps/admin_dependencies_chk/appinfo/app.php index 72d368a085e..62b26342d23 100644 --- a/apps/admin_dependencies_chk/appinfo/app.php +++ b/apps/admin_dependencies_chk/appinfo/app.php @@ -1,9 +1,4 @@ <?php $l=OC_L10N::get('admin_dependencies_chk'); -OCP\App::register( array( - 'order' => 14, - 'id' => 'admin_dependencies_chk', - 'name' => 'Owncloud Install Info' )); - OCP\App::registerAdmin('admin_dependencies_chk','settings'); diff --git a/apps/bookmarks/appinfo/app.php b/apps/bookmarks/appinfo/app.php index 8a8f443891c..f4bca9df700 100644 --- a/apps/bookmarks/appinfo/app.php +++ b/apps/bookmarks/appinfo/app.php @@ -10,8 +10,6 @@ OC::$CLASSPATH['OC_Bookmarks_Bookmarks'] = 'apps/bookmarks/lib/bookmarks.php'; OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php'; -OCP\App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' )); - $l = new OC_l10n('bookmarks'); OCP\App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks'))); diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index 202af1eb46e..904c07c52e7 100644 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -7,16 +7,23 @@ */ //check for calendar rights or create new one ob_start(); + OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); + $nl="\r\n"; $comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); + $progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '10'); - fclose($progressfopen); + +function writeProgress($pct) { + if(is_writable('import_tmp/')){ + $progressfopen = fopen($progressfile, 'w'); + fwrite($progressfopen, $pct); + fclose($progressfopen); + } } +writeProgress('10'); $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); if($_POST['method'] == 'new'){ $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), $_POST['calname']); @@ -29,20 +36,12 @@ if($_POST['method'] == 'new'){ } $id = $_POST['id']; } -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '20'); - fclose($progressfopen); -} +writeProgress('20'); // normalize the newlines $file = str_replace(array("\r","\n\n"), array("\n","\n"), $file); $lines = explode("\n", $file); unset($file); -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '30'); - fclose($progressfopen); -} +writeProgress('30'); // analyze the file, group components by uid, and keep refs to originating calendar object // $cals is array calendar objects, keys are 1st line# $cal, ie array( $cal => $caldata ) // $caldata is array( 'first' => 1st component line#, 'last' => last comp line#, 'end' => end line# ) @@ -86,11 +85,7 @@ foreach($lines as $line) { $i++; } // import the calendar -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '60'); - fclose($progressfopen); -} +writeProgress('60'); foreach($uids as $uid) { $prefix=$suffix=$content=array(); @@ -117,11 +112,7 @@ foreach($uids as $uid) { } } // finished import -if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, '100'); - fclose($progressfopen); -} +writeProgress('100'); sleep(3); if(is_writable('import_tmp/')){ unlink($progressfile); diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 73480522eaf..253844c1f08 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -12,10 +12,6 @@ OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'delete OCP\Util::addscript('calendar','loader'); OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min"); OCP\Util::addStyle("3rdparty", "chosen/chosen"); -OCP\App::register( array( - 'order' => 10, - 'id' => 'calendar', - 'name' => 'Calendar' )); OCP\App::addNavigationEntry( array( 'id' => 'calendar_index', 'order' => 10, diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php index 965523f847a..bad268897bf 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -1,6 +1,6 @@ <?php echo '<td width="20px"><input id="active_' . $_['calendar']['id'] . '" type="checkbox" onClick="Calendar.UI.Calendar.activation(this,' . $_['calendar']['id'] . ')"' . ($_['calendar']['active'] ? ' checked="checked"' : '') . '></td>'; -echo '<td id="' . OCP\USER::getUser() . '_' . $_['calendar']['id'] . '"><label for="active_' . $_['calendar']['id'] . '">' . $_['calendar']['displayname'] . '</label></td>'; +echo '<td id="' . OCP\USER::getUser() . '_' . $_['calendar']['id'] . '"><label for="active_' . $_['calendar']['id'] . '">' . htmlspecialchars($_['calendar']['displayname']) . '</label></td>'; echo '<td width="20px"><a href="#" onclick="Calendar.UI.Share.dropdown(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['id'] . '\');" title="' . $l->t("Share Calendar") . '" class="action"><img class="svg action" src="' . ((!$_['shared']) ? OCP\Util::imagePath('core', 'actions/share.svg') : OCP\Util::imagePath('core', 'actions/shared.svg')) . '"></a></td>'; echo '<td width="20px"><a href="#" onclick="Calendar.UI.showCalDAVUrl(\'' . OCP\USER::getUser() . '\', \'' . $_['calendar']['uri'] . '\');" title="' . $l->t("CalDav Link") . '" class="action"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/public.svg').'"></a></td>'; echo '<td width="20px"><a href="?app=calendar&getfile=export.php?calid=' . $_['calendar']['id'] . '" title="' . $l->t('Download') . '" class="action"><img class="svg action" src="'.OCP\Util::imagePath('core', 'actions/download.svg').'"></a></td>'; diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php index a23266da0c3..6a212858a21 100644 --- a/apps/calendar/templates/part.choosecalendar.rowfields.shared.php +++ b/apps/calendar/templates/part.choosecalendar.rowfields.shared.php @@ -1,4 +1,4 @@ <?php echo '<td width="20px"><input id="active_' . $_['share']['owner'] . '_' . $_['share']['calendar']['id'] . '" type="checkbox" onClick="Calendar.UI.Share.activation(this,\'' . $_['share']['owner'] . '\',' . $_['share']['calendar']['id'] . ')"' . ($_['share']['active'] ? ' checked="checked"' : '') . '></td>'; -echo '<td><label for="active_' . $_['share']['owner'] . '_' . $_['share']['calendar']['id'] . '">' . $_['share']['calendar']['displayname'] . '</label></td>'; +echo '<td><label for="active_' . $_['share']['owner'] . '_' . $_['share']['calendar']['id'] . '">' . htmlspecialchars($_['share']['calendar']['displayname']) . '</label></td>'; echo '<td style="font-style: italic;">' . $l->t('shared with you by') . ' ' . $_['share']['owner'] . '</td>';
\ No newline at end of file diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 20d97697bf4..7a04ec7ff5e 100644 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -9,11 +9,6 @@ OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'delete OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents'); OCP\Util::connectHook('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources'); -OCP\App::register( array( - 'order' => 10, - 'id' => 'contacts', - 'name' => 'Contacts' )); - OCP\App::addNavigationEntry( array( 'id' => 'contacts_index', 'order' => 10, diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php index ee5437782cd..1a02f3a1be8 100644 --- a/apps/external/appinfo/app.php +++ b/apps/external/appinfo/app.php @@ -26,8 +26,6 @@ OCP\Util::addStyle( 'external', 'style'); OCP\App::registerAdmin('external', 'settings'); -OCP\App::register(array('order' => 70, 'id' => 'external', 'name' => 'External')); - $sites = OC_External::getSites(); for ($i = 0; $i < sizeof($sites); $i++) { OCP\App::addNavigationEntry( diff --git a/apps/files/ajax/timezone.php b/apps/files/ajax/timezone.php index 8e1d2aa1ec1..cafb5074ece 100644 --- a/apps/files/ajax/timezone.php +++ b/apps/files/ajax/timezone.php @@ -1,6 +1,6 @@ <?php // FIXME: this should start a secure session if forcessl is enabled // see lib/base.php for an example - session_start(); + //session_start(); $_SESSION['timezone'] = $_GET['time']; ?> diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index 5c0d3c8db83..db3b213ab8d 100644 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -1,7 +1,6 @@ <?php $l=OC_L10N::get('files'); -OCP\App::register( array( "order" => 2, "id" => "files", "name" => "Files" )); OCP\App::registerAdmin('files','admin'); OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") )); diff --git a/apps/files/index.php b/apps/files/index.php index a2fae12d945..60a3836cb59 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -74,11 +74,11 @@ foreach( explode( '/', $dir ) as $i ){ // make breadcrumb und filelist markup $list = new OCP\Template( 'files', 'part.list', '' ); $list->assign( 'files', $files ); -$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir='); +$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file='); $breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' ); $breadcrumbNav->assign( 'breadcrumb', $breadcrumb ); -$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir='); +$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir='); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 68268a7d3a9..19978b61a7d 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -161,7 +161,7 @@ FileActions.register('all','Rename',function(){return OC.imagePath('core','actio }); FileActions.register('dir','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php') + '&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('dir','Open'); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 31fb5f892e4..e6a9a6883af 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -41,7 +41,7 @@ FileList={ html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name}); td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); td.append('<input type="checkbox" />'); - var link_elem = $('<a></a>').attr({ "class": "name", "href": "index.php?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); + var link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); link_elem.append($('<span></span>').addClass('nametext').text(name)); link_elem.append($('<span></span>').attr({'class': 'uploadtext', 'currentUploads': 0})); td.append(link_elem); @@ -56,7 +56,7 @@ FileList={ modifiedColor=Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5); td = $('<td></td>').attr({ "class": "filesize", "title": humanFileSize(size), "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')'}).text(simpleSize); html.append(td); - + td = $('<td></td>').attr({ "class": "date" }); td.append($('<span></span>').attr({ "class": "modified", "title": formatDate(lastModified), "style": 'color:rgb('+modifiedColor+','+modifiedColor+','+modifiedColor+')' }).text( relative_modified_date(lastModified.getTime() / 1000) )); html.append(td); diff --git a/apps/files_archive/js/archive.js b/apps/files_archive/js/archive.js index 531eb61c01a..9fb9853e299 100644 --- a/apps/files_archive/js/archive.js +++ b/apps/files_archive/js/archive.js @@ -8,11 +8,11 @@ $(document).ready(function() { if(typeof FileActions!=='undefined'){ FileActions.register('application/zip','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('application/zip','Open'); FileActions.register('application/x-gzip','Open','',function(filename){ - window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php')+'&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('application/x-gzip','Open'); } diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index ec27900cbc6..d2b8ad145ae 100644 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -43,16 +43,23 @@ class OC_Crypt { self::init($params['uid'],$params['password']); } - public static function init($login,$password) { - $view=new OC_FilesystemView('/'.$login); - OC_FileProxy::$enabled=false; - if(!$view->file_exists('/encryption.key')){// does key exist? - OC_Crypt::createkey($login,$password); - } - $key=$view->file_get_contents('/encryption.key'); - OC_FileProxy::$enabled=true; - $_SESSION['enckey']=OC_Crypt::decrypt($key, $password); - } + public static function init($login,$password) { + $view1=new OC_FilesystemView('/'); + if(!$view1->file_exists('/'.$login)){ + $view1->mkdir('/'.$login); + } + + $view=new OC_FilesystemView('/'.$login); + + OC_FileProxy::$enabled=false; + if(!$view->file_exists('/encryption.key')){// does key exist? + OC_Crypt::createkey($login,$password); + } + $key=$view->file_get_contents('/encryption.key'); + OC_FileProxy::$enabled=true; + $_SESSION['enckey']=OC_Crypt::decrypt($key, $password); + } + /** * get the blowfish encryption handeler for a key diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php index 163683cd0e3..523c3d2078b 100644 --- a/apps/files_sharing/ajax/email.php +++ b/apps/files_sharing/ajax/email.php @@ -7,7 +7,7 @@ $type = (strpos($_POST['file'], '.') === false) ? 'folder' : 'file'; $subject = $user.' shared a '.$type.' with you'; $link = $_POST['link']; $text = $user.' shared the '.$type.' '.$_POST['file'].' with you. It is available for download here: '.$link; -$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.$_SERVER['HTTP_HOST']); +$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.OCP\Util::getServerHost()); OC_Mail::send($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user); -?>
\ No newline at end of file +?> diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 457c5125353..49f1573f7c2 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -2,14 +2,8 @@ require_once('apps/files_versions/versions.php'); -// Add an entry in the app list -OCP\App::register( array( - 'order' => 10, - 'id' => 'files_versions', - 'name' => 'Versioning' )); - OCP\App::registerAdmin('files_versions', 'settings'); OCP\Util::addscript('files_versions', 'versions'); // Listen to write signals -OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook");
\ No newline at end of file +OCP\Util::connectHook(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OCA_Versions\Storage", "write_hook"); diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index 8a88808f548..f39b5a7f4eb 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -81,7 +81,7 @@ class Storage { Storage::init(); // check if filename is a directory - if(is_dir($filesfoldername.$filename)){ + if(is_dir($filesfoldername.'/'.$filename)){ return false; } @@ -96,14 +96,14 @@ class Storage { } // check filesize - if(filesize($filesfoldername.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ + if(filesize($filesfoldername.'/'.$filename)>\OCP\Config::getSystemValue('files_versionsmaxfilesize', Storage::DEFAULTMAXFILESIZE)){ return false; } // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) if ($uid == \OCP\User::getUser()) { - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); sort($matches); $parts=explode('.v',end($matches)); if((end($parts)+Storage::DEFAULTMININTERVAL)>time()){ @@ -114,10 +114,10 @@ class Storage { // create all parent folders $info=pathinfo($filename); - @mkdir($versionsfoldername.$info['dirname'],0700,true); + if(!file_exists($versionsfoldername.'/'.$info['dirname'])) mkdir($versionsfoldername.'/'.$info['dirname'],0700,true); // store a new version of a file - copy($filesfoldername.$filename,$versionsfoldername.$filename.'.v'.time()); + copy($filesfoldername.'/'.$filename,$versionsfoldername.'/'.$filename.'.v'.time()); // expire old revisions Storage::expire($filename); @@ -143,7 +143,7 @@ class Storage { $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; // rollback - if ( @copy($versionsfoldername.$filename.'.v'.$revision,$filesfoldername.$filename) ) { + if ( @copy($versionsfoldername.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) { return true; @@ -172,7 +172,7 @@ class Storage { $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); if(count($matches)>1){ return true; }else{ @@ -201,7 +201,7 @@ class Storage { $versions=array(); // fetch for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); sort($matches); foreach($matches as $ma) { $parts=explode('.v',$ma); @@ -238,14 +238,14 @@ class Storage { $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.$filename.'.v*'); + $matches=glob($versionsfoldername.'/'.$filename.'.v*'); if(count($matches)>\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)){ $numbertodelete=count($matches-\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)); // delete old versions of a file $deleteitems=array_slice($matches,0,$numbertodelete); foreach($deleteitems as $de){ - unlink($versionsfoldername.$filename.'.v'.$de); + unlink($versionsfoldername.'/'.$filename.'.v'.$de); } } } diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 878da48698a..e1db33eb314 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -29,11 +29,6 @@ OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.p $l = OC_L10N::get('gallery'); -OCP\App::register(array( - 'order' => 20, - 'id' => 'gallery', - 'name' => 'Pictures')); - OCP\App::addNavigationEntry( array( 'id' => 'gallery_index', 'order' => 20, diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index d6a09c48059..869bc344020 100644 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -29,8 +29,6 @@ require_once('apps/media/lib_scanner.php'); OCP\Util::addscript('media','loader'); OCP\App::registerPersonal('media','settings'); -OCP\App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' )); - OCP\App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music'))); OC_Search::registerProvider('OC_MediaSearchProvider'); diff --git a/apps/remoteStorage/appinfo/app.php b/apps/remoteStorage/appinfo/app.php index 14b8a3d11df..c278fd73056 100644 --- a/apps/remoteStorage/appinfo/app.php +++ b/apps/remoteStorage/appinfo/app.php @@ -1,6 +1,2 @@ <?php -OCP\App::register( array( - 'order' => 10, - 'id' => 'remoteStorage', - 'name' => 'remoteStorage compatibility' )); OCP\App::registerPersonal('remoteStorage','settings'); diff --git a/apps/tasks/appinfo/app.php b/apps/tasks/appinfo/app.php index f346e2aa4c0..e7c82d6f247 100644 --- a/apps/tasks/appinfo/app.php +++ b/apps/tasks/appinfo/app.php @@ -3,11 +3,6 @@ $l=new OC_L10N('tasks'); OC::$CLASSPATH['OC_Calendar_Calendar'] = 'apps/calendar/lib/calendar.php'; OC::$CLASSPATH['OC_Task_App'] = 'apps/tasks/lib/app.php'; -OCP\App::register( array( - 'order' => 11, - 'id' => 'tasks', - 'name' => 'Tasks' )); - OCP\App::addNavigationEntry( array( 'id' => 'tasks_index', 'order' => 11, diff --git a/apps/tasks/index.php b/apps/tasks/index.php index 5e17ca454ec..4ff304a5607 100644 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -26,7 +26,6 @@ OCP\Util::addScript('','oc-vcategories'); OCP\App::setActiveNavigationEntry('tasks_index'); $categories = OC_Calendar_App::getCategoryOptions(); -$l10n = new OC_L10N('tasks'); $priority_options = OC_Task_App::getPriorityOptions(); $output = new OCP\Template('tasks', 'tasks', 'user'); $output->assign('priority_options', $priority_options); diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 5cd7e0241bf..b900a67ec31 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -366,19 +366,24 @@ class OC_LDAP { $table = self::getMapTable($isUser); $dn = self::sanitizeDN($dn); - $sqliteAdjustment = ''; + $sqlAdjustment = ''; $dbtype = OCP\Config::getSystemValue('dbtype'); - if(($dbtype == 'sqlite') || ($dbtype == 'sqlite3')) { - $sqliteAdjustment = 'OR'; + if($dbtype == 'mysql') { + $sqlAdjustment = 'FROM dual'; } $insert = OCP\DB::prepare(' - INSERT '.$sqliteAdjustment.' IGNORE INTO '.$table.' - (ldap_dn, owncloud_name) - VALUES (?,?) + INSERT INTO '.$table.' (ldap_dn, owncloud_name) + SELECT ?,? + '.$sqlAdjustment.' + WHERE NOT EXISTS ( + SELECT 1 + FROM '.$table.' + WHERE ldap_dn = ? + AND owncloud_name = ? ) '); - $res = $insert->execute(array($dn, $ocname)); + $res = $insert->execute(array($dn, $ocname, $dn, $ocname)); return !OCP\DB::isError($res); } diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 137daa485a9..5aaab642856 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -1624,7 +1624,7 @@ if (! array_key_exists('idp_url', $profile)) //Determine the requested URL - DO NOT OVERRIDE $profile['req_url'] = sprintf("%s://%s%s", $proto, - $_SERVER['HTTP_HOST'], + OCP\Util::getServerHost(), // $port,//host already includes the path $_SERVER["REQUEST_URI"]); diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index 8deb42f68c8..3267db3fa0f 100644 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -39,9 +39,9 @@ class OC_USER_OPENID extends OC_User_Backend { // Get identity from user and redirect browser to OpenID Server $openid = new SimpleOpenID; $openid->SetIdentity($uid); - $openid->SetTrustRoot('http://' . $_SERVER["HTTP_HOST"]); + $openid->SetTrustRoot('http://' . OCP\Util::getServerHost()); if ($openid->GetOpenIDServer()){ - $openid->SetApprovedURL('http://' . $_SERVER["HTTP_HOST"] . OC::$WEBROOT); // Send Response from OpenID server to this script + $openid->SetApprovedURL('http://' . OCP\Util::getServerHost() . OC::$WEBROOT); // Send Response from OpenID server to this script $openid->Redirect(); // This will redirect user to OpenID Server exit; }else{ diff --git a/apps/user_webfinger/appinfo/app.php b/apps/user_webfinger/appinfo/app.php index a45efd96a46..3336af66820 100644 --- a/apps/user_webfinger/appinfo/app.php +++ b/apps/user_webfinger/appinfo/app.php @@ -1,7 +1,3 @@ <?php -OCP\App::register( array( - 'order' => 11, - 'id' => 'user_webfinger', - 'name' => 'Webfinger' )); OCP\CONFIG::setAppValue('core', 'public_host-meta', '/apps/user_webfinger/host-meta.php'); OCP\CONFIG::setAppValue('core', 'public_webfinger', '/apps/user_webfinger/webfinger.php'); diff --git a/config/config.sample.php b/config/config.sample.php index e46c3cacd7e..e86dc05cb01 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -22,7 +22,7 @@ $CONFIG = array( "appstoreurl" => "", "mail_smtpmode" => "sendmail", "mail_smtphost" => "127.0.0.1", -"mail_smtpauth" => "false", +"mail_smtpauth" => false, "mail_smtpname" => "", "mail_smtppassword" => "", "appcodechecker" => "", diff --git a/core/lostpassword/index.php b/core/lostpassword/index.php index 6a4748588fc..f1d90eaeffe 100644 --- a/core/lostpassword/index.php +++ b/core/lostpassword/index.php @@ -22,7 +22,7 @@ if (isset($_POST['user'])) { $tmpl->assign('link', $link); $msg = $tmpl->fetchPage(); $l = OC_L10N::get('core'); - $from = 'lostpassword-noreply@' . $_SERVER['HTTP_HOST']; + $from = 'lostpassword-noreply@' . OCP\Util::getServerHost(); $r=mail($email, $l->t('Owncloud password reset'), $msg, 'From:' . $from); OC_MAIL::send($email,$_POST['user'],$l->t('ownCloud password reset'),$msg,$from,'ownCloud'); echo('sent'); diff --git a/lib/app.php b/lib/app.php index 78de0fa21b6..124b76cdc3d 100755 --- a/lib/app.php +++ b/lib/app.php @@ -28,7 +28,6 @@ */ class OC_App{ static private $init = false; - static private $apps = array(); static private $activeapp = ''; static private $navigation = array(); static private $settingsForms = array(); @@ -54,14 +53,7 @@ class OC_App{ return true; } - // Our very own core apps are hardcoded - foreach( array( 'settings') as $app ){ - if(is_null($types)){ - require( $app.'/appinfo/app.php' ); - } - } - - // The rest comes here + // Load the enabled apps here $apps = self::getEnabledApps(); // prevent app.php from printing output ob_start(); @@ -217,36 +209,6 @@ class OC_App{ } /** - * @brief makes owncloud aware of this app - * @param $data array with all information - * @returns true/false - * - * This function registers the application. $data is an associative array. - * The following keys are required: - * - id: id of the application, has to be unique ('addressbook') - * - name: Human readable name ('Addressbook') - * - version: array with Version (major, minor, bugfix) ( array(1, 0, 2)) - * - * The following keys are optional: - * - order: integer, that influences the position of your application in - * a list of applications. Lower values come first. - * - */ - public static function register( $data ){ - OC_App::$apps[] = $data; - } - - /** - * @brief returns information of all apps - * @return array with all information - * - * This function returns all data it got via register(). - */ - public static function get(){ - return OC_App::$apps; - } - - /** * @brief adds an entry to the navigation * @param $data array containing the data * @returns true/false diff --git a/lib/base.php b/lib/base.php index fdb682bf503..cb98a6c9e0b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -214,8 +214,8 @@ class OC{ // redirect to https site if configured if( OC_Config::getValue( "forcessl", false )){ ini_set("session.cookie_secure", "on"); - if(!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') { - $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; + if(OC_Helper::serverProtocol()<>'https') { + $url = "https://". OC_Helper::serverHost() . $_SERVER['REQUEST_URI']; header("Location: $url"); exit(); } @@ -376,11 +376,11 @@ class OC{ // CSRF protection if(isset($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer=''; - if(isset($_SERVER['HTTPS']) and $_SERVER['HTTPS']<>'') $protocol='https://'; else $protocol='http://'; + $protocol=OC_Helper::serverProtocol().'://'; if(!self::$CLI){ - $server=$protocol.$_SERVER['SERVER_NAME']; + $server=$protocol.OC_Helper::serverHost(); if(($_SERVER['REQUEST_METHOD']=='POST') and (substr($referer,0,strlen($server))<>$server)) { - $url = $protocol.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php'; + $url = $protocol.OC_Helper::serverProtocol().OC::$WEBROOT.'/index.php'; header("Location: $url"); exit(); } diff --git a/lib/files.php b/lib/files.php index 072de33004f..79d214665de 100644 --- a/lib/files.php +++ b/lib/files.php @@ -32,11 +32,11 @@ class OC_Files { * get the content of a directory * @param dir $directory */ - public static function getDirectoryContent($directory, $mimetype_filter = ''){ + public static function getDirectoryContent($directory, $mimetype_filter = ''){ if(strpos($directory,OC::$CONFIG_DATADIRECTORY)===0){ $directory=substr($directory,strlen(OC::$CONFIG_DATADIRECTORY)); } - $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); + $files=OC_FileCache::getFolderContent($directory, '', $mimetype_filter); foreach($files as &$file){ $file['directory']=$directory; $file['type']=($file['mimetype']=='httpd/unix-directory')?'dir':'file'; diff --git a/lib/filestorage.php b/lib/filestorage.php index d05acd3674d..1d7e004af3b 100644 --- a/lib/filestorage.php +++ b/lib/filestorage.php @@ -21,7 +21,7 @@ */ /** - * Privde a common interface to all different storage options + * Provde a common interface to all different storage options */ abstract class OC_Filestorage{ public function __construct($parameters){} diff --git a/lib/filesystemview.php b/lib/filesystemview.php index d893bd4d3df..c8df59cf827 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -1,25 +1,42 @@ <?php /** -* ownCloud -* -* @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/>. -* -*/ + * ownCloud + * + * @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/>. + */ + + +/** + * Class to provide access to ownCloud filesystem via a "view", and methods for + * working with files within that view (e.g. read, write, delete, etc.). Each + * view is restricted to a set of directories via a virtual root. The default view + * uses the currently logged in user's data directory as root (parts of + * OC_Filesystem are merely a wrapper for OC_FilesystemView). + * + * Apps that need to access files outside of the user data folders (to modify files + * belonging to a user other than the one currently logged in, for example) should + * use this class directly rather than using OC_Filesystem, or making use of PHP's + * built-in file manipulation functions. This will ensure all hooks and proxies + * are triggered correctly. + * + * Filesystem functions are not called directly; they are passed to the correct + * OC_Filestorage object + */ class OC_FilesystemView { private $fakeRoot=''; @@ -103,7 +120,9 @@ class OC_FilesystemView { } /** - * following functions are equivilent to their php buildin equivilents for arguments/return values. + * the following functions operate with arguments and return values identical + * to those of their PHP built-in equivalents. Mostly they are merely wrappers + * for OC_Filestorage via basicOperation(). */ public function mkdir($path){ return $this->basicOperation('mkdir',$path,array('create','write')); @@ -336,16 +355,20 @@ class OC_FilesystemView { } /** - * abstraction for running most basic operations + * @brief abstraction layer for basic filesystem functions: wrapper for OC_Filestorage * @param string $operation * @param string #path * @param array (optional) hooks * @param mixed (optional) $extraParam * @return mixed + * + * This method takes requests for basic filesystem functions (e.g. reading & writing + * files), processes hooks and proxies, sanitises paths, and finally passes them on to + * OC_Filestorage for delegation to a storage backend for execution */ private function basicOperation($operation,$path,$hooks=array(),$extraParam=null){ if(OC_FileProxy::runPreProxies($operation,$path, $extraParam) and OC_Filesystem::isValidPath($path)){ - $interalPath=$this->getInternalPath($path); + $internalPath=$this->getInternalPath($path); $run=true; if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){ foreach($hooks as $hook){ @@ -358,9 +381,9 @@ class OC_FilesystemView { } if($run and $storage=$this->getStorage($path)){ if(!is_null($extraParam)){ - $result=$storage->$operation($interalPath,$extraParam); + $result=$storage->$operation($internalPath,$extraParam); }else{ - $result=$storage->$operation($interalPath); + $result=$storage->$operation($internalPath); } $result=OC_FileProxy::runPostProxies($operation,$path,$result); if(OC_Filesystem::$loaded and $this->fakeRoot==OC_Filesystem::getRoot()){ diff --git a/lib/helper.php b/lib/helper.php index 537465b15ac..f8f84b91ae3 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -89,6 +89,27 @@ class OC_Helper { return $host; } + + /** + * @brief Returns the server protocol + * @returns the server protocol + * + * Returns the server protocol. It respects reverse proxy servers and load balancers + */ + public static function serverProtocol() { + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { + $proto = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']); + }else{ + if(isset($_SERVER['HTTPS']) and !empty($_SERVER['HTTPS']) and ($_SERVER['HTTPS']!='off')) { + $proto = 'https'; + }else{ + $proto = 'http'; + } + } + return($proto); + } + + /** * @brief Creates an absolute url * @param $app app @@ -99,9 +120,7 @@ class OC_Helper { */ public static function linkToAbsolute( $app, $file ) { $urlLinkTo = self::linkTo( $app, $file ); - // Checking if the request was made through HTTPS. The last in line is for IIS - $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS']!='off'); - $urlLinkTo = ($protocol?'https':'http') . '://' . self::serverHost() . $urlLinkTo; + $urlLinkTo = OC_Helper::serverProtocol(). '://' . self::serverHost() . $urlLinkTo; return $urlLinkTo; } diff --git a/lib/mail.php b/lib/mail.php index 0045f8de6da..b46f73bd94b 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -31,7 +31,7 @@ class OC_Mail { $SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' ); $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' ); - $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', 'false' ); + $SMTPAUTH = OC_Config::getValue( 'mail_smtpauth', false ); $SMTPUSERNAME = OC_Config::getValue( 'mail_smtpname', '' ); $SMTPPASSWORD = OC_Config::getValue( 'mail_smtppassword', '' ); diff --git a/lib/ocs.php b/lib/ocs.php index e28eb61987c..1be41202d78 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -357,11 +357,11 @@ class OC_OCS { */ private static function apiConfig($format) { $user=OC_OCS::checkpassword(false); - $url=substr($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'],0,-11).''; + $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'],0,-11).''; $xml['version']='1.5'; $xml['website']='ownCloud'; - $xml['host']=$_SERVER['HTTP_HOST']; + $xml['host']=OCP\Util::getServerHost(); $xml['contact']=''; $xml['ssl']='false'; echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'config','',1)); diff --git a/lib/public/app.php b/lib/public/app.php index 3960db6d897..1f84087f076 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -52,7 +52,6 @@ class App { * */ public static function register( $data ){ - return \OC_App::register( $data ); } diff --git a/lib/public/util.php b/lib/public/util.php index 39a185d02a7..9b499574da1 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -169,6 +169,16 @@ class Util { } /** + * @brief Returns the server protocol + * @returns the server protocol + * + * Returns the server protocol. It respects reverse proxy servers and load balancers + */ + public static function getServerProtocol() { + return(\OC_Helper::serverProtocol()); + } + + /** * @brief Creates path to an image * @param $app app * @param $image image name diff --git a/ocs/providers.php b/ocs/providers.php index 397d2f06f5d..adaa28db6cd 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -23,7 +23,7 @@ require_once('../lib/base.php'); -$url='http://'.substr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],0,-17).'ocs/v1.php/'; +$url='http://'.substr(OCP\Util::getServerHost().$_SERVER['REQUEST_URI'],0,-17).'ocs/v1.php/'; echo(' <providers> diff --git a/search/appinfo/app.php b/search/appinfo/app.php deleted file mode 100644 index b91341643f2..00000000000 --- a/search/appinfo/app.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - -OC_App::register( array( 'order' => 2, "id" => 'search', 'name' => 'Search' )); - -?> diff --git a/settings/appinfo/app.php b/settings/appinfo/app.php deleted file mode 100644 index d18bcdbff0d..00000000000 --- a/settings/appinfo/app.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -OC_App::register( array( "id" => "settings", "name" => "Settings" )); -OC_App::register( array( "order" => 1, "id" => "admin", "name" => "Administration" )); -OC_App::register( array( "order" => 1, "id" => "help", "name" => "Help" )); - -?> |