Browse Source

Delete Sessionx

Create Cookie and move RPC under the Movim namespace
Refactor
pull/356/head
Timothée Jaussoin 9 years ago
parent
commit
ab8580ff36
  1. 3
      app/controllers/AccountController.php
  2. 5
      app/controllers/DisconnectController.php
  3. 8
      app/widgets/Account/Account.php
  4. 13
      app/widgets/AccountNext/AccountNext.php
  5. 2
      app/widgets/Ack/Ack.php
  6. 10
      app/widgets/AdHoc/AdHoc.php
  7. 4
      app/widgets/AdminDB/AdminDB.php
  8. 3
      app/widgets/AdminLogin/AdminLogin.php
  9. 12
      app/widgets/AdminMain/AdminMain.php
  10. 3
      app/widgets/AdminTest/AdminTest.php
  11. 4
      app/widgets/Api/Api.php
  12. 6
      app/widgets/Avatar/Avatar.php
  13. 6
      app/widgets/Caps/Caps.php
  14. 50
      app/widgets/Chat/Chat.php
  15. 24
      app/widgets/Chats/Chats.php
  16. 2
      app/widgets/Chats/_chats_item.tpl
  17. 2
      app/widgets/Communities/Communities.php
  18. 6
      app/widgets/CommunitiesServer/CommunitiesServer.php
  19. 2
      app/widgets/CommunityHeader/CommunityHeader.php
  20. 14
      app/widgets/CommunityPosts/CommunityPosts.php
  21. 4
      app/widgets/Config/Config.php
  22. 20
      app/widgets/Contact/Contact.php
  23. 2
      app/widgets/Dialog/Dialog.php
  24. 2
      app/widgets/Drawer/Drawer.php
  25. 14
      app/widgets/Help/Help.php
  26. 32
      app/widgets/Infos/Infos.php
  27. 2
      app/widgets/Init/Init.php
  28. 2
      app/widgets/Invitations/Invitations.php
  29. 14
      app/widgets/Login/Login.php
  30. 9
      app/widgets/LoginAnonymous/LoginAnonymous.php
  31. 2
      app/widgets/Notification/Notification.php
  32. 22
      app/widgets/Post/Post.php
  33. 18
      app/widgets/Publish/Publish.php
  34. 8
      app/widgets/Rooms/Rooms.php
  35. 8
      app/widgets/Roster/Roster.php
  36. 4
      app/widgets/Search/Search.php
  37. 6
      app/widgets/Share/Share.php
  38. 2
      app/widgets/Statistics/Statistics.php
  39. 7
      app/widgets/System/System.php
  40. 1
      app/widgets/Tabs/Tabs.php
  41. 58
      app/widgets/Tabs/tabs.css
  42. 2
      app/widgets/Upload/Upload.php
  43. 4
      app/widgets/Vcard4/Vcard4.php
  44. 10
      app/widgets/Visio/Visio.php
  45. 2
      composer.json
  46. 12
      composer.lock
  47. 7
      linker.php
  48. 4
      src/Movim/Bootstrap.php
  49. 4
      src/Movim/Controller/Front.php
  50. 40
      src/Movim/Cookie.php
  51. 3
      src/Movim/RPC.php
  52. 3
      src/Movim/Widget/Base.php
  53. 54
      system/Sessionx.php

3
app/controllers/AccountController.php

@ -10,8 +10,7 @@ class AccountController extends Base
function dispatch()
{
$session = \Sessionx::start();
requestURL('http://localhost:1560/disconnect/', 2, ['sid' => $session->sessionid]);
requestURL('http://localhost:1560/disconnect/', 2, ['sid' => SESSION_ID]);
$this->page->setTitle(__('page.account_creation'));
}

5
app/controllers/DisconnectController.php

@ -1,5 +1,7 @@
<?php
use Movim\Controller\Base;
use Movim\Cookie;
class DisconnectController extends Base
{
@ -15,8 +17,7 @@ class DisconnectController extends Base
Session::dispose();
// Fresh cookie
$session = \Sessionx::start();
$session->renewCookie();
Cookie::renew();
$this->redirect('login');
}

8
app/widgets/Account/Account.php

@ -18,7 +18,7 @@ class Account extends \Movim\Widget\Base
function onPasswordChanged()
{
RPC::call('Account.resetPassword');
$this->rpc('Account.resetPassword');
Notification::append(null, $this->__('account.password_changed'));
}
@ -28,7 +28,7 @@ class Account extends \Movim\Widget\Base
$md->clearMessage();
$pd = new Modl\PostnDAO;
$pd->deleteNode($this->user->getLogin(), 'urn:xmpp:microblog:0');
RPC::call('Account.clearAccount');
$this->rpc('Account.clearAccount');
}
function onRegister($package)
@ -71,11 +71,11 @@ class Account extends \Movim\Widget\Base
->setPassword($p1)
->request();
} else {
RPC::call('Account.resetPassword');
$this->rpc('Account.resetPassword');
Notification::append(null, $this->__('account.password_not_same'));
}
} else {
RPC::call('Account.resetPassword');
$this->rpc('Account.resetPassword');
Notification::append(null, $this->__('account.password_not_valid'));
}
}

13
app/widgets/AccountNext/AccountNext.php

