Merge branch 'master' of https://github.com/redmatrix/hubzilla
This commit is contained in:
commit
fbc6c60805
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace RedMatrix\RedDAV;
|
||||
namespace Zotlabs\Storage;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
/**
|
||||
* @brief Authentication backend class for RedDAV.
|
||||
* @brief Authentication backend class for DAV.
|
||||
*
|
||||
* This class also contains some data which is not necessary for authentication
|
||||
* like timezone settings.
|
||||
@ -15,7 +15,7 @@ use Sabre\DAV;
|
||||
* @link http://github.com/friendica/red
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
*/
|
||||
class RedBasicAuth extends DAV\Auth\Backend\AbstractBasic {
|
||||
class BasicAuth extends DAV\Auth\Backend\AbstractBasic {
|
||||
|
||||
/**
|
||||
* @brief This variable holds the currently logged-in channel_address.
|
||||
@ -45,18 +45,18 @@ class RedBasicAuth extends DAV\Auth\Backend\AbstractBasic {
|
||||
public $observer = '';
|
||||
/**
|
||||
*
|
||||
* @see RedBrowser::set_writeable()
|
||||
* @see Browser::set_writeable()
|
||||
* @var \Sabre\DAV\Browser\Plugin
|
||||
*/
|
||||
public $browser;
|
||||
/**
|
||||
* channel_id of the current visited path. Set in RedDirectory::getDir().
|
||||
* channel_id of the current visited path. Set in Directory::getDir().
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $owner_id = 0;
|
||||
/**
|
||||
* channel_name of the current visited path. Set in RedDirectory::getDir().
|
||||
* channel_name of the current visited path. Set in Directory::getDir().
|
||||
*
|
||||
* Used for creating the path in cloud/
|
||||
*
|
||||
@ -197,7 +197,7 @@ class RedBasicAuth extends DAV\Auth\Backend\AbstractBasic {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Prints out all RedBasicAuth variables to logger().
|
||||
* @brief Prints out all BasicAuth variables to logger().
|
||||
*
|
||||
* @return void
|
||||
*/
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RedMatrix\RedDAV;
|
||||
namespace Zotlabs\Storage;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
@ -15,7 +15,7 @@ use Sabre\DAV;
|
||||
* @link http://github.com/friendica/red
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
*/
|
||||
class RedBrowser extends DAV\Browser\Plugin {
|
||||
class Browser extends DAV\Browser\Plugin {
|
||||
|
||||
/**
|
||||
* @see set_writeable()
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RedMatrix\RedDAV;
|
||||
namespace Zotlabs\Storage;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
@ -16,7 +16,7 @@ use Sabre\DAV;
|
||||
* @link http://github.com/friendica/red
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
*/
|
||||
class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
||||
class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
||||
|
||||
/**
|
||||
* @brief The path inside /cloud
|
||||
@ -116,7 +116,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
|
||||
|
||||
$modulename = get_app()->module;
|
||||
if ($this->red_path === '/' && $name === $modulename) {
|
||||
return new RedDirectory('/' . $modulename, $this->auth);
|
||||
return new Directory('/' . $modulename, $this->auth);
|
||||
}
|
||||
|
||||
$x = RedFileData($this->ext_path . '/' . $name, $this->auth);
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace RedMatrix\RedDAV;
|
||||
namespace Zotlabs\Storage;
|
||||
|
||||
use Sabre\DAV;
|
||||
|
||||
@ -15,7 +15,7 @@ use Sabre\DAV;
|
||||
* @link http://github.com/friendica/red
|
||||
* @license http://opensource.org/licenses/mit-license.php The MIT License (MIT)
|
||||
*/
|
||||
class RedFile extends DAV\Node implements DAV\IFile {
|
||||
class File extends DAV\Node implements DAV\IFile {
|
||||
|
||||
/**
|
||||
* The file from attach table.
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace Zotlabs\Zot;
|
||||
|
||||
require_once('Zotlabs/Zot/IHandler.php');
|
||||
|
||||
|
||||
class ZotHandler implements IHandler {
|
||||
|
||||
function Ping() {
|
||||
|
@ -294,8 +294,8 @@ function z_post_url_json($url, $params, $redirects = 0, $opts = array()) {
|
||||
}
|
||||
|
||||
|
||||
function json_return_and_die($x) {
|
||||
header("content-type: application/json");
|
||||
function json_return_and_die($x, $content_type = 'application/json') {
|
||||
header("Content-type: $content_type");
|
||||
echo json_encode($x);
|
||||
killme();
|
||||
}
|
||||
|
@ -19,13 +19,13 @@
|
||||
*/
|
||||
|
||||
use Sabre\DAV;
|
||||
use RedMatrix\RedDAV;
|
||||
use Zotlabs\Storage;
|
||||
|
||||
require_once('vendor/autoload.php');
|
||||
require_once('include/attach.php');
|
||||
require_once('include/RedDAV/RedFile.php');
|
||||
require_once('include/RedDAV/RedDirectory.php');
|
||||
require_once('include/RedDAV/RedBasicAuth.php');
|
||||
//require_once('Zotlabs/Storage/File.php');
|
||||
//require_once('Zotlabs/Storage/Directory.php');
|
||||
//require_once('Zotlabs/Storage/BasicAuth.php');
|
||||
|
||||
/**
|
||||
* @brief Returns an array with viewable channels.
|
||||
@ -51,7 +51,7 @@ function RedChannelList(&$auth) {
|
||||
if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage')) {
|
||||
logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
|
||||
// @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory
|
||||
$ret[] = new RedDAV\RedDirectory('/cloud/' . $rr['channel_address'], $auth);
|
||||
$ret[] = new Zotlabs\Storage\Directory('/cloud/' . $rr['channel_address'], $auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,9 +167,9 @@ function RedCollectionData($file, &$auth) {
|
||||
foreach ($r as $rr) {
|
||||
//logger('filename: ' . $rr['filename'], LOGGER_DEBUG);
|
||||
if (intval($rr['is_dir'])) {
|
||||
$ret[] = new RedDAV\RedDirectory($path . '/' . $rr['filename'], $auth);
|
||||
$ret[] = new Zotlabs\Storage\Directory($path . '/' . $rr['filename'], $auth);
|
||||
} else {
|
||||
$ret[] = new RedDAV\RedFile($path . '/' . $rr['filename'], $rr, $auth);
|
||||
$ret[] = new Zotlabs\Storage\File($path . '/' . $rr['filename'], $rr, $auth);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ function RedFileData($file, &$auth, $test = false) {
|
||||
|
||||
|
||||
if ((! $file) || ($file === '/')) {
|
||||
return new RedDAV\RedDirectory('/', $auth);
|
||||
return new Zotlabs\Storage\Directory('/', $auth);
|
||||
}
|
||||
|
||||
$file = trim($file, '/');
|
||||
@ -274,7 +274,7 @@ function RedFileData($file, &$auth, $test = false) {
|
||||
if ($test)
|
||||
return true;
|
||||
// final component was a directory.
|
||||
return new RedDAV\RedDirectory($file, $auth);
|
||||
return new Zotlabs\Storage\Directory($file, $auth);
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
@ -293,9 +293,9 @@ function RedFileData($file, &$auth, $test = false) {
|
||||
return true;
|
||||
|
||||
if (intval($r[0]['is_dir'])) {
|
||||
return new RedDAV\RedDirectory($path . '/' . $r[0]['filename'], $auth);
|
||||
return new Zotlabs\Storage\Directory($path . '/' . $r[0]['filename'], $auth);
|
||||
} else {
|
||||
return new RedDAV\RedFile($path . '/' . $r[0]['filename'], $r[0], $auth);
|
||||
return new Zotlabs\Storage\File($path . '/' . $r[0]['filename'], $r[0], $auth);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
use Sabre\DAV;
|
||||
use RedMatrix\RedDAV;
|
||||
use Zotlabs\Storage;
|
||||
|
||||
// composer autoloader for SabreDAV
|
||||
require_once('vendor/autoload.php');
|
||||
@ -35,7 +35,7 @@ function cloud_init(&$a) {
|
||||
if ($which)
|
||||
profile_load($a, $which, $profile);
|
||||
|
||||
$auth = new RedDAV\RedBasicAuth();
|
||||
$auth = new Zotlabs\Storage\BasicAuth();
|
||||
|
||||
$ob_hash = get_observer_hash();
|
||||
|
||||
@ -63,7 +63,7 @@ function cloud_init(&$a) {
|
||||
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
|
||||
$_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$rootDirectory = new RedDAV\RedDirectory('/', $auth);
|
||||
$rootDirectory = new Zotlabs\Storage\Directory('/', $auth);
|
||||
|
||||
// A SabreDAV server-object
|
||||
$server = new DAV\Server($rootDirectory);
|
||||
@ -86,16 +86,16 @@ function cloud_init(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
require_once('include/RedDAV/RedBrowser.php');
|
||||
// require_once('Zotlabs/Storage/Browser.php');
|
||||
// provide a directory view for the cloud in Hubzilla
|
||||
$browser = new RedDAV\RedBrowser($auth);
|
||||
$browser = new Zotlabs\Storage\Browser($auth);
|
||||
$auth->setBrowserPlugin($browser);
|
||||
|
||||
$server->addPlugin($browser);
|
||||
|
||||
// Experimental QuotaPlugin
|
||||
// require_once('include/RedDAV/QuotaPlugin.php');
|
||||
// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
|
||||
// require_once('Zotlabs\Storage/QuotaPlugin.php');
|
||||
// $server->addPlugin(new Zotlabs\Storage\\QuotaPlugin($auth));
|
||||
|
||||
// All we need to do now, is to fire up the server
|
||||
$server->exec();
|
||||
|
16
mod/dav.php
16
mod/dav.php
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
use Sabre\DAV;
|
||||
use RedMatrix\RedDAV;
|
||||
use Zotlabs\Storage;
|
||||
|
||||
// composer autoloader for SabreDAV
|
||||
require_once('vendor/autoload.php');
|
||||
@ -54,7 +54,7 @@ function dav_init(&$a) {
|
||||
if ($which)
|
||||
profile_load($a, $which, $profile);
|
||||
|
||||
$auth = new RedDAV\RedBasicAuth();
|
||||
$auth = new Zotlabs\Storage\BasicAuth();
|
||||
|
||||
$ob_hash = get_observer_hash();
|
||||
|
||||
@ -82,7 +82,7 @@ function dav_init(&$a) {
|
||||
$_SERVER['REQUEST_URI'] = strip_zids($_SERVER['REQUEST_URI']);
|
||||
$_SERVER['REQUEST_URI'] = preg_replace('/[\?&]davguest=(.*?)([\?&]|$)/ism', '', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$rootDirectory = new RedDAV\RedDirectory('/', $auth);
|
||||
$rootDirectory = new Zotlabs\Storage\Directory('/', $auth);
|
||||
|
||||
// A SabreDAV server-object
|
||||
$server = new DAV\Server($rootDirectory);
|
||||
@ -108,7 +108,7 @@ function dav_init(&$a) {
|
||||
if ((! $auth->observer) && ($_SERVER['REQUEST_METHOD'] === 'GET')) {
|
||||
try {
|
||||
$x = RedFileData('/' . $a->cmd, $auth);
|
||||
if($x instanceof RedDAV\RedFile)
|
||||
if($x instanceof Zotlabs\Storage\File)
|
||||
$isapublic_file = true;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
@ -126,14 +126,14 @@ function dav_init(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
require_once('include/RedDAV/RedBrowser.php');
|
||||
// require_once('Zotlabs/Storage/Browser.php');
|
||||
// provide a directory view for the cloud in Hubzilla
|
||||
$browser = new RedDAV\RedBrowser($auth);
|
||||
$browser = new Zotlabs\Storage\Browser($auth);
|
||||
$auth->setBrowserPlugin($browser);
|
||||
|
||||
// Experimental QuotaPlugin
|
||||
// require_once('include/RedDAV/QuotaPlugin.php');
|
||||
// $server->addPlugin(new RedDAV\QuotaPlugin($auth));
|
||||
// require_once('Zotlabs/Storage/QuotaPlugin.php');
|
||||
// $server->addPlugin(new Zotlabs\Storage\QuotaPlugin($auth));
|
||||
|
||||
// All we need to do now, is to fire up the server
|
||||
$server->exec();
|
||||
|
@ -12,7 +12,6 @@ require_once('include/zot.php');
|
||||
function post_init(&$a) {
|
||||
|
||||
if (array_key_exists('auth', $_REQUEST)) {
|
||||
require_once('Zotlabs/Zot/Auth.php');
|
||||
$x = new Zotlabs\Zot\Auth($_REQUEST);
|
||||
exit;
|
||||
}
|
||||
@ -22,9 +21,6 @@ function post_init(&$a) {
|
||||
|
||||
function post_post(&$a) {
|
||||
|
||||
require_once('Zotlabs/Zot/Receiver.php');
|
||||
require_once('Zotlabs/Zot/ZotHandler.php');
|
||||
|
||||
$z = new Zotlabs\Zot\Receiver($_REQUEST['data'],get_config('system','prvkey'), new Zotlabs\Zot\ZotHandler());
|
||||
|
||||
// notreached;
|
||||
|
@ -225,10 +225,44 @@ function settings_post(&$a) {
|
||||
|
||||
$errs = array();
|
||||
|
||||
$email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : '');
|
||||
$account = $a->get_account();
|
||||
if($email != $account['account_email']) {
|
||||
if(! valid_email($email))
|
||||
$errs[] = t('Not valid email.');
|
||||
$adm = trim(get_config('system','admin_email'));
|
||||
if(($adm) && (strcasecmp($email,$adm) == 0)) {
|
||||
$errs[] = t('Protected email address. Cannot change to that email.');
|
||||
$email = $a->user['email'];
|
||||
}
|
||||
if(! $errs) {
|
||||
$r = q("update account set account_email = '%s' where account_id = %d",
|
||||
dbesc($email),
|
||||
intval($account['account_id'])
|
||||
);
|
||||
if(! $r)
|
||||
$errs[] = t('System failure storing new email. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
if($errs) {
|
||||
foreach($errs as $err)
|
||||
notice($err . EOL);
|
||||
$errs = array();
|
||||
}
|
||||
|
||||
|
||||
if((x($_POST,'npassword')) || (x($_POST,'confirm'))) {
|
||||
|
||||
$newpass = $_POST['npassword'];
|
||||
$confirm = $_POST['confirm'];
|
||||
$origpass = trim($_POST['origpass']);
|
||||
|
||||
require_once('include/auth.php');
|
||||
if(! account_verify_password($email,$origpass)) {
|
||||
$errs[] = t('Password verification failed.');
|
||||
}
|
||||
|
||||
$newpass = trim($_POST['npassword']);
|
||||
$confirm = trim($_POST['confirm']);
|
||||
|
||||
if($newpass != $confirm ) {
|
||||
$errs[] = t('Passwords do not match. Password unchanged.');
|
||||
@ -255,31 +289,6 @@ function settings_post(&$a) {
|
||||
}
|
||||
}
|
||||
|
||||
if($errs) {
|
||||
foreach($errs as $err)
|
||||
notice($err . EOL);
|
||||
$errs = array();
|
||||
}
|
||||
|
||||
$email = ((x($_POST,'email')) ? trim(notags($_POST['email'])) : '');
|
||||
$account = $a->get_account();
|
||||
if($email != $account['account_email']) {
|
||||
if(! valid_email($email))
|
||||
$errs[] = t('Not valid email.');
|
||||
$adm = trim(get_config('system','admin_email'));
|
||||
if(($adm) && (strcasecmp($email,$adm) == 0)) {
|
||||
$errs[] = t('Protected email address. Cannot change to that email.');
|
||||
$email = $a->user['email'];
|
||||
}
|
||||
if(! $errs) {
|
||||
$r = q("update account set account_email = '%s' where account_id = %d",
|
||||
dbesc($email),
|
||||
intval($account['account_id'])
|
||||
);
|
||||
if(! $r)
|
||||
$errs[] = t('System failure storing new email. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
if($errs) {
|
||||
foreach($errs as $err)
|
||||
@ -695,8 +704,9 @@ function settings_content(&$a) {
|
||||
$o .= replace_macros($tpl, array(
|
||||
'$form_security_token' => get_form_security_token("settings_account"),
|
||||
'$title' => t('Account Settings'),
|
||||
'$password1'=> array('npassword', t('Enter New Password:'), '', ''),
|
||||
'$password2'=> array('confirm', t('Confirm New Password:'), '', t('Leave password fields blank unless changing')),
|
||||
'$origpass' => array('origpass', t('Current Password'), ' ',''),
|
||||
'$password1'=> array('npassword', t('Enter New Password'), '', ''),
|
||||
'$password2'=> array('confirm', t('Confirm New Password'), '', t('Leave password fields blank unless changing')),
|
||||
'$submit' => t('Submit'),
|
||||
'$email' => array('email', t('Email Address:'), $email, ''),
|
||||
'$removeme' => t('Remove Account'),
|
||||
|
@ -51,8 +51,6 @@ function wfinger_init(&$a) {
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
header('Content-type: application/jrd+json');
|
||||
|
||||
|
||||
if($resource && $r) {
|
||||
|
||||
@ -124,7 +122,6 @@ function wfinger_init(&$a) {
|
||||
$arr = array('channel' => $r[0], 'request' => $_REQUEST, 'result' => $result);
|
||||
call_hooks('webfinger',$arr);
|
||||
|
||||
echo json_encode($arr['result']);
|
||||
killme();
|
||||
json_return_and_die($arr['result'],'application/jrd+json');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
|
||||
<div class="section-content-tools-wrapper">
|
||||
{{include file="field_input.tpl" field=$email}}
|
||||
{{include file="field_password.tpl" field=$origpass}}
|
||||
{{include file="field_password.tpl" field=$password1}}
|
||||
{{include file="field_password.tpl" field=$password2}}
|
||||
<div class="settings-submit-wrapper" >
|
||||
|
Reference in New Issue
Block a user