streams/Zotlabs/Module/Home.php

117 lines
2.8 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module;
2018-06-01 02:42:13 +00:00
use Zotlabs\Lib\Libzot;
2018-06-20 02:33:50 +00:00
use Zotlabs\Web\HTTPSig;
2016-04-19 03:38:38 +00:00
2018-06-01 04:05:09 +00:00
require_once('include/conversation.php');
2016-04-19 03:38:38 +00:00
class Home extends \Zotlabs\Web\Controller {
function init() {
2016-04-19 03:38:38 +00:00
$ret = array();
call_hooks('home_init',$ret);
2018-04-23 04:30:14 +00:00
2018-06-01 02:42:13 +00:00
if(Libzot::is_zot_request()) {
2018-04-23 04:30:14 +00:00
2018-06-20 02:33:50 +00:00
$key = get_config('system','prvkey');
$ret = json_encode(Libzot::site_info());
2018-04-23 04:30:14 +00:00
2018-06-20 02:33:50 +00:00
$headers = [ 'Content-Type' => 'application/x-zot+json', 'Digest' => HTTPSig::generate_digest_header($ret) ];
2018-06-20 05:09:49 +00:00
$h = HTTPSig::create_sig($headers, $key, z_root());
2018-06-20 02:33:50 +00:00
HTTPSig::set_headers($h);
2018-04-23 04:30:14 +00:00
echo $ret;
killme();
}
2016-04-19 03:38:38 +00:00
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
$channel = \App::get_channel();
if(local_channel() && $channel && $channel['xchan_url'] && ! $splash) {
$dest = $channel['channel_startpage'];
if(! $dest)
$dest = get_pconfig(local_channel(),'system','startpage');
if(! $dest)
$dest = get_config('system','startpage');
if(! $dest)
$dest = z_root() . '/network';
goaway($dest);
}
if(remote_channel() && (! $splash) && $_SESSION['atoken']) {
$r = q("select * from atoken where atoken_id = %d",
intval($_SESSION['atoken'])
);
if($r) {
$x = channelx_by_n($r[0]['atoken_uid']);
if($x) {
goaway(z_root() . '/channel/' . $x['channel_address']);
}
}
}
2016-04-19 03:38:38 +00:00
if(get_account_id() && ! $splash) {
goaway(z_root() . '/new_channel');
}
}
function get($update = 0, $load = false) {
$o = '';
if(x($_SESSION,'theme'))
unset($_SESSION['theme']);
if(x($_SESSION,'mobile_theme'))
unset($_SESSION['mobile_theme']);
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
call_hooks('home_content',$o);
if($o)
return $o;
$frontpage = get_config('system','frontpage');
if($frontpage) {
if(strpos($frontpage,'include:') !== false) {
$file = trim(str_replace('include:' , '', $frontpage));
if(file_exists($file)) {
\App::$page['template'] = 'full';
\App::$page['title'] = t('$Projectname');
$o .= file_get_contents($file);
return $o;
}
}
if(strpos($frontpage,'http') !== 0)
$frontpage = z_root() . '/' . $frontpage;
if(intval(get_config('system','mirror_frontpage'))) {
$o = '<html><head><title>' . t('$Projectname') . '</title></head><body style="margin: 0; padding: 0; border: none;" ><iframe src="' . $frontpage . '" width="100%" height="100%" style="margin: 0; padding: 0; border: none;" ></iframe></body></html>';
echo $o;
killme();
}
goaway($frontpage);
}
$sitename = get_config('system','sitename');
if($sitename)
$o .= '<h1 class="home-welcome">' . sprintf( t('Welcome to %s') ,$sitename) . '</h1>';
2016-04-19 03:38:38 +00:00
$loginbox = get_config('system','login_on_homepage');
if(intval($loginbox) || $loginbox === false)
$o .= login(true);
2016-04-19 03:38:38 +00:00
return $o;
}
}