@ -43,7 +43,7 @@ class AccountNext extends \Movim\Widget\Base {
$html = $formview->draw('_accountnext_form', true);
break;
case 'jabber:x:oob' :
RPC::call('MovimUtils.redirect', (string)$form->x->url);
$this->rpc('MovimUtils.redirect', (string)$form->x->url);
break;
}
} else {
@ -56,7 +56,7 @@ class AccountNext extends \Movim\Widget\Base {
$html = $formview->draw('_accountnext_form', true);
}
RPC::call('MovimTpl.fill', '#subscription_form', $html);
$this->rpc('MovimTpl.fill', '#subscription_form', $html);
}
function onRegistered($packet)
@ -66,8 +66,8 @@ class AccountNext extends \Movim\Widget\Base {
$view = $this->tpl();
$html = $view->draw('_accountnext_registered', true);
RPC::call('MovimTpl.fill', '#subscribe', $html);
RPC::call('setUsername', $data->username->value);
$this->rpc('MovimTpl.fill', '#subscribe', $html);
$this->rpc('setUsername', $data->username->value);
}
function onError()
@ -95,10 +95,9 @@ class AccountNext extends \Movim\Widget\Base {
{
Notification::append(null, $this->__('error.service_unavailable'));
$session = \Sessionx::start();
requestURL('http://localhost:1560/disconnect/', 2, ['sid' => $session->sessionid]);
requestURL('http://localhost:1560/disconnect/', 2, ['sid' => SESSION_ID]);
RPC::call('MovimUtils.redirect', $this->route('account'));
$this->rpc('MovimUtils.redirect', $this->route('account'));
}
function ajaxGetForm($host)

2
app/widgets/Ack/Ack.php

@ -21,7 +21,7 @@ class Ack extends \Movim\Widget\Base {
function onAckRequest($ack) {
$to = $ack[0];
$id = $ack[1];
RPC::call('ackRequest', $to, $id);
$this->rpc('ackRequest', $to, $id);
}
function ajaxAckRequest($to, $id) {

10
app/widgets/AdHoc/AdHoc.php

@ -18,8 +18,8 @@ class AdHoc extends \Movim\Widget\Base
{
$list = $package->content;
$html = $this->prepareList($list);
RPC::call('MovimTpl.fill', '#adhoc_widget', $html);
RPC::call('AdHoc.refresh');
$this->rpc('MovimTpl.fill', '#adhoc_widget', $html);
$this->rpc('AdHoc.refresh');
}
function onCommand($package)
@ -48,7 +48,7 @@ class AdHoc extends \Movim\Widget\Base
Dialog::fill($view->draw('_adhoc_form', true), true);
}
RPC::call('AdHoc.initForm');
$this->rpc('AdHoc.initForm');
}
function prepareList($list)
@ -89,7 +89,7 @@ class AdHoc extends \Movim\Widget\Base
function getIcon($command)
{
$icons = array(
$icons = [
'http://jabber.org/protocol/admin#delete-user' => 'zmdi-delete',
'http://jabber.org/protocol/admin#end-user-session' => 'zmdi-stop',
'http://jabber.org/protocol/admin#change-user-password' => 'zmdi-lock',
@ -102,7 +102,7 @@ class AdHoc extends \Movim\Widget\Base
'http://jabber.org/protocol/admin#get-user-roster' => 'zmdi-format-list-bulleted',
'http://jabber.org/protocol/admin#get-online-users' => 'zmdi-trending-up',
'http://jabber.org/protocol/admin#announce' => 'zmdi-notifications',
);
];
if(array_key_exists($command, $icons)) {
return $icons[$command];

4
app/widgets/AdminDB/AdminDB.php

@ -10,7 +10,7 @@ class AdminDB extends \Movim\Widget\Base
{
$md = \modl\Modl::getInstance();
$md->check(true);
RPC::call('MovimUtils.reloadThis');
$this->rpc('MovimUtils.reloadThis');
}
public function hidePassword($pass)
@ -20,7 +20,7 @@ class AdminDB extends \Movim\Widget\Base
function display()
{
$md = \modl\Modl::getInstance();
$md = \Modl\Modl::getInstance();
$infos = $md->check();
$errors = '';

3
app/widgets/AdminLogin/AdminLogin.php

@ -1,6 +1,7 @@
<?php
class AdminLogin extends \Movim\Widget\Base {
class AdminLogin extends \Movim\Widget\Base
{
function load()
{
}

12
app/widgets/AdminMain/AdminMain.php

@ -2,11 +2,12 @@
class AdminMain extends \Movim\Widget\Base
{
function load() {
function load()
{
$this->addjs('admin.js');
$form = $_POST;
$cd = new \Modl\ConfigDAO();
$cd = new \Modl\ConfigDAO;
$config = $cd->get();
if(isset($form) && !empty($form)) {
@ -54,12 +55,11 @@ class AdminMain extends \Movim\Widget\Base
$l = Movim\i18n\Locale::start();
$this->view->assign('conf', $cd->get());
$this->view->assign('logs',
array(
$this->view->assign('logs', [
0 => $this->__('log.empty'),
1 => $this->__('log.syslog'),
2 => $this->__('log.syslog_files'))
);
2 => $this->__('log.syslog_files')
]);
$this->view->assign('bosh_info4',
$this->__('bosh.info4', '<a href="http://wiki.movim.eu/en:install">', '</a>'));

3
app/widgets/AdminTest/AdminTest.php

@ -2,7 +2,8 @@
class AdminTest extends \Movim\Widget\Base
{
function load() {
function load()
{
$this->addjs('admintest.js');
$this->addcss('admintest.css');
}

4
app/widgets/Api/Api.php

@ -48,7 +48,7 @@ class Api extends \Movim\Widget\Base
$json = json_decode($json);
if(isset($json) && $json->status == 200) {
RPC::call('MovimUtils.reloadThis');
$this->rpc('MovimUtils.reloadThis');
Notification::append(null, $this->__('api.conf_updated'));
}
}
@ -61,6 +61,6 @@ class Api extends \Movim\Widget\Base
$config->unregister = !$config->unregister;
$cd->set($config);
RPC::call('MovimUtils.reloadThis');
$this->rpc('MovimUtils.reloadThis');
}
}

6
app/widgets/Avatar/Avatar.php

@ -24,7 +24,7 @@ class Avatar extends \Movim\Widget\Base
$me = $packet->content;
$html = $this->prepareForm($me);
RPC::call('MovimTpl.fill', '#avatar_form', $html);
$this->rpc('MovimTpl.fill', '#avatar_form', $html);
Notification::append(null, $this->__('avatar.updated'));
}
@ -34,7 +34,7 @@ class Avatar extends \Movim\Widget\Base
$me = $cd->get();
$html = $this->prepareForm($me);
RPC::call('MovimTpl.fill', '#avatar_form', $html);
$this->rpc('MovimTpl.fill', '#avatar_form', $html);
Notification::append(null, $this->__('avatar.not_updated'));
}
@ -70,7 +70,7 @@ class Avatar extends \Movim\Widget\Base
$cd = new \Modl\ContactDAO;
$me = $cd->get();
RPC::call('MovimTpl.fill', '#avatar_form', $this->prepareForm($me));
$this->rpc('MovimTpl.fill', '#avatar_form', $this->prepareForm($me));
}
function ajaxSubmit($avatar)

6
app/widgets/Caps/Caps.php

@ -5,11 +5,13 @@ class Caps extends \Movim\Widget\Base
private $_table = [];
private $_nslist;
function load() {
function load()
{
$this->addcss('caps.css');
}
function isImplemented($client, $key) {
function isImplemented($client, $key)
{
if(in_array($this->_nslist[$key]['ns'], $client)) {
return '
<td

50
app/widgets/Chat/Chat.php

@ -106,7 +106,7 @@ class Chat extends \Movim\Widget\Base
4);
}
RPC::call('MovimTpl.fill', '#' . cleanupId($from.'_state'), $contact->jid);
$this->rpc('MovimTpl.fill', '#' . cleanupId($from.'_state'), $contact->jid);
} else {
// If the message is from me we reset the notif counter
$from = $message->jidto;
@ -114,7 +114,7 @@ class Chat extends \Movim\Widget\Base
$n->ajaxClear('chat|'.$from);
}
if(!preg_match('#^\?OTR#', $message->body)) {
RPC::call('Chat.appendMessagesWrapper', $this->prepareMessage($message, $from));
$this->rpc('Chat.appendMessagesWrapper', $this->prepareMessage($message, $from));
}
}
@ -178,7 +178,7 @@ class Chat extends \Movim\Widget\Base
$html = $view->draw('_chat_state', true);
RPC::call('MovimTpl.fill', '#' . cleanupId($jid.'_state'), $html);
$this->rpc('MovimTpl.fill', '#' . cleanupId($jid.'_state'), $html);
}
/**
@ -188,10 +188,10 @@ class Chat extends \Movim\Widget\Base
function ajaxGet($jid = null)
{
if($jid == null) {
RPC::call('MovimUtils.pushState', $this->route('chat'));
$this->rpc('MovimUtils.pushState', $this->route('chat'));
RPC::call('MovimUtils.removeClass', '#chat_widget', 'fixed');
RPC::call('MovimTpl.fill', '#chat_widget', $this->prepareEmpty());
$this->rpc('MovimUtils.removeClass', '#chat_widget', 'fixed');
$this->rpc('MovimTpl.fill', '#chat_widget', $this->prepareEmpty());
} else {
$chats = new Chats;
$chats->ajaxGetHistory($jid);
@ -201,12 +201,12 @@ class Chat extends \Movim\Widget\Base
$html = $this->prepareChat($jid);
RPC::call('MovimUtils.pushState', $this->route('chat', $jid));
$this->rpc('MovimUtils.pushState', $this->route('chat', $jid));
RPC::call('MovimUtils.addClass', '#chat_widget', 'fixed');
RPC::call('MovimTpl.fill', '#chat_widget', $html);
RPC::call('Chat.focus', $jid);
RPC::call('MovimTpl.showPanel');
$this->rpc('MovimUtils.addClass', '#chat_widget', 'fixed');
$this->rpc('MovimTpl.fill', '#chat_widget', $html);
$this->rpc('Chat.focus', $jid);
$this->rpc('MovimTpl.showPanel');
$this->prepareMessages($jid);
}
@ -235,25 +235,25 @@ class Chat extends \Movim\Widget\Base
if($r) {
$rooms = new Rooms;
if(!$rooms->checkConnected($r->conference, $r->nick)) {
RPC::call('Rooms_ajaxJoin', $r->conference, $r->nick);
$this->rpc('Rooms_ajaxJoin', $r->conference, $r->nick);
}
$html = $this->prepareChat($room, true);
RPC::call('MovimUtils.pushState', $this->route('chat', [$room, 'room']));
$this->rpc('MovimUtils.pushState', $this->route('chat', [$room, 'room']));
RPC::call('MovimUtils.addClass', '#chat_widget', 'fixed');
RPC::call('MovimTpl.fill', '#chat_widget', $html);
RPC::call('MovimTpl.showPanel');
RPC::call('Chat.focus');
$this->rpc('MovimUtils.addClass', '#chat_widget', 'fixed');
$this->rpc('MovimTpl.fill', '#chat_widget', $html);
$this->rpc('MovimTpl.showPanel');
$this->rpc('Chat.focus');
$this->prepareMessages($room, true);
$notif = new Notification;
$notif->ajaxClear('chat|'.$room);
RPC::call('Notification.current', 'chat|'.$room);
$this->rpc('Notification.current', 'chat|'.$room);
} else {
RPC::call('Rooms_ajaxAdd', $room);
$this->rpc('Rooms_ajaxAdd', $room);
}
}
@ -375,7 +375,7 @@ class Chat extends \Movim\Widget\Base
if(!isset($m->sticker)
&& !isset($m->file)) {
RPC::call('Chat.setTextarea', $m->body);
$this->rpc('Chat.setTextarea', $m->body);
}
}
@ -425,7 +425,7 @@ class Chat extends \Movim\Widget\Base
$this->prepareMessage($message);
}
}
RPC::call('Chat.appendMessagesWrapper', $this->_wrapper, true);
$this->rpc('Chat.appendMessagesWrapper', $this->_wrapper, true);
$this->_wrapper = [];
}
}
@ -580,10 +580,10 @@ class Chat extends \Movim\Widget\Base
$date = $view->draw('_chat_date', true);
RPC::call('Chat.setBubbles', $left, $right, $room, $date);
RPC::call('Chat.appendMessagesWrapper', $this->_wrapper);
RPC::call('MovimTpl.scrollPanel');
RPC::call('Chat.clearReplace');
$this->rpc('Chat.setBubbles', $left, $right, $room, $date);
$this->rpc('Chat.appendMessagesWrapper', $this->_wrapper);
$this->rpc('MovimTpl.scrollPanel');
$this->rpc('Chat.clearReplace');
}
function prepareMessage(&$message, $jid = null)

24
app/widgets/Chats/Chats.php

@ -42,8 +42,8 @@ class Chats extends \Movim\Widget\Base
$c = $contacts[0];
$chats = \Movim\Cache::c('chats');
if(is_array($chats) && array_key_exists($c->jid, $chats)) {
RPC::call('MovimTpl.replace', '#' . cleanupId($c->jid.'_chat_item'), $this->prepareChat($c->jid));
RPC::call('Chats.refresh');
$this->rpc('MovimTpl.replace', '#' . cleanupId($c->jid.'_chat_item'), $this->prepareChat($c->jid));
$this->rpc('Chats.refresh');
$n = new Notification;
$n->ajaxGet();
@ -70,14 +70,14 @@ class Chats extends \Movim\Widget\Base
$jid = $from;
}
RPC::call('MovimTpl.replace', '#' . cleanupId($jid.'_chat_item'), $this->prepareChat($jid, $message));
RPC::call('Chats.refresh');
$this->rpc('MovimTpl.replace', '#' . cleanupId($jid.'_chat_item'), $this->prepareChat($jid, $message));
$this->rpc('Chats.refresh');
}
function ajaxGet()
{
RPC::call('MovimTpl.fill', '#chats_widget_list', $this->prepareChats());
RPC::call('Chats.refresh');
$this->rpc('MovimTpl.fill', '#chats_widget_list', $this->prepareChats());
$this->rpc('Chats.refresh');
}
/**
@ -131,7 +131,7 @@ class Chats extends \Movim\Widget\Base
if($history) $this->ajaxGetHistory($jid);
\Movim\Cache::c('chats', $chats);
RPC::call('Chats.prepend', $jid, $this->prepareChat($jid));
$this->rpc('Chats.prepend', $jid, $this->prepareChat($jid));
}
}
@ -143,11 +143,11 @@ class Chats extends \Movim\Widget\Base
unset($chats[$jid]);
\Movim\Cache::c('chats', $chats);
RPC::call('MovimTpl.remove', '#' . cleanupId($jid . '_chat_item'));
$this->rpc('MovimTpl.remove', '#' . cleanupId($jid . '_chat_item'));
RPC::call('Chats.refresh');
RPC::call('Chat.empty');
RPC::call('MovimTpl.hidePanel');
$this->rpc('Chats.refresh');
$this->rpc('Chat.empty');
$this->rpc('MovimTpl.hidePanel');
}
/**
@ -180,7 +180,7 @@ class Chats extends \Movim\Widget\Base
$contacts = $cd->getRosterSimple();
$view->assign('contacts', $contacts);
RPC::call('MovimTpl.fill', '#add_extend', $view->draw('_chats_add_extend', true));
$this->rpc('MovimTpl.fill', '#add_extend', $view->draw('_chats_add_extend', true));
}
function prepareChats()

2
app/widgets/Chats/_chats_item.tpl

@ -3,7 +3,7 @@
data-jid="{$contact->jid}"
class="
{if="isset($message)"}condensed{/if}
{if="$contact->last > 60"} inactive{/if}
{if="isset($contact->last) && $contact->last > 60"} inactive{/if}
{if="$caps && in_array($caps->type, array('handheld', 'phone', 'web'))"}
action
{/if}

2
app/widgets/Communities/Communities.php

@ -29,7 +29,7 @@ class Communities extends \Movim\Widget\Base
function ajaxGet()
{
RPC::call('MovimTpl.fill', '#communities', $this->prepareCommunities());
$this->rpc('MovimTpl.fill', '#communities', $this->prepareCommunities());
}
function prepareCommunities()

6
app/widgets/CommunitiesServer/CommunitiesServer.php

@ -33,7 +33,7 @@ class CommunitiesServer extends \Movim\Widget\Base
{
$server = $packet->content;
RPC::call('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server));
$this->rpc('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server));
}
function onDiscoError($packet)
@ -43,7 +43,7 @@ class CommunitiesServer extends \Movim\Widget\Base
$id = new \Modl\ItemDAO();
$id->deleteItems($server);
RPC::call('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server));
$this->rpc('MovimTpl.fill', '#communities_server', $this->prepareCommunitiesServer($server));
Notification::append(null, $this->__('communitiesserver.disco_error'));
}
@ -70,7 +70,7 @@ class CommunitiesServer extends \Movim\Widget\Base
return;
}
RPC::call('MovimTpl.fill', '#communities_server', '');
$this->rpc('MovimTpl.fill', '#communities_server', '');
$r = new Items;
$r->setTo($server)->request();

2
app/widgets/CommunityHeader/CommunityHeader.php

@ -30,7 +30,7 @@ class CommunityHeader extends \Movim\Widget\Base
{
list($server, $node) = $packet->content;
RPC::call('MovimTpl.fill', '#community_header', $this->prepareHeader($server, $node));
$this->rpc('MovimTpl.fill', '#community_header', $this->prepareHeader($server, $node));
}
function onTestPublish($packet)

14
app/widgets/CommunityPosts/CommunityPosts.php

@ -26,8 +26,8 @@ class CommunityPosts extends \Movim\Widget\Base
{
list($server, $node, $id) = array_values($packet->content);
/*
RPC::call('MovimTpl.fill', '#'.cleanupId($id), $this->preparePost($server, $node, $id));
RPC::call('MovimUtils.enableVideos');*/
$this->rpc('MovimTpl.fill', '#'.cleanupId($id), $this->preparePost($server, $node, $id));
$this->rpc('MovimUtils.enableVideos');*/
$this->displayItems($server, $node);
}
@ -66,8 +66,8 @@ class CommunityPosts extends \Movim\Widget\Base
$html = $this->prepareCommunity($server, $node, 0, $ids);
$slugify = new Slugify;
RPC::call('MovimTpl.fill', '#communityposts.'.$slugify->slugify($server.'_'.$node), $html);
RPC::call('MovimUtils.enableVideos');
$this->rpc('MovimTpl.fill', '#communityposts.'.$slugify->slugify($server.'_'.$node), $html);
$this->rpc('MovimUtils.enableVideos');
}
function ajaxGetContact($jid)
@ -91,14 +91,14 @@ class CommunityPosts extends \Movim\Widget\Base
function ajaxGetHistory($server, $node, $page)
{
$html = $this->prepareCommunity($server, $node, $page);
RPC::call('MovimTpl.append', '#communityposts', $html);
RPC::call('MovimUtils.enableVideos');
$this->rpc('MovimTpl.append', '#communityposts', $html);
$this->rpc('MovimUtils.enableVideos');
}
function ajaxClear()
{
$html = $this->prepareEmpty();
RPC::call('MovimTpl.fill', '#communityposts', $html);
$this->rpc('MovimTpl.fill', '#communityposts', $html);
}
function prepareEmpty()

4
app/widgets/Config/Config.php

@ -67,8 +67,8 @@ class Config extends \Movim\Widget\Base
{
$html = $this->prepareConfigForm();
RPC::call('MovimTpl.fill', '#config_widget', $html);
RPC::call('Config.load');
$this->rpc('MovimTpl.fill', '#config_widget', $html);
$this->rpc('Config.load');
}
private function validateForm($data)

20
app/widgets/Contact/Contact.php

@ -43,15 +43,15 @@ class Contact extends \Movim\Widget\Base
$view->assign('subscriptions', $items);
RPC::call('MovimTpl.fill', '#contact_subscriptions', $view->draw('_contact_subscriptions', true));
$this->rpc('MovimTpl.fill', '#contact_subscriptions', $view->draw('_contact_subscriptions', true));
}
function ajaxClear($page = 0)
{
$html = $this->prepareEmpty($page);
RPC::call('MovimUtils.pushState', $this->route('contact'));
RPC::call('MovimTpl.fill', '#contact_widget', $html);
$this->rpc('MovimUtils.pushState', $this->route('contact'));
$this->rpc('MovimTpl.fill', '#contact_widget', $html);
}
function ajaxGetContact($jid, $page = 0)
@ -62,10 +62,10 @@ class Contact extends \Movim\Widget\Base
$this->ajaxRefreshSubscriptions($jid);
RPC::call('MovimUtils.pushState', $this->route('contact', $jid));
$this->rpc('MovimUtils.pushState', $this->route('contact', $jid));
RPC::call('MovimTpl.fill', '#contact_widget', $html);
RPC::call('MovimTpl.showPanel');
$this->rpc('MovimTpl.fill', '#contact_widget', $html);
$this->rpc('MovimTpl.showPanel');
$r = new GetItemsId;
$r->setTo($jid)
@ -83,7 +83,7 @@ class Contact extends \Movim\Widget\Base
$view->assign('jid', $jid);
$view->assign('gallery', $pd->getGallery($jid, 0, 20));
RPC::call('MovimTpl.fill', '#contact_tab', $view->draw('_contact_gallery', true));
$this->rpc('MovimTpl.fill', '#contact_tab', $view->draw('_contact_gallery', true));
}
function ajaxGetBlog($jid)
@ -96,7 +96,7 @@ class Contact extends \Movim\Widget\Base
$view->assign('jid', $jid);
$view->assign('blog', $pd->getPublic($jid, 'urn:xmpp:microblog:0', 0, 18));
RPC::call('MovimTpl.fill', '#contact_tab', $view->draw('_contact_blog', true));
$this->rpc('MovimTpl.fill', '#contact_tab', $view->draw('_contact_blog', true));
}
function ajaxGetDrawer($jid)
@ -196,7 +196,7 @@ class Contact extends \Movim\Widget\Base
$c = new Chats;
$c->ajaxOpen($jid);
RPC::call('MovimUtils.redirect', $this->route('chat', $jid));
$this->rpc('MovimUtils.redirect', $this->route('chat', $jid));
}
function ajaxDeleteContact($jid)
@ -234,7 +234,7 @@ class Contact extends \Movim\Widget\Base
$validate_page = Validator::intType();
if(!$validate_page->validate($page)) return;
RPC::call('MovimTpl.fill', '#public_list', $this->preparePublic($page));
$this->rpc('MovimTpl.fill', '#public_list', $this->preparePublic($page));
}
private function preparePublic($page = 0)

