Merge branch 'master' into calendar_repeat

This commit is contained in:
Georg Ehrke 2012-06-01 11:40:39 +02:00
commit e75146a811
42 changed files with 164 additions and 206 deletions

View File

@ -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');

View File

@ -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')));

View File

@ -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);

View File

@ -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,

View File

@ -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>';

View File

@ -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>';

View File

@ -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,

View File

@ -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(

View File

@ -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'];
?>

View File

@ -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") ));

View File

@ -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'));

View File

@ -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');

View File

@ -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);

View File

@ -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');
}

View File

@ -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

View File

@ -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);
?>

View File

@ -2,12 +2,6 @@
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');

View File

@ -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);
}
}
}

View File

@ -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,

View File

@ -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');

View File

@ -1,6 +1,2 @@
<?php
OCP\App::register( array(
'order' => 10,
'id' => 'remoteStorage',
'name' => 'remoteStorage compatibility' ));
OCP\App::registerPersonal('remoteStorage','settings');

View File

@ -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,

View File

@ -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);

View File

@ -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);
}

View File

@ -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"]);

View File

@ -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{

View File

@ -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');

View File

@ -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" => "",

View File

@ -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');

View File

@ -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();
@ -216,36 +208,6 @@ class OC_App{
OC_Appconfig::setValue( $app, 'enabled', 'no' );
}
/**
* @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

View File

@ -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();
}

View File

@ -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';

View File

@ -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){}

View File

@ -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()){

View File

@ -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;
}

View File

@ -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', '' );

View File

@ -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));

View File

@ -52,7 +52,6 @@ class App {
*
*/
public static function register( $data ){
return \OC_App::register( $data );
}

View File

@ -168,6 +168,16 @@ class Util {
return(\OC_Helper::serverHost());
}
/**
* @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

View File

@ -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>

View File

@ -1,5 +0,0 @@
<?php
OC_App::register( array( 'order' => 2, "id" => 'search', 'name' => 'Search' ));
?>

View File

@ -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" ));
?>