2
app/widgets/Dialog/Dialog.php

@ -1,5 +1,7 @@
<?php
use Movim\RPC;
class Dialog extends \Movim\Widget\Base
{
function load()

2
app/widgets/Drawer/Drawer.php

@ -1,5 +1,7 @@
<?php
use Movim\RPC;
class Drawer extends \Movim\Widget\Base
{
function load()

14
app/widgets/Help/Help.php

@ -2,28 +2,26 @@
class Help extends \Movim\Widget\Base
{
function load()
function load()
{
}
function ajaxAddChatroom()
{
$r = new Rooms;
$r->ajaxChatroomAdd(
array(
$r->ajaxChatroomAdd([
'jid' => 'movim@conference.movim.eu',
'name'=> 'Movim Chatroom',
'nick' => false,
'autojoin' => 0
)
);
]);
$r->ajaxJoin('movim@conference.movim.eu');
RPC::call('MovimUtils.redirect', $this->route('chat'));
$this->rpc('MovimUtils.redirect', $this->route('chat'));
}
function display()
function display()
{
}
}

32
app/widgets/Infos/Infos.php

@ -2,8 +2,8 @@
class Infos extends \Movim\Widget\Base
{
function load() {
function load()
{
}
function display()
@ -21,20 +21,20 @@ class Infos extends \Movim\Widget\Base
$connected = (int)requestURL('http://localhost:1560/started/', 2);
$infos = array(
'url' => BASE_URI,
'language' => $config->locale,
'whitelist' => $config->xmppwhitelist,
'timezone' => $config->timezone,
'description' => $config->description,
'unregister' => $config->unregister,
'php_version' => phpversion(),
'version' => APP_VERSION,
'population' => $pop,
'linked' => (int)requestURL('http://localhost:1560/linked/', 2),
'started' => $connected,
'connected' => $connected
);
$infos = [
'url' => BASE_URI,
'language' => $config->locale,
'whitelist' => $config->xmppwhitelist,
'timezone' => $config->timezone,
'description' => $config->description,
'unregister' => $config->unregister,
'php_version' => phpversion(),
'version' => APP_VERSION,
'population' => $pop,
'linked' => (int)requestURL('http://localhost:1560/linked/', 2),
'started' => $connected,
'connected' => $connected
];
$this->view->assign('json', json_encode($infos));
}

2
app/widgets/Init/Init.php

@ -22,7 +22,7 @@ class Init extends \Movim\Widget\Base
function onConfigured($package)
{
$node = $package->content;
RPC::call('Init.setNode', $node);
$this->rpc('Init.setNode', $node);
}
private function createPersistentStorage($node)

2
app/widgets/Invitations/Invitations.php

@ -23,7 +23,7 @@ class Invitations extends \Movim\Widget\Base
function onInvitations($from = false)
{
$html = $this->prepareInvitations();
RPC::call('MovimTpl.fill', '#invitations_widget', $html);
$this->rpc('MovimTpl.fill', '#invitations_widget', $html);
if(is_string($from)) {
$cd = new \Modl\ContactDAO;

14
app/widgets/Login/Login.php

@ -3,6 +3,7 @@
use Moxl\Xec\Action\Storage\Get;
use Moxl\Xec\Action\Roster\GetList;
use Respect\Validation\Validator;
use Movim\Cookie;
class Login extends \Movim\Widget\Base
{
@ -90,8 +91,8 @@ class Login extends \Movim\Widget\Base
function showErrorBlock($error)
{
RPC::call('MovimTpl.fill', '#error', $this->prepareError($error));
RPC::call('MovimUtils.addClass', '#login_widget', 'error');
$this->rpc('MovimTpl.fill', '#error', $this->prepareError($error));
$this->rpc('MovimUtils.addClass', '#login_widget', 'error');
}
function prepareError($error = 'default')
@ -186,15 +187,12 @@ class Login extends \Movim\Widget\Base
return;
}
// TODO Clean me
$se = Sessionx::start();
// We check if we already have an open session
$sd = new \Modl\SessionxDAO;
$here = $sd->getHash(sha1($username.$password.$host));
if($here) {
$this->rpc('Login.setCookie', $here->session, date(DATE_COOKIE, $se->getTime()));
$this->rpc('Login.setCookie', $here->session, date(DATE_COOKIE, Cookie::getTime()));
$this->rpc('MovimUtils.redirect', $this->route('main'));
return;
}
@ -236,7 +234,7 @@ class Login extends \Movim\Widget\Base
$sessionshtml->assign('sessions', $sessions_grabbed);
$sessionshtml->assign('empty', new \Modl\Contact);
RPC::call('MovimTpl.fill', '#sessions', $sessionshtml->draw('_login_sessions', true));
RPC::call('Login.refresh');
$this->rpc('MovimTpl.fill', '#sessions', $sessionshtml->draw('_login_sessions', true));
$this->rpc('Login.refresh');
}
}

9
app/widgets/LoginAnonymous/LoginAnonymous.php

@ -38,15 +38,16 @@ class LoginAnonymous extends \Movim\Widget\Base
$domain = \Moxl\Utils::getDomain($host);
// We launch the XMPP socket
RPC::call('register', $host);
$this->rpc('register', $host);
// We set the username in the session
$s = Session::start();
$s->set('username', $username);
// We create a new session or clear the old one
$s = Sessionx::start();
$s->init($username, $password, $host, $domain);
$s = new \Modl\Sessionx;
$s->init($username, $password, $host);
$s->loadMemory();
$sd->set($s);
\Moxl\Stanza\Stream::init($host);
}

2
app/widgets/Notification/Notification.php

@ -1,5 +1,7 @@
<?php
use Movim\RPC;
class Notification extends \Movim\Widget\Base
{
function load()

22
app/widgets/Post/Post.php

@ -33,10 +33,10 @@ class Post extends \Movim\Widget\Base
if($p) {
$html = $this->preparePost($p);
RPC::call('MovimUtils.pushState', $this->route('news', [$p->origin, $p->node, $p->nodeid]));
$this->rpc('MovimUtils.pushState', $this->route('news', [$p->origin, $p->node, $p->nodeid]));
RPC::call('MovimTpl.fill', '#post_widget', $html);
RPC::call('MovimUtils.enableVideos');
$this->rpc('MovimTpl.fill', '#post_widget', $html);
$this->rpc('MovimUtils.enableVideos');
}
}
}
@ -86,23 +86,23 @@ class Post extends \Movim\Widget\Base
$view->assign('id', $id);
$html = $view->draw('_post_comments', true);
RPC::call('MovimTpl.fill', '#comments', $html);
$this->rpc('MovimTpl.fill', '#comments', $html);
}
function onCommentsError($packet)
{
$view = $this->tpl();
$html = $view->draw('_post_comments_error', true);
RPC::call('MovimTpl.fill', '#comments', $html);
$this->rpc('MovimTpl.fill', '#comments', $html);
}
function ajaxClear()
{
RPC::call('MovimUtils.pushState', $this->route('news'));
$this->rpc('MovimUtils.pushState', $this->route('news'));
RPC::call('MovimTpl.fill', '#post_widget', $this->prepareEmpty());
RPC::call('Menu.refresh');
//RPC::call('Menu_ajaxGetAll');
$this->rpc('MovimTpl.fill', '#post_widget', $this->prepareEmpty());
$this->rpc('Menu.refresh');
//$this->rpc('Menu_ajaxGetAll');
}
function ajaxGetContact($jid)
@ -119,8 +119,8 @@ class Post extends \Movim\Widget\Base
if($p) {
$html = $this->preparePost($p);
RPC::call('MovimTpl.fill', '#post_widget', $html);
RPC::call('MovimUtils.enableVideos');
$this->rpc('MovimTpl.fill', '#post_widget', $html);
$this->rpc('MovimUtils.enableVideos');
// If the post is a reply but we don't have the original
if($p->isReply() && !$p->getReply()) {

18
app/widgets/Publish/Publish.php

@ -109,11 +109,11 @@ class Publish extends \Movim\Widget\Base
$view->assign('item', $item);*/
if($id) {
RPC::call('Publish.initEdit');
$this->rpc('Publish.initEdit');
}
if($session->get('share_url')) {
RPC::call('Publish.setEmbed');
$this->rpc('Publish.setEmbed');
}
}
@ -157,7 +157,7 @@ class Publish extends \Movim\Widget\Base
$session = \Session::start();
$session->remove('share_url');
RPC::call('Publish.clearEmbed');
$this->rpc('Publish.clearEmbed');
}
function ajaxHelp()
@ -207,7 +207,7 @@ class Publish extends \Movim\Widget\Base
function ajaxPublish($form)
{
RPC::call('Publish.disableSend');
$this->rpc('Publish.disableSend');
if(Validator::stringType()->notEmpty()->validate(trim($form->title->value))) {
$p = new PostPublish;
@ -293,7 +293,7 @@ class Publish extends \Movim\Widget\Base
$p->request();
} else {
RPC::call('Publish.enableSend');
$this->rpc('Publish.enableSend');
Notification::append(false, $this->__('publish.no_title'));
}
}
@ -311,15 +311,15 @@ class Publish extends \Movim\Widget\Base
$embed = Embed\Embed::create($url);
$html = $this->prepareEmbed($embed);
RPC::call('MovimTpl.fill', '#preview', '');
RPC::call('MovimTpl.fill', '#gallery', '');
$this->rpc('MovimTpl.fill', '#preview', '');
$this->rpc('MovimTpl.fill', '#gallery', '');
if(in_array($embed->type, ['photo', 'rich'])) {
RPC::call('MovimTpl.fill', '#gallery', $this->prepareGallery($embed));
$this->rpc('MovimTpl.fill', '#gallery', $this->prepareGallery($embed));
}
if($embed->type !== 'photo') {
RPC::call('MovimTpl.fill', '#preview', $html);
$this->rpc('MovimTpl.fill', '#preview', $html);
}
} catch(Exception $e) {
error_log($e->getMessage());

8
app/widgets/Rooms/Rooms.php

@ -40,7 +40,7 @@ class Rooms extends \Movim\Widget\Base
function onBookmark()
{
$this->refreshRooms();
RPC::call('MovimTpl.hidePanel');
$this->rpc('MovimTpl.hidePanel');
}
function onConnected()
@ -65,8 +65,8 @@ class Rooms extends \Movim\Widget\Base
private function refreshRooms($edit = false)
{
RPC::call('MovimTpl.fill', '#rooms_widget', $this->prepareRooms($edit));
RPC::call('Rooms.refresh');
$this->rpc('MovimTpl.fill', '#rooms_widget', $this->prepareRooms($edit));
$this->rpc('Rooms.refresh');
}
/**
@ -213,7 +213,7 @@ class Rooms extends \Movim\Widget\Base
'jid' => strtolower($form['jid'])
];
$this->setBookmark($item);
RPC::call('Dialog_ajaxClear');
$this->rpc('Dialog_ajaxClear');
}
}

8
app/widgets/Roster/Roster.php

@ -22,7 +22,7 @@ class Roster extends \Movim\Widget\Base
function onChange($packet)
{
RPC::call(
$this->rpc(
'MovimTpl.fill',
'#roster',
$this->prepareItems()
@ -44,7 +44,7 @@ class Roster extends \Movim\Widget\Base
$html = $this->prepareItem($cd->getRoster($contact->jid)[0]);
if($html) {
RPC::call('MovimTpl.replace', '#'.cleanupId($contact->jid), $html);
$this->rpc('MovimTpl.replace', '#'.cleanupId($contact->jid), $html);
}
}
}
@ -116,7 +116,7 @@ class Roster extends \Movim\Widget\Base
$view->assign('contacts', $contacts);
$html = $view->draw('_roster_search_results', true);
RPC::call('MovimTpl.fill', '#search_results', $html);
$this->rpc('MovimTpl.fill', '#search_results', $html);
}
}
@ -157,7 +157,7 @@ class Roster extends \Movim\Widget\Base
function ajaxSearchContact($jid)
{
if(filter_var($jid, FILTER_VALIDATE_EMAIL)) {
RPC::call('MovimUtils.redirect', $this->route('contact', $jid));
$this->rpc('MovimUtils.redirect', $this->route('contact', $jid));
} else
Notification::append(null, $this->__('roster.jid_error'));
}

4
app/widgets/Search/Search.php

@ -22,7 +22,7 @@ class Search extends \Movim\Widget\Base
$view->assign('presencestxt', getPresencesTxt());
Drawer::fill($view->draw('_search', true), true);
RPC::call('Search.init');
$this->rpc('Search.init');
}
function prepareSearch($key)
@ -53,7 +53,7 @@ class Search extends \Movim\Widget\Base
function ajaxSearch($key)
{
RPC::call('MovimTpl.fill', '#results', $this->prepareSearch($key));
$this->rpc('MovimTpl.fill', '#results', $this->prepareSearch($key));
}
function ajaxChat($jid)

6
app/widgets/Share/Share.php

@ -17,19 +17,19 @@ class Share extends \Movim\Widget\Base
&& substr($link, 0, 4) == 'http') {
$session = \Session::start();
$session->set('share_url', $link);
RPC::call('Share.redirect', $this->route('publish'));
$this->rpc('Share.redirect', $this->route('publish'));
} elseif(substr($link, 0, 5) == 'xmpp:') {
$link = str_replace(['xmpp://', 'xmpp:'], '', $link);
if(substr($link, -5, 5) == '?join') {
RPC::call(
$this->rpc(
'MovimUtils.redirect',
$this->route(
'chat', [str_replace('?join', '', $link), 'room']
)
);
} else {
RPC::call(
$this->rpc(
'MovimUtils.redirect',
$this->route(
'contact', $link

2
app/widgets/Statistics/Statistics.php

@ -59,7 +59,7 @@ class Statistics extends \Movim\Widget\Base
array_push($data->datasets, $first);
RPC::call('Statistics.drawGraphs', $data);
$this->rpc('Statistics.drawGraphs', $data);
}
function display()

7
app/widgets/System/System.php

@ -19,15 +19,16 @@ class System extends \Movim\Widget\Base
$r = new Route;
$this->view->assign('current_page', $r->find());
if(!isset($_SERVER['HTTP_MOD_REWRITE']) || !$_SERVER['HTTP_MOD_REWRITE'])
if(!isset($_SERVER['HTTP_MOD_REWRITE']) || !$_SERVER['HTTP_MOD_REWRITE']) {
$this->view->assign('page_key_uri', '?q=');
else
} else {
$this->view->assign('page_key_uri', '');
}
$this->view->assign('secure_websocket', file_get_contents(CACHE_PATH.'websocket'));
// And we load some public values of the system configuration
$cd = new \Modl\ConfigDAO();
$cd = new \Modl\ConfigDAO;
$config = $cd->get();
$public_conf = [

1
app/widgets/Tabs/Tabs.php

@ -4,7 +4,6 @@ class Tabs extends \Movim\Widget\Base
{
function load()
{
//$this->addcss('tabs.css');
$this->addjs('tabs.js');
}
}

58
app/widgets/Tabs/tabs.css

@ -1,58 +0,0 @@
#navtabs {
list-style-type: none;
margin: 0px;
padding: 0px;
text-align: center;
border-bottom: 1px solid #DCDCDC;
overflow: hidden;
background-color: white;
}
#navtabs li {
display: inline-block;
cursor: pointer;
white-space: nowrap;
font-weight: bold;
padding: 0em 1em;
transition: background 0.5s;
}
#navtabs li.disabled {
pointer-events: none;
opacity: 0.5;
}
#navtabs li a {
display: block;
line-height: 3em;
padding: 0em 1em;
width:100%;
text-decoration: none;
color: #555;
border-bottom: 2px solid transparent;
}
#navtabs li:hover a {
border-bottom: 2px solid #EEE;
}
#navtabs li.on a {
border-bottom: 2px solid #DCDCDC;
}
.tabelem{
position: relative;
}
.fixed_block{
background-color: white;
width: 880px;
}
.anchor{
display: block;
position: absolute;
}

2
app/widgets/Upload/Upload.php

@ -15,7 +15,7 @@ class Upload extends \Movim\Widget\Base
function onRequested($package)
{
list($get, $put) = array_values($package->content);
RPC::call('Upload.request', $get, $put);
$this->rpc('Upload.request', $get, $put);
}
function onErrorNotAcceptable()

4
app/widgets/Vcard4/Vcard4.php

@ -60,12 +60,12 @@ class Vcard4 extends \Movim\Widget\Base
Notification::append(null, $this->__('vcard.updated'));
RPC::call('MovimTpl.fill', '#vcard_form', $html);
$this->rpc('MovimTpl.fill', '#vcard_form', $html);
}
function onMyVcard4Received()
{
RPC::call('MovimUtils.buttonReset', '#vcard4validate');
$this->rpc('MovimUtils.buttonReset', '#vcard4validate');
Notification::append(null, $this->__('vcard.updated'));
}

10
app/widgets/Visio/Visio.php

@ -24,14 +24,14 @@ class Visio extends \Movim\Widget\Base
$s = Session::start();
$s->set('sdp', $jts->generate());
RPC::call('VisioLink.openVisio', $from);
$this->rpc('VisioLink.openVisio', $from);
}
function ajaxGetSDP()
{
$s = Session::start();
if($s->get('sdp')) {
RPC::call('Visio.onSDP', $s->get('sdp'), 'offer');
$this->rpc('Visio.onSDP', $s->get('sdp'), 'offer');
$s->remove('sdp');
}
}
@ -40,7 +40,7 @@ class Visio extends \Movim\Widget\Base
{
$jts = new JingletoSDP($stanza);
RPC::call('Visio.onSDP', $jts->generate(), 'answer');
$this->rpc('Visio.onSDP', $jts->generate(), 'answer');
}
function onCandidate($stanza)
@ -65,7 +65,7 @@ class Visio extends \Movim\Widget\Base
if(is_array($candidates)) {
foreach($candidates as $candidate) {
RPC::call('Visio.onCandidate', $candidate[0], $candidate[1], $candidate[2]);
$this->rpc('Visio.onCandidate', $candidate[0], $candidate[1], $candidate[2]);
}
}
@ -74,7 +74,7 @@ class Visio extends \Movim\Widget\Base
function onTerminate($stanza)
{
RPC::call('Visio.onTerminate');
$this->rpc('Visio.onTerminate');
}
function ajaxInitiate($sdp, $to)

2
composer.json

@ -17,7 +17,7 @@
"movim/modl": "dev-master#3b4d032665c695781c5584602b2bd1403a957a72",
"movim/sasl2": "dev-master",
"movim/moxl": "dev-master#98ee0f4c5cba8ba64e07d2fab5a91dd7270d3cc9",
"movim/moxl": "dev-master#a1f8cd79053456ee39a4d6a18919015d111e234e",
"embed/embed": "dev-master",
"heyupdate/emoji": "dev-master",

12
composer.lock

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "865f453e88833dea8975bc51064067d8",
"content-hash": "053eb5fe6e81119bd7f9bcf04e54b095",
"hash": "61c4e85d50550147e92258e482ee8692",
"content-hash": "7610484300c7416dee9eb437b667f1dd",
"packages": [
{
"name": "cboden/ratchet",
@ -651,12 +651,12 @@
"source": {
"type": "git",
"url": "https://github.com/movim/moxl.git",
"reference": "98ee0f4c5cba8ba64e07d2fab5a91dd7270d3cc9"
"reference": "a1f8cd79053456ee39a4d6a18919015d111e234e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/movim/moxl/zipball/98ee0f4c5cba8ba64e07d2fab5a91dd7270d3cc9",
"reference": "98ee0f4c5cba8ba64e07d2fab5a91dd7270d3cc9",
"url": "https://api.github.com/repos/movim/moxl/zipball/a1f8cd79053456ee39a4d6a18919015d111e234e",
"reference": "a1f8cd79053456ee39a4d6a18919015d111e234e",
"shasum": ""
},
"require": {
@ -691,7 +691,7 @@
"php",
"xmpp"
],
"time": "2017-02-24 08:01:50"
"time": "2017-02-24 22:36:33"
},
{
"name": "movim/sasl2",

7
linker.php

@ -6,6 +6,7 @@ define('DOCUMENT_ROOT', dirname(__FILE__));
gc_enable();
use Movim\Bootstrap;
use Movim\RPC;
$bootstrap = new Bootstrap;
$booted = $bootstrap->boot();
@ -62,14 +63,14 @@ $loop->addPeriodicTimer(5, function() use(&$conn, &$timestamp) {
function writeOut()
{
$msg = \RPC::commit();
$msg = RPC::commit();
if(!empty($msg)) {
echo base64_encode(gzcompress(json_encode($msg), 9))."";
//fwrite(STDERR, colorize(json_encode($msg).' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n");
}
\RPC::clear();
RPC::clear();
}
function writeXMPP($xml)
@ -168,7 +169,7 @@ $stdin_behaviour = function ($data) use (&$conn, $loop, &$buffer, &$connector, &
break;
}
$rpc = new \RPC();
$rpc = new RPC;
$rpc->handle_json($msg);
writeOut();

4
src/Movim/Bootstrap.php

@ -182,8 +182,6 @@ class Bootstrap
private function loadSystem()
{
require_once(SYSTEM_PATH . "Session.php");
require_once(SYSTEM_PATH . "Sessionx.php");
require_once(SYSTEM_PATH . "RPC.php");
require_once(SYSTEM_PATH . "User.php");
}
@ -332,7 +330,7 @@ class Bootstrap
}
}
\Sessionx::start();
Cookie::set();
}
public function getWidgets()

4
src/Movim/Controller/Front.php

@ -4,6 +4,7 @@ namespace Movim\Controller;
use Monolog\Logger;
use Monolog\Handler\SyslogHandler;
use Movim\Route;
use Movim\Cookie;
class Front extends Base
{
@ -37,8 +38,7 @@ class Front extends Base
{
$c = $this->loadController($request);
$sess = \Sessionx::start();
$sess->refreshCookie();
Cookie::refresh();
if(is_callable([$c, 'load'])) {
$c->name = $request;

40
src/Movim/Cookie.php

@ -0,0 +1,40 @@
<?php
namespace Movim;
class Cookie
{
public static function set()
{
if(SESSION_ID == false) {
self::setCookie(generateKey(32));
} else {
self::setCookie(SESSION_ID);
}
}
public static function refresh()
{
if(isset($_COOKIE['MOVIM_SESSION_ID'])) {
self::setCookie($_COOKIE['MOVIM_SESSION_ID']);
}
}
public static function renew()
{
self::setCookie(generateKey(32));
}
public static function getTime()
{
return time()+604800;
}
private function setCookie($key)
{
if(!headers_sent()) {
header_remove('Set-Cookie');
setcookie("MOVIM_SESSION_ID", $key, self::getTime(), '/'/*, BASE_HOST, APP_SECURED*/);
}
}
}

3
system/RPC.php → src/Movim/RPC.php

@ -1,4 +1,7 @@
<?php
namespace Movim;
use Movim\Widget\Wrapper;
class RPC

3
src/Movim/Widget/Base.php

@ -1,4 +1,5 @@
<?php
namespace Movim\Widget;
use Rain\Tpl;
@ -106,7 +107,7 @@ class Base
function rpc()
{
return call_user_func_array('\RPC::call', func_get_args());
return call_user_func_array('\Movim\RPC::call', func_get_args());
}
function load() {}

54
system/Sessionx.php

@ -1,54 +0,0 @@
<?php
use Modl\SQL;
class Sessionx
{
protected static $_instance;
private $_max_age = 604800; // 24hour
private $_timestamp;
/*
* Session generation and handling part
*/
protected function __construct()
{
if(SESSION_ID == false) {
$this->setCookie(generateKey(32));
} elseif(!headers_sent()) {
$this->setCookie(SESSION_ID);
}
}
public function refreshCookie()
{
if(isset($_COOKIE['MOVIM_SESSION_ID'])) {
$this->setCookie($_COOKIE['MOVIM_SESSION_ID']);
}
}
public function renewCookie()
{
$this->setCookie(generateKey(32));
}
public function getTime()
{
return time()+$this->_max_age;
}
private function setCookie($key)
{
header_remove('Set-Cookie');
setcookie("MOVIM_SESSION_ID", $key, $this->getTime(), '/'/*, BASE_HOST, APP_SECURED*/);
}
public static function start()
{
if(!isset(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
}
}
Loading…
Cancel
